org.springframework.webflow.engine.builder
Class RefreshableFlowDefinitionHolder

java.lang.Object
  extended by org.springframework.webflow.engine.builder.RefreshableFlowDefinitionHolder
All Implemented Interfaces:
FlowDefinitionHolder

public class RefreshableFlowDefinitionHolder
extends java.lang.Object
implements FlowDefinitionHolder

A flow definition holder that can detect changes on an underlying flow definition resource and refresh that resource automatically.

This class is threadsafe.

Note that this FlowDefinition holder uses a Flow assembler. This is normal since a Flow is a FlowDefinition! This class bridges the abstract world of flow definitions with the concrete world of flow implementations.

Author:
Keith Donald
See Also:
FlowDefinition, Flow, FlowAssembler

Constructor Summary
RefreshableFlowDefinitionHolder(FlowAssembler assembler)
          Creates a new refreshable flow definition holder that uses the configured assembler (GOF director) to drive flow assembly, on initial use and on any resource change or refresh.
 
Method Summary
protected  void assembleFlow()
          Assemble the held flow definition, delegating to the configured FlowAssembler (director).
protected  long calculateLastModified()
          Helper that retrieves the last modified date by querying the backing flow resource.
protected  FlowBuilder getFlowBuilder()
          Returns the flow builder that actually builds the Flow definition.
 FlowDefinition getFlowDefinition()
          Returns the flow definition held by this holder.
 java.lang.String getFlowDefinitionId()
          Returns the id of the flow definition held by this holder.
protected  long getLastModified()
          Returns the last modifed date of the backed flow definition resource.
protected  boolean isAssembled()
          Returns a flag indicating if this holder has performed and completed flow definition assembly.
protected  boolean isAssembling()
          Returns a flag indicating if this holder is performing assembly.
 void refresh()
          Refresh the flow definition held by this holder.
protected  void refreshIfChanged()
          Reassemble the flow if its underlying resource has changed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RefreshableFlowDefinitionHolder

public RefreshableFlowDefinitionHolder(FlowAssembler assembler)
Creates a new refreshable flow definition holder that uses the configured assembler (GOF director) to drive flow assembly, on initial use and on any resource change or refresh.

Parameters:
assembler - the flow assembler to use
Method Detail

getFlowDefinitionId

public java.lang.String getFlowDefinitionId()
Description copied from interface: FlowDefinitionHolder
Returns the id of the flow definition held by this holder. This is a lightweight method callers may call to obtain the id of the flow without triggering full flow definition assembly (which may be an expensive operation).

Specified by:
getFlowDefinitionId in interface FlowDefinitionHolder

getFlowDefinition

public FlowDefinition getFlowDefinition()
                                 throws FlowDefinitionConstructionException
Description copied from interface: FlowDefinitionHolder
Returns the flow definition held by this holder. Calling this method the first time may trigger flow assembly (which may be expensive).

Specified by:
getFlowDefinition in interface FlowDefinitionHolder
Throws:
FlowDefinitionConstructionException - if there is a problem constructing the target flow definition

refresh

public void refresh()
             throws FlowBuilderException
Description copied from interface: FlowDefinitionHolder
Refresh the flow definition held by this holder. Calling this method typically triggers flow reassembly, which may include a refresh from an externalized resource such as a file.

Specified by:
refresh in interface FlowDefinitionHolder
Throws:
FlowBuilderException

getFlowBuilder

protected FlowBuilder getFlowBuilder()
Returns the flow builder that actually builds the Flow definition.


refreshIfChanged

protected void refreshIfChanged()
Reassemble the flow if its underlying resource has changed.


calculateLastModified

protected long calculateLastModified()
Helper that retrieves the last modified date by querying the backing flow resource.

Returns:
the last modified date, or -1 if it could not be retrieved

getLastModified

protected long getLastModified()
Returns the last modifed date of the backed flow definition resource.

Returns:
the last modified date

assembleFlow

protected void assembleFlow()
                     throws FlowBuilderException
Assemble the held flow definition, delegating to the configured FlowAssembler (director).

Throws:
FlowBuilderException

isAssembled

protected boolean isAssembled()
Returns a flag indicating if this holder has performed and completed flow definition assembly.


isAssembling

protected boolean isAssembling()
Returns a flag indicating if this holder is performing assembly.



Copyright © 2004-2007. All Rights Reserved.