Search in sources :

Example 6 with WebModule

use of org.apache.openejb.config.WebModule in project tomee by apache.

the class OpenEJBDeployableContainer method quickDeploy.

private DeploymentInfo quickDeploy(final Archive<?> archive, final TestClass testClass, final Closeables cls) throws DeploymentException {
    final String name = archive.getName();
    DeploymentInfo info = DEPLOYMENT_INFO.get(name);
    if (info == null) {
        try {
            final AppModule module = OpenEJBArchiveProcessor.createModule(archive, testClass, cls);
            final AppInfo appInfo = configurationFactory.configureApplication(module);
            final WebAppBuilder webAppBuilder = SystemInstance.get().getComponent(WebAppBuilder.class);
            final boolean isEmbeddedWebAppBuilder = webAppBuilder != null && LightweightWebAppBuilder.class.isInstance(webAppBuilder);
            if (isEmbeddedWebAppBuilder) {
                // for now we keep the same classloader, open to discussion if we should recreate it, not sure it does worth it
                final LightweightWebAppBuilder lightweightWebAppBuilder = LightweightWebAppBuilder.class.cast(webAppBuilder);
                for (final WebModule w : module.getWebModules()) {
                    final String moduleId = w.getModuleId();
                    lightweightWebAppBuilder.setClassLoader(moduleId, w.getClassLoader());
                    cls.add(new Closeable() {

                        @Override
                        public void close() throws IOException {
                            lightweightWebAppBuilder.removeClassLoader(moduleId);
                        }
                    });
                }
            }
            final AppContext appCtx = assembler.createApplication(appInfo, module.getClassLoader());
            if (isEmbeddedWebAppBuilder && PROPERTIES.containsKey(OpenEjbContainer.OPENEJB_EMBEDDED_REMOTABLE) && !appCtx.getWebContexts().isEmpty()) {
                cls.add(new Closeable() {

                    @Override
                    public void close() throws IOException {
                        try {
                            final SessionManager sessionManager = SystemInstance.get().getComponent(SessionManager.class);
                            if (sessionManager != null) {
                                for (final WebContext web : appCtx.getWebContexts()) {
                                    sessionManager.destroy(web);
                                }
                            }
                        } catch (final Throwable e) {
                        // no-op
                        }
                    }
                });
            }
            final ServletContext appServletContext = new MockServletContext();
            final HttpSession appSession = new MockHttpSession();
            if (configuration.isStartDefaultScopes() && appCtx.getWebBeansContext() != null) {
                startContexts(appCtx.getWebBeansContext().getContextsService(), appServletContext, appSession);
            }
            info = new DeploymentInfo(appServletContext, appSession, appInfo, appCtx);
            if (configuration.isSingleDeploymentByArchiveName(name)) {
                DEPLOYMENT_INFO.putIfAbsent(name, info);
            }
        } catch (final Exception e) {
            throw new DeploymentException("can't deploy " + name, e);
        }
    }
    return info;
}
Also used : AppModule(org.apache.openejb.config.AppModule) WebContext(org.apache.openejb.core.WebContext) SessionManager(org.apache.openejb.server.httpd.session.SessionManager) HttpSession(javax.servlet.http.HttpSession) MockHttpSession(org.apache.webbeans.web.lifecycle.test.MockHttpSession) Closeable(java.io.Closeable) AppContext(org.apache.openejb.AppContext) WebModule(org.apache.openejb.config.WebModule) IOException(java.io.IOException) LightweightWebAppBuilder(org.apache.openejb.web.LightweightWebAppBuilder) WebAppBuilder(org.apache.openejb.assembler.classic.WebAppBuilder) MockServletContext(org.apache.webbeans.web.lifecycle.test.MockServletContext) NamingException(javax.naming.NamingException) LifecycleException(org.jboss.arquillian.container.spi.client.container.LifecycleException) IOException(java.io.IOException) OpenEJBRuntimeException(org.apache.openejb.OpenEJBRuntimeException) DeploymentException(org.jboss.arquillian.container.spi.client.container.DeploymentException) WebAppInfo(org.apache.openejb.assembler.classic.WebAppInfo) AppInfo(org.apache.openejb.assembler.classic.AppInfo) LightweightWebAppBuilder(org.apache.openejb.web.LightweightWebAppBuilder) MockServletContext(org.apache.webbeans.web.lifecycle.test.MockServletContext) ServletContext(javax.servlet.ServletContext) MockHttpSession(org.apache.webbeans.web.lifecycle.test.MockHttpSession) DeploymentException(org.jboss.arquillian.container.spi.client.container.DeploymentException)

Example 7 with WebModule

use of org.apache.openejb.config.WebModule in project tomee by apache.

the class CheckAnnotations method validate.

@Override
public void validate(final AppModule appModule) {
    try {
        for (final EjbModule ejbModule : appModule.getEjbModules()) {
            module = ejbModule;
            findClassesAnnotatedWithWebService(ejbModule);
        }
        for (final WebModule webModule : appModule.getWebModules()) {
            module = webModule;
            findClassesAnnotatedWithWebService(webModule);
        }
    } catch (final Exception e) {
        logger.error("Error while validating @WebService annotation", e);
    }
}
Also used : EjbModule(org.apache.openejb.config.EjbModule) WebModule(org.apache.openejb.config.WebModule)

Example 8 with WebModule

use of org.apache.openejb.config.WebModule in project tomee by apache.

the class CheckClassLoading method validate.

@Override
public void validate(final AppModule appModule) {
    this.appModule = appModule;
    module = appModule;
    check(appModule.getClassLoader());
    for (final WebModule webModule : appModule.getWebModules()) {
        module = webModule;
        validate(webModule);
    }
    super.validate(appModule);
}
Also used : WebModule(org.apache.openejb.config.WebModule)

Example 9 with WebModule

use of org.apache.openejb.config.WebModule in project tomee by apache.

the class LoggingJAXRSWebAppModuleClassConfigurationTest method service.

@Module
public AppModule service() throws Exception {
    final WebModule war = new WebModule(getWebApp(), "/test", Thread.currentThread().getContextClassLoader(), "", "test");
    war.getRestApplications().add(LogginTestApplication.class.getName());
    final AppModule appModule = new AppModule(getEjbModule(LogginTestApplication.class.getName(), "test"), war);
    configureLoggin();
    return appModule;
}
Also used : AppModule(org.apache.openejb.config.AppModule) WebModule(org.apache.openejb.config.WebModule) WebModule(org.apache.openejb.config.WebModule) AppModule(org.apache.openejb.config.AppModule) Module(org.apache.openejb.testing.Module)

Example 10 with WebModule

use of org.apache.openejb.config.WebModule in project tomee by apache.

the class LoggingJAXRSWebAppModuleTest method service.

@Module
public AppModule service() throws Exception {
    final WebModule war = new WebModule(getWebApp(), "/test", Thread.currentThread().getContextClassLoader(), "", "test");
    war.getRestApplications().add(LogginTestApplication.class.getName());
    final AppModule appModule = new AppModule(getEjbModule("jaxrs-application", "test"), war);
    configureLoggin();
    return appModule;
}
Also used : AppModule(org.apache.openejb.config.AppModule) WebModule(org.apache.openejb.config.WebModule) WebModule(org.apache.openejb.config.WebModule) AppModule(org.apache.openejb.config.AppModule) Module(org.apache.openejb.testing.Module)

Aggregations

WebModule (org.apache.openejb.config.WebModule)18 AppModule (org.apache.openejb.config.AppModule)9 EjbModule (org.apache.openejb.config.EjbModule)9 File (java.io.File)7 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)5 WebApp (org.apache.openejb.jee.WebApp)5 OpenejbJar (org.apache.openejb.jee.oejb3.OpenejbJar)5 HashMap (java.util.HashMap)4 Map (java.util.Map)4 EjbJar (org.apache.openejb.jee.EjbJar)4 Module (org.apache.openejb.testing.Module)4 URL (java.net.URL)3 LinkedList (java.util.LinkedList)3 OpenEJBException (org.apache.openejb.OpenEJBException)3 OpenEJBRuntimeException (org.apache.openejb.OpenEJBRuntimeException)3 AppInfo (org.apache.openejb.assembler.classic.AppInfo)3 Beans (org.apache.openejb.jee.Beans)3 EnvEntry (org.apache.openejb.jee.EnvEntry)3 Arrays.asList (java.util.Arrays.asList)2