Java 类javax.enterprise.inject.spi.ProducerFactory 实例源码

项目:testee.fi    文件:MockingExtension.java   
private <T> ProducerFactory<T> factory(final Object mock) {
    return new ProducerFactory<T>() {
        @Override
        public <T1> Producer<T1> createProducer(final Bean<T1> bean) {
            return new Producer<T1>() {

                @Override
                public T1 produce(final CreationalContext<T1> ctx) {
                    return (T1) mock;
                }

                @Override
                public void dispose(final T1 instance) {
                }

                @Override
                public Set<InjectionPoint> getInjectionPoints() {
                    return Collections.emptySet();
                }
            };
        }
    };
}
项目:Mastering-Java-EE-Development-with-WildFly    文件:InjectSPITestCase.java   
@Test
public void testProducer() {
    logger.info("starting producer spi test");
    CDI<Object> cdi = current();
    BeanManager beanManager = cdi.select(BeanManager.class).get();

    AnnotatedField<? super AnotherFactory> field = this
            .<AnotherFactory, AnnotatedField<AnotherFactory>>getAnnotatedMember(AnotherFactory.class, "jessie",
                    beanManager);
    Bean<AnotherFactory> declaringBean = cast(beanManager.resolve(beanManager.getBeans(AnotherFactory.class)));
    ProducerFactory<AnotherFactory> producerFactory = beanManager.getProducerFactory(field, declaringBean);
    Producer<Toy> producer = cast(producerFactory.createProducer(null));
    assertNotNull(producer);
    assertTrue(producer.getInjectionPoints().isEmpty());
    Toy jessie = producer.produce(beanManager.<Toy>createCreationalContext(null));
    assertEquals("Jessie", jessie.getName());
}
项目:Mastering-Java-EE-Development-with-WildFly    文件:ObserverExtension.java   
<T> void producerFactory(@Observes ProducerFactory<T> pf) {
    logger.info("finished the scanning process");
    producerFactory++;
}
项目:tapestry-jpa-transactions    文件:NoopBeanManager.java   
@Override
public <X> ProducerFactory<X> getProducerFactory(AnnotatedField<? super X> field, Bean<X> declaringBean)
{
    // TODO Auto-generated method stub
    return null;
}
项目:tapestry-jpa-transactions    文件:NoopBeanManager.java   
@Override
public <X> ProducerFactory<X> getProducerFactory(AnnotatedMethod<? super X> method, Bean<X> declaringBean)
{
    // TODO Auto-generated method stub
    return null;
}
项目:tapestry-jpa-transactions    文件:NoopBeanManager.java   
@Override
public <T, X> Bean<T> createBean(BeanAttributes<T> attributes, Class<X> beanClass, ProducerFactory<X> producerFactory)
{
    // TODO Auto-generated method stub
    return null;
}
项目:jbromo    文件:BeanManagerExt.java   
@Override
public <T, X> Bean<T> createBean(final BeanAttributes<T> arg0,
        final Class<X> arg1, final ProducerFactory<X> arg2) {
    return this.beanManager.createBean(arg0, arg1, arg2);
}
项目:jbromo    文件:BeanManagerExt.java   
@Override
public <X> ProducerFactory<X> getProducerFactory(
        final AnnotatedField<? super X> arg0, final Bean<X> arg1) {
    return this.beanManager.getProducerFactory(arg0, arg1);
}
项目:jbromo    文件:BeanManagerExt.java   
@Override
public <X> ProducerFactory<X> getProducerFactory(
        final AnnotatedMethod<? super X> arg0, final Bean<X> arg1) {
    return this.beanManager.getProducerFactory(arg0, arg1);
}