Package org.glassfish.internal.embedded
Class Server
java.lang.Object
org.glassfish.internal.embedded.Server
Instances of server are embedded application servers, capable of attaching various containers
(entities running users applications).
- Author:
- Jerome Dochez
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for creating embedded server instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a container of a particular type using the default operating configuration for the container.<T extends EmbeddedContainer>
TaddContainer(ContainerBuilder<T> info) Adds a container to this server.<T extends ContainerBuilder<?>>
TcreateConfig(Class<T> configType) Get an embedded container configuration.createConfig(String name) Get the embedded container builder for a container type identified by its name.Get the embedded container configuration for a container type.createPort(int portNumber) Creates a port to attach to embedded containers.Returns a list of the currently managed containersReturns the embedded deployer implementation, can be used to generically deploy applications to the embedded server.Returns the embedded file system used to run this embedded instance.getName()Returns the server name, as specified inBuilder(String)static ServerReturns the embedded server instance of a particular nameReturns the list of existing embedded instancesvoidstart()Starts the embedded server, opening ports, and running the startup services.voidstop()stops the embedded server instance, any deployed application will be stopped ports will be closed and shutdown services will be ran.
-
Method Details
-
getServerNames
Returns the list of existing embedded instances- Returns:
- list of the instanciated embedded instances.
-
getServer
Returns the embedded server instance of a particular name- Parameters:
name- requested server name- Returns:
- a server instance if it exists, null otherwise
-
createConfig
Get the embedded container configuration for a container type.- Parameters:
type- the container type (e.g. Type.ejb)- Returns:
- the embedded configuration for this container
-
createConfig
Get the embedded container builder for a container type identified by its name.- Parameters:
name- the container name, which is the name used on the @Service annotation- Returns:
- the embedded builder for this container
-
createConfig
Get an embedded container configuration. The type of the expected configuration is passed to the method and is not necessarily known to the glassfish embedded API. This type of configuration is used for extensions which are not defined by the core glassfish project. The API stability of the interfaces returned by this method is outside the scope of the glassfish-api stability contract, it's a private contract between the provider of that configuration and the user.- Type Parameters:
T- type of the embedded container- Parameters:
configType- the type of the embedded container configuration- Returns:
- the configuration to configure a container of type
-
addContainer
Adds a container of a particular type using the default operating configuration for the container.- Parameters:
type- type of the container to be added (like web, ejb).- Throws:
IllegalStateException- if the container is already started.
-
addContainer
Adds a container to this server. Using the configuration instance for the container of type, creating the container from that configuration and finally adding the container instance to the list of managed containers - Type Parameters:
T- type of the container- Parameters:
info- the configuration for the container- Returns:
- instance of the container
- Throws:
IllegalStateException- if the container is already started.
-
getContainers
Returns a list of the currently managed containers- Returns:
- the containers list
-
createPort
Creates a port to attach to embedded containers. Ports can be attached to many embedded containers and some containers may accept more than one port.- Parameters:
portNumber- port number for this port- Returns:
- a new port abstraction.
- Throws:
IOException- if the port cannot be opened.
-
getName
Returns the server name, as specified inBuilder(String)- Returns:
- container name
-
getFileSystem
Returns the embedded file system used to run this embedded instance.- Returns:
- embedded file system used by this instance
-
start
Starts the embedded server, opening ports, and running the startup services.- Throws:
LifecycleException- if the server cannot be started propertly
-
stop
stops the embedded server instance, any deployed application will be stopped ports will be closed and shutdown services will be ran. EmbeddedFileSystem will be released, meaning that any managed directory will be deleted rendering the EmbeddedFileSystem unusable.- Throws:
LifecycleException- if the server cannot shuts down properly
-
getDeployer
Returns the embedded deployer implementation, can be used to generically deploy applications to the embedded server.- Returns:
- embedded deployer
-