All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.infinispan.cdi.event.cache.DataRehashedAdapter Maven / Gradle / Ivy

There is a newer version: 9.1.7.Final
Show newest version
package org.infinispan.cdi.event.cache;

import org.infinispan.Cache;
import org.infinispan.distribution.ch.ConsistentHash;
import org.infinispan.notifications.Listener;
import org.infinispan.notifications.cachelistener.annotation.DataRehashed;
import org.infinispan.notifications.cachelistener.event.DataRehashedEvent;
import org.infinispan.remoting.transport.Address;

import javax.enterprise.event.Event;
import javax.enterprise.util.TypeLiteral;
import java.util.Collection;

/**
 * Event bridge for {@link org.infinispan.notifications.cachelistener.annotation.DataRehashed}.
 *
 * @author Pete Muir
 * @author Sebastian Laskawiec
 * @see org.infinispan.notifications.Listener
 * @see org.infinispan.notifications.cachelistener.annotation.DataRehashed
 */
@Listener
public class DataRehashedAdapter 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 CDIDataRehashedEvent implements DataRehashedEvent {
      private DataRehashedEvent decoratedEvent;

      private CDIDataRehashedEvent(DataRehashedEvent decoratedEvent) {
         this.decoratedEvent = decoratedEvent;
      }

      @Override
      public Collection
getMembersAtStart() { return decoratedEvent.getMembersAtStart(); } @Override public Collection
getMembersAtEnd() { return decoratedEvent.getMembersAtEnd(); } @Override public ConsistentHash getConsistentHashAtStart() { return decoratedEvent.getConsistentHashAtStart(); } @Override public ConsistentHash getConsistentHashAtEnd() { return decoratedEvent.getConsistentHashAtEnd(); } @Override public ConsistentHash getUnionConsistentHash() { return decoratedEvent.getUnionConsistentHash(); } @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(); } } public static final DataRehashedEvent EMPTY = new DataRehashedEvent() { @Override public Collection
getMembersAtStart() { return null; } @Override public Collection
getMembersAtEnd() { return null; } @Override public ConsistentHash getConsistentHashAtStart() { return null; } @Override public ConsistentHash getConsistentHashAtEnd() { return null; } @Override public ConsistentHash getUnionConsistentHash() { return null; } @Override public int getNewTopologyId() { return 0; } @Override public Type getType() { return null; } @Override public boolean isPre() { return false; } @Override public Cache getCache() { return null; } }; /** * Events which will be selected (including generic type information (). */ @SuppressWarnings("serial") public static final TypeLiteral> WILDCARD_TYPE = new TypeLiteral>() { }; public DataRehashedAdapter(Event> event) { super(event); } @Override @DataRehashed public void fire(DataRehashedEvent payload) { super.fire(new CDIDataRehashedEvent(payload)); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy