org.jboss.msc.inject.Injector Java Examples

The following examples show how to use org.jboss.msc.inject.Injector. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DomainDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static void injectRoleMapper(String roleMapper, OperationContext context, ServiceBuilder<SecurityDomain> domainBuilder, Injector<RoleMapper> injector) {
    if (roleMapper == null) {
        return;
    }

    if (injector == null) {
        // Service did not supply one as one is already present for this name.
        return;
    }

    String runtimeCapability = RuntimeCapability.buildDynamicCapabilityName(ROLE_MAPPER_CAPABILITY, roleMapper);
    ServiceName roleMapperServiceName = context.getCapabilityServiceName(runtimeCapability, RoleMapper.class);

    domainBuilder.addDependency(roleMapperServiceName, RoleMapper.class, injector);
}
 
Example #2
Source File: DomainService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private Injector<RoleMapper> createRoleMapperInjector(final String roleMapperName) {
    if (roleMappers.containsKey(roleMapperName)) {
        return null; // i.e. should already be injected for this name.
    }

    InjectedValue<RoleMapper> roleMapperInjector = new InjectedValue<>();
    roleMappers.put(roleMapperName, roleMapperInjector);
    return roleMapperInjector;
}
 
Example #3
Source File: DomainService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private Injector<RoleDecoder> createRoleDecoderInjector(final String roleDecoderName) {
    if (roleDecoders.containsKey(roleDecoderName)) {
        return null; // i.e. should already be injected for this name.
    }

    InjectedValue<RoleDecoder> roleDecoderInjector = new InjectedValue<>();
    roleDecoders.put(roleDecoderName, roleDecoderInjector);
    return roleDecoderInjector;
}
 
Example #4
Source File: DomainDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static void injectRoleDecoder(String roleDecoder, OperationContext context, ServiceBuilder<SecurityDomain> domainBuilder, Injector<RoleDecoder> injector) {
    if (roleDecoder == null) {
        return;
    }
    if (injector == null) {
        return;
    }
    String runtimeCapability = RuntimeCapability.buildDynamicCapabilityName(ROLE_DECODER_CAPABILITY, roleDecoder);
    ServiceName roleDecoderServiceName = context.getCapabilityServiceName(runtimeCapability, RoleDecoder.class);
    domainBuilder.addDependency(roleDecoderServiceName, RoleDecoder.class, injector);
}
 
Example #5
Source File: DomainService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private Injector<PrincipalTransformer> createPrincipalTransformerInjector(final String principalTransformerName) {
    if (principalTransformers.containsKey(principalTransformerName)) {
        return null; // i.e. should already be injected for this name.
    }

    InjectedValue<PrincipalTransformer> principalTransformerInjector = new InjectedValue<>();
    principalTransformers.put(principalTransformerName, principalTransformerInjector);
    return principalTransformerInjector;
}
 
Example #6
Source File: AuthenticationFactoryDefinitions.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static void injectRealmMapper(SimpleAttributeDefinition realmMapperAttribute, ServiceBuilder<?> serviceBuilder, OperationContext context, ModelNode model, Injector<RealmMapper> realmMapperInjector) throws OperationFailedException {
    String realmMapper = realmMapperAttribute.resolveModelAttribute(context, model).asStringOrNull();
    if (realmMapper != null) {
        serviceBuilder.addDependency(context.getCapabilityServiceName(
                buildDynamicCapabilityName(REALM_MAPPER_CAPABILITY, realmMapper), RealmMapper.class),
                RealmMapper.class, realmMapperInjector);
    }
}
 
Example #7
Source File: AuthenticationFactoryDefinitions.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static void injectSecurityFactory(SimpleAttributeDefinition securityFactoryAttribute, ServiceBuilder<?> serviceBuilder, OperationContext context, ModelNode model, Injector<SecurityFactory> securityFactoryInjector) throws OperationFailedException {
    String securityFactory = securityFactoryAttribute.resolveModelAttribute(context, model).asStringOrNull();
    if (securityFactory != null) {
        serviceBuilder.addDependency(context.getCapabilityServiceName(
                buildDynamicCapabilityName(SECURITY_FACTORY_CREDENTIAL_CAPABILITY, securityFactory), SecurityFactory.class),
                SecurityFactory.class, securityFactoryInjector);
    }
}
 
Example #8
Source File: ThreadPoolManagementUtils.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
static <T> void installThreadPoolService(final Service<T> threadPoolService,
                                         final String threadPoolName,
                                         final ServiceName serviceNameBase,
                                         final String threadFactoryName,
                                         final ThreadFactoryResolver threadFactoryResolver,
                                         final Injector<ThreadFactory> threadFactoryInjector,
                                         final ServiceTarget target) {
    installThreadPoolService(threadPoolService, threadPoolName, serviceNameBase,
            threadFactoryName, threadFactoryResolver, threadFactoryInjector,
            null, null, null,
            target);
}
 
Example #9
Source File: DomainDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static void injectPrincipalTransformer(String principalTransformer, OperationContext context, ServiceBuilder<SecurityDomain> domainBuilder, Injector<PrincipalTransformer> injector) {
    if (principalTransformer == null) {
        return;
    }

    if (injector == null) {
        // Service did not supply one as one is already present for this name.
        return;
    }

    String runtimeCapability = RuntimeCapability.buildDynamicCapabilityName(PRINCIPAL_TRANSFORMER_CAPABILITY, principalTransformer);
    ServiceName principalTransformerServiceName = context.getCapabilityServiceName(runtimeCapability, PrincipalTransformer.class);

    domainBuilder.addDependency(principalTransformerServiceName, PrincipalTransformer.class, injector);
}
 
Example #10
Source File: JdbcRealmDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model)
        throws OperationFailedException {
    ServiceTarget serviceTarget = context.getServiceTarget();
    RuntimeCapability<Void> runtimeCapability = SECURITY_REALM_RUNTIME_CAPABILITY.fromBaseCapability(context.getCurrentAddressValue());
    ServiceName realmName = runtimeCapability.getCapabilityServiceName(SecurityRealm.class);
    ModelNode principalQueries = PrincipalQueryAttributes.PRINCIPAL_QUERIES_7_0.resolveModelAttribute(context, operation);
    final JdbcSecurityRealmBuilder builder = JdbcSecurityRealm.builder();

    TrivialService<SecurityRealm> service = new TrivialService<SecurityRealm>(builder::build);
    ServiceBuilder<SecurityRealm> serviceBuilder = serviceTarget.addService(realmName, service);

    for (ModelNode query : principalQueries.asList()) {
        String authenticationQuerySql = PrincipalQueryAttributes.SQL.resolveModelAttribute(context, query).asString();
        QueryBuilder queryBuilder = builder.principalQuery(authenticationQuerySql)
                .withMapper(resolveAttributeMappers(context, query))
                .withMapper(resolveKeyMappers(context, query));

        String dataSourceName = PrincipalQueryAttributes.DATA_SOURCE.resolveModelAttribute(context, query).asString();
        String capabilityName = Capabilities.DATA_SOURCE_CAPABILITY_NAME + "." + dataSourceName;
        ServiceName dataSourceServiceName = context.getCapabilityServiceName(capabilityName, DataSource.class);

        serviceBuilder.addDependency(dataSourceServiceName, DataSource.class, new Injector<DataSource>() {

            @Override
            public void inject(DataSource value) throws InjectionException {
                queryBuilder.from(value);
            }

            @Override
            public void uninject() {
                // no-op
            }
        });
    }

    commonDependencies(serviceBuilder)
            .setInitialMode(context.getRunningMode() == RunningMode.ADMIN_ONLY ? ServiceController.Mode.LAZY : ServiceController.Mode.ACTIVE)
            .install();
}
 
Example #11
Source File: CachingRealmDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void addRealmDependency(OperationContext context, ServiceBuilder<SecurityRealm> serviceBuilder, String realmName, Injector<SecurityRealm> securityRealmInjector) {
    String runtimeCapability = RuntimeCapability.buildDynamicCapabilityName(SECURITY_REALM_CAPABILITY, realmName);
    ServiceName realmServiceName = context.getCapabilityServiceName(runtimeCapability, SecurityRealm.class);
    REALM_SERVICE_UTIL.addInjection(serviceBuilder, securityRealmInjector, realmServiceName);
}
 
Example #12
Source File: ServiceUtil.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
ServiceBuilder<?> addInjection(ServiceBuilder<?> sb, Injector<T> injector, ServiceName serviceName) {
    sb.addDependency(serviceName, clazz, injector);
    return sb;
}
 
Example #13
Source File: ThreadPoolManagementUtils.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
static <T> void installThreadPoolService(final Service<T> threadPoolService,
                                         final String threadPoolName,
                                         final RuntimeCapability<Void> cap,
                                         final PathAddress address,
                                         final ServiceName serviceNameBase,
                                         final String threadFactoryName,
                                         final ThreadFactoryResolver threadFactoryResolver,
                                         final Injector<ThreadFactory> threadFactoryInjector,
                                         final String handoffExecutorName,
                                         final HandoffExecutorResolver handoffExecutorResolver,
                                         final Injector<Executor> handoffExecutorInjector,
                                         final ServiceTarget target) {
    final ServiceName threadPoolServiceName;
    final ServiceName aliasServiceName;
    if(cap != null) {
        threadPoolServiceName = cap.getCapabilityServiceName(address);
        if(serviceNameBase != null) {
            aliasServiceName = serviceNameBase.append(threadPoolName);
        } else {
            aliasServiceName = null;
        }
    } else {
        threadPoolServiceName = serviceNameBase.append(threadPoolName);
        aliasServiceName = null;
    }
    final ServiceBuilder<?> serviceBuilder = target.addService(threadPoolServiceName, threadPoolService);
    if(aliasServiceName != null) {
        serviceBuilder.addAliases(aliasServiceName);
    }
    final ServiceName threadFactoryServiceName = threadFactoryResolver.resolveThreadFactory(threadFactoryName,
            threadPoolName, threadPoolServiceName, target);
    serviceBuilder.addDependency(threadFactoryServiceName, ThreadFactory.class, threadFactoryInjector);

    if (handoffExecutorInjector != null) {
        ServiceName handoffServiceName = handoffExecutorResolver.resolveHandoffExecutor(handoffExecutorName,
                threadPoolName, threadPoolServiceName, target);
        if (handoffServiceName != null) {
            serviceBuilder.addDependency(handoffServiceName, Executor.class, handoffExecutorInjector);
        }
    }

    serviceBuilder.install();

}
 
Example #14
Source File: DomainService.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
Injector<RoleMapper> getRoleMapperInjector(final String name) {
    this.roleMapper = name;
    return createRoleMapperInjector(name);
}
 
Example #15
Source File: DomainService.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
Injector<RoleDecoder> getRoleDecoderInjector(final String name) {
    this.roleDecoder = name;
    return createRoleDecoderInjector(name);
}
 
Example #16
Source File: DomainService.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
Injector<PrincipalTransformer> getPrincipalTransformerInjector(final String name) {
    this.principalTransformer = name;
    return createPrincipalTransformerInjector(name);
}
 
Example #17
Source File: AcmeAccountService.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
Injector<KeyStore> getKeyStoreInjector() {
    return keyStoreInjector;
}
 
Example #18
Source File: JGroupsTopologyConnector.java    From thorntail with Apache License 2.0 4 votes vote down vote up
public Injector<CommandDispatcherFactory> getCommandDispatcherFactoryInjector() {
    return this.commandDispatcherFactoryInjector;
}
 
Example #19
Source File: CredentialStoreService.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
Injector<Provider[]> getProvidersInjector() {
    return providers;
}
 
Example #20
Source File: CredentialStoreService.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
Injector<Provider[]> getOtherProvidersInjector() {
    return otherProviders;
}
 
Example #21
Source File: KeyStoreService.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
Injector<ExceptionSupplier<CredentialSource, Exception>> getCredentialSourceSupplierInjector() {
    return credentialSourceSupplier;
}
 
Example #22
Source File: KeyStoreService.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
Injector<PathManager> getPathManagerInjector() {
    return pathManager;
}
 
Example #23
Source File: CredentialStoreService.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
Injector<PathManager> getPathManagerInjector() {
    return pathManager;
}
 
Example #24
Source File: QueuelessThreadPoolService.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public Injector<ThreadFactory> getThreadFactoryInjector() {
    return threadFactoryValue;
}
 
Example #25
Source File: SecurityRealmService.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Deprecated // TODO: eliminate this method when WildFly codebase is migrated to new constructor
public Injector<String> getTmpDirPathInjector() {
    return tmpDirPath;
}
 
Example #26
Source File: AggregateRealmDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void addRealmDependency(OperationContext context, ServiceBuilder<SecurityRealm> serviceBuilder, String realmName, Injector<SecurityRealm> securityRealmInjector) {
    String runtimeCapability = RuntimeCapability.buildDynamicCapabilityName(SECURITY_REALM_CAPABILITY, realmName);
    ServiceName realmServiceName = context.getCapabilityServiceName(runtimeCapability, SecurityRealm.class);

    REALM_SERVICE_UTIL.addInjection(serviceBuilder, securityRealmInjector, realmServiceName);
}
 
Example #27
Source File: UnboundedQueueThreadPoolService.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public Injector<ThreadFactory> getThreadFactoryInjector() {
    return threadFactoryValue;
}
 
Example #28
Source File: ProviderRegistrationService.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
Injector<Provider[]> getInitialProivders() {
    return initialProviders;
}
 
Example #29
Source File: LdapKeyStoreService.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
Injector<DirContextSupplier> getDirContextSupplierInjector() {
    return dirContextSupplierInjector;
}
 
Example #30
Source File: CredentialStoreService.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
Injector<ExceptionSupplier<CredentialSource, Exception>> getCredentialSourceSupplierInjector() {
    return credentialSourceSupplier;
}