Class GlassFishProperties

java.lang.Object
org.glassfish.embeddable.GlassFishProperties

public class GlassFishProperties extends Object
Encapsulates the set of properties required to create a new GlassFish instance.
 ...
 GlassFishRuntime runtime = GlassFishRuntime.bootstrap(new BootstrapProperties());
 GlassFish glassfish = runtime.newGlassFish(glassFishProperties);
 ...
 
Author:
bhavanishankar@dev.java.net, Prasad.Subramanian@Sun.COM
  • Field Details

    • INSTANCE_ROOT_PROP_NAME

      public static final String INSTANCE_ROOT_PROP_NAME
      Key for specifying which instance root (aka domain dir) GlassFish should run with.
      See Also:
    • CONFIG_FILE_URI_PROP_NAME

      public static final String CONFIG_FILE_URI_PROP_NAME
      Key for specifying absolute URI which configuration file (domain.xml) GlassFish should run with.
      See Also:
    • CONFIG_FILE_READ_ONLY

      public static final String CONFIG_FILE_READ_ONLY
      Key for specifying whether the specified configuration file (domain.xml) or config/domain.xml at the user specified instanceRoot should be operated by GlassFish in read only mode or not.
      See Also:
  • Constructor Details

    • GlassFishProperties

      public GlassFishProperties()
      Create GlassFishProperties with default properties.
    • GlassFishProperties

      public GlassFishProperties(Properties props)
      Create GlassFishProperties with custom properties. This method does not take a copy of the passed in properties object; instead it just maintains a reference to it, so all semantics of "pass-by-reference" applies.

      Custom properties can include values for all or some of the keys defined as constants in this class. Eg., a value for com.sun.aas.instanceRoot can be included in the custom properties.

      Custom properties can also include additional properties which are required for the plugged in GlassFishRuntime (if any)

      Parameters:
      props - Properties object which will back this GlassFishProperties object.
  • Method Details

    • getProperties

      public Properties getProperties()
      Get the underlying Properties object which backs this GlassFishProperties.

      If getProperties().setProperty(key,value) is called, then it will add a property to this GlassFishProperties.

      Returns:
      The Properties object that is backing this GlassFishProperties.
    • setProperty

      public void setProperty(String key, String value)
      Set any custom glassfish property. May be required for the plugged in GlassFishRuntime (if any)
      Parameters:
      key - the key to be placed into this glassfish properties.
      value - the value corresponding to the key.
    • setInstanceRoot

      public void setInstanceRoot(String instanceRoot)
      Optionally set the instance root (aka domain dir) using which the GlassFish should run.

      Make sure to specify a valid GlassFish instance directory (eg., GF_INSTALL_DIR/domains/domain1).

      By default, the config/domain.xml at the specified instance root is operated in read only mode. To writeback changes to it, call setConfigFileReadOnly(boolean) by passing 'false'

      If the instance root is not specified, then a small sized temporary instance directory is created in the current directory. The temporary instance directory will get deleted when the glassfish.dispose() is called.

      Parameters:
      instanceRoot - Location of the instance root.
    • getInstanceRoot

      public String getInstanceRoot()
      Get the location instance root set using setInstanceRoot(String)
      Returns:
      Location of instance root set using setInstanceRoot(String)
    • setConfigFileURI

      @Deprecated(forRemoval=true, since="7.0.20") public void setConfigFileURI(String configFileURI)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Optionally set the location of configuration file (i.e., domain.xml) using which the GlassFish should run.

      If the parameter does not start with file:, it is resolved as a local file path relative to the current directory.

      Unless specified, the configuration file is operated on read only mode. To writeback any changes, call setConfigFileReadOnly(boolean) with 'false'.

      Parameters:
      configFileURI - Location of configuration file. File path, or full URI with the schema, e.g. file:
    • setConfigFile

      public void setConfigFile(File configFile)
      Optionally set the location of configuration file (i.e., domain.xml) using which the GlassFish should run. The file will be converted to the absolute URI.

      Unless specified, the configuration file is operated on read only mode. To writeback any changes, call setConfigFileReadOnly(boolean) with 'false'.

      Parameters:
      configFile - Location of configuration file. File path, or full URI with the schema, e.g. file:
    • setConfigFile

      public void setConfigFile(URI configFileURI)
      Optionally set the location of configuration file (i.e., domain.xml) using which the GlassFish should run. The parameter must be an absolute URI or null.

      Unless specified, the configuration file is operated on read only mode. To writeback any changes, call setConfigFileReadOnly(boolean) with 'false'.

      Parameters:
      configFileURI - Location of configuration file. File path, or full URI with the schema, e.g. file:
      Throws:
      IllegalArgumentException - If the parameter is not an absolute URI or null.
    • getConfigFileURI

      public URI getConfigFileURI()
      Get the absolute configurationFileURI set using setConfigFileURI(String)
      Returns:
      The configurationFileURI set using setConfigFileURI(String)
    • isConfigFileReadOnly

      public boolean isConfigFileReadOnly()
      Check whether the specified configuration file or config/domain.xml at the specified instance root is operated read only or not.
      Returns:
      true if the specified configurator file or config/domain.xml at the specified instance root remains unchanged when the glassfish runs, false otherwise.
    • setConfigFileReadOnly

      public void setConfigFileReadOnly(boolean readOnly)
      Mention whether or not the GlassFish should writeback any changes to specified configuration file or config/domain.xml at the specified instance root.

      By default readOnly is true.

      Parameters:
      readOnly - false to writeback any changes.
    • setPort

      public void setPort(String networkListener, int port)
      Set the port number for a network listener that the GlassFish server should use. In the default configuration, all listeners are disabled. This method will enable the listener if it's disabled. If the port is 0 or a negative value, it will disable the network listener.

      Examples:

      1. When the custom configuration file is not used, the ports can be set using:

            setPort("http-listener", 8080); // GlassFish will listen on HTTP port 8080
            setPort("https-listener", 8181); // GlassFish will listen on HTTPS port 8181
            setPort("http-listener", 0); // GlassFish will disable the HTTP listener
       

      2. When the custom configuration file (domain.xml) is used, then the name of the network listener specified here will point to the network-listener element in the domain.xml. For example:

            setPort("joe", 8080);
       

      will point to server.network-config.network-listeners.network-listener.joe. Hence the GlassFish server will use "joe" network listener with its port set to 8080.

      If there is no such network-listener by name "joe" in the supplied domain.xml, then the server will throw an exception and fail to start.

      Parameters:
      networkListener - Name of the network listener.
      port - Port number
    • getPort

      public int getPort(String networkListener)
      Get the port number set using setPort(String, int)
      Parameters:
      networkListener - Name of the listener
      Returns:
      Port number which was set using setPort(String, int). -1 if it was not set previously.