Package org.apache.webbeans.config

Examples of org.apache.webbeans.config.WebBeansContext


        if (beanContext == null) return;
        ModuleContext moduleContext = beanContext.getModuleContext();
        //TODO its not clear what the scope for one of these context should be: ejb, module, or app
        //For now, go with the attachment of the BeanManager to AppContext
        AppContext appContext = moduleContext.getAppContext();
        WebBeansContext owbContext = appContext.getWebBeansContext();
        if (owbContext == null) {
//            throw new IllegalStateException("WebBeansContext not initialized in appContext " + appContext);
            return;
        }
        Object oldOWBContext = singletonService.contextEntered(owbContext);
View Full Code Here


        services.put(ResourceInjectionService.class, new CdiResourceInjectionService());
        services.put(ScannerService.class, new CdiScanner());

        optional(services, ConversationService.class, "org.apache.webbeans.jsf.DefaultConversationService");

        WebBeansContext webBeansContext = new WebBeansContext(services, properties);
        appContext.set(WebBeansContext.class, webBeansContext);
        Object old = contextEntered(webBeansContext);
        try {
            setConfiguration(webBeansContext.getOpenWebBeansConfiguration());
            try {
                webBeansContext.getService(ContainerLifecycle.class).startApplication(startupObject);
            } catch (Exception e) {
                throw new RuntimeException("couldn't start owb context", e);
            }
        } finally {
            contextExited(old);
View Full Code Here

    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

        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

    }

    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

    }

    public Object inject(Object o) throws OpenEJBException {

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

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

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

            // Create bean instance
            final Context initialContext = (Context) new InitialContext().lookup("java:");
            final Context unwrap = InjectionProcessor.unwrap(initialContext);
            final InjectionProcessor injectionProcessor = new InjectionProcessor(o, injections, unwrap);
View Full Code Here

    }

    @Override
    public void initialize(StartupObject startupObject) {
        //share owb singletons
        WebBeansContext webBeansContext = startupObject.getAppContext().get(WebBeansContext.class);
        if (webBeansContext != null) {
            return;
        }
        Object old = contextEntered(null);
        try {
View Full Code Here

        }

        services.put(ContextsService.class, new CdiAppContextsService(true));
        services.put(ResourceInjectionService.class, new CdiResourceInjectionService());
        services.put(ScannerService.class, new CdiScanner());
        WebBeansContext webBeansContext = new WebBeansContext(services, properties);
        //must be last since it copies stuff
        OpenEJBLifecycle lifecycle = new OpenEJBLifecycle(webBeansContext);
        webBeansContext.registerService(ContainerLifecycle.class, lifecycle);

        WebBeansContext oldContext = GeronimoSingletonService.contextEntered(webBeansContext);
        //from OWB's WebBeansConfigurationListener
        try {
            if (startup == null) {
                //this should only be used for servlet tests
                StartupObject startupObject = new StartupObject(new AppContext("none", SystemInstance.get(), Thread.currentThread().getContextClassLoader(), null, null, true), new AppInfo(),
View Full Code Here

        }
        return webBeansContext;
    }

    public static ScheduledExecutorService initializeServletContext(WebBeansContext webBeansContext, ServletContext servletContext) {
        WebBeansContext oldContext = GeronimoSingletonService.contextEntered(webBeansContext);
        try {
            OpenEJBLifecycle lifecycle = (OpenEJBLifecycle) webBeansContext.getService(ContainerLifecycle.class);
            //lifecycle.startServletContext(servletContext);
            //startServletContext will eventually call the static method  initializeServletContext, which will return a ThreadPool reference
            //We do need to keep that reference to prevent the thread leak
View Full Code Here

    public static GeronimoSingletonService getInstance() {
        return INSTANCE;
    }

    public static WebBeansContext contextEntered(WebBeansContext newContext) {
        final WebBeansContext oldContext = contexts.get();
        contexts.set(newContext);
        return oldContext;
    }
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.