use of org.wildfly.clustering.marshalling.spi.ByteBufferMarshaller in project wildfly by wildfly.
the class ChannelCommandDispatcherFactory method createCommandDispatcher.
@Override
public <C> CommandDispatcher<C> createCommandDispatcher(Object id, C commandContext, ClassLoader loader) {
ByteBufferMarshaller dispatcherMarshaller = this.marshallerFactory.apply(loader);
MarshalledValueFactory<ByteBufferMarshaller> factory = new ByteBufferMarshalledValueFactory(dispatcherMarshaller);
Contextualizer contextualizer = this.contextualizerFactory.apply(loader);
CommandDispatcherContext<C, ByteBufferMarshaller> context = new CommandDispatcherContext<C, ByteBufferMarshaller>() {
@Override
public C getCommandContext() {
return commandContext;
}
@Override
public Contextualizer getContextualizer() {
return contextualizer;
}
@Override
public MarshalledValueFactory<ByteBufferMarshaller> getMarshalledValueFactory() {
return factory;
}
};
if (this.contexts.putIfAbsent(id, context) != null) {
throw ClusteringServerLogger.ROOT_LOGGER.commandDispatcherAlreadyExists(id);
}
CommandMarshaller<C> marshaller = new CommandDispatcherMarshaller<>(this.marshaller, id, factory);
CommandDispatcher<C> localDispatcher = new LocalCommandDispatcher<>(this.getLocalMember(), commandContext);
return new ChannelCommandDispatcher<>(this.dispatcher, marshaller, dispatcherMarshaller, this, this.timeout, localDispatcher, () -> {
localDispatcher.close();
this.contexts.remove(id);
});
}
use of org.wildfly.clustering.marshalling.spi.ByteBufferMarshaller 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);
}
use of org.wildfly.clustering.marshalling.spi.ByteBufferMarshaller in project wildfly by wildfly.
the class InfinispanBeanGroupEntryMarshallerTestCase method test.
@Test
public void test() throws IOException {
SessionID id = new UUIDSessionID(UUID.randomUUID());
Map<SessionID, String> beans = Collections.singletonMap(id, "bean");
InfinispanBeanGroupEntry<SessionID, String, ByteBufferMarshaller> entry = new InfinispanBeanGroupEntry<>(new ByteBufferMarshalledValue<>(beans, JavaByteBufferMarshaller.INSTANCE));
Tester<InfinispanBeanGroupEntry<SessionID, String, ByteBufferMarshaller>> tester = ProtoStreamTesterFactory.INSTANCE.createTester();
tester.test(entry, InfinispanBeanGroupEntryMarshallerTestCase::assertEquals);
}
Aggregations