Package org.apache.openejb.config

Examples of org.apache.openejb.config.WebModule


        final AppModule appModule = new AppModule(loader, archive.getName());
        if (WEB_INF.equals(prefix)) {
            appModule.setDelegateFirst(false);
            appModule.setStandloneWebModule();

            final WebModule webModule = new WebModule(new WebApp(), contextRoot(archive.getName()), loader, "", appModule.getModuleId());
            webModule.setUrls(additionalPaths);
            appModule.getWebModules().add(webModule);
        }

        // add the test as a managed bean to be able to inject into it easily
        if (javaClass != null) {
View Full Code Here


                    root = "/openejb";
                }

                testBean.getEnvEntry().addAll(webapp.getEnvEntry());

                final WebModule webModule = new WebModule(webapp, root, Thread.currentThread().getContextClassLoader(), "", root);

                webModule.getAltDDs().putAll(additionalDescriptors);
                webModule.getAltDDs().putAll(descriptorsToMap(method.getAnnotation(Descriptors.class)));

                if (classes != null) {
                    webModule.setFinder(finderFromClasses(classes));
                }
                final EjbModule ejbModule = DeploymentLoader.addWebModule(webModule, appModule);
                if (cdi) {
                    ejbModule.setBeans(beans(new Beans(), cdiDecorators, cdiInterceptors, cdiAlternatives));
                }
            } else if (obj instanceof WebModule) { // will add the ejbmodule too
                webModulesNb++;

                final WebModule webModule = (WebModule) obj;

                webModule.getAltDDs().putAll(additionalDescriptors);
                webModule.getAltDDs().putAll(descriptorsToMap(method.getAnnotation(Descriptors.class)));

                if (classes != null) {
                    webModule.setFinder(finderFromClasses(classes));
                }
                final EjbModule ejbModule = DeploymentLoader.addWebModule(webModule, appModule);
                if (cdi) {
                    ejbModule.setBeans(beans(new Beans(), cdiDecorators, cdiInterceptors, cdiAlternatives));
                }
View Full Code Here

                        root = "/openejb";
                    }

                    testBean.getEnvEntry().addAll(webapp.getEnvEntry());

                    final WebModule webModule = new WebModule(webapp, root, Thread.currentThread().getContextClassLoader(), "", root);

                    webModule.getAltDDs().putAll(additionalDescriptors);
                    webModule.getAltDDs().putAll(descriptorsToMap(method.getAnnotation(Descriptors.class)));

                    final EjbModule ejbModule = DeploymentLoader.addWebModule(webModule, appModule);
                    if (cdi) {
                        ejbModule.setBeans(beans(new Beans(), cdiDecorators, cdiInterceptors, cdiAlternatives));
                    }

                    final IAnnotationFinder finder = finderFromClasses(webModule, classes, findFiles(jarsAnnotation));
                    webModule.setFinder(finder);
                    ejbModule.setFinder(webModule.getFinder());
                } else if (obj instanceof WebModule) { // will add the ejbmodule too
                    webModulesNb++;

                    final WebModule webModule = (WebModule) obj;

                    webModule.getAltDDs().putAll(additionalDescriptors);
                    webModule.getAltDDs().putAll(descriptorsToMap(method.getAnnotation(Descriptors.class)));

                    final EjbModule ejbModule = DeploymentLoader.addWebModule(webModule, appModule);
                    if (cdi) {
                        ejbModule.setBeans(beans(new Beans(), cdiDecorators, cdiInterceptors, cdiAlternatives));
                    }

                    webModule.setFinder(finderFromClasses(webModule, classes, findFiles(jarsAnnotation)));
                    ejbModule.setFinder(webModule.getFinder());
                } else if (obj instanceof EjbModule) {
                    final EjbModule ejbModule = (EjbModule) obj;

                    ejbModule.getAltDDs().putAll(additionalDescriptors);
                    ejbModule.getAltDDs().putAll(descriptorsToMap(method.getAnnotation(Descriptors.class)));
View Full Code Here

                String root = webapp.getContextRoot();
                if (root == null) {
                    root = "/openejb";
                }

                final WebModule webModule = new WebModule(webapp, root, Thread.currentThread().getContextClassLoader(), "", root);

                webModule.getAltDDs().putAll(additionalDescriptors);
                webModule.getAltDDs().putAll(descriptorsToMap(method.getAnnotation(Descriptors.class)));

                if (classes != null) {
                    webModule.setFinder(finderFromClasses(classes));
                }
                final EjbModule ejbModule = DeploymentLoader.addWebModule(webModule, appModule);
                if (cdi) {
                    ejbModule.setBeans(new Beans());
                }
            } else if (obj instanceof WebModule) { // will add the ejbmodule too
                webModulesNb++;

                final WebModule webModule = (WebModule) obj;

                webModule.getAltDDs().putAll(additionalDescriptors);
                webModule.getAltDDs().putAll(descriptorsToMap(method.getAnnotation(Descriptors.class)));

                if (classes != null) {
                    webModule.setFinder(finderFromClasses(classes));
                }
                DeploymentLoader.addWebModule(webModule, appModule);
            } else if (obj instanceof EjbModule) {
                final EjbModule ejbModule = (EjbModule) obj;
View Full Code Here

        final AppModule appModule = new AppModule(loader, archive.getName());
        if (WEB_INF.equals(prefix)) {
            appModule.setDelegateFirst(false);
            appModule.setStandloneWebModule();

            final WebModule webModule = new WebModule(new WebApp(), contextRoot(archive.getName()), loader, "", appModule.getModuleId());
            webModule.setUrls(additionalPaths);
            appModule.getWebModules().add(webModule);
        }

        // add the test as a managed bean to be able to inject into it easily
        if (javaClass != null) {
View Full Code Here

    public static void start() throws Exception {
        WebApp webApp = new WebApp();
        webApp.setContextRoot("/my-web-app");
        webApp.setId("web");
        webApp.setVersion("2.5");
        WebModule webModule = new WebModule(webApp, webApp.getContextRoot(),
                Thread.currentThread().getContextClassLoader(), "myapp", webApp.getId());
        webModule.setFinder(new AnnotationFinder(new ClassesArchive(
                MyFirstRestClass.class, MySecondRestClass.class, MyNonListedRestClass.class,
                MyRESTApplication.class, MyExpertRestClass.class, HookedRest.class, RestWithInjections.class)).link());

        Assembler assembler = new Assembler();
        SystemInstance.get().setComponent(Assembler.class, assembler);

        AnnotationDeployer annotationDeployer = new AnnotationDeployer();
        ConfigurationFactory config = new ConfigurationFactory();
        assembler.createProxyFactory(config.configureService(ProxyFactoryInfo.class));
        assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
        assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));

        webModule = annotationDeployer.deploy(webModule);

        EjbJar ejbJar = new EjbJar("ejb");
        ejbJar.addEnterpriseBean(new StatelessBean(SimpleEJB.class));

        ConfigurationFactory factory = new ConfigurationFactory(false);

        AppModule appModule = new AppModule(Thread.currentThread().getContextClassLoader(), "foo");
        appModule.setModuleId("rest");
        appModule.getWebModules().add(webModule);
        appModule.getEjbModules().add(new EjbModule(ejbJar));
        appModule.getEjbModules().iterator().next().setModuleId(webModule.getModuleId());
        appModule.setStandloneWebModule();
        annotationDeployer.deploy(appModule);

        AppInfo appInfo = factory.configureApplication(appModule);
        final AppContext application = assembler.createApplication(appInfo);

        Context ctx = (Context) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class<?>[]{Context.class}, new InvocationHandler() {
            @Override
            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                if (args.length == 1 && args[0].equals("SimpleEJBLocalBean")) {
                    return new SimpleEJB();
                }
                return method.invoke(new InitialContext(), args);
            }
        });

        CoreContainerSystem containerSystem = new CoreContainerSystem(new IvmJndiFactory());
        WebContext webContext = new WebContext(application);
        webContext.setId(webApp.getId());
        webContext.setClassLoader(webModule.getClassLoader());
        webContext.getInjections().add(new Injection("SimpleEJBLocalBean", "simple", RestWithInjections.class));
        webContext.setJndiEnc(ctx);
        containerSystem.addWebContext(webContext);
        SystemInstance.get().setComponent(ContainerSystem.class, containerSystem);
View Full Code Here

        return properties;
    }

    @Module
    public WebModule war() {
        final WebModule webModule = new WebModule(new WebApp(), "/foo", Thread.currentThread().getContextClassLoader(), "", "foo");
        webModule.getRestClasses().add(MyFirstRestClass.class.getName());
        return webModule;
    }
View Full Code Here

                        file = file.getCanonicalFile().getAbsoluteFile();
                        final AppModule appModule = deploymentLoader.load(file);

                        // Ignore any standalone web modules - this happens when the app is unpaked and doesn't have a WEB-INF dir
                        if (appModule.getDeploymentModule().size() == 1 && appModule.getWebModules().size() == 1) {
                            final WebModule webModule = appModule.getWebModules().iterator().next();
                            if (file.getAbsolutePath().equals(webModule.getJarLocation())) {
                                continue;
                            }
                        }

                        // tell web modules to deploy using this host
                        for (final WebModule webModule : appModule.getWebModules()) {
                            webModule.setHost(standardHost.getName());
                        }

                        appInfo = configurationFactory.configureApplication(appModule);

                        // if this is an unpacked dir, tomcat will pick it up as a webapp so undeploy it first
View Full Code Here

     * tomcat context instance.
     *
     * @param standardContext tomcat context instance
     */
    private void loadWebModule(final AppModule appModule, final StandardContext standardContext) {
        final WebModule webModule = appModule.getWebModules().get(0);
        final WebApp webApp = webModule.getWebApp();

        // create the web module
        final String path = standardContext.getPath();
        logger.debug("context path = " + path);
        webModule.setHost(standardContext.getHostname());
        // Add all Tomcat env entries to context so they can be overriden by the env.properties file
        final NamingResources naming = standardContext.getNamingResources();
        for (final ContextEnvironment environment : naming.findEnvironments()) {
            EnvEntry envEntry = webApp.getEnvEntryMap().get(environment.getName());
            if (envEntry == null) {
View Full Code Here

        final AppModule appModule = new AppModule(loader, archive.getName());
        if (WEB_INF.equals(prefix)) {
            appModule.setDelegateFirst(false);
            appModule.setStandloneWebModule();

            final WebModule webModule = new WebModule(new WebApp(), contextRoot(archive.getName()), loader, "", appModule.getModuleId());
            webModule.setUrls(additionalPaths);
            appModule.getWebModules().add(webModule);
        }

        // add the test as a managed bean to be able to inject into it easily
        if (javaClass != null) {
View Full Code Here

TOP

Related Classes of org.apache.openejb.config.WebModule

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.