001 package com.hammurapi.flow.runtime;
002
003 import java.util.List;
004
005 import com.hammurapi.config.bootstrap.ConfigurationException;
006
007
008 /**
009 * Flows shall implement this interface.
010 * @author Pavel Vlasov
011 * @param <N> Node type.
012 * @param <T> Transition type.
013 * @param <P> Pin configuration type.
014 * @param <K> Connect key type.
015 * @param <S> Flow state type.
016 * @param <A> Argument type.
017 */
018 public interface Flow<N extends Node<P,K,S,A>, T extends Transition<S,A>, P, K, S, A> extends Node<P,K,S,A> {
019
020 /**
021 * Configuration runtime injects node instances into flow using this method.
022 * @param nodes Nodes.
023 */
024 void setNodes(List<N> nodes) throws ConfigurationException;
025
026 /**
027 * Configuration runtime injects transition instances into flow using this method.
028 * @param transitions
029 * @throws ConfigurationException
030 */
031 void setTransitions(List<T> transitions) throws ConfigurationException;
032
033 /**
034 * Configuration runtime injects facade interface class into flow using this method.
035 * @param facadeInterface
036 */
037 void setFacadeInterface(Class<?> facadeInterface);
038
039
040 /**
041 * @return Proxy facade for this flow or null if facade interface
042 * was not specified in the definition.
043 */
044 Object getFacade();
045
046 /**
047 * Connects contents of the flow (internal nodes).
048 * @param nodeIdx Node index. The flow itself has index -1.
049 * @param pinName Pin name.
050 * @param transitionIdx Transition index.
051 * @param isInbound True if transition is directed to the pin, false otherwise.
052 * @param connectKey Connect key.
053 */
054 void connect(int nodeIdx, String pinName, int transitionIdx, boolean isInbound, K connectKey) throws ConfigurationException;
055
056 /**
057 * Sets back-end object (optional operation). If back-end object is set, flow connects its pins to
058 * the back-end object methods with matching names.
059 * This is a convenience method for embedding flows into Java programs.
060 * @param object
061 */
062 void setBackEnd(Object object);
063 }