Methods Summary |
---|
public static void | boot(java.lang.String configPath)Bootstrap the EJB3 container by loading up JBoss Microcontainer files.
initInitialContext();
String basePath = "";
if (configPath != null && !configPath.equals(""))
{
basePath = configPath;
if (!configPath.endsWith("/"))
{
basePath += "/";
}
}
try
{
URL bootstrap = Thread.currentThread().getContextClassLoader().getResource(basePath + "embedded-jboss-beans.xml");
createKernel();
loadMBeanServer();
BeanXMLDeployer deployer = new BeanXMLDeployer(kernel);
if (bootstrap == null)
throw new RuntimeException("Cannot find embedded-jboss-beans.xml");
deployments.add(0, deployer.deploy(bootstrap));
deployer.validate();
URL ejb3_interceptors = Thread.currentThread().getContextClassLoader().getResource(basePath + "ejb3-interceptors-aop.xml");
if (ejb3_interceptors == null)
throw new RuntimeException("Cannot find ejb3-interceptors-aop.xml");
AspectXmlLoader.deployXML(ejb3_interceptors);
aopDeployments.add(ejb3_interceptors);
getDeployment("");
}
catch (Throwable throwable)
{
throw new RuntimeException(throwable);
}
|
public static EJB3StandaloneDeployer | createDeployer()Create a deployer that you can start deploying to. You must call create/start and stop/destroy to bootstrap
and shutdown
EJB3StandaloneDeployer deployer;
deployer = new EJB3StandaloneDeployer();
deployer.setJndiProperties(getInitialContextProperties());
deployer.setKernel(kernel);
deployer.setMbeanServer(mbeanServer);
return deployer;
|
public static void | createKernel()
BasicBootstrap bootstrap1 = new BasicBootstrap();
bootstrap1.run();
kernel = bootstrap1.getKernel();
KernelAbstractionFactory.setKernel(kernel);
|
public static void | deployXmlResource(java.lang.String resource)Deploy a JBoss Microcontainer XML file.
try
{
BeanXMLDeployer deployer = new BeanXMLDeployer(kernel);
URL bootstrap = Thread.currentThread().getContextClassLoader().getResource(resource);
if (bootstrap == null)
throw new RuntimeException("Cannot find " + resource);
KernelDeployment deployment = deployer.deploy(bootstrap);
deployments.add(0, deployment);
deployer.validate();
}
catch (Throwable throwable)
{
throw new RuntimeException(throwable);
}
|
public static java.lang.Object | getDeployment(java.lang.String name)
Iterator allDeployments = deployments.iterator();
while (allDeployments.hasNext())
{
KernelDeployment deployment = (KernelDeployment)allDeployments.next();
Iterator contexts = deployment.getInstalledContexts().iterator();
while (contexts.hasNext())
{
org.jboss.kernel.plugins.dependency.AbstractKernelControllerContext context = (org.jboss.kernel.plugins.dependency.AbstractKernelControllerContext)contexts.next();
if (context.getName().equals(name))
return context.getTarget();
}
}
return null;
|
public static java.util.Hashtable | getInitialContextProperties()
ignoredJars.add("antlr-2.7.5H3.jar");
ignoredJars.add("asm-attrs.jar");
ignoredJars.add("asm.jar");
ignoredJars.add("cglib-2.1.1.jar");
ignoredJars.add("commons-collections.jar");
ignoredJars.add("commons-logging-api.jar");
ignoredJars.add("commons-logging.jar");
ignoredJars.add("concurrent.jar");
ignoredJars.add("dom4j.jar");
ignoredJars.add("ejb3-persistence.jar");
ignoredJars.add("hibernate3.jar");
ignoredJars.add("hibernate-annotations.jar");
ignoredJars.add("hibernate-entitymanager.jar");
ignoredJars.add("hsqldb.jar");
ignoredJars.add("javassist.jar");
ignoredJars.add("jboss-annotations-ejb3.jar");
ignoredJars.add("jboss-aop-jdk50.jar");
ignoredJars.add("jboss-aspect-library-jdk50.jar");
ignoredJars.add("jboss-common.jar");
ignoredJars.add("jboss-common-jdbc-wrapper.jar");
ignoredJars.add("jboss-container.jar");
ignoredJars.add("jboss-dependency.jar");
ignoredJars.add("jboss-ejb3.jar");
ignoredJars.add("jboss-ejb3x.jar");
ignoredJars.add("jboss-j2ee.jar");
ignoredJars.add("jboss-j2se.jar");
ignoredJars.add("jboss.jar");
ignoredJars.add("jboss-jca.jar");
ignoredJars.add("jboss-local-jdbc.jar");
ignoredJars.add("jboss-microcontainer.jar");
ignoredJars.add("jbossmq.jar");
ignoredJars.add("jboss-remoting.jar");
ignoredJars.add("jbosssx.jar");
ignoredJars.add("jboss-system.jar");
ignoredJars.add("jboss-transaction.jar");
ignoredJars.add("jboss-xa-jdbc.jar");
ignoredJars.add("jnpserver.jar");
ignoredJars.add("log4j.jar");
ignoredJars.add("resolver.jar");
ignoredJars.add("trove.jar");
ignoredJars.add("xercesImpl.jar");
ignoredJars.add("xml-apis.jar");
ignoredJars.add("jboss-ejb3-all.jar");
ignoredJars.add("hibernate-all.jar");
ignoredJars.add("thirdparty-all.jar");
Hashtable hash = null;
ControllerContext context = kernel.getController().getInstalledContext("InitialContextProperties");
if (context != null)
hash = (Hashtable) context.getTarget();
else if (warned == false)
{
log.warn("Could not find an configured InitialContextProperties, this is ok if your already have a correct jndi.properties file");
warned = true;
}
return hash;
|
public static org.jboss.kernel.Kernel | getKernel()
return kernel;
|
private static void | initInitialContext()
Properties jndiProps = new Properties();
jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.LocalOnlyContextFactory");
jndiProps.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
InitialContextFactory.setProperties(jndiProps);
|
public static void | loadMBeanServer()
ControllerContext context = kernel.getController().getInstalledContext("MBeanServer");
if (context != null)
{
mbeanServer = (MBeanServer) context.getTarget();
}
else
{
ArrayList servers = MBeanServerFactory.findMBeanServer(null);
if (servers.size() == 0)
{
mbeanServer = MBeanServerFactory.createMBeanServer();
org.jboss.mx.util.MBeanServerLocator.setJBoss(mbeanServer);
}
}
|
public static void | scanClasspath(java.lang.String paths)Scan java.class.path System property for jars that contain EJB3 files.
This is unportable and unreliable. Use with caution.
try
{
String classpath = System.getProperty("java.class.path");
StringTokenizer tokenizer = new StringTokenizer(classpath, File.pathSeparator);
String[] split = paths.split(",");
for (int i = 0; i < split.length; i++)
{
split[i] = split[i].trim();
}
deployer = createDeployer();
while (tokenizer.hasMoreTokens())
{
String path = tokenizer.nextToken().trim();
boolean found = false;
for (String wantedPath : split)
{
if (path.endsWith(System.getProperty("file.separator") + wantedPath))
{
found = true;
break;
}
}
if (!found) continue;
File fp = new File(path);
if (ignoredJars.contains(fp.getName())) continue;
URL archive = fp.toURL();
deployer.getArchives().add(archive);
}
if (deployer.getArchives().size() == 0)
{
deployer = null;
return;
}
deployer.create();
deployer.start();
}
catch (Exception e)
{
throw new RuntimeException(e);
}
if (!KernelErrors.validate(kernel)) throw new RuntimeException("Problems scanning classpath");
|
public static void | scanClasspath()Scan java.class.path System property for jars that contain EJB3 files.
This is unportable and unreliable. Use with caution.
try
{
String classpath = System.getProperty("java.class.path");
StringTokenizer tokenizer = new StringTokenizer(classpath, File.pathSeparator);
deployer = createDeployer();
while (tokenizer.hasMoreTokens())
{
String path = tokenizer.nextToken();
File fp = new File(path);
if (ignoredJars.contains(fp.getName())) continue;
URL archive = fp.toURL();
deployer.getArchives().add(archive);
}
if (deployer.getArchives().size() == 0)
{
deployer = null;
return;
}
deployer.create();
deployer.start();
}
catch (Exception e)
{
throw new RuntimeException(e);
}
if (!KernelErrors.validate(kernel)) throw new RuntimeException("Problems scanning classpath");
|
public static void | shutdown()
try
{
if (deployer != null)
{
deployer.stop();
deployer.destroy();
deployer = null;
}
BeanXMLDeployer deployer = new BeanXMLDeployer(kernel);
for (KernelDeployment deployment : deployments)
{
deployer.undeploy(deployment);
}
for (URL url : aopDeployments)
{
try
{
AspectXmlLoader.undeployXML(url);
}
catch (Exception e)
{
log.warn(e);
}
}
kernel = null;
}
catch (Throwable throwable)
{
log.warn(throwable);
}
|