Class ServerBuilder
- java.lang.Object
- 
- com.ibm.wsspi.kernel.embeddable.ServerBuilder
 
- 
 public class ServerBuilder extends java.lang.ObjectBuilder for constructing an embeddedServer.Use this Builder to set immutable server attributes, then call the build()method to build and return aServerinstance.As an example, to build a new Serverinstance, this snippet would suffice:Server defaultServer = new ServerBuilder().setName("embeddedServer").build();
- 
- 
Constructor SummaryConstructors Constructor Description ServerBuilder()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description ServerBuilderaddProductExtension(java.lang.String name, java.util.Properties props)Add a product extension.Serverbuild()Get a newServerinstance.ServerBuildersetInstallDir(java.io.File install)Sets the path of the Liberty install.ServerBuildersetLogDir(java.io.File logDir)Set the path of the log directory.ServerBuildersetName(java.lang.String serverName)Set the locally unique name for the server; the name can be constructed using Unicode alphanumeric characters (for example, A-Za-z0-9), the underscore (_), dash (-), plus (+) and period (.).ServerBuildersetOutputDir(java.io.File outputDir)Set the path of the user output directory.ServerBuildersetServerEventListener(ServerEventListener listener)Set the listener that will receiveServerEventListener.ServerEventnotifications.ServerBuildersetUserDir(java.io.File userDir)Set the path of the user directory.
 
- 
- 
- 
Method Detail- 
setNamepublic ServerBuilder setName(java.lang.String serverName) Set the locally unique name for the server; the name can be constructed using Unicode alphanumeric characters (for example, A-Za-z0-9), the underscore (_), dash (-), plus (+) and period (.). A server name cannot begin with a dash (-) or period (.).- Parameters:
- serverName- The name for the server instance.
- Returns:
- a reference to this object.
 
 - 
setUserDirpublic ServerBuilder setUserDir(java.io.File userDir) Set the path of the user directory. The server must have read access to this directory. This is the equivalent of setting theWLP_USER_DIRenvironment variable when launching the server from the command line.This is optional. By default, the user directory will be wlp/usr, wherewlpis the root of the Liberty installation as determined by the location of the jar providing the server implementation.This path is referred to by the ${wlp.user.dir}variable.The server configuration directory, ${server.config.dir}, is equivalent to${wlp.user.dir}/servers/serverName.- Parameters:
- userDir- The path to the user directory.
- Returns:
- a reference to this object.
 
 - 
setOutputDirpublic ServerBuilder setOutputDir(java.io.File outputDir) Set the path of the user output directory. The server must have read/write access to this directory. This is the equivalent of setting theWLP_OUTPUT_DIRenvironment variable when launching the server from the command line.This is optional. By default, the user output directory will be ${wlp.user.dir}/servers.If this is specified, ${server.output.dir}will be set tooutputDir/serverName. Otherwise,${server.output.dir}will be the same as${server.config.dir}.- Parameters:
- outputDir- The path to the user output directory.
- Returns:
- a reference to this object.
- See Also:
- setUserDir(File)
 
 - 
setLogDirpublic ServerBuilder setLogDir(java.io.File logDir) Set the path of the log directory. The server must have read/write access to this directory. This is the equivalent of setting theLOG_DIRenvironment variable when launching the server from the command line.- Parameters:
- logDir- The path to the log directory.
- Returns:
- a reference to this object.
 
 - 
setInstallDirpublic ServerBuilder setInstallDir(java.io.File install) Sets the path of the Liberty install.This is optional. If the Liberty ws-server.jar is on the classpath of the caller this method has no effect. If it is not this allows the Liberty install to be chosen. - Parameters:
- install- The path to the Liberty install.
- Returns:
- a reference to this object.
 
 - 
setServerEventListenerpublic ServerBuilder setServerEventListener(ServerEventListener listener) Set the listener that will receiveServerEventListener.ServerEventnotifications.Using a ServerEventListeneris optional.- Parameters:
- listener- The- ServerEventListenerto notify.
 
 - 
buildpublic Server build() throws ServerException Get a newServerinstance. This will fail if the server does not already exist (${server.config.dir}must exist, and must contain aserver.xmlfile).- Returns:
- a Server instance using any attributes set on the builder.
- Throws:
- ServerException- if the named server does not exist, or if the attributes set using the set methods fail validation, e.g. the server name contains invalid characters, or the provided Files point to existing files in the file system instead of directories.
 
 - 
addProductExtensionpublic ServerBuilder addProductExtension(java.lang.String name, java.util.Properties props) Add a product extension.The addProductExtension method can be called multiple times to add multiple extensions. When the server is started, any product extension files added by this method will be combined with the product extension files found in other source locations. Any duplicate product names will invoke the following override logic: product extensions defined through this SPI will override product extensions defined by the Environment variable WLP_PRODUCT_EXT_DIRwhich in turn would override product extensions found in$WLP_INSTALL_DIR/etc/extensionsto constitute the full set of product extensions for this instance of the running server.- Parameters:
- name- The name of the product extension.
- props- A properties file containing com.ibm.websphere.productId and com.ibm.websphere.productInstall.
- Returns:
- a reference to this object.
 
 
- 
 
-