diff --git a/config/alfresco/network-protocol-context.xml b/config/alfresco/network-protocol-context.xml
index 0c15255cd3..95cfb77064 100644
--- a/config/alfresco/network-protocol-context.xml
+++ b/config/alfresco/network-protocol-context.xml
@@ -79,6 +79,14 @@
+
+
+
+
+
+
+
+
diff --git a/source/java/org/alfresco/filesys/repo/ContentContext.java b/source/java/org/alfresco/filesys/repo/ContentContext.java
index a9049c9ba9..9c2a79e5b3 100644
--- a/source/java/org/alfresco/filesys/repo/ContentContext.java
+++ b/source/java/org/alfresco/filesys/repo/ContentContext.java
@@ -144,12 +144,12 @@ public class ContentContext extends AlfrescoContext
}
/**
- * Create the node monitor
+ * Set the node monitor
*
* @param filesysDriver ContentDiskDriver
*/
- protected void createNodeMonitor( ContentDiskDriver filesysDriver) {
- m_nodeMonitor = new NodeMonitor( filesysDriver, this);
+ protected void setNodeMonitor( NodeMonitor nodeMonitor) {
+ m_nodeMonitor = nodeMonitor;
}
/**
diff --git a/source/java/org/alfresco/filesys/repo/ContentDiskDriver.java b/source/java/org/alfresco/filesys/repo/ContentDiskDriver.java
index 8067e6aa13..c3db451569 100644
--- a/source/java/org/alfresco/filesys/repo/ContentDiskDriver.java
+++ b/source/java/org/alfresco/filesys/repo/ContentDiskDriver.java
@@ -121,7 +121,9 @@ public class ContentDiskDriver extends AlfrescoDiskDriver implements DiskInterfa
private AuthenticationComponent authComponent;
private AuthenticationService authService;
- private PolicyComponent policyComponent;
+ // Node monitor factory
+
+ private NodeMonitorFactory m_nodeMonitorFactory;
// Lock manager
@@ -223,15 +225,6 @@ public class ContentDiskDriver extends AlfrescoDiskDriver implements DiskInterfa
return this.permissionService;
}
- /**
- * Return the policy component
- *
- * @return PolicyComponent
- */
- public final PolicyComponent getPolicyComponent() {
- return this.policyComponent;
- }
-
/**
* @param contentService the content service
*/
@@ -313,12 +306,12 @@ public class ContentDiskDriver extends AlfrescoDiskDriver implements DiskInterfa
}
/**
- * Set the policy component
+ * Set the node monitor factory
*
- * @param policyComponent PolicyComponent
+ * @param nodeMonitorFactory NodeMonitorFactory
*/
- public void setPolicyComponent(PolicyComponent policyComponent) {
- this.policyComponent = policyComponent;
+ public void setNodeMonitorFactory(NodeMonitorFactory nodeMonitorFactory) {
+ m_nodeMonitorFactory = nodeMonitorFactory;
}
/**
@@ -548,11 +541,12 @@ public class ContentDiskDriver extends AlfrescoDiskDriver implements DiskInterfa
// Install the node service monitor
- if ( cfg.getChild("disableNodeMonitor") == null) {
+ if ( cfg.getChild("disableNodeMonitor") == null && m_nodeMonitorFactory != null) {
// Create the node monitor
-
- context.createNodeMonitor( this);
+
+ NodeMonitor nodeMonitor = m_nodeMonitorFactory.createNodeMonitor( this, context);
+ context.setNodeMonitor( nodeMonitor);
}
// Return the context for this shared filesystem
diff --git a/source/java/org/alfresco/filesys/repo/NodeMonitor.java b/source/java/org/alfresco/filesys/repo/NodeMonitor.java
index fada4dbb9c..0a495b47f8 100644
--- a/source/java/org/alfresco/filesys/repo/NodeMonitor.java
+++ b/source/java/org/alfresco/filesys/repo/NodeMonitor.java
@@ -118,10 +118,19 @@ public class NodeMonitor extends TransactionListenerAdapter
* @param filesysDriver ContentDiskDriver
* @param filesysCtx ContentContext
*/
- public NodeMonitor( ContentDiskDriver filesysDriver, ContentContext filesysCtx) {
+ protected NodeMonitor( ContentDiskDriver filesysDriver, ContentContext filesysCtx, NodeService nodeService, PolicyComponent policyComponent,
+ FileFolderService fileFolderService, PermissionService permissionService, TransactionService transService) {
m_filesysDriver = filesysDriver;
m_filesysCtx = filesysCtx;
+ // Set various services
+
+ m_nodeService = nodeService;
+ m_policyComponent = policyComponent;
+ m_fileFolderService = fileFolderService;
+ m_permissionService = permissionService;
+ m_transService = transService;
+
// Initialize the node monitor
init();
@@ -132,14 +141,6 @@ public class NodeMonitor extends TransactionListenerAdapter
*/
public final void init() {
- // Get various services via the filesystem driver
-
- m_nodeService = m_filesysDriver.getNodeService();
- m_policyComponent = m_filesysDriver.getPolicyComponent();
- m_fileFolderService = m_filesysDriver.getFileFolderService();
- m_permissionService = m_filesysDriver.getPermissionService();
- m_transService = m_filesysDriver.getTransactionService();
-
// Disable change notifications from the file server
m_filesysCtx.setFileServerNotifications( false);
diff --git a/source/java/org/alfresco/filesys/repo/NodeMonitorFactory.java b/source/java/org/alfresco/filesys/repo/NodeMonitorFactory.java
new file mode 100644
index 0000000000..0108406969
--- /dev/null
+++ b/source/java/org/alfresco/filesys/repo/NodeMonitorFactory.java
@@ -0,0 +1,166 @@
+/*
+ * Copyright (C) 2006-2008 Alfresco Software Limited.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ * As a special exception to the terms and conditions of version 2.0 of
+ * the GPL, you may redistribute this Program in connection with Free/Libre
+ * and Open Source Software ("FLOSS") applications as described in Alfresco's
+ * FLOSS exception. You should have recieved a copy of the text describing
+ * the FLOSS exception, and it is also available here:
+ * http://www.alfresco.com/legal/licensing"
+ */
+
+package org.alfresco.filesys.repo;
+
+import javax.transaction.UserTransaction;
+
+import org.alfresco.repo.policy.PolicyComponent;
+import org.alfresco.service.cmr.model.FileFolderService;
+import org.alfresco.service.cmr.repository.NodeService;
+import org.alfresco.service.cmr.security.PermissionService;
+import org.alfresco.service.transaction.TransactionService;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Node Monitor Factory Class
+ *
+ * @author gkspencer
+ */
+public class NodeMonitorFactory {
+
+ // Logging
+
+ private static final Log logger = LogFactory.getLog(NodeMonitorFactory.class);
+
+ // Services/components
+
+ private PolicyComponent m_policyComponent;
+ private NodeService m_nodeService;
+ private FileFolderService m_fileFolderService;
+ private PermissionService m_permissionService;
+ private TransactionService m_transService;
+
+ /**
+ * Default constructor
+ */
+ public NodeMonitorFactory () {
+ }
+
+ /**
+ * Create a node monitor
+ *
+ * @param filesysDriver ContentDiskDriver
+ * @param filesysCtx ContentContext
+ */
+ public NodeMonitor createNodeMonitor( ContentDiskDriver filesysDriver, ContentContext filesysCtx) {
+
+ // Initialization needs a transaction
+
+ UserTransaction tx = m_transService.getUserTransaction(true);
+ NodeMonitor nodeMonitor = null;
+
+ try {
+
+ // Start the transaction
+
+ tx.begin();
+
+ // Create the node monitor
+
+ nodeMonitor = new NodeMonitor( filesysDriver, filesysCtx, m_nodeService, m_policyComponent, m_fileFolderService,
+ m_permissionService, m_transService);
+
+ // Commit the transaction
+
+ tx.commit();
+ tx = null;
+ }
+ catch ( Exception ex) {
+ logger.error(ex);
+ }
+ finally {
+
+ // If there is an active transaction then roll it back
+
+ if ( tx != null)
+ {
+ try
+ {
+ tx.rollback();
+ }
+ catch (Exception ex)
+ {
+ logger.warn("Failed to rollback transaction", ex);
+ }
+ }
+ }
+
+ // Return the node monitor
+
+ return nodeMonitor;
+ }
+
+ /**
+ * Set the node service
+ *
+ * @param nodeService the node service
+ */
+ public void setNodeService(NodeService nodeService)
+ {
+ m_nodeService = nodeService;
+ }
+
+ /**
+ * Set the permission service
+ *
+ * @param permissionService PermissionService
+ */
+ public void setPermissionService(PermissionService permissionService)
+ {
+ m_permissionService = permissionService;
+ }
+
+ /**
+ * Set the file folder service
+ *
+ * @param fileService FileFolderService
+ */
+ public void setFileFolderService(FileFolderService fileService)
+ {
+ m_fileFolderService = fileService;
+ }
+
+ /**
+ * Set the policy component
+ *
+ * @param policyComponent PolicyComponent
+ */
+ public void setPolicyComponent(PolicyComponent policyComponent) {
+ m_policyComponent = policyComponent;
+ }
+
+ /**
+ * Set the transaction service
+ *
+ * @param transactionService the transaction service
+ */
+ public void setTransactionService(TransactionService transactionService)
+ {
+ m_transService = transactionService;
+ }
+
+}