com.ibm.wsspi.kernel.embeddable

Class ServerBuilder

  1. java.lang.Object
  2. extended bycom.ibm.wsspi.kernel.embeddable.ServerBuilder

  1. public class ServerBuilder
  2. extends java.lang.Object
Builder for constructing an embedded Server.

Use this Builder to set immutable server attributes, then call the build() method to build and return a Server instance.

As an example, to build a new Server instance, this snippet would suffice:

 Server defaultServer = new ServerBuilder().setName("embeddedServer").build();
 

Constructor Summary

Constructor and Description
ServerBuilder()

Method Summary

Modifier and Type Method and Description
  1. Server
build()
Get a new Server instance.
  1. 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 (.).
  1. ServerBuilder
setOutputDir(java.io.File outputDir)
Set the path of the user output directory.
  1. ServerBuilder
setServerEventListener(ServerEventListener listener)
Set the listener that will receive ServerEventListener.ServerEvent notifications.
  1. ServerBuilder
setUserDir(java.io.File userDir)
Set the path of the user directory.
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail

ServerBuilder

  1. public ServerBuilder()

Method Detail

setName

  1. public 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.

setUserDir

  1. public 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 the WLP_USER_DIR environment variable when launching the server from the command line.

This is optional. By default, the user directory will be wlp/usr, where wlp is 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.

setOutputDir

  1. public 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 the WLP_OUTPUT_DIR environment 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 to outputDir/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:

setServerEventListener

  1. public ServerBuilder setServerEventListener( ServerEventListener listener)
Set the listener that will receive ServerEventListener.ServerEvent notifications.

Using a ServerEventListener is optional.

Parameters:
listener - The ServerEventListener to notify.

build

  1. public Server build()
  2. throws ServerException
Get a new Server instance. This will fail if the server does not already exist (${server.config.dir} must exist, and must contain a server.xml file).
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.