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

项目: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());
}
项目:jpa-unit    文件:JpaUnitCdiExtensionTest.java   
@Test
public void testRegisterProducer() {
    // GIVEN
    final JpaUnitCdiExtension extension = new JpaUnitCdiExtension();

    // WHEN
    extension.registerProducer(producer);

    // THEN
    verify(producer).getProducer();
    verify(producer).setProducer(producerCaptor.capture());
    verifyNoMoreInteractions(producer);

    final Producer<EntityManager> captured = producerCaptor.getValue();
    assertThat(captured, not(nullValue()));
    assertThat(captured, instanceOf(EntityManagerProducerProxy.class));
}
项目:axon-cdi    文件:AxonCdiExtension.java   
<T, X extends CommandBus> void processCommandBusProducer(
        @Observes final ProcessProducer<T, X> processProducer,
        final BeanManager beanManager) {

    AnnotatedMember<T> annotatedMember = processProducer.getAnnotatedMember();

    if (annotatedMember.isAnnotationPresent(AutoConfigure.class)) {
        Producer<X> originalProducer = processProducer.getProducer();
        Producer<X> producer = new AutoConfiguringCommandBusProducer<>(originalProducer,
                annotatedMember, getAggregateRoots(), getCommandHandlers(), beanManager);
        processProducer.setProducer(producer);
    }
}
项目:axon-cdi    文件:AxonCdiExtension.java   
<T, X extends EventStore> void processEventStoreProducer(
        @Observes final ProcessProducer<T, X> processProducer,
        final BeanManager beanManager) {
    AnnotatedMember<T> annotatedMember = processProducer.getAnnotatedMember();
    if (annotatedMember.isAnnotationPresent(AutoConfigure.class)) {
        Producer<X> originalProducer = processProducer.getProducer();
        Producer<X> producer = new AutoConfiguringEventStoreProducer<>(originalProducer,
                annotatedMember,
                getEventHandlers(),
                getSagas(), beanManager);
        processProducer.setProducer(producer);
    }
}
项目:axon-cdi    文件:AxonCdiExtension.java   
<T, X extends Snapshotter> void processSnapshotterProducer(
        @Observes final ProcessProducer<T, X> processProducer,
        final BeanManager beanManager) {
    Producer<X> originalProducer = processProducer.getProducer();
    AnnotatedMember<T> annotatedMember = processProducer.getAnnotatedMember();
    if (annotatedMember.isAnnotationPresent(AutoConfigure.class)) {
        Producer<X> producer = new AutoConfiguringAggregateSnapshotterProducer<>(originalProducer,
                annotatedMember, getAggregateRoots(), beanManager);
        processProducer.setProducer(producer);
    }
}
项目:axon-cdi    文件:AxonCdiExtension.java   
<T, X extends SagaRepository<?>> void processSagaRepositoryProducer(
        @Observes final ProcessProducer<T, X> processProducer,
        final BeanManager beanManager) {
    Producer<X> originalProducer = processProducer.getProducer();
    AnnotatedMember<T> annotatedMember = processProducer.getAnnotatedMember();
    if (annotatedMember.isAnnotationPresent(AutoConfigure.class)) {
        Producer<X> producer = new AutoConfiguringSagaRepositoryProducer<>(originalProducer,
                annotatedMember, beanManager);
        processProducer.setProducer(producer);
    }
}
项目:axon-cdi    文件:AbstractAutoConfiguringProducer.java   
public AbstractAutoConfiguringProducer(final Producer<X> wrappedProducer,
        final AnnotatedMember<?> annotatedMember,
        final BeanManager beanManager) {
    this.wrappedProducer = wrappedProducer;
    this.beanManager = beanManager;
    this.annotatedMember = annotatedMember;
}
项目:axon-cdi    文件:AutoConfiguringEventStoreProducer.java   
public AutoConfiguringEventStoreProducer(final Producer<X> wrappedProducer,
        final AnnotatedMember<?> annotatedMember,
        final Set<HandlerInfo> eventHandlersInfo,
        final Set<SagaInfo> sagasInfo,
        final BeanManager beanManager) {
    super(wrappedProducer, annotatedMember, beanManager);
    this.eventHandlersInfo = eventHandlersInfo;
    this.sagaManagersInfo = SagaManagerInfo.from(sagasInfo);
}
项目:axon-cdi    文件:AutoConfiguringCommandBusProducer.java   
public AutoConfiguringCommandBusProducer(Producer<X> wrappedProducer,
        AnnotatedMember<?> annotatedMember,
        Set<AggregateRootInfo> aggregateRootsInfo,
        Set<HandlerInfo> commandHandlersInfo,
        BeanManager beanManager) {
    super(wrappedProducer, annotatedMember, beanManager);
    this.commandHandlersInfo = commandHandlersInfo;
    this.aggregateRootsInfo = aggregateRootsInfo;
}
项目:deltaspike    文件:MockAwareProducerWrapper.java   
public MockAwareProducerWrapper(BeanManager beanManager,
                                Producer<T> wrapped,
                                List<Type> beanTypes,
                                List<Annotation> qualifiers)
{
    this.beanManager = beanManager;
    this.wrapped = wrapped;
    this.beanTypes = beanTypes;
    this.qualifiers = qualifiers;
}
项目:jpa-unit    文件:EntityManagerProducerProxy.java   
public EntityManagerProducerProxy(final Producer<EntityManager> proxied) {
    this.proxied = proxied;
}
项目:Camel    文件:CdiCamelEnvironment.java   
<T extends CamelContext> Producer<T> camelContextProducer(Producer<T> delegate, Annotated annotated, BeanManager manager, CdiCamelExtension extension) {
    CamelContextProducer<T> producer = new CamelContextProducer<>(delegate, annotated, manager, extension);
    return hasBundleContext ? new CamelContextOsgiProducer<>(producer) : producer;
}
项目:Camel    文件:DelegateInjectionTarget.java   
DelegateInjectionTarget(InjectionTarget<T> target, Producer<T> producer) {
    super(producer);
    this.delegate = target;
}
项目:Camel    文件:CamelContextInjectionTarget.java   
CamelContextInjectionTarget(InjectionTarget<T> target, Producer<T> producer) {
    super(target, producer);
}
项目:Camel    文件:CamelContextProducer.java   
CamelContextProducer(Producer<T> delegate, Annotated annotated, BeanManager manager, CdiCamelExtension extension) {
    super(delegate);
    this.annotated = annotated;
    this.manager = manager;
    this.extension = extension;
}
项目:Camel    文件:DelegateProducer.java   
DelegateProducer(Producer<T> delegate) {
    this.delegate = delegate;
}
项目:Camel    文件:CamelContextOsgiProducer.java   
CamelContextOsgiProducer(Producer<T> delegate) {
    super(delegate);
}
项目:axon-cdi    文件:AbstractAutoConfiguringProducer.java   
protected final Producer<X> getWrappedProducer() {
    return wrappedProducer;
}
项目:axon-cdi    文件:AutoConfiguringAggregateSnapshotterProducer.java   
public AutoConfiguringAggregateSnapshotterProducer(final Producer<X> wrappedProducer,
        final AnnotatedMember<?> annotatedMember, final Set<AggregateRootInfo> aggregateRoots,
        final BeanManager beanManager) {
    super(wrappedProducer, annotatedMember, beanManager);
    this.aggregateRootsInfo = aggregateRoots;
}
项目:axon-cdi    文件:AutoConfiguringSagaRepositoryProducer.java   
public AutoConfiguringSagaRepositoryProducer(final Producer<X> wrappedProducer,
        final AnnotatedMember<?> annotatedMember, final BeanManager beanManager) {
    super(wrappedProducer, annotatedMember, beanManager);
}
项目:spearal-jpa2    文件:SpearalExtension.java   
public EntityManagerProducerWrapper(Producer<EntityManager> wrappedProducer) {
    this.wrappedProducer = wrappedProducer;
}
项目:spearal-jpa2    文件:SpearalExtension.java   
public EntityManagerFactoryProducerWrapper(Producer<EntityManagerFactory> wrappedProducer, BeanManager beanManager) {
    this.wrappedProducer = wrappedProducer;
    this.beanManager = beanManager;
}
项目:camel-cdi    文件:CdiCamelEnvironment.java   
<T extends CamelContext> Producer<T> camelContextProducer(Producer<T> delegate, Annotated annotated, BeanManager manager) {
    CamelContextProducer<T> producer = new CamelContextProducer<>(delegate, annotated, manager);
    return hasBundleContext ? new CamelContextOsgiProducer<>(producer) : producer;
}
项目:camel-cdi    文件:DelegateInjectionTarget.java   
DelegateInjectionTarget(InjectionTarget<T> target, Producer<T> producer) {
    super(producer);
    this.delegate = target;
}
项目:camel-cdi    文件:CamelContextInjectionTarget.java   
CamelContextInjectionTarget(InjectionTarget<T> target, Producer<T> producer) {
    super(target, producer);
}
项目:camel-cdi    文件:CamelContextProducer.java   
CamelContextProducer(Producer<T> delegate, Annotated annotated, BeanManager manager) {
    super(delegate);
    this.annotated = annotated;
    this.manager = manager;
}
项目:camel-cdi    文件:DelegateProducer.java   
DelegateProducer(Producer<T> delegate) {
    this.delegate = delegate;
}
项目:camel-cdi    文件:CamelContextOsgiProducer.java   
CamelContextOsgiProducer(Producer<T> delegate) {
    super(delegate);
}
项目:tomee    文件:CdiPlugin.java   
@Override
public Producer<T> getProducer() {
    return new EjbProducer<T>(this, bean);
}
项目:deltaspike    文件:MockExtension.java   
public <X, T> void onProcessProducer(@Observes ProcessProducer<X, T> processProducer, BeanManager beanManager)
{
    if (!isActivated)
    {
        return;
    }

    for (MockFilter mockFilter : mockFilters)
    {
        if (!mockFilter.isMockedImplementationSupported(beanManager, processProducer.getAnnotatedMember()))
        {
            return;
        }
    }

    final Producer<T> originalProducer = processProducer.getProducer();
    AnnotatedMember<X> annotatedMember = processProducer.getAnnotatedMember();
    List<Annotation> qualifiers = new ArrayList<Annotation>();
    for (Annotation annotation : annotatedMember.getAnnotations())
    {
        if (beanManager.isQualifier(annotation.annotationType()))
        {
            qualifiers.add(annotation);
        }
    }

    Typed typed = annotatedMember.getAnnotation(Typed.class);

    List<Type> foundTypes = new ArrayList<Type>();
    if (typed != null)
    {
        Collections.addAll(foundTypes, typed.value());
    }
    else if (annotatedMember.getBaseType() instanceof Class)
    {
        foundTypes.addAll(extractTypes((Class)annotatedMember.getBaseType()));
    }

    if (foundTypes.isEmpty())
    {
        return;
    }

    processProducer.setProducer(new MockAwareProducerWrapper<T>(
        beanManager, originalProducer, foundTypes, qualifiers));
}