javax.enterprise.inject.spi.configurator.ObserverMethodConfigurator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cdi-api Show documentation
Show all versions of cdi-api Show documentation
APIs for CDI (Contexts and Dependency Injection for Java EE)
/*
* JBoss, Home of Professional Open Source
* Copyright 2016, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.enterprise.inject.spi.configurator;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.Set;
import javax.enterprise.event.ObserverException;
import javax.enterprise.event.Reception;
import javax.enterprise.event.TransactionPhase;
import javax.enterprise.inject.spi.AfterBeanDiscovery;
import javax.enterprise.inject.spi.AnnotatedMethod;
import javax.enterprise.inject.spi.EventContext;
import javax.enterprise.inject.spi.ObserverMethod;
import javax.enterprise.inject.spi.ProcessObserverMethod;
/**
*
* An {@link ObserverMethodConfigurator} can configure an {@link ObserverMethod}. The container must provide an implementation
* of this interface.
*
*
*
* This configurator is not thread safe and shall not be used concurrently.
*
*
* @param type of the event the configured ObserverMethod will observe
* @author Antoine Sabot-Durand
* @see ProcessObserverMethod#configureObserverMethod()
* @see AfterBeanDiscovery#addObserverMethod()
* @since 2.0
*/
public interface ObserverMethodConfigurator {
/**
* Read observer meta data from a existing {@link java.lang.reflect.Method}
*
* @param method to read meta data from
* @return self
*/
ObserverMethodConfigurator read(Method method);
/**
* Read observer meta data from a existing {@link AnnotatedMethod}
*
* @param method to read meta data from
* @return self
*/
ObserverMethodConfigurator read(AnnotatedMethod> method);
/**
* Read observer meta data from a existing ObserverMethod
*
* @param method to read meta data from
* @return self
*/
ObserverMethodConfigurator read(ObserverMethod method);
/**
* Set the class of the Bean containing this observer. If not set, the extension class is used.
*
* @param type the bean class containing this configurator.
* @return self
*/
ObserverMethodConfigurator beanClass(Class> type);
/**
* Set the type of the observed event
*
* @param type of the observed event
* @return self
*/
ObserverMethodConfigurator observedType(Type type);
/**
* Add the qualifier to the observed event
*
* @param qualifier to add to event
* @return self
*/
ObserverMethodConfigurator addQualifier(Annotation qualifier);
/**
* Add all the qualifiers to the Observed event
*
* @param qualifiers to add to event
* @return self
*/
ObserverMethodConfigurator addQualifiers(Annotation... qualifiers);
/**
* Add all the qualifiers to the Observed event
*
* @param qualifiers to add to event
* @return self
*/
ObserverMethodConfigurator addQualifiers(Set qualifiers);
/**
* Replace all qualifiers on the Observed event.
*
* @param qualifiers to put on event
* @return self
*/
ObserverMethodConfigurator qualifiers(Annotation... qualifiers);
/**
* Replace all qualifiers on the Observed event.
*
* @param qualifiers to put on event
* @return self
*/
ObserverMethodConfigurator qualifiers(Set qualifiers);
/**
* Set the {@link Reception} mode for the observer to build
*
* @param reception reception type
* @return self
*/
ObserverMethodConfigurator reception(Reception reception);
/**
* Set the {@link TransactionPhase} for the observer to build
*
* @param transactionPhase phase for the observer
* @return self
*/
ObserverMethodConfigurator transactionPhase(TransactionPhase transactionPhase);
/**
* Set the priority for the observer to build
*
* @param priority priority of the observer
* @return self
*/
ObserverMethodConfigurator priority(int priority);
/**
* Define an operation that accepts a context of a fired event.
*
* @param callback to call for the event notification
* @return self
*/
ObserverMethodConfigurator notifyWith(EventConsumer callback);
/**
* Allows modification of the asynchronous status of the observer to build.
*
* @param async async status
* @return self
*/
ObserverMethodConfigurator async(boolean async);
/**
* Represents an operation that accepts a context of a fired event.
*
* @author Martin Kouba
*
* @param
* @see EventContext
*/
@FunctionalInterface
interface EventConsumer {
/**
*
* @param eventContext
* @throws Exception The thrown checked exception is wrapped and rethrown as an (unchecked) {@link ObserverException}
*/
void accept(EventContext eventContext) throws Exception;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy