本文整理汇总了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();
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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();
}