|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.neeve.server.embedded.EmbeddedXVM
public class EmbeddedXVM
Wraps a SrvController
to facilitate configuring and launching an embedded Talon XVM (aka Talon Server).
An EmbeddedXVM
provides a thread of control for the xvm along with the requisite
start()
and shutdown()
methods.
This class provides factory methods that allow the EmbeddedXVM
to be created in a
manner that is consistent with how the xvm would be configured and created using the non
embedded Talon XVM Main
, as well as factory methods that accept a pre configured or
programmatically created SrvConfigDescriptor
for the server.
Important Notes:
Creating multiple instances of an EmbeddedXVM
or creating one after any other
platform class has been loaded is inherently unreliable as by nature the intent of the Configurer
is to not only seed the configuration repository with the server configuration but to also perform
environment wide configuration that is used throughout the platform during static
singleton initialization of shared components. As such it is not guaranteed that an EmbeddedXVM
will behave exactly as one launched from the command line if the environment has been in any way altered
prior to creation and start()
of the EmbeddedXVM
particularly if the Configurer
s
for each xvm configure the environment in a different of conflicting fashion.
This class is not intended for use in production and is provided for use in testing situations. This class may be removed or altered in future releases, so users are encouraged to encapsulate this class to protect against changes until such time as its api has been stabliized.
Method Summary | |
---|---|
static EmbeddedXVM |
create(Configurer configurer,
String... args)
Creates an embedded talon xvm using the provided configurer and optional arguments. |
static EmbeddedXVM |
create(Properties ddlProperties,
String xvmName)
Creates an embedded XVM. |
static EmbeddedXVM |
create(SrvConfigDescriptor configDescriptor)
Creates an embedded talon xvm using the provided SrvConfigDescriptor . |
static EmbeddedXVM |
create(String... args)
Bootstraps and creates an embedded talon xvm using the provided command line arguments. |
static EmbeddedXVM |
create(URL ddlConfig,
String xvmName,
Properties configProperties)
Creates and embedded XVM. |
Object |
getApplication(String appName)
Gets an application loaded in this server. |
SrvController |
getServerController()
Returns the underlying SrvController which provides access to its
SrvAppManager |
Throwable |
getStartupError()
Returns the error associated with a failed xvm start or null if the server started successfully, or failed without an associated exception. |
EmbeddedServer.State |
getState()
Gets the current xvm state. |
void |
shutdown()
Shuts down the xvm (synchronously). |
void |
shutdown(boolean sync)
Shuts down the xvm. |
void |
start()
Starts the embedded talon xvm waiting until start up completes. |
boolean |
start(long timeout)
Starts the embedded xvm, waiting for it to start. |
boolean |
waitForStart(long timeout)
Waits for the xvm to start. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static EmbeddedXVM create(Properties ddlProperties, String xvmName) throws Exception
WARNING: EmbeddedXVMs are intended for use only in testing scenarios. When launching more than one EmbeddedXVM in a JVM, the configuration bootstrapping of their environments cannot be guaranteed particularly in cases where their environment conflicts.
ddlProperties
- The x-ddl configuration properties describing the system that contains the server.xvmName
- The name of the xvmName to create (which must be defined as a server in the ddlConfig).
in the ddlConfig.
Exception
- If there is an error creating the EmbeddedXVM
.public static EmbeddedXVM create(URL ddlConfig, String xvmName, Properties configProperties) throws Exception
WARNING: EmbeddedXVMs are intended for use only in testing scenarios. When launching more than one EmbeddedXVM in a JVM, the configuration bootstrapping of their environments cannot be guaranteed particularly in cases where their environment conflicts.
ddlConfig
- The x-ddl configuration document describing the system that contains the server.xvmName
- The name of the xvmName to create (which must be defined as a server in the ddlConfig).configProperties
- The set of configuration properties to use as System Properties and to override variables
in the ddlConfig.
Exception
- If there is an error creating the EmbeddedXVM
.public static EmbeddedXVM create(String... args) throws Exception
This method allows creation of a Talon server using the same arguments that would be used
to launch a non embedded server using the Talon Server Main
.
Specifically this method:
Configurer
via Main.loadBootstrapConfigurer()
Configurer.configure(String[])
method with the supplied arguments
to allow it to seed the configuration repository via VMConfigurer
.
SrvController
using the embedded
WARNING: EmbeddedXVMs are intended for use only in testing scenarios. When launching more than one EmbeddedXVM in a JVM, the configuration bootstrapping of their environments cannot be guaranteed particularly in cases where their environment conflicts.
args
- The same arguments that would be passed on the command line when launching Main.main(String[])
.
It is possible to pass in "--help" to pring a listing of valid arguments.
Exception
- If there is an error creating the embedded server.Main
,
SrvController
public static EmbeddedXVM create(SrvConfigDescriptor configDescriptor) throws Exception
SrvConfigDescriptor
.
Exception
- If there is an error creating the embedded server.public static EmbeddedXVM create(Configurer configurer, String... args) throws Exception
This method is equivalent to create(String...)
except that the bootstrap
Configurer
invoked is the one supplied here. If the Configurer is null, no bootstrap configuration
is performed.
WARNING: EmbeddedXVMs are intended for use only in testing scenarios. When launching more than one EmbeddedXVM in a JVM, the configuration bootstrapping of their environments cannot be guaranteed particularly in cases where their environment conflicts.
configurer
- The Bootstrap Configurer to use for seeding the server configuration.args
- The same arguments that would be passed on the command line when launching Main.main(String[])
.
It is possible to pass in "--help" to pring a listing of valid arguments.
Exception
- If there is an error creating the embedded server.public boolean start(long timeout) throws TimeoutException, Throwable
When working with multiple embedded servers that employ separate
Configurer
s it is generally not a good idea to start servers
in parallel to avoid separate configurations from stepping on
one another during the startup phase.
If this call throws an Exception, it is incumbent on the caller
to call shutdown()
.
timeout
- The time in seconds to wait for the server to start. A value of -1 means wait indefinitely,
0 means don't wait at all, otherwise wait the given number of seconds
EmbeddedServer.State.Started
, or false if it did not start in the allotted time and is still EmbeddedServer.State.Starting
IllegalStateException
- If the server was already started.
InterruptedException
- If the thread is interrupted waiting for the server to start.
Throwable
- If the server fails to start
TimeoutException
public void start() throws Throwable
This id equivalent to calling start(long)
with a value of -1
IllegalStateException
- If the server was already started.
Throwable
public Throwable getStartupError()
public void shutdown()
public void shutdown(boolean sync)
sync
- Whether or not to synchronously shutdown the server. It is not safe to
set this value to true when called from any thread that must exit prior to server shutdown.public EmbeddedServer.State getState()
public boolean waitForStart(long timeout) throws Throwable
timeout
- The time in seconds to wait for the server to start. A value of -1 means wait indefinitely,
0 means don't wait at all, otherwise wait the given number of seconds
EmbeddedServer.State.Starting
IllegalStateException
- If the xvm has not been started or has been shutdown.
InterruptedException
- If the thread is interrupted waiting for the xvm to start.
Throwable
- thrown if there is an error in xvm startup or the server was shutdown.public SrvController getServerController()
SrvController
which provides access to its
SrvAppManager
SrvController
.public Object getApplication(String appName)
appName
- The name of the application.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |