Author: sdumitriu
Date: 2008-01-02 13:29:02 +0100 (Wed, 02 Jan 2008)
New Revision: 6582

Modified:
   
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/ClassPropertySetOperation.java
   
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/ContentDeleteOperation.java
   
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/ContentInsertOperation.java
   
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/OperationFactoryImpl.java
   
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/PropertySetOperation.java
Log:
XWIKI-1977: Create a patchservice data model
Better Factory implementation


Modified: 
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/ClassPropertySetOperation.java
===================================================================
--- 
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/ClassPropertySetOperation.java
      2008-01-02 12:21:33 UTC (rev 6581)
+++ 
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/ClassPropertySetOperation.java
      2008-01-02 12:29:02 UTC (rev 6582)
@@ -31,9 +31,9 @@
     private Map propertyConfig;
 
     static {
-        OperationFactoryImpl.getInstance().registerTypeProvider(
+        OperationFactoryImpl.registerTypeProvider(
             Operation.TYPE_CLASS_PROPERTY_ADD, 
ClassPropertySetOperation.class);
-        OperationFactoryImpl.getInstance().registerTypeProvider(
+        OperationFactoryImpl.registerTypeProvider(
             Operation.TYPE_CLASS_PROPERTY_CHANGE, 
ClassPropertySetOperation.class);
     }
 
@@ -140,7 +140,6 @@
         int i =
             new HashCodeBuilder(11, 
13).append(this.propertyType).append(this.propertyConfig)
                 .toHashCode();
-        System.out.print(" asd > " + i);
         return i;
     }
 

Modified: 
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/ContentDeleteOperation.java
===================================================================
--- 
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/ContentDeleteOperation.java
 2008-01-02 12:21:33 UTC (rev 6581)
+++ 
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/ContentDeleteOperation.java
 2008-01-02 12:29:02 UTC (rev 6582)
@@ -20,7 +20,7 @@
     private String removedContent;
 
     static {
-        
OperationFactoryImpl.getInstance().registerTypeProvider(Operation.TYPE_CONTENT_DELETE,
+        
OperationFactoryImpl.registerTypeProvider(Operation.TYPE_CONTENT_DELETE,
             ContentDeleteOperation.class);
     }
 

Modified: 
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/ContentInsertOperation.java
===================================================================
--- 
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/ContentInsertOperation.java
 2008-01-02 12:21:33 UTC (rev 6581)
+++ 
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/ContentInsertOperation.java
 2008-01-02 12:29:02 UTC (rev 6582)
@@ -19,7 +19,7 @@
     private String addedContent;
 
     static {
-        
OperationFactoryImpl.getInstance().registerTypeProvider(Operation.TYPE_CONTENT_INSERT,
+        
OperationFactoryImpl.registerTypeProvider(Operation.TYPE_CONTENT_INSERT,
             ContentInsertOperation.class);
     }
     

Modified: 
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/OperationFactoryImpl.java
===================================================================
--- 
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/OperationFactoryImpl.java
   2008-01-02 12:21:33 UTC (rev 6581)
+++ 
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/OperationFactoryImpl.java
   2008-01-02 12:29:02 UTC (rev 6582)
@@ -14,22 +14,18 @@
 
 import com.xpn.xwiki.XWikiException;
 
-public class OperationFactoryImpl implements OperationFactory
+public final class OperationFactoryImpl implements OperationFactory
 {
     private static final Log LOG = 
LogFactory.getLog(OperationFactoryImpl.class);
 
-    private static OperationFactoryImpl theInstance = new 
OperationFactoryImpl();
+    private static Map typeMap = new HashMap();
 
-    private static boolean initialized;
-
-    public Map typeMap = new HashMap();
-
-    private OperationFactoryImpl()
+    private static class SingletonHolder
     {
-        // Private constructor so that it cannot be instantiated.
+        private static OperationFactoryImpl theInstance = new 
OperationFactoryImpl();
     }
 
-    private static void init()
+    private OperationFactoryImpl()
     {
         for (Iterator it = Service.providers(RWOperation.class); 
it.hasNext();) {
             Operation op = (Operation) it.next();
@@ -40,15 +36,7 @@
 
     public static OperationFactoryImpl getInstance()
     {
-        if (!initialized) {
-            synchronized (OperationFactoryImpl.class) {
-                if (!initialized) {
-                    initialized = true;
-                    init();
-                }
-            }
-        }
-        return theInstance;
+        return SingletonHolder.theInstance;
     }
 
     public RWOperation newOperation(String type) throws XWikiException
@@ -82,15 +70,15 @@
         return op;
     }
 
-    public void registerTypeProvider(String type, Class provider)
+    public static void registerTypeProvider(String type, Class provider)
     {
-        this.typeMap.put(type, provider);
+        typeMap.put(type, provider);
     }
 
-    public void registerTypeProvider(String[] types, Class provider)
+    public static void registerTypeProvider(String[] types, Class provider)
     {
         for (int i = 0; i < types.length; ++i) {
-            this.registerTypeProvider(types[i], provider);
+            registerTypeProvider(types[i], provider);
         }
     }
 }

Modified: 
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/PropertySetOperation.java
===================================================================
--- 
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/PropertySetOperation.java
   2008-01-02 12:21:33 UTC (rev 6581)
+++ 
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/PropertySetOperation.java
   2008-01-02 12:29:02 UTC (rev 6582)
@@ -22,7 +22,7 @@
     private String propertyValue;
 
     static {
-        
OperationFactoryImpl.getInstance().registerTypeProvider(Operation.TYPE_PROPERTY_SET,
+        OperationFactoryImpl.registerTypeProvider(Operation.TYPE_PROPERTY_SET,
             PropertySetOperation.class);
     }
 

_______________________________________________
notifications mailing list
notifications@xwiki.org
http://lists.xwiki.org/mailman/listinfo/notifications

Reply via email to