- public EntityOwnershipListenerRegistration registerListener(Entity entity, EntityOwnershipListener listener) {
- // TODO Auto-generated method stub
- return null;
+ public EntityOwnershipListenerRegistration registerListener(String entityType, EntityOwnershipListener listener) {
+ Preconditions.checkNotNull(entityType, "entityType cannot be null");
+ Preconditions.checkNotNull(listener, "listener cannot be null");
+
+ RegisterListenerLocal registerListener = new RegisterListenerLocal(listener, entityType);
+
+ LOG.debug("Registering listener with message: {}", registerListener);
+
+ executeLocalEntityOwnershipShardOperation(registerListener);
+ return new DistributedEntityOwnershipListenerRegistration(listener, entityType, this);
+ }
+
+ void unregisterListener(String entityType, EntityOwnershipListener listener) {
+ LOG.debug("Unregistering listener {} for entity type {}", listener, entityType);
+
+ executeLocalEntityOwnershipShardOperation(new UnregisterListenerLocal(listener, entityType));