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

项目:cito    文件:Extension.java   
/**
     * 
     * @param e
     * @param beanManager
     */
    public void registerMessageEvent(@Observes ProcessObserverMethod<Message, ?> e) {
        final ObserverMethod<Message> method = e.getObserverMethod();
        for (Annotation a : method.getObservedQualifiers()) {
            if (a instanceof OnConnected) {
                registerMessageObserver(OnConnected.class, method);
//              e.veto(); //  CDI 2.0
            } else if (a instanceof OnSend) {
                registerMessageObserver(OnSend.class, method);
//              e.veto(); //  CDI 2.0
            } else if (a instanceof OnSubscribe) {
                registerMessageObserver(OnSubscribe.class, method);
//              e.veto(); //  CDI 2.0
            } else if (a instanceof OnUnsubscribe) {
                registerMessageObserver(OnUnsubscribe.class, method);
//              e.veto(); //  CDI 2.0
            } else if (a instanceof OnDisconnect) {
                registerMessageObserver(OnDisconnect.class, method);
//              e.veto(); //  CDI 2.0
            }
        }
    }
项目:cito    文件:ExtensionTest.java   
@Test
@SuppressWarnings("unchecked")
public void register_onConnected() {
    final ProcessObserverMethod<Message, ?> processObserverMethod = mock(ProcessObserverMethod.class);
    final ObserverMethod<Message> observerMethod = mock(ObserverMethod.class);
    when(processObserverMethod.getObserverMethod()).thenReturn(observerMethod);
    when(observerMethod.getObservedQualifiers()).thenReturn(singleton(OnConnected.Literal.onConnected()));

    this.extension.registerMessageEvent(processObserverMethod);

    assertEquals(observerMethod, getMessageObservers(this.extension).get(OnConnected.class).iterator().next());

    verify(processObserverMethod).getObserverMethod();
    verify(observerMethod).getObservedQualifiers();
    verifyNoMoreInteractions(processObserverMethod, observerMethod);
}
项目:cito    文件:ExtensionTest.java   
@Test
@SuppressWarnings("unchecked")
public void register_onSend() {
    final ProcessObserverMethod<Message, ?> processObserverMethod = mock(ProcessObserverMethod.class);
    final ObserverMethod<Message> observerMethod = mock(ObserverMethod.class);
    when(processObserverMethod.getObserverMethod()).thenReturn(observerMethod);
    when(observerMethod.getObservedQualifiers()).thenReturn(singleton(onSend("")));

    this.extension.registerMessageEvent(processObserverMethod);

    assertEquals(observerMethod, getMessageObservers(this.extension).get(OnSend.class).iterator().next());

    verify(processObserverMethod).getObserverMethod();
    verify(observerMethod).getObservedQualifiers();
    verifyNoMoreInteractions(processObserverMethod, observerMethod);
}
项目:cito    文件:ExtensionTest.java   
@Test
@SuppressWarnings("unchecked")
public void register_onSubscribe() {
    final ProcessObserverMethod<Message, ?> processObserverMethod = mock(ProcessObserverMethod.class);
    final ObserverMethod<Message> observerMethod = mock(ObserverMethod.class);
    when(processObserverMethod.getObserverMethod()).thenReturn(observerMethod);
    when(observerMethod.getObservedQualifiers()).thenReturn(singleton(onSubscribe("")));

    this.extension.registerMessageEvent(processObserverMethod);

    assertEquals(observerMethod, getMessageObservers(this.extension).get(OnSubscribe.class).iterator().next());

    verify(processObserverMethod).getObserverMethod();
    verify(observerMethod).getObservedQualifiers();
    verifyNoMoreInteractions(processObserverMethod, observerMethod);
}
项目:cito    文件:ExtensionTest.java   
@Test
@SuppressWarnings("unchecked")
public void register_onUnsubscribe() {
    final ProcessObserverMethod<Message, ?> processObserverMethod = mock(ProcessObserverMethod.class);
    final ObserverMethod<Message> observerMethod = mock(ObserverMethod.class);
    when(processObserverMethod.getObserverMethod()).thenReturn(observerMethod);
    when(observerMethod.getObservedQualifiers()).thenReturn(singleton(onUnsubscribe("")));

    this.extension.registerMessageEvent(processObserverMethod);

    assertEquals(observerMethod, getMessageObservers(this.extension).get(OnUnsubscribe.class).iterator().next());

    verify(processObserverMethod).getObserverMethod();
    verify(observerMethod).getObservedQualifiers();
    verifyNoMoreInteractions(processObserverMethod, observerMethod);
}
项目:cito    文件:ExtensionTest.java   
@Test
@SuppressWarnings("unchecked")
public void register_onDisconnect() {
    final ProcessObserverMethod<Message, ?> processObserverMethod = mock(ProcessObserverMethod.class);
    final ObserverMethod<Message> observerMethod = mock(ObserverMethod.class);
    when(processObserverMethod.getObserverMethod()).thenReturn(observerMethod);
    when(observerMethod.getObservedQualifiers()).thenReturn(singleton(onDisconnect()));

    this.extension.registerMessageEvent(processObserverMethod);

    assertEquals(observerMethod, getMessageObservers(this.extension).get(OnDisconnect.class).iterator().next());

    verify(processObserverMethod).getObserverMethod();
    verify(observerMethod).getObservedQualifiers();
    verifyNoMoreInteractions(processObserverMethod, observerMethod);
}
项目:Camel    文件:CdiCamelExtension.java   
private <T extends EventObject> void camelEventNotifiers(@Observes ProcessObserverMethod<T, ?> pom) {
    // Only activate Camel event notifiers for explicit Camel event observers, that is, an observer method for a super type won't activate notifiers.
    Type type = pom.getObserverMethod().getObservedType();
    // Camel events are raw types
    if (type instanceof Class && Class.class.cast(type).getPackage().equals(AbstractExchangeEvent.class.getPackage())) {
        Set<Annotation> qualifiers = pom.getObserverMethod().getObservedQualifiers();
        if (qualifiers.isEmpty()) {
            eventQualifiers.add(ANY);
        } else if (qualifiers.size() == 1 && qualifiers.stream()
            .filter(isAnnotationType(Named.class)).findAny().isPresent()) {
            eventQualifiers.add(DEFAULT);
        } else {
            eventQualifiers.addAll(qualifiers);
        }
    }
}
项目:cito    文件:Extension.java   
/**
 * 
 * @param e
 * @param beanManager
 */
public void registerDestinationEvent(@Observes ProcessObserverMethod<DestinationChanged, ?> e) {
    final ObserverMethod<DestinationChanged> method = e.getObserverMethod();
    for (Annotation a : method.getObservedQualifiers()) {
        if (a instanceof OnAdded)
            registerDestinationObserver(OnAdded.class, method);
        if (a instanceof OnRemoved)
            registerDestinationObserver(OnRemoved.class, method);
    }
}
项目:weld-vertx    文件:VertxExtension.java   
public void processVertxEventObserver(@Observes ProcessObserverMethod<VertxEvent, ?> event) {
    String vertxAddress = getVertxAddress(event.getObserverMethod());
    if (vertxAddress == null) {
        LOGGER.warn("VertxEvent observer found but no @VertxConsumer declared: {0}", event.getObserverMethod());
        return;
    }
    LOGGER.debug("Vertx message consumer found: {0}", event.getObserverMethod());
    consumerAddresses.add(vertxAddress);
}
项目:camel-cdi    文件:CdiCamelExtension.java   
private <T extends EventObject> void camelEventNotifiers(@Observes ProcessObserverMethod<T, ?> pom) {
    // Only activate Camel event notifiers for explicit Camel event observers, that is,
    // an observer method for a super type won't activate notifiers.
    Type type = pom.getObserverMethod().getObservedType();
    // Camel events are raw types
    if (type instanceof Class && Class.class.cast(type).getPackage().equals(AbstractExchangeEvent.class.getPackage())) {
        Set<Annotation> qualifiers = pom.getObserverMethod().getObservedQualifiers();
        if (qualifiers.isEmpty())
            eventQualifiers.add(ANY);
        else if (qualifiers.size() == 1 && qualifiers.stream().anyMatch(isAnnotationType(Named.class)))
            eventQualifiers.add(DEFAULT);
        else
            eventQualifiers.addAll(qualifiers);
    }
}
项目:Mastering-Java-EE-Development-with-WildFly    文件:ObserverExtension.java   
<K, V> void processObserverMethod(@Observes ProcessObserverMethod<K, V> pom) {
    logger.info("finished the scanning process");
    processObserverMethod++;
}
项目:microbean-kubernetes-client-cdi    文件:KubernetesClientExtension.java   
private final <X> void processObserverMethod(@Observes final ProcessObserverMethod<Event, X> event, final BeanManager beanManager) {
  if (event != null && beanManager != null && !this.startWatcher && event.getObserverMethod() != null) {
    this.startWatcher = true;
  }
}
项目:Java-EE    文件:LifeCycleLogger.java   
<T, X> void logLifecycleEvent(@Observes ProcessObserverMethod<T, X> event) {
    LOGGER.info("ProcessObserverMethod: observerMethod" + event.getObserverMethod());
}