001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.jetspeed.aggregator;
018:
019: import javax.servlet.http.HttpServletRequest;
020: import javax.servlet.http.HttpServletResponse;
021:
022: import org.apache.jetspeed.om.page.ContentFragment;
023: import org.apache.jetspeed.request.RequestContext;
024: import org.apache.pluto.om.portlet.PortletDefinition;
025: import org.apache.pluto.om.window.PortletWindow;
026:
027: /**
028: * MockRenderJob
029: *
030: * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
031: * @version $Id: $
032: */
033:
034: public class MockRenderJob implements RenderingJob {
035: private long mockTime;
036: private String jobName;
037: private PortletWindow window;
038:
039: protected long startTimeMillis = 0;
040: protected long timeout;
041:
042: public MockRenderJob(String jobName, long mockTime,
043: PortletWindow window) {
044: this .mockTime = mockTime;
045: this .jobName = jobName;
046: this .window = window;
047: }
048:
049: /**
050: * Sets portlet timout in milliseconds.
051: */
052: public void setTimeout(long timeout) {
053: this .timeout = timeout;
054: }
055:
056: /**
057: * Gets portlet timout in milliseconds.
058: */
059: public long getTimeout() {
060: return this .timeout;
061: }
062:
063: /**
064: * Checks if the portlet rendering is timeout
065: */
066: public boolean isTimeout() {
067: if ((this .timeout > 0) && (this .startTimeMillis > 0)) {
068: return (System.currentTimeMillis() - this .startTimeMillis > this .timeout);
069: }
070:
071: return false;
072: }
073:
074: public void run() {
075: if (this .timeout > 0) {
076: this .startTimeMillis = System.currentTimeMillis();
077: }
078:
079: execute();
080: }
081:
082: /* (non-Javadoc)
083: * @see org.apache.jetspeed.aggregator.RenderingJob#execute()
084: */
085: public void execute() {
086: System.out.println("Running mock rendering job ..." + jobName);
087: try {
088: Thread.sleep(mockTime);
089: } catch (InterruptedException e) {
090: System.out.println("Interrupted job..." + jobName);
091: }
092: System.out.println("mock job completed " + jobName);
093: }
094:
095: /* (non-Javadoc)
096: * @see org.apache.jetspeed.aggregator.RenderingJob#getWindow()
097: */
098: public PortletWindow getWindow() {
099: // TODO Auto-generated method stub
100: return window;
101: }
102:
103: /* (non-Javadoc)
104: * @see org.apache.jetspeed.aggregator.RenderingJob#getPortletContent()
105: */
106: public PortletContent getPortletContent() {
107: // TODO Auto-generated method stub
108: return null;
109: }
110:
111: public ContentDispatcherCtrl getDispatcher() {
112: // TODO Auto-generated method stub
113: return null;
114: }
115:
116: public int getExpirationCache() {
117: // TODO Auto-generated method stub
118: return 0;
119: }
120:
121: public ContentFragment getFragment() {
122: // TODO Auto-generated method stub
123: return null;
124: }
125:
126: public PortletDefinition getPortletDefinition() {
127: // TODO Auto-generated method stub
128: return null;
129: }
130:
131: public HttpServletRequest getRequest() {
132: // TODO Auto-generated method stub
133: return null;
134: }
135:
136: public RequestContext getRequestContext() {
137: // TODO Auto-generated method stub
138: return null;
139: }
140:
141: public HttpServletResponse getResponse() {
142: // TODO Auto-generated method stub
143: return null;
144: }
145:
146: public boolean isContentCached() {
147: // TODO Auto-generated method stub
148: return false;
149: }
150:
151: public Object getWorkerAttribute(String name) {
152: // TODO Auto-generated method stub
153: return null;
154: }
155:
156: public void removeWorkerAttribute(String name) {
157: // TODO Auto-generated method stub
158: }
159:
160: public void setWorkerAttribute(String name, Object value) {
161: // TODO Auto-generated method stub
162: }
163: }
|