mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#723 - Breaking API - Change BeanPersistListener to return void rather than boolean for inserted(), updated() and deleted()
This commit is contained in:
@@ -19,8 +19,7 @@ public abstract class AbstractBeanPersistListener implements BeanPersistListener
|
||||
* @param bean The bean that was inserted.
|
||||
*/
|
||||
@Override
|
||||
public boolean inserted(Object bean) {
|
||||
return false;
|
||||
public void inserted(Object bean) {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -31,8 +30,7 @@ public abstract class AbstractBeanPersistListener implements BeanPersistListener
|
||||
* @param updatedProperties The properties that were modified by this update.
|
||||
*/
|
||||
@Override
|
||||
public boolean updated(Object bean, Set<String> updatedProperties) {
|
||||
return false;
|
||||
public void updated(Object bean, Set<String> updatedProperties) {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -42,8 +40,7 @@ public abstract class AbstractBeanPersistListener implements BeanPersistListener
|
||||
* @param bean The bean that was deleted.
|
||||
*/
|
||||
@Override
|
||||
public boolean deleted(Object bean) {
|
||||
return false;
|
||||
public void deleted(Object bean) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.avaje.ebean.event;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import com.avaje.ebean.config.ServerConfig;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Listens for committed bean events.
|
||||
* <p>
|
||||
@@ -13,22 +13,18 @@ import com.avaje.ebean.config.ServerConfig;
|
||||
* the listener is notified of the event.
|
||||
* </p>
|
||||
* <p>
|
||||
* For a cluster these events may need to be broadcast. Each of the inserted(),
|
||||
* updated() and deleted() methods return true if you want those events to be
|
||||
* broadcast to the other members of a cluster (the id values are broadcast). If
|
||||
* these methods return false then the events are not broadcast.
|
||||
* </p>
|
||||
* <p>
|
||||
* It is worth noting that BeanPersistListener is different in three main ways
|
||||
* It is worth noting that BeanPersistListener is different in two main ways
|
||||
* from BeanPersistController postXXX methods.
|
||||
* <ul>
|
||||
* <li>BeanPersistListener only sees successfully committed events.
|
||||
* BeanPersistController pre and post methods occur before the commit or a
|
||||
* rollback and will see events that are later rolled back</li>
|
||||
* <li>BeanPersistListener runs in a background thread and will not effect the
|
||||
* response time of the actual persist where as BeanPersistController code will</li>
|
||||
* <li>BeanPersistListener can be notified of events from other servers in a
|
||||
* cluster.</li>
|
||||
* <li>
|
||||
* BeanPersistListener only sees successfully committed events.
|
||||
* BeanPersistController pre and post methods occur before the commit or a
|
||||
* rollback and will see events that are later rolled back
|
||||
* </li>
|
||||
* <li>
|
||||
* BeanPersistListener runs in a background thread and will not effect the
|
||||
* response time of the actual persist where as BeanPersistController code will
|
||||
* </li>
|
||||
* </ul>
|
||||
* </p>
|
||||
* <p>
|
||||
@@ -46,32 +42,29 @@ public interface BeanPersistListener {
|
||||
boolean isRegisterFor(Class<?> cls);
|
||||
|
||||
/**
|
||||
* Notified that a bean has been inserted locally. Return true if you want the
|
||||
* cluster to be notified of the event.
|
||||
* Notified that a bean has been inserted.
|
||||
*
|
||||
* @param bean
|
||||
* The bean that was inserted.
|
||||
*/
|
||||
boolean inserted(Object bean);
|
||||
void inserted(Object bean);
|
||||
|
||||
/**
|
||||
* Notified that a bean has been updated locally. Return true if you want the
|
||||
* cluster to be notified of the event.
|
||||
* Notified that a bean has been updated.
|
||||
*
|
||||
* @param bean
|
||||
* The bean that was updated.
|
||||
* @param updatedProperties
|
||||
* The properties that were modified by this update.
|
||||
*/
|
||||
boolean updated(Object bean, Set<String> updatedProperties);
|
||||
void updated(Object bean, Set<String> updatedProperties);
|
||||
|
||||
/**
|
||||
* Notified that a bean has been deleted locally. Return true if you want the
|
||||
* cluster to be notified of the event.
|
||||
* Notified that a bean has been deleted.
|
||||
*
|
||||
* @param bean
|
||||
* The bean that was deleted.
|
||||
*/
|
||||
boolean deleted(Object bean);
|
||||
void deleted(Object bean);
|
||||
|
||||
}
|
||||
|
||||
+6
-18
@@ -83,33 +83,21 @@ public class ChainedBeanPersistListener implements BeanPersistListener {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean deleted(Object bean) {
|
||||
boolean notifyCluster = false;
|
||||
public void deleted(Object bean) {
|
||||
for (int i = 0; i < chain.length; i++) {
|
||||
if (chain[i].deleted(bean)) {
|
||||
notifyCluster = true;
|
||||
}
|
||||
chain[i].deleted(bean);
|
||||
}
|
||||
return notifyCluster;
|
||||
}
|
||||
|
||||
public boolean inserted(Object bean) {
|
||||
boolean notifyCluster = false;
|
||||
public void inserted(Object bean) {
|
||||
for (int i = 0; i < chain.length; i++) {
|
||||
if (chain[i].inserted(bean)) {
|
||||
notifyCluster = true;
|
||||
}
|
||||
chain[i].inserted(bean);
|
||||
}
|
||||
return notifyCluster;
|
||||
}
|
||||
|
||||
public boolean updated(Object bean, Set<String> updatedProperties) {
|
||||
boolean notifyCluster = false;
|
||||
public void updated(Object bean, Set<String> updatedProperties) {
|
||||
for (int i = 0; i < chain.length; i++) {
|
||||
if (chain[i].updated(bean, updatedProperties)) {
|
||||
notifyCluster = true;
|
||||
}
|
||||
chain[i].updated(bean, updatedProperties);
|
||||
}
|
||||
return notifyCluster;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user