From c2ddab2ba05c338823182c7cdaccaa461ca3c12f Mon Sep 17 00:00:00 2001
From: rbygrave
- * For beans that are not in a JDBC data source you can implement this handle
- * bean finding. For example, read a log file building each entry as a bean and
- * returning that.
- *
- * There are a number of internal BeanFinders in Ebean to return meta data from
- * Ebean at runtime such as query execution statistics etc. See the beans in
- * com.avaje.ebean.meta and finders in com.avaje.ebean.server.meta.
- *
- * Note the returning object is cast to a List Set or Map so you do need to
- * get the return type right.
- *
+ * For beans that are not in a JDBC data source you can implement this handle
+ * bean finding. For example, read a log file building each entry as a bean and
+ * returning that.
+ *
+ * There are a number of internal BeanFinders in Ebean to return meta data from
+ * Ebean at runtime such as query execution statistics etc. See the beans in
+ * com.avaje.ebean.meta and finders in com.avaje.ebean.server.meta.
+ *
+ * Note the returning object is cast to a List Set or Map so you do need to
+ * get the return type right.
+ *
- * A BeanPersistAdapter is either found automatically via class path search or
- * can be added programmatically via
- * {@link ServerConfig#add(BeanPersistController)} or
- * {@link ServerConfig#setPersistControllers(java.util.List)}.
- *
+ * A BeanPersistAdapter is either found automatically via class path search or
+ * can be added programmatically via
+ * {@link ServerConfig#add(BeanPersistController)} or
+ * {@link ServerConfig#setPersistControllers(java.util.List)}.
+ *
- * Note that if want to totally change the finding, you need to use a BeanQueryAdapter
- * rather than using postLoad().
- *
- * Note that getTransaction() on the PersistRequest returns the transaction used
- * for the insert, update, delete or fetch. To explicitly use this same
- * transaction you should use this transaction via methods on EbeanServer.
- *
- * It is worth noting that BeanPersistListener is different in three main ways
- * from BeanPersistController postXXX methods.
- *
- *
- * Object extaBeanToSave = ...;
- * Transaction t = request.getTransaction();
- * EbeanServer server = request.getEbeanServer();
- * server.save(extraBeanToSave, t);
- *
- *
- *
- *
- *
- *
- * A BeanPersistController is either found automatically via class path search - * or can be added programmatically via ServerConfiguration.addEntity(). - *
- */ -public interface BeanPersistController { - - /** - * When there are multiple BeanPersistController's for a given entity type - * this controls the order in which they are executed. - *- * Lowest values are executed first. - *
- * - * @return an int used to control the order BeanPersistController's are - * executed - */ - int getExecutionOrder(); - - /** - * Return true if this BeanPersistController should be registered for events - * on this entity type. - */ - boolean isRegisterFor(Class> cls); - - /** - * Prior to the insert perform some action. Return true if you want the - * default functionality to continue. - *- * Return false if you have completely replaced the insert functionality and - * do not want the default insert to be performed. - *
- */ - boolean preInsert(BeanPersistRequest> request); - - /** - * Prior to the update perform some action. Return true if you want the - * default functionality to continue. - *- * Return false if you have completely replaced the update functionality and - * do not want the default update to be performed. - *
- */ - boolean preUpdate(BeanPersistRequest> request); - - /** - * Prior to the delete perform some action. Return true if you want the - * default functionality to continue. - *- * Return false if you have completely replaced the delete functionality and - * do not want the default delete to be performed. - *
- */ - boolean preDelete(BeanPersistRequest> request); - - /** - * Called after the insert was performed. - */ - void postInsert(BeanPersistRequest> request); - - /** - * Called after the update was performed. - */ - void postUpdate(BeanPersistRequest> request); - - /** - * Called after the delete was performed. - */ - void postDelete(BeanPersistRequest> request); - - /** - * Called after every each bean is fetched and loaded from the database. You - * can override this to derive some information to set to the bean. - */ - void postLoad(Object bean, Set+ * Note that if want to totally change the finding, you need to use a BeanQueryAdapter + * rather than using postLoad(). + *
+ *+ * Note that getTransaction() on the PersistRequest returns the transaction used + * for the insert, update, delete or fetch. To explicitly use this same + * transaction you should use this transaction via methods on EbeanServer. + *
+ * + *+ * + * Object extaBeanToSave = ...; + * Transaction t = request.getTransaction(); + * EbeanServer server = request.getEbeanServer(); + * server.save(extraBeanToSave, t); + * + *+ * + *
+ * It is worth noting that BeanPersistListener is different in three main ways + * from BeanPersistController postXXX methods. + *
+ * A BeanPersistController is either found automatically via class path search + * or can be added programmatically via ServerConfiguration.addEntity(). + *
+ */ +public interface BeanPersistController { + + /** + * When there are multiple BeanPersistController's for a given entity type + * this controls the order in which they are executed. + *+ * Lowest values are executed first. + *
+ * + * @return an int used to control the order BeanPersistController's are + * executed + */ + int getExecutionOrder(); + + /** + * Return true if this BeanPersistController should be registered for events + * on this entity type. + */ + boolean isRegisterFor(Class> cls); + + /** + * Prior to the insert perform some action. Return true if you want the + * default functionality to continue. + *+ * Return false if you have completely replaced the insert functionality and + * do not want the default insert to be performed. + *
+ */ + boolean preInsert(BeanPersistRequest> request); + + /** + * Prior to the update perform some action. Return true if you want the + * default functionality to continue. + *+ * Return false if you have completely replaced the update functionality and + * do not want the default update to be performed. + *
+ */ + boolean preUpdate(BeanPersistRequest> request); + + /** + * Prior to the delete perform some action. Return true if you want the + * default functionality to continue. + *+ * Return false if you have completely replaced the delete functionality and + * do not want the default delete to be performed. + *
+ */ + boolean preDelete(BeanPersistRequest> request); + + /** + * Called after the insert was performed. + */ + void postInsert(BeanPersistRequest> request); + + /** + * Called after the update was performed. + */ + void postUpdate(BeanPersistRequest> request); + + /** + * Called after the delete was performed. + */ + void postDelete(BeanPersistRequest> request); + + /** + * Called after every each bean is fetched and loaded from the database. You + * can override this to derive some information to set to the bean. + */ + void postLoad(Object bean, Set- * These listen events occur after a successful commit. They also occur in a - * background thread rather than the thread used to perform the actual insert - * update or delete. In this way there is a delay between the commit and when - * the listener is notified of the event. - *
- *- * 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. - *
- *- * It is worth noting that BeanPersistListener is different in three main ways - * from BeanPersistController postXXX methods. - *
- * A BeanPersistListener is either found automatically via class path search or - * can be added programmatically via {@link ServerConfig#add(BeanPersistListener)}}. - *
- * @see ServerConfig#add(BeanPersistListener) - */ -public interface BeanPersistListener { - - /** - * Return true if this BeanPersistListener should be registered for events - * on this entity type. - */ - 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. - * - * @param bean - * The bean that was inserted. - */ - boolean inserted(Object bean); - - /** - * Notified that a bean has been updated locally. Return true if you want the - * cluster to be notified of the event. - * - * @param bean - * The bean that was updated. - * @param updatedProperties - * The properties that were modified by this update. - */ - boolean updated(Object bean, Set+ * These listen events occur after a successful commit. They also occur in a + * background thread rather than the thread used to perform the actual insert + * update or delete. In this way there is a delay between the commit and when + * the listener is notified of the event. + *
+ *+ * 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. + *
+ *+ * It is worth noting that BeanPersistListener is different in three main ways + * from BeanPersistController postXXX methods. + *
+ * A BeanPersistListener is either found automatically via class path search or + * can be added programmatically via {@link ServerConfig#add(BeanPersistListener)}}. + *
+ * @see ServerConfig#add(BeanPersistListener) + */ +public interface BeanPersistListener { + + /** + * Return true if this BeanPersistListener should be registered for events + * on this entity type. + */ + 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. + * + * @param bean + * The bean that was inserted. + */ + boolean inserted(Object bean); + + /** + * Notified that a bean has been updated locally. Return true if you want the + * cluster to be notified of the event. + * + * @param bean + * The bean that was updated. + * @param updatedProperties + * The properties that were modified by this update. + */ + boolean updated(Object bean, Set- * This can be used to add expressions to a query - for example to enable - * partitioning based on the user executing the query. - *
- *- * A BeanQueryAdapter is either found automatically via class path search or can - * be added programmatically via {@link ServerConfig#add(BeanQueryAdapter)}. - *
- *- * Note that a BeanQueryAdapter should be thread safe (stateless) and if - * registered automatically via class path search it needs to have a default - * constructor. - *
- */ -public interface BeanQueryAdapter { - - /** - * Return true if this adapter is interested in queries for the given entity - * type. - */ - boolean isRegisterFor(Class> cls); - - /** - * Returns an int to to control the order in which BeanQueryAdapter are - * executed when there is multiple of them registered for a given entity type - * (class). - */ - int getExecutionOrder(); - - /** - * Modify the associated query prior to it being executed. - */ - void preQuery(BeanQueryRequest> request); - -} +package com.avaje.ebean.event; + +import com.avaje.ebean.config.ServerConfig; + +/** + * Objects extending this modify queries prior their execution. + *+ * This can be used to add expressions to a query - for example to enable + * partitioning based on the user executing the query. + *
+ *+ * A BeanQueryAdapter is either found automatically via class path search or can + * be added programmatically via {@link ServerConfig#add(BeanQueryAdapter)}. + *
+ *+ * Note that a BeanQueryAdapter should be thread safe (stateless) and if + * registered automatically via class path search it needs to have a default + * constructor. + *
+ */ +public interface BeanQueryAdapter { + + /** + * Return true if this adapter is interested in queries for the given entity + * type. + */ + boolean isRegisterFor(Class> cls); + + /** + * Returns an int to to control the order in which BeanQueryAdapter are + * executed when there is multiple of them registered for a given entity type + * (class). + */ + int getExecutionOrder(); + + /** + * Modify the associated query prior to it being executed. + */ + void preQuery(BeanQueryRequest> request); + +} diff --git a/src/main/java/com/avaje/ebean/event/BulkTableEvent.java b/src/main/java/com/avaje/ebean/event/BulkTableEvent.java index ed0fbbc0c..419e04c9c 100644 --- a/src/main/java/com/avaje/ebean/event/BulkTableEvent.java +++ b/src/main/java/com/avaje/ebean/event/BulkTableEvent.java @@ -1,30 +1,30 @@ -package com.avaje.ebean.event; - -/** - * The bulk table event. - * - * @author Robin Bygrave - */ -public interface BulkTableEvent { - - /** - * Return the name of the table that was involved. - */ - String getTableName(); - - /** - * Return true if rows were inserted. - */ - boolean isInsert(); - - /** - * Return true if rows were updated. - */ - boolean isUpdate(); - - /** - * Return true if rows were deleted. - */ - boolean isDelete(); - -} +package com.avaje.ebean.event; + +/** + * The bulk table event. + * + * @author Robin Bygrave + */ +public interface BulkTableEvent { + + /** + * Return the name of the table that was involved. + */ + String getTableName(); + + /** + * Return true if rows were inserted. + */ + boolean isInsert(); + + /** + * Return true if rows were updated. + */ + boolean isUpdate(); + + /** + * Return true if rows were deleted. + */ + boolean isDelete(); + +} diff --git a/src/main/java/com/avaje/ebean/event/BulkTableEventListener.java b/src/main/java/com/avaje/ebean/event/BulkTableEventListener.java index db1959cf6..e3583cf7b 100644 --- a/src/main/java/com/avaje/ebean/event/BulkTableEventListener.java +++ b/src/main/java/com/avaje/ebean/event/BulkTableEventListener.java @@ -1,30 +1,30 @@ -package com.avaje.ebean.event; - -import java.util.Set; - -import com.avaje.ebean.Ebean; - -/** - * Listen for bulk table events that occur. - *- * These events can be triggered via - * {@link Ebean#externalModification(String, boolean, boolean, boolean)} or - * automatically determined from Ebean bulk update statements. - *
- * - * @author Robin Bygrave - * - */ -public interface BulkTableEventListener { - - /** - * Return the tables that this listener is interested in. - */ - Set+ * These events can be triggered via + * {@link Ebean#externalModification(String, boolean, boolean, boolean)} or + * automatically determined from Ebean bulk update statements. + *
+ * + * @author Robin Bygrave + * + */ +public interface BulkTableEventListener { + + /** + * Return the tables that this listener is interested in. + */ + Set- * Provides a simple way to construct and register multiple listeners and - * adapters that need shared services without using DI. - *
- * - * @author Robin Bygrave - */ -public interface ServerConfigStartup { - - /** - * On starting configure the ServerConfig. - */ - void onStart(ServerConfig serverConfig); - -} +package com.avaje.ebean.event; + +import com.avaje.ebean.config.ServerConfig; + +/** + * Used to configure the server on startup. + *+ * Provides a simple way to construct and register multiple listeners and + * adapters that need shared services without using DI. + *
+ * + * @author Robin Bygrave + */ +public interface ServerConfigStartup { + + /** + * On starting configure the ServerConfig. + */ + void onStart(ServerConfig serverConfig); + +} diff --git a/src/main/java/com/avaje/ebean/event/TransactionEventListener.java b/src/main/java/com/avaje/ebean/event/TransactionEventListener.java index 59dc47ce3..fb9ab50c7 100644 --- a/src/main/java/com/avaje/ebean/event/TransactionEventListener.java +++ b/src/main/java/com/avaje/ebean/event/TransactionEventListener.java @@ -1,18 +1,18 @@ -package com.avaje.ebean.event; - -import com.avaje.ebean.Transaction; - -/** - * Used to get notified about commit or rollback of a transaction - */ -public interface TransactionEventListener { - /** - * Called after the transaction has been committed - */ - void postTransactionCommit(Transaction tx); - - /** - * Called after the transaction has been rolled back - */ - void postTransactionRollback(Transaction tx, Throwable cause); -} +package com.avaje.ebean.event; + +import com.avaje.ebean.Transaction; + +/** + * Used to get notified about commit or rollback of a transaction + */ +public interface TransactionEventListener { + /** + * Called after the transaction has been committed + */ + void postTransactionCommit(Transaction tx); + + /** + * Called after the transaction has been rolled back + */ + void postTransactionRollback(Transaction tx, Throwable cause); +} diff --git a/src/main/java/com/avaje/ebean/event/TransactionEventListenerAdapter.java b/src/main/java/com/avaje/ebean/event/TransactionEventListenerAdapter.java index d9f0e3d20..376dfdfbe 100644 --- a/src/main/java/com/avaje/ebean/event/TransactionEventListenerAdapter.java +++ b/src/main/java/com/avaje/ebean/event/TransactionEventListenerAdapter.java @@ -1,18 +1,18 @@ -package com.avaje.ebean.event; - -import com.avaje.ebean.Transaction; - -/** - * A no operation implementation of TransactionEventListener. Objects extending - * this need to only override the methods they want to. - */ -public abstract class TransactionEventListenerAdapter implements TransactionEventListener { - - public void postTransactionCommit(Transaction tx) { - // do nothing by default - } - - public void postTransactionRollback(Transaction tx, Throwable cause) { - // do nothing by default - } -} +package com.avaje.ebean.event; + +import com.avaje.ebean.Transaction; + +/** + * A no operation implementation of TransactionEventListener. Objects extending + * this need to only override the methods they want to. + */ +public abstract class TransactionEventListenerAdapter implements TransactionEventListener { + + public void postTransactionCommit(Transaction tx) { + // do nothing by default + } + + public void postTransactionRollback(Transaction tx, Throwable cause) { + // do nothing by default + } +}