/*
* Copyright 2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.agila.services.rendezvous;
import org.apache.agila.model.BusinessProcessID;
import org.apache.agila.model.NodeID;
import org.apache.agila.engine.InstanceID;
import org.apache.agila.engine.TokenID;
import org.apache.agila.services.InstanceService;
import org.apache.agila.services.log.LogService;
import java.util.Map;
/**
*
* @author <a href="mailto:geir@gluecode.com">Geir Magnusson Jr.</a>
* @version $Id: AbstractRendezvousService.java 38 2005-06-01 19:39:54Z chirino $
*/
public abstract class AbstractRendezvousService implements RendezvousService {
protected InstanceService instanceService = null;
protected LogService logService = null;
public void setInstanceService(InstanceService isvc) {
this.instanceService = isvc;
}
public void setLogService(LogService svc) {
this.logService = svc;
}
/**
* Registers a policy for a given business process.
* Used by thhe BusinessProcessService to register all policies of a
* process.
*
* @param procid
* @param policy
* @return
*/
public RendezvousRegistration registerProcessRendezvous(BusinessProcessID procid,
RendezvousPolicyInfo policy)
throws RendezvousException {
/*
* first, get the container for this process or create a new one if not exist
*/
BusProcInfo info = getBusProcInfo(procid, true);
if (info != null) {
info.addPolicy(policy);
}
return new RendezvousRegistrationImpl();
}
/**
* Registers an instance when one begins. Used by the
* InstanceService.
*
* @param instanceID
* @return
*/
public boolean registerInstanceStart(InstanceID instanceID)
throws RendezvousException {
/*
* create a policy handler for each policy
*/
BusinessProcessID procID = instanceService.getInstanceInfoByID(instanceID).getBusinessProcessID();
BusProcInfo info = getBusProcInfo(procID, false);
if (info == null) {
logService.debug("starting instance of process = " + procID + " No rendezvous info known");
return false;
}
return true;
}
/**
* Notfies the RendezvousService that a token has reached a RendezvousNode
*
* @param token
* @param policy
* @return true if processing should continue, false if node must wait for
* external notification
*/
public boolean nodeNotification(TokenID token, RendezvousPolicyInfo policy) {
return false;
}
public abstract BusProcInfo getBusProcInfo(BusinessProcessID id, boolean createNew);
class RendezvousRegistrationImpl implements RendezvousRegistration {
}
}