Package org.glassfish.embeddable
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. Eg.., GlassFishRuntime.bootstrap(new BootstrapProperties()).newGlassFish(new GlassFishProperties());- Author:
- [email protected], [email protected]
-
-
Constructor Summary
Constructors Constructor Description GlassFishProperties()
Create GlassFishProperties with default properties.GlassFishProperties(Properties props)
Create GlassFishProperties with custom properties.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getConfigFileURI()
Get the configurationFileURI set usingsetConfigFileURI(String)
String
getInstanceRoot()
Get the location instance root set usingsetInstanceRoot(String)
int
getPort(String networkListener)
Get the port number set usingsetPort(String, int)
Properties
getProperties()
Get the underlying Properties object which backs this GlassFishProperties.boolean
isConfigFileReadOnly()
Check whether the specified configuration file or config/domain.xml at the specified instance root is operated read only or not.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.void
setConfigFileURI(String configFileURI)
Optionally set the location of configuration file (i.e., domain.xml) using which the GlassFish should run.void
setInstanceRoot(String instanceRoot)
Optionally set the instance root (aka domain dir) using which the GlassFish should run.void
setPort(String networkListener, int port)
Set the port number for a network listener that the GlassFish server should use.void
setProperty(String key, String value)
Set any custom glassfish property.
-
-
-
Constructor Detail
-
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 inGlassFishRuntime
(if any)- Parameters:
props
- Properties object which will back this GlassFishProperties object.- Throws:
NullPointerException
- if props is null
-
-
Method Detail
-
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 inGlassFishRuntime
(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, 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
public String getInstanceRoot()
Get the location instance root set usingsetInstanceRoot(String)
- Returns:
- Location of instance root set using
setInstanceRoot(String)
-
setConfigFileURI
public void setConfigFileURI(String configFileURI)
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
public String 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
public void setPort(String networkListener, int port)
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 8181
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 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.
-
-