com.hammurapi.flow.runtime.impl
Class FlowBase<N extends Node<P,K,S,A>,T extends Transition<S,A>,P,K,S,A>
java.lang.Object
com.hammurapi.flow.runtime.impl.FlowBase<N,T,P,K,S,A>
- Type Parameters:
N - Node type.T - Transition type.P - Pin configuration type.K - Connect key type.S - Flow state type.A - Argument type.
- All Implemented Interfaces:
- Component<Flow>, Flow<N,T,P,K,S,A>, FlowElement, Node<P,K,S,A>, TaskCounter
- Direct Known Subclasses:
- TaskCountingFlowBase
public abstract class FlowBase<N extends Node<P,K,S,A>,T extends Transition<S,A>,P,K,S,A>
- extends Object
- implements Flow<N,T,P,K,S,A>, Component<Flow>, TaskCounter
Base class for flow implementations.
- Author:
- Pavel Vlasov
|
Method Summary |
void |
afterConnect()
|
void |
beforeConnect()
|
void |
connect(int nodeIdx,
String pinName,
int transitionIdx,
boolean isInbound,
K connectKey)
|
protected Object |
convertResult(Object proxy,
Method method,
Object[] args,
Collection<Future<?>> invocationResult)
Facade methods may return values other than collection of futures. |
protected S |
createFlowState(Object proxy)
Creates flow state. |
Object |
getFacade()
|
protected abstract Invocable<S,A> |
getInternalInvocable(String pinName,
K connectKey)
|
protected abstract Invoker<S,A> |
getInternalInvoker(String pinName,
K connectKey)
|
protected SynapseFactory.SynapseConfig |
getSynapseConfig(K connectKey)
This method attempts to convert connect key to synapse config. |
SynapseFactory<K,S,A> |
getSynapseFactory()
|
void |
init(ConfigurationContext<Flow> context)
|
void |
setFacadeInterface(Class<?> facadeInterface)
|
void |
setNodes(List<N> nodes)
|
void |
setSynapseFactory(SynapseFactory<K,S,A> synapseFactory)
|
void |
setTransitions(List<T> transitions)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.hammurapi.flow.runtime.Flow |
setBackEnd |
nodes
protected List<N extends Node<P,K,S,A>> nodes
transitions
protected List<T extends Transition<S,A>> transitions
FlowBase
public FlowBase()
setSynapseFactory
public void setSynapseFactory(SynapseFactory<K,S,A> synapseFactory)
getSynapseFactory
public SynapseFactory<K,S,A> getSynapseFactory()
connect
public void connect(int nodeIdx,
String pinName,
int transitionIdx,
boolean isInbound,
K connectKey)
throws ConfigurationException
- Specified by:
connect in interface Flow<N extends Node<P,K,S,A>,T extends Transition<S,A>,P,K,S,A>
- Throws:
ConfigurationException
getSynapseConfig
protected SynapseFactory.SynapseConfig getSynapseConfig(K connectKey)
- This method attempts to convert connect key to synapse config.
Subclasses can override this method to provide different implementation.
- Parameters:
connectKey - Connect key
- Returns:
- synapse config or null if connect key cannot be converted to synapse config
getInternalInvoker
protected abstract Invoker<S,A> getInternalInvoker(String pinName,
K connectKey)
- Parameters:
pinName - Flow pin name.connectKey - Connect key.
- Returns:
- Invoker for internal transitions.
getInternalInvocable
protected abstract Invocable<S,A> getInternalInvocable(String pinName,
K connectKey)
- Parameters:
pinName - Flow pin name.connectKey - Connect key.
- Returns:
- Invocable for internal transitions.
getFacade
public Object getFacade()
- Specified by:
getFacade in interface Flow<N extends Node<P,K,S,A>,T extends Transition<S,A>,P,K,S,A>
setFacadeInterface
public void setFacadeInterface(Class<?> facadeInterface)
- Specified by:
setFacadeInterface in interface Flow<N extends Node<P,K,S,A>,T extends Transition<S,A>,P,K,S,A>
setNodes
public void setNodes(List<N> nodes)
throws ConfigurationException
- Specified by:
setNodes in interface Flow<N extends Node<P,K,S,A>,T extends Transition<S,A>,P,K,S,A>
- Throws:
ConfigurationException
setTransitions
public void setTransitions(List<T> transitions)
throws ConfigurationException
- Specified by:
setTransitions in interface Flow<N extends Node<P,K,S,A>,T extends Transition<S,A>,P,K,S,A>
- Throws:
ConfigurationException
init
public void init(ConfigurationContext<Flow> context)
throws ConfigurationException
- Specified by:
init in interface Component<Flow>
- Throws:
ConfigurationException
createFlowState
protected S createFlowState(Object proxy)
- Creates flow state. This implementation simply returns the proxy.
- Parameters:
proxy -
- Returns:
- Flow state for the new flow.
convertResult
protected Object convertResult(Object proxy,
Method method,
Object[] args,
Collection<Future<?>> invocationResult)
throws Exception
- Facade methods may return values other than collection of futures.
Subclasses shall override this method to convert invocation result to appropriate type.
This implementation returns result without any conversion.
- Parameters:
proxy - Facade proxy.method - Target method.args - Arguments.invocationResult - Invocation result.
- Returns:
-
- Throws:
Exception
beforeConnect
public void beforeConnect()
throws ConfigurationException
- Specified by:
beforeConnect in interface FlowElement
- Throws:
ConfigurationException
afterConnect
public void afterConnect()
throws ConfigurationException
- Specified by:
afterConnect in interface FlowElement
- Throws:
ConfigurationException