String systemId = IdGenerator.generate();
String props = channelConfig.replaceAll(IP_ADRESS_TEMPLATE, bindIPAddress);
// get workspace container
WorkspaceContainer wContainer =
(WorkspaceContainer)jcrRepository.getSystemSession(workspaces[wIndex]).getContainer();
String uniqueNoame = jcrRepository.getName() + "_" + workspaces[wIndex];
if (testMode != null && "true".equals(testMode))
uniqueNoame = "Test_Channel234";
ReplicationChannelManager channelManager =
new ReplicationChannelManager(props, channelName + (channelName.equals("") ? "" : "_")
+ uniqueNoame);
WorkspaceContainerFacade wsFacade = jcrRepository.getWorkspaceContainer(workspaces[wIndex]);
WorkspaceEntry wconf = (WorkspaceEntry)wsFacade.getComponent(WorkspaceEntry.class);
int maxBufferSize =
wconf.getContainer().getParameterInteger(WorkspaceDataContainer.MAXBUFFERSIZE_PROP,
WorkspaceDataContainer.DEF_MAXBUFFERSIZE);
WorkspaceFileCleanerHolder wfcleaner =
(WorkspaceFileCleanerHolder)wsFacade.getComponent(WorkspaceFileCleanerHolder.class);
FileCleaner fileCleaner = wfcleaner.getFileCleaner();
// create the RecoveryManager
RecoveryManager recoveryManager =
new RecoveryManager(dir, ownName, systemId, participantsClusterList, waitConfirmation,
jcrRepository.getName(), workspaces[wIndex], channelManager, fileCleaner, maxBufferSize,
new ReaderSpoolFileHolder());
PersistentDataManager dataManager =
(PersistentDataManager)wsFacade.getComponent(PersistentDataManager.class);
ConnectionFailDetector failDetector =
new ConnectionFailDetector(channelManager, dataManager, recoveryManager, ownPriority,
participantsClusterList, ownName, priprityType, workspaces[wIndex]);
channelManager.addStateListener(failDetector);
// add data transmitter
wContainer.registerComponentImplementation(WorkspaceDataTransmitter.class);
WorkspaceDataTransmitter dataTransmitter =
(WorkspaceDataTransmitter)wContainer.getComponentInstanceOfType(WorkspaceDataTransmitter.class);
dataTransmitter.init(/* disp */channelManager, systemId, ownName, recoveryManager);
// add data receiver
AbstractWorkspaceDataReceiver dataReceiver = null;
if (mode.equals(PROXY_MODE))
{
wContainer.registerComponentImplementation(WorkspaceDataManagerProxy.class);
wContainer.registerComponentImplementation(ProxyWorkspaceDataReceiver.class);
dataReceiver =
(ProxyWorkspaceDataReceiver)wContainer
.getComponentInstanceOfType(ProxyWorkspaceDataReceiver.class);
}
else if (mode.equals(PERSISTENT_MODE))
{
wContainer.registerComponentImplementation(PersistentWorkspaceDataReceiver.class);
dataReceiver =
(PersistentWorkspaceDataReceiver)wContainer
.getComponentInstanceOfType(PersistentWorkspaceDataReceiver.class);
}
recoveryManager.setDataKeeper(dataReceiver.getDataKeeper());
dataReceiver.init(channelManager, systemId, ownName, recoveryManager);