AS Branch_5_x now booting in Embedded
alrubinger Jul 10, 2009 12:52 AMWith a bunch of the requisite bootstrap refactoring done, I've moved into making an Embedded booter for AS. At the same time, I'm prototyping some APIs for virtual (declarative, VFS-backed) deployments much like Bill did in "DeploymentGroup" of the old Embedded.
The issue of the day is: https://jira.jboss.org/jira/browse/EMB-32
So AS now is running in what I call "Mode 1", which is backed by a true filesystem installation. The API looks like:
final JBossASEmbeddedServer server = new JBossASEmbeddedServerImpl(); server.start();
There's also a single-arg constructor which will accept a JBOSS_HOME. In the no-arg form we look for environment variable "JBOSS_HOME" or system property "jboss.home".
Then we can make a deployment:
final String name = "testDeployment.jar"; final VirtualVfsArchive deployment = new VirtualVfsArchiveImpl(name).addClasses(OutputBean.class, OutputLocalBusiness.class); log.info(deployment.toString(true));
The "toString(true)" is a verbose form which aids in debugging the virtual deployment, printing out something similar to:
23:35:47,852 INFO [ServerTestCase] MemoryContextHandler@324589909[path= context=vfsmemory://testDeployment.jar real=vfsmemory://testDeployment.jar] - 0 bytes org - 0 bytes org/jboss - 0 bytes org/jboss/embedded - 0 bytes org/jboss/embedded/testsuite - 0 bytes org/jboss/embedded/testsuite/fulldep - 0 bytes org/jboss/embedded/testsuite/fulldep/ejb3 - 0 bytes org/jboss/embedded/testsuite/fulldep/ejb3/slsb - 0 bytes org/jboss/embedded/testsuite/fulldep/ejb3/slsb/OutputBean.class - 844 bytes org/jboss/embedded/testsuite/fulldep/ejb3/slsb/OutputLocalBusiness.class - 312 bytes
Then we deploy and test:
server.deploy(deployment); final OutputLocalBusiness bean = (OutputLocalBusiness) new InitialContext().lookup(OutputBean.class .getSimpleName() + "/local");; final String output = bean.getOutput(); log.info("Got output: " + output); Assert.assertEquals(OutputLocalBusiness.OUTPUT, output);
This test is now turning green. So we can say that Embedded is showing some signs of life, and the bootstrap refactoring is starting to pay off.
The phase of development I'm in now is building out the virtual archive APIs. I want tests that show Servlets, JMS, SLSB, SFSB, JCA, etc all working in this mode. And even further we need finer-grained unit tests which are currently absent in the Embedded source tree (it's all integration thus far).
Wiki documentation to be forthcoming, but in the interim anyone who wants to be involved should ping me directly.
http://anonsvn.jboss.org/repos/jbossas/projects/embedded/trunk/testsuite-full-dep/src/test/java/org/jboss/ServerTestCase.java
S,
ALR