org.jasig.portal.layout.dlm.processing
Class ProcessingPipe

java.lang.Object
  extended by org.jasig.portal.layout.dlm.processing.ProcessingPipe
All Implemented Interfaces:
IParameterProcessor

public class ProcessingPipe
extends Object
implements IParameterProcessor

Handles chaining of layout parameter request processing for the DistributedLayoutManager object and provides assistance during generation of the SAX event stream during rendering by wrapping the ultimate ContentHandler to which all events will be pushed. Conceptually, the pipe performs as if sitting between UserInstance and the DistributedLayoutManager instance as shown below. The call to processLayoutParameters and the call to render the layout via the getUserLayout call pass through the pipe along with the resulting SAX event stream. This is conceptual only. The pipe is actually embedded within the DistributedLayoutManager.


              time proceeds forward moving downward
                              |
                              |
                              V
                process                        optionally      +-------------+
   +----------+ Layout           +-----------+ specific layout | Distributed |
   | User     | Parameters       | Processor | action calls to | Layout      |
   | Instance |  (...)           | Pipe      | the manager     | Manager     |
   |          |----------------->|           |---------------->|             |
   |          |                  |           |                 |             |
   |          | getUserLayout()  |           | getUserLayout() |             |
   |          |----------------->|           |---------------->|             |
   |          |                  |           |                 |             |
   |          | SAX Events flow  |           | SAX Events flow |             |
   |          | back to User     |           | back to Pipe's  |             |
   |          | Instance's       |           | ContentHandler  |             |
   |          | ContentHandler   |           |                 |             |
   |          |<-----------------|           |<----------------|             |
   |          |                  |           |                 |             |
   +----------+                  +-----------+                 +-------------+


 
This pipe allows us to do specific URL parameter handling that may be unique to a structure and theme stylesheet set. A special parameter uP_dlmPrc is also looked for which causes an optional processor to be embedded within the pipe until a further occurrance of this parameter either replaces that processor with a new processor or removes it by specifying an empty value. This allows a specific dlm stylesheet set to use custom processing for things like adding channel targets, adding column or tab targets, adding targets for moving channels and a different policy for adding targets for moving columns or tabs, etc. There are two types of processors supported, a fixed set which does not change and an optional set from which a single processor can be added to the pipe via the uP_dlmPrc parameter. All are configured via the "properties/context/layoutContext.xml" file. The pipe provides a "front" ContentHandler to the DistributedLayoutManager representing the front of the pipe for SAX events generated in the getUserLayout() method. The ContentHandler passed in from UserInstance via the getUserLayout() method is set as the "back" ContentHandler to which all events exiting the pipe are pushed. As such this pipe can act on incoming layout parameters and then influence the perceived layout seen by UserInstance by altering the SAX stream accordingly as it flows back toward UserInstance's ContentHandler.

Author:
Mark Boyd

Field Summary
static String CHANGE_PROCESSOR_PARAM
          The parameter watched for by this pipe in the request whose value if included should be an empty String or a value that matches one of the keys in the optionalProcessors Map.
static String PROCESSING_PIPE_BEAN_ID
          Holds the name of the bean configured in the context file that is a factory for instances of this class.
 
Constructor Summary
ProcessingPipe()
          Construct a pipe.
 
Method Summary
 String getCacheKey()
          Returns a cache key indicative of the affect that the pipe has on the SAX event stream.
 ContentHandler getContentHandler(ContentHandler handler)
          Sets the ContentHandler to which all SAX events passing through the pipe will be passed including any modifications made to that stream by any of the fixed processors if any or the currently selected optional processor if any.
 void processParameters(UserPreferences prefs, HttpServletRequest request)
          Passes a request to the set of processors that are currently part of the pipe allowing them to act on query or post parameters embedded in the request.
 void setFixedProcessors(List fixedProcessors)
          Sets the configured set of fixed processors in the order that they are allowed to process layout parameters and filter the SAX event stream.
 void setOptionalProcessors(Map optionalProcessors)
          Sets the map of optional processors that can be included in the processing and SAX event pipe by inclusion of the uP_dlmPrc parameter being included with a value corresponding to a key in this map.
 void setResources(IPerson person, DistributedLayoutManager dlm)
          Hands the passed-in instances or IPerson and DistributedLayoutManager to all configured fixed and optional processors.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CHANGE_PROCESSOR_PARAM

public static final String CHANGE_PROCESSOR_PARAM
The parameter watched for by this pipe in the request whose value if included should be an empty String or a value that matches one of the keys in the optionalProcessors Map. An empty String value removes the currently selected optional processor if any from pipe processing. A value matching a key sets the corresponding processor as the optional procesor prior to performing regular pipe processing. This means that the request in which a processor is made the currently selected optional processor is the first request that that processor will be allowed to participate in processing. Furthermore, when a currently selected optional processor is replaced it does not take part in processing of the request during which it was replaced.

See Also:
Constant Field Values

PROCESSING_PIPE_BEAN_ID

public static final String PROCESSING_PIPE_BEAN_ID
Holds the name of the bean configured in the context file that is a factory for instances of this class. The factory must return a new instance of this class and all configured, contained processors for each call to the factory to get an instance of this class.

See Also:
Constant Field Values
Constructor Detail

ProcessingPipe

public ProcessingPipe()
Construct a pipe.

Method Detail

setFixedProcessors

public void setFixedProcessors(List fixedProcessors)
Sets the configured set of fixed processors in the order that they are allowed to process layout parameters and filter the SAX event stream. These processors will take part in either parameter processing or SAX event stream modification depending on which interfaces they implement. See IParmeterProcessor and ISaxProcessor.

Parameters:
fixedProcessors -

setOptionalProcessors

public void setOptionalProcessors(Map optionalProcessors)
Sets the map of optional processors that can be included in the processing and SAX event pipe by inclusion of the uP_dlmPrc parameter being included with a value corresponding to a key in this map.

Parameters:
optionalProcessors -

setResources

public void setResources(IPerson person,
                         DistributedLayoutManager dlm)
Hands the passed-in instances or IPerson and DistributedLayoutManager to all configured fixed and optional processors. Hence, this should be called after setFixedProcessors() and setOptionalProcessors().

Specified by:
setResources in interface IParameterProcessor
See Also:
IParameterProcessor.setResources(org.jasig.portal.security.IPerson, org.jasig.portal.layout.dlm.DistributedLayoutManager)

processParameters

public void processParameters(UserPreferences prefs,
                              HttpServletRequest request)
Passes a request to the set of processors that are currently part of the pipe allowing them to act on query or post parameters embedded in the request. This will include all fixed processors if any followed by the optional processor if one is set. If this request includes the uP_dlmPrc parameter then prior to passing the request to any processors the optional processor state is updated according to the value of uP_dlmPrc. If it is an empty String then the optional processor is removed from the pipe. If non-null then the value must match a key in the optional processors map. If no matching key is found then an InvalidArgumentException is logged and processing continues with no optional processor. If a matching key is found then the corresponding optional processor becomes part of the pipe possibly replacing an existing optional processor set when uP_dlmPrc was last specified in a request.

Specified by:
processParameters in interface IParameterProcessor
See Also:
IParameterProcessor.processParameters(org.jasig.portal.UserPreferences, javax.servlet.http.HttpServletRequest)

getCacheKey

public String getCacheKey()
Returns a cache key indicative of the affect that the pipe has on the SAX event stream. If there is no effect on the SAX event stream then an empty String is returned.

Returns:
String cache key

getContentHandler

public ContentHandler getContentHandler(ContentHandler handler)
Sets the ContentHandler to which all SAX events passing through the pipe will be passed including any modifications made to that stream by any of the fixed processors if any or the currently selected optional processor if any. If there are no fixed processors and no currently selected optional processor then the "front" and "back" ContentHandler will be the same object. Accordingly, this method must be called prior to calling getFrontContentHandler().



Copyright © 2010 Jasig. All Rights Reserved.