本文整理匯總了Java中javax.enterprise.inject.Any類的典型用法代碼示例。如果您正苦於以下問題:Java Any類的具體用法?Java Any怎麽用?Java Any使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Any類屬於javax.enterprise.inject包,在下文中一共展示了Any類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: mockEndpointFromUri
import javax.enterprise.inject.Any; //導入依賴的package包/類
@Uri("")
@Produces
@Typed(MockEndpoint.class)
// Qualifiers are dynamically added in CdiCamelExtension
private static MockEndpoint mockEndpointFromUri(InjectionPoint ip, @Any Instance<CamelContext> instance, CdiCamelExtension extension) {
Uri uri = getQualifierByType(ip, Uri.class).get();
try {
CamelContext context = uri.context().isEmpty()
? selectContext(ip, instance, extension)
: selectContext(uri.context(), instance);
return context.getEndpoint(uri.value(), MockEndpoint.class);
} catch (Exception cause) {
throw new InjectionException("Error injecting mock endpoint annotated with " + uri
+ " into " + ip, cause);
}
}
示例2: getServices
import javax.enterprise.inject.Any; //導入依賴的package包/類
/**
* Retrieves the services that are available for use with the description for each service.
* The Services are determined by looking up all of the implementations of the
* Customer Service interface that are using the DataService qualifier annotation.
* The DataService annotation contains the service name and description information.
* @return Map containing a list of services available and a description of each one.
*/
public Map<String,String> getServices (){
TreeMap<String,String> services = new TreeMap<String,String>();
logger.fine("Getting CustomerService Impls");
Set<Bean<?>> beans = beanManager.getBeans(CustomerService.class,new AnnotationLiteral<Any>() {
private static final long serialVersionUID = 1L;});
for (Bean<?> bean : beans) {
for (Annotation qualifer: bean.getQualifiers()){
if(DataService.class.getName().equalsIgnoreCase(qualifer.annotationType().getName())){
DataService service = (DataService) qualifer;
logger.fine(" name="+service.name()+" description="+service.description());
services.put(service.name(), service.description());
}
}
}
return services;
}
示例3: AsyncReferenceImpl
import javax.enterprise.inject.Any; //導入依賴的package包/類
@Inject
public AsyncReferenceImpl(InjectionPoint injectionPoint, Vertx vertx, BeanManager beanManager, @Any WeldInstance<Object> instance) {
this.isDone = new AtomicBoolean(false);
this.future = new VertxCompletableFuture<>(vertx);
this.instance = instance;
ParameterizedType parameterizedType = (ParameterizedType) injectionPoint.getType();
Type requiredType = parameterizedType.getActualTypeArguments()[0];
Annotation[] qualifiers = injectionPoint.getQualifiers().toArray(new Annotation[] {});
// First check if there is a relevant async producer method available
WeldInstance<Object> completionStage = instance.select(new ParameterizedTypeImpl(CompletionStage.class, requiredType), qualifiers);
if (completionStage.isAmbiguous()) {
failure(new AmbiguousResolutionException(
"Ambiguous async producer methods for type " + requiredType + " with qualifiers " + injectionPoint.getQualifiers()));
} else if (!completionStage.isUnsatisfied()) {
// Use the produced CompletionStage
initWithCompletionStage(completionStage.getHandler());
} else {
// Use Vertx worker thread
initWithWorker(requiredType, qualifiers, vertx, beanManager);
}
}
示例4: ClientProxyBean
import javax.enterprise.inject.Any; //導入依賴的package包/類
/**
* Public constructor.
*
* @param serviceName The name of the ESB Service being proxied to.
* @param proxyInterface The proxy Interface.
* @param qualifiers The CDI bean qualifiers. Copied from the injection point.
* @param beanDeploymentMetaData Deployment metadata.
*/
public ClientProxyBean(String serviceName, Class<?> proxyInterface, Set<Annotation> qualifiers, BeanDeploymentMetaData beanDeploymentMetaData) {
this._serviceName = serviceName;
this._serviceInterface = proxyInterface;
if (qualifiers != null) {
this._qualifiers = qualifiers;
} else {
this._qualifiers = new HashSet<Annotation>();
this._qualifiers.add(new AnnotationLiteral<Default>() {
});
this._qualifiers.add(new AnnotationLiteral<Any>() {
});
}
_proxyBean = Proxy.newProxyInstance(beanDeploymentMetaData.getDeploymentClassLoader(),
new Class[]{_serviceInterface},
new ClientProxyInvocationHandler(_serviceInterface));
}
示例5: initMetrics
import javax.enterprise.inject.Any; //導入依賴的package包/類
public void initMetrics() throws IOException {
String hostname = metricNameService.getHostName();
Observable.from(beanManager.getBeans(Object.class, new AnnotationLiteral<Any>() {}))
.map(Bean::getBeanClass)
.filter(this::isRESTHandler)
.flatMap(c -> Observable.from(c.getMethods()))
.filter(this::isRESTHandlerMethod)
.subscribe(
method -> {
HTTPMethod httpMethod = getHttpMethod(method);
String uri = getURI(method);
if (isWrite(method, uri)) {
register(RESTMetaData.forWrite(httpMethod, uri, hostname));
} else {
register(RESTMetaData.forRead(httpMethod, uri, hostname));
}
},
t -> logger.warn("Failed to register meta data for REST metrics", t),
() -> {}
);
}
示例6: sendMessageToProducer
import javax.enterprise.inject.Any; //導入依賴的package包/類
@Test
public void sendMessageToProducer(@Uri("direct:produce") ProducerTemplate producer) throws InterruptedException {
long random = Math.round(Math.random() * Long.MAX_VALUE);
produced.expectedMessageCount(1);
produced.expectedBodiesReceived(random);
produced.message(0).predicate(exchange -> {
EventMetadata metadata = exchange.getIn().getHeader("metadata", EventMetadata.class);
return metadata.getType().equals(Long.class) && metadata.getQualifiers().equals(new HashSet<>(Arrays.asList(new AnnotationLiteral<Any>() {}, new AnnotationLiteral<Default>() {})));
});
consumed.expectedMessageCount(1);
consumed.expectedBodiesReceived(random);
producer.sendBody(random);
assertIsSatisfied(2L, TimeUnit.SECONDS, consumed, produced);
}
示例7: initModules
import javax.enterprise.inject.Any; //導入依賴的package包/類
/**
* Initialise all statistics modules that are found in the system
* @param modules
*/
@Inject
protected void initModules(@Any Instance<StatisticsModule> modules) {
log.info("Apache Marmotta StatisticsService starting up ...");
this.modules = new LinkedHashMap<String,StatisticsModule>();
for(StatisticsModule module : modules) {
registerModule(module.getName(),module);
}
if(configurationService.getBooleanConfiguration("statistics.enabled",false)) {
enableAll();
} else {
disableAll();
}
}
示例8: getBeanInstance
import javax.enterprise.inject.Any; //導入依賴的package包/類
@SuppressWarnings("unchecked")
private static <T> T getBeanInstance(final Class<T> type) throws Exception {
BeanManager beanManager = getBeanManager();
final Set<Bean<?>> beans = beanManager.getBeans(Object.class,new AnnotationLiteral<Any>() {
private static final long serialVersionUID = 3612602223649004820L;});
for (Bean<?> iterateBean : beans) {
if(iterateBean.getBeanClass().getName() == type.getName()){
Bean<T> bean = (Bean<T>) iterateBean;
final CreationalContext<T> creationalContext = beanManager.createCreationalContext(bean);
return (T) beanManager.getReference(bean, type,creationalContext);
}
}
return null;
}
示例9: SessionPreviewImpl
import javax.enterprise.inject.Any; //導入依賴的package包/類
@Inject
public SessionPreviewImpl(final DefinitionManager definitionManager,
final ShapeManager shapeManager,
final TextPropertyProviderFactory textPropertyProviderFactory,
final CanvasCommandManager<AbstractCanvasHandler> canvasCommandManager,
final DefinitionUtils definitionUtils,
final GraphUtils graphUtils,
final @Any ManagedInstance<BaseCanvasHandler> canvasHandlerFactories,
final @Any ManagedInstance<CanvasCommandFactory> canvasCommandFactories,
final @MultipleSelection SelectionControl<AbstractCanvasHandler, ?> selectionControl,
final WidgetWrapperView view) {
super(definitionManager,
shapeManager,
textPropertyProviderFactory,
canvasCommandManager,
definitionUtils,
graphUtils,
canvasHandlerFactories,
canvasCommandFactories,
selectionControl,
view);
}
示例10: LRUBuilderCache
import javax.enterprise.inject.Any; //導入依賴的package包/類
@Inject
public LRUBuilderCache(final @Named("ioStrategy") IOService ioService,
final KieModuleService moduleService,
final ProjectImportsService importsService,
final @Any Instance<BuildValidationHelper> buildValidationHelperBeans,
final @Named("LRUModuleDependenciesClassLoaderCache") LRUModuleDependenciesClassLoaderCache dependenciesClassLoaderCache,
final @Named("LRUPomModelCache") LRUPomModelCache pomModelCache,
final PackageNameWhiteListService packageNameWhiteListService,
final @JavaSourceFilter Instance<Predicate<String>> classFilterBeans) {
this.ioService = ioService;
this.moduleService = moduleService;
this.importsService = importsService;
this.buildValidationHelperBeans = buildValidationHelperBeans;
this.dependenciesClassLoaderCache = dependenciesClassLoaderCache;
this.pomModelCache = pomModelCache;
this.packageNameWhiteListService = (PackageNameWhiteListServiceImpl) packageNameWhiteListService;
this.classFilterBeans = classFilterBeans;
}
示例11: ClientProjectSessionManager
import javax.enterprise.inject.Any; //導入依賴的package包/類
@Inject
public ClientProjectSessionManager(final DefinitionUtils definitionUtils,
final @Any ManagedInstance<ClientSessionFactory> sessionFactoriesInstances,
final Event<SessionOpenedEvent> sessionOpenedEvent,
final Event<SessionDestroyedEvent> sessionDestroyedEvent,
final Event<SessionPausedEvent> sessionPausedEvent,
final Event<SessionResumedEvent> sessionResumedEvent,
final Event<OnSessionErrorEvent> sessionErrorEvent) {
super(definitionUtils,
sessionFactoriesInstances,
sessionOpenedEvent,
sessionDestroyedEvent,
sessionPausedEvent,
sessionResumedEvent,
sessionErrorEvent);
}
示例12: ClientSessionManagerImpl
import javax.enterprise.inject.Any; //導入依賴的package包/類
@Inject
public ClientSessionManagerImpl(final DefinitionUtils definitionUtils,
final @Any ManagedInstance<ClientSessionFactory> sessionFactoriesInstances,
final Event<SessionOpenedEvent> sessionOpenedEvent,
final Event<SessionDestroyedEvent> sessionDestroyedEvent,
final Event<SessionPausedEvent> sessionPausedEvent,
final Event<SessionResumedEvent> sessionResumedEvent,
final Event<OnSessionErrorEvent> sessionErrorEvent) {
this.definitionUtils = definitionUtils;
this.sessionFactoriesInstances = sessionFactoriesInstances;
this.sessionOpenedEvent = sessionOpenedEvent;
this.sessionPausedEvent = sessionPausedEvent;
this.sessionResumedEvent = sessionResumedEvent;
this.sessionDestroyedEvent = sessionDestroyedEvent;
this.sessionErrorEvent = sessionErrorEvent;
}
示例13: cacheBeans
import javax.enterprise.inject.Any; //導入依賴的package包/類
@PostConstruct
public void cacheBeans() {
LOG.info("> Initializing ProviderTypes. ");
final Set<Bean<?>> beans = beanManager.getBeans(ProviderType.class,
new AnnotationLiteral<Any>() {
});
for (final Bean b : beans) {
try {
// I don't want to register the CDI proxy, I need a fresh instance :(
ProviderType pt = (ProviderType) b.getBeanClass().newInstance();
LOG.info("> Registering ProviderType: " + pt.getProviderTypeName());
runtimeRegistry.registerProviderType(pt);
} catch (InstantiationException | IllegalAccessException ex) {
LOG.error("Something went wrong with registering Provider Types!",
ex);
}
}
}
示例14: NewDeployWizard
import javax.enterprise.inject.Any; //導入依賴的package包/類
@Inject
public NewDeployWizard(final SelectPipelinePagePresenter selectPipelinePage,
final ManagedInstance<PipelineParamsPagePresenter> pipelineParamsPageInstance,
final @Any Instance<PipelineDescriptor> pipelineDescriptorInstance,
final PopupHelper popupHelper,
final TranslationService translationService,
final Caller<RuntimeService> runtimeService,
final Event<NotificationEvent> notification,
final Event<RefreshRuntimeEvent> refreshRuntimeEvent) {
super(translationService,
notification);
this.popupHelper = popupHelper;
this.selectPipelinePage = selectPipelinePage;
this.pipelineParamsPageInstance = pipelineParamsPageInstance;
this.pipelineDescriptorInstance = pipelineDescriptorInstance;
this.runtimeService = runtimeService;
this.refreshRuntimeEvent = refreshRuntimeEvent;
}
示例15: findServiceProviderBeans
import javax.enterprise.inject.Any; //導入依賴的package包/類
@SuppressWarnings("serial")
public Set<Bean<?>> findServiceProviderBeans() {
Set<Bean<?>> result = new HashSet<>();
for (Bean<?> bean : beanManager.getBeans(Object.class, new AnnotationLiteral<Any>() {
})) {
ServiceProvider serviceProvider = bean.getBeanClass().getAnnotation(ServiceProvider.class);
if (serviceProvider != null) {
ProvidedBy providedBy = getProvidedByAnnotation(serviceProvider.serviceInterface());
verifyProvidedBy(providedBy, serviceProvider.serviceInterface(), bean);
result.add(bean);
if (LOG.isTraceEnabled()) {
LOG.trace(format("Bean %s is a service provider. Adding to result.", bean));
}
} else if (LOG.isTraceEnabled()) {
LOG.trace(format("Ignoring bean: %s", bean));
}
}
if (LOG.isDebugEnabled()) {
LOG.debug(format("Found the following service provider beans:%n%s", result));
}
return result;
}