Portal concepts guides———— pipeline

来源:互联网 发布:最新网络项目 编辑:程序博客网 时间:2024/05/16 04:04

1.       Guide to Jetspeed-2 pipeline

As described below, one of key component of the Jetspeed-2 portal engine is its request pipeline.

   

In Jetspeed-2 request are processed through a series of Valve assembled together as a pipeline. For detailed information about Jetspeed-2 pipeline, click here.

Request Pipeline

In Jetspeed-2, a request pipeline performs individual operations to the request.

Pipeline Concepts

A Pipeline is made of Value chained together in a chain of responsibility pattern[MS1] . The Jetspeed Pipeline implementation assembles an ordered list of Valves that are processed sequentially.

 

[MS2] 

Jetspeed-2 Valves

Jetspeed-2 provides various type of Valve as illustrated below:
The above valves serve the following purpose:

Valve Name

Description

ActionValve

Check if PortletAction needs to be processed and process it, if required. Used in the portlet pipeline.

AggregateValve

Invokes all Layout components in render mode to aggregate the generated contents and send the result to the client.

CapabilityValve

Identifies the browser and adds a CapabilityMap to the RequestContext.

CleanupValve

Look for JSP pages that were pushed onto the org.apache.jetspeed.renderStack request attribute, and attempts to include them.

LoginValidationValve

Checks if a login attempt failed and determines the cause.

PasswordCredentialValve

Checks the PasswordCredential (only once) after a User is logged in and redirects to a change password page if necessary.

SecurityValve

Authenticates the user or redirects to Login if necessary, add authenticated Subject to the RequestContext.

Request lifcycle:

  1. The o.a.j.container.ContainerValve receives the request.
  2. The request is then inspected by the o.a.j.engine.core.PortalControlParameter.getPortletWindowOfAction() to see whether or not a portlet action has been requested.
  3. If an action has been found the o.a.j.request.RequestContext.setActionWindow() is passed that action window, if not it is passed null.
  4. Next the ActionValve checks to see if the there is an action window defined, if the there is there, the PortletContainer.processPortletAction() is called by passing in the action window and HttpServletRequest aand httpServletResponse objects.   The request and response objects are actually wrappers around the original request and response objects which can parse action and/or render parameters for a specific PortletWindow. These wrappers are generated by calling RequestContext.getRequestForWindow() and RequestContext.getResponseForWindow() respectively.
  5. The container now handles the request. The container is responsible to generating an ActionRequest and an ActionResponse for the portlet action to be invoked.  Next the creates a new PortletInvoker object by passsing the PortletDefinition which was extract from the PortletWindow via the PortletEntity.   In Jetspeed's case, the PortletInvoker will be an instance of o.a.j.container.invoker.ServletPortletInvoker.  The  PortletInvoker.action() method is called passing in the previously generated ActionRequest and ActionResponse.
  6. ServletPortletInvoker receives the ActionRequest and ActionResponse from the container.  From here the ServletPortletInvoker extracts the ServletRequest and ServletResponse from the ActionRequest and ActionResponse respectively.  
  7. The PortletDefintion (which was provided at creation time to the ServletPortletInvoker) is queried for the WebApplication object which has the context path of the web app that controls this portlet.  
  8. With the name of the webapp ServletPortletInvoker no dispatches the request to the actual web application represented by the context path.  NOTE:  All portlet applications must contain a definition in its web.xml for the o.a.j.container.JetspeedContainerPortlet.  However, Jetspeed's deployment tool will generally take care of this for you.
  9. Once the JetspeedContainerServlet receives the request, it invokes Portlet.processAction(ActionRequest, ActionResponse) on your portlet.
  10. After the PortletInvoker and the JetspeedContainerServlet are finished the container once again takes control.  The container gets the redirection location from the response using ActionResponse.getRedirectLocation().  The ActionResponse is now checked to see if the state or the mode of the portlet has changed and communicates this information PortletWindow we are invoking the action on.  These changes are also applied to the rediretion location and passed to the current ServletResponse.sendRedirect() method so that all the encoded portlet state information is preserved in the URL>

 [MS1]责任链模式是一种对象的行为模式【GOF95】。在责任链模式里,很多对象由每一个对象对其下家的引用而连接起来形成一条链。请求在这个链上传递,直到链上的某一个对象决定处理此请求。发出这个请求的客户端并不知道链上的哪一个对象最终处理这个请求,这使得系统可以在不影响客户端的情况下动态地重新组织链和分配责任。

 [MS2]这些valve 是有顺序的

ContainerValve

CapabilityValve

UserProfilerValve

PageProfilerValve

ActionValve

LayoutValve

ContentValve

AggregateValve

CleanupValve