Search in sources :

Example 1 with CommandDispatcherFactory

use of org.wildfly.clustering.spi.dispatcher.CommandDispatcherFactory in project wildfly by wildfly.

the class LocalCommandDispatcherFactoryServiceConfigurator method build.

@Override
public ServiceBuilder<?> build(ServiceTarget target) {
    ServiceBuilder<?> builder = target.addService(this.getServiceName());
    Consumer<CommandDispatcherFactory> factory = this.group.register(builder).provides(this.getServiceName());
    Service service = new FunctionalService<>(factory, Functions.identity(), this);
    return builder.setInstance(service).setInitialMode(ServiceController.Mode.ON_DEMAND);
}
Also used : FunctionalService(org.wildfly.clustering.service.FunctionalService) CommandDispatcherFactory(org.wildfly.clustering.spi.dispatcher.CommandDispatcherFactory) FunctionalService(org.wildfly.clustering.service.FunctionalService) Service(org.jboss.msc.Service)

Example 2 with CommandDispatcherFactory

use of org.wildfly.clustering.spi.dispatcher.CommandDispatcherFactory in project wildfly by wildfly.

the class BroadcastCommandDispatcherFactoryInstaller method accept.

@Override
public void accept(OperationContext context, String channelName) {
    ServiceName name = MessagingServices.getBroadcastCommandDispatcherFactoryServiceName(channelName);
    // N.B. BroadcastCommandDispatcherFactory implementations are shared across multiple server resources
    if (this.names.add(name)) {
        ServiceBuilder<?> builder = context.getServiceTarget().addService(name);
        Consumer<BroadcastCommandDispatcherFactory> injector = builder.provides(name);
        Supplier<CommandDispatcherFactory> factory = builder.requires(ClusteringRequirement.COMMAND_DISPATCHER_FACTORY.getServiceName(context, channelName));
        Service service = new FunctionalService<>(injector, ConcurrentBroadcastCommandDispatcherFactory::new, factory);
        builder.setInstance(service).setInitialMode(ServiceController.Mode.ON_DEMAND).install();
    }
}
Also used : FunctionalService(org.wildfly.clustering.service.FunctionalService) ServiceName(org.jboss.msc.service.ServiceName) CommandDispatcherFactory(org.wildfly.clustering.spi.dispatcher.CommandDispatcherFactory) FunctionalService(org.wildfly.clustering.service.FunctionalService) Service(org.jboss.msc.Service)

Example 3 with CommandDispatcherFactory

use of org.wildfly.clustering.spi.dispatcher.CommandDispatcherFactory in project wildfly by wildfly.

the class ConcurrentBroadcastCommandDispatcherFactory method createCommandDispatcher.

@SuppressWarnings("unchecked")
@Override
public <C> CommandDispatcher<C> createCommandDispatcher(Object id, C context) {
    CommandDispatcherFactory dispatcherFactory = this.factory;
    Function<Runnable, CommandDispatcher<?>> factory = new Function<Runnable, CommandDispatcher<?>>() {

        @Override
        public CommandDispatcher<C> apply(Runnable closeTask) {
            CommandDispatcher<C> dispatcher = dispatcherFactory.createCommandDispatcher(id, context, WildFlySecurityManager.getClassLoaderPrivileged(this.getClass()));
            return new ConcurrentCommandDispatcher<>(dispatcher, closeTask);
        }
    };
    return (CommandDispatcher<C>) this.dispatchers.apply(id, factory);
}
Also used : Function(java.util.function.Function) CommandDispatcherFactory(org.wildfly.clustering.spi.dispatcher.CommandDispatcherFactory) CommandDispatcher(org.wildfly.clustering.dispatcher.CommandDispatcher)

Example 4 with CommandDispatcherFactory

use of org.wildfly.clustering.spi.dispatcher.CommandDispatcherFactory in project wildfly by wildfly.

the class InfinispanBeanManagerFactory method createBeanManager.

@Override
public BeanManager<I, T, TransactionBatch> createBeanManager(Supplier<I> identifierFactory, PassivationListener<T> passivationListener, RemoveListener<T> removeListener) {
    ByteBufferMarshaller marshaller = new JBossByteBufferMarshaller(this.configuration.getMarshallingConfigurationRepository(), this.configuration.getBeanConfiguration().getModule().getClassLoader());
    MarshalledValueFactory<ByteBufferMarshaller> factory = new ByteBufferMarshalledValueFactory(marshaller);
    Cache<BeanKey<I>, BeanEntry<I>> beanCache = this.configuration.getCache();
    Cache<BeanGroupKey<I>, BeanGroupEntry<I, T, ByteBufferMarshaller>> groupCache = this.configuration.getCache();
    CacheProperties properties = new InfinispanCacheProperties(groupCache.getCacheConfiguration());
    String beanName = this.configuration.getBeanConfiguration().getName();
    BeanPassivationConfiguration passivationConfig = this.configuration.getPassivationConfiguration();
    PassivationConfiguration<T> passivation = new PassivationConfiguration<T>() {

        @Override
        public PassivationListener<T> getPassivationListener() {
            return passivationListener;
        }

        @Override
        public BeanPassivationConfiguration getConfiguration() {
            return passivationConfig;
        }
    };
    Predicate<Map.Entry<? super BeanKey<I>, ? super BeanEntry<I>>> beanFilter = new BeanFilter<>(beanName);
    BeanGroupFactory<I, T, ByteBufferMarshaller> groupFactory = new InfinispanBeanGroupFactory<>(groupCache, beanCache, beanFilter, factory, properties, passivation);
    Configuration<BeanGroupKey<I>, BeanGroupEntry<I, T, ByteBufferMarshaller>, BeanGroupFactory<I, T, ByteBufferMarshaller>> groupConfiguration = new SimpleConfiguration<>(groupCache, groupFactory);
    BeanFactory<I, T> beanFactory = new InfinispanBeanFactory<>(beanName, groupFactory, beanCache, properties, this.configuration.getBeanConfiguration().getTimeout(), properties.isPersistent() ? passivationListener : null);
    Configuration<BeanKey<I>, BeanEntry<I>, BeanFactory<I, T>> beanConfiguration = new SimpleConfiguration<>(beanCache, beanFactory);
    Group<Address> group = this.configuration.getGroup();
    KeyAffinityServiceFactory affinityFactory = this.configuration.getKeyAffinityServiceFactory();
    CommandDispatcherFactory dispatcherFactory = this.configuration.getCommandDispatcherFactory();
    Duration timeout = this.configuration.getBeanConfiguration().getTimeout();
    ExpirationConfiguration<T> expiration = new ExpirationConfiguration<T>() {

        @Override
        public Duration getTimeout() {
            return timeout;
        }

        @Override
        public RemoveListener<T> getRemoveListener() {
            return removeListener;
        }
    };
    String name = this.configuration.getName();
    InfinispanBeanManagerConfiguration<I, T> configuration = new InfinispanBeanManagerConfiguration<I, T>() {

        @Override
        public String getName() {
            return name;
        }

        @Override
        public Predicate<Map.Entry<? super BeanKey<I>, ? super BeanEntry<I>>> getBeanFilter() {
            return beanFilter;
        }

        @Override
        public KeyAffinityServiceFactory getAffinityFactory() {
            return affinityFactory;
        }

        @Override
        public Group<Address> getGroup() {
            return group;
        }

        @Override
        public CommandDispatcherFactory getCommandDispatcherFactory() {
            return dispatcherFactory;
        }

        @Override
        public ExpirationConfiguration<T> getExpirationConfiguration() {
            return expiration;
        }

        @Override
        public PassivationConfiguration<T> getPassivationConfiguration() {
            return passivation;
        }

        @Override
        public CacheProperties getProperties() {
            return properties;
        }
    };
    return new InfinispanBeanManager<>(configuration, identifierFactory, beanConfiguration, groupConfiguration);
}
Also used : InfinispanBeanGroupFactory(org.wildfly.clustering.ejb.infinispan.group.InfinispanBeanGroupFactory) Address(org.infinispan.remoting.transport.Address) BeanPassivationConfiguration(org.wildfly.clustering.ejb.BeanPassivationConfiguration) InfinispanCacheProperties(org.wildfly.clustering.ee.infinispan.InfinispanCacheProperties) CacheProperties(org.wildfly.clustering.ee.cache.CacheProperties) InfinispanBeanFactory(org.wildfly.clustering.ejb.infinispan.bean.InfinispanBeanFactory) CommandDispatcherFactory(org.wildfly.clustering.spi.dispatcher.CommandDispatcherFactory) ByteBufferMarshaller(org.wildfly.clustering.marshalling.spi.ByteBufferMarshaller) JBossByteBufferMarshaller(org.wildfly.clustering.marshalling.jboss.JBossByteBufferMarshaller) JBossByteBufferMarshaller(org.wildfly.clustering.marshalling.jboss.JBossByteBufferMarshaller) InfinispanBeanGroupFactory(org.wildfly.clustering.ejb.infinispan.group.InfinispanBeanGroupFactory) InfinispanBeanFactory(org.wildfly.clustering.ejb.infinispan.bean.InfinispanBeanFactory) BeanPassivationConfiguration(org.wildfly.clustering.ejb.BeanPassivationConfiguration) Duration(java.time.Duration) KeyAffinityServiceFactory(org.wildfly.clustering.infinispan.spi.affinity.KeyAffinityServiceFactory) ByteBufferMarshalledValueFactory(org.wildfly.clustering.marshalling.spi.ByteBufferMarshalledValueFactory) InfinispanCacheProperties(org.wildfly.clustering.ee.infinispan.InfinispanCacheProperties)

Aggregations

CommandDispatcherFactory (org.wildfly.clustering.spi.dispatcher.CommandDispatcherFactory)4 Service (org.jboss.msc.Service)2 FunctionalService (org.wildfly.clustering.service.FunctionalService)2 Duration (java.time.Duration)1 Function (java.util.function.Function)1 Address (org.infinispan.remoting.transport.Address)1 ServiceName (org.jboss.msc.service.ServiceName)1 CommandDispatcher (org.wildfly.clustering.dispatcher.CommandDispatcher)1 CacheProperties (org.wildfly.clustering.ee.cache.CacheProperties)1 InfinispanCacheProperties (org.wildfly.clustering.ee.infinispan.InfinispanCacheProperties)1 BeanPassivationConfiguration (org.wildfly.clustering.ejb.BeanPassivationConfiguration)1 InfinispanBeanFactory (org.wildfly.clustering.ejb.infinispan.bean.InfinispanBeanFactory)1 InfinispanBeanGroupFactory (org.wildfly.clustering.ejb.infinispan.group.InfinispanBeanGroupFactory)1 KeyAffinityServiceFactory (org.wildfly.clustering.infinispan.spi.affinity.KeyAffinityServiceFactory)1 JBossByteBufferMarshaller (org.wildfly.clustering.marshalling.jboss.JBossByteBufferMarshaller)1 ByteBufferMarshalledValueFactory (org.wildfly.clustering.marshalling.spi.ByteBufferMarshalledValueFactory)1 ByteBufferMarshaller (org.wildfly.clustering.marshalling.spi.ByteBufferMarshaller)1