View Javadoc
1   package com.atlassian.plugin.parsers;
2   
3   import com.google.common.annotations.VisibleForTesting;
4   import io.atlassian.util.concurrent.LazyReference;
5   
6   import javax.annotation.Nonnull;
7   
8   import static java.lang.System.getProperty;
9   
10  /**
11   * This is used by the application this library is bundled with, it shouldn't be changed without also changing all the products it is bundled with.
12   */
13  public class DefaultSafeModeCommandLineArgumentsFactory implements SafeModeCommandLineArgumentsFactory {
14      private static final String PARAMETER_SYSTEM_PROPERTY = "atlassian.plugins.startup.options";
15      private LazyReference<SafeModeCommandLineArguments> safeModeCommandLineArguments = new LazyReference<SafeModeCommandLineArguments>() {
16          @Override
17          protected SafeModeCommandLineArguments create() throws Exception {
18              return new SafeModeCommandLineArguments(getProperty(PARAMETER_SYSTEM_PROPERTY, ""));
19          }
20      };
21  
22      /**
23       * The name of the system property that contains the startup parameters passed to start-<product>.sh
24       * (for example in the case <code>start-jira.sh -fg --disable-plugins=com.atlassian.xyz</code> this system property
25       * would be set to <code>-fg --disable-plugins=com.atlassian.xyz</code>
26       * This requires support from the host product
27       *
28       * @return The name of the system property
29       */
30      @VisibleForTesting
31      @Nonnull
32      String getParameterSystemProperty() {
33          return PARAMETER_SYSTEM_PROPERTY;
34      }
35  
36      @Override
37      public SafeModeCommandLineArguments get() {
38          return safeModeCommandLineArguments.get();
39      }
40  }