Search in sources :

Example 1 with SimpleMarshalledValueFactory

use of org.wildfly.clustering.marshalling.jboss.SimpleMarshalledValueFactory in project wildfly by wildfly.

the class InfinispanBeanManagerFactory method createBeanManager.

@Override
public BeanManager<I, T, TransactionBatch> createBeanManager(IdentifierFactory<I> identifierFactory, PassivationListener<T> passivationListener, RemoveListener<T> removeListener) {
    MarshallingContext context = new SimpleMarshallingContextFactory().createMarshallingContext(this.configuration.getMarshallingConfigurationRepository(), this.configuration.getBeanContext().getClassLoader());
    MarshalledValueFactory<MarshallingContext> factory = new SimpleMarshalledValueFactory(context);
    Cache<BeanKey<I>, BeanEntry<I>> beanCache = this.configuration.getCache();
    Cache<BeanGroupKey<I>, BeanGroupEntry<I, T>> groupCache = this.configuration.getCache();
    final CacheProperties properties = new InfinispanCacheProperties(groupCache.getCacheConfiguration());
    final String beanName = this.configuration.getBeanContext().getBeanName();
    BeanGroupFactory<I, T> groupFactory = new InfinispanBeanGroupFactory<>(groupCache, beanCache, factory, context, properties);
    Configuration<BeanGroupKey<I>, BeanGroupEntry<I, T>, BeanGroupFactory<I, T>> groupConfiguration = new SimpleConfiguration<>(groupCache, groupFactory);
    BeanFactory<I, T> beanFactory = new InfinispanBeanFactory<>(beanName, groupFactory, beanCache, properties, this.configuration.getBeanContext().getTimeout(), properties.isPersistent() ? passivationListener : null);
    Configuration<BeanKey<I>, BeanEntry<I>, BeanFactory<I, T>> beanConfiguration = new SimpleConfiguration<>(beanCache, beanFactory);
    final NodeFactory<Address> nodeFactory = this.configuration.getNodeFactory();
    final Registry<String, ?> registry = this.configuration.getRegistry();
    final KeyAffinityServiceFactory affinityFactory = this.configuration.getKeyAffinityServiceFactory();
    final CommandDispatcherFactory dispatcherFactory = this.configuration.getCommandDispatcherFactory();
    final Time timeout = this.configuration.getBeanContext().getTimeout();
    final ScheduledExecutorService scheduler = this.configuration.getScheduler();
    final ExpirationConfiguration<T> expiration = new ExpirationConfiguration<T>() {

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

        @Override
        public RemoveListener<T> getRemoveListener() {
            return removeListener;
        }

        @Override
        public ScheduledExecutorService getExecutor() {
            return scheduler;
        }
    };
    final Executor executor = this.configuration.getExecutor();
    final BeanPassivationConfiguration passivationConfig = this.configuration.getPassivationConfiguration();
    final PassivationConfiguration<T> passivation = new PassivationConfiguration<T>() {

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

        @Override
        public BeanPassivationConfiguration getConfiguration() {
            return passivationConfig;
        }

        @Override
        public Executor getExecutor() {
            return executor;
        }
    };
    InfinispanBeanManagerConfiguration<T> configuration = new InfinispanBeanManagerConfiguration<T>() {

        @Override
        public String getBeanName() {
            return beanName;
        }

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

        @Override
        public Registry<String, ?> getRegistry() {
            return registry;
        }

        @Override
        public NodeFactory<Address> getNodeFactory() {
            return nodeFactory;
        }

        @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) Time(org.wildfly.clustering.ejb.Time) BeanPassivationConfiguration(org.wildfly.clustering.ejb.BeanPassivationConfiguration) InfinispanCacheProperties(org.wildfly.clustering.ee.infinispan.InfinispanCacheProperties) CacheProperties(org.wildfly.clustering.ee.infinispan.CacheProperties) Executor(java.util.concurrent.Executor) SimpleMarshallingContextFactory(org.wildfly.clustering.marshalling.jboss.SimpleMarshallingContextFactory) InfinispanBeanFactory(org.wildfly.clustering.ejb.infinispan.bean.InfinispanBeanFactory) CommandDispatcherFactory(org.wildfly.clustering.dispatcher.CommandDispatcherFactory) MarshallingContext(org.wildfly.clustering.marshalling.jboss.MarshallingContext) InfinispanBeanGroupFactory(org.wildfly.clustering.ejb.infinispan.group.InfinispanBeanGroupFactory) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) InfinispanBeanFactory(org.wildfly.clustering.ejb.infinispan.bean.InfinispanBeanFactory) BeanPassivationConfiguration(org.wildfly.clustering.ejb.BeanPassivationConfiguration) KeyAffinityServiceFactory(org.wildfly.clustering.infinispan.spi.affinity.KeyAffinityServiceFactory) SimpleMarshalledValueFactory(org.wildfly.clustering.marshalling.jboss.SimpleMarshalledValueFactory) InfinispanCacheProperties(org.wildfly.clustering.ee.infinispan.InfinispanCacheProperties)

Example 2 with SimpleMarshalledValueFactory

use of org.wildfly.clustering.marshalling.jboss.SimpleMarshalledValueFactory in project wildfly by wildfly.

the class DistributableSessionManagerFactoryBuilder method build.

@Override
public ServiceBuilder<SessionManagerFactory> build(CapabilityServiceSupport support, ServiceTarget target, ServiceName name, DistributableSessionManagerConfiguration config) {
    Module module = config.getModule();
    MarshallingContext context = new SimpleMarshallingContextFactory().createMarshallingContext(new SimpleMarshallingConfigurationRepository(MarshallingVersion.class, MarshallingVersion.CURRENT, module), module.getClassLoader());
    MarshalledValueFactory<MarshallingContext> factory = new SimpleMarshalledValueFactory(context);
    SessionManagerFactoryConfiguration<MarshallingContext> configuration = new SessionManagerFactoryConfiguration<MarshallingContext>() {

        @Override
        public int getMaxActiveSessions() {
            return config.getMaxActiveSessions();
        }

        @Override
        public SessionAttributePersistenceStrategy getAttributePersistenceStrategy() {
            return strategies.get(config.getGranularity());
        }

        @Override
        public String getDeploymentName() {
            return config.getDeploymentName();
        }

        @Override
        public String getCacheName() {
            return config.getCacheName();
        }

        @Override
        public MarshalledValueFactory<MarshallingContext> getMarshalledValueFactory() {
            return factory;
        }

        @Override
        public MarshallingContext getMarshallingContext() {
            return context;
        }
    };
    Builder<org.wildfly.clustering.web.session.SessionManagerFactory<Batch>> builder = this.provider.getBuilder(configuration).configure(support);
    builder.build(target).install();
    return target.addService(name, new ValueService<>(this)).addDependency(builder.getServiceName(), org.wildfly.clustering.web.session.SessionManagerFactory.class, this.factory).setInitialMode(ServiceController.Mode.ON_DEMAND);
}
Also used : SessionManagerFactoryConfiguration(org.wildfly.clustering.web.session.SessionManagerFactoryConfiguration) SimpleMarshallingConfigurationRepository(org.wildfly.clustering.marshalling.jboss.SimpleMarshallingConfigurationRepository) SimpleMarshallingContextFactory(org.wildfly.clustering.marshalling.jboss.SimpleMarshallingContextFactory) SimpleMarshalledValueFactory(org.wildfly.clustering.marshalling.jboss.SimpleMarshalledValueFactory) SessionManagerFactory(io.undertow.servlet.api.SessionManagerFactory) MarshallingContext(org.wildfly.clustering.marshalling.jboss.MarshallingContext) Module(org.jboss.modules.Module)

Aggregations

MarshallingContext (org.wildfly.clustering.marshalling.jboss.MarshallingContext)2 SimpleMarshalledValueFactory (org.wildfly.clustering.marshalling.jboss.SimpleMarshalledValueFactory)2 SimpleMarshallingContextFactory (org.wildfly.clustering.marshalling.jboss.SimpleMarshallingContextFactory)2 SessionManagerFactory (io.undertow.servlet.api.SessionManagerFactory)1 Executor (java.util.concurrent.Executor)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 Address (org.infinispan.remoting.transport.Address)1 Module (org.jboss.modules.Module)1 CommandDispatcherFactory (org.wildfly.clustering.dispatcher.CommandDispatcherFactory)1 CacheProperties (org.wildfly.clustering.ee.infinispan.CacheProperties)1 InfinispanCacheProperties (org.wildfly.clustering.ee.infinispan.InfinispanCacheProperties)1 BeanPassivationConfiguration (org.wildfly.clustering.ejb.BeanPassivationConfiguration)1 Time (org.wildfly.clustering.ejb.Time)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 SimpleMarshallingConfigurationRepository (org.wildfly.clustering.marshalling.jboss.SimpleMarshallingConfigurationRepository)1 SessionManagerFactoryConfiguration (org.wildfly.clustering.web.session.SessionManagerFactoryConfiguration)1