本文整理汇总了Java中org.jboss.msc.inject.Injector类的典型用法代码示例。如果您正苦于以下问题:Java Injector类的具体用法?Java Injector怎么用?Java Injector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Injector类属于org.jboss.msc.inject包,在下文中一共展示了Injector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addDependency
import org.jboss.msc.inject.Injector; //导入依赖的package包/类
public static ServiceBuilder<?> addDependency(ServiceBuilder<?> sb, Injector<KeytabIdentityFactoryService> injector,
String realmName) {
ServiceBuilder.DependencyType type = ServiceBuilder.DependencyType.REQUIRED;
sb.addDependency(type, createServiceName(realmName), KeytabIdentityFactoryService.class, injector);
return sb;
}
示例2: startNeo4jDriverService
import org.jboss.msc.inject.Injector; //导入依赖的package包/类
private void startNeo4jDriverService(OperationContext context, ConfigurationBuilder builder, final Set<String> outboundSocketBindings) throws OperationFailedException {
if (builder.getJNDIName() != null && builder.getJNDIName().length() > 0) {
final Neo4jClientConnectionService neo4jClientConnectionService = new Neo4jClientConnectionService(builder);
final ServiceName serviceName = ConnectionServiceAccess.serviceName(builder.getDescription());
final ContextNames.BindInfo bindingInfo = ContextNames.bindInfoFor(builder.getJNDIName());
final BinderService binderService = new BinderService(bindingInfo.getBindName());
context.getServiceTarget().addService(bindingInfo.getBinderServiceName(), binderService)
.addDependency(Neo4jSubsystemService.serviceName())
.addDependency(bindingInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, binderService.getNamingStoreInjector())
.addDependency(serviceName, Neo4jClientConnectionService.class, new Injector<Neo4jClientConnectionService>() {
@Override
public void inject(final Neo4jClientConnectionService value) throws
InjectionException {
binderService.getManagedObjectInjector().inject(new ValueManagedReferenceFactory(new ImmediateValue<>(value.getDriver())));
}
@Override
public void uninject() {
binderService.getNamingStoreInjector().uninject();
}
}).install();
final ServiceBuilder<Neo4jClientConnectionService> serviceBuilder = context.getServiceTarget().addService(serviceName, neo4jClientConnectionService);
serviceBuilder.addDependency(Neo4jSubsystemService.serviceName(), new CastingInjector<>(neo4jClientConnectionService.getNeo4jSubsystemServiceInjectedValue(), Neo4jSubsystemService.class));
// add service dependency on each separate hostname/port reference in standalone*.xml referenced from this driver profile definition.
for (final String outboundSocketBinding : outboundSocketBindings) {
final ServiceName outboundSocketBindingDependency = context.getCapabilityServiceName(Neo4jDriverDefinition.OUTBOUND_SOCKET_BINDING_CAPABILITY_NAME, outboundSocketBinding, OutboundSocketBinding.class);
serviceBuilder.addDependency(ServiceBuilder.DependencyType.REQUIRED, outboundSocketBindingDependency, OutboundSocketBinding.class, neo4jClientConnectionService.getOutboundSocketBindingInjector(outboundSocketBinding));
}
if (builder.getSecurityDomain() != null) {
serviceBuilder.addDependency(SubjectFactoryService.SERVICE_NAME, SubjectFactory.class,
neo4jClientConnectionService.getSubjectFactoryInjector());
}
serviceBuilder.setInitialMode(ServiceController.Mode.ACTIVE).install();
}
}
示例3: bindJndi
import org.jboss.msc.inject.Injector; //导入依赖的package包/类
private <T> void bindJndi(OperationContext context, ServiceName serviceName, String jndiName, Class<T> clazz) {
ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(jndiName);
BinderService binderService = new BinderService(bindInfo.getBindName());
context.getServiceTarget().addService(bindInfo.getBinderServiceName(), binderService)
.addDependency(OrientSubsystemService.SERVICE_NAME)
.addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class,
binderService.getNamingStoreInjector())
.addDependency(serviceName, OrientClientConnectionsService.class,
new Injector<OrientClientConnectionsService>() {
@Override
public void inject(final OrientClientConnectionsService value) throws InjectionException {
binderService.getManagedObjectInjector().inject(
new ValueManagedReferenceFactory(new ImmediateValue<>(value.unwrap(clazz))));
}
@Override
public void uninject() {
binderService.getNamingStoreInjector().uninject();
}
})
.install();
}
示例4: addLocalService
import org.jboss.msc.inject.Injector; //导入依赖的package包/类
private void addLocalService(OperationContext context, ModelNode local, String realmName, ServiceTarget serviceTarget,
ServiceBuilder<?> realmBuilder, Injector<CallbackHandlerService> injector) throws OperationFailedException {
ServiceName localServiceName = LocalCallbackHandlerService.ServiceUtil.createServiceName(realmName);
ModelNode node = LocalAuthenticationResourceDefinition.DEFAULT_USER.resolveModelAttribute(context, local);
String defaultUser = node.isDefined() ? node.asString() : null;
node = LocalAuthenticationResourceDefinition.ALLOWED_USERS.resolveModelAttribute(context, local);
String allowedUsers = node.isDefined() ? node.asString() : null;
node = LocalAuthenticationResourceDefinition.SKIP_GROUP_LOADING.resolveModelAttribute(context, local);
boolean skipGroupLoading = node.asBoolean();
LocalCallbackHandlerService localCallbackHandler = new LocalCallbackHandlerService(defaultUser, allowedUsers, skipGroupLoading);
serviceTarget.addService(localServiceName, localCallbackHandler)
.setInitialMode(ON_DEMAND)
.install();
CallbackHandlerService.ServiceUtil.addDependency(realmBuilder, injector, localServiceName);
}
示例5: addPlugInAuthenticationService
import org.jboss.msc.inject.Injector; //导入依赖的package包/类
private void addPlugInAuthenticationService(OperationContext context, ModelNode model, String realmName,
SecurityRealmService registry, ServiceTarget serviceTarget,
ServiceBuilder<?> realmBuilder, Injector<CallbackHandlerService> injector) throws OperationFailedException {
ServiceName plugInServiceName = PlugInAuthenticationCallbackHandler.ServiceUtil.createServiceName(realmName);
final String pluginName = PlugInAuthorizationResourceDefinition.NAME.resolveModelAttribute(context, model).asString();
final Map<String, String> properties = resolveProperties(context, model);
String mechanismName = PlugInAuthenticationResourceDefinition.MECHANISM.resolveModelAttribute(context, model).asString();
AuthMechanism mechanism = AuthMechanism.valueOf(mechanismName);
PlugInAuthenticationCallbackHandler plugInService = new PlugInAuthenticationCallbackHandler(registry.getName(),
pluginName, properties, mechanism);
ServiceBuilder<CallbackHandlerService> plugInBuilder = serviceTarget.addService(plugInServiceName, plugInService);
PlugInLoaderService.ServiceUtil.addDependency(plugInBuilder, plugInService.getPlugInLoaderServiceValue(), realmName);
plugInBuilder.setInitialMode(ON_DEMAND).install();
CallbackHandlerService.ServiceUtil.addDependency(realmBuilder, injector, plugInServiceName);
}
示例6: addPropertiesAuthenticationService
import org.jboss.msc.inject.Injector; //导入依赖的package包/类
private void addPropertiesAuthenticationService(OperationContext context, ModelNode properties, String realmName,
ServiceTarget serviceTarget, ServiceBuilder<?> realmBuilder,
Injector<CallbackHandlerService> injector) throws OperationFailedException {
ServiceName propsServiceName = PropertiesCallbackHandler.ServiceUtil.createServiceName(realmName);
final String path = PropertiesAuthenticationResourceDefinition.PATH.resolveModelAttribute(context, properties).asString();
final ModelNode relativeToNode = PropertiesAuthenticationResourceDefinition.RELATIVE_TO.resolveModelAttribute(context, properties);
final boolean plainText = PropertiesAuthenticationResourceDefinition.PLAIN_TEXT.resolveModelAttribute(context, properties).asBoolean();
String relativeTo = relativeToNode.isDefined() ? relativeToNode.asString() : null;
PropertiesCallbackHandler propsCallbackHandler = new PropertiesCallbackHandler(realmName, path, relativeTo, plainText);
ServiceBuilder<?> propsBuilder = serviceTarget.addService(propsServiceName, propsCallbackHandler);
if (relativeTo != null) {
propsBuilder.addDependency(context.getCapabilityServiceName(PATH_MANAGER_CAPABILITY, PathManager.class),
PathManager.class, propsCallbackHandler.getPathManagerInjectorInjector());
propsBuilder.addDependency(pathName(relativeTo));
}
propsBuilder.setInitialMode(ON_DEMAND)
.install();
CallbackHandlerService.ServiceUtil.addDependency(realmBuilder, injector, propsServiceName);
}
示例7: addSecretService
import org.jboss.msc.inject.Injector; //导入依赖的package包/类
private void addSecretService(OperationContext context, ModelNode secret, String realmName, ServiceTarget serviceTarget,
ServiceBuilder<?> realmBuilder, Injector<CallbackHandlerFactory> injector) throws OperationFailedException {
ServiceName secretServiceName = SecretIdentityService.ServiceUtil.createServiceName(realmName);
ModelNode resolvedValueNode = SecretServerIdentityResourceDefinition.VALUE.resolveModelAttribute(context, secret);
boolean base64 = secret.get(SecretServerIdentityResourceDefinition.VALUE.getName()).getType() != ModelType.EXPRESSION;
SecretIdentityService sis;
if (secret.hasDefined(CredentialReference.CREDENTIAL_REFERENCE)) {
sis = new SecretIdentityService(resolvedValueNode.asString(), false);
} else {
sis = new SecretIdentityService(resolvedValueNode.asString(), base64);
}
final ServiceBuilder<CallbackHandlerFactory> serviceBuilder = serviceTarget.addService(secretServiceName, sis)
.setInitialMode(ON_DEMAND);
if (secret.hasDefined(CredentialReference.CREDENTIAL_REFERENCE)) {
sis.getCredentialSourceSupplierInjector()
.inject(CredentialReference.getCredentialSourceSupplier(context, SecretServerIdentityResourceDefinition.CREDENTIAL_REFERENCE, secret, serviceBuilder));
}
serviceBuilder.install();
CallbackHandlerFactory.ServiceUtil.addDependency(realmBuilder, injector, secretServiceName);
}
示例8: installService
import org.jboss.msc.inject.Injector; //导入依赖的package包/类
private static void installService(final ServiceTarget serviceTarget, final ModuleIdentifier moduleIdentifier, int phaseNumber, final Set<ModuleDependency> nextPhaseIdentifiers, final Set<ModuleIdentifier> nextAlreadySeen) {
final ModuleResolvePhaseService nextPhaseService = new ModuleResolvePhaseService(moduleIdentifier, nextAlreadySeen, phaseNumber);
ServiceBuilder<ModuleResolvePhaseService> builder = serviceTarget.addService(moduleSpecServiceName(moduleIdentifier, phaseNumber), nextPhaseService);
for (ModuleDependency module : nextPhaseIdentifiers) {
builder.addDependency(module.isOptional() ? OPTIONAL : REQUIRED, ServiceModuleLoader.moduleSpecServiceName(module.getIdentifier()), ModuleDefinition.class, new Injector<ModuleDefinition>() {
ModuleDefinition definition;
@Override
public synchronized void inject(final ModuleDefinition o) throws InjectionException {
nextPhaseService.getModuleSpecs().add(o);
this.definition = o;
}
@Override
public synchronized void uninject() {
nextPhaseService.getModuleSpecs().remove(definition);
this.definition = null;
}
});
}
builder.install();
}
示例9: startCassandraDriverService
import org.jboss.msc.inject.Injector; //导入依赖的package包/类
private void startCassandraDriverService(OperationContext context, ConfigurationBuilder builder, final Set<String> outboundSocketBindings) throws OperationFailedException {
if (builder.getJNDIName() != null && builder.getJNDIName().length() > 0) {
final CassandraClientConnectionsService cassandraClientConnectionsService = new CassandraClientConnectionsService(builder);
final ServiceName serviceName = ConnectionServiceAccess.serviceName(builder.getDescription());
final ContextNames.BindInfo bindingInfo = ContextNames.bindInfoFor(builder.getJNDIName());
final BinderService binderService = new BinderService(bindingInfo.getBindName());
context.getServiceTarget().addService(bindingInfo.getBinderServiceName(), binderService)
.addDependency(CassandraSubsystemService.serviceName())
.addDependency(bindingInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, binderService.getNamingStoreInjector())
.addDependency(serviceName, CassandraClientConnectionsService.class, new Injector<CassandraClientConnectionsService>() {
@Override
public void inject(final CassandraClientConnectionsService value) throws
InjectionException {
binderService.getManagedObjectInjector().inject(new ValueManagedReferenceFactory(new ImmediateValue<>(value.getSession() != null ? value.getSession() : value.getCluster())));
}
@Override
public void uninject() {
binderService.getNamingStoreInjector().uninject();
}
}).install();
final ServiceBuilder<CassandraClientConnectionsService> serviceBuilder = context.getServiceTarget().addService(serviceName, cassandraClientConnectionsService);
serviceBuilder.addDependency(CassandraSubsystemService.serviceName(), new CastingInjector<>(cassandraClientConnectionsService.getCassandraSubsystemServiceInjectedValue(), CassandraSubsystemService.class));
// add service dependency on each separate hostname/port reference in standalone*.xml referenced from this driver profile definition.
for (final String outboundSocketBinding : outboundSocketBindings) {
final ServiceName outboundSocketBindingDependency = context.getCapabilityServiceName(CassandraDriverDefinition.OUTBOUND_SOCKET_BINDING_CAPABILITY_NAME, outboundSocketBinding, OutboundSocketBinding.class);
serviceBuilder.addDependency(ServiceBuilder.DependencyType.REQUIRED, outboundSocketBindingDependency, OutboundSocketBinding.class, cassandraClientConnectionsService.getOutboundSocketBindingInjector(outboundSocketBinding));
}
if (builder.getSecurityDomain() != null) {
serviceBuilder.addDependency(SubjectFactoryService.SERVICE_NAME, SubjectFactory.class,
cassandraClientConnectionsService.getSubjectFactoryInjector());
}
serviceBuilder.setInitialMode(ServiceController.Mode.ACTIVE).install();
}
}
示例10: startMongoDriverService
import org.jboss.msc.inject.Injector; //导入依赖的package包/类
private void startMongoDriverService(OperationContext context, ConfigurationBuilder builder, Set<String> outboundSocketBindings) {
if (builder.getJNDIName() != null && builder.getJNDIName().length() > 0) {
final MongoClientConnectionsService mongoClientConnectionsService = new MongoClientConnectionsService(builder);
final ServiceName serviceName = ConnectionServiceAccess.serviceName(builder.getDescription());
final ContextNames.BindInfo bindingInfo = ContextNames.bindInfoFor(builder.getJNDIName());
final BinderService binderService = new BinderService(bindingInfo.getBindName());
context.getServiceTarget().addService(bindingInfo.getBinderServiceName(), binderService)
.addDependency(MongoSubsystemService.serviceName())
.addDependency(bindingInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, binderService.getNamingStoreInjector())
.addDependency(serviceName, MongoClientConnectionsService.class, new Injector<MongoClientConnectionsService>() {
@Override
public void inject(final MongoClientConnectionsService value) throws
InjectionException {
binderService.getManagedObjectInjector().inject(new ValueManagedReferenceFactory(new ImmediateValue<>(value.getDatabase() != null ? value.getDatabase() : value.getClient())));
}
@Override
public void uninject() {
binderService.getNamingStoreInjector().uninject();
}
}).install();
final ServiceBuilder<MongoClientConnectionsService> serviceBuilder = context.getServiceTarget().addService(serviceName, mongoClientConnectionsService);
serviceBuilder.addDependency(MongoSubsystemService.serviceName(), new CastingInjector<>(mongoClientConnectionsService.getMongoSubsystemServiceInjectedValue(), MongoSubsystemService.class));
// add service dependency on each separate hostname/port reference in standalone*.xml referenced from this driver profile definition.
for (final String outboundSocketBinding : outboundSocketBindings) {
final ServiceName outboundSocketBindingDependency = context.getCapabilityServiceName(OUTBOUND_SOCKET_BINDING_CAPABILITY_NAME, outboundSocketBinding, OutboundSocketBinding.class);
serviceBuilder.addDependency(ServiceBuilder.DependencyType.REQUIRED, outboundSocketBindingDependency, OutboundSocketBinding.class, mongoClientConnectionsService.getOutboundSocketBindingInjector(outboundSocketBinding));
}
if (builder.getSecurityDomain() != null) {
serviceBuilder.addDependency(SubjectFactoryService.SERVICE_NAME, SubjectFactory.class,
mongoClientConnectionsService.getSubjectFactoryInjector());
}
serviceBuilder.setInitialMode(ServiceController.Mode.ACTIVE).install();
}
}
示例11: getHandlerInjectorFor
import org.jboss.msc.inject.Injector; //导入依赖的package包/类
public Injector<HttpHandler> getHandlerInjectorFor(String serviceName) {
InjectedValue<HttpHandler> injector = proxyHandlerMap.get(serviceName);
if (injector == null) {
injector = new InjectedValue<>();
proxyHandlerMap.put(serviceName, injector);
}
return injector;
}
示例12: test_1
import org.jboss.msc.inject.Injector; //导入依赖的package包/类
static void test_1(){
final AtomicReference<String> reference = new AtomicReference<String>();
final Injector<String> injector = new AtomicReferenceInjector<String>(reference);
injector.inject("Hello World");
System.out.println(reference.get());
injector.uninject();
}
示例13: test_2
import org.jboss.msc.inject.Injector; //导入依赖的package包/类
static void test_2() throws NoSuchFieldException, SecurityException {
final Field field = SimplePojo.class.getField("description");
final SimplePojo pojo = new SimplePojo();
final Injector<String> injector = new FieldInjector<String>(Values.immediateValue(pojo), field);
injector.inject("Injection of description field");
System.out.println(pojo.description);
injector.uninject();
}
示例14: test_3
import org.jboss.msc.inject.Injector; //导入依赖的package包/类
static void test_3() throws NoSuchMethodException, SecurityException {
Value<SimplePojo> target = new ImmediateValue<>(new SimplePojo());
List<Value<String>> arguments =new ArrayList<>();
arguments.add(new ImmediateValue<String>("Hello World"));
final Injector<String> injector = new MethodInjector<String>(SimplePojo.class.getMethod("testMethod", String.class), target, Values.immediateValue("String"), arguments);
injector.inject(null);
}
示例15: test_4
import org.jboss.msc.inject.Injector; //导入依赖的package包/类
static void test_4() throws NoSuchMethodException, SecurityException {
Value<SimplePojo> target = new ImmediateValue<>(new SimplePojo());
Method method = SimplePojo.class.getMethod("setId", Integer.class);
final Injector<Integer> injector = SetMethodInjector.<Integer>create(target, method);
injector.inject(1000);
System.out.println(target.getValue().getId());
injector.uninject();
}