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


Java InjectedValue.getOptionalValue方法代码示例

本文整理汇总了Java中org.jboss.msc.value.InjectedValue.getOptionalValue方法的典型用法代码示例。如果您正苦于以下问题:Java InjectedValue.getOptionalValue方法的具体用法?Java InjectedValue.getOptionalValue怎么用?Java InjectedValue.getOptionalValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jboss.msc.value.InjectedValue的用法示例。


在下文中一共展示了InjectedValue.getOptionalValue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: performRuntime

import org.jboss.msc.value.InjectedValue; //导入方法依赖的package包/类
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model)
        throws OperationFailedException {
    ServiceTarget serviceTarget = context.getServiceTarget();
    RuntimeCapability<Void> runtimeCapability = REALM_MAPPER_RUNTIME_CAPABILITY.fromBaseCapability(context.getCurrentAddressValue());
    ServiceName realmMapperName = runtimeCapability.getCapabilityServiceName(RealmMapper.class);

    final String pattern = PATTERN_CAPTURE_GROUP.resolveModelAttribute(context, model).asString();
    String delegateRealmMapper = DELEGATE_REALM_MAPPER.resolveModelAttribute(context, model).asStringOrNull();

    final InjectedValue<RealmMapper> delegateRealmMapperInjector = new InjectedValue<RealmMapper>();

    TrivialService<RealmMapper> realmMapperService = new TrivialService<RealmMapper>(() -> {
        RealmMapper delegate = delegateRealmMapperInjector.getOptionalValue();
        Pattern compiledPattern = Pattern.compile(pattern);
        if (delegate == null) {
            return new SimpleRegexRealmMapper(compiledPattern);
        } else {
            return new SimpleRegexRealmMapper(compiledPattern, delegate);
        }
    });

    ServiceBuilder<RealmMapper> realmMapperBuilder = serviceTarget.addService(realmMapperName, realmMapperService);

    if (delegateRealmMapper != null) {
        String delegateCapabilityName = RuntimeCapability.buildDynamicCapabilityName(REALM_MAPPER_CAPABILITY, delegateRealmMapper);
        ServiceName delegateServiceName = context.getCapabilityServiceName(delegateCapabilityName, RealmMapper.class);

        realmMapperBuilder.addDependency(delegateServiceName, RealmMapper.class, delegateRealmMapperInjector);
    }

    commonDependencies(realmMapperBuilder)
        .setInitialMode(Mode.LAZY)
        .install();
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:36,代码来源:RealmMapperDefinitions.java

示例2: setPrincipalTransformer

import org.jboss.msc.value.InjectedValue; //导入方法依赖的package包/类
private static void setPrincipalTransformer(InjectedValue<PrincipalTransformer> injectedValue, Consumer<Function<Principal, Principal>> principalTransformerConsumer) {
    PrincipalTransformer principalTransformer = injectedValue.getOptionalValue();
    if (principalTransformer != null) {
        principalTransformerConsumer.accept(principalTransformer);
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:7,代码来源:AuthenticationFactoryDefinitions.java

示例3: setSecurityFactory

import org.jboss.msc.value.InjectedValue; //导入方法依赖的package包/类
private static void setSecurityFactory(InjectedValue<SecurityFactory> injectedValue, Consumer<SecurityFactory> securityFactoryConsumer) {
    SecurityFactory securityFactory = injectedValue.getOptionalValue();
    if (securityFactory != null) {
        securityFactoryConsumer.accept(securityFactory);
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:7,代码来源:AuthenticationFactoryDefinitions.java

示例4: setRealmMapper

import org.jboss.msc.value.InjectedValue; //导入方法依赖的package包/类
private static void setRealmMapper(InjectedValue<RealmMapper> injectedValue, Consumer<RealmMapper> realmMapperConsumer) {
    RealmMapper realmMapper = injectedValue.getOptionalValue();
    if (realmMapper != null) {
        realmMapperConsumer.accept(realmMapper);
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:7,代码来源:AuthenticationFactoryDefinitions.java

示例5: performRuntime

import org.jboss.msc.value.InjectedValue; //导入方法依赖的package包/类
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model)
        throws OperationFailedException {
    ServiceTarget serviceTarget = context.getServiceTarget();

    String address = context.getCurrentAddressValue();
    ServiceName mainServiceName = MODIFIABLE_SECURITY_REALM_RUNTIME_CAPABILITY.fromBaseCapability(address).getCapabilityServiceName();
    ServiceName aliasServiceName = SECURITY_REALM_RUNTIME_CAPABILITY.fromBaseCapability(address).getCapabilityServiceName();

    final int levels = LEVELS.resolveModelAttribute(context, model).asInt();

    final boolean encoded = ENCODED.resolveModelAttribute(context, model).asBoolean();

    final String path = PATH.resolveModelAttribute(context, model).asString();
    final String relativeTo = RELATIVE_TO.resolveModelAttribute(context, model).asStringOrNull();

    final InjectedValue<PathManager> pathManagerInjector = new InjectedValue<>();
    final InjectedValue<NameRewriter> nameRewriterInjector = new InjectedValue<>();

    TrivialService<SecurityRealm> fileSystemRealmService = new TrivialService<>(
            new TrivialService.ValueSupplier<SecurityRealm>() {

                private PathResolver pathResolver;

                @Override
                public SecurityRealm get() throws StartException {
                    pathResolver = pathResolver();
                    Path rootPath = pathResolver.path(path).relativeTo(relativeTo, pathManagerInjector.getOptionalValue()).resolve().toPath();

                    NameRewriter nameRewriter = nameRewriterInjector.getOptionalValue();

                    return nameRewriter != null ?
                            new FileSystemSecurityRealm(rootPath, nameRewriter, levels, encoded) :
                            new FileSystemSecurityRealm(rootPath, NameRewriter.IDENTITY_REWRITER, levels, encoded);
                }

                @Override
                public void dispose() {
                    if (pathResolver != null) {
                        pathResolver.clear();
                        pathResolver = null;
                    }
                }

            });

    ServiceBuilder<SecurityRealm> serviceBuilder = serviceTarget.addService(mainServiceName, fileSystemRealmService)
            .addAliases(aliasServiceName);

    if (relativeTo != null) {
        serviceBuilder.addDependency(PathManagerService.SERVICE_NAME, PathManager.class, pathManagerInjector);
        serviceBuilder.addDependency(pathName(relativeTo));
    }
    serviceBuilder.install();
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:56,代码来源:FileSystemRealmDefinition.java


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