Search in sources :

Example 1 with InjectedValueDependency

use of org.wildfly.clustering.service.InjectedValueDependency in project wildfly by wildfly.

the class ModClusterConfigurationServiceBuilder method configure.

@Override
public Builder<ModClusterConfiguration> configure(OperationContext context, ModelNode model) throws OperationFailedException {
    // Advertise
    optionalString(ADVERTISE_SOCKET.resolveModelAttribute(context, model)).ifPresent(advertiseSocketRef -> this.advertiseSocketDependency = new InjectedValueDependency<>(context.getCapabilityServiceName(SOCKET_BINDING_CAPABILITY_NAME, advertiseSocketRef, SocketBinding.class), SocketBinding.class));
    optionalString(ADVERTISE_SECURITY_KEY.resolveModelAttribute(context, model)).ifPresent(securityKey -> builder.advertise().setAdvertiseSecurityKey(securityKey));
    // MCMP
    builder.mcmp().setAdvertise(ADVERTISE.resolveModelAttribute(context, model).asBoolean()).setProxyURL(PROXY_URL.resolveModelAttribute(context, model).asString()).setAutoEnableContexts(AUTO_ENABLE_CONTEXTS.resolveModelAttribute(context, model).asBoolean()).setStopContextTimeout(STOP_CONTEXT_TIMEOUT.resolveModelAttribute(context, model).asInt()).setStopContextTimeoutUnit(TimeUnit.valueOf(STOP_CONTEXT_TIMEOUT.getMeasurementUnit().getName())).setSocketTimeout(SOCKET_TIMEOUT.resolveModelAttribute(context, model).asInt() * 1000).setSessionDrainingStrategy(Enum.valueOf(SessionDrainingStrategyEnum.class, SESSION_DRAINING_STRATEGY.resolveModelAttribute(context, model).asString()));
    if (model.hasDefined(CommonAttributes.EXCLUDED_CONTEXTS)) {
        String contexts = EXCLUDED_CONTEXTS.resolveModelAttribute(context, model).asString();
        Map<String, Set<String>> excludedContextsPerHost;
        if (contexts == null) {
            excludedContextsPerHost = Collections.emptyMap();
        } else {
            String trimmedContexts = contexts.trim();
            if (trimmedContexts.isEmpty()) {
                excludedContextsPerHost = Collections.emptyMap();
            } else {
                excludedContextsPerHost = new HashMap<>();
                for (String c : trimmedContexts.split(",")) {
                    String[] parts = c.trim().split(":");
                    if (parts.length > 2) {
                        throw ROOT_LOGGER.excludedContextsWrongFormat(trimmedContexts);
                    }
                    String host = null;
                    String trimmedContext = parts[0].trim();
                    if (parts.length == 2) {
                        host = trimmedContext;
                        trimmedContext = parts[1].trim();
                    }
                    String path = trimmedContext.equals("ROOT") ? "" : "/" + trimmedContext;
                    Set<String> paths = excludedContextsPerHost.computeIfAbsent(host, k -> new HashSet<>());
                    paths.add(path);
                }
            }
        }
        builder.mcmp().setExcludedContextsPerHost(excludedContextsPerHost);
    }
    // Balancer
    builder.balancer().setStickySession(STICKY_SESSION.resolveModelAttribute(context, model).asBoolean()).setStickySessionRemove(STICKY_SESSION_REMOVE.resolveModelAttribute(context, model).asBoolean()).setStickySessionForce(STICKY_SESSION_FORCE.resolveModelAttribute(context, model).asBoolean()).setWorkerTimeout(WORKER_TIMEOUT.resolveModelAttribute(context, model).asInt()).setMaxAttempts(MAX_ATTEMPTS.resolveModelAttribute(context, model).asInt());
    // Node
    builder.node().setFlushPackets(FLUSH_PACKETS.resolveModelAttribute(context, model).asBoolean()).setFlushWait(FLUSH_WAIT.resolveModelAttribute(context, model).asInt()).setPing(PING.resolveModelAttribute(context, model).asInt()).setSmax(SMAX.resolveModelAttribute(context, model).asInt()).setTtl(TTL.resolveModelAttribute(context, model).asInt()).setNodeTimeout(NODE_TIMEOUT.resolveModelAttribute(context, model).asInt());
    optionalString(BALANCER.resolveModelAttribute(context, model)).ifPresent(balancer -> builder.node().setBalancer(balancer));
    optionalString(LOAD_BALANCING_GROUP.resolveModelAttribute(context, model)).ifPresent(group -> builder.node().setLoadBalancingGroup(group));
    optionalList(PROXIES.resolveModelAttribute(context, model)).ifPresent(refs -> refs.stream().map(ModelNode::asString).forEach(ref -> outboundSocketBindings.add(new InjectedValueDependency<>(context.getCapabilityServiceName(OUTBOUND_SOCKET_BINDING_CAPABILITY_NAME, ref, OutboundSocketBinding.class), OutboundSocketBinding.class))));
    if (model.hasDefined(CommonAttributes.PROXY_LIST)) {
        throw new OperationFailedException(ROOT_LOGGER.proxyListNotAllowedInCurrentModel());
    }
    // Elytron-based security support
    Optional<String> sslContextRef = optionalString(SSL_CONTEXT.resolveModelAttribute(context, model));
    sslContextRef.ifPresent(sslContext -> this.sslContextDependency = new InjectedValueDependency<>(context.getCapabilityServiceName(SSL_CONTEXT_CAPABILITY_NAME, sslContext, SSLContext.class), SSLContext.class));
    if (model.get(ModClusterSSLResourceDefinition.PATH.getKeyValuePair()).isDefined()) {
        if (sslContextRef.isPresent()) {
            throw ROOT_LOGGER.bothElytronAndLegacySslContextDefined();
        }
        ModelNode sslModel = model.get(ModClusterSSLResourceDefinition.PATH.getKeyValuePair());
        ModClusterConfig sslConfiguration = new ModClusterConfig();
        optionalString(KEY_ALIAS.resolveModelAttribute(context, sslModel)).ifPresent(sslConfiguration::setSslKeyAlias);
        optionalString(PASSWORD.resolveModelAttribute(context, sslModel)).ifPresent(sslConfiguration::setSslTrustStorePassword);
        optionalString(PASSWORD.resolveModelAttribute(context, sslModel)).ifPresent(sslConfiguration::setSslKeyStorePassword);
        optionalString(CERTIFICATE_KEY_FILE.resolveModelAttribute(context, sslModel)).ifPresent(sslConfiguration::setSslKeyStore);
        optionalString(CIPHER_SUITE.resolveModelAttribute(context, sslModel)).ifPresent(sslConfiguration::setSslCiphers);
        optionalString(PROTOCOL.resolveModelAttribute(context, sslModel)).ifPresent(sslConfiguration::setSslProtocol);
        optionalString(CA_CERTIFICATE_FILE.resolveModelAttribute(context, sslModel)).ifPresent(sslConfiguration::setSslTrustStore);
        optionalString(CA_REVOCATION_URL.resolveModelAttribute(context, sslModel)).ifPresent(sslConfiguration::setSslCrlFile);
        builder.mcmp().setSocketFactory(new JSSESocketFactory(sslConfiguration));
    }
    return this;
}
Also used : OutboundSocketBinding(org.jboss.as.network.OutboundSocketBinding) SocketBinding(org.jboss.as.network.SocketBinding) FLUSH_WAIT(org.wildfly.extension.mod_cluster.ModClusterConfigResourceDefinition.FLUSH_WAIT) LOAD_BALANCING_GROUP(org.wildfly.extension.mod_cluster.ModClusterConfigResourceDefinition.LOAD_BALANCING_GROUP) SSLContext(javax.net.ssl.SSLContext) ROOT_LOGGER(org.wildfly.extension.mod_cluster.ModClusterLogger.ROOT_LOGGER) OutboundSocketBinding(org.jboss.as.network.OutboundSocketBinding) OperationContext(org.jboss.as.controller.OperationContext) SSL_CONTEXT(org.wildfly.extension.mod_cluster.ModClusterConfigResourceDefinition.SSL_CONTEXT) Map(java.util.Map) SessionDrainingStrategyEnum(org.jboss.modcluster.config.impl.SessionDrainingStrategyEnum) ServiceTarget(org.jboss.msc.service.ServiceTarget) WORKER_TIMEOUT(org.wildfly.extension.mod_cluster.ModClusterConfigResourceDefinition.WORKER_TIMEOUT) ModelNodes.optionalList(org.jboss.as.clustering.dmr.ModelNodes.optionalList) CA_REVOCATION_URL(org.wildfly.extension.mod_cluster.ModClusterSSLResourceDefinition.CA_REVOCATION_URL) AUTO_ENABLE_CONTEXTS(org.wildfly.extension.mod_cluster.ModClusterConfigResourceDefinition.AUTO_ENABLE_CONTEXTS) Collection(java.util.Collection) NetworkInterface(java.net.NetworkInterface) ADVERTISE_SECURITY_KEY(org.wildfly.extension.mod_cluster.ModClusterConfigResourceDefinition.ADVERTISE_SECURITY_KEY) Set(java.util.Set) ResourceServiceBuilder(org.jboss.as.clustering.controller.ResourceServiceBuilder) ADVERTISE_SOCKET(org.wildfly.extension.mod_cluster.ModClusterConfigResourceDefinition.ADVERTISE_SOCKET) InetSocketAddress(java.net.InetSocketAddress) Objects(java.util.Objects) SSL_CONTEXT_CAPABILITY_NAME(org.wildfly.extension.mod_cluster.ModClusterConfigResourceDefinition.SSL_CONTEXT_CAPABILITY_NAME) PASSWORD(org.wildfly.extension.mod_cluster.ModClusterSSLResourceDefinition.PASSWORD) PROTOCOL(org.wildfly.extension.mod_cluster.ModClusterSSLResourceDefinition.PROTOCOL) List(java.util.List) Stream(java.util.stream.Stream) OperationFailedException(org.jboss.as.controller.OperationFailedException) JSSESocketFactory(org.jboss.modcluster.mcmp.impl.JSSESocketFactory) ServiceName(org.jboss.msc.service.ServiceName) Optional(java.util.Optional) MAX_ATTEMPTS(org.wildfly.extension.mod_cluster.ModClusterConfigResourceDefinition.MAX_ATTEMPTS) ModelNode(org.jboss.dmr.ModelNode) Builder(org.wildfly.clustering.service.Builder) SESSION_DRAINING_STRATEGY(org.wildfly.extension.mod_cluster.ModClusterConfigResourceDefinition.SESSION_DRAINING_STRATEGY) ValueDependency(org.wildfly.clustering.service.ValueDependency) SMAX(org.wildfly.extension.mod_cluster.ModClusterConfigResourceDefinition.SMAX) Value(org.jboss.msc.value.Value) BALANCER(org.wildfly.extension.mod_cluster.ModClusterConfigResourceDefinition.BALANCER) ProxyConfiguration(org.jboss.modcluster.config.ProxyConfiguration) HashMap(java.util.HashMap) PROXY_URL(org.wildfly.extension.mod_cluster.ModClusterConfigResourceDefinition.PROXY_URL) PROXIES(org.wildfly.extension.mod_cluster.ModClusterConfigResourceDefinition.PROXIES) HashSet(java.util.HashSet) CIPHER_SUITE(org.wildfly.extension.mod_cluster.ModClusterSSLResourceDefinition.CIPHER_SUITE) SocketException(java.net.SocketException) KEY_ALIAS(org.wildfly.extension.mod_cluster.ModClusterSSLResourceDefinition.KEY_ALIAS) CERTIFICATE_KEY_FILE(org.wildfly.extension.mod_cluster.ModClusterSSLResourceDefinition.CERTIFICATE_KEY_FILE) SocketBinding(org.jboss.as.network.SocketBinding) InjectedValueDependency(org.wildfly.clustering.service.InjectedValueDependency) LinkedList(java.util.LinkedList) ModClusterConfiguration(org.jboss.modcluster.config.ModClusterConfiguration) PING(org.wildfly.extension.mod_cluster.ModClusterConfigResourceDefinition.PING) NODE_TIMEOUT(org.wildfly.extension.mod_cluster.ModClusterConfigResourceDefinition.NODE_TIMEOUT) STOP_CONTEXT_TIMEOUT(org.wildfly.extension.mod_cluster.ModClusterConfigResourceDefinition.STOP_CONTEXT_TIMEOUT) EXCLUDED_CONTEXTS(org.wildfly.extension.mod_cluster.ModClusterConfigResourceDefinition.EXCLUDED_CONTEXTS) ModClusterConfig(org.jboss.modcluster.config.impl.ModClusterConfig) ServiceBuilder(org.jboss.msc.service.ServiceBuilder) ModClusterConfigurationBuilder(org.jboss.modcluster.config.builder.ModClusterConfigurationBuilder) STICKY_SESSION(org.wildfly.extension.mod_cluster.ModClusterConfigResourceDefinition.STICKY_SESSION) STICKY_SESSION_FORCE(org.wildfly.extension.mod_cluster.ModClusterConfigResourceDefinition.STICKY_SESSION_FORCE) TimeUnit(java.util.concurrent.TimeUnit) CA_CERTIFICATE_FILE(org.wildfly.extension.mod_cluster.ModClusterSSLResourceDefinition.CA_CERTIFICATE_FILE) ServiceController(org.jboss.msc.service.ServiceController) ValueService(org.jboss.msc.service.ValueService) ADVERTISE(org.wildfly.extension.mod_cluster.ModClusterConfigResourceDefinition.ADVERTISE) TTL(org.wildfly.extension.mod_cluster.ModClusterConfigResourceDefinition.TTL) ModelNodes.optionalString(org.jboss.as.clustering.dmr.ModelNodes.optionalString) FLUSH_PACKETS(org.wildfly.extension.mod_cluster.ModClusterConfigResourceDefinition.FLUSH_PACKETS) SOCKET_TIMEOUT(org.wildfly.extension.mod_cluster.ModClusterConfigResourceDefinition.SOCKET_TIMEOUT) STICKY_SESSION_REMOVE(org.wildfly.extension.mod_cluster.ModClusterConfigResourceDefinition.STICKY_SESSION_REMOVE) Collections(java.util.Collections) Set(java.util.Set) HashSet(java.util.HashSet) OutboundSocketBinding(org.jboss.as.network.OutboundSocketBinding) OperationFailedException(org.jboss.as.controller.OperationFailedException) SessionDrainingStrategyEnum(org.jboss.modcluster.config.impl.SessionDrainingStrategyEnum) ModelNodes.optionalString(org.jboss.as.clustering.dmr.ModelNodes.optionalString) SSLContext(javax.net.ssl.SSLContext) ModClusterConfig(org.jboss.modcluster.config.impl.ModClusterConfig) InjectedValueDependency(org.wildfly.clustering.service.InjectedValueDependency) ModelNode(org.jboss.dmr.ModelNode) JSSESocketFactory(org.jboss.modcluster.mcmp.impl.JSSESocketFactory)

Example 2 with InjectedValueDependency

use of org.wildfly.clustering.service.InjectedValueDependency in project wildfly by wildfly.

the class TransportConfigurationBuilder method configure.

@Override
public Builder<TransportConfiguration<T>> configure(OperationContext context, ModelNode model) throws OperationFailedException {
    this.socketBinding = new InjectedValueDependency<>(CommonUnaryRequirement.SOCKET_BINDING.getServiceName(context, SOCKET_BINDING.resolveModelAttribute(context, model).asString()), SocketBinding.class);
    this.diagnosticsSocketBinding = ModelNodes.optionalString(DIAGNOSTICS_SOCKET_BINDING.resolveModelAttribute(context, model)).map(diagnosticsBinding -> new InjectedValueDependency<>(CommonUnaryRequirement.SOCKET_BINDING.getServiceName(context, diagnosticsBinding), SocketBinding.class)).orElse(null);
    Optional<String> machine = ModelNodes.optionalString(MACHINE.resolveModelAttribute(context, model));
    Optional<String> rack = ModelNodes.optionalString(RACK.resolveModelAttribute(context, model));
    Optional<String> site = ModelNodes.optionalString(SITE.resolveModelAttribute(context, model));
    if (site.isPresent() || rack.isPresent() || machine.isPresent()) {
        this.topology = new Topology() {

            @Override
            public String getMachine() {
                return machine.orElse(null);
            }

            @Override
            public String getRack() {
                return rack.orElse(null);
            }

            @Override
            public String getSite() {
                return site.orElse(null);
            }
        };
    }
    PathAddress address = context.getCurrentAddress();
    EnumSet.complementOf(EnumSet.of(ThreadPoolResourceDefinition.TIMER)).forEach(pool -> this.threadPoolFactories.put(pool, new InjectedValueDependency<>(new ThreadPoolServiceNameProvider(address, pool.getPathElement()), ThreadPoolFactory.class)));
    this.timerFactory = new InjectedValueDependency<>(new ThreadPoolServiceNameProvider(address, ThreadPoolResourceDefinition.TIMER.getPathElement()), TimerFactory.class);
    return super.configure(context, model);
}
Also used : SocketBinding(org.jboss.as.network.SocketBinding) InjectedValueDependency(org.wildfly.clustering.service.InjectedValueDependency) PathAddress(org.jboss.as.controller.PathAddress)

Example 3 with InjectedValueDependency

use of org.wildfly.clustering.service.InjectedValueDependency in project wildfly by wildfly.

the class CacheConfigurationBuilder method configure.

@Override
public Builder<Configuration> configure(OperationContext context, ModelNode model) throws OperationFailedException {
    boolean enabled = STATISTICS_ENABLED.resolveModelAttribute(context, model).asBoolean();
    this.statistics = new ConfigurationBuilder().jmxStatistics().enabled(enabled).available(enabled).create();
    this.global = new InjectedValueDependency<>(InfinispanRequirement.CONFIGURATION.getServiceName(context, this.containerName), GlobalConfiguration.class);
    this.builder = new org.wildfly.clustering.infinispan.spi.service.ConfigurationBuilder(CONFIGURATION.getServiceName(context.getCurrentAddress()), this.containerName, this.cacheName, this.andThen(builder -> {
        CacheMode mode = builder.clustering().cacheMode();
        if (mode.isSynchronous() && (this.transaction.getValue().lockingMode() == LockingMode.OPTIMISTIC) && (this.locking.getValue().isolationLevel() == IsolationLevel.REPEATABLE_READ)) {
            builder.locking().writeSkewCheck(true);
            builder.versioning().enable().scheme(VersioningScheme.SIMPLE);
        }
        GroupsConfigurationBuilder groupsBuilder = builder.clustering().hash().groups().enabled();
        this.module.getValue().loadService(Grouper.class).forEach(grouper -> groupsBuilder.addGrouper(grouper));
    })).configure(context);
    return this;
}
Also used : ValueDependency(org.wildfly.clustering.service.ValueDependency) ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) ExpirationConfiguration(org.infinispan.configuration.cache.ExpirationConfiguration) PersistenceConfiguration(org.infinispan.configuration.cache.PersistenceConfiguration) GlobalConfiguration(org.infinispan.configuration.global.GlobalConfiguration) OperationContext(org.jboss.as.controller.OperationContext) EvictionConfiguration(org.infinispan.configuration.cache.EvictionConfiguration) GroupsConfigurationBuilder(org.infinispan.configuration.cache.GroupsConfigurationBuilder) InfinispanRequirement(org.wildfly.clustering.infinispan.spi.InfinispanRequirement) Capability(org.jboss.as.clustering.infinispan.subsystem.CacheResourceDefinition.Capability) InjectedValueDependency(org.wildfly.clustering.service.InjectedValueDependency) ServiceTarget(org.jboss.msc.service.ServiceTarget) VersioningScheme(org.infinispan.configuration.cache.VersioningScheme) PathAddress(org.jboss.as.controller.PathAddress) Attribute(org.jboss.as.clustering.infinispan.subsystem.CacheResourceDefinition.Attribute) ServiceBuilder(org.jboss.msc.service.ServiceBuilder) LockingMode(org.infinispan.transaction.LockingMode) ResourceServiceBuilder(org.jboss.as.clustering.controller.ResourceServiceBuilder) TransactionConfiguration(org.infinispan.configuration.cache.TransactionConfiguration) Consumer(java.util.function.Consumer) ServiceController(org.jboss.msc.service.ServiceController) CacheMode(org.infinispan.configuration.cache.CacheMode) Grouper(org.infinispan.distribution.group.Grouper) IsolationLevel(org.infinispan.util.concurrent.IsolationLevel) Module(org.jboss.modules.Module) OperationFailedException(org.jboss.as.controller.OperationFailedException) Configuration(org.infinispan.configuration.cache.Configuration) ServiceName(org.jboss.msc.service.ServiceName) ModelNode(org.jboss.dmr.ModelNode) LockingConfiguration(org.infinispan.configuration.cache.LockingConfiguration) JMXStatisticsConfiguration(org.infinispan.configuration.cache.JMXStatisticsConfiguration) Builder(org.wildfly.clustering.service.Builder) InjectedValue(org.jboss.msc.value.InjectedValue) ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) GroupsConfigurationBuilder(org.infinispan.configuration.cache.GroupsConfigurationBuilder) GlobalConfiguration(org.infinispan.configuration.global.GlobalConfiguration) GroupsConfigurationBuilder(org.infinispan.configuration.cache.GroupsConfigurationBuilder) CacheMode(org.infinispan.configuration.cache.CacheMode)

Example 4 with InjectedValueDependency

use of org.wildfly.clustering.service.InjectedValueDependency 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();
    @SuppressWarnings("rawtypes") Collection<ValueDependency<CacheFactoryBuilder>> cacheDependencies = moduleDescription.getComponentDescriptions().stream().filter(StatefulComponentDescription.class::isInstance).map(description -> new InjectedValueDependency<>(getCacheFactoryBuilderServiceName((StatefulComponentDescription) description), CacheFactoryBuilder.class)).distinct().collect(Collectors.toList());
    Service<Void> service = new AbstractService<Void>() {

        @Override
        public void start(StartContext context) {
            // Install dependencies for each distinct cache factory builder referenced by the deployment
            cacheDependencies.stream().map(Value::getValue).distinct().forEach(builder -> builder.installDeploymentUnitDependencies(support, target, name));
        }
    };
    ServiceBuilder<Void> builder = target.addService(name.append("cache-dependencies-installer"), service);
    cacheDependencies.forEach(dependency -> dependency.register(builder));
    builder.install();
    // Install versioned marshalling configuration
    InjectedValue<ModuleDeployment> deployment = new InjectedValue<>();
    Module module = unit.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE);
    target.addService(MarshallingConfigurationRepositoryValue.getServiceName(name), new ValueService<>(new MarshallingConfigurationRepositoryValue(deployment, new ImmediateValue<>(module)))).addDependency(name.append(ModuleDeployment.SERVICE_NAME), ModuleDeployment.class, deployment).setInitialMode(ServiceController.Mode.ON_DEMAND).install();
}
Also used : InjectedValue(org.jboss.msc.value.InjectedValue) ServiceTarget(org.jboss.msc.service.ServiceTarget) MarshallingConfigurationRepositoryValue(org.jboss.as.ejb3.component.stateful.MarshallingConfigurationRepositoryValue) AbstractService(org.jboss.msc.service.AbstractService) ValueDependency(org.wildfly.clustering.service.ValueDependency) InjectedValueDependency(org.wildfly.clustering.service.InjectedValueDependency) ValueService(org.jboss.msc.service.ValueService) CapabilityServiceSupport(org.jboss.as.controller.capability.CapabilityServiceSupport) CacheFactoryBuilder(org.jboss.as.ejb3.cache.CacheFactoryBuilder) ImmediateValue(org.jboss.msc.value.ImmediateValue) ModuleDeployment(org.jboss.as.ejb3.deployment.ModuleDeployment) StartContext(org.jboss.msc.service.StartContext) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) ServiceName(org.jboss.msc.service.ServiceName) Value(org.jboss.msc.value.Value) ImmediateValue(org.jboss.msc.value.ImmediateValue) MarshallingConfigurationRepositoryValue(org.jboss.as.ejb3.component.stateful.MarshallingConfigurationRepositoryValue) InjectedValue(org.jboss.msc.value.InjectedValue) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 5 with InjectedValueDependency

use of org.wildfly.clustering.service.InjectedValueDependency in project wildfly by wildfly.

the class ElectionPolicyBuilder method configure.

@Override
public Builder<SingletonElectionPolicy> configure(OperationContext context, ModelNode model) throws OperationFailedException {
    this.preferences.clear();
    this.dependencies.clear();
    ModelNodes.optionalList(SOCKET_BINDING_PREFERENCES.resolveModelAttribute(context, model)).ifPresent(bindings -> {
        bindings.stream().map(ModelNode::asString).forEach(bindingName -> {
            InjectedValueDependency<OutboundSocketBinding> binding = new InjectedValueDependency<>(CommonUnaryRequirement.OUTBOUND_SOCKET_BINDING.getServiceName(context, bindingName), OutboundSocketBinding.class);
            this.preferences.add(new OutboundSocketBindingPreference(binding));
            this.dependencies.add(binding);
        });
    });
    ModelNodes.optionalList(NAME_PREFERENCES.resolveModelAttribute(context, model)).ifPresent(names -> {
        names.stream().map(ModelNode::asString).forEach(name -> this.preferences.add(new NamePreference(name)));
    });
    return this;
}
Also used : OutboundSocketBindingPreference(org.wildfly.extension.clustering.singleton.election.OutboundSocketBindingPreference) NamePreference(org.wildfly.clustering.singleton.election.NamePreference) OutboundSocketBinding(org.jboss.as.network.OutboundSocketBinding) InjectedValueDependency(org.wildfly.clustering.service.InjectedValueDependency)

Aggregations

InjectedValueDependency (org.wildfly.clustering.service.InjectedValueDependency)6 PathAddress (org.jboss.as.controller.PathAddress)3 ServiceName (org.jboss.msc.service.ServiceName)3 ServiceTarget (org.jboss.msc.service.ServiceTarget)3 ValueDependency (org.wildfly.clustering.service.ValueDependency)3 ResourceServiceBuilder (org.jboss.as.clustering.controller.ResourceServiceBuilder)2 OperationContext (org.jboss.as.controller.OperationContext)2 OperationFailedException (org.jboss.as.controller.OperationFailedException)2 OutboundSocketBinding (org.jboss.as.network.OutboundSocketBinding)2 SocketBinding (org.jboss.as.network.SocketBinding)2 ModelNode (org.jboss.dmr.ModelNode)2 Module (org.jboss.modules.Module)2 ServiceBuilder (org.jboss.msc.service.ServiceBuilder)2 ServiceController (org.jboss.msc.service.ServiceController)2 ValueService (org.jboss.msc.service.ValueService)2 InjectedValue (org.jboss.msc.value.InjectedValue)2 Value (org.jboss.msc.value.Value)2 Builder (org.wildfly.clustering.service.Builder)2 InetSocketAddress (java.net.InetSocketAddress)1 NetworkInterface (java.net.NetworkInterface)1