javax.enterprise.inject.spi.configurator.BeanConfigurator Maven / Gradle / Ivy
/*
* 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.configurator;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.Instance;
import javax.enterprise.inject.spi.AnnotatedType;
import javax.enterprise.inject.spi.BeanAttributes;
import javax.enterprise.inject.spi.InjectionPoint;
import javax.enterprise.inject.spi.PassivationCapable;
import javax.enterprise.util.TypeLiteral;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import java.util.Set;
import java.util.function.BiConsumer;
import java.util.function.Function;
public interface BeanConfigurator {
/**
*
* Set the class of the configured Bean.
* If not set, the extension class is used.
*
* @param beanClass class of the configured bean
* @return self
*/
BeanConfigurator beanClass(Class> beanClass);
/**
*
* Add an InjectionPoint to the configured bean
*
* @param injectionPoint the injectionPoint to add
* @return self
*/
BeanConfigurator addInjectionPoint(InjectionPoint injectionPoint);
/**
*
* Add InjectionPoints to the configured bean
*
* @param injectionPoints the injectionPoints to add
* @return self
*/
BeanConfigurator addInjectionPoints(InjectionPoint... injectionPoints);
/**
*
* Add InjectionPoints to the configured bean
*
* @param injectionPoints the injectionPoints to add
* @return self
*/
BeanConfigurator addInjectionPoints(Set injectionPoints);
/**
*
* Replace InjectionPoints for the configured bean
*
* @param injectionPoints the injectionPoints for the configured bean
* @return self
*/
BeanConfigurator injectionPoints(InjectionPoint... injectionPoints);
/**
*
* Replace InjectionPoints for the configured bean
*
* @param injectionPoints the injectionPoints for the configured bean
* @return self
*/
BeanConfigurator injectionPoints(Set injectionPoints);
/**
*
* Make the configured bean implements {@link PassivationCapable} and its Id for passivation.
*
*
* @param id for
* @see PassivationCapable#getId()
* @return self
*/
BeanConfigurator id(String id);
/**
*
* Set a {@link Function} to create a bean instance from a {@link CreationalContext}
*
* @param callback the Function to create the instance
* @return self
*/
BeanConfigurator createWith(Function, U> callback);
/**
*
*
* @param callback use as produced instance for the configured bean
* @return self
*/
BeanConfigurator produceWith(Function, U> callback);
/**
*
* Set a {@link BiConsumer} to destroy a bean instance from a {@link CreationalContext}.
* If no destroy callback is specified, a NOOP dispose callback is automatically set.
*
* @param callback the BiConsumer to destroy the instance
* @return self
*/
BeanConfigurator destroyWith(BiConsumer> callback);
/**
*
* Set a {@link BiConsumer} to destroy a bean instance.
* If no dispose callback is specified, a NOOP dispose callback is automatically set.
*
* @param callback the Consumer to dispose the instance
* @return self
*/
BeanConfigurator disposeWith(BiConsumer> callback);
/**
* Read the information from the given annotated type. All relevant information is overwritten.
*
* @param type class to read information from
* @return self
*/
BeanConfigurator read(AnnotatedType type);
/**
* Read the information from the given bean attributes. All relevant information is overwritten.
*
* @param beanAttributes beanAttributes to read information from
* @return self
*/
BeanConfigurator read(BeanAttributes> beanAttributes);
/**
*
* Add a type to the bean types
*
* @param type the type to add
* @return self
*/
BeanConfigurator addType(Type type);
/**
*
* Add a type to the bean types
*
* @param typeLiteral the type to add
* @return self
*/
BeanConfigurator addType(TypeLiteral> typeLiteral);
/**
*
* Add types to the bean types
*
* @param types types to add
* @return self
*/
BeanConfigurator addTypes(Type... types);
/**
*
* Add types to the bean types
*
* @param types types to add
* @return self
*/
BeanConfigurator addTypes(Set types);
/**
* Adds an unrestricted set of bean types for the given type as if it represented a bean class of a managed bean.
* Illegal bean types are omitted.
*
* @param type to build the closure from
* @return self
*/
BeanConfigurator addTransitiveTypeClosure(Type type);
/**
*
* Replace bean types
*
* @param types the types of the configured bean
* @return self
*/
BeanConfigurator types(Type... types);
/**
*
* Replace bean types
*
* @param types the types of the configured bean
* @return self
*/
BeanConfigurator types(Set types);
/**
*
* Replace Bean scope
*
* @param scope new scope for the configured bean
* @return self
*/
BeanConfigurator scope(Class extends Annotation> scope);
/**
*
* Add a qualifier to the configured bean
*
* @param qualifier qualifier to add
* @return self
*/
BeanConfigurator addQualifier(Annotation qualifier);
/**
*
* Add qualifiers to the bean.
*
* @param qualifiers qualifiers to add
* @return self
*/
BeanConfigurator addQualifiers(Annotation... qualifiers);
/**
*
* Add qualifiers to the bean.
*
* @param qualifiers qualifiers to add
* @return self
*/
BeanConfigurator addQualifiers(Set qualifiers);
/**
* Replace all qualifiers.
*
* @param qualifiers qualifiers for the build bean
* @return self
*/
BeanConfigurator qualifiers(Annotation... qualifiers);
/**
* Replace all qualifiers.
*
* @param qualifiers for the configured bean
* @return self
*/
BeanConfigurator qualifiers(Set qualifiers);
/**
*
* Add a stereotype to the configured bean
*
* @param stereotype stereotype to add
* @return self
*/
BeanConfigurator addStereotype(Class extends Annotation> stereotype);
/**
*
* Add stereotypes to the configured bean
*
* @param stereotypes stereotypes to add
* @return self
*/
BeanConfigurator addStereotypes(Set> stereotypes);
/**
*
* Replace stereotypes on the configured bean
*
* @param stereotypes for the configured bean
* @return self
*/
BeanConfigurator stereotypes(Set> stereotypes);
/**
*
* Set the name of the configured bean
*
* @param name name for the configured bean
* @return self
*/
BeanConfigurator name(String name);
/**
*
* Change the alternative status of the configured bean.
* By default the configured bean is not an alternative.
*
* @param value value for alternative property
* @return self
*/
BeanConfigurator alternative(boolean value);
}