Search in sources :

Example 1 with Observes

use of javax.enterprise.event.Observes in project camel by apache.

the class CdiCamelExtension method beans.

private void beans(@Observes ProcessBean<?> pb, BeanManager manager) {
    cdiBeans.add(pb.getBean());
    // Lookup for CDI event endpoint injection points
    pb.getBean().getInjectionPoints().stream().filter(ip -> CdiEventEndpoint.class.equals(getRawType(ip.getType()))).forEach(ip -> {
        Type type = ip.getType() instanceof ParameterizedType ? ((ParameterizedType) ip.getType()).getActualTypeArguments()[0] : Object.class;
        String uri = eventEndpointUri(type, ip.getQualifiers());
        cdiEventEndpoints.put(uri, new CdiEventEndpoint<>(uri, type, ip.getQualifiers(), manager));
    });
}
Also used : CdiSpiHelper.isAnnotationType(org.apache.camel.cdi.CdiSpiHelper.isAnnotationType) Produces(javax.enterprise.inject.Produces) AfterBeanDiscovery(javax.enterprise.inject.spi.AfterBeanDiscovery) LoggerFactory(org.slf4j.LoggerFactory) ProcessBean(javax.enterprise.inject.spi.ProcessBean) Endpoint(org.apache.camel.Endpoint) PropertyInject(org.apache.camel.PropertyInject) EventObject(java.util.EventObject) ProcessProducerField(javax.enterprise.inject.spi.ProcessProducerField) ProcessObserverMethod(javax.enterprise.inject.spi.ProcessObserverMethod) Map(java.util.Map) Observes(javax.enterprise.event.Observes) ProducerTemplate(org.apache.camel.ProducerTemplate) ANY(org.apache.camel.cdi.AnyLiteral.ANY) Method(java.lang.reflect.Method) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Collectors.toSet(java.util.stream.Collectors.toSet) CamelContextAware(org.apache.camel.CamelContextAware) Annotated(javax.enterprise.inject.spi.Annotated) Extension(javax.enterprise.inject.spi.Extension) CdiSpiHelper.hasType(org.apache.camel.cdi.CdiSpiHelper.hasType) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ProcessAnnotatedType(javax.enterprise.inject.spi.ProcessAnnotatedType) BeanManagerHelper.getReference(org.apache.camel.cdi.BeanManagerHelper.getReference) Set(java.util.Set) ResourceHelper.getResource(org.apache.camel.cdi.ResourceHelper.getResource) CdiSpiHelper.getRawType(org.apache.camel.cdi.CdiSpiHelper.getRawType) ProcessProducerMethod(javax.enterprise.inject.spi.ProcessProducerMethod) BeanInject(org.apache.camel.BeanInject) Stream(java.util.stream.Stream) Type(java.lang.reflect.Type) CdiEventEndpoint.eventEndpointUri(org.apache.camel.cdi.CdiEventEndpoint.eventEndpointUri) Annotation(java.lang.annotation.Annotation) ConsumerTemplate(org.apache.camel.ConsumerTemplate) EXCLUDED(org.apache.camel.cdi.Excluded.EXCLUDED) Bean(javax.enterprise.inject.spi.Bean) RoutesBuilder(org.apache.camel.RoutesBuilder) EndpointInject(org.apache.camel.EndpointInject) Component(org.apache.camel.Component) AbstractExchangeEvent(org.apache.camel.management.event.AbstractExchangeEvent) Collectors.collectingAndThen(java.util.stream.Collectors.collectingAndThen) AnnotatedType(javax.enterprise.inject.spi.AnnotatedType) Produce(org.apache.camel.Produce) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) ProcessProducer(javax.enterprise.inject.spi.ProcessProducer) Collections.newSetFromMap(java.util.Collections.newSetFromMap) APPLICATION_SCOPED(org.apache.camel.cdi.ApplicationScopedLiteral.APPLICATION_SCOPED) BeanManagerHelper.getReferencesByType(org.apache.camel.cdi.BeanManagerHelper.getReferencesByType) FluentProducerTemplate(org.apache.camel.FluentProducerTemplate) AfterDeploymentValidation(javax.enterprise.inject.spi.AfterDeploymentValidation) Stream.concat(java.util.stream.Stream.concat) Named(javax.inject.Named) DEFAULT(org.apache.camel.cdi.DefaultLiteral.DEFAULT) ServiceStatus(org.apache.camel.ServiceStatus) CamelContext(org.apache.camel.CamelContext) Default(javax.enterprise.inject.Default) Logger(org.slf4j.Logger) CdiSpiHelper.getQualifiers(org.apache.camel.cdi.CdiSpiHelper.getQualifiers) Consume(org.apache.camel.Consume) Predicate.isEqual(java.util.function.Predicate.isEqual) STARTUP(org.apache.camel.cdi.Startup.Literal.STARTUP) InjectionException(javax.enterprise.inject.InjectionException) Converter(org.apache.camel.Converter) ProcessInjectionTarget(javax.enterprise.inject.spi.ProcessInjectionTarget) TypeConverter(org.apache.camel.TypeConverter) ParameterizedType(java.lang.reflect.ParameterizedType) RouteContainer(org.apache.camel.model.RouteContainer) CdiSpiHelper.hasAnnotation(org.apache.camel.cdi.CdiSpiHelper.hasAnnotation) InjectionPoint(javax.enterprise.inject.spi.InjectionPoint) BeanManager(javax.enterprise.inject.spi.BeanManager) ParameterizedType(java.lang.reflect.ParameterizedType) CdiSpiHelper.isAnnotationType(org.apache.camel.cdi.CdiSpiHelper.isAnnotationType) CdiSpiHelper.hasType(org.apache.camel.cdi.CdiSpiHelper.hasType) ProcessAnnotatedType(javax.enterprise.inject.spi.ProcessAnnotatedType) CdiSpiHelper.getRawType(org.apache.camel.cdi.CdiSpiHelper.getRawType) Type(java.lang.reflect.Type) AnnotatedType(javax.enterprise.inject.spi.AnnotatedType) BeanManagerHelper.getReferencesByType(org.apache.camel.cdi.BeanManagerHelper.getReferencesByType) ParameterizedType(java.lang.reflect.ParameterizedType)

Aggregations

Annotation (java.lang.annotation.Annotation)1 Method (java.lang.reflect.Method)1 ParameterizedType (java.lang.reflect.ParameterizedType)1 Type (java.lang.reflect.Type)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections.newSetFromMap (java.util.Collections.newSetFromMap)1 EventObject (java.util.EventObject)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Set (java.util.Set)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Predicate.isEqual (java.util.function.Predicate.isEqual)1 Collectors.collectingAndThen (java.util.stream.Collectors.collectingAndThen)1 Collectors.toSet (java.util.stream.Collectors.toSet)1 Stream (java.util.stream.Stream)1 Stream.concat (java.util.stream.Stream.concat)1 Observes (javax.enterprise.event.Observes)1 Default (javax.enterprise.inject.Default)1 InjectionException (javax.enterprise.inject.InjectionException)1