cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r507579 - in /cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src: main/java/org/apache/cayenne/ main/java/org/apache/cayenne/access/ main/java/org/apache/cayenne/access/event/ main/java/org/apache/cayenne/intercept/ main/java/org/a...
Date Wed, 14 Feb 2007 15:33:40 GMT
Author: aadamchik
Date: Wed Feb 14 07:33:38 2007
New Revision: 507579

URL: http://svn.apache.org/viewvc?view=rev&rev=507579
Log:
CAY-753: Lifecycle Callback API Refactoring
first pass

Added:
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/LifecycleListener.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/AbstractCallback.java
      - copied, changed from r507031, cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/LifecycleEventCallback.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/LifecycleCallbackEventHandler.java
      - copied, changed from r507031, cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/LifecycleEventCallbackMap.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/LifecycleCallbackRegistry.java
Removed:
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/LifecycleEventCallback.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/LifecycleEventCallbackMap.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/map/MockLifecycleEventCallbackMap.java
Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/CayenneDataObject.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/DataObject.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/ClientServerChannel.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/DataContext.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/DataContextFlushEventHandler.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/event/DataContextEvent.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/event/DataContextTransactionEventListener.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/event/DataObjectTransactionEventListener.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/intercept/DataChannelCallbackInterceptor.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/intercept/ObjectContextCallbackInterceptor.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/intercept/SyncCallbackProcessor.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/CallbackDescriptor.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/CallbackMap.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/CallbackOnEntity.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/CallbackOnListener.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/EntityResolver.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextEventsTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextExtrasTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/intercept/DataChannelCallbackInterceptorTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/intercept/ObjectContextCallbackInterceptorTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/map/CallbackDescriptorTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/map/LifecycleEventCallbackMapTest.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/CayenneDataObject.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/CayenneDataObject.java?view=diff&rev=507579&r1=507578&r2=507579
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/CayenneDataObject.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/CayenneDataObject.java Wed Feb 14 07:33:38 2007
@@ -36,7 +36,6 @@
 import org.apache.cayenne.map.DbJoin;
 import org.apache.cayenne.map.DbRelationship;
 import org.apache.cayenne.map.EntityResolver;
-import org.apache.cayenne.map.LifecycleEventCallback;
 import org.apache.cayenne.map.ObjAttribute;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.ObjRelationship;
@@ -428,7 +427,7 @@
      * Default implementation does nothing.
      * 
      * @deprecated since 3.0 use callbacks.
-     * @see LifecycleEventCallback
+     * @see LifecycleListener
      */
     public void fetchFinished() {
     }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/DataObject.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/DataObject.java?view=diff&rev=507579&r1=507578&r2=507579
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/DataObject.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/DataObject.java Wed Feb 14 07:33:38 2007
@@ -20,7 +20,6 @@
 package org.apache.cayenne;
 
 import org.apache.cayenne.access.DataContext;
-import org.apache.cayenne.map.LifecycleEventCallback;
 
 /**
  * Defines basic methods for a persistent object in Cayenne.
@@ -153,7 +152,7 @@
     /**
      * @deprecated since 3.0 users must use callbacks instead. This method is no longer
      *             invoked by Cayenne runtime.
-     * @see LifecycleEventCallback
+     * @see LifecycleListener
      */
     public void fetchFinished();
 

Added: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/LifecycleListener.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/LifecycleListener.java?view=auto&rev=507579
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/LifecycleListener.java (added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/LifecycleListener.java Wed Feb 14 07:33:38 2007
@@ -0,0 +1,47 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne;
+
+import org.apache.cayenne.map.LifecycleCallbackRegistry;
+
+/**
+ * A callback interface to listen to persistent object lifecycle events. Note that
+ * listeners ARE NOT REQUIRED to implement this interface, and in fact both won't. It
+ * exists for type safety and for simplifying listener registration. See
+ * {@link LifecycleCallbackRegistry} for details on how to register callbacks.
+ * 
+ * @since 3.0
+ * @author Andrus Adamchik
+ */
+public interface LifecycleListener {
+
+    void prePersist(Object entity);
+
+    void postPersist(Object entity);
+
+    void preRemove(Object entity);
+
+    void postRemove(Object entity);
+
+    void preUpdate(Object entity);
+
+    void postUpdate(Object entity);
+
+    void postLoad(Object entity);
+}

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/ClientServerChannel.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/ClientServerChannel.java?view=diff&rev=507579&r1=507578&r2=507579
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/ClientServerChannel.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/ClientServerChannel.java Wed Feb 14 07:33:38 2007
@@ -27,7 +27,6 @@
 import org.apache.cayenne.graph.GraphDiff;
 import org.apache.cayenne.intercept.DataChannelCallbackInterceptor;
 import org.apache.cayenne.map.EntityResolver;
-import org.apache.cayenne.map.LifecycleEventCallback;
 import org.apache.cayenne.query.Query;
 
 /**
@@ -116,7 +115,6 @@
      * by this channel. Enabling callbacks allows server side logic to be applied to the
      * persistent objects during select and commit operations.
      * 
-     * @see LifecycleEventCallback
      * @since 3.0
      */
     public void setLifecycleCallbacksEnabled(boolean lifecycleCallbacksEnabled) {

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/DataContext.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/DataContext.java?view=diff&rev=507579&r1=507578&r2=507579
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/DataContext.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/DataContext.java Wed Feb 14 07:33:38 2007
@@ -39,6 +39,7 @@
 import org.apache.cayenne.DataRow;
 import org.apache.cayenne.DeleteDenyException;
 import org.apache.cayenne.Fault;
+import org.apache.cayenne.LifecycleListener;
 import org.apache.cayenne.ObjectContext;
 import org.apache.cayenne.ObjectId;
 import org.apache.cayenne.PersistenceState;
@@ -58,7 +59,6 @@
 import org.apache.cayenne.map.DbJoin;
 import org.apache.cayenne.map.DbRelationship;
 import org.apache.cayenne.map.EntityResolver;
-import org.apache.cayenne.map.LifecycleEventCallback;
 import org.apache.cayenne.map.ObjAttribute;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.ObjRelationship;
@@ -1388,7 +1388,7 @@
     /**
      * Sets default for posting transaction events by new DataContexts.
      * 
-     * @deprecated since 3.0M1 in favor of {@link LifecycleEventCallback}. Will be
+     * @deprecated since 3.0M1 in favor of {@link LifecycleListener}. Will be
      *             removed in later 3.0 milestones.
      */
     public static void setTransactionEventsEnabledDefault(boolean flag) {
@@ -1398,7 +1398,7 @@
     /**
      * Enables or disables posting of transaction events by this DataContext.
      * 
-     * @deprecated since 3.0M1 in favor of {@link LifecycleEventCallback}. Will be
+     * @deprecated since 3.0M1 in favor of {@link LifecycleListener}. Will be
      *             removed in later 3.0 milestones.
      */
     public void setTransactionEventsEnabled(boolean flag) {
@@ -1406,7 +1406,7 @@
     }
 
     /**
-     * @deprecated since 3.0M1 in favor of {@link LifecycleEventCallback}. Will be
+     * @deprecated since 3.0M1 in favor of {@link LifecycleListener}. Will be
      *             removed in later 3.0 milestones.
      */
     public boolean isTransactionEventsEnabled() {
@@ -1444,7 +1444,7 @@
     }
 
     /**
-     * @deprecated since 3.0M1 in favor of {@link LifecycleEventCallback}. Will be
+     * @deprecated since 3.0M1 in favor of {@link LifecycleListener}. Will be
      *             removed in later 3.0 milestones.
      */
     void fireWillCommit() {
@@ -1456,7 +1456,7 @@
     }
 
     /**
-     * @deprecated since 3.0M1 in favor of {@link LifecycleEventCallback}. Will be
+     * @deprecated since 3.0M1 in favor of {@link LifecycleListener}. Will be
      *             removed in later 3.0 milestones.
      */
     void fireTransactionRolledback() {
@@ -1468,7 +1468,7 @@
     }
 
     /**
-     * @deprecated since 3.0M1 in favor of {@link LifecycleEventCallback}. Will be
+     * @deprecated since 3.0M1 in favor of {@link LifecycleListener}. Will be
      *             removed in later 3.0 milestones.
      */
     void fireTransactionCommitted() {

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/DataContextFlushEventHandler.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/DataContextFlushEventHandler.java?view=diff&rev=507579&r1=507578&r2=507579
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/DataContextFlushEventHandler.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/DataContextFlushEventHandler.java Wed Feb 14 07:33:38 2007
@@ -23,20 +23,20 @@
 import java.util.Iterator;
 import java.util.List;
 
+import org.apache.cayenne.LifecycleListener;
 import org.apache.cayenne.PersistenceState;
 import org.apache.cayenne.Persistent;
 import org.apache.cayenne.access.event.DataContextEvent;
 import org.apache.cayenne.access.event.DataContextTransactionEventListener;
 import org.apache.cayenne.access.event.DataObjectTransactionEventListener;
 import org.apache.cayenne.event.EventManager;
-import org.apache.cayenne.map.LifecycleEventCallback;
 
 /**
  * Handles DataContext events on domain flush.
  * 
  * @since 1.2
  * @author Andrus Adamchik
- * @deprecated since 3.0M1 in favor of {@link LifecycleEventCallback}. Will be removed in
+ * @deprecated since 3.0M1 in favor of {@link LifecycleListener}. Will be removed in
  *             later 3.0 milestones.
  */
 class DataContextFlushEventHandler implements DataContextTransactionEventListener {

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/event/DataContextEvent.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/event/DataContextEvent.java?view=diff&rev=507579&r1=507578&r2=507579
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/event/DataContextEvent.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/event/DataContextEvent.java Wed Feb 14 07:33:38 2007
@@ -21,16 +21,16 @@
 
 import java.util.Map;
 
+import org.apache.cayenne.LifecycleListener;
 import org.apache.cayenne.access.DataContext;
 import org.apache.cayenne.event.CayenneEvent;
-import org.apache.cayenne.map.LifecycleEventCallback;
 
 /**
  * Represents events sent by DataContext.
  * 
  * @author Dirk Olmes
  * @author Holger Hoffstaette
- * @deprecated since 3.0M1 in favor of {@link LifecycleEventCallback}. Will be removed in
+ * @deprecated since 3.0M1 in favor of {@link LifecycleListener}. Will be removed in
  *             later 3.0 milestones.
  */
 public class DataContextEvent extends CayenneEvent {

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/event/DataContextTransactionEventListener.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/event/DataContextTransactionEventListener.java?view=diff&rev=507579&r1=507578&r2=507579
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/event/DataContextTransactionEventListener.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/event/DataContextTransactionEventListener.java Wed Feb 14 07:33:38 2007
@@ -20,13 +20,13 @@
 
 import java.util.EventListener;
 
-import org.apache.cayenne.map.LifecycleEventCallback;
+import org.apache.cayenne.LifecycleListener;
 
 /**
  * This interface declares callback methods that subscribers to DataContext events can
  * implement to be notified about transactions.
  * 
- * @deprecated since 3.0M1 in favor of {@link LifecycleEventCallback}. Will be removed in
+ * @deprecated since 3.0M1 in favor of {@link LifecycleListener}. Will be removed in
  *             later 3.0 milestones.
  */
 public interface DataContextTransactionEventListener extends EventListener {

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/event/DataObjectTransactionEventListener.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/event/DataObjectTransactionEventListener.java?view=diff&rev=507579&r1=507578&r2=507579
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/event/DataObjectTransactionEventListener.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/event/DataObjectTransactionEventListener.java Wed Feb 14 07:33:38 2007
@@ -20,7 +20,7 @@
 
 import java.util.EventListener;
 
-import org.apache.cayenne.map.LifecycleEventCallback;
+import org.apache.cayenne.LifecycleListener;
 
 /**
  * This interface declares methods that DataObject classes can implement to be notified
@@ -29,7 +29,7 @@
  * stricly speaking these methods are just regular 'callbacks'. The event argument is
  * passed along for convenience.
  * 
- * @deprecated since 3.0M1 in favor of {@link LifecycleEventCallback}. Will be removed in
+ * @deprecated since 3.0M1 in favor of {@link LifecycleListener}. Will be removed in
  *             later 3.0 milestones.
  */
 public interface DataObjectTransactionEventListener extends EventListener {

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/intercept/DataChannelCallbackInterceptor.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/intercept/DataChannelCallbackInterceptor.java?view=diff&rev=507579&r1=507578&r2=507579
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/intercept/DataChannelCallbackInterceptor.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/intercept/DataChannelCallbackInterceptor.java Wed Feb 14 07:33:38 2007
@@ -25,9 +25,8 @@
 import org.apache.cayenne.QueryResponse;
 import org.apache.cayenne.graph.GraphDiff;
 import org.apache.cayenne.graph.GraphManager;
-import org.apache.cayenne.map.EntityResolver;
-import org.apache.cayenne.map.LifecycleEventCallback;
-import org.apache.cayenne.map.LifecycleEventCallbackMap;
+import org.apache.cayenne.map.CallbackMap;
+import org.apache.cayenne.map.LifecycleCallbackRegistry;
 import org.apache.cayenne.query.Query;
 
 /**
@@ -47,53 +46,28 @@
  */
 public class DataChannelCallbackInterceptor extends DataChannelDecorator {
 
-    protected LifecycleEventCallbackMap preUpdate;
-    protected LifecycleEventCallbackMap postPersist;
-    protected LifecycleEventCallbackMap postRemove;
-    protected LifecycleEventCallbackMap postUpdate;
-    protected LifecycleEventCallbackMap postLoad;
-
+    protected LifecycleCallbackRegistry callbackRegistry;
     protected boolean contextCallbacksEnabled;
-    protected LifecycleEventCallbackMap preRemove;
-    protected LifecycleEventCallbackMap prePersist;
 
     public void setChannel(DataChannel channel) {
         this.channel = channel;
 
-        // init callback ivars for faster access...
-        if (channel != null) {
-            EntityResolver resolver = getEntityResolver();
-
-            preUpdate = resolver.getCallbacks(LifecycleEventCallback.PRE_UPDATE);
-            postPersist = resolver.getCallbacks(LifecycleEventCallback.POST_PERSIST);
-            postRemove = resolver.getCallbacks(LifecycleEventCallback.POST_REMOVE);
-            postUpdate = resolver.getCallbacks(LifecycleEventCallback.POST_UPDATE);
-            postLoad = resolver.getCallbacks(LifecycleEventCallback.POST_LOAD);
-            preRemove = resolver.getCallbacks(LifecycleEventCallback.PRE_REMOVE);
-            prePersist = resolver.getCallbacks(LifecycleEventCallback.PRE_PERSIST);
-        }
-        else {
-            preUpdate = null;
-            postPersist = null;
-            postRemove = null;
-            postUpdate = null;
-            postLoad = null;
-            preRemove = null;
-            prePersist = null;
-        }
+        callbackRegistry = (channel != null)
+                ? getEntityResolver().getCallbackRegistry()
+                : null;
     }
 
     protected boolean isEmpty() {
-        if (!(preUpdate.isEmpty()
-                && postPersist.isEmpty()
-                && postRemove.isEmpty()
-                && postUpdate.isEmpty() && postLoad.isEmpty())) {
+        if (!(callbackRegistry.isEmpty(CallbackMap.PRE_UPDATE)
+                && callbackRegistry.isEmpty(CallbackMap.POST_PERSIST)
+                && callbackRegistry.isEmpty(CallbackMap.POST_REMOVE)
+                && callbackRegistry.isEmpty(CallbackMap.POST_UPDATE) && callbackRegistry
+                .isEmpty(CallbackMap.POST_LOAD))) {
             return false;
         }
 
-        return contextCallbacksEnabled
-                ? preRemove.isEmpty() && prePersist.isEmpty()
-                : true;
+        return contextCallbacksEnabled ? callbackRegistry.isEmpty(CallbackMap.PRE_REMOVE)
+                && callbackRegistry.isEmpty(CallbackMap.PRE_PERSIST) : true;
     }
 
     public QueryResponse onQuery(ObjectContext originatingContext, Query query) {
@@ -102,14 +76,14 @@
         // TODO: andrus, 9/21/2006 - this method incorrectly calls "postLoad" when query
         // refresh flag is set to false and object is already there.
 
-        if (!postLoad.isEmpty()) {
+        if (!callbackRegistry.isEmpty(CallbackMap.POST_LOAD)) {
 
             List list = response.firstList();
             if (list != null
                     && !list.isEmpty()
                     && !(query.getMetaData(originatingContext.getEntityResolver()))
                             .isFetchingDataRows()) {
-                postLoad.performCallbacks(list);
+                callbackRegistry.performCallbacks(CallbackMap.POST_LOAD, list);
             }
         }
 
@@ -139,26 +113,6 @@
         return new SyncCallbackProcessor(this, graphManager, changes);
     }
 
-    public LifecycleEventCallbackMap getPostLoad() {
-        return postLoad;
-    }
-
-    public LifecycleEventCallbackMap getPostPersist() {
-        return postPersist;
-    }
-
-    public LifecycleEventCallbackMap getPostRemove() {
-        return postRemove;
-    }
-
-    public LifecycleEventCallbackMap getPostUpdate() {
-        return postUpdate;
-    }
-
-    public LifecycleEventCallbackMap getPreUpdate() {
-        return preUpdate;
-    }
-
     /**
      * Returns whether "PrePersist" and "PreRemove" callbacks should be executed during
      * sync. By default this is false, as they are executed by the parent ObjectContext.
@@ -172,13 +126,7 @@
         this.contextCallbacksEnabled = contextCallbacksEnabled;
     }
 
-    
-    public LifecycleEventCallbackMap getPrePersist() {
-        return prePersist;
-    }
-
-    
-    public LifecycleEventCallbackMap getPreRemove() {
-        return preRemove;
+    public LifecycleCallbackRegistry getCallbackRegistry() {
+        return callbackRegistry;
     }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/intercept/ObjectContextCallbackInterceptor.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/intercept/ObjectContextCallbackInterceptor.java?view=diff&rev=507579&r1=507578&r2=507579
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/intercept/ObjectContextCallbackInterceptor.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/intercept/ObjectContextCallbackInterceptor.java Wed Feb 14 07:33:38 2007
@@ -25,10 +25,9 @@
 import org.apache.cayenne.ObjectContext;
 import org.apache.cayenne.PersistenceState;
 import org.apache.cayenne.Persistent;
+import org.apache.cayenne.map.CallbackMap;
 import org.apache.cayenne.map.DeleteRule;
-import org.apache.cayenne.map.EntityResolver;
-import org.apache.cayenne.map.LifecycleEventCallback;
-import org.apache.cayenne.map.LifecycleEventCallbackMap;
+import org.apache.cayenne.map.LifecycleCallbackRegistry;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.ObjRelationship;
 import org.apache.cayenne.reflect.ClassDescriptor;
@@ -46,23 +45,14 @@
  */
 public class ObjectContextCallbackInterceptor extends ObjectContextDecorator {
 
-    protected LifecycleEventCallbackMap prePersist;
-    protected LifecycleEventCallbackMap preRemove;
+    protected LifecycleCallbackRegistry callbackRegistry;
 
     public void setContext(ObjectContext context) {
         super.setContext(context);
 
-        // init callback ivars for faster access...
-        if (context != null) {
-            EntityResolver resolver = context.getEntityResolver();
-
-            prePersist = resolver.getCallbacks(LifecycleEventCallback.PRE_PERSIST);
-            preRemove = resolver.getCallbacks(LifecycleEventCallback.PRE_REMOVE);
-        }
-        else {
-            prePersist = null;
-            preRemove = null;
-        }
+        callbackRegistry = (context != null) ? context
+                .getEntityResolver()
+                .getCallbackRegistry() : null;
     }
 
     /**
@@ -70,9 +60,7 @@
      */
     public Persistent newObject(Class persistentClass) {
         Persistent object = super.newObject(persistentClass);
-
-        prePersist.performCallbacks(object);
-
+        callbackRegistry.performCallbacks(CallbackMap.PRE_PERSIST, object);
         return object;
     }
 
@@ -81,7 +69,7 @@
      */
     public void registerNewObject(Object object) {
         super.registerNewObject(object);
-        prePersist.performCallbacks(object);
+        callbackRegistry.performCallbacks(CallbackMap.PRE_PERSIST, object);
     }
 
     /**
@@ -100,7 +88,7 @@
     void applyPreRemoveCallbacks(Persistent object) {
 
         if (object.getPersistenceState() != PersistenceState.NEW) {
-            preRemove.performCallbacks(object);
+            callbackRegistry.performCallbacks(CallbackMap.PRE_REMOVE, object);
         }
 
         ObjEntity entity = getEntityResolver().lookupObjEntity(object);

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/intercept/SyncCallbackProcessor.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/intercept/SyncCallbackProcessor.java?view=diff&rev=507579&r1=507578&r2=507579
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/intercept/SyncCallbackProcessor.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/intercept/SyncCallbackProcessor.java Wed Feb 14 07:33:38 2007
@@ -27,7 +27,7 @@
 import org.apache.cayenne.graph.GraphChangeHandler;
 import org.apache.cayenne.graph.GraphDiff;
 import org.apache.cayenne.graph.GraphManager;
-import org.apache.cayenne.map.LifecycleEventCallbackMap;
+import org.apache.cayenne.map.CallbackMap;
 
 class SyncCallbackProcessor implements GraphChangeHandler {
 
@@ -50,11 +50,11 @@
         switch (syncType) {
             case DataChannel.FLUSH_CASCADE_SYNC:
             case DataChannel.FLUSH_NOCASCADE_SYNC:
-                apply(interceptor.getPreUpdate(), updated);
+                apply(CallbackMap.PRE_UPDATE, updated);
 
                 if (interceptor.isContextCallbacksEnabled()) {
-                    apply(interceptor.getPrePersist(), persisted);
-                    apply(interceptor.getPreRemove(), removed);
+                    apply(CallbackMap.PRE_PERSIST, persisted);
+                    apply(CallbackMap.PRE_REMOVE, removed);
                 }
         }
     }
@@ -63,19 +63,19 @@
         switch (syncType) {
             case DataChannel.FLUSH_CASCADE_SYNC:
             case DataChannel.FLUSH_NOCASCADE_SYNC:
-                apply(interceptor.getPostUpdate(), updated);
-                apply(interceptor.getPostRemove(), removed);
-                apply(interceptor.getPostPersist(), persisted);
+                apply(CallbackMap.POST_UPDATE, updated);
+                apply(CallbackMap.POST_REMOVE, removed);
+                apply(CallbackMap.POST_PERSIST, persisted);
                 break;
             case DataChannel.ROLLBACK_CASCADE_SYNC:
-                apply(interceptor.getPostLoad(), updated);
-                apply(interceptor.getPostLoad(), removed);
+                apply(CallbackMap.POST_LOAD, updated);
+                apply(CallbackMap.POST_LOAD, removed);
         }
     }
 
-    void apply(LifecycleEventCallbackMap callbacks, Collection objects) {
-        if (objects != null && !callbacks.isEmpty()) {
-            callbacks.performCallbacks(objects);
+    void apply(int callbackType, Collection objects) {
+        if (objects != null) {
+            interceptor.getCallbackRegistry().performCallbacks(callbackType, objects);
         }
     }
 

Copied: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/AbstractCallback.java (from r507031, cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/LifecycleEventCallback.java)
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/AbstractCallback.java?view=diff&rev=507579&p1=cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/LifecycleEventCallback.java&r1=507031&p2=cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/AbstractCallback.java&r2=507579
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/LifecycleEventCallback.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/AbstractCallback.java Wed Feb 14 07:33:38 2007
@@ -22,19 +22,9 @@
  * Defines a callback operation.
  * 
  * @author Andrus Adamchik
+ * @since 3.0
  */
-public interface LifecycleEventCallback {
+abstract class AbstractCallback {
 
-    // these int constants correspond to indexes in array in EntityResolver, so they must
-    // start with 0 and increment by 1.
-
-    public static final int PRE_PERSIST = 0;
-    public static final int PRE_REMOVE = 1;
-    public static final int PRE_UPDATE = 2;
-    public static final int POST_PERSIST = 3;
-    public static final int POST_REMOVE = 4;
-    public static final int POST_UPDATE = 5;
-    public static final int POST_LOAD = 6;
-
-    void performCallback(Object entity);
+    abstract void performCallback(Object entity);
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/CallbackDescriptor.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/CallbackDescriptor.java?view=diff&rev=507579&r1=507578&r2=507579
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/CallbackDescriptor.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/CallbackDescriptor.java Wed Feb 14 07:33:38 2007
@@ -32,6 +32,8 @@
  * @author Andrus Adamchik
  */
 public class CallbackDescriptor implements Serializable {
+    
+   
 
     protected int callbackType;
     protected Set callbackMethods;

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/CallbackMap.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/CallbackMap.java?view=diff&rev=507579&r1=507578&r2=507579
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/CallbackMap.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/CallbackMap.java Wed Feb 14 07:33:38 2007
@@ -28,15 +28,25 @@
  */
 public class CallbackMap implements Serializable {
 
+    // these int constants correspond to indexes in array in LifecycleCallbackRegistry, so
+    // they must start with 0 and increment by 1.
+
+    public static final int PRE_PERSIST = 0;
+    public static final int PRE_REMOVE = 1;
+    public static final int PRE_UPDATE = 2;
+    public static final int POST_PERSIST = 3;
+    public static final int POST_REMOVE = 4;
+    public static final int POST_UPDATE = 5;
+    public static final int POST_LOAD = 6;
+
     /**
      * An array containing all valid callbacks with each callback int value corresponding
      * to its index in the array.
      */
     public static final int[] CALLBACKS = new int[] {
-            LifecycleEventCallback.PRE_PERSIST, LifecycleEventCallback.PRE_REMOVE,
-            LifecycleEventCallback.PRE_UPDATE, LifecycleEventCallback.POST_PERSIST,
-            LifecycleEventCallback.POST_REMOVE, LifecycleEventCallback.POST_UPDATE,
-            LifecycleEventCallback.POST_LOAD
+            CallbackMap.PRE_PERSIST, CallbackMap.PRE_REMOVE, CallbackMap.PRE_UPDATE,
+            CallbackMap.POST_PERSIST, CallbackMap.POST_REMOVE, CallbackMap.POST_UPDATE,
+            CallbackMap.POST_LOAD
     };
 
     protected CallbackDescriptor prePersist;
@@ -48,13 +58,13 @@
     protected CallbackDescriptor postLoad;
 
     public CallbackMap() {
-        this.prePersist = new CallbackDescriptor(LifecycleEventCallback.PRE_PERSIST);
-        this.postPersist = new CallbackDescriptor(LifecycleEventCallback.POST_PERSIST);
-        this.preUpdate = new CallbackDescriptor(LifecycleEventCallback.PRE_UPDATE);
-        this.postUpdate = new CallbackDescriptor(LifecycleEventCallback.POST_UPDATE);
-        this.preRemove = new CallbackDescriptor(LifecycleEventCallback.PRE_REMOVE);
-        this.postRemove = new CallbackDescriptor(LifecycleEventCallback.POST_REMOVE);
-        this.postLoad = new CallbackDescriptor(LifecycleEventCallback.POST_LOAD);
+        this.prePersist = new CallbackDescriptor(CallbackMap.PRE_PERSIST);
+        this.postPersist = new CallbackDescriptor(CallbackMap.POST_PERSIST);
+        this.preUpdate = new CallbackDescriptor(CallbackMap.PRE_UPDATE);
+        this.postUpdate = new CallbackDescriptor(CallbackMap.POST_UPDATE);
+        this.preRemove = new CallbackDescriptor(CallbackMap.PRE_REMOVE);
+        this.postRemove = new CallbackDescriptor(CallbackMap.POST_REMOVE);
+        this.postLoad = new CallbackDescriptor(CallbackMap.POST_LOAD);
     }
 
     /**

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/CallbackOnEntity.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/CallbackOnEntity.java?view=diff&rev=507579&r1=507578&r2=507579
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/CallbackOnEntity.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/CallbackOnEntity.java Wed Feb 14 07:33:38 2007
@@ -32,7 +32,7 @@
  * @since 3.0
  * @author Andrus Adamchik
  */
-class CallbackOnEntity implements LifecycleEventCallback {
+class CallbackOnEntity extends AbstractCallback {
 
     private Method callbackMethod;
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/CallbackOnListener.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/CallbackOnListener.java?view=diff&rev=507579&r1=507578&r2=507579
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/CallbackOnListener.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/CallbackOnListener.java Wed Feb 14 07:33:38 2007
@@ -32,7 +32,7 @@
  * @since 3.0
  * @author Andrus Adamchik
  */
-class CallbackOnListener implements LifecycleEventCallback {
+class CallbackOnListener extends AbstractCallback {
 
     private Method callbackMethod;
     private Object listener;

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/EntityResolver.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/EntityResolver.java?view=diff&rev=507579&r1=507578&r2=507579
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/EntityResolver.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/EntityResolver.java Wed Feb 14 07:33:38 2007
@@ -72,7 +72,7 @@
     protected transient ClassDescriptorMap classDescriptorMap;
 
     // callbacks are not serializable
-    protected transient LifecycleEventCallbackMap[] lifecycleEventCallbacks;
+    protected transient LifecycleCallbackRegistry callbackRegistry;
 
     /**
      * Creates new EntityResolver.
@@ -98,22 +98,13 @@
         this.constructCache();
     }
 
+    /**
+     * Compiles internal callback registry.
+     */
     synchronized void initCallbacks() {
-        if (lifecycleEventCallbacks == null) {
-            LifecycleEventCallbackMap[] lifecycleEventCallbacks = new LifecycleEventCallbackMap[7];
-
-            for (int i = 0; i < lifecycleEventCallbacks.length; i++) {
-                lifecycleEventCallbacks[i] = new LifecycleEventCallbackMap() {
-
-                    protected boolean isExcludingDefaultListeners(Class objectClass) {
-                        return excludingDefaultListeners(objectClass);
-                    }
-
-                    protected boolean isExcludingSuperclassListeners(Class objectClass) {
-                        return excludingSuperclassListeners(objectClass);
-                    }
-                };
-            }
+        if (callbackRegistry == null) {
+            LifecycleCallbackRegistry callbackRegistry = new LifecycleCallbackRegistry(
+                    this);
 
             // load default callbacks
             Iterator maps = this.maps.iterator();
@@ -136,7 +127,8 @@
                             String method = (String) callbackMethods.next();
 
                             // note that callbacks[i].getCallbackType() == i
-                            lifecycleEventCallbacks[i].addDefaultListener(
+                            callbackRegistry.addDefaultListener(
+                                    i,
                                     listenerInstance,
                                     method);
                         }
@@ -168,7 +160,8 @@
                             String method = (String) callbackMethods.next();
 
                             // note that callbacks[i].getCallbackType() == i
-                            lifecycleEventCallbacks[i].addListener(
+                            callbackRegistry.addListener(
+                                    i,
                                     entityClass,
                                     listenerInstance,
                                     method);
@@ -185,12 +178,12 @@
                         String method = (String) callbackMethods.next();
 
                         // note that callbacks[i].getCallbackType() == i
-                        lifecycleEventCallbacks[i].addListener(entityClass, method);
+                        callbackRegistry.addListener(i, entityClass, method);
                     }
                 }
             }
 
-            this.lifecycleEventCallbacks = lifecycleEventCallbacks;
+            this.callbackRegistry = callbackRegistry;
         }
     }
 
@@ -219,34 +212,17 @@
     }
 
     /**
-     * @since 3.0
-     */
-    boolean excludingDefaultListeners(Class objectClass) {
-        ObjEntity entity = lookupObjEntity(objectClass);
-        return entity != null && entity.isExcludingDefaultListeners();
-    }
-
-    /**
-     * @since 3.0
-     */
-    boolean excludingSuperclassListeners(Class objectClass) {
-        ObjEntity entity = lookupObjEntity(objectClass);
-        return entity != null && entity.isExcludingSuperclassListeners();
-    }
-
-    /**
-     * Returns a {@link LifecycleEventCallbackMap} for a given type of lifecycle events.
-     * Event types are defined as constants in LifecycleEventCallback interface. E.g.
-     * {@link LifecycleEventCallback#PRE_PERSIST}, etc.
+     * Returns a {@link LifecycleCallbackRegistry} for handling callbacks. Registry is
+     * lazily initialized on first call.
      * 
      * @since 3.0
      */
-    public LifecycleEventCallbackMap getCallbacks(int callbackType) {
-        if (lifecycleEventCallbacks == null) {
+    public LifecycleCallbackRegistry getCallbackRegistry() {
+        if (callbackRegistry == null) {
             initCallbacks();
         }
 
-        return lifecycleEventCallbacks[callbackType];
+        return callbackRegistry;
     }
 
     /**

Copied: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/LifecycleCallbackEventHandler.java (from r507031, cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/LifecycleEventCallbackMap.java)
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/LifecycleCallbackEventHandler.java?view=diff&rev=507579&p1=cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/LifecycleEventCallbackMap.java&r1=507031&p2=cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/LifecycleCallbackEventHandler.java&r2=507579
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/LifecycleEventCallbackMap.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/LifecycleCallbackEventHandler.java Wed Feb 14 07:33:38 2007
@@ -25,44 +25,50 @@
 import java.util.Map;
 
 /**
- * A runtime callback processor for a single lifecycle event.
+ * A runtime callback processor for a single kind of lifecycle events.
  * 
  * @since 3.0
  * @author Andrus Adamchik
  */
-public abstract class LifecycleEventCallbackMap {
+class LifecycleCallbackEventHandler {
 
-    protected Map listeners;
-    protected Collection defaultListeners;
+    private EntityResolver resolver;
+    private Map listeners;
+    private Collection defaultListeners;
 
-    public LifecycleEventCallbackMap() {
-        listeners = new HashMap();
-        defaultListeners = new ArrayList();
+    LifecycleCallbackEventHandler(EntityResolver resolver) {
+        this.resolver = resolver;
+        this.listeners = new HashMap();
+        this.defaultListeners = new ArrayList();
     }
 
-    protected abstract boolean isExcludingDefaultListeners(Class objectClass);
+    private boolean excludingDefaultListeners(Class objectClass) {
+        ObjEntity entity = resolver.lookupObjEntity(objectClass);
+        return entity != null && entity.isExcludingDefaultListeners();
+    }
 
-    protected abstract boolean isExcludingSuperclassListeners(Class objectClass);
+    private boolean excludingSuperclassListeners(Class objectClass) {
+        ObjEntity entity = resolver.lookupObjEntity(objectClass);
+        return entity != null && entity.isExcludingSuperclassListeners();
+    }
 
-    /**
-     * Removes all listeners.
-     */
-    public void removeAll() {
-        listeners.clear();
+    boolean isEmpty() {
+        return listeners.isEmpty() && defaultListeners.isEmpty();
     }
 
     /**
-     * Returns true if no listeners are regsitered with this callback for any entity.
+     * Removes all listeners.
      */
-    public boolean isEmpty() {
-        return listeners.isEmpty();
+    void clear() {
+        listeners.clear();
+        defaultListeners.clear();
     }
 
     /**
      * Registers a callback method to be invoked on a provided non-entity object when a
      * lifecycle event occurs on any entity that does not suppress default callbacks.
      */
-    public void addDefaultListener(Object listener, String methodName) {
+    void addDefaultListener(Object listener, String methodName) {
         CallbackOnListener callback = new CallbackOnListener(listener, methodName);
         addDefaultCallback(callback);
     }
@@ -70,7 +76,7 @@
     /**
      * Registers a callback object to be invoked when a lifecycle event occurs.
      */
-    public void addDefaultCallback(LifecycleEventCallback callback) {
+    private void addDefaultCallback(AbstractCallback callback) {
         defaultListeners.add(callback);
     }
 
@@ -78,7 +84,7 @@
      * Registers a callback method to be invoked on an entity class instances when a
      * lifecycle event occurs.
      */
-    public void addListener(Class entityClass, String methodName) {
+    void addListener(Class entityClass, String methodName) {
         addCallback(entityClass, new CallbackOnEntity(entityClass, methodName));
     }
 
@@ -86,7 +92,7 @@
      * Registers callback method to be invoked on a provided non-entity object when a
      * lifecycle event occurs.
      */
-    public void addListener(Class entityClass, Object listener, String methodName) {
+    void addListener(Class entityClass, Object listener, String methodName) {
         CallbackOnListener callback = new CallbackOnListener(
                 listener,
                 methodName,
@@ -97,7 +103,7 @@
     /**
      * Registers a callback object to be invoked when a lifecycle event occurs.
      */
-    public void addCallback(Class entityClass, LifecycleEventCallback callback) {
+    private void addCallback(Class entityClass, AbstractCallback callback) {
         Collection entityListeners = (Collection) listeners.get(entityClass.getName());
 
         if (entityListeners == null) {
@@ -111,14 +117,13 @@
     /**
      * Invokes callbacks for a given entity object.
      */
-    public void performCallbacks(Object object) {
+    void performCallbacks(Object object) {
 
         // default listeners are invoked first
-        if (!defaultListeners.isEmpty()
-                && !isExcludingDefaultListeners(object.getClass())) {
+        if (!defaultListeners.isEmpty() && !excludingDefaultListeners(object.getClass())) {
             Iterator it = (Iterator) defaultListeners.iterator();
             while (it.hasNext()) {
-                ((LifecycleEventCallback) it.next()).performCallback(object);
+                ((AbstractCallback) it.next()).performCallback(object);
             }
         }
 
@@ -127,16 +132,27 @@
     }
 
     /**
+     * Invokes callbacks for a collection of entity objects.
+     */
+    void performCallbacks(Collection objects) {
+        Iterator it = objects.iterator();
+        while (it.hasNext()) {
+            Object object = it.next();
+            performCallbacks(object);
+        }
+    }
+
+    /**
      * Invokes callbacks for the class hierarchy, starting from the most generic
      * superclass.
      */
-    protected void performCallbacks(Object object, Class callbackEntityClass) {
+    private void performCallbacks(Object object, Class callbackEntityClass) {
         if (Object.class.equals(callbackEntityClass) || callbackEntityClass == null) {
             return;
         }
 
         // recursively perform super callbacks first
-        if (!isExcludingSuperclassListeners(callbackEntityClass)) {
+        if (!excludingSuperclassListeners(callbackEntityClass)) {
             performCallbacks(object, callbackEntityClass.getSuperclass());
         }
 
@@ -147,19 +163,9 @@
         if (entityListeners != null) {
             Iterator it = (Iterator) entityListeners.iterator();
             while (it.hasNext()) {
-                ((LifecycleEventCallback) it.next()).performCallback(object);
+                ((AbstractCallback) it.next()).performCallback(object);
             }
         }
     }
 
-    /**
-     * Invokes callbacks for a collection of entity objects.
-     */
-    public void performCallbacks(Collection objects) {
-        Iterator it = objects.iterator();
-        while (it.hasNext()) {
-            Object object = it.next();
-            performCallbacks(object);
-        }
-    }
 }

Added: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/LifecycleCallbackRegistry.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/LifecycleCallbackRegistry.java?view=auto&rev=507579
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/LifecycleCallbackRegistry.java (added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/LifecycleCallbackRegistry.java Wed Feb 14 07:33:38 2007
@@ -0,0 +1,139 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.map;
+
+import java.util.Collection;
+
+import org.apache.cayenne.LifecycleListener;
+
+/**
+ * A registry of lifecycle callbacks for all callback event types.
+ * 
+ * @since 3.0
+ * @author Andrus Adamchik
+ */
+public class LifecycleCallbackRegistry {
+
+    protected LifecycleCallbackEventHandler[] eventCallbacks;
+
+    /**
+     * Creates an empty callback registry.
+     */
+    public LifecycleCallbackRegistry(EntityResolver resolver) {
+        eventCallbacks = new LifecycleCallbackEventHandler[CallbackMap.CALLBACKS.length];
+        for (int i = 0; i < eventCallbacks.length; i++) {
+            eventCallbacks[i] = new LifecycleCallbackEventHandler(resolver);
+        }
+    }
+
+    /**
+     * Removes all listeners for all event types.
+     */
+    public void clear() {
+        for (int i = 0; i < eventCallbacks.length; i++) {
+            eventCallbacks[i].clear();
+        }
+    }
+
+    /**
+     * Removes listeners for a single event type.
+     */
+    public void clear(int type) {
+        eventCallbacks[type].clear();
+    }
+
+    /**
+     * Returns true if there are no listeners for a specific event type.
+     */
+    public boolean isEmpty(int type) {
+        return eventCallbacks[type].isEmpty();
+    }
+
+    /**
+     * Registers a {@link LifecycleListener} for all events on all entities. Note that
+     * listeners are not required to implement {@link LifecycleListener} interface. Other
+     * methods in this class can be used to register arbitrary listeners.
+     */
+    public void addDefaultListener(LifecycleListener listener) {
+        addDefaultListener(CallbackMap.PRE_PERSIST, listener, "prePersist");
+        addDefaultListener(CallbackMap.POST_PERSIST, listener, "postPersist");
+        addDefaultListener(CallbackMap.PRE_REMOVE, listener, "preRemove");
+        addDefaultListener(CallbackMap.POST_REMOVE, listener, "postRemove");
+        addDefaultListener(CallbackMap.PRE_UPDATE, listener, "preUpdate");
+        addDefaultListener(CallbackMap.POST_UPDATE, listener, "postUpdate");
+        addDefaultListener(CallbackMap.POST_LOAD, listener, "postLoad");
+    }
+
+    /**
+     * Registers a callback method to be invoked on a provided non-entity object when a
+     * lifecycle event occurs on any entity that does not suppress default callbacks.
+     */
+    public void addDefaultListener(int type, Object listener, String methodName) {
+        eventCallbacks[type].addDefaultListener(listener, methodName);
+    }
+
+    /**
+     * Registers a {@link LifecycleListener} for all events on all entities. Note that
+     * listeners are not required to implement {@link LifecycleListener} interface. Other
+     * methods in this class can be used to register arbitrary listeners.
+     */
+    public void addListener(Class entityClass, LifecycleListener listener) {
+        addListener(CallbackMap.PRE_PERSIST, entityClass, listener, "prePersist");
+        addListener(CallbackMap.POST_PERSIST, entityClass, listener, "postPersist");
+        addListener(CallbackMap.PRE_REMOVE, entityClass, listener, "preRemove");
+        addListener(CallbackMap.POST_REMOVE, entityClass, listener, "postRemove");
+        addListener(CallbackMap.PRE_UPDATE, entityClass, listener, "preUpdate");
+        addListener(CallbackMap.POST_UPDATE, entityClass, listener, "postUpdate");
+        addListener(CallbackMap.POST_LOAD, entityClass, listener, "postLoad");
+    }
+
+    /**
+     * Registers callback method to be invoked on a provided non-entity object when a
+     * lifecycle event occurs for a specific entity.
+     */
+    public void addListener(
+            int type,
+            Class entityClass,
+            Object listener,
+            String methodName) {
+        eventCallbacks[type].addListener(entityClass, listener, methodName);
+    }
+
+    /**
+     * Registers a callback method to be invoked on an entity class instances when a
+     * lifecycle event occurs.
+     */
+    public void addListener(int type, Class entityClass, String methodName) {
+        eventCallbacks[type].addListener(entityClass, methodName);
+    }
+
+    /**
+     * Invokes callbacks of a specific type for a given entity object.
+     */
+    public void performCallbacks(int type, Object object) {
+        eventCallbacks[type].performCallbacks(object);
+    }
+
+    /**
+     * Invokes callbacks of a specific type for a collection of entity objects.
+     */
+    public void performCallbacks(int type, Collection objects) {
+        eventCallbacks[type].performCallbacks(objects);
+    }
+}

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextEventsTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextEventsTest.java?view=diff&rev=507579&r1=507578&r2=507579
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextEventsTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextEventsTest.java Wed Feb 14 07:33:38 2007
@@ -23,14 +23,14 @@
 
 import org.apache.art.oneway.Artist;
 import org.apache.cayenne.CayenneRuntimeException;
+import org.apache.cayenne.LifecycleListener;
 import org.apache.cayenne.dba.mysql.MySQLAdapter;
-import org.apache.cayenne.map.LifecycleEventCallback;
 import org.apache.cayenne.unit.OneWayMappingCase;
 
 /**
  * @author Holger Hoffstaette
  * @author Andrus Adamchik
- * @deprecated since 3.0M1 in favor of {@link LifecycleEventCallback}. Will be removed in
+ * @deprecated since 3.0M1 in favor of {@link LifecycleListener}. Will be removed in
  *             later 3.0 milestones.
  */
 public class DataContextEventsTest extends OneWayMappingCase {

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextExtrasTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextExtrasTest.java?view=diff&rev=507579&r1=507578&r2=507579
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextExtrasTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextExtrasTest.java Wed Feb 14 07:33:38 2007
@@ -30,6 +30,7 @@
 import org.apache.cayenne.DataObject;
 import org.apache.cayenne.DataObjectUtils;
 import org.apache.cayenne.DataRow;
+import org.apache.cayenne.LifecycleListener;
 import org.apache.cayenne.ObjectId;
 import org.apache.cayenne.PersistenceState;
 import org.apache.cayenne.Persistent;
@@ -37,7 +38,6 @@
 import org.apache.cayenne.dba.JdbcPkGenerator;
 import org.apache.cayenne.dba.PkGenerator;
 import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.map.LifecycleEventCallback;
 import org.apache.cayenne.query.SQLTemplate;
 import org.apache.cayenne.query.SelectQuery;
 import org.apache.cayenne.unit.CayenneCase;
@@ -122,7 +122,7 @@
     }
 
     /**
-     * @deprecated since 3.0M1 in favor of {@link LifecycleEventCallback}. Will be
+     * @deprecated since 3.0M1 in favor of {@link LifecycleListener}. Will be
      *             removed in later 3.0 milestones.
      */
     public void testTransactionEventsEnabled() {

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/intercept/DataChannelCallbackInterceptorTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/intercept/DataChannelCallbackInterceptorTest.java?view=diff&rev=507579&r1=507578&r2=507579
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/intercept/DataChannelCallbackInterceptorTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/intercept/DataChannelCallbackInterceptorTest.java Wed Feb 14 07:33:38 2007
@@ -22,9 +22,9 @@
 import org.apache.cayenne.ObjectContext;
 import org.apache.cayenne.access.DataContext;
 import org.apache.cayenne.access.ObjectStore;
+import org.apache.cayenne.map.CallbackMap;
 import org.apache.cayenne.map.EntityResolver;
-import org.apache.cayenne.map.LifecycleEventCallback;
-import org.apache.cayenne.map.LifecycleEventCallbackMap;
+import org.apache.cayenne.map.LifecycleCallbackRegistry;
 import org.apache.cayenne.query.RefreshQuery;
 import org.apache.cayenne.query.SelectQuery;
 import org.apache.cayenne.unit.CayenneCase;
@@ -37,20 +37,13 @@
 
     protected void tearDown() throws Exception {
         EntityResolver resolver = getDomain().getEntityResolver();
-
-        resolver.getCallbacks(LifecycleEventCallback.POST_LOAD).removeAll();
-        resolver.getCallbacks(LifecycleEventCallback.POST_PERSIST).removeAll();
-        resolver.getCallbacks(LifecycleEventCallback.POST_REMOVE).removeAll();
-        resolver.getCallbacks(LifecycleEventCallback.POST_UPDATE).removeAll();
-        resolver.getCallbacks(LifecycleEventCallback.PRE_PERSIST).removeAll();
-        resolver.getCallbacks(LifecycleEventCallback.PRE_REMOVE).removeAll();
-        resolver.getCallbacks(LifecycleEventCallback.PRE_UPDATE).removeAll();
+        resolver.getCallbackRegistry().clear();
     }
 
     public void testPostLoad() throws Exception {
-        LifecycleEventCallbackMap postLoad = getDomain()
+        LifecycleCallbackRegistry registry = getDomain()
                 .getEntityResolver()
-                .getCallbacks(LifecycleEventCallback.POST_LOAD);
+                .getCallbackRegistry();
 
         DataChannelCallbackInterceptor i = new DataChannelCallbackInterceptor();
         i.setChannel(getDomain());
@@ -58,9 +51,13 @@
         ObjectContext context = new DataContext(i, new ObjectStore(getDomain()
                 .getSharedSnapshotCache()));
 
-        postLoad.addListener(Artist.class, "postLoadCallback");
+        registry.addListener(CallbackMap.POST_LOAD, Artist.class, "postLoadCallback");
         MockCallingBackListener listener = new MockCallingBackListener();
-        postLoad.addListener(Artist.class, listener, "publicCallback");
+        registry.addListener(
+                CallbackMap.POST_LOAD,
+                Artist.class,
+                listener,
+                "publicCallback");
 
         Artist a1 = (Artist) context.newObject(Artist.class);
         a1.setArtistName("XX");
@@ -116,9 +113,9 @@
 
     public void testPreUpdate() {
 
-        LifecycleEventCallbackMap preUpdate = getDomain()
+        LifecycleCallbackRegistry registry = getDomain()
                 .getEntityResolver()
-                .getCallbacks(LifecycleEventCallback.PRE_UPDATE);
+                .getCallbackRegistry();
 
         DataChannelCallbackInterceptor i = new DataChannelCallbackInterceptor();
         i.setChannel(getDomain());
@@ -135,7 +132,7 @@
         context.commitChanges();
         assertFalse(a1.isPreUpdated());
 
-        preUpdate.addListener(Artist.class, "preUpdateCallback");
+        registry.addListener(CallbackMap.PRE_UPDATE, Artist.class, "preUpdateCallback");
         a1.setArtistName("ZZ");
         context.commitChanges();
         assertTrue(a1.isPreUpdated());
@@ -144,7 +141,11 @@
         assertFalse(a1.isPreUpdated());
 
         MockCallingBackListener listener2 = new MockCallingBackListener();
-        preUpdate.addListener(Artist.class, listener2, "publicCallback");
+        registry.addListener(
+                CallbackMap.PRE_UPDATE,
+                Artist.class,
+                listener2,
+                "publicCallback");
 
         a1.setArtistName("AA");
         context.commitChanges();
@@ -155,9 +156,9 @@
 
     public void testPostUpdate() {
 
-        LifecycleEventCallbackMap postUpdate = getDomain()
+        LifecycleCallbackRegistry registry = getDomain()
                 .getEntityResolver()
-                .getCallbacks(LifecycleEventCallback.POST_UPDATE);
+                .getCallbackRegistry();
 
         DataChannelCallbackInterceptor i = new DataChannelCallbackInterceptor();
         i.setChannel(getDomain());
@@ -174,7 +175,7 @@
         context.commitChanges();
         assertFalse(a1.isPostUpdated());
 
-        postUpdate.addListener(Artist.class, "postUpdateCallback");
+        registry.addListener(CallbackMap.POST_UPDATE, Artist.class, "postUpdateCallback");
         a1.setArtistName("ZZ");
         context.commitChanges();
         assertTrue(a1.isPostUpdated());
@@ -183,7 +184,11 @@
         assertFalse(a1.isPostUpdated());
 
         MockCallingBackListener listener2 = new MockCallingBackListener();
-        postUpdate.addListener(Artist.class, listener2, "publicCallback");
+        registry.addListener(
+                CallbackMap.POST_UPDATE,
+                Artist.class,
+                listener2,
+                "publicCallback");
 
         a1.setArtistName("AA");
         context.commitChanges();
@@ -194,9 +199,9 @@
 
     public void testPostRemove() {
 
-        LifecycleEventCallbackMap postRemove = getDomain()
+        LifecycleCallbackRegistry registry = getDomain()
                 .getEntityResolver()
-                .getCallbacks(LifecycleEventCallback.POST_REMOVE);
+                .getCallbackRegistry();
 
         DataChannelCallbackInterceptor i = new DataChannelCallbackInterceptor();
         i.setChannel(getDomain());
@@ -208,9 +213,13 @@
         a1.setArtistName("XX");
         context.commitChanges();
 
-        postRemove.addListener(Artist.class, "postRemoveCallback");
+        registry.addListener(CallbackMap.POST_REMOVE, Artist.class, "postRemoveCallback");
         MockCallingBackListener listener2 = new MockCallingBackListener();
-        postRemove.addListener(Artist.class, listener2, "publicCallback");
+        registry.addListener(
+                CallbackMap.POST_REMOVE,
+                Artist.class,
+                listener2,
+                "publicCallback");
 
         context.deleteObject(a1);
         context.commitChanges();
@@ -221,9 +230,9 @@
 
     public void testPostPersist() {
 
-        LifecycleEventCallbackMap postPersist = getDomain()
+        LifecycleCallbackRegistry registry = getDomain()
                 .getEntityResolver()
-                .getCallbacks(LifecycleEventCallback.POST_PERSIST);
+                .getCallbackRegistry();
 
         DataChannelCallbackInterceptor i = new DataChannelCallbackInterceptor();
         i.setChannel(getDomain());
@@ -236,9 +245,16 @@
         context.commitChanges();
         assertFalse(a1.isPostPersisted());
 
-        postPersist.addListener(Artist.class, "postPersistCallback");
+        registry.addListener(
+                CallbackMap.POST_PERSIST,
+                Artist.class,
+                "postPersistCallback");
         MockCallingBackListener listener2 = new MockCallingBackListener();
-        postPersist.addListener(Artist.class, listener2, "publicCallback");
+        registry.addListener(
+                CallbackMap.POST_PERSIST,
+                Artist.class,
+                listener2,
+                "publicCallback");
 
         Artist a2 = (Artist) context.newObject(Artist.class);
         a2.setArtistName("XX");

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/intercept/ObjectContextCallbackInterceptorTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/intercept/ObjectContextCallbackInterceptorTest.java?view=diff&rev=507579&r1=507578&r2=507579
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/intercept/ObjectContextCallbackInterceptorTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/intercept/ObjectContextCallbackInterceptorTest.java Wed Feb 14 07:33:38 2007
@@ -20,9 +20,9 @@
 
 import org.apache.art.Artist;
 import org.apache.art.Painting;
+import org.apache.cayenne.map.CallbackMap;
 import org.apache.cayenne.map.EntityResolver;
-import org.apache.cayenne.map.LifecycleEventCallback;
-import org.apache.cayenne.map.LifecycleEventCallbackMap;
+import org.apache.cayenne.map.LifecycleCallbackRegistry;
 import org.apache.cayenne.unit.CayenneCase;
 
 public class ObjectContextCallbackInterceptorTest extends CayenneCase {
@@ -33,21 +33,13 @@
 
     protected void tearDown() throws Exception {
         EntityResolver resolver = getDomain().getEntityResolver();
-
-        resolver.getCallbacks(LifecycleEventCallback.POST_LOAD).removeAll();
-        resolver.getCallbacks(LifecycleEventCallback.POST_PERSIST).removeAll();
-        resolver.getCallbacks(LifecycleEventCallback.POST_REMOVE).removeAll();
-        resolver.getCallbacks(LifecycleEventCallback.POST_UPDATE).removeAll();
-        resolver.getCallbacks(LifecycleEventCallback.PRE_PERSIST).removeAll();
-        resolver.getCallbacks(LifecycleEventCallback.PRE_REMOVE).removeAll();
-        resolver.getCallbacks(LifecycleEventCallback.PRE_UPDATE).removeAll();
+        resolver.getCallbackRegistry().clear();
     }
 
     public void testPrePersistCallbacks() {
-
-        LifecycleEventCallbackMap prePersist = getDomain()
+        LifecycleCallbackRegistry registry = getDomain()
                 .getEntityResolver()
-                .getCallbacks(LifecycleEventCallback.PRE_PERSIST);
+                .getCallbackRegistry();
 
         ObjectContextCallbackInterceptor i = new ObjectContextCallbackInterceptor();
         i.setContext(createDataContext());
@@ -57,14 +49,18 @@
         assertNotNull(a1);
         assertFalse(a1.isPrePersisted());
 
-        prePersist.addListener(Artist.class, "prePersistCallback");
+        registry.addListener(CallbackMap.PRE_PERSIST, Artist.class, "prePersistCallback");
 
         Artist a2 = (Artist) i.newObject(Artist.class);
         assertNotNull(a2);
         assertTrue(a2.isPrePersisted());
 
         MockCallingBackListener listener2 = new MockCallingBackListener();
-        prePersist.addListener(Artist.class, listener2, "publicCallback");
+        registry.addListener(
+                CallbackMap.PRE_PERSIST,
+                Artist.class,
+                listener2,
+                "publicCallback");
 
         Artist a3 = (Artist) i.newObject(Artist.class);
         assertNotNull(a3);
@@ -79,9 +75,9 @@
     }
 
     public void testPreRemoveCallbacks() {
-        LifecycleEventCallbackMap preRemove = getDomain()
+        LifecycleCallbackRegistry registry = getDomain()
                 .getEntityResolver()
-                .getCallbacks(LifecycleEventCallback.PRE_REMOVE);
+                .getCallbackRegistry();
 
         ObjectContextCallbackInterceptor i = new ObjectContextCallbackInterceptor();
         i.setContext(createDataContext());
@@ -94,7 +90,7 @@
         assertFalse(a1.isPrePersisted());
         assertFalse(a1.isPreRemoved());
 
-        preRemove.addListener(Artist.class, "preRemoveCallback");
+        registry.addListener(CallbackMap.PRE_REMOVE, Artist.class, "preRemoveCallback");
 
         Artist a2 = (Artist) i.newObject(Artist.class);
         a2.setArtistName("XX");
@@ -104,7 +100,11 @@
         assertTrue(a2.isPreRemoved());
 
         MockCallingBackListener listener2 = new MockCallingBackListener();
-        preRemove.addListener(Artist.class, listener2, "publicCallback");
+        registry.addListener(
+                CallbackMap.PRE_REMOVE,
+                Artist.class,
+                listener2,
+                "publicCallback");
 
         Artist a3 = (Artist) i.newObject(Artist.class);
         a3.setArtistName("XX");

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/map/CallbackDescriptorTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/map/CallbackDescriptorTest.java?view=diff&rev=507579&r1=507578&r2=507579
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/map/CallbackDescriptorTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/map/CallbackDescriptorTest.java Wed Feb 14 07:33:38 2007
@@ -23,8 +23,8 @@
 public class CallbackDescriptorTest extends TestCase {
 
     public void testConstructor() {
-        CallbackDescriptor m = new CallbackDescriptor(LifecycleEventCallback.POST_LOAD);
-        assertEquals(LifecycleEventCallback.POST_LOAD, m.getCallbackType());
+        CallbackDescriptor m = new CallbackDescriptor(CallbackMap.POST_LOAD);
+        assertEquals(CallbackMap.POST_LOAD, m.getCallbackType());
 
         try {
             new CallbackDescriptor(10000);
@@ -36,7 +36,7 @@
     }
 
     public void testAddCallbackMethod() {
-        CallbackDescriptor m = new CallbackDescriptor(LifecycleEventCallback.PRE_PERSIST);
+        CallbackDescriptor m = new CallbackDescriptor(CallbackMap.PRE_PERSIST);
         assertEquals(0, m.getCallbackMethods().size());
         m.addCallbackMethod("a");
         assertEquals(1, m.getCallbackMethods().size());

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/map/LifecycleEventCallbackMapTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/map/LifecycleEventCallbackMapTest.java?view=diff&rev=507579&r1=507578&r2=507579
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/map/LifecycleEventCallbackMapTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/map/LifecycleEventCallbackMapTest.java Wed Feb 14 07:33:38 2007
@@ -27,7 +27,8 @@
 
     public void testDefaultListeners() {
 
-        LifecycleEventCallbackMap map = new MockLifecycleEventCallbackMap();
+        LifecycleCallbackEventHandler map = new LifecycleCallbackEventHandler(
+                new EntityResolver());
         L1 l1 = new L1();
         map.addDefaultListener(l1, "callback");
 
@@ -41,7 +42,8 @@
 
     public void testDefaultListenersCallbackOrder() {
 
-        LifecycleEventCallbackMap map = new MockLifecycleEventCallbackMap();
+        LifecycleCallbackEventHandler map = new LifecycleCallbackEventHandler(
+                new EntityResolver());
         L2 l1 = new L2();
         map.addListener(C1.class, l1, "callback");
 
@@ -61,7 +63,8 @@
 
     public void testCallbackOnSuperclass() {
 
-        LifecycleEventCallbackMap map = new MockLifecycleEventCallbackMap();
+        LifecycleCallbackEventHandler map = new LifecycleCallbackEventHandler(
+                new EntityResolver());
         map.addListener(C1.class, "c1Callback");
 
         C3 subclass = new C3();
@@ -73,7 +76,8 @@
 
     public void testCallbackOnSuperclassWithSublcassOverrides() {
 
-        LifecycleEventCallbackMap map = new MockLifecycleEventCallbackMap();
+        LifecycleCallbackEventHandler map = new LifecycleCallbackEventHandler(
+                new EntityResolver());
         map.addListener(C1.class, "c1Callback");
 
         C4 subclass = new C4();
@@ -86,7 +90,8 @@
 
     public void testCallbackOrderInInheritanceHierarchy() {
 
-        LifecycleEventCallbackMap map = new MockLifecycleEventCallbackMap();
+        LifecycleCallbackEventHandler map = new LifecycleCallbackEventHandler(
+                new EntityResolver());
         map.addListener(C2.class, "c2Callback");
         map.addListener(C1.class, "c1Callback");
 



Mime
View raw message