String bindAddress = System.getProperty("embedded.bind.address", "localhost");
Thread.currentThread().setContextClassLoader(loader);
JBossASEmbeddedServer server = JBossASEmbeddedServerFactory.createServer(loader);
JBossASServerConfig config = server.getConfiguration();
config.jbossHome(jbossHome);
config.serverName(serverName);
config.bindAddress(bindAddress);
try
{
server.start();
InitialContext context = new InitialContext();
if(appName == null)
server.deploy(deployments);
else
{
// Create a virtual EAR with the correct name and add the given modules.
/* If only...
EnterpriseArchive archive = ShrinkWrap.create(EnterpriseArchive.class, appName);
for(File d : deployments)
archive.addModule(d);
server.deploy(archive);
*/
VirtualFileAssembly assembly = new VirtualFileAssembly(appName + ".ear");
// make sure we don't have class loader isolation (else CCE in the user class)
assembly.addDirectory("META-INF"); // make sure this is visible as a child
assembly.add("META-INF/jboss-classloading.xml", createJBossClassLoadingXML());
for(File d : deployments)
{
// if it's already a file it must not be mounted twice (see AbstractVFSArchiveStructureDeployer#determineStructure)
if(d.isFile())
assembly.addZip(d.getName(), d);
else
{
// a whimsical hack to make sure the directory is marked as an expanded archive
String name = d.getName();
if(!name.endsWith(".jar"))
name = name + ".jar";
assembly.add(name, d);
}
}
// Deploy the virtual EAR.
server.deploy(assembly.getMountRoot().toURL());
}
return new JBossSubmersibleEJBContainer(server, context);
}
catch(Exception e)