cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r585926 - in /cayenne/main/trunk/framework: cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/ cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/bridge/ cayenne-jpa-unpublished/src/test/java/org/apache/cayenne/jpa/b...
Date Thu, 18 Oct 2007 11:01:22 GMT
Author: aadamchik
Date: Thu Oct 18 04:01:21 2007
New Revision: 585926

URL: http://svn.apache.org/viewvc?rev=585926&view=rev
Log:
removed entity listener cache stored in DataMap... such redundancy is confusing and won't
work well anyways... the only correct place to cache aggregated metadata is EntityResolver

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/DataMap.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/main/java/org/apache/cayenne/map/MappingNamespace.java
    cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/bridge/DataMapConverter.java
    cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/test/java/org/apache/cayenne/jpa/bridge/DataMapConverterTest.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/DataMap.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/DataMap.java?rev=585926&r1=585925&r2=585926&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/DataMap.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/DataMap.java
Thu Oct 18 04:01:21 2007
@@ -115,7 +115,6 @@
     protected String defaultClientPackage;
 
     private SortedMap embeddablesMap;
-    private SortedMap entityListenersMap;
     private SortedMap objEntityMap;
     private SortedMap dbEntityMap;
     private SortedMap procedureMap;
@@ -139,7 +138,6 @@
 
     public DataMap(String mapName, Map properties) {
         embeddablesMap = new TreeMap();
-        entityListenersMap = new TreeMap();
         objEntityMap = new TreeMap();
         dbEntityMap = new TreeMap();
         procedureMap = new TreeMap();
@@ -494,15 +492,6 @@
     }
 
     /**
-     * Removes all stored entity listeners from the map.
-     * 
-     * @since 3.0
-     */
-    public void clearEntityListeners() {
-        entityListenersMap.clear();
-    }
-
-    /**
      * @since 1.1
      */
     public void clearQueries() {
@@ -547,48 +536,6 @@
     }
 
     /**
-     * Adds a default entity listener that should be notified of certain events on all
-     * entities.
-     */
-    public void addEntityListener(EntityListener listener) {
-        if (listener == null) {
-            throw new NullPointerException("Null EntityListener");
-        }
-
-        if (listener.getClassName() == null) {
-            throw new NullPointerException(
-                    "Attempt to add EntityListener with no class name.");
-        }
-
-        // TODO: change method signature to return replaced el and make sure the
-        // Modeler handles it...
-        Object existing = embeddablesMap.get(listener.getClassName());
-        if (existing != null) {
-            if (existing == listener) {
-                return;
-            }
-            else {
-                throw new IllegalArgumentException("An attempt to override listener '"
-                        + listener.getClassName());
-            }
-        }
-
-        entityListenersMap.put(listener.getClassName(), listener);
-    }
-
-    /**
-     * Removes an {@link EntityListener} descriptor with matching class name from entity
-     * listeners and default entity listeners.
-     * 
-     * @since 3.0
-     */
-    public void removeEntityListener(String className) {
-        if (entityListenersMap.remove(className) != null) {
-            removeDefaultEntityListener(className);
-        }
-    }
-
-    /**
      * Adds an embeddable object to the DataMap.
      * 
      * @since 3.0
@@ -702,34 +649,6 @@
         }
 
         return namespace != null ? namespace.getEmbeddable(className) : null;
-    }
-
-    /**
-     * @since 3.0
-     */
-    public Map getEntityListenersMap() {
-        return Collections.unmodifiableMap(entityListenersMap);
-    }
-
-    /**
-     * Returns a collection of {@link EntityListener} mappings stored in the DataMap.
-     * 
-     * @since 3.0
-     */
-    public Collection getEntityListeners() {
-        return Collections.unmodifiableCollection(entityListenersMap.values());
-    }
-
-    /**
-     * @since 3.0
-     */
-    public EntityListener getEntityListener(String className) {
-        EntityListener e = (EntityListener) entityListenersMap.get(className);
-        if (e != null) {
-            return e;
-        }
-
-        return namespace != null ? namespace.getEntityListener(className) : null;
     }
 
     /**

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?rev=585926&r1=585925&r2=585926&view=diff
==============================================================================
--- 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
Thu Oct 18 04:01:21 2007
@@ -66,7 +66,6 @@
 
     protected transient Map queryCache;
     protected transient Map embeddableCache;
-    protected transient Map entityListenerCache;
     protected transient Map dbEntityCache;
     protected transient Map objEntityCache;
     protected transient Map procedureCache;
@@ -88,7 +87,6 @@
         this.indexedByClass = true;
         this.maps = new ArrayList();
         this.embeddableCache = new HashMap();
-        this.entityListenerCache = new HashMap();
         this.queryCache = new HashMap();
         this.dbEntityCache = new HashMap();
         this.objEntityCache = new HashMap();
@@ -347,22 +345,6 @@
     }
 
     /**
-     * @since 3.0
-     */
-    public EntityListener getEntityListener(String className) {
-        EntityListener result = (EntityListener) entityListenerCache.get(className);
-
-        if (result == null) {
-            // reconstruct cache just in case some of the datamaps
-            // have changed and now contain the required information
-            constructCache();
-            result = (EntityListener) entityListenerCache.get(className);
-        }
-
-        return result;
-    }
-
-    /**
      * Returns ClassDescriptor for the ObjEntity matching the name. Returns null if no
      * matching entity exists.
      * 
@@ -395,7 +377,6 @@
         objEntityCache.clear();
         procedureCache.clear();
         entityInheritanceCache.clear();
-        entityListenerCache.clear();
         clientEntityResolver = null;
     }
 
@@ -475,13 +456,6 @@
                     throw new CayenneRuntimeException("More than one Query for name"
                             + name);
                 }
-            }
-
-            // index listeners
-            Iterator listeners = map.getEntityListeners().iterator();
-            while (listeners.hasNext()) {
-                EntityListener listener = (EntityListener) listeners.next();
-                entityListenerCache.put(listener.getClassName(), listener);
             }
         }
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/MappingNamespace.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/MappingNamespace.java?rev=585926&r1=585925&r2=585926&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/MappingNamespace.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/MappingNamespace.java
Thu Oct 18 04:01:21 2007
@@ -41,14 +41,6 @@
     Embeddable getEmbeddable(String className);
 
     /**
-     * Returns an {@link EntityListener} matching class name or null if such
-     * EntityListener is not mapped.
-     * 
-     * @since 3.0
-     */
-    EntityListener getEntityListener(String className);
-
-    /**
      * Returns DbEntity for a given name, or null if no such DbEntity is found in the
      * MappingNamespace.
      */

Modified: cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/bridge/DataMapConverter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/bridge/DataMapConverter.java?rev=585926&r1=585925&r2=585926&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/bridge/DataMapConverter.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/bridge/DataMapConverter.java
Thu Oct 18 04:01:21 2007
@@ -204,13 +204,9 @@
             JpaEntityListener jpaListener = (JpaEntityListener) path.getObject();
 
             DataMap map = (DataMap) targetPath.firstInstanceOf(DataMap.class);
-            EntityListener listener = map.getEntityListener(jpaListener.getClassName());
-            if (listener == null) {
-                listener = makeEntityListener(jpaListener);
-                map.addEntityListener(listener);
-            }
-
+            EntityListener listener = makeEntityListener(jpaListener);
             map.addDefaultEntityListener(listener);
+
             return false;
         }
     }
@@ -220,14 +216,8 @@
         @Override
         public boolean onStartNode(ProjectPath path) {
             JpaEntityListener jpaListener = (JpaEntityListener) path.getObject();
-
-            DataMap map = (DataMap) targetPath.firstInstanceOf(DataMap.class);
-            EntityListener listener = map.getEntityListener(jpaListener.getClassName());
-            if (listener == null) {
-                listener = makeEntityListener(jpaListener);
-                map.addEntityListener(listener);
-            }
-
+            
+            EntityListener listener = makeEntityListener(jpaListener);
             ObjEntity entity = (ObjEntity) targetPath.firstInstanceOf(ObjEntity.class);
             entity.addEntityListener(listener);
 

Modified: cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/test/java/org/apache/cayenne/jpa/bridge/DataMapConverterTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/test/java/org/apache/cayenne/jpa/bridge/DataMapConverterTest.java?rev=585926&r1=585925&r2=585926&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/test/java/org/apache/cayenne/jpa/bridge/DataMapConverterTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/test/java/org/apache/cayenne/jpa/bridge/DataMapConverterTest.java
Thu Oct 18 04:01:21 2007
@@ -79,12 +79,12 @@
         listeners.getEntityListeners().add(l2);
 
         DataMap cayenneMap = new DataMapConverter().toDataMap("n1", context);
-        Collection entityListeners = cayenneMap.getEntityListeners();
+        Collection entityListeners = cayenneMap.getDefaultEntityListeners();
         assertEquals(2, entityListeners.size());
         Collection defaultListeners = cayenneMap.getDefaultEntityListeners();
         assertEquals(2, defaultListeners.size());
 
-        EntityListener cl1 = cayenneMap.getEntityListener("abc.C1");
+        EntityListener cl1 = cayenneMap.getDefaultEntityListener("abc.C1");
         assertNotNull(cl1);
         assertEquals(l1.getClassName(), cl1.getClassName());
         assertEquals(1, cl1.getCallbackMap().getPostLoad().getCallbackMethods().size());



Mime
View raw message