db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m..@apache.org
Subject svn commit: r208674 - in /incubator/jdo/trunk/core20/src/java/org/apache/jdo: impl/model/java/AbstractJavaModelFactory.java impl/model/jdo/JDOModelFactoryImplDynamic.java model/java/JavaModelFactory.java model/jdo/JDOModelFactory.java
Date Thu, 30 Jun 2005 20:10:11 GMT
Author: mbo
Date: Thu Jun 30 13:10:10 2005
New Revision: 208674

URL: http://svn.apache.org/viewcvs?rev=208674&view=rev
Log:
Added remove methods to JavaModelFactory and JDOModelFactory and its implementing classes

Modified:
    incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/AbstractJavaModelFactory.java
    incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/JDOModelFactoryImplDynamic.java
    incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/java/JavaModelFactory.java
    incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/jdo/JDOModelFactory.java

Modified: incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/AbstractJavaModelFactory.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/AbstractJavaModelFactory.java?rev=208674&r1=208673&r2=208674&view=diff
==============================================================================
--- incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/AbstractJavaModelFactory.java
(original)
+++ incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/AbstractJavaModelFactory.java
Thu Jun 30 13:10:10 2005
@@ -16,6 +16,7 @@
 
 package org.apache.jdo.impl.model.java;
 
+import java.util.Iterator;
 import java.util.Map;
 import java.util.HashMap;
 
@@ -41,7 +42,8 @@
  * ModelFatalException.
  * 
  * @author Michael Bouschen
- * @since JDO 1.0.1
+ * @since 1.0.1
+ * @version 2.0
  */
 abstract public class AbstractJavaModelFactory
     implements JavaModelFactory
@@ -92,7 +94,7 @@
      */
     public JavaModel getJavaModel(Object key)
     {
-        synchronized (this.modelCache) {
+        synchronized (modelCache) {
             JavaModel javaModel = (JavaModel)modelCache.get(key);
             if (javaModel == null) {
                 // create new model and store it using the specified key
@@ -107,6 +109,45 @@
             } 
             return javaModel;
          }
+    }
+
+    /**
+     * Removes the specified javaModel from the JavaModel cache. Note, if
+     * there are multiple entries in the cache with the specified javaModel
+     * as value, then all of them get removed. The method does not have an
+     * effect, if this factory does not have the specified javaModel.
+     * @param javaModel the JavaModel to be removed.
+     * @since 2.0
+     */
+    public void removeJavaModel(JavaModel javaModel) {
+        if (javaModel == null) {
+            // nothing to be removed => return
+            return;
+        }
+        
+        synchronized (modelCache) {
+            for (Iterator i = modelCache.entrySet().iterator(); i.hasNext();) {
+                Map.Entry entry = (Map.Entry) i.next();
+                Object value = entry.getValue();
+                if ((javaModel == value) || javaModel.equals(value)) {
+                    // found javaModel => remove the entry
+                    i.remove();
+                }
+            }
+        }
+    }
+
+    /**
+     * Removes the JavaModel for the specified key from the JavaModel
+     * cache. The method does not have an effect, if this factory does not 
+     * have a JavaModel for the the specified key.
+     * @param key the key used to find the JavaModel instance to be removed.
+     * @since 2.0
+     */
+    public void removeJavaModel(Object key) {
+        synchronized (modelCache) {
+            modelCache.remove(key);
+        } 
     }
 
     /**

Modified: incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/JDOModelFactoryImplDynamic.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/JDOModelFactoryImplDynamic.java?rev=208674&r1=208673&r2=208674&view=diff
==============================================================================
--- incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/JDOModelFactoryImplDynamic.java
(original)
+++ incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/JDOModelFactoryImplDynamic.java
Thu Jun 30 13:10:10 2005
@@ -16,6 +16,7 @@
 
 package org.apache.jdo.impl.model.jdo;
 
+import java.util.Iterator;
 import java.util.Map;
 import java.util.HashMap;
 
@@ -34,7 +35,7 @@
  *
  * @author Michael Bouschen
  * @since 1.1
- * @version 1.1
+ * @version 2.0
  */
 public class JDOModelFactoryImplDynamic implements JDOModelFactory {
 
@@ -80,7 +81,7 @@
     }
     
     /**
-     * Returns the JDOModel instance for the specified JavaModel.
+     * Returns the JDOModel instance for the specified javaModel.
      * @param javaModel the javaModel used to cache the returned JDOModel
      * instance.
      */
@@ -89,7 +90,7 @@
     }
 
     /**
-     * Returns the JDOModel instance for the specified JavaModel.  
+     * Returns the JDOModel instance for the specified javaModel.  
      * The returned JDOModel instance uses the specified flag
      * <code>loadXMLMetadataDefault</code> to set the default behavior 
      * for the creation of new JDOClass instances  using methods 
@@ -101,7 +102,7 @@
      */
     public JDOModel getJDOModel(JavaModel javaModel,
                                 boolean loadXMLMetadataDefault) {
-        synchronized (this.modelCache) {
+        synchronized (modelCache) {
             JDOModel jdoModel = (JDOModel)modelCache.get(javaModel);
             if (jdoModel == null) {
                 // create new model and store it using the specified javaModel
@@ -112,4 +113,43 @@
         }
     }
 
+    /**
+     * Removes the specified jdoModel from the JDOModel cache. Note, if
+     * there are multiple entries in the cache with the specified jdoModel
+     * as value, then all of them get removed. The method does not have an
+     * effect, if this factory does not have the specified jdoModel.
+     * @param jdoModel the JDOModel to be removed.
+     * @since 2.0
+     */
+    public void removeJDOModel(JDOModel jdoModel) {
+        if (jdoModel == null) {
+            // nothing to be removed => return
+            return;
+        }
+        
+        synchronized (modelCache) {
+            for (Iterator i = modelCache.entrySet().iterator(); i.hasNext();) {
+                Map.Entry entry = (Map.Entry) i.next();
+                Object value = entry.getValue();
+                if (jdoModel.equals(value)) {
+                    // found jdoModel => remove the entry
+                    i.remove();
+                }
+            }
+        }
+    }
+
+    /**
+     * Removes the JDOModel for the specified javaModel from the JDOModel
+     * cache. The method does not have an effect, if this factory does not
+     * have a JDOModel for the the specified javaModel.
+     * @param javaModel the javaModel used to find the JDOModel instance to be
+     * removed.
+     * @since 2.0
+     */
+    public void removeJDOModel(JavaModel javaModel) {
+        synchronized (modelCache) {
+            modelCache.remove(javaModel);
+        }
+    }
 }

Modified: incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/java/JavaModelFactory.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/java/JavaModelFactory.java?rev=208674&r1=208673&r2=208674&view=diff
==============================================================================
--- incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/java/JavaModelFactory.java (original)
+++ incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/java/JavaModelFactory.java Thu
Jun 30 13:10:10 2005
@@ -26,7 +26,8 @@
  * JavaType by an implementation specific type description. 
  * 
  * @author Michael Bouschen
- * @since JDO 1.0.1
+ * @since 1.0.1
+ * @version 2.0
  */
 public interface JavaModelFactory 
 {
@@ -67,6 +68,27 @@
      */
     public JavaModel getJavaModel(Object key)
         throws ModelFatalException;
+
+    /**
+     * Removes the specified javaModel from the JavaModel cache. Note, if
+     * there are multiple entries in the cache with the specified javaModel
+     * as value, then all of them get removed. The method does not have an
+     * effect, if this factory does not have the specified javaModel.
+     * @param javaModel the JavaModel to be removed.
+     * @since 2.0
+     */
+    public void removeJavaModel(JavaModel javaModel)
+        throws ModelException;
+
+    /**
+     * Removes the JavaModel for the specified key from the JavaModel
+     * cache. The method does not have an effect, if this factory does not 
+     * have a JavaModel for the the specified key.
+     * @param key the key used to find the JavaModel instance to be removed.
+     * @since 2.0
+     */
+    public void removeJavaModel(Object key)
+        throws ModelException;
 
     /**
      * Returns a JavaType instance for the specified type description

Modified: incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/jdo/JDOModelFactory.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/jdo/JDOModelFactory.java?rev=208674&r1=208673&r2=208674&view=diff
==============================================================================
--- incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/jdo/JDOModelFactory.java (original)
+++ incubator/jdo/trunk/core20/src/java/org/apache/jdo/model/jdo/JDOModelFactory.java Thu
Jun 30 13:10:10 2005
@@ -25,6 +25,7 @@
  * JDOModel instances per user defined keys.
  * 
  * @author Michael Bouschen
+ * @version 2.0
  */
 public interface JDOModelFactory 
 {
@@ -45,14 +46,14 @@
         throws ModelException;
     
     /**
-     * Returns the JDOModel instance for the specified JavaModel.
+     * Returns the JDOModel instance for the specified javaModel.
      * @param javaModel the javaModel used to cache the returned JDOModel
      * instance.
      */
     public JDOModel getJDOModel(JavaModel javaModel);
     
     /**
-     * Returns the JDOModel instance for the specified JavaModel.  
+     * Returns the JDOModel instance for the specified javaModel.  
      * The returned JDOModel instance uses the specified flag
      * <code>loadXMLMetadataDefault</code> to set the default behavior 
      * for the creation of new JDOClass instances  using methods 
@@ -64,5 +65,27 @@
      */
     public JDOModel getJDOModel(JavaModel javaModel, 
                                 boolean loadXMLMetadataDefault);
+
+    /**
+     * Removes the specified jdoModel from the JDOModel cache. Note, if
+     * there are multiple entries in the cache with the specified jdoModel
+     * as value, then all of them get removed. The method does not have an
+     * effect, if this factory does not have the specified jdoModel.
+     * @param jdoModel the JDOModel to be removed.
+     * @since 2.0
+     */
+    public void removeJDOModel(JDOModel jdoModel)
+        throws ModelException;
+
+    /**
+     * Removes the JDOModel for the specified javaModel from the JDOModel
+     * cache. The method does not have an effect, if this factory does not
+     * have a JDOModel for the the specified javaModel.
+     * @param javaModel the javaModel used to find the JDOModel instance to be
+     * removed.
+     * @since 2.0
+     */
+    public void removeJDOModel(JavaModel javaModel)
+        throws ModelException;
 
 }



Mime
View raw message