1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.jetspeed.aggregator;
18
19 import javax.servlet.http.HttpServletRequest;
20 import javax.servlet.http.HttpServletResponse;
21
22 import org.apache.jetspeed.om.page.ContentFragment;
23 import org.apache.jetspeed.request.RequestContext;
24 import org.apache.pluto.om.portlet.PortletDefinition;
25 import org.apache.pluto.om.window.PortletWindow;
26
27
28 /***
29 * MockRenderJob
30 *
31 * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
32 * @version $Id: $
33 */
34
35 public class MockRenderJob implements RenderingJob
36 {
37 private long mockTime;
38 private String jobName;
39 private PortletWindow window;
40
41 protected long startTimeMillis = 0;
42 protected long timeout;
43
44 public MockRenderJob(String jobName, long mockTime, PortletWindow window)
45 {
46 this.mockTime = mockTime;
47 this.jobName = jobName;
48 this.window = window;
49 }
50
51 /***
52 * Sets portlet timout in milliseconds.
53 */
54 public void setTimeout(long timeout) {
55 this.timeout = timeout;
56 }
57
58 /***
59 * Gets portlet timout in milliseconds.
60 */
61 public long getTimeout() {
62 return this.timeout;
63 }
64
65 /***
66 * Checks if the portlet rendering is timeout
67 */
68 public boolean isTimeout() {
69 if ((this.timeout > 0) && (this.startTimeMillis > 0)) {
70 return (System.currentTimeMillis() - this.startTimeMillis > this.timeout);
71 }
72
73 return false;
74 }
75
76 public void run()
77 {
78 if (this.timeout > 0) {
79 this.startTimeMillis = System.currentTimeMillis();
80 }
81
82 execute();
83 }
84
85
86
87
88 public void execute()
89 {
90 System.out.println("Running mock rendering job ..." + jobName);
91 try
92 {
93 Thread.sleep(mockTime);
94 }
95 catch (InterruptedException e)
96 {
97 System.out.println("Interrupted job..." + jobName);
98 }
99 System.out.println("mock job completed " + jobName);
100 }
101
102
103
104
105 public PortletWindow getWindow()
106 {
107
108 return window;
109 }
110
111
112
113
114 public PortletContent getPortletContent()
115 {
116
117 return null;
118 }
119
120 public ContentDispatcherCtrl getDispatcher()
121 {
122
123 return null;
124 }
125
126 public int getExpirationCache()
127 {
128
129 return 0;
130 }
131
132 public ContentFragment getFragment()
133 {
134
135 return null;
136 }
137
138 public PortletDefinition getPortletDefinition()
139 {
140
141 return null;
142 }
143
144 public HttpServletRequest getRequest()
145 {
146
147 return null;
148 }
149
150 public RequestContext getRequestContext()
151 {
152
153 return null;
154 }
155
156 public HttpServletResponse getResponse()
157 {
158
159 return null;
160 }
161
162 public boolean isContentCached()
163 {
164
165 return false;
166 }
167
168 public Object getWorkerAttribute(String name)
169 {
170
171 return null;
172 }
173
174 public void removeWorkerAttribute(String name)
175 {
176
177 }
178
179 public void setWorkerAttribute(String name, Object value)
180 {
181
182 }
183 }