Remove use of public services from filesystem node monitor.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@10316 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Gary Spencer
2008-08-12 10:23:56 +00:00
parent dda0c7ea51
commit 90fe218266
5 changed files with 198 additions and 29 deletions

View File

@@ -79,6 +79,14 @@
<property name="fileFolderService"><ref bean="FileFolderService" /></property>
<property name="serviceRegistry"><ref bean="ServiceRegistry"/></property>
<property name="stateReaper"><ref bean="fileStateReaper"/></property>
<property name="nodeMonitorFactory"><ref bean="nodeMonitorFactory"/></property>
</bean>
<bean id="nodeMonitorFactory" class="org.alfresco.filesys.repo.NodeMonitorFactory">
<property name="transactionService"><ref bean="transactionService" /></property>
<property name="nodeService"><ref bean="nodeService" /></property>
<property name="fileFolderService"><ref bean="fileFolderService" /></property>
<property name="permissionService"><ref bean="permissionService"/></property>
<property name="policyComponent"><ref bean="policyComponent"/></property>
</bean>

View File

@@ -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;
}
/**

View File

@@ -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

View File

@@ -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);

View File

@@ -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;
}
}