jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From marti...@apache.org
Subject svn commit: r789257 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core: ./ state/ version/
Date Mon, 29 Jun 2009 08:32:23 GMT
Author: martijnh
Date: Mon Jun 29 08:32:23 2009
New Revision: 789257

URL: http://svn.apache.org/viewvc?rev=789257&view=rev
Log:
JCR-2168 Avoid premature publication of XAItemStateManager

* Replaced public constructors by a factory methods and moved the registration to the fcatory
method.

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/XAWorkspace.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/LocalItemStateManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/XAItemStateManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/XAVersionManager.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java?rev=789257&r1=789256&r2=789257&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java
Mon Jun 29 08:32:23 2009
@@ -913,7 +913,7 @@
      * @return local item state manager
      */
     protected LocalItemStateManager createItemStateManager(SharedItemStateManager shared)
{
-        return new LocalItemStateManager(shared, this, rep.getItemStateCacheFactory());
+        return LocalItemStateManager.createInstance(shared, this, rep.getItemStateCacheFactory());
     }
 
     //------------------------------------------< EventStateCollectionFactory >

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/XAWorkspace.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/XAWorkspace.java?rev=789257&r1=789256&r2=789257&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/XAWorkspace.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/XAWorkspace.java
Mon Jun 29 08:32:23 2009
@@ -45,6 +45,6 @@
      * {@inheritDoc}
      */
     protected LocalItemStateManager createItemStateManager(SharedItemStateManager shared)
{
-        return new XAItemStateManager(shared, this, rep.getItemStateCacheFactory());
+        return XAItemStateManager.createInstance(shared, this, null, rep.getItemStateCacheFactory());
     }
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/LocalItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/LocalItemStateManager.java?rev=789257&r1=789256&r2=789257&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/LocalItemStateManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/LocalItemStateManager.java
Mon Jun 29 08:32:23 2009
@@ -67,13 +67,27 @@
      * @param sharedStateMgr shared state manager
      * @param factory event state collection factory
      */
-    public LocalItemStateManager(SharedItemStateManager sharedStateMgr,
+    protected LocalItemStateManager(SharedItemStateManager sharedStateMgr,
                                  EventStateCollectionFactory factory, ItemStateCacheFactory
cacheFactory) {
         cache = new ItemStateReferenceCache(cacheFactory);
         this.sharedStateMgr = sharedStateMgr;
         this.factory = factory;
+    }
 
-        sharedStateMgr.addListener(this);
+    /**
+     * Creates a new {@code LocalItemStateManager} instance and registers it as an {@link
ItemStateListener}
+     * with the given {@link SharedItemStateManager}. 
+     * 
+     * @param sharedStateMgr the {@link SharedItemStateManager}
+     * @param factory the {@link EventStateCollectionFactory}
+     * @param cacheFactory the {@link ItemStateCacheFactory}
+     * @return a new {@code LocalItemStateManager} instance
+     */
+    public static LocalItemStateManager createInstance(SharedItemStateManager sharedStateMgr,
+            EventStateCollectionFactory factory, ItemStateCacheFactory cacheFactory) {
+        LocalItemStateManager mgr = new LocalItemStateManager(sharedStateMgr, factory, cacheFactory);
+        sharedStateMgr.addListener(mgr);
+        return mgr;
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/XAItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/XAItemStateManager.java?rev=789257&r1=789256&r2=789257&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/XAItemStateManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/XAItemStateManager.java
Mon Jun 29 08:32:23 2009
@@ -83,30 +83,39 @@
     private VirtualItemStateProvider virtualProvider;
 
     /**
-     * Creates a new instance of this class.
-     *
-     * @param sharedStateMgr shared state manager
-     * @param factory        event state collection factory
-     */
-    public XAItemStateManager(SharedItemStateManager sharedStateMgr,
-                              EventStateCollectionFactory factory, ItemStateCacheFactory
cacheFactory) {
-        this(sharedStateMgr, factory, DEFAULT_ATTRIBUTE_NAME, cacheFactory);
-    }
-
-    /**
      * Creates a new instance of this class with a custom attribute name.
      *
      * @param sharedStateMgr shared state manager
      * @param factory        event state collection factory
-     * @param attributeName  attribute name
+     * @param attributeName  the attribute name, if {@code null} then a default name is used
      */
-    public XAItemStateManager(SharedItemStateManager sharedStateMgr,
+    private XAItemStateManager(SharedItemStateManager sharedStateMgr,
                               EventStateCollectionFactory factory,
                               String attributeName,
                               ItemStateCacheFactory cacheFactory) {
         super(sharedStateMgr, factory, cacheFactory);
+        if (attributeName != null) {
+            this.attributeName = attributeName;
+        } else {
+            this.attributeName = DEFAULT_ATTRIBUTE_NAME;
+        }
+    }
 
-        this.attributeName = attributeName;
+    /**
+     * Creates a new {@code XAItemStateManager} instance and registers it as an {@link ItemStateListener}
+     * with the given {@link SharedItemStateManager}. 
+     * 
+     * @param sharedStateMgr the {@link SharedItemStateManager}
+     * @param factory the {@link EventStateCollectionFactory}
+     * @param attributeName the attribute name, if {@code null} then a default name is used
+     * @param cacheFactory the {@link ItemStateCacheFactory}
+     * @return a new {@code XAItemStateManager} instance
+     */
+    public static XAItemStateManager createInstance(SharedItemStateManager sharedStateMgr,
+            EventStateCollectionFactory factory, String attributeName, ItemStateCacheFactory
cacheFactory) {
+        XAItemStateManager mgr = new XAItemStateManager(sharedStateMgr, factory, attributeName,
cacheFactory);
+        sharedStateMgr.addListener(mgr);
+        return mgr;
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java?rev=789257&r1=789256&r2=789257&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
Mon Jun 29 08:32:23 2009
@@ -203,7 +203,7 @@
 
             sharedStateMgr = createItemStateManager(pMgr, storageId, ntReg, cacheFactory,
ismLocking);
 
-            stateMgr = new LocalItemStateManager(sharedStateMgr, escFactory, cacheFactory);
+            stateMgr = LocalItemStateManager.createInstance(sharedStateMgr, escFactory, cacheFactory);
             stateMgr.addListener(this);
 
             NodeState nodeState = (NodeState) stateMgr.getItemState(storageId);

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/XAVersionManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/XAVersionManager.java?rev=789257&r1=789256&r2=789257&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/XAVersionManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/XAVersionManager.java
Mon Jun 29 08:32:23 2009
@@ -112,7 +112,7 @@
         super(ntReg);
         this.vMgr = vMgr;
         this.session = session;
-        this.stateMgr = new XAItemStateManager(vMgr.getSharedStateMgr(),
+        this.stateMgr = XAItemStateManager.createInstance(vMgr.getSharedStateMgr(),
                 this, CHANGE_LOG_ATTRIBUTE_NAME, cacheFactory);
 
         NodeState state;



Mime
View raw message