001: /* Copyright 2004 The JA-SIG Collaborative. All rights reserved.
002: * See license distributed with this file and
003: * available online at http://www.uportal.org/license.html
004: */
005:
006: package org.jasig.portal.container.om.servlet;
007:
008: import java.io.Serializable;
009: import java.util.Locale;
010:
011: import javax.servlet.RequestDispatcher;
012: import javax.servlet.ServletContext;
013:
014: import org.apache.pluto.om.common.Description;
015: import org.apache.pluto.om.common.DescriptionSet;
016: import org.apache.pluto.om.common.DisplayName;
017: import org.apache.pluto.om.common.DisplayNameSet;
018: import org.apache.pluto.om.common.ObjectID;
019: import org.apache.pluto.om.common.ParameterSet;
020: import org.apache.pluto.om.common.SecurityRoleRefSet;
021: import org.apache.pluto.om.servlet.ServletDefinition;
022: import org.apache.pluto.om.servlet.ServletDefinitionCtrl;
023: import org.apache.pluto.om.servlet.WebApplicationDefinition;
024: import org.jasig.portal.container.om.common.DescriptionSetImpl;
025: import org.jasig.portal.container.om.common.DisplayNameSetImpl;
026: import org.jasig.portal.container.om.common.ObjectIDImpl;
027: import org.jasig.portal.container.om.common.ParameterSetImpl;
028: import org.jasig.portal.container.om.common.SecurityRoleRefSetImpl;
029:
030: /**
031: * Implementation of Apache Pluto object model.
032: * @author Ken Weiner, kweiner@unicon.net
033: * @version $Revision: 34757 $
034: */
035: public class ServletDefinitionImpl implements ServletDefinition,
036: ServletDefinitionCtrl, Serializable {
037:
038: private ObjectID objectId = null;
039: private String servletName = null;
040: private IconImpl icon = null;
041: private DisplayNameSet displayNames = null;
042: private DescriptionSet descriptions = null;
043: private String servletClass = null;
044: private String jspFile = null;
045: private ParameterSet parameters = null;
046: private String loadOnStartup = null;
047: private RunAsImpl runAs = null;
048: private SecurityRoleRefSet initSecurityRoleRefs = null;
049: private WebApplicationDefinition webApplicationDefinition = null;
050: private long available = 0;
051:
052: private ServletMappingImpl servletMapping = null;
053:
054: public ServletDefinitionImpl() {
055: displayNames = new DisplayNameSetImpl();
056: descriptions = new DescriptionSetImpl();
057: parameters = new ParameterSetImpl();
058: initSecurityRoleRefs = new SecurityRoleRefSetImpl();
059: }
060:
061: public ServletDefinitionImpl(String servletName, String servletClass) {
062: this ();
063: setServletName(servletName);
064: setServletClass(servletClass);
065: }
066:
067: // ServletDefinition methods
068:
069: public ObjectID getId() {
070: return objectId;
071: }
072:
073: public String getServletName() {
074: return servletName;
075: }
076:
077: public DisplayName getDisplayName(Locale locale) {
078: return displayNames.get(locale);
079: }
080:
081: public Description getDescription(Locale locale) {
082: return descriptions.get(locale);
083: }
084:
085: public String getServletClass() {
086: return servletClass;
087: }
088:
089: public ParameterSet getInitParameterSet() {
090: return parameters;
091: }
092:
093: public WebApplicationDefinition getWebApplicationDefinition() {
094: return webApplicationDefinition;
095: }
096:
097: public RequestDispatcher getRequestDispatcher(
098: ServletContext servletContext) {
099: RequestDispatcher requestDispatcher = null;
100: ServletContext newContext = webApplicationDefinition
101: .getServletContext(servletContext);
102: if (newContext != null) {
103: requestDispatcher = newContext
104: .getRequestDispatcher(servletMapping
105: .getUrlPattern());
106: }
107: return requestDispatcher;
108: }
109:
110: public long getAvailable() {
111: return available;
112: }
113:
114: public boolean isUnavailable() {
115: boolean unavailable = true;
116: if (available == 0) {
117: unavailable = false;
118: } else if (available <= System.currentTimeMillis()) {
119: available = 0;
120: unavailable = false;
121: }
122: return unavailable;
123: }
124:
125: // ServletDefinitionCtrl methods
126:
127: public void setId(String id) {
128: this .objectId = ObjectIDImpl.createFromString(id);
129: }
130:
131: public void setServletName(String name) {
132: this .servletName = name;
133: }
134:
135: public void setDisplayNames(DisplayNameSet displayNames) {
136: this .displayNames = displayNames;
137: }
138:
139: public void setDescriptions(DescriptionSet descriptions) {
140: this .descriptions = descriptions;
141: }
142:
143: public void setServletClass(String servletClass) {
144: this .servletClass = servletClass;
145: }
146:
147: public void setInitParameters(ParameterSet parameters) {
148: this .parameters = parameters;
149: }
150:
151: public void setWebApplicationDefinition(
152: WebApplicationDefinition webApplicationDefinition) {
153: this .webApplicationDefinition = webApplicationDefinition;
154: }
155:
156: public void setAvailable(long available) {
157: this .available = available;
158: }
159:
160: // Additional methods
161:
162: public IconImpl getIcon() {
163: return this .icon;
164: }
165:
166: public void setIcon(IconImpl icon) {
167: this .icon = icon;
168: }
169:
170: public DisplayNameSet getDisplayNames() {
171: return this .displayNames;
172: }
173:
174: public DescriptionSet getDescriptions() {
175: return this .descriptions;
176: }
177:
178: public String getLoadOnStartup() {
179: return this .loadOnStartup;
180: }
181:
182: public void setLoadOnStartup(String loadOnStartup) {
183: this .loadOnStartup = loadOnStartup;
184: }
185:
186: public RunAsImpl getRunAs() {
187: return this .runAs;
188: }
189:
190: public void setRunAs(RunAsImpl runAs) {
191: this .runAs = runAs;
192: }
193:
194: public String getJspFile() {
195: return this .jspFile;
196: }
197:
198: public void setJspFile(String jspFile) {
199: this .jspFile = jspFile;
200: }
201:
202: public SecurityRoleRefSet getSecurityRoleRefs() {
203: return this .initSecurityRoleRefs;
204: }
205:
206: public void setSecurityRoleRefs(
207: SecurityRoleRefSet initSecurityRoleRefs) {
208: this .initSecurityRoleRefs = initSecurityRoleRefs;
209: }
210:
211: public ServletMappingImpl getServletMapping() {
212: return this .servletMapping;
213: }
214:
215: public void setServletMapping(String servletName, String urlPattern) {
216: this .servletMapping = new ServletMappingImpl(servletName,
217: urlPattern);
218: }
219:
220: }
|