org.infinispan.cdi.embedded.event.cache.TopologyChangedAdapter Maven / Gradle / Ivy
package org.infinispan.cdi.embedded.event.cache;
import javax.enterprise.event.Event;
import javax.enterprise.util.TypeLiteral;
import org.infinispan.Cache;
import org.infinispan.distribution.ch.ConsistentHash;
import org.infinispan.notifications.Listener;
import org.infinispan.notifications.cachelistener.annotation.TopologyChanged;
import org.infinispan.notifications.cachelistener.event.TopologyChangedEvent;
import org.infinispan.notifications.cachelistener.event.TransactionRegisteredEvent;
import org.infinispan.transaction.xa.GlobalTransaction;
/**
* @author Pete Muir
*/
@Listener
public class TopologyChangedAdapter extends AbstractAdapter> {
/**
* CDI does not allow parametrized type for events (like
). This is why this wrapped needs to be
* introduced. To ensure type safety, this needs to be linked to parent class (in other words this class can not
* be static).
*/
private class CDITopologyChangedEvent implements TopologyChangedEvent {
private TopologyChangedEvent decoratedEvent;
private CDITopologyChangedEvent(TopologyChangedEvent decoratedEvent) {
this.decoratedEvent = decoratedEvent;
}
@Override
public ConsistentHash getConsistentHashAtStart() {
return decoratedEvent.getConsistentHashAtStart();
}
@Override
public ConsistentHash getConsistentHashAtEnd() {
return decoratedEvent.getConsistentHashAtEnd();
}
@Override
public int getNewTopologyId() {
return decoratedEvent.getNewTopologyId();
}
@Override
public Type getType() {
return decoratedEvent.getType();
}
@Override
public boolean isPre() {
return decoratedEvent.isPre();
}
@Override
public Cache getCache() {
return decoratedEvent.getCache();
}
}
/**
* Needed for creating event bridge.
*/
public static final TransactionRegisteredEvent, ?> EMPTY = new TransactionRegisteredEvent
© 2015 - 2025 Weber Informatics LLC | Privacy Policy