You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by dk...@apache.org on 2011/08/11 18:13:04 UTC
svn commit: r1156659 - in /cayenne/main/trunk:
docs/doc/src/main/resources/RELEASE-NOTES.txt
framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/reflect/LifecycleCallbackRegistry.java
Author: dkazimirchyk
Date: Thu Aug 11 16:13:04 2011
New Revision: 1156659
URL: http://svn.apache.org/viewvc?rev=1156659&view=rev
Log:
CAY-1599 Annotation-based global listeners registration
registering as global all listener's methods which have annotation without parameters
Modified:
cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/reflect/LifecycleCallbackRegistry.java
Modified: cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt?rev=1156659&r1=1156658&r2=1156659&view=diff
==============================================================================
--- cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt (original)
+++ cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt Thu Aug 11 16:13:04 2011
@@ -28,6 +28,7 @@ CAY-1584 Improve Cayenne modeler re-orde
CAY-1586 New extension point: a strategy for retaining objects in the ObjectStore
CAY-1590 DDL generation without a live datasource
CAY-1594 DI extension point: turning on/off cross-ObjectContext synchronization
+CAY-1599 Annotation-based global listeners registration
Bug Fixes Since 3.1M2:
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/reflect/LifecycleCallbackRegistry.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/reflect/LifecycleCallbackRegistry.java?rev=1156659&r1=1156658&r2=1156659&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/reflect/LifecycleCallbackRegistry.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/reflect/LifecycleCallbackRegistry.java Thu Aug 11 16:13:04 2011
@@ -178,15 +178,19 @@ public class LifecycleCallbackRegistry {
if (reader != null) {
Set<Class<?>> types = new HashSet<Class<?>>();
- for (Class<?> type : reader.entities(a)) {
+
+ Class<?>[] entities = reader.entities(a);
+ Class<? extends Annotation>[] entityAnnotations =
+ reader.entityAnnotations(a);
+
+ for (Class<?> type : entities) {
// TODO: ignoring entity subclasses? whenever we add those,
// take
// into account "exlcudeSuperclassListeners" flag
types.add(type);
}
- for (Class<? extends Annotation> type : reader
- .entityAnnotations(a)) {
+ for (Class<? extends Annotation> type : entityAnnotations) {
types.addAll(getAnnotatedEntities(type));
}
@@ -196,6 +200,13 @@ public class LifecycleCallbackRegistry {
listener,
m);
}
+
+ // if no entities specified then adding global callback
+ if (entities.length == 0 && entityAnnotations.length == 0) {
+ eventCallbacks[reader.eventType().ordinal()].addDefaultListener(
+ listener,
+ m.getName());
+ }
}
}
}