当前位置: 首页>>代码示例>>Java>>正文


Java Injector类代码示例

本文整理汇总了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;
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:8,代码来源:KeytabIdentityFactoryService.java

示例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();
    }
}
 
开发者ID:wildfly,项目名称:wildfly-nosql,代码行数:39,代码来源:Neo4jDefinition.java

示例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();
}
 
开发者ID:wildfly,项目名称:wildfly-nosql,代码行数:23,代码来源:OrientDefinition.java

示例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);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:19,代码来源:SecurityRealmAddHandler.java

示例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);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:20,代码来源:SecurityRealmAddHandler.java

示例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);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:27,代码来源:SecurityRealmAddHandler.java

示例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);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:22,代码来源:SecurityRealmAddHandler.java

示例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();
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:24,代码来源:ModuleResolvePhaseService.java

示例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();
    }
}
 
开发者ID:wildfly,项目名称:wildfly-nosql,代码行数:40,代码来源:CassandraDefinition.java

示例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();
    }
}
 
开发者ID:wildfly,项目名称:wildfly-nosql,代码行数:38,代码来源:MongoDefinition.java

示例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;
}
 
开发者ID:wildfly-swarm-archive,项目名称:wildfly-swarm-topology,代码行数:9,代码来源:TopologyProxyService.java

示例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();
}
 
开发者ID:jbosschina,项目名称:wildfly-dev-cookbook,代码行数:8,代码来源:TestInject.java

示例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();
}
 
开发者ID:jbosschina,项目名称:wildfly-dev-cookbook,代码行数:9,代码来源:TestInject.java

示例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);
}
 
开发者ID:jbosschina,项目名称:wildfly-dev-cookbook,代码行数:8,代码来源:TestInject.java

示例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();
}
 
开发者ID:jbosschina,项目名称:wildfly-dev-cookbook,代码行数:9,代码来源:TestInject.java


注:本文中的org.jboss.msc.inject.Injector类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。