xmlbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ra...@apache.org
Subject svn commit: r240307 - in /xmlbeans/trunk: external/lib/oldxbean.jar src/common/org/apache/xmlbeans/impl/common/SystemCache.java src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeLoaderImpl.java
Date Fri, 26 Aug 2005 18:28:52 GMT
Author: radup
Date: Fri Aug 26 11:28:45 2005
New Revision: 240307

URL: http://svn.apache.org/viewcvs?rev=240307&view=rev
Log:
Changed the caching interfaces (see r233375) to make them more usable.


Modified:
    xmlbeans/trunk/external/lib/oldxbean.jar
    xmlbeans/trunk/src/common/org/apache/xmlbeans/impl/common/SystemCache.java
    xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeLoaderImpl.java

Modified: xmlbeans/trunk/external/lib/oldxbean.jar
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/external/lib/oldxbean.jar?rev=240307&r1=240306&r2=240307&view=diff
==============================================================================
Binary files - no diff available.

Modified: xmlbeans/trunk/src/common/org/apache/xmlbeans/impl/common/SystemCache.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/common/org/apache/xmlbeans/impl/common/SystemCache.java?rev=240307&r1=240306&r2=240307&view=diff
==============================================================================
--- xmlbeans/trunk/src/common/org/apache/xmlbeans/impl/common/SystemCache.java (original)
+++ xmlbeans/trunk/src/common/org/apache/xmlbeans/impl/common/SystemCache.java Fri Aug 26
11:28:45 2005
@@ -20,6 +20,18 @@
 import org.apache.xmlbeans.SchemaTypeLoader;
 import org.apache.xmlbeans.SystemProperties;
 
+/**
+ * This class encapsulates the caching strategy for XmlBeans.
+ * By subclassing this, a client of XmlBeans can implement caches that are
+ * more suitable for different applications using information that XmlBeans
+ * cannot know.
+ * <p/>
+ * This class works as a singleton and as a default implementation for the cache.
+ * You can set a particular implementation using the "xmlbean.systemcacheimpl"
+ * system property or using the static {@link set} method.
+ * Subclasses of this need to be thread-safe. An implementation can be replaced
+ * at any time, so use of static variables is discouraged to ensure proper cleanup.
+ */
 public class SystemCache
 {
     private static SystemCache INSTANCE = new SystemCache();
@@ -63,9 +75,6 @@
 
     public static synchronized final void set(SystemCache instance)
     {
-        if (INSTANCE.getClass() != SystemCache.class)
-            throw new RuntimeException("Cache instance is already set to class " +
-                INSTANCE.getClass().getName());
         INSTANCE = instance;
     }
 
@@ -84,7 +93,7 @@
         return;
     }
 
-    private static ThreadLocal tl_saxLoaders = new ThreadLocal();
+    private ThreadLocal tl_saxLoaders = new ThreadLocal();
 
     public Object getSaxLoader()
     {

Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeLoaderImpl.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeLoaderImpl.java?rev=240307&r1=240306&r2=240307&view=diff
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeLoaderImpl.java
(original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeLoaderImpl.java
Fri Aug 26 11:28:45 2005
@@ -66,7 +66,7 @@
         // I use soft references to allow the garbage collector to reclain the type loaders
         // and/pr class loaders at will.
 
-        private static ThreadLocal _cachedTypeSystems =
+        private ThreadLocal _cachedTypeSystems =
             new ThreadLocal() { protected Object initialValue() { return new ArrayList();
} };
 
         public SchemaTypeLoader getFromTypeLoaderCache(ClassLoader cl)
@@ -609,6 +609,7 @@
 
     static
     {
-        SystemCache.set(new SchemaTypeLoaderCache());
+        if (SystemCache.get() instanceof SystemCache)
+            SystemCache.set(new SchemaTypeLoaderCache());
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: commits-help@xmlbeans.apache.org


Mime
View raw message