use of org.apache.struts2.osgi.host.OsgiHost in project struts by apache.
the class StrutsOsgiListener method contextInitialized.
@Override
public void contextInitialized(ServletContextEvent sce) {
LOG.trace("StrutsOsgiListener attempting to start. ContextInitialized called. SCE: [{}]", sce);
if (sce == null) {
// Better than a NPE.
throw new StrutsException("ServletContextEvent is null. Cannot init OSGi platform!");
}
ServletContext servletContext = sce.getServletContext();
LOG.trace("StrutsOsgiListener attempting to start. ServletContext: [{}]", servletContext);
if (servletContext == null) {
// Better than a NPE.
throw new StrutsException("ServletContext is null within the ServletContextEvent. Cannot init OSGi platform!");
}
String platform = servletContext.getInitParameter(PLATFORM_KEY);
LOG.debug("Defined OSGi platform as [{}] via context-param [{}]", platform, PLATFORM_KEY);
try {
osgiHost = OsgiHostFactory.createOsgiHost(platform);
LOG.trace("StrutsOsgiListener attempting to start. OSGi Host constructed: [{}]", osgiHost);
} catch (Throwable t) {
throw new StrutsException("StrutsOsgiListener failed to create an OSGi Host!", t);
}
servletContext.setAttribute(OSGI_HOST, osgiHost);
try {
osgiHost.init(servletContext);
} catch (Exception e) {
throw new StrutsException("StrutsOsgiListener failed to initialize the OSGi Host platform!", e);
}
}
Aggregations