All Downloads are FREE. Search and download functionalities are using the official Maven repository.

javax.enterprise.inject.spi.BeanManager Maven / Gradle / Ivy

There is a newer version: 6.0-6
Show newest version
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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;

import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
import java.util.List;
import java.util.Set;

import javax.el.ELResolver;
import javax.el.ExpressionFactory;
import javax.enterprise.context.spi.Context;
import javax.enterprise.context.spi.Contextual;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.AmbiguousResolutionException;
import javax.enterprise.inject.InjectionException;
import javax.enterprise.inject.UnsatisfiedResolutionException;


/**
 * The interface Manager provides operations for
 * obtaining the contextual instance of the webbeans. There are operations
 * related with;
 * 
 * 
    *
  • Adding new webbeans
  • *
  • Adding new contexts
  • *
  • Adding new decorators
  • *
  • Adding new interceptors
  • *
  • Firing the observer events
  • *
  • Creating the instance of the contextual beans
  • *
  • Resolution of beans, interceptors, decorators and observers
  • *
  • Other utility methods etc..
  • *
* *

* There is always one root manager in the system. You can set the * current activity via call to the {@link BeanManager#setCurrent(Class)} method. *

* * @version $Rev$ $Date$ */ public interface BeanManager { /** * Returns a bean instance reference for the given bean. * * @param bean bean that its reference is getting * @param beanType bean api type that is implemented by the proxy * @param ctx creational context is used to destroy any object with scope @Dependent * @return bean reference * @throws IllegalArgumentException if given bean type is not api type of the given bean object */ public Object getReference(Bean bean, Type beanType, CreationalContext ctx); /** * Gets injection point bean reference. * * @param injectionPoint injection point definition * @param ctx creational context that is passed to the {@link Bean#create(CreationalContext)} method * @return bean reference * @throws UnsatisfiedResolutionException if no bean found for the given injection point * @throws AmbiguousResolutionException if more than one bean found */ public Object getInjectableReference(InjectionPoint injectionPoint, CreationalContext ctx); /** * Returns a new creational context implementation. * * @return new creational context */ public CreationalContext createCreationalContext(Contextual contextual); /** * Returns set of beans that their api types contain * given bean type and given qualifiers. * *

* If no qualifier is given, @Current is assumed. *

* * @param beanType required bean type * @param qualifiers required qualifiers * @return set of beans * @throws IllegalArgumentException given bean type is a {@link TypeVariable} * @throws IllegalArgumentException given qualifier annotation is not a qualifier * @throws IllegalArgumentException same qualifier is given */ public Set> getBeans(Type beanType, Annotation... qualifiers); /** * Returns set of beans with given name. * * @param name name of the bean * @return set of beans with given name */ public Set> getBeans(String name); /** * Returns passivation capable bean given id. * * @param id bean id * @return passivation capable bean given id */ public Bean getPassivationCapableBean(String id); /** * Returns a bean object that is resolved according to the type safe resolution rules. * * @param bean class info * @param beans set of beans * @return bean that is resolved according to the type safe resolution rules * @throws AmbiguousResolutionException if ambigious exists */ public Bean resolve(Set> beans); /** * Fires an event with given even object and qualifiers. * * @param event observer event object * @param qualifiers event qualifiers * @throws IllegalArgumentException event object contains a {@link TypeVariable} * @throws IllegalArgumentException given qualifier annotation is not a qualifier * @throws IllegalArgumentException same qualifier is given */ public void fireEvent(Object event, Annotation... qualifiers); /** * Returns set of observer methods. * * @param event type * @param event even object * @param qualifiers event qualifiers * @return set of observer methods */ public Set> resolveObserverMethods(T event, Annotation... qualifiers); /** * Returns a list of decorator. * * @param types bean types of the decorated bean * @param qualifiers decorated bean qualifiers * @return list of decorator * @throws IllegalArgumentException given qualifier annotation is not a qualifier * @throws IllegalArgumentException same qualifier is given * @throws IllegalArgumentException if types is empty set */ List> resolveDecorators(Set types, Annotation... qualifiers); /** * Returns a list of interceptor. * * @param type interception type * @param interceptorBindings interceptor bindings * @return list of interceptor * @throws IllegalArgumentException given binding annotation is not a binding * @throws IllegalArgumentException same binding is given * @throws IllegalArgumentException binding is not an interceptor binding */ List> resolveInterceptors(InterceptionType type, Annotation... interceptorBindings); /** * Validates injection point. * * @param injectionPoint injection point * @throws InjectionException if problem exist */ public void validate(InjectionPoint injectionPoint); /** * Returns true if given type is a scope type, false otherwise. * * @param annotationType annotation type * @return true if given type is a scope type, false otherwise */ public boolean isScope(Class annotationType); /** * Returns true if given type is a normal scope type, false otherwise. * * @param annotationType annotation type * @return true if given type is a scope type, false otherwise */ public boolean isNormalScope(Class annotationType); /** * Returns true if given type is a passivating scope type, false otherwise. * * @param annotationType annotation type * @return true if given type is a scope type, false otherwise */ public boolean isPassivatingScope(Class annotationType); /** * Returns true if given type is a qualifier, false otherwise. * * @param annotationType annotation type * @return true if given type is a qualifier, false otherwise */ public boolean isQualifier(Class annotationType); /** * Returns true if given type is a interceptor binding, false otherwise. * * @param annotationType annotation type * @return true if given type is a interceptor binding, false otherwise */ public boolean isInterceptorBinding(Class annotationType); /** * Returns true if given type is a stereotype type, false otherwise. * * @param annotationType annotation type * @return true if given type is a stereotype, false otherwise */ public boolean isStereotype(Class annotationType); /** * Returns a set of meta-annotations that are defined on the binding * * @param qualifier binding class * @return a set of meta-annotations that are defined on the binding */ public Set getInterceptorBindingDefinition(Class qualifier); /** * Returns a set of meta-annotations that are defined on the stereotype type. * * @param stereotype stereotype type class * @return a set of meta-annotations that are defined on the stereotype type */ public Set getStereotypeDefinition(Class stereotype); /** * Returns a context with given scope type. * * @param scope scope type class type * @return a context with given scope type */ public Context getContext(Class scope); /** * Returns el resolver. * * @return el resolver */ public ELResolver getELResolver(); /** * Returns a {@link AnnotatedType} instance for the given * class. * * @param class type * @param type class * @return a {@link AnnotatedType} instance */ public AnnotatedType createAnnotatedType(Class type); /** * Creates a new instance of injection target. * * @param bean type * @param type annotated type * @return injection target */ public InjectionTarget createInjectionTarget(AnnotatedType type); /** * Wrapped around given expression factory. * @param expressionFactory expression factory * @return wrapped expression factory */ public ExpressionFactory wrapExpressionFactory(javax.el.ExpressionFactory expressionFactory); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy