001: /*
002: * Copyright 2004-2007 the original author or authors.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.springframework.webflow.engine.builder;
017:
018: import org.springframework.beans.factory.BeanFactory;
019: import org.springframework.binding.convert.ConversionService;
020: import org.springframework.binding.expression.ExpressionParser;
021: import org.springframework.core.io.ResourceLoader;
022: import org.springframework.webflow.action.AbstractBeanInvokingAction;
023: import org.springframework.webflow.action.BeanInvokingActionFactory;
024: import org.springframework.webflow.engine.Flow;
025: import org.springframework.webflow.engine.FlowAttributeMapper;
026: import org.springframework.webflow.engine.FlowExecutionExceptionHandler;
027: import org.springframework.webflow.engine.State;
028: import org.springframework.webflow.engine.TargetStateResolver;
029: import org.springframework.webflow.engine.Transition;
030: import org.springframework.webflow.engine.TransitionCriteria;
031: import org.springframework.webflow.engine.ViewSelector;
032: import org.springframework.webflow.execution.Action;
033:
034: /**
035: * A support interface used by flow builders at configuration time. Acts as a
036: * "service locator" responsible for:
037: * <ol>
038: * <li> Retrieving dependent (but externally managed) flow services needed to
039: * configure flow and state definitions. Such services are usually hosted in a
040: * backing registry and may be shared by multiple flows.
041: * <li> Providing access to abstract factories to create core flow definitional
042: * artifacts such as {@link Flow}, {@link State}, {@link Transition}, and
043: * {@link AbstractBeanInvokingAction bean invoking actions}. These artifacts
044: * are unique to each flow and are typically not shared.
045: * </ol>
046: * <p>
047: * In general, implementations of this interface act as facades to accessing and
048: * creating flow artifacts during {@link FlowAssembler flow assembly}.
049: * <p>
050: * Finally, this interface also exposes access to generic infrastructure
051: * services also needed by flow assemblers such as a {@link ConversionService}
052: * and {@link ExpressionParser}.
053: *
054: * @see org.springframework.webflow.engine.builder.FlowBuilder
055: * @see org.springframework.webflow.engine.builder.BaseFlowBuilder
056: * @see org.springframework.webflow.engine.builder.FlowAssembler
057: *
058: * @author Keith Donald
059: * @author Erwin Vervaet
060: */
061: public interface FlowServiceLocator {
062:
063: /**
064: * Returns the Flow to be used as a subflow with the provided id.
065: * @param id the flow id
066: * @return the flow to be used as a subflow
067: * @throws FlowArtifactLookupException when no such flow is found
068: */
069: public Flow getSubflow(String id)
070: throws FlowArtifactLookupException;
071:
072: /**
073: * Retrieve an action to be executed within a flow with the assigned id.
074: * @param id the id of the action
075: * @throws FlowArtifactLookupException when no such action is found
076: */
077: public Action getAction(String id)
078: throws FlowArtifactLookupException;
079:
080: /**
081: * Returns the flow attribute mapper with the provided id. Flow attribute
082: * mappers are used from subflow states to map input and output attributes.
083: * @param id the attribute mapper id
084: * @return the attribute mapper
085: * @throws FlowArtifactLookupException when no such mapper is found
086: */
087: public FlowAttributeMapper getAttributeMapper(String id)
088: throws FlowArtifactLookupException;
089:
090: /**
091: * Returns the transition criteria to drive state transitions with the
092: * provided id.
093: * @param id the transition criteria id
094: * @return the transition criteria
095: * @throws FlowArtifactLookupException when no such criteria is found
096: */
097: public TransitionCriteria getTransitionCriteria(String id)
098: throws FlowArtifactLookupException;
099:
100: /**
101: * Returns the transition target state resolver with the specified id.
102: * @param id the target state resolver id
103: * @return the target state resolver
104: * @throws FlowArtifactLookupException when no such resolver is found
105: */
106: public TargetStateResolver getTargetStateResolver(String id)
107: throws FlowArtifactLookupException;
108:
109: /**
110: * Returns the view selector to make view selections in view states with the
111: * provided id.
112: * @param id the view selector id
113: * @return the view selector
114: * @throws FlowArtifactLookupException when no such selector is found
115: */
116: public ViewSelector getViewSelector(String id)
117: throws FlowArtifactLookupException;
118:
119: /**
120: * Returns the exception handler to handle flow execution exceptions with
121: * the provided id.
122: * @param id the exception handler id
123: * @return the exception handler
124: * @throws FlowArtifactLookupException when no such handler is found
125: */
126: public FlowExecutionExceptionHandler getExceptionHandler(String id)
127: throws FlowArtifactLookupException;
128:
129: /**
130: * Returns the factory for core flow artifacts such as Flow and State.
131: * @return the flow artifact factory
132: */
133: public FlowArtifactFactory getFlowArtifactFactory();
134:
135: /**
136: * Returns the factory for bean invoking actions.
137: * @return the bean invoking action factory
138: */
139: public BeanInvokingActionFactory getBeanInvokingActionFactory();
140:
141: /**
142: * Returns a generic bean (service) registry for accessing arbitrary beans.
143: * @return the generic service registry
144: * @throws UnsupportedOperationException when not supported by this locator
145: */
146: public BeanFactory getBeanFactory()
147: throws UnsupportedOperationException;
148:
149: /**
150: * Returns a generic resource loader for accessing file-based resources.
151: * @return the generic resource loader
152: */
153: public ResourceLoader getResourceLoader();
154:
155: /**
156: * Returns the expression parser for parsing expression strings.
157: * @return the expression parser
158: */
159: public ExpressionParser getExpressionParser();
160:
161: /**
162: * Returns a generic type conversion service for converting between types,
163: * typically from string to a rich value object.
164: * @return the generic conversion service
165: */
166: public ConversionService getConversionService();
167: }
|