Package org.glassfish.embeddable
Class GlassFishProperties
java.lang.Object
org.glassfish.embeddable.GlassFishProperties
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final StringKey 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.static final StringKey for specifying which configuration file (domain.xml) GlassFish should run with.static final StringKey for specifying which instance root (aka domain dir) GlassFish should run with. -
Constructor Summary
ConstructorsConstructorDescriptionCreate GlassFishProperties with default properties.GlassFishProperties(Properties props) Create GlassFishProperties with custom properties. -
Method Summary
Modifier and TypeMethodDescriptionGet the configurationFileURI set usingsetConfigFileURI(String)Get the location instance root set usingsetInstanceRoot(String)intGet the port number set usingsetPort(String, int)Get the underlying Properties object which backs this GlassFishProperties.booleanCheck whether the specified configuration file or config/domain.xml at the specified instance root is operated read only or not.voidsetConfigFileReadOnly(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.voidsetConfigFileURI(String configFileURI) Optionally set the location of configuration file (i.e., domain.xml) using which the GlassFish should run.voidsetInstanceRoot(String instanceRoot) Optionally set the instance root (aka domain dir) using which the GlassFish should run.voidSet the port number for a network listener that the GlassFish server should use.voidsetProperty(String key, String value) Set any custom glassfish property.
-
Field Details
-
INSTANCE_ROOT_PROP_NAME
Key for specifying which instance root (aka domain dir) GlassFish should run with.- See Also:
-
CONFIG_FILE_URI_PROP_NAME
Key for specifying which configuration file (domain.xml) GlassFish should run with.- See Also:
-
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
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 inGlassFishRuntime(if any)- Parameters:
props- Properties object which will back this GlassFishProperties object.
-
-
Method Details
-
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
Set any custom glassfish property. May be required for the plugged inGlassFishRuntime(if any)- Parameters:
key- the key to be placed into this glassfish properties.value- the value corresponding to the key.
-
setInstanceRoot
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, callsetConfigFileReadOnly(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
Get the location instance root set usingsetInstanceRoot(String)- Returns:
- Location of instance root set using
setInstanceRoot(String)
-
setConfigFileURI
Optionally set the location of configuration file (i.e., domain.xml) using which the GlassFish should run. Unless specified, the configuration file is operated on read only mode. To writeback any changes, callsetConfigFileReadOnly(boolean)with 'false'.- Parameters:
configFileURI- Location of configuration file.
-
getConfigFileURI
Get the configurationFileURI set usingsetConfigFileURI(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
Set the port number for a network listener that the GlassFish server should use. 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 81812. 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
Get the port number set usingsetPort(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.
-