use of javax.inject.Named in project camel by apache.
the class Jms method sjms.
@Produces
@Named("sjms")
@ApplicationScoped
SjmsComponent sjms() {
SjmsComponent component = new SjmsComponent();
component.setConnectionFactory(new ActiveMQConnectionFactory("vm://broker?broker.persistent=false&broker.useShutdownHook=false&broker.useJmx=false"));
component.setConnectionCount(maxConnections);
return component;
}
use of javax.inject.Named in project camel by apache.
the class Application method properties.
@Produces
@ApplicationScoped
@Named("properties")
// "properties" component bean that Camel uses to lookup properties
PropertiesComponent properties(PropertiesParser parser) {
PropertiesComponent component = new PropertiesComponent();
// Use DeltaSpike as configuration source for Camel CDI
component.setPropertiesParser(parser);
return component;
}
use of javax.inject.Named in project rest.li by linkedin.
the class Jsr330Adapter method scanInjectableConstructors.
private void scanInjectableConstructors(Class<?> beanClazz) {
int annotatedConstructors = 0;
for (Constructor<?> constructor : beanClazz.getConstructors()) {
Inject injectAnnotation = constructor.getAnnotation(Inject.class);
if (injectAnnotation != null) {
++annotatedConstructors;
if (annotatedConstructors > 1) {
throw new RestLiInternalException("Found multiple constructors annotated with @Inject in " + "class '" + beanClazz.getCanonicalName() + "'. At most one constructor can be annotated " + "with @Inject.");
}
Class<?>[] parameters = constructor.getParameterTypes();
Annotation[][] parameterAnnotations = constructor.getParameterAnnotations();
List<DependencyDecl> parameterDecls = new ArrayList<DependencyDecl>(parameters.length);
for (int i = 0; i < parameters.length; ++i) {
Class<?> parameter = parameters[i];
AnnotationSet annotations = new AnnotationSet(parameterAnnotations[i]);
Named namedAnno = annotations.get(Named.class);
parameterDecls.add(new DependencyDecl(parameter, namedAnno != null ? namedAnno.value() : null));
}
constructor.setAccessible(true);
_constructorParameterDependencies.put(beanClazz, new InjectableConstructor(constructor, parameterDecls));
}
}
if (annotatedConstructors == 0) {
try {
Constructor<?> defaultConstructor = beanClazz.getConstructor();
defaultConstructor.setAccessible(true);
_constructorParameterDependencies.put(beanClazz, new InjectableConstructor(defaultConstructor, Collections.<DependencyDecl>emptyList()));
} catch (NoSuchMethodException e) {
throw new RestLiInternalException(String.format("No injectable constructor defined for class %s. Classes must define" + " either a default constructor or a constructor annotated " + "with @Inject.", beanClazz.getName()), e);
}
}
}
use of javax.inject.Named in project OpenAM by OpenRock.
the class CoreRestGuiceModule method getServerAttributeTitles.
@Provides
@Singleton
@Named("ServerAttributeTitles")
public Properties getServerAttributeTitles() throws IOException {
Properties titleProperties = new Properties();
titleProperties.load(getClass().getClassLoader().getResourceAsStream("amConsole.properties"));
return titleProperties;
}
use of javax.inject.Named in project OpenAM by OpenRock.
the class OAuth2GuiceModule method getOAuth2AuditContextProviders.
@Inject
@Provides
@Singleton
@Named(OAUTH2_AUDIT_CONTEXT_PROVIDERS)
Set<OAuth2AuditContextProvider> getOAuth2AuditContextProviders(TokenStore tokenStore, OAuth2RequestFactory<?, Request> requestFactory) {
Set<OAuth2AuditContextProvider> set = new HashSet<>();
set.add(new OAuth2AuditAccessTokenContextProvider(tokenStore, requestFactory));
set.add(new OAuth2AuditRefreshTokenContextProvider(tokenStore, requestFactory));
set.add(new OAuth2AuditSSOTokenContextProvider());
return set;
}
Aggregations