org.springframework.webflow.builder.FlowBuilder Maven / Gradle / Ivy
/*
* Copyright 2002-2006 the original author or authors.
*
* 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.springframework.webflow.builder;
import org.springframework.webflow.AttributeCollection;
import org.springframework.webflow.Flow;
/**
* Builder interface used to build a flow definition. The process of building a
* flow consists of the following steps:
*
* - Initialize this builder, creating the initial flow definition, by
* calling {@link #init(String, AttributeCollection)}.
*
- Call {@link #buildVariables()} to create any variables of the flow and
* add them to the flow definition.
*
- Call {@link #buildInputMapper()} to create and set the input mapper for
* the flow.
*
- Call {@link #buildStartActions()} to create and add any start actions to
* the flow.
*
- Call {@link #buildInlineFlows()} to create and add any inline flows
* encapsulated by the flow and add them to the flow definition.
*
- Call {@link #buildStates()} to create the states of the flow and add
* them to the flow definition.
*
- Call {@link #buildGlobalTransitions()} to create the state exception
* handlers of the flow and add them to the flow definition.
*
- Call {@link #buildEndActions()} to create and add any end actions to
* the flow.
*
- Call {@link #buildOutputMapper()} to create and set the output mapper
* for the flow.
*
- Call {@link #buildExceptionHandlers()} to create the state exception
* handlers of the flow and add them to the flow definition.
*
- Call {@link #getFlow()} to return the fully-built {@link Flow}
* definition.
*
- Dispose this builder, releasing any resources allocated during the
* building process by calling {@link #dispose()}.
*
*
* Implementations should encapsulate flow construction logic, either for a
* specific kind of flow, for example, an OrderFlowBuilder
built
* in Java code, or a generic flow builder strategy, like the
* XmlFlowBuilder
, for building flows from an XML-definition.
*
* Flow builders are used by the
* {@link org.springframework.webflow.builder.FlowAssembler}, which acts as an
* assembler (director). Flow Builders may be reused, however, exercise caution
* when doing this as these objects are not thread safe. Also, for each use be
* sure to call init, followed by the build* methods, getFlow, and dispose
* completely in that order.
*
* This is an example of the classic GoF Builder pattern.
*
* @see org.springframework.webflow.builder.AbstractFlowBuilder
* @see org.springframework.webflow.builder.XmlFlowBuilder
* @see org.springframework.webflow.builder.FlowAssembler
*
* @author Keith Donald
* @author Erwin Vervaet
*/
public interface FlowBuilder {
/**
* Initialize this builder. This could cause the builder to open a stream to
* an externalized resource representing the flow definition, for example.
* @param id the identifier to assign to the flow
* @param attributes custom attributes to assign to the flow
* @throws FlowBuilderException an exception occured building the flow
*/
public void init(String id, AttributeCollection attributes) throws FlowBuilderException;
/**
* Builds any variables initialized by the flow when it starts.
* @throws FlowBuilderException an exception occured building the flow
*/
public void buildVariables() throws FlowBuilderException;
/**
* Builds the input mapper responsible for mapping flow input on start.
* @throws FlowBuilderException an exception occured building the flow
*/
public void buildInputMapper() throws FlowBuilderException;
/**
* Builds any start actions to execute when the flow starts.
* @throws FlowBuilderException an exception occured building the flow
*/
public void buildStartActions() throws FlowBuilderException;
/**
* Builds any "in-line" flows encapsulated by the flow.
* @throws FlowBuilderException an exception occured building the flow
*/
public void buildInlineFlows() throws FlowBuilderException;
/**
* Builds the states (steps) of the flow.
* @throws FlowBuilderException an exception occured building the flow
*/
public void buildStates() throws FlowBuilderException;
/**
* Builds any transitions shared by all states of the flow.
* @throws FlowBuilderException an exception occured building the flow
*/
public void buildGlobalTransitions() throws FlowBuilderException;
/**
* Builds any end actions to execute when the flow ends.
* @throws FlowBuilderException an exception occured building the flow
*/
public void buildEndActions() throws FlowBuilderException;
/**
* Builds the output mapper responsible for mapping flow output on end.
* @throws FlowBuilderException an exception occured building the flow
*/
public void buildOutputMapper() throws FlowBuilderException;
/**
* Creates and adds all state exception handlers to the flow built by this
* builder.
* @throws FlowBuilderException an exception occured building this flow
*/
public void buildExceptionHandlers() throws FlowBuilderException;
/**
* Get the fully constructed and configured Flow object - called by the
* builder's assembler (director) after assembly. Ehen this method is called
* by the assembler, it is expectred flow construction wto have completed
* and the returned flow is ready for use.
*/
public Flow getFlow();
/**
* Shutdown the builder, releasing any resources it holds. A new flow
* construction process should start with another call to the
* init()
method.
*/
public void dispose();
}