Scope
The jboss-bootstrap base is responsible for providing a:
- Simple configuration allowing a bootstrap to be parsed from XML
- Server Start / Stop API
- Lifecycle Event Notification system
- Threadsafe implementation
Intentionally left out-of-scope is:
- ClassLoading. This is supplied and managed by the client.
- Any operational logic during "start" or "shutdown". No bootstraps are parsed, no deployments are made. This may be extended for a custom implementation, or handled by JBossMicrocontainer as part of the bootstrap JBoss Bootstrap | Microcontainer Implementation, API and SPI.
Modules
Module Name | Maven2 ID |
---|---|
api | org.jboss.bootstrap:jboss-bootstrap-api |
spi | org.jboss.bootstrap:jboss-bootstrap-spi |
impl-base | org.jboss.bootstrap:jboss-bootstrap-impl-base |
Sample Code
Start and shutdown a Server Using an Explicit ClassLoader
final ClassLoader cl = Thread.currentThread().getContextClassLoader(); final Server<?,?> server = ServerFactory.createServer( "some.package.ServerFullyQualifiedClassName",cl); server.start(); // Do some tests server.shutdown();
Register an Event Handler to Fire When the Server is Started
final Server<?,?> server = null; // Assume we've got a server server.registerEventHandler(LifecycleState.STARTED,new LifecycleEventHandler() { public void handleEvent(final LifecycleState state) throws LifecycleEventException { log.info("I'm in state: " + state); } }); server.start();
Obtain and Use Typesafe Configuration
// Define our server class class TestNoOpServer extends AbstractServer<TestNoOpServer, TestServerConfig> implements Server<TestNoOpServer, TestServerConfig> {// ...} // Define our server configuration class class TestServerConfig extends AbstractBasicServerConfig<TestServerConfig> implements ServerConfig<TestServerConfig>{//...} // Now we can make typesafe API calls, using method chaining for ease-of-use final TestNoOpServer server = new TestNoOpServer(); final TestServerConfig config = server.getConfiguration(); config.bootstrapHome("file:/path/to/home").bootstrapName("nameOfBootstrap.xml");
Comments