本文整理匯總了Java中javax.enterprise.inject.spi.AfterBeanDiscovery.addBean方法的典型用法代碼示例。如果您正苦於以下問題:Java AfterBeanDiscovery.addBean方法的具體用法?Java AfterBeanDiscovery.addBean怎麽用?Java AfterBeanDiscovery.addBean使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.enterprise.inject.spi.AfterBeanDiscovery
的用法示例。
在下文中一共展示了AfterBeanDiscovery.addBean方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: registerNoSQLSourceBeans
import javax.enterprise.inject.spi.AfterBeanDiscovery; //導入方法依賴的package包/類
/**
*/
void registerNoSQLSourceBeans(@Observes AfterBeanDiscovery abd, BeanManager bm) {
if (bm.getBeans(clusterClass, DefaultLiteral.INSTANCE).isEmpty()) {
// Iterate profiles and create Cluster/Session bean for each profile, that application code can @Inject
for(String profile: getService().profileNames()) {
log.log(Level.INFO, "Registering bean for profile {0}", profile);
abd.addBean(bm.createBean(
new ClusterBeanAttributes(bm.createBeanAttributes(bm.createAnnotatedType(clusterClass)), profile),
clusterClass, new ClusterProducerFactory(profile, clusterClass)));
abd.addBean(bm.createBean(
new SessionBeanAttributes(bm.createBeanAttributes(bm.createAnnotatedType(sessionClass)), profile),
sessionClass, new SessionProducerFactory(profile, sessionClass)));
}
} else {
log.log(Level.INFO, "Application contains a default Cluster Bean, automatic registration will be disabled");
}
}
示例2: registerNoSQLSourceBeans
import javax.enterprise.inject.spi.AfterBeanDiscovery; //導入方法依賴的package包/類
void registerNoSQLSourceBeans(@Observes AfterBeanDiscovery abd, BeanManager bm) {
if (bm.getBeans(mongoClientClass, DefaultLiteral.INSTANCE).isEmpty()) {
// Iterate profiles and create Cluster/Session bean for each profile, that application code can @Inject
for(String profile: getService().profileNames()) {
log.log(Level.INFO, "Registering bean for profile {0}", profile);
abd.addBean(bm.createBean(
new MongoClientBeanAttributes(bm.createBeanAttributes(bm.createAnnotatedType(mongoClientClass)), profile),
mongoClientClass, new MongoClientProducerFactory(profile, mongoClientClass)));
abd.addBean(bm.createBean(
new MongoDatabaseBeanAttributes(bm.createBeanAttributes(bm.createAnnotatedType(mongoDatabaseClass)), profile),
mongoDatabaseClass, new MongoDatabaseProducerFactory(profile, mongoDatabaseClass)));
}
} else {
log.log(Level.INFO, "Application contains a default MongoClient Bean, automatic registration will be disabled");
}
}
示例3: processMojoCdiProducerFields
import javax.enterprise.inject.spi.AfterBeanDiscovery; //導入方法依賴的package包/類
@SuppressWarnings("unused")
// will be called automatically by the CDI container once the bean discovery has finished
private void processMojoCdiProducerFields(@Observes AfterBeanDiscovery event, BeanManager beanManager)
throws MojoExecutionException {
Class<?> cls = getClass();
Set<Field> fields = Sets.newHashSet();
while (cls != AbstractCDIMojo.class) {
fields.addAll(Sets.newHashSet(cls.getFields()));
fields.addAll(Sets.newHashSet(cls.getDeclaredFields()));
cls = cls.getSuperclass();
}
for (Field f : fields) {
if (f.isAnnotationPresent(MojoProduces.class)) {
try {
f.setAccessible(true);
event.addBean(
new CdiBeanWrapper<Object>(f.get(this), f.getGenericType(), f.getType(), CDIUtil.getCdiQualifiers(f)));
} catch (Throwable t) {
throw new MojoExecutionException("Could not process CDI producer field of the Mojo.", t);
}
}
}
}
示例4: processMojoCdiProducerMethods
import javax.enterprise.inject.spi.AfterBeanDiscovery; //導入方法依賴的package包/類
@SuppressWarnings({ "unused", "unchecked", "rawtypes" })
// will be called automatically by the CDI container once the bean discovery has finished
private void processMojoCdiProducerMethods(@Observes AfterBeanDiscovery event, BeanManager beanManager)
throws MojoExecutionException {
// no method parameter injection possible at the moment since the container is not yet initialized at this point!
Class<?> cls = getClass();
Set<Method> methods = Sets.newHashSet();
while (cls != AbstractCDIMojo.class) {
methods.addAll(Sets.newHashSet(cls.getMethods()));
methods.addAll(Sets.newHashSet(cls.getDeclaredMethods()));
cls = cls.getSuperclass();
}
for (Method m : methods) {
if (m.getReturnType() != Void.class && m.isAnnotationPresent(MojoProduces.class)) {
try {
event.addBean(new CdiProducerBean(m, this, beanManager, m.getGenericReturnType(), m.getReturnType(),
CDIUtil.getCdiQualifiers(m)));
} catch (Throwable t) {
throw new MojoExecutionException("Could not process CDI producer method of the Mojo.", t);
}
}
}
}
示例5: afterBeanDiscovery
import javax.enterprise.inject.spi.AfterBeanDiscovery; //導入方法依賴的package包/類
void afterBeanDiscovery(@Observes AfterBeanDiscovery abd) {
CommonBean<String[]> stringBean = CommonBeanBuilder.newBuilder(String[].class)
.beanClass(CommandLineArgsExtension.class)
.scope(Dependent.class)
.createSupplier(() -> args)
.addQualifier(CommandLineArgs.Literal.INSTANCE)
.addType(String[].class)
.addType(Object.class).build();
abd.addBean(stringBean);
CommonBean<List> listBean = CommonBeanBuilder.newBuilder(List.class)
.beanClass(CommandLineArgsExtension.class)
.scope(Dependent.class)
.createSupplier(() -> argsList)
.addQualifier(DefaultLiteral.INSTANCE)
.addType(List.class)
.addType(Object.class).build();
abd.addBean(listBean);
}
示例6: addJCacheBeans
import javax.enterprise.inject.spi.AfterBeanDiscovery; //導入方法依賴的package包/類
public void addJCacheBeans(final @Observes AfterBeanDiscovery afterBeanDiscovery)
{
if (!ACTIVATED)
{
return;
}
if (cacheManagerFound && cacheProviderFound) {
return;
}
cachingProvider = Caching.getCachingProvider();
if (!cacheManagerFound)
{
cacheManager = cachingProvider.getCacheManager(
cachingProvider.getDefaultURI(),
cachingProvider.getDefaultClassLoader(),
new Properties());
afterBeanDiscovery.addBean(new CacheManagerBean(cacheManager));
}
if (!cacheProviderFound)
{
afterBeanDiscovery.addBean(new CacheProviderBean(cachingProvider));
}
}
示例7: afterBeanDiscovery
import javax.enterprise.inject.spi.AfterBeanDiscovery; //導入方法依賴的package包/類
/**
* {@link javax.enterprise.inject.spi.ProcessBean} CDI event observer.
*
* @param afterEvent CDI Event instance.
*/
public void afterBeanDiscovery(@Observes AfterBeanDiscovery afterEvent) {
for (ClientProxyBean proxyBean : _createdProxyBeans) {
_logger.debug("Adding ClientProxyBean for bean Service " + proxyBean.getServiceName() + ". Service Interface type is " + proxyBean.getServiceInterface().getName());
afterEvent.addBean(proxyBean);
_beanDeploymentMetaData.addClientProxy(proxyBean);
}
for (ReferenceInvokerBean invokerBean : _createdInvokerBeans) {
_logger.debug("Adding ReferenceInvokerBean for bean Service " + invokerBean.getServiceName());
afterEvent.addBean(invokerBean);
_beanDeploymentMetaData.addReferenceInvoker(invokerBean);
}
afterEvent.addBean(new BeanDeploymentMetaDataCDIBean(_beanDeploymentMetaData));
afterEvent.addBean(new ContextBean());
afterEvent.addBean(new MessageBean());
afterEvent.addBean(new ExchangeBean());
_logger.debug("CDI Bean discovery process completed.");
}
示例8: createBeans
import javax.enterprise.inject.spi.AfterBeanDiscovery; //導入方法依賴的package包/類
public <X> void createBeans(@Observes AfterBeanDiscovery afterBeanDiscovery, BeanManager beanManager)
{
if (!this.isActivated)
{
return;
}
for (Class<?> originalClass : this.classesToProxy)
{
Bean bean = createBean(originalClass, beanManager);
if (bean != null)
{
afterBeanDiscovery.addBean(bean);
}
}
this.classesToProxy.clear();
}
示例9: installMessageBundleProducerBeans
import javax.enterprise.inject.spi.AfterBeanDiscovery; //導入方法依賴的package包/類
@SuppressWarnings("UnusedDeclaration")
protected void installMessageBundleProducerBeans(@Observes AfterBeanDiscovery abd, BeanManager beanManager)
{
if (!deploymentErrors.isEmpty())
{
abd.addDefinitionError(new IllegalArgumentException("The following MessageBundle problems where found: " +
Arrays.toString(deploymentErrors.toArray())));
return;
}
MessageBundleExtension parentExtension = ParentExtensionStorage.getParentExtension(this);
if (parentExtension != null)
{
messageBundleTypes.addAll(parentExtension.messageBundleTypes);
}
for (AnnotatedType<?> type : messageBundleTypes)
{
abd.addBean(createMessageBundleBean(type, beanManager));
}
}
示例10: addDynamicBeans
import javax.enterprise.inject.spi.AfterBeanDiscovery; //導入方法依賴的package包/類
public void addDynamicBeans(@Observes AfterBeanDiscovery afterBeanDiscovery, BeanManager bm)
{
if (dynamicProducer != null && !dynamicConfigTypes.isEmpty())
{
afterBeanDiscovery.addBean(new DynamicBean(dynamicProducer, dynamicConfigTypes));
}
for (final Class<?> proxyType : dynamicConfigurationBeanClasses)
{
afterBeanDiscovery.addBean(new BeanBuilder(null)
.types(proxyType, Object.class)
.qualifiers(new DefaultLiteral(), new AnyLiteral())
.beanLifecycle(new ProxyConfigurationLifecycle(proxyType))
.scope(ApplicationScoped.class)
.passivationCapable(true)
.id("DeltaSpikeConfiguration#" + proxyType.getName())
.beanClass(proxyType)
.create());
}
}
示例11: afterBeandiscovery
import javax.enterprise.inject.spi.AfterBeanDiscovery; //導入方法依賴的package包/類
void afterBeandiscovery(@Observes AfterBeanDiscovery event) {
if (scopesToActivate != null) {
for (Class<? extends Annotation> scope : scopesToActivate) {
ContextImpl ctx = new ContextImpl(scope);
contexts.add(ctx);
event.addContext(ctx);
}
}
if (beans != null) {
for (Bean<?> bean : beans) {
event.addBean(bean);
}
}
}
示例12: registerNoSQLSourceBeans
import javax.enterprise.inject.spi.AfterBeanDiscovery; //導入方法依賴的package包/類
void registerNoSQLSourceBeans(@Observes AfterBeanDiscovery abd, BeanManager bm) {
if (bm.getBeans(driverClass, DefaultLiteral.INSTANCE).isEmpty()) {
for(String profile: getService().profileNames()) {
log.log(Level.INFO, "Registering bean for profile {0}", profile);
abd.addBean(bm.createBean(
new DriverBeanAttributes(bm.createBeanAttributes(bm.createAnnotatedType(driverClass)), profile),
driverClass, new DriverProducerFactory(profile, driverClass)));
// TODO: uncomment or delete the following.
// abd.addBean(bm.createBean(new SessionBeanAttributes(bm.createBeanAttributes(bm.createAnnotatedType(Session.class)),profile),
// Session.class, new SessionProducerFactory(profile)));
}
} else {
log.log(Level.INFO, "Application contains a default Driver Bean, automatic registration will be disabled");
}
}
示例13: registerNoSQLSourceBeans
import javax.enterprise.inject.spi.AfterBeanDiscovery; //導入方法依賴的package包/類
public void registerNoSQLSourceBeans(@Observes AfterBeanDiscovery afterBeanDiscovery, BeanManager beanManager) {
if (beanManager.getBeans(oPartitionedDatabasePoolClass, DefaultLiteral.INSTANCE).isEmpty()) {
for(String profile: getService().profileNames()) {
LOGGER.log(Level.INFO, "Registering " + oPartitionedDatabasePoolClass + " bean for profile {0}", profile);
afterBeanDiscovery.addBean(getBean(beanManager, oPartitionedDatabasePoolClass, profile));
}
} else {
LOGGER.log(Level.INFO, "Application contains a default " + oPartitionedDatabasePoolClass
+ " Bean, automatic registration will be disabled");
}
}
示例14: afterBeanDiscovery
import javax.enterprise.inject.spi.AfterBeanDiscovery; //導入方法依賴的package包/類
@SuppressWarnings("unused")
void afterBeanDiscovery(@Observes AfterBeanDiscovery abd, BeanManager beanManager) throws Exception {
try (AutoCloseable handle = Performance.time("ConfigViewProducingExtension.afterBeanDiscovery")) {
CommonBean<ConfigView> configViewBean = CommonBeanBuilder.newBuilder(ConfigView.class)
.beanClass(ConfigViewProducingExtension.class)
.scope(Singleton.class)
.addQualifier(DefaultLiteral.INSTANCE)
.createSupplier(() -> configView)
.addType(ConfigView.class)
.addType(Object.class).build();
abd.addBean(configViewBean);
}
}
示例15: afterBeanDiscovery
import javax.enterprise.inject.spi.AfterBeanDiscovery; //導入方法依賴的package包/類
void afterBeanDiscovery(@Observes AfterBeanDiscovery abd, BeanManager beanManager) throws Exception {
try (AutoCloseable handle = Performance.time("XMLConfigProducingExtension.afterBeanDiscovery")) {
CommonBean<URL> urlBean = CommonBeanBuilder.newBuilder(URL.class)
.beanClass(XMLConfigProducingExtension.class)
.scope(Dependent.class)
.addQualifier(XMLConfig.Literal.INSTANCE)
.createSupplier(this::getXMLConfig)
.addType(URL.class)
.addType(Object.class).build();
abd.addBean(urlBean);
}
}