View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    * 
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   * 
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.jetspeed.messaging;
18  
19  import java.io.IOException;
20  
21  import javax.portlet.ActionRequest;
22  import javax.portlet.ActionResponse;
23  import javax.portlet.PortletException;
24  import javax.servlet.http.HttpServletRequest;
25  import javax.servlet.http.HttpServletResponse;
26  
27  import org.apache.jetspeed.container.window.PortletWindowAccessor;
28  import org.apache.jetspeed.request.RequestContext;
29  import org.apache.pluto.PortletContainerServices;
30  import org.apache.pluto.factory.PortletObjectAccess;
31  import org.apache.pluto.invoker.PortletInvoker;
32  import org.apache.pluto.invoker.PortletInvokerAccess;
33  import org.apache.pluto.om.window.PortletWindow;
34  
35  
36  /***
37   * Message 
38   *
39   * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
40   * @version $Id: $
41   */
42  public class PortletMessagingImpl 
43  {
44      private PortletWindowAccessor windowAccessor;
45      private PortletInvoker invoker;
46      private ActionRequest actionRequest;
47      private ActionResponse actionResponse;
48      
49      public PortletMessagingImpl(PortletWindowAccessor windowAccessor)
50      {
51          this.windowAccessor = windowAccessor;
52      }
53      
54      public void processActionMessage(String portletName, RequestContext jetspeedRequest)
55      throws PortletException, IOException
56      {
57          //RequestContext jetspeedRequest = (RequestContext)request.getAttribute(PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE);
58          PortletContainerServices.prepare("Jetspeed");
59  
60          PortletWindow window = windowAccessor.getPortletWindow("psd-1");
61          HttpServletRequest requestForWindow = jetspeedRequest.getRequestForWindow(window);        
62          HttpServletResponse responseForWindow = jetspeedRequest.getResponseForWindow(window);
63          
64          actionRequest = PortletObjectAccess.getActionRequest(window, requestForWindow, responseForWindow);
65          actionResponse = PortletObjectAccess.getActionResponse(window, requestForWindow, responseForWindow); 
66          
67          invoker = PortletInvokerAccess.getPortletInvoker(window.getPortletEntity().getPortletDefinition());
68          
69          invoker.action(actionRequest, actionResponse);
70          
71          PortletContainerServices.release();
72      }
73      
74  }