use of org.wildfly.clustering.service.SupplierDependency in project wildfly by wildfly.
the class RemoteCacheContainerConfigurationServiceConfigurator method configure.
@Override
public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException {
this.connectionTimeout = Attribute.CONNECTION_TIMEOUT.resolveModelAttribute(context, model).asInt();
this.defaultRemoteCluster = Attribute.DEFAULT_REMOTE_CLUSTER.resolveModelAttribute(context, model).asString();
this.maxRetries = Attribute.MAX_RETRIES.resolveModelAttribute(context, model).asInt();
this.protocolVersion = Attribute.PROTOCOL_VERSION.resolveModelAttribute(context, model).asString();
this.socketTimeout = Attribute.SOCKET_TIMEOUT.resolveModelAttribute(context, model).asInt();
this.tcpNoDelay = Attribute.TCP_NO_DELAY.resolveModelAttribute(context, model).asBoolean();
this.tcpKeepAlive = Attribute.TCP_KEEP_ALIVE.resolveModelAttribute(context, model).asBoolean();
this.statisticsEnabled = Attribute.STATISTICS_ENABLED.resolveModelAttribute(context, model).asBoolean();
this.transactionTimeout = Attribute.TRANSACTION_TIMEOUT.resolveModelAttribute(context, model).asLong();
this.marshallerFactory = HotRodMarshallerFactory.valueOf(Attribute.MARSHALLER.resolveModelAttribute(context, model).asString());
this.clusters.clear();
Resource container = context.readResource(PathAddress.EMPTY_ADDRESS);
for (Resource.ResourceEntry entry : container.getChildren(RemoteClusterResourceDefinition.WILDCARD_PATH.getKey())) {
String clusterName = entry.getName();
ModelNode cluster = entry.getModel();
List<String> bindings = StringListAttributeDefinition.unwrapValue(context, RemoteClusterResourceDefinition.Attribute.SOCKET_BINDINGS.resolveModelAttribute(context, cluster));
List<SupplierDependency<OutboundSocketBinding>> bindingDependencies = new ArrayList<>(bindings.size());
for (String binding : bindings) {
bindingDependencies.add(new ServiceSupplierDependency<>(CommonUnaryRequirement.OUTBOUND_SOCKET_BINDING.getServiceName(context, binding)));
}
this.clusters.put(clusterName, bindingDependencies);
}
this.server = context.hasOptionalCapability(CommonRequirement.MBEAN_SERVER.getName(), null, null) ? new ServiceSupplierDependency<>(CommonRequirement.MBEAN_SERVER.getServiceName(context)) : null;
this.properties.clear();
for (Property property : Attribute.PROPERTIES.resolveModelAttribute(context, model).asPropertyListOrEmpty()) {
this.properties.setProperty(property.getName(), property.getValue().asString());
}
return this;
}
use of org.wildfly.clustering.service.SupplierDependency in project wildfly by wildfly.
the class RemoteCacheContainerConfigurationServiceConfigurator method get.
@Override
public Configuration get() {
String name = this.getServiceName().getSimpleName();
ConfigurationBuilder builder = new ConfigurationBuilder();
// Configure formal security first
builder.security().read(this.security.get());
// Apply properties next, which may override formal security configuration
builder.withProperties(this.properties).connectionTimeout(this.connectionTimeout).maxRetries(this.maxRetries).version(ProtocolVersion.parseVersion(this.protocolVersion)).socketTimeout(this.socketTimeout).statistics().enabled(this.statisticsEnabled).jmxDomain("org.wildfly.clustering.infinispan").jmxEnabled(this.server != null).jmxName(name).mBeanServerLookup((this.server != null) ? new MBeanServerProvider(this.server.get()) : null).tcpNoDelay(this.tcpNoDelay).tcpKeepAlive(this.tcpKeepAlive).transactionTimeout(this.transactionTimeout, TimeUnit.MILLISECONDS);
List<Module> modules = this.modules.get();
Marshaller marshaller = this.marshallerFactory.apply(this.loader.get(), modules);
builder.marshaller(marshaller);
builder.classLoader(modules.size() > 1 ? new AggregatedClassLoader(modules.stream().map(Module::getClassLoader).collect(Collectors.toList())) : modules.get(0).getClassLoader());
builder.connectionPool().read(this.connectionPool.get());
builder.asyncExecutorFactory().read(this.threadPools.get(ThreadPoolResourceDefinition.CLIENT).get());
for (Map.Entry<String, List<SupplierDependency<OutboundSocketBinding>>> cluster : this.clusters.entrySet()) {
String clusterName = cluster.getKey();
List<SupplierDependency<OutboundSocketBinding>> bindingDependencies = cluster.getValue();
if (this.defaultRemoteCluster.equals(clusterName)) {
for (Supplier<OutboundSocketBinding> bindingDependency : bindingDependencies) {
OutboundSocketBinding binding = bindingDependency.get();
builder.addServer().host(binding.getUnresolvedDestinationAddress()).port(binding.getDestinationPort());
}
} else {
ClusterConfigurationBuilder clusterConfigurationBuilder = builder.addCluster(clusterName);
for (Supplier<OutboundSocketBinding> bindingDependency : bindingDependencies) {
OutboundSocketBinding binding = bindingDependency.get();
clusterConfigurationBuilder.addClusterNode(binding.getUnresolvedDestinationAddress(), binding.getDestinationPort());
}
}
}
return builder.build();
}
use of org.wildfly.clustering.service.SupplierDependency in project wildfly by wildfly.
the class CacheDependenciesProcessor method deploy.
@Override
public void deploy(DeploymentPhaseContext context) {
DeploymentUnit unit = context.getDeploymentUnit();
final ServiceName name = unit.getServiceName();
EEModuleDescription moduleDescription = unit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
if (moduleDescription == null) {
return;
}
final CapabilityServiceSupport support = unit.getAttachment(org.jboss.as.server.deployment.Attachments.CAPABILITY_SERVICE_SUPPORT);
final ServiceTarget target = context.getServiceTarget();
Set<SupplierDependency<CacheFactoryBuilder<SessionID, StatefulSessionComponentInstance>>> dependencies = new HashSet<>();
for (ComponentDescription description : moduleDescription.getComponentDescriptions()) {
if (description instanceof StatefulComponentDescription) {
StatefulComponentDescription statefulDescription = (StatefulComponentDescription) description;
dependencies.add(new ServiceSupplierDependency<>(getCacheFactoryBuilderServiceName(statefulDescription)));
}
}
Service service = new ChildTargetService(new Consumer<ServiceTarget>() {
@Override
public void accept(ServiceTarget target) {
// Cache factory builder dependencies might still contain duplicates (if referenced via alias), so ensure we collect only distinct instances.
Set<CacheFactoryBuilder<SessionID, StatefulSessionComponentInstance>> builders = new HashSet<>(dependencies.size());
for (Supplier<CacheFactoryBuilder<SessionID, StatefulSessionComponentInstance>> dependency : dependencies) {
builders.add(dependency.get());
}
for (CacheFactoryBuilder<SessionID, StatefulSessionComponentInstance> builder : builders) {
for (CapabilityServiceConfigurator configurator : builder.getDeploymentServiceConfigurators(unit)) {
configurator.configure(support).build(target).install();
}
}
}
});
ServiceBuilder<?> builder = target.addService(name.append("cache-dependencies-installer"));
for (Dependency dependency : dependencies) {
dependency.register(builder);
}
builder.setInstance(service).install();
// Install versioned marshalling configuration
new MarshallingConfigurationRepositoryServiceConfigurator(unit).build(target).setInitialMode(ServiceController.Mode.ON_DEMAND).install();
}
use of org.wildfly.clustering.service.SupplierDependency in project wildfly by wildfly.
the class DistributableSingleSignOnManagerServiceConfigurator method configure.
@Override
public ServiceConfigurator configure(OperationContext context) {
String securityDomainName = this.configuration.getSecurityDomainName();
Supplier<String> generator = this.configuration.getIdentifierGenerator();
CapabilityServiceSupport support = context.getCapabilityServiceSupport();
SupplierDependency<DistributableSSOManagementProvider> provider = getProvider(context, securityDomainName);
ServiceName managerServiceName = this.getServiceName().append("manager");
this.manager = new ServiceSupplierDependency<>(managerServiceName);
this.provider = provider;
this.installer = new Consumer<ServiceTarget>() {
@Override
public void accept(ServiceTarget target) {
ServiceConfigurator factoryConfigurator = provider.get().getServiceConfigurator(securityDomainName).configure(support);
factoryConfigurator.build(target).install();
SupplierDependency<SSOManagerFactory<ElytronAuthentication, String, Map.Entry<String, URI>, Batch>> factoryDependency = new ServiceSupplierDependency<>(factoryConfigurator);
SupplierDependency<SessionIdGenerator> generatorDependency = new SimpleSupplierDependency<>(new SessionIdGeneratorAdapter(generator));
new SSOManagerServiceConfigurator<>(managerServiceName, factoryDependency, generatorDependency, new LocalSSOContextFactory()).configure(support).build(target).install();
}
};
return this;
}
use of org.wildfly.clustering.service.SupplierDependency in project wildfly by wildfly.
the class ElectionPolicyServiceConfigurator method configure.
@Override
public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException {
List<ModelNode> socketBindingPreferences = SOCKET_BINDING_PREFERENCES.resolveModelAttribute(context, model).asListOrEmpty();
List<ModelNode> namePreferences = NAME_PREFERENCES.resolveModelAttribute(context, model).asListOrEmpty();
List<Preference> preferences = new ArrayList<>(socketBindingPreferences.size() + namePreferences.size());
List<Dependency> dependencies = new ArrayList<>(socketBindingPreferences.size());
for (ModelNode preference : socketBindingPreferences) {
SupplierDependency<OutboundSocketBinding> binding = new ServiceSupplierDependency<>(CommonUnaryRequirement.OUTBOUND_SOCKET_BINDING.getServiceName(context, preference.asString()));
preferences.add(new OutboundSocketBindingPreference(binding));
dependencies.add(binding);
}
for (ModelNode preference : namePreferences) {
preferences.add(new NamePreference(preference.asString()));
}
this.dependencies = dependencies;
this.preferences = preferences;
return this;
}
Aggregations