1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
package org.apache.jetspeed.container; |
18 |
|
|
19 |
|
import java.io.IOException; |
20 |
|
import java.util.Properties; |
21 |
|
|
22 |
|
import javax.portlet.PortletException; |
23 |
|
import javax.servlet.ServletConfig; |
24 |
|
import javax.servlet.http.HttpServletRequest; |
25 |
|
import javax.servlet.http.HttpServletResponse; |
26 |
|
|
27 |
|
import org.apache.commons.logging.Log; |
28 |
|
import org.apache.commons.logging.LogFactory; |
29 |
|
import org.apache.jetspeed.engine.servlet.ServletRequestFactory; |
30 |
|
import org.apache.jetspeed.engine.servlet.ServletResponseFactory; |
31 |
|
import org.apache.pluto.PortletContainer; |
32 |
|
import org.apache.pluto.PortletContainerException; |
33 |
|
import org.apache.pluto.om.window.PortletWindow; |
34 |
|
import org.apache.pluto.services.PortletContainerEnvironment; |
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
public class JetspeedPortletContainerWrapper implements PortletContainerWrapper |
43 |
|
{ |
44 |
0 |
private boolean initialized = false; |
45 |
0 |
private static final Log log = LogFactory.getLog(JetspeedPortletContainerWrapper.class); |
46 |
|
private final PortletContainer pluto; |
47 |
|
private final String containerId; |
48 |
|
private final Properties properties; |
49 |
|
private final PortletContainerEnvironment environment; |
50 |
|
private final ServletConfig servletConfig; |
51 |
|
|
52 |
|
private ServletRequestFactory requestFactory; |
53 |
|
private ServletResponseFactory responseFactory; |
54 |
|
|
55 |
|
public JetspeedPortletContainerWrapper(PortletContainer pluto, String containerId, |
56 |
|
ServletConfig servletConfig, PortletContainerEnvironment env, Properties properties) |
57 |
0 |
{ |
58 |
0 |
this.pluto = pluto; |
59 |
0 |
this.containerId = containerId; |
60 |
0 |
this.environment = env; |
61 |
0 |
this.properties = properties; |
62 |
0 |
this.servletConfig = servletConfig; |
63 |
0 |
} |
64 |
|
|
65 |
|
public JetspeedPortletContainerWrapper(PortletContainer pluto, String containerId, |
66 |
|
ServletConfig servletConfig, PortletContainerEnvironment env) |
67 |
|
{ |
68 |
0 |
this(pluto, containerId, servletConfig, env, new Properties()); |
69 |
0 |
} |
70 |
|
|
71 |
|
|
72 |
|
|
73 |
|
|
74 |
|
|
75 |
|
|
76 |
|
|
77 |
|
|
78 |
|
public void start() throws PortletContainerException |
79 |
|
{ |
80 |
0 |
log.info("Attmepting to start Pluto portal container..."); |
81 |
0 |
this.init(containerId, servletConfig, environment, properties); |
82 |
0 |
log.info("Pluto portlet container successfully started."); |
83 |
0 |
} |
84 |
|
|
85 |
|
|
86 |
|
|
87 |
|
|
88 |
|
public synchronized void init( |
89 |
|
String uniqueContainerId, |
90 |
|
ServletConfig servletConfig, |
91 |
|
PortletContainerEnvironment environment, |
92 |
|
Properties props) |
93 |
|
throws PortletContainerException |
94 |
|
{ |
95 |
|
|
96 |
0 |
pluto.init(uniqueContainerId, servletConfig, environment, props); |
97 |
0 |
initialized = true; |
98 |
0 |
} |
99 |
|
|
100 |
|
public synchronized void shutdown() throws PortletContainerException |
101 |
|
{ |
102 |
0 |
initialized = false; |
103 |
0 |
pluto.shutdown(); |
104 |
0 |
} |
105 |
|
|
106 |
|
public void renderPortlet(PortletWindow portletWindow, HttpServletRequest servletRequest, HttpServletResponse servletResponse) |
107 |
|
throws PortletException, IOException, PortletContainerException |
108 |
|
{ |
109 |
|
|
110 |
0 |
if(portletWindow.getPortletEntity() == null) |
111 |
|
{ |
112 |
0 |
log.warn("Could not render PortletWindow "+ portletWindow.getId() + " as it has no PortletEntity defined."); |
113 |
0 |
return; |
114 |
|
} |
115 |
|
|
116 |
0 |
if(portletWindow.getPortletEntity().getPortletDefinition() == null) |
117 |
|
{ |
118 |
0 |
log.warn("Could not render PortletWindow"+ portletWindow.getId() + " as it has no PortletDefintion defined."); |
119 |
0 |
return; |
120 |
|
} |
121 |
0 |
pluto.renderPortlet(portletWindow, servletRequest, servletResponse); |
122 |
|
|
123 |
|
|
124 |
|
|
125 |
0 |
} |
126 |
|
|
127 |
|
public void processPortletAction( |
128 |
|
PortletWindow portletWindow, |
129 |
|
HttpServletRequest servletRequest, |
130 |
|
HttpServletResponse servletResponse) |
131 |
|
throws PortletException, IOException, PortletContainerException |
132 |
|
{ |
133 |
0 |
pluto.processPortletAction(portletWindow, servletRequest, servletResponse); |
134 |
|
|
135 |
|
|
136 |
0 |
} |
137 |
|
|
138 |
|
public void portletLoad(PortletWindow portletWindow, HttpServletRequest servletRequest, HttpServletResponse servletResponse) |
139 |
|
throws PortletException, PortletContainerException |
140 |
|
{ |
141 |
0 |
pluto.portletLoad( |
142 |
|
portletWindow, |
143 |
|
requestFactory.getServletRequest(servletRequest, portletWindow), |
144 |
|
responseFactory.getServletResponse(servletResponse)); |
145 |
0 |
} |
146 |
|
|
147 |
|
|
148 |
|
|
149 |
|
|
150 |
|
|
151 |
|
|
152 |
|
|
153 |
|
|
154 |
|
|
155 |
|
public boolean isInitialized() |
156 |
|
{ |
157 |
0 |
return initialized; |
158 |
|
} |
159 |
|
|
160 |
|
public void setRequestFactory(ServletRequestFactory requestFactory) |
161 |
|
{ |
162 |
0 |
this.requestFactory = requestFactory; |
163 |
0 |
} |
164 |
|
|
165 |
|
public void setResponseFactory(ServletResponseFactory responseFactory) |
166 |
|
{ |
167 |
0 |
this.responseFactory = responseFactory; |
168 |
0 |
} |
169 |
|
|
170 |
|
} |