Enhancements to FSR.

1) Performance imporvements (client and server are now multi-threaded + other performance work)
2) Pluggable transport protocols (ENH-145)
3) Changes to initialisation (ALFCOM-135)
4) Changes to the action service to enable multiple async event queues.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@11022 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Mark Rogers
2008-09-25 15:10:58 +00:00
parent 2a4b7c9eef
commit e98ab1750a
31 changed files with 1890 additions and 500 deletions

View File

@@ -112,11 +112,12 @@ public class ActionServiceImpl implements ActionService, RuntimeActionService, A
/** The authentication component */
private AuthenticationComponent authenticationComponent;
/**
* The asynchronous action execution queue
* The asynchronous action execution queues
* map of name, queue
*/
private AsynchronousActionExecutionQueue asynchronousActionExecutionQueue;
private Map<String, AsynchronousActionExecutionQueue> asynchronousActionExecutionQueues;
/**
* Action transaction listener
@@ -182,26 +183,16 @@ public class ActionServiceImpl implements ActionService, RuntimeActionService, A
{
this.dictionaryService = dictionaryService;
}
/**
* Set the asynchronous action execution queue
* Set the asynchronous action execution queues
*
* @param asynchronousActionExecutionQueue the asynchronous action execution queue
* @param asynchronousActionExecutionQueue the asynchronous action execution queues
*/
public void setAsynchronousActionExecutionQueue(
AsynchronousActionExecutionQueue asynchronousActionExecutionQueue)
public void setAsynchronousActionExecutionQueues(
Map<String, AsynchronousActionExecutionQueue> asynchronousActionExecutionQueues)
{
this.asynchronousActionExecutionQueue = asynchronousActionExecutionQueue;
}
/**
* Get the asychronous action execution queue
*
* @return the asynchronous action execution queue
*/
public AsynchronousActionExecutionQueue getAsynchronousActionExecutionQueue()
{
return asynchronousActionExecutionQueue;
this.asynchronousActionExecutionQueues = asynchronousActionExecutionQueues;
}
/**
@@ -404,6 +395,71 @@ public class ActionServiceImpl implements ActionService, RuntimeActionService, A
addPostTransactionPendingAction(action, actionedUponNodeRef, checkConditions, actionChain);
}
}
/**
* called by transaction service.
*/
public void postCommit()
{
for (PendingAction pendingAction : getPostTransactionPendingActions())
{
queueAction(pendingAction);
}
}
/**
*
*/
private void queueAction(PendingAction action)
{
// Get the right queue
AsynchronousActionExecutionQueue queue = getQueue(action.action);
// Queue the action for execution
queue.executeAction(
this,
action.getAction(),
action.getActionedUponNodeRef(),
action.getCheckConditions(),
action.getActionChain());
}
/**
*
* @param compensatingAction
* @param actionedUponNodeRef
*/
private void queueAction(Action compensatingAction, NodeRef actionedUponNodeRef)
{
// Get the right queue
AsynchronousActionExecutionQueue queue = getQueue(compensatingAction);
// Queue the action for execution
queue.executeAction(this, compensatingAction, actionedUponNodeRef, false, null);
}
private AsynchronousActionExecutionQueue getQueue(Action action)
{
ActionExecuter executer = (ActionExecuter)this.applicationContext.getBean(action.getActionDefinitionName());
AsynchronousActionExecutionQueue queue = null;
String queueName = executer.getQueueName();
if(queueName == null)
{
queue = asynchronousActionExecutionQueues.get("");
}
else
{
queue = asynchronousActionExecutionQueues.get(queueName);
}
if(queue == null)
{
// can't get queue
throw new ActionServiceException("Unable to get AsynchronousActionExecutionQueue name: "+ queueName);
}
return queue;
}
/**
* @see org.alfresco.repo.action.RuntimeActionService#executeActionImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef, boolean, org.alfresco.service.cmr.repository.NodeRef)
@@ -501,9 +557,7 @@ public class ActionServiceImpl implements ActionService, RuntimeActionService, A
{
// Set the current user
((ActionImpl)compensatingAction).setRunAsUser(currentUserName);
// Queue the compensating action ready for execution
this.asynchronousActionExecutionQueue.executeAction(this, compensatingAction, actionedUponNodeRef, false, null);
queueAction(compensatingAction, actionedUponNodeRef);
}
}
@@ -1195,7 +1249,7 @@ public class ActionServiceImpl implements ActionService, RuntimeActionService, A
* @see org.alfresco.repo.action.RuntimeActionService#getPostTransactionPendingActions()
*/
@SuppressWarnings("unchecked")
public List<PendingAction> getPostTransactionPendingActions()
private List<PendingAction> getPostTransactionPendingActions()
{
return (List<PendingAction>)AlfrescoTransactionSupport.getResource(POST_TRANSACTION_PENDING_ACTIONS);
}
@@ -1203,7 +1257,7 @@ public class ActionServiceImpl implements ActionService, RuntimeActionService, A
/**
* Pending action details class
*/
public class PendingAction
private class PendingAction
{
/**
* The action

View File

@@ -24,7 +24,6 @@
*/
package org.alfresco.repo.action;
import org.alfresco.repo.action.ActionServiceImpl.PendingAction;
import org.alfresco.repo.transaction.TransactionListener;
import org.alfresco.util.GUID;
@@ -81,15 +80,7 @@ public class ActionTransactionListener implements TransactionListener
*/
public void afterCommit()
{
for (PendingAction pendingAction : this.actionService.getPostTransactionPendingActions())
{
this.actionService.getAsynchronousActionExecutionQueue().executeAction(
actionService,
pendingAction.getAction(),
pendingAction.getActionedUponNodeRef(),
pendingAction.getCheckConditions(),
pendingAction.getActionChain());
}
this.actionService.postCommit();
}
/**

View File

@@ -24,10 +24,8 @@
*/
package org.alfresco.repo.action;
import java.util.List;
import java.util.Set;
import org.alfresco.repo.action.ActionServiceImpl.PendingAction;
import org.alfresco.repo.action.evaluator.ActionConditionEvaluator;
import org.alfresco.repo.action.executer.ActionExecuter;
import org.alfresco.service.cmr.action.Action;
@@ -39,12 +37,17 @@ import org.alfresco.service.namespace.QName;
*/
public interface RuntimeActionService
{
/**
*
*/
void postCommit();
/**
* Get the asynchronous action queue.
*
* @return the asynchronous action queue
*/
AsynchronousActionExecutionQueue getAsynchronousActionExecutionQueue();
//AsynchronousActionExecutionQueue getAsynchronousActionExecutionQueue();
/**
* Register an action condition evaluator
@@ -93,10 +96,10 @@ public interface RuntimeActionService
*/
public void directActionExecution(Action action, NodeRef actionedUponNodeRef);
/**
* Gets a list of the actions that are pending post transaction
*
* @return list of pending actions
*/
public List<PendingAction> getPostTransactionPendingActions();
// /**
// * Gets a list of the actions that are pending post transaction
// *
// * @return list of pending actions
// */
// public List<PendingAction> getPostTransactionPendingActions();
}

View File

@@ -54,4 +54,10 @@ public interface ActionExecuter
public void execute(
Action action,
NodeRef actionedUponNodeRef);
/**
* Get the queueName that will execute this action
*/
String getQueueName();
}

View File

@@ -53,6 +53,13 @@ public abstract class ActionExecuterAbstractBase extends ParameterizedItemAbstra
/** List of types and aspects for which this action is applicable */
protected List<QName> applicableTypes = new ArrayList<QName>();
/**
*
*/
private String queueName = "";
/**
* Init method
@@ -127,6 +134,18 @@ public abstract class ActionExecuterAbstractBase extends ParameterizedItemAbstra
* @param actionedUponNodeRef the actioned upon node
*/
protected abstract void executeImpl(Action action, NodeRef actionedUponNodeRef);
/**
* Set the queueName which will execute this action
* if blank or null then the action will be executed on the "default" queue
* @param the name of the execution queue which should execute this action.
*/
public void setQueueName(String queueName)
{
this.queueName = queueName;
}
public String getQueueName() {
return queueName;
}
}

View File

@@ -45,6 +45,7 @@ import org.alfresco.service.cmr.action.ParameterDefinition;
import org.alfresco.service.cmr.avm.deploy.DeploymentCallback;
import org.alfresco.service.cmr.avm.deploy.DeploymentEvent;
import org.alfresco.service.cmr.avm.deploy.DeploymentReport;
import org.alfresco.service.cmr.avm.deploy.DeploymentReportCallback;
import org.alfresco.service.cmr.avm.deploy.DeploymentService;
import org.alfresco.service.cmr.avmsync.AVMSyncException;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
@@ -72,6 +73,8 @@ public class AVMDeployWebsiteAction extends ActionExecuterAbstractBase
public static final String PARAM_SERVER = "server";
public static final String PARAM_ATTEMPT = "attempt";
public static final String PARAM_CALLBACK = "callback";
public static final String ASYNC_QUEUE_NAME = "deployment";
private int delay = -1;
private int defaultAlfRmiPort = 50500;
@@ -79,6 +82,7 @@ public class AVMDeployWebsiteAction extends ActionExecuterAbstractBase
private String defaultRemoteUsername = "admin";
private String defaultRemotePassword = "admin";
private String defaultTargetName = "default";
private String defaultAdapterName = "default";
private List<DeploymentCallback> configuredCallbacks;
private DeploymentService deployService;
private ContentService contentService;
@@ -275,6 +279,7 @@ public class AVMDeployWebsiteAction extends ActionExecuterAbstractBase
String sourcePath = (String)serverProps.get(WCMAppModel.PROP_DEPLOYSOURCEPATH);
String excludes = (String)serverProps.get(WCMAppModel.PROP_DEPLOYEXCLUDES);
String targetName = (String)serverProps.get(WCMAppModel.PROP_DEPLOYSERVERTARGET);
String adapterName = (String)serverProps.get(WCMAppModel.PROP_DEPLOYSERVERADPTERNAME);
String targetPath = path;
if (fileServerDeployment == false)
@@ -289,6 +294,12 @@ public class AVMDeployWebsiteAction extends ActionExecuterAbstractBase
targetPath = storePath[0] + "live:" + storePath[1];
}
}
else
{
if (adapterName == null) {
adapterName = defaultAdapterName;
}
}
// get defaults for data not provided in server node
if (port == null)
@@ -371,7 +382,10 @@ public class AVMDeployWebsiteAction extends ActionExecuterAbstractBase
// make the deploy call passing in the DeploymentCallback, if present
Throwable deployError = null;
DeploymentReport report = null;
DeploymentReport report = new DeploymentReport();
callbacks.add(new DeploymentReportCallback(report));
try
{
// overwrite the password before logging
@@ -384,8 +398,19 @@ public class AVMDeployWebsiteAction extends ActionExecuterAbstractBase
logger.debug("Performing file server deployment to " + host + ":" + port +
" using deploymentserver: " + serverProps);
report = this.deployService.deployDifferenceFS(version, path, host, port,
remoteUsername, remotePassword, targetName, regexMatcher, true, false, false, callbacks);
this.deployService.deployDifferenceFS(version,
path,
adapterName,
host,
port,
remoteUsername,
remotePassword,
targetName,
regexMatcher,
true,
false,
false,
callbacks);
}
else
{
@@ -393,14 +418,14 @@ public class AVMDeployWebsiteAction extends ActionExecuterAbstractBase
logger.debug("Performing Alfresco deployment to " + host + ":" + port +
" using deploymentserver: " + serverProps);
report = this.deployService.deployDifference(version, path, host, port,
remoteUsername, remotePassword, targetPath, regexMatcher, true, false, false, callbacks);
this.deployService.deployDifference(version, path, host, port,
remoteUsername, remotePassword, targetPath, regexMatcher, true, false, false, callbacks);
}
}
catch (Throwable err)
{
deployError = err;
logger.error(deployError);
logger.error("Deployment Error", deployError);
}
if (report != null)
@@ -458,7 +483,7 @@ public class AVMDeployWebsiteAction extends ActionExecuterAbstractBase
reportProps.put(WCMAppModel.PROP_DEPLOYSERVERURLUSED,
serverProps.get(WCMAppModel.PROP_DEPLOYSERVERURL));
reportProps.put(WCMAppModel.PROP_DEPLOYSUCCESSFUL, (report != null));
reportProps.put(WCMAppModel.PROP_DEPLOYSUCCESSFUL, (report != null) && (error == null));
if (report == null && error != null)
{
// add error message as fail reason if appropriate (the reported
@@ -515,4 +540,6 @@ public class AVMDeployWebsiteAction extends ActionExecuterAbstractBase
return reportRef;
}
}

View File

@@ -0,0 +1,55 @@
/*
* Copyright (C) 2005-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.repo.deploy;
import java.util.List;
import org.alfresco.deployment.DeploymentTransportOutputFilter;
/**
* Abstract Transport Adapter.
*
*/
public abstract class AbstractDeploymentReceiverTransportAdapter {
List<DeploymentTransportOutputFilter> transformers;
/**
* Get the content transformers for this transport - if the transport does not support
* content transformation then simply return null;
* @return the content transformers or null if there are no transformers.
*/
public List<DeploymentTransportOutputFilter>getTransformers() {
return transformers;
}
/**
* Set the content transformers for this transport - if the transport does not support
* content transformation then simply set null or do not call this method.
*/
public void setTransformers( List<DeploymentTransportOutputFilter> transformers) {
this.transformers = transformers;
}
}

View File

@@ -0,0 +1,125 @@
/*
* Copyright (C) 2005-2007 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.repo.deploy;
import java.io.IOException;
import java.io.OutputStream;
import org.alfresco.deployment.DeploymentReceiverTransport;
/**
* OutputStream used by client side to talk to
* the deployment receiver.
* @author britt
*/
public class DeploymentClientOutputStream extends OutputStream
{
private DeploymentReceiverTransport fTransport;
private String fTicket;
private String fOutputToken;
/**
* Make one up.
* @param transport
* @param ticket
* @param outputToken
*/
public DeploymentClientOutputStream(DeploymentReceiverTransport transport,
String ticket,
String outputToken)
{
fTransport = transport;
fTicket = ticket;
fOutputToken = outputToken;
}
/* (non-Javadoc)
* @see java.io.OutputStream#write(int)
*/
@Override
public void write(int b) throws IOException
{
byte[] buff = new byte[1];
buff[0] = (byte)b;
write(buff);
}
/* (non-Javadoc)
* @see java.io.OutputStream#close()
*/
@Override
public void close() throws IOException
{
// NO OP
}
/* (non-Javadoc)
* @see java.io.OutputStream#flush()
*/
@Override
public void flush() throws IOException
{
// NO OP
}
/* (non-Javadoc)
* @see java.io.OutputStream#write(byte[], int, int)
*/
@Override
public void write(byte[] b, int off, int len) throws IOException
{
fTransport.write(fTicket, fOutputToken, b, off, len);
}
/* (non-Javadoc)
* @see java.io.OutputStream#write(byte[])
*/
@Override
public void write(byte[] b) throws IOException
{
write(b, 0, b.length);
}
/**
* Get the deployment ticket.
* @return
*/
public String getTicket()
{
return fTicket;
}
/**
* Get the output token.
* @return
*/
public String getOutputToken()
{
return fOutputToken;
}
}

View File

@@ -0,0 +1,77 @@
/*
* Copyright (C) 2005-2007 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.repo.deploy;
/**
* Class to hold Deployment destination information.
* Used as a lock to serialize deployments to the same
* destination.
* @author britt
*/
public class DeploymentDestination
{
private String fHost;
private int fPort;
DeploymentDestination(String host, int port)
{
fHost = host;
fPort = port;
}
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj)
{
if (this == obj)
{
return true;
}
if (!(obj instanceof DeploymentDestination))
{
return false;
}
DeploymentDestination other = (DeploymentDestination)obj;
return fHost.equals(other.fHost) && fPort == other.fPort;
}
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode()
{
return fHost.hashCode() + fPort;
}
public String toString()
{
return fHost;
}
}

View File

@@ -0,0 +1,138 @@
/*
* Copyright (C) 2005-2007 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.repo.deploy;
import java.io.OutputStream;
import java.util.List;
import org.alfresco.deployment.DeploymentReceiverService;
import org.alfresco.deployment.DeploymentReceiverTransport;
import org.alfresco.deployment.FileDescriptor;
/**
* Client side implementation of DeploymentReceiverService which decorates a
* DeploymentReceiverTransport instance.
*
* This class adds code to the send and finishSend methods.
*
* @author britt
*/
public class DeploymentReceiverServiceClient implements
DeploymentReceiverService
{
/**
* The underlying transport.
*/
private DeploymentReceiverTransport fTransport;
public DeploymentReceiverServiceClient()
{
}
public void setDeploymentReceiverTransport(DeploymentReceiverTransport transport)
{
fTransport = transport;
}
/* (non-Javadoc)
* @see org.alfresco.deployment.DeploymentReceiverService#abort(java.lang.String)
*/
public void abort(String ticket)
{
fTransport.abort(ticket);
}
/* (non-Javadoc)
* @see org.alfresco.deployment.DeploymentReceiverService#begin(java.lang.String, java.lang.String, java.lang.String)
*/
public String begin(String target, String user, String password)
{
return fTransport.begin(target, user, password);
}
/* (non-Javadoc)
* @see org.alfresco.deployment.DeploymentReceiverService#commit(java.lang.String)
*/
public void commit(String ticket)
{
fTransport.commit(ticket);
}
/* (non-Javadoc)
* @see org.alfresco.deployment.DeploymentReceiverService#delete(java.lang.String, java.lang.String)
*/
public void delete(String ticket, String path)
{
fTransport.delete(ticket, path);
}
/* (non-Javadoc)
* @see org.alfresco.deployment.DeploymentReceiverService#finishSend(java.lang.String, java.io.OutputStream)
*/
public void finishSend(String ticket, OutputStream out)
{
DeploymentClientOutputStream dcOut = (DeploymentClientOutputStream)out;
fTransport.finishSend(dcOut.getTicket(), dcOut.getOutputToken());
}
/* (non-Javadoc)
* @see org.alfresco.deployment.DeploymentReceiverService#getListing(java.lang.String, java.lang.String)
*/
public List<FileDescriptor> getListing(String ticket, String path)
{
return fTransport.getListing(ticket, path);
}
/* (non-Javadoc)
* @see org.alfresco.deployment.DeploymentReceiverService#mkdir(java.lang.String, java.lang.String, java.lang.String)
*/
public void mkdir(String ticket, String path, String guid)
{
fTransport.mkdir(ticket, path, guid);
}
/* (non-Javadoc)
* @see org.alfresco.deployment.DeploymentReceiverService#send(java.lang.String, java.lang.String, java.lang.String)
*/
public OutputStream send(String ticket, String path, String guid)
{
String outputToken = fTransport.getSendToken(ticket, path, guid);
return new DeploymentClientOutputStream(fTransport, ticket, outputToken);
}
/* (non-Javadoc)
* @see org.alfresco.deployment.DeploymentReceiverService#shutDown(java.lang.String, java.lang.String)
*/
public void shutDown(String user, String password)
{
fTransport.shutDown(user, password);
}
public void setGuid(String ticket, String path, String guid)
{
fTransport.setGuid(ticket, path, guid);
}
}

View File

@@ -0,0 +1,69 @@
/*
* Copyright (C) 2005-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.repo.deploy;
import java.util.List;
import org.alfresco.deployment.DeploymentReceiverTransport;
import org.alfresco.deployment.DeploymentTransportOutputFilter;
/**
*
* DeploymentReceiverTransportAdapter are used to adapt the interface used by the FSR Client to the
* interface used by the underlying transport implementation.
*
* The DeploymentReceiverTransport objects returned will typically be proxy classes to a remote service.
*
* @see org.alfresco.deployment.impl.client.DeploymentReceiverTransportAdapterRMI
* @see org.alfresco.deployment.impl.client.DeploymentReceiverTransportAdapterSpringHTTP
* @see org.alfresco.deployment.impl.client.DeploymentReceiverTransportAdapterHessian
*
* @author mrogers
*
*/
public interface DeploymentReceiverTransportAdapter
{
/**
* getObject is a factory method to get a DeploymentReceiverTransport object, which will typically
* be a proxy to a remote service.
*
* It is up to the adapters themselves to decide whether hostName, port or URL takes precedence.
*
* @param adapterName the name of this adapter
* @param hostName the name of the host to connect to
* @param port the port to connect to
* @param version the version of the website
* @param the path of the website to be deployed
* @return a DeploymentRecieverTransport
*/
public DeploymentReceiverTransport getTransport(String hostName, int port, int version, String srcPath);
/**
* Get the content transformers for this transport - if the transport does not support
* content transformation then simply return null;
* @return the content transformers or null if there are no transformers.
*/
public List<DeploymentTransportOutputFilter>getTransformers();
}

View File

@@ -0,0 +1,71 @@
/*
* Copyright (C) 2005-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.repo.deploy;
import java.text.MessageFormat;
import org.alfresco.deployment.DeploymentReceiverTransport;
import org.springframework.remoting.caucho.HessianProxyFactoryBean;
/**
* This class adapts the Hessian protocol to DeploymentReceiverTransport
*
* @author mrogers
*/
public class DeploymentReceiverTransportAdapterHessian extends AbstractDeploymentReceiverTransportAdapter implements DeploymentReceiverTransportAdapter
{
/**
* The pattern to use when constructing the URL from hostname and port
*
* eg http://localhost:8080/FSR/deployment
*/
private String urlPattern = "http://{1}:{2}/FSR/deployment";
public DeploymentReceiverTransport getTransport(String host,
int port, int version, String srcPath)
{
MessageFormat f = new MessageFormat(urlPattern);
Object[] objs = { host, port };
String URL = f.format(objs);
// Code to use Hessian transport provided via Spring
HessianProxyFactoryBean factory = new HessianProxyFactoryBean();
factory.setServiceInterface(DeploymentReceiverTransport.class);
factory.setServiceUrl(URL);
factory.afterPropertiesSet();
DeploymentReceiverTransport transport = (DeploymentReceiverTransport) factory.getObject();
return transport;
}
public void setUrlPattern(String urlPattern) {
this.urlPattern = urlPattern;
}
public String getUrlPattern() {
return urlPattern;
}
}

View File

@@ -0,0 +1,53 @@
/*
* Copyright (C) 2005-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.repo.deploy;
import org.alfresco.deployment.DeploymentReceiverTransport;
import org.springframework.remoting.rmi.RmiProxyFactoryBean;
/**
* Transport adapter to connect to the FSR using RMI protocol.
*
* @author mrogers
*
*/
public class DeploymentReceiverTransportAdapterRMI extends AbstractDeploymentReceiverTransportAdapter implements DeploymentReceiverTransportAdapter {
public DeploymentReceiverTransport getTransport(String hostName,
int port, int version, String srcPath)
{
// Code to use RMI transport
RmiProxyFactoryBean factory = new RmiProxyFactoryBean();
factory.setRefreshStubOnConnectFailure(true);
factory.setServiceInterface(DeploymentReceiverTransport.class);
factory.setServiceUrl("rmi://" + hostName + ":" + port + "/deployment");
factory.afterPropertiesSet();
DeploymentReceiverTransport transport = (DeploymentReceiverTransport)factory.getObject();
return transport;
}
}

View File

@@ -0,0 +1,72 @@
/*
* Copyright (C) 2005-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.repo.deploy;
import java.text.MessageFormat;
import org.alfresco.deployment.DeploymentReceiverTransport;
import org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean;
/**
* Transport adapter to connect to the FSR using Spring over HTTP protocol.
*
* @author mrogers
*
*/
public class DeploymentReceiverTransportAdapterSpringHTTP extends AbstractDeploymentReceiverTransportAdapter implements DeploymentReceiverTransportAdapter {
/**
* The pattern to use when constructing the URL from hostname and port
* {1} substitues for hostname {2} substitues for port
* Default format results in the following URL http://localhost:8080/alfrescoFSR/deployment
*/
private String urlPattern = "http://{1}:{2}/alfrescoFSR/deployment";
public DeploymentReceiverTransport getTransport(String host,
int port, int version, String srcPath)
{
MessageFormat f = new MessageFormat(getUrlPattern());
Object[] objs = { host, port };
String URL = f.format(objs);
// Code to use HTTP spring transport
HttpInvokerProxyFactoryBean factory = new HttpInvokerProxyFactoryBean();
factory.setServiceInterface(DeploymentReceiverTransport.class);
factory.setServiceUrl(URL);
factory.afterPropertiesSet();
DeploymentReceiverTransport transport = (DeploymentReceiverTransport) factory.getObject();
return transport;
}
public void setUrlPattern(String urlPattern) {
this.urlPattern = urlPattern;
}
public String getUrlPattern() {
return urlPattern;
}
}

View File

@@ -0,0 +1,68 @@
/*
* Copyright (C) 2005-2007 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.repo.deploy;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.cmr.avm.deploy.DeploymentEvent;
class DeploymentWork
{
private DeploymentEvent event;
private AVMNodeDescriptor src;
private String ticket;
public DeploymentWork(DeploymentEvent event, String ticket)
{
this.event = event;
this.ticket = ticket;
}
public DeploymentWork(DeploymentEvent event, String ticket, AVMNodeDescriptor src)
{
this.event = event;
this.ticket = ticket;
this.setSrc(src);
}
public DeploymentEvent getEvent()
{
return event;
}
public String getTicket()
{
return this.ticket;
}
public void setSrc(AVMNodeDescriptor src) {
this.src = src;
}
public AVMNodeDescriptor getSrc() {
return src;
}
}

View File

@@ -26,11 +26,15 @@
package org.alfresco.repo.deploy;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import org.alfresco.repo.avm.AVMServiceTestBase;
import org.alfresco.repo.avm.util.BulkLoader;
import org.alfresco.service.cmr.avm.deploy.DeploymentCallback;
import org.alfresco.service.cmr.avm.deploy.DeploymentEvent;
import org.alfresco.service.cmr.avm.deploy.DeploymentReport;
import org.alfresco.service.cmr.avm.deploy.DeploymentReportCallback;
import org.alfresco.service.cmr.avm.deploy.DeploymentService;
import org.alfresco.util.Deleter;
import org.alfresco.util.NameMatcher;
@@ -62,7 +66,11 @@ public class FSDeploymentTest extends AVMServiceTestBase
NameMatcher matcher = (NameMatcher)fContext.getBean("globalPathExcluder");
setupBasicTree();
fService.createFile("main:/a/b", "fudge.bak").close();
DeploymentReport report = service.deployDifferenceFS(-1, "main:/", "localhost", 44100, "Giles", "Watcher", "sampleTarget", matcher, false, false, false, null);
DeploymentReport report = new DeploymentReport();
List<DeploymentCallback> callbacks = new ArrayList<DeploymentCallback>();
callbacks.add(new DeploymentReportCallback(report));
service.deployDifferenceFS(-1, "main:/", "localhost", "default", 44100, "Giles", "Watcher", "sampleTarget", matcher, false, false, false, callbacks);
int count = 0;
for (DeploymentEvent event : report)
{
@@ -70,7 +78,14 @@ public class FSDeploymentTest extends AVMServiceTestBase
count++;
}
assertEquals(10, count);
report = service.deployDifferenceFS(-1, "main:/", "localhost", 44100, "Giles", "Watcher", "sampleTarget", matcher, false, false, false, null);
report = new DeploymentReport();
callbacks = new ArrayList<DeploymentCallback>();
callbacks.add(new DeploymentReportCallback(report));
callbacks.add(new DeploymentReportCallback(report));
service.deployDifferenceFS(-1, "main:/", "localhost", "default", 44100, "Giles", "Watcher", "sampleTarget", matcher, false, false, false, callbacks);
count = 0;
for (DeploymentEvent event : report)
{
@@ -80,7 +95,13 @@ public class FSDeploymentTest extends AVMServiceTestBase
assertEquals(2, count);
fService.createFile("main:/d", "jonathan").close();
fService.removeNode("main:/a/b");
report = service.deployDifferenceFS(-1, "main:/", "localhost", 44100, "Giles", "Watcher", "sampleTarget", matcher, false, false, false, null);
report = new DeploymentReport();
callbacks = new ArrayList<DeploymentCallback>();
callbacks.add(new DeploymentReportCallback(report));
service.deployDifferenceFS(-1, "main:/", "localhost", "default", 44100, "Giles", "Watcher", "sampleTarget", matcher, false, false, false, callbacks);
count = 0;
for (DeploymentEvent event : report)
{
@@ -90,7 +111,12 @@ public class FSDeploymentTest extends AVMServiceTestBase
assertEquals(4, count);
fService.removeNode("main:/d/e");
fService.createFile("main:/d", "e").close();
report = service.deployDifferenceFS(-1, "main:/", "localhost", 44100, "Giles", "Watcher", "sampleTarget", matcher, false, false, false, null);
report = new DeploymentReport();
callbacks = new ArrayList<DeploymentCallback>();
callbacks.add(new DeploymentReportCallback(report));
service.deployDifferenceFS(-1, "main:/", "localhost", "default", 44100, "Giles", "Watcher", "sampleTarget", matcher, false, false, false, callbacks);
count = 0;
for (DeploymentEvent event : report)
{
@@ -102,7 +128,11 @@ public class FSDeploymentTest extends AVMServiceTestBase
fService.createDirectory("main:/d", "e");
fService.createFile("main:/d/e", "Warren.txt").close();
fService.createFile("main:/d/e", "It's a silly name.txt").close();
report = service.deployDifferenceFS(-1, "main:/", "localhost", 44100, "Giles", "Watcher", "sampleTarget", matcher, false, false, false, null);
report = new DeploymentReport();
callbacks = new ArrayList<DeploymentCallback>();
callbacks.add(new DeploymentReportCallback(report));
service.deployDifferenceFS(-1, "main:/", "localhost", "default", 44100, "Giles", "Watcher", "sampleTarget", matcher, false, false, false, callbacks);
count = 0;
for (DeploymentEvent event : report)
{
@@ -113,10 +143,18 @@ public class FSDeploymentTest extends AVMServiceTestBase
BulkLoader loader = new BulkLoader();
loader.setAvmService(fService);
loader.recursiveLoad("source/java/org/alfresco/repo/avm", "main:/");
report = service.deployDifferenceFS(-1, "main:/", "localhost", 44100, "Giles", "Watcher", "sampleTarget", matcher, false, false, false, null);
report = new DeploymentReport();
callbacks = new ArrayList<DeploymentCallback>();
callbacks.add(new DeploymentReportCallback(report));
service.deployDifferenceFS(-1, "main:/", "localhost", "default", 44100, "Giles", "Watcher", "sampleTarget", matcher, false, false, false, callbacks);
fService.removeNode("main:/avm/hibernate");
fService.getFileOutputStream("main:/avm/AVMServiceTest.java").close();
report = service.deployDifferenceFS(-1, "main:/", "localhost", 44100, "Giles", "Watcher", "sampleTarget", matcher, false, false, false, null);
report = new DeploymentReport();
callbacks = new ArrayList<DeploymentCallback>();
callbacks.add(new DeploymentReportCallback(report));
service.deployDifferenceFS(-1, "main:/", "localhost", "default", 44100, "Giles", "Watcher", "sampleTarget", matcher, false, false, false, callbacks);
count = 0;
for (DeploymentEvent event : report)
{

View File

@@ -34,6 +34,7 @@ import org.alfresco.service.cmr.action.ActionService;
import org.alfresco.service.cmr.attributes.AttributeService;
import org.alfresco.service.cmr.audit.AuditService;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.avm.deploy.DeploymentService;
import org.alfresco.service.cmr.avm.locking.AVMLockingService;
import org.alfresco.service.cmr.avmsync.AVMSyncService;
import org.alfresco.service.cmr.coci.CheckOutCheckInService;
@@ -451,4 +452,14 @@ public class ServiceDescriptorRegistry
{
return (TaggingService)getService(TAGGING_SERVICE);
}
/* (non-Javadoc)
* @see org.alfresco.service.ServiceRegistry#getDeploymentService()
*/
public DeploymentService getDeploymentService() {
return (DeploymentService) getService(DEPLOYMENT_SERVICE);
}
}