javax.ejb.Singleton Java Examples

The following examples show how to use javax.ejb.Singleton. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BeanTestExtension.java    From BeanTest with Apache License 2.0 3 votes vote down vote up
/**
 * Replaces the meta data of the {@link ProcessAnnotatedType}.
 * 
 * <p>
 * The ProcessAnnotatedType's meta data will be replaced, if the annotated type has one of the following annotations:
 * <ul>
 * <li> {@link Stateless}
 * <li> {@link MessageDriven}
 * <li> {@link Interceptor}
 * <li> {@link Singleton}
 * </ul>
 *
 * @param <X> the type of the ProcessAnnotatedType
 * @param pat the annotated type representing the class being processed
 */
public <X> void processInjectionTarget(@Observes @WithAnnotations({Stateless.class, MessageDriven.class, Interceptor.class, Singleton.class}) ProcessAnnotatedType<X> pat) {
    if (pat.getAnnotatedType().isAnnotationPresent(Stateless.class) || pat.getAnnotatedType().isAnnotationPresent(MessageDriven.class)) {
        modifiyAnnotatedTypeMetadata(pat);
    } else if (pat.getAnnotatedType().isAnnotationPresent(Interceptor.class)) {
        processInterceptorDependencies(pat);
    } else if(pat.getAnnotatedType().isAnnotationPresent(Singleton.class)) {
        addApplicationScopedAndTransactionalToSingleton(pat);
    }
}