Search in sources :

Example 6 with Mutator

use of org.wildfly.clustering.ee.Mutator in project wildfly by wildfly.

the class FineSessionAttributesFactory method createSessionAttributes.

@Override
public SessionAttributes createSessionAttributes(String id, SessionAttributeNamesEntry entry) {
    SessionAttributeNamesKey key = new SessionAttributeNamesKey(id);
    Mutator mutator = this.properties.isTransactional() && this.namesCache.getAdvancedCache().getCacheEntry(key).isCreated() ? Mutator.PASSIVE : new CacheEntryMutator<>(this.namesCache, key, entry);
    return new FineSessionAttributes<>(id, entry.getSequence(), entry.getNames(), mutator, this.attributeCache, this.marshaller, this.properties);
}
Also used : CacheEntryMutator(org.wildfly.clustering.ee.infinispan.CacheEntryMutator) Mutator(org.wildfly.clustering.ee.Mutator)

Example 7 with Mutator

use of org.wildfly.clustering.ee.Mutator in project wildfly by wildfly.

the class CacheEntryMutatorTestCase method mutateNonTransactional.

@Test
public void mutateNonTransactional() {
    AdvancedCache<Object, Object> cache = mock(AdvancedCache.class);
    Object id = new Object();
    Object value = new Object();
    Configuration config = new ConfigurationBuilder().transaction().transactionMode(TransactionMode.NON_TRANSACTIONAL).build();
    when(cache.getCacheConfiguration()).thenReturn(config);
    Mutator mutator = new CacheEntryMutator<>(cache, id, value);
    when(cache.getAdvancedCache()).thenReturn(cache);
    when(cache.withFlags(Flag.IGNORE_RETURN_VALUES, Flag.FAIL_SILENTLY)).thenReturn(cache);
    mutator.mutate();
    verify(cache).put(same(id), same(value));
    mutator.mutate();
    verify(cache, times(2)).put(same(id), same(value));
    mutator.mutate();
    verify(cache, times(3)).put(same(id), same(value));
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) Configuration(org.infinispan.configuration.cache.Configuration) Mutator(org.wildfly.clustering.ee.Mutator) Test(org.junit.Test)

Example 8 with Mutator

use of org.wildfly.clustering.ee.Mutator in project wildfly by wildfly.

the class InfinispanBeanFactory method createBean.

@Override
public Bean<I, T> createBean(I id, BeanEntry<I> entry) {
    I groupId = entry.getGroupId();
    BeanGroupEntry<I, T> groupEntry = this.groupFactory.findValue(groupId);
    if (groupEntry == null) {
        InfinispanEjbLogger.ROOT_LOGGER.invalidBeanGroup(id, groupId);
        this.cache.getAdvancedCache().withFlags(Flag.IGNORE_RETURN_VALUES).remove(this.createKey(id));
        return null;
    }
    BeanGroup<I, T> group = this.groupFactory.createGroup(groupId, groupEntry);
    Mutator mutator = (entry.getLastAccessedTime() == null) ? Mutator.PASSIVE : new CacheEntryMutator<>(this.cache, this.createKey(id), entry);
    return new InfinispanBean<>(id, entry, group, mutator, this, this.timeout, this.listener);
}
Also used : CacheEntryMutator(org.wildfly.clustering.ee.infinispan.CacheEntryMutator) Mutator(org.wildfly.clustering.ee.Mutator)

Aggregations

Mutator (org.wildfly.clustering.ee.Mutator)8 CacheEntryMutator (org.wildfly.clustering.ee.infinispan.CacheEntryMutator)6 Configuration (org.infinispan.configuration.cache.Configuration)2 ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)2 Test (org.junit.Test)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1