Examples of WebBeansContext


Examples of org.apache.webbeans.config.WebBeansContext

            logger.error("the mbean " + mbeanClass + " can't be registered", e);
        }
    }

    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, 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);
            appContext.setCdiEnabled(false);
        }

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

Examples of org.apache.webbeans.config.WebBeansContext

            }

            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

Examples of org.apache.webbeans.config.WebBeansContext

    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

Examples of org.apache.webbeans.config.WebBeansContext

            cl = new MultipleClassLoader(oldClassLoader, ThreadSingletonServiceImpl.class.getClassLoader());
        } else {
            cl = oldClassLoader;
        }
        Thread.currentThread().setContextClassLoader(cl);
        WebBeansContext webBeansContext;
        Object old = null;
        try {
            webBeansContext = new WebBeansContext(services, properties);
            appContext.set(WebBeansContext.class, webBeansContext);
            old = contextEntered(webBeansContext);
            setConfiguration(webBeansContext.getOpenWebBeansConfiguration());
            try {
                webBeansContext.getService(ContainerLifecycle.class).startApplication(startupObject);
            } catch (Exception e) {
                throw new OpenEJBRuntimeException("couldn't start owb context", e);
            }
        } finally {
            contextExited(old);
View Full Code Here

Examples of org.apache.webbeans.config.WebBeansContext

    public Object contextEntered(WebBeansContext newOWBContext) {
        return enter(newOWBContext);
    }

    public static WebBeansContext enter(WebBeansContext newOWBContext) {
        WebBeansContext oldContext = contexts.get();
        contexts.set(newOWBContext);
        contextMessage(newOWBContext, "Enter:");
        return oldContext;
    }
View Full Code Here

Examples of org.apache.webbeans.config.WebBeansContext

        return get();
    }

    public static WebBeansContext get()
    {
        WebBeansContext context = contexts.get();
        if (context == null) {
            // Fallback strategy is to just grab the first AppContext and assume it is the right one
            // This kind of algorithm could be greatly improved
            final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
View Full Code Here

Examples of org.apache.webbeans.config.WebBeansContext

    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;

        webBeansContext = getModuleContext().getAppContext().getWebBeansContext();
        beanDefinition = get(CdiEjbBean.class);

        if (isDynamicallyImplemented()) {
            if (!InvocationHandler.class.isAssignableFrom(getProxyClass())) {
                throw new OpenEJBException("proxy class can only be InvocationHandler");
            }
        }

        ConstructorInjectionBean<Object> beanConstructor = new ConstructorInjectionBean<Object>(webBeansContext, getManagedClass());
        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) {
                creationalContext = webBeansContext.getBeanManagerImpl().createCreationalContext(beanDefinition);
            }

            // Create bean instance
            final Object beanInstance;
            final InjectionProcessor injectionProcessor;
View Full Code Here

Examples of org.apache.webbeans.config.WebBeansContext

        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, getManagedClass());

        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

Examples of org.apache.webbeans.config.WebBeansContext

            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();
        }
View Full Code Here

Examples of org.apache.webbeans.config.WebBeansContext

    }

    public Object newInstance(Class beanClass) throws OpenEJBException {

        try {
            final WebBeansContext webBeansContext = getAppContext().getWebBeansContext();

            final ConstructorInjectionBean<Object> beanDefinition = new ConstructorInjectionBean<Object>(webBeansContext, beanClass).complete();

            final CreationalContext<Object> creationalContext = webBeansContext.getBeanManagerImpl().createCreationalContext(beanDefinition);

            // Create bean instance
            final Object o = beanDefinition.create(creationalContext);
            final Context initialContext = (Context) new InitialContext().lookup("java:");
            final Context unwrap = InjectionProcessor.unwrap(initialContext);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.