jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r816648 - in /jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype: NodeTypeCache.java NodeTypeImpl.java NodeTypeRegistryImpl.java
Date Fri, 18 Sep 2009 14:35:09 GMT
Author: reschke
Date: Fri Sep 18 14:35:08 2009
New Revision: 816648

URL: http://svn.apache.org/viewvc?rev=816648&view=rev
Log:
JCR-2087: parametrize generic types

Modified:
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeCache.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistryImpl.java

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeCache.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeCache.java?rev=816648&r1=816647&r2=816648&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeCache.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeCache.java
Fri Sep 18 14:35:08 2009
@@ -40,7 +40,7 @@
     /**
      * The caches per repository service instance
      */
-    private static final Map<RepositoryService, Map> CACHES_PER_SERVICE = new WeakHashMap<RepositoryService,
Map>();
+    private static final Map<RepositoryService, Map<String, NodeTypeCache>> CACHES_PER_SERVICE
= new WeakHashMap<RepositoryService, Map<String, NodeTypeCache>>();
 
     /**
      * Maps node type Names to QNodeTypeDefinition
@@ -59,7 +59,7 @@
         if (userId == null) {
             return new NodeTypeCache();
         }
-        Map caches;
+        Map<String, NodeTypeCache> caches;
         synchronized (CACHES_PER_SERVICE) {
             caches = CACHES_PER_SERVICE.get(service);
             if (caches == null) {
@@ -69,7 +69,7 @@
             }
         }
         synchronized (caches) {
-            NodeTypeCache cache = (NodeTypeCache) caches.get(userId);
+            NodeTypeCache cache = caches.get(userId);
             if (cache == null) {
                 cache = new NodeTypeCache();
                 caches.put(userId, cache);

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeImpl.java?rev=816648&r1=816647&r2=816648&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeImpl.java
Fri Sep 18 14:35:08 2009
@@ -31,7 +31,6 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.jcr.NamespaceException;
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
@@ -272,7 +271,7 @@
                 targetType = type;
             }
 
-            ArrayList list = new ArrayList();
+            ArrayList<QValue> list = new ArrayList<QValue>();
             // convert values and compact array (purge null entries)
             for (int i = 0; i < values.length; i++) {
                 if (values[i] != null) {
@@ -283,7 +282,7 @@
                     list.add(qValue);
                 }
             }
-            QValue[] internalValues = (QValue[]) list.toArray(new QValue[list.size()]);
+            QValue[] internalValues = list.toArray(new QValue[list.size()]);
             checkSetPropertyValueConstraints(def, internalValues);
             return true;
         } catch (NameException be) {

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistryImpl.java?rev=816648&r1=816647&r2=816648&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistryImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistryImpl.java
Fri Sep 18 14:35:08 2009
@@ -82,7 +82,7 @@
     /**
      * Listeners (soft references)
      */
-    private final Map listeners = Collections.synchronizedMap(new ReferenceMap(ReferenceMap.WEAK,
ReferenceMap.WEAK));
+    private final Map<NodeTypeRegistryListener, NodeTypeRegistryListener> listeners
= Collections.synchronizedMap(new ReferenceMap(ReferenceMap.WEAK, ReferenceMap.WEAK));
 
     /**
      * Create a new <code>NodeTypeRegistry</codes>
@@ -206,8 +206,8 @@
             if (dependents.size() > 0) {
                 StringBuffer msg = new StringBuffer();
                 msg.append(ntName).append(" can not be removed because the following node
types depend on it: ");
-                for (Iterator<Name> depIter = dependents.iterator(); depIter.hasNext();)
{
-                    msg.append(depIter.next());
+                for (Name name : dependents) {
+                    msg.append(name);
                     msg.append(" ");
                 }
                 throw new RepositoryException(msg.toString());
@@ -223,8 +223,7 @@
         internalUnregister(nodeTypeNames);
 
         // notify listeners
-        for (Iterator<Name> iter = nodeTypeNames.iterator(); iter.hasNext();) {
-            Name ntName = iter.next();
+        for (Name ntName : nodeTypeNames) {
             notifyUnregistered(ntName);
         }
     }
@@ -533,10 +532,9 @@
         // copy listeners to array to avoid ConcurrentModificationException
         NodeTypeRegistryListener[] la =
                 new NodeTypeRegistryListener[listeners.size()];
-        Iterator iter = listeners.values().iterator();
         int cnt = 0;
-        while (iter.hasNext()) {
-            la[cnt++] = (NodeTypeRegistryListener) iter.next();
+        for (NodeTypeRegistryListener ntrl : listeners.values()) {
+            la[cnt++] = ntrl;
         }
         for (int i = 0; i < la.length; i++) {
             if (la[i] != null) {
@@ -551,10 +549,9 @@
     private void notifyReRegistered(Name ntName) {
         // copy listeners to array to avoid ConcurrentModificationException
         NodeTypeRegistryListener[] la = new NodeTypeRegistryListener[listeners.size()];
-        Iterator iter = listeners.values().iterator();
         int cnt = 0;
-        while (iter.hasNext()) {
-            la[cnt++] = (NodeTypeRegistryListener) iter.next();
+        for (NodeTypeRegistryListener ntrl : listeners.values()) {
+            la[cnt++] = ntrl;
         }
         for (int i = 0; i < la.length; i++) {
             if (la[i] != null) {
@@ -569,10 +566,9 @@
     private void notifyUnregistered(Name ntName) {
         // copy listeners to array to avoid ConcurrentModificationException
         NodeTypeRegistryListener[] la = new NodeTypeRegistryListener[listeners.size()];
-        Iterator iter = listeners.values().iterator();
         int cnt = 0;
-        while (iter.hasNext()) {
-            la[cnt++] = (NodeTypeRegistryListener) iter.next();
+        for (NodeTypeRegistryListener ntrl : listeners.values()) {
+            la[cnt++] = ntrl;
         }
         for (int i = 0; i < la.length; i++) {
             if (la[i] != null) {
@@ -694,9 +690,7 @@
             // get names of those node types that have dependencies on the
             // node type with the given nodeTypeName.
             HashSet<Name> names = new HashSet<Name>();
-            Iterator<QNodeTypeDefinition> iter = getValues().iterator();
-            while (iter.hasNext()) {
-                QNodeTypeDefinition ntd = iter.next();
+            for (QNodeTypeDefinition ntd : getValues()) {
                 if (ntd.getDependencies().contains(nodeTypeName)) {
                     names.add(ntd.getName());
                 }
@@ -799,9 +793,7 @@
 
         //-------------------------------------------------------< Dumpable >---
         public void dump(PrintStream ps) {
-            Iterator<QNodeTypeDefinition> iter = getValues().iterator();
-            while (iter.hasNext()) {
-                QNodeTypeDefinition ntd = iter.next();
+            for (QNodeTypeDefinition ntd : getValues()) {
                 ps.println(ntd.getName());
                 Name[] supertypes = ntd.getSupertypes();
                 ps.println("\tSupertypes");



Mime
View raw message