1 /* 2 * Copyright 2002-2006 the original author or authors. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package org.springframework.webflow.engine.builder; 17 18 import org.springframework.beans.factory.BeanFactory; 19 import org.springframework.binding.convert.ConversionService; 20 import org.springframework.binding.expression.ExpressionParser; 21 import org.springframework.core.io.ResourceLoader; 22 import org.springframework.webflow.action.AbstractBeanInvokingAction; 23 import org.springframework.webflow.action.BeanInvokingActionFactory; 24 import org.springframework.webflow.engine.Flow; 25 import org.springframework.webflow.engine.FlowAttributeMapper; 26 import org.springframework.webflow.engine.FlowExecutionExceptionHandler; 27 import org.springframework.webflow.engine.State; 28 import org.springframework.webflow.engine.TargetStateResolver; 29 import org.springframework.webflow.engine.Transition; 30 import org.springframework.webflow.engine.TransitionCriteria; 31 import org.springframework.webflow.engine.ViewSelector; 32 import org.springframework.webflow.execution.Action; 33 34 /** 35 * A support interface used by flow builders at configuration time. Acts as a 36 * "service locator" responsible for: 37 * <ol> 38 * <li> Retrieving dependent (but externally managed) flow services needed to 39 * configure flow and state definitions. Such services are usually hosted in a 40 * backing registry and may be shared by multiple flows. 41 * <li> Providing access to abstract factories to create core flow definitional 42 * artifacts such as {@link Flow}, {@link State}, {@link Transition}, and 43 * {@link AbstractBeanInvokingAction bean invoking actions}. These artifacts 44 * are unique to each flow and are typically not shared. 45 * </ol> 46 * <p> 47 * In general, implementations of this interface act as facades to accessing and 48 * creating flow artifacts during {@link FlowAssembler flow assembly}. 49 * <p> 50 * Finally, this interface also exposes access to generic infrastructure 51 * services also needed by flow assemblers such as a {@link ConversionService} 52 * and {@link ExpressionParser}. 53 * 54 * @see org.springframework.webflow.engine.builder.FlowBuilder 55 * @see org.springframework.webflow.engine.builder.BaseFlowBuilder 56 * @see org.springframework.webflow.engine.builder.FlowAssembler 57 * 58 * @author Keith Donald 59 * @author Erwin Vervaet 60 */ 61 public interface FlowServiceLocator { 62 63 /** 64 * Returns the Flow to be used as a subflow with the provided id. 65 * @param id the flow id 66 * @return the flow to be used as a subflow 67 * @throws FlowArtifactLookupException when no such flow is found 68 */ 69 public Flow getSubflow(String id) throws FlowArtifactLookupException; 70 71 /** 72 * Retrieve an action to be executed within a flow with the assigned id. 73 * @param id the id of the action 74 * @throws FlowArtifactLookupException when no such action is found 75 */ 76 public Action getAction(String id) throws FlowArtifactLookupException; 77 78 /** 79 * Returns the flow attribute mapper with the provided id. Flow attribute 80 * mappers are used from subflow states to map input and output attributes. 81 * @param id the attribute mapper id 82 * @return the attribute mapper 83 * @throws FlowArtifactLookupException when no such mapper is found 84 */ 85 public FlowAttributeMapper getAttributeMapper(String id) throws FlowArtifactLookupException; 86 87 /** 88 * Returns the transition criteria to drive state transitions with the 89 * provided id. 90 * @param id the transition criteria id 91 * @return the transition criteria 92 * @throws FlowArtifactLookupException when no such criteria is found 93 */ 94 public TransitionCriteria getTransitionCriteria(String id) throws FlowArtifactLookupException; 95 96 /** 97 * Returns the transition target state resolver with the specified id. 98 * @param id the target state resolver id 99 * @return the target state resolver 100 * @throws FlowArtifactLookupException when no such resolver is found 101 */ 102 public TargetStateResolver getTargetStateResolver(String id) throws FlowArtifactLookupException; 103 104 /** 105 * Returns the view selector to make view selections in view states with the 106 * provided id. 107 * @param id the view selector id 108 * @return the view selector 109 * @throws FlowArtifactLookupException when no such selector is found 110 */ 111 public ViewSelector getViewSelector(String id) throws FlowArtifactLookupException; 112 113 /** 114 * Returns the exception handler to handle flow execution exceptions with 115 * the provided id. 116 * @param id the exception handler id 117 * @return the exception handler 118 * @throws FlowArtifactLookupException when no such handler is found 119 */ 120 public FlowExecutionExceptionHandler getExceptionHandler(String id) throws FlowArtifactLookupException; 121 122 /** 123 * Returns the factory for core flow artifacts such as Flow and State. 124 * @return the flow artifact factory 125 */ 126 public FlowArtifactFactory getFlowArtifactFactory(); 127 128 /** 129 * Returns the factory for bean invoking actions. 130 * @return the bean invoking action factory 131 */ 132 public BeanInvokingActionFactory getBeanInvokingActionFactory(); 133 134 /** 135 * Returns a generic bean (service) registry for accessing arbitrary beans. 136 * @return the generic service registry 137 * @throws UnsupportedOperationException when not supported by this locator 138 */ 139 public BeanFactory getBeanFactory() throws UnsupportedOperationException; 140 141 /** 142 * Returns a generic resource loader for accessing file-based resources. 143 * @return the generic resource loader 144 */ 145 public ResourceLoader getResourceLoader(); 146 147 /** 148 * Returns the expression parser for parsing expression strings. 149 * @return the expression parser 150 */ 151 public ExpressionParser getExpressionParser(); 152 153 /** 154 * Returns a generic type conversion service for converting between types, 155 * typically from string to a rich value object. 156 * @return the generic conversion service 157 */ 158 public ConversionService getConversionService(); 159 }