Package javax.enterprise.context.spi

Examples of javax.enterprise.context.spi.CreationalContext


    @Test
    public void testSimpleInterceptor3() {
        reset();
        Bean bean = beanManager.getBeans(Ball.class).iterator().next();
        CreationalContext creationalContext = beanManager.createCreationalContext(bean);
        Ball ball = (Ball) bean.create(creationalContext);
        ball.lob();
        assert !Defender.defended;
        assert Ball.played;
        assert Goalkeeper.caught;
View Full Code Here


                {
                    // there is no nice way to explain the Java Compiler that we are handling the same type T,
                    // therefore we need completely drop the type information :( 
                    Contextual contextual = componentEntry.getKey();
                    Object instance = componentEntry.getValue();
                    CreationalContext creational = creationalContextMap.get(contextual);
                   
                    contextual.destroy(instance, creational);
                }
            }
        }
View Full Code Here

        if (managerRetrieved) {
            synchronized (beanManager) {
                T managedObject;
                AnnotatedType annotatedType = beanManager.createAnnotatedType(c);
                InjectionTarget it = beanManager.createInjectionTarget(annotatedType);
                CreationalContext cc = beanManager.createCreationalContext(null);
                managedObject = (T) it.produce(cc);
                it.inject(managedObject, cc);
                it.postConstruct(managedObject);
                cdiBeanToContext.put(managedObject, new CdiInjectionContext(it, cc));
View Full Code Here

                    String beanId = componentEntry.getKey();
                    // there is no nice way to explain the Java Compiler that we are handling the same type T,
                    // therefore we need completely drop the type information :(
                    Contextual contextual = beanManager.getPassivationCapableBean(beanId);
                    Object instance = componentEntry.getValue();
                    CreationalContext creational = creationalContextMap.get(beanId);

                    contextual.destroy(instance, creational);
                }
            }
        }
View Full Code Here

    public static <T> T getBeanByType(Class<T> type) {

        BeanManager bm = getBeanManager();
        Bean bean = bm.getBeans(type).iterator().next();
        CreationalContext ctx = bm.createCreationalContext(bean); // could be inlined below
        T o = (T) bm.getReference(bean, type, ctx); // could be inlined with return
        return o;
    }
View Full Code Here

    }

    public static <T> T getBeanByName(String name) {
        BeanManager bm = getBeanManager();
        Bean bean = bm.getBeans(name).iterator().next();
        CreationalContext ctx = bm.createCreationalContext(bean); // could be inlined below
        T o = (T) bm.getReference(bean, bean.getBeanClass(), ctx); // could be inlined with return
        return o;
    }
View Full Code Here

    }

    public static <T> T getBeanByNameAndType(String name,Class<T>type ) {
        BeanManager bm = getBeanManager();
        Bean bean = bm.getBeans(name).iterator().next();
        CreationalContext ctx = bm.createCreationalContext(bean); // could be inlined below
        T o = (T) bm.getReference(bean, type, ctx); // could be inlined with return
        return o;
    }
View Full Code Here

            @Override
            public Class<? extends Annotation> annotationType() {
                return qualifier;
            }
        }).iterator().next();
        CreationalContext ctx = bm.createCreationalContext(bean); // could be inlined below
        T o = (T) bm.getReference(bean, type, ctx); // could be inlined with return
        return o;
    }
View Full Code Here

                bean = bm.resolve(beans);
            }

            // create the MBean instance with cdi if possible or manually otherwise
            final Object instance;
            final CreationalContext creationalContext;
            if (bean == null) {
                try {
                    instance = clazz.newInstance();
                } catch (final InstantiationException e) {
                    logger.error("the mbean " + mbeanClass + " can't be registered because it can't be instantiated", e);
View Full Code Here

                try {
                    final ObjectName on = new ObjectName((String) objectName);
                    if (server.isRegistered(on)) {
                        server.unregisterMBean(on);
                    }
                    final CreationalContext cc = creationalContextForAppMbeans.remove(on);
                    if (cc != null) {
                        cc.release();
                    }
                } catch (final InstanceNotFoundException e) {
                    logger.warning("can't unregister " + objectName + " because the mbean was not found", e);
                } catch (final MBeanRegistrationException e) {
                    logger.warning("can't unregister " + objectName, e);
View Full Code Here

TOP

Related Classes of javax.enterprise.context.spi.CreationalContext

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.