01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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: * Message
37: *
38: * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
39: * @version $Id: $
40: */
41: public class PortletMessagingImpl {
42: private PortletWindowAccessor windowAccessor;
43: private PortletInvoker invoker;
44: private ActionRequest actionRequest;
45: private ActionResponse actionResponse;
46:
47: public PortletMessagingImpl(PortletWindowAccessor windowAccessor) {
48: this .windowAccessor = windowAccessor;
49: }
50:
51: public void processActionMessage(String portletName,
52: RequestContext jetspeedRequest) throws PortletException,
53: IOException {
54: //RequestContext jetspeedRequest = (RequestContext)request.getAttribute(PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE);
55: PortletContainerServices.prepare("Jetspeed");
56:
57: PortletWindow window = windowAccessor.getPortletWindow("psd-1");
58: HttpServletRequest requestForWindow = jetspeedRequest
59: .getRequestForWindow(window);
60: HttpServletResponse responseForWindow = jetspeedRequest
61: .getResponseForWindow(window);
62:
63: actionRequest = PortletObjectAccess.getActionRequest(window,
64: requestForWindow, responseForWindow);
65: actionResponse = PortletObjectAccess.getActionResponse(window,
66: requestForWindow, responseForWindow);
67:
68: invoker = PortletInvokerAccess.getPortletInvoker(window
69: .getPortletEntity().getPortletDefinition());
70:
71: invoker.action(actionRequest, actionResponse);
72:
73: PortletContainerServices.release();
74: }
75:
76: }
|