Methods Summary |
---|
public void | contextDestroyed(javax.servlet.ServletContextEvent servletContextEvent)
try
{
if (deployer != null)
{
deployer.stop();
deployer.destroy();
}
BeanXMLDeployer deployer = new BeanXMLDeployer(kernel);
for (KernelDeployment deployment : deployments)
{
deployer.undeploy(deployment);
}
for (URL url : aopDeployments)
{
AspectXmlLoader.undeployXML(url);
}
}
catch (Throwable throwable)
{
throwable.printStackTrace();
throw new RuntimeException(throwable);
}
|
public void | contextInitialized(javax.servlet.ServletContextEvent servletContextEvent)
try
{
createKernel();
ServletContext servletContext = servletContextEvent.getServletContext();
String aop = (String) servletContext.getInitParameter("jboss-aop-deployments");
if (aop == null) aop = "ejb3-interceptors-aop.xml";
StringTokenizer tokenizer = new StringTokenizer(aop, ",");
while (tokenizer.hasMoreTokens())
{
String token = tokenizer.nextToken().trim();
log.debug("deploying aop xml: " + token);
URL url = Thread.currentThread().getContextClassLoader().getResource(token);
try
{
AspectXmlLoader.deployXML(url);
aopDeployments.add(0, url);
}
catch (Exception e)
{
throw new RuntimeException(e);
}
}
String deployments = (String) servletContext.getInitParameter("jboss-kernel-deployments");
if (deployments == null) deployments = "embedded-jboss-beans.xml";
tokenizer = new StringTokenizer(deployments, ",");
while (tokenizer.hasMoreTokens())
{
String token = tokenizer.nextToken().trim();
log.debug("deploying kernel xml: " + token);
deployXmlResource(token);
}
String scan = (String) servletContext.getInitParameter("automatic-scan");
if (scan != null && !scan.equals("false")) return;
Set libJars = servletContext.getResourcePaths("/WEB-INF/lib");
deployer = new EJB3StandaloneDeployer();
deployer.setJndiProperties(getInitialContextProperties());
deployer.setKernel(kernel);
for (Object jar : libJars)
{
if (ignoredJars.contains(jar)) continue;
URL archive = servletContext.getResource((String)jar);
deployer.getArchives().add(archive);
}
if (deployer.getArchives().size() == 0)
{
deployer = null;
return;
}
deployer.create();
deployer.start();
}
catch (Exception e)
{
log.error(e);
throw new RuntimeException(e);
}
if (!KernelErrors.validate(kernel)) throw new RuntimeException("Problems scanning ServletContext.getResourcePaths");
|
protected void | createKernel()
BasicBootstrap bootstrap1 = new BasicBootstrap();
bootstrap1.run();
kernel = bootstrap1.getKernel();
|
protected void | deployXmlResource(java.lang.String resource)
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);
deployer.validate();
deployments.add(0, deployment);
}
catch (Throwable throwable)
{
throwable.printStackTrace();
throw new RuntimeException(throwable);
}
|
protected java.util.Hashtable | getInitialContextProperties()
Hashtable hash = null;
ControllerContext context = kernel.getController().getInstalledContext("InitialContextProperties");
if (context != null)
hash = (Hashtable) context.getTarget();
else
log.warn("could not find an configured InitialContextProperties, this is ok if your already have a correct jndi.properties file");
return hash;
|