Package org.apache.openejb.core

Examples of org.apache.openejb.core.WebContext


            } else {
                path += "/" + standardContext.getPath();
            }
        }

        WebContext webContext = cs.getWebContext(path);
        if (webContext == null) { // tomee-embedded deployment
            webContext = cs.getWebContext(standardContext.getPath().replaceFirst("/", ""));
            if (webContext == null) {
                webContext = cs.getWebContext(standardContext.getPath());
            }
        }

        if (webContext != null && webContext.getBindings() != null) {
            for (Map.Entry<String, Object> entry : webContext.getBindings().entrySet()) {
                try {
                    final String key = entry.getKey();
                    Object value = normalize(entry.getValue());
                    Contexts.createSubcontexts(root, key);
                    root.rebind(key, value);
                } catch (NamingException e) {
                    e.printStackTrace();
                }
            }
        }

        // try to force some binding which probably failed earlier (see in TomcatWebappBuilder)
        try {
            Context comp = (Context) ContextBindings.getClassLoader().lookup("comp");
            TransactionManager transactionManager = SystemInstance.get().getComponent(TransactionManager.class);
            comp.rebind("TransactionManager", transactionManager);

            // bind TransactionSynchronizationRegistry
            TransactionSynchronizationRegistry synchronizationRegistry = SystemInstance.get().getComponent(TransactionSynchronizationRegistry.class);
            comp.rebind("TransactionSynchronizationRegistry", synchronizationRegistry);

            comp.rebind("ORB", new SystemComponentReference(ORB.class));
            comp.rebind("HandleDelegate", new SystemComponentReference(HandleDelegate.class));

            if (webContext != null) {
                comp.rebind("BeanManager", webContext.getAppContext().getBeanManager());
            }
        } catch (Exception ignored) {
            ignored.printStackTrace();
            // no-op
        }
View Full Code Here


                // merge OpenEJB jndi into Tomcat jndi
                final TomcatJndiBuilder jndiBuilder = new TomcatJndiBuilder(standardContext, webAppInfo, injections);
                jndiBuilder.mergeJndi();

                // add WebDeploymentInfo to ContainerSystem
                final WebContext webContext = new WebContext(appContext);
                webContext.setClassLoader(classLoader);
                webContext.setId(webAppInfo.moduleId);
                webContext.setBindings(bindings);
                webContext.getInjections().addAll(injections);
                appContext.getWebContexts().add(webContext);
                cs.addWebContext(webContext);

                standardContext.setInstanceManager(new JavaeeInstanceManager(webContext, standardContext));
                standardContext.getServletContext().setAttribute(InstanceManager.class.getName(), standardContext.getInstanceManager());
View Full Code Here

            // add context to WebDeploymentInfo
            for (WebAppInfo webAppInfo : contextInfo.appInfo.webApps) {
                boolean isRoot = isRootApplication(standardContext);
                if (("/" + webAppInfo.contextRoot).equals(standardContext.getPath()) || isRoot) {
                    WebContext webContext = getContainerSystem().getWebContext(webAppInfo.moduleId);
                    if (webContext != null) {
                        webContext.setJndiEnc(comp);
                    }

                    try {
                        // Bean Validation
                        standardContext.getServletContext().setAttribute("javax.faces.validator.beanValidator.ValidatorFactory", openejbContext.lookup(Assembler.VALIDATOR_FACTORY_NAMING_CONTEXT.replaceFirst("openejb", "") + webAppInfo.uniqueId));
View Full Code Here

    private String virtualHost;

    public void afterApplicationCreated(final AppInfo appInfo, final WebAppInfo webApp) {
        final Map<String, EJBRestServiceInfo> restEjbs = getRestEjbs(appInfo);

        final WebContext webContext = containerSystem.getWebContext(webApp.moduleId);
        if (webContext == null) {
            return;
        }

        if (!deployedWebApps.add(webApp)) {
            return;
        }

        final ClassLoader classLoader = getClassLoader(webContext.getClassLoader());
        final Collection<Injection> injections = webContext.getInjections();
        final WebBeansContext owbCtx = webContext.getAppContext().getWebBeansContext();
        Context context = webContext.getJndiEnc();
        if (context == null) { // usually true since it is set in org.apache.tomee.catalina.TomcatWebAppBuilder.afterStart() and lookup(comp) fails
            context = webContext.getAppContext().getAppJndiContext();
        }

        // The spec says:
        //
        // "The resources and providers that make up a JAX-RS application are configured via an application-supplied
View Full Code Here

            }
        }
    }

    public void afterApplicationCreated(WebAppInfo webApp) {
        WebContext webContext = containerSystem.getWebContext(webApp.moduleId);
        if (webContext == null) return;

        // if already deployed skip this webapp
        if (!deployedWebApps.add(webApp)) return;

        Map<String,PortInfo> ports = new TreeMap<String,PortInfo>();
        for (PortInfo port : webApp.portInfos) {
            ports.put(port.serviceLink, port);
        }

        URL moduleBaseUrl = null;
        try {
            moduleBaseUrl = new File(webApp.path).toURI().toURL();
        } catch (MalformedURLException e) {
            logger.error("Invalid ejb jar location " + webApp.path, e);
        }

        for (ServletInfo servlet : webApp.servlets) {
            PortInfo portInfo = ports.get(servlet.servletName);
            if (portInfo == null) continue;

            try {
                ClassLoader classLoader = webContext.getClassLoader();
                Collection<Injection> injections = webContext.getInjections();
                Context context = webContext.getJndiEnc();
                Class target = classLoader.loadClass(servlet.servletClass);

                PortData port = WsBuilder.toPortData(portInfo, injections, moduleBaseUrl, classLoader);

                HttpListener container = createPojoWsContainer(moduleBaseUrl, port, portInfo.serviceLink, target, context, webApp.contextRoot);
View Full Code Here

                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);

        ServiceInfo serviceInfo = new ServiceInfo();
        serviceInfo.className = HttpServerFactory.class.getName();
View Full Code Here

                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);

        ServiceInfo serviceInfo = new ServiceInfo();
        serviceInfo.className = HttpServerFactory.class.getName();
View Full Code Here

                // merge OpenEJB jndi into Tomcat jndi
                final TomcatJndiBuilder jndiBuilder = new TomcatJndiBuilder(standardContext, webAppInfo, injections);
                jndiBuilder.mergeJndi();

                // add WebDeploymentInfo to ContainerSystem
                final WebContext webContext = new WebContext(appContext);
                webContext.setClassLoader(classLoader);
                webContext.setId(webAppInfo.moduleId);
                webContext.setBindings(bindings);
                webContext.getInjections().addAll(injections);
                appContext.getWebContexts().add(webContext);
                cs.addWebContext(webContext);

                standardContext.setInstanceManager(new JavaeeInstanceManager(webContext, standardContext));
                standardContext.getServletContext().setAttribute(InstanceManager.class.getName(), standardContext.getInstanceManager());
View Full Code Here

            // add context to WebDeploymentInfo
            for (WebAppInfo webAppInfo : contextInfo.appInfo.webApps) {
                boolean isRoot = isRootApplication(standardContext);
                if (("/" + webAppInfo.contextRoot).equals(standardContext.getPath()) || isRoot) {
                    WebContext webContext = getContainerSystem().getWebContext(webAppInfo.moduleId);
                    if (webContext != null) {
                        webContext.setJndiEnc(comp);
                    }

                    try {
                        // Bean Validation
                        standardContext.getServletContext().setAttribute("javax.faces.validator.beanValidator.ValidatorFactory", openejbContext.lookup(Assembler.VALIDATOR_FACTORY_NAMING_CONTEXT.replaceFirst("openejb", "") + webAppInfo.uniqueId));
View Full Code Here

    private RsRegistry rsRegistry;
    private List<String> services = new ArrayList<String>();
    private String virtualHost;

    public void afterApplicationCreated(final WebAppInfo webApp) {
        final WebContext webContext = containerSystem.getWebContext(webApp.moduleId);
        if (webContext == null) {
            return;
        }

        if (!deployedWebApps.add(webApp)) {
            return;
        }

        final ClassLoader classLoader = getClassLoader(webContext.getClassLoader());
        final Collection<Injection> injections = webContext.getInjections();
        final Context context = webContext.getJndiEnc();

        // The spec says:
        //
        // "The resources and providers that make up a JAX-RS application are configured via an application-supplied
        // subclass of Application. An implementation MAY provide alternate mechanisms for locating resource
View Full Code Here

TOP

Related Classes of org.apache.openejb.core.WebContext

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.