Package org.apache.webbeans.config

Examples of org.apache.webbeans.config.WebBeansContext


            }
        }
    }

    private void ensureWebBeansContext(final AppContext appContext) {
        WebBeansContext webBeansContext = appContext.get(WebBeansContext.class);
        if (webBeansContext == null) {
            webBeansContext = appContext.getWebBeansContext();
        }
        if (webBeansContext == null) {

            final Map<Class<?>, Object> services = new HashMap<Class<?>, Object>();

            services.put(JNDIService.class, new OpenEJBJndiService());
            services.put(AppContext.class, appContext);
            services.put(TransactionService.class, new OpenEJBTransactionService());
            services.put(ScannerService.class, new CdiScanner());
            services.put(ELAdaptor.class, new CustomELAdapter(appContext));
            services.put(LoaderService.class, new OptimizedLoaderService());

            final Properties properties = new Properties();
            properties.setProperty(org.apache.webbeans.spi.SecurityService.class.getName(), ManagedSecurityService.class.getName());

            webBeansContext = new WebBeansContext(services, properties);

            webBeansContext.registerService(ContextsService.class, new CdiAppContextsService(webBeansContext, true));
            webBeansContext.registerService(ResourceInjectionService.class, new CdiResourceInjectionService(webBeansContext));

            appContext.setCdiEnabled(false);
            OpenEJBTransactionService.class.cast(services.get(TransactionService.class)).setWebBeansContext(webBeansContext);
        }
View Full Code Here


            if (null == appContext) {
                logger.warning("Application id '" + appInfo.appId + "' not found in: " + Arrays.toString(containerSystem.getAppContextKeys()));
                return;
            } else {
                final WebBeansContext webBeansContext = appContext.getWebBeansContext();
                if (webBeansContext != null) {
                    final ClassLoader old = Thread.currentThread().getContextClassLoader();
                    Thread.currentThread().setContextClassLoader(classLoader);
                    try {
                        webBeansContext.getService(ContainerLifecycle.class).stopApplication(null);
                    } finally {
                        Thread.currentThread().setContextClassLoader(old);
                    }
                }
                final Map<String, Object> cb = appContext.getBindings();
View Full Code Here

            }
        }

        if (context == null) return;

        final WebBeansContext webBeansContext = context.getModuleContext().getAppContext().getWebBeansContext();
        contextsService = webBeansContext.getContextsService();

        contextsService.startContext(RequestScoped.class, null);
    }
View Full Code Here

            }

            JspFactory factory = JspFactory.getDefaultFactory();
            if (factory != null) {
                JspApplicationContext applicationCtx = factory.getJspApplicationContext(standardContext.getServletContext());
                WebBeansContext context = appContext.getWebBeansContext();
                if (context != null && context.getBeanManagerImpl().isInUse()) {
                    // Registering ELResolver with JSP container
                    ELAdaptor elAdaptor = context.getService(ELAdaptor.class);
                    ELResolver resolver = elAdaptor.getOwbELResolver();
                    applicationCtx.addELResolver(resolver);
                }
            }
        }
View Full Code Here

    private WebBeansListener getWebBeansContext(ContextInfo contextInfo) {
        final AppContext appContext = getContainerSystem().getAppContext(contextInfo.appInfo.appId);

        if (appContext == null) return null;

        final WebBeansContext webBeansContext = appContext.getWebBeansContext();

        if (webBeansContext == null) return null;

        return new WebBeansListener(webBeansContext);
    }
View Full Code Here

    @Override
    public void contextEntered(ThreadContext oldContext, ThreadContext newContext) {

        final BeanContext beanContext = newContext.getBeanContext();

        final WebBeansContext webBeansContext = beanContext.getModuleContext().getAppContext().getWebBeansContext();
        final ContextsService contextsService = webBeansContext.getContextsService();

        final Context requestContext = contextsService.getCurrentContext(RequestScoped.class);

        if (requestContext == null) {
            contextsService.startContext(RequestScoped.class, null);
View Full Code Here

        }
        StartupObject startupObject = (StartupObject) object;
        AppInfo appInfo = startupObject.getAppInfo();
        ClassLoader classLoader = startupObject.getAppContext().getClassLoader();

        WebBeansContext webBeansContext = startupObject.getAppContext().getWebBeansContext();
        final AlternativesManager alternativesManager = webBeansContext.getAlternativesManager();
        final DecoratorsManager decoratorsManager = webBeansContext.getDecoratorsManager();
        final InterceptorsManager interceptorsManager = webBeansContext.getInterceptorsManager();

        final HashSet<String> ejbClasses = new HashSet<String>();

        for (EjbJarInfo ejbJar : appInfo.ejbJars) {
            for (EnterpriseBeanInfo bean : ejbJar.enterpriseBeans) {
                ejbClasses.add(bean.ejbClass);
            }
        }

        final AnnotationManager annotationManager = webBeansContext.getAnnotationManager();

        for (EjbJarInfo ejbJar : appInfo.ejbJars) {
            final BeansInfo beans = ejbJar.beans;

            if (beans == null) continue;
View Full Code Here

    public InstanceContext newInstance() throws Exception {
        ThreadContext callContext = new ThreadContext(this, null, Operation.INJECTION);
        ThreadContext oldContext = ThreadContext.enter(callContext);

        WebBeansContext webBeansContext = null;
        AbstractInjectionTargetBean<Object> beanDefinition = null;
        ConstructorInjectionBean<Object> beanConstructor = null;
        if (!isDynamicallyImplemented()) { // not a dynamic proxy implementation
            webBeansContext = getModuleContext().getAppContext().getWebBeansContext();

            beanDefinition = get(CdiEjbBean.class);

            beanConstructor = new ConstructorInjectionBean<Object>(webBeansContext, beanClass);

            if (beanDefinition == null) {
                beanDefinition = beanConstructor;
            }
        }

        try {
            final Context ctx = this.getJndiEnc();
            final Class beanClass = this.getBeanClass();

            CurrentCreationalContext<Object> currentCreationalContext = get(CurrentCreationalContext.class);
            CreationalContext<Object> creationalContext = (currentCreationalContext != null) ? currentCreationalContext.get() : null;

            if (creationalContext == null && !isDynamicallyImplemented()) {
                creationalContext = webBeansContext.getBeanManagerImpl().createCreationalContext(beanDefinition);
            }

            // Create bean instance
            final Object beanInstance;
            if (!isDynamicallyImplemented()) {
View Full Code Here

        return clazz.cast(bean);
    }

    public <T> void inject(T instance, CreationalContext<T> ctx) {

        WebBeansContext webBeansContext = getModuleContext().getAppContext().getWebBeansContext();

        AbstractInjectionTargetBean<Object> beanDefinition = get(CdiEjbBean.class);

        final ConstructorInjectionBean<Object> beanConstructor = new ConstructorInjectionBean<Object>(webBeansContext, beanClass);

        if (beanDefinition == null) {
            beanDefinition = beanConstructor;
        }

        if (!(ctx instanceof CreationalContextImpl)) {
            ctx = webBeansContext.getCreationalContextFactory().wrappedCreationalContext(ctx, beanDefinition);
        }

        Object oldInstanceUnderInjection = AbstractInjectable.instanceUnderInjection.get();
        boolean isInjectionToAnotherBean = false;
        try {
View Full Code Here

            throw new OpenEJBException(messages.format("createApplication.failed", appInfo.path), t);
        }
    }

    private void ensureWebBeansContext(AppContext appContext) {
        WebBeansContext webBeansContext = appContext.get(WebBeansContext.class);
        if (webBeansContext == null) webBeansContext = appContext.getWebBeansContext();
        if (webBeansContext == null) {

            final Map<Class<?>, Object> services = new HashMap<Class<?>, Object>();

            services.put(AppContext.class, appContext);
            services.put(TransactionService.class, new OpenEJBTransactionService());
            services.put(ContextsService.class, new CdiAppContextsService(true));
            services.put(ResourceInjectionService.class, new CdiResourceInjectionService());
            services.put(ScannerService.class, new CdiScanner());
            services.put(ELAdaptor.class, (ELAdaptor) new CustomELAdapter(appContext));
            final Properties properties = new Properties();
            properties.setProperty(org.apache.webbeans.spi.SecurityService.class.getName(), ManagedSecurityService.class.getName());
            webBeansContext = new WebBeansContext(services, properties);
            appContext.setCdiEnabled(false);
        }

        appContext.set(WebBeansContext.class, webBeansContext);
        appContext.setWebBeansContext(webBeansContext);
View Full Code Here

TOP

Related Classes of org.apache.webbeans.config.WebBeansContext

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.