1 16 package org.apache.cocoon.portal.pluto.om; 17 18 import java.util.Collection ; 19 import java.util.Locale ; 20 21 import javax.servlet.RequestDispatcher ; 22 import javax.servlet.ServletContext ; 23 24 import org.apache.pluto.om.common.Description; 25 import org.apache.pluto.om.common.DescriptionSet; 26 import org.apache.pluto.om.common.DisplayName; 27 import org.apache.pluto.om.common.DisplayNameSet; 28 import org.apache.pluto.om.common.ObjectID; 29 import org.apache.pluto.om.common.ParameterSet; 30 import org.apache.pluto.om.common.SecurityRoleRefSet; 31 import org.apache.pluto.om.servlet.ServletDefinition; 32 import org.apache.pluto.om.servlet.ServletDefinitionCtrl; 33 import org.apache.pluto.om.servlet.WebApplicationDefinition; 34 import org.apache.cocoon.portal.pluto.om.common.ParameterSetImpl; 35 import org.apache.cocoon.portal.pluto.om.common.SecurityRoleRefSetImpl; 36 import org.apache.cocoon.portal.pluto.om.common.Support; 37 import org.apache.cocoon.portal.pluto.om.common.DescriptionSetImpl; 38 import org.apache.cocoon.portal.pluto.om.common.DisplayNameSetImpl; 39 40 47 public class ServletDefinitionImpl 48 implements ServletDefinition, ServletDefinitionCtrl, java.io.Serializable , Support { 49 50 private DescriptionSet descriptions = new DescriptionSetImpl(); 51 private DisplayNameSet displayNames = new DisplayNameSetImpl(); 52 53 public String icon; 55 private String id = ""; 56 private ParameterSet initParams = new ParameterSetImpl(); 57 private SecurityRoleRefSet initSecurityRoleRefs = new SecurityRoleRefSetImpl(); 58 public String jspFile; 59 public String loadOnStartup; 60 private ObjectID objectId; 61 public String securityRoleRef; 62 private String servletClass; 63 private ServletMapping servletMapping; 64 private String servletName; 65 private long available = 0; 66 67 private WebApplicationDefinition webApplication; 68 69 71 public ObjectID getId() { 72 if (objectId==null) { 73 objectId = org.apache.cocoon.portal.pluto.om.common.ObjectIDImpl.createFromString(id); 74 } 75 return objectId; 76 } 77 78 public String getServletName() { 79 return servletName; 80 } 81 82 public DisplayName getDisplayName(Locale locale) { 83 return displayNames.get(locale); 84 } 85 86 89 public Description getDescription(Locale locale) { 90 return descriptions.get(locale); 91 } 92 93 public String getServletClass() { 94 return servletClass; 95 } 96 97 public ParameterSet getInitParameterSet() { 98 return initParams; 99 } 100 101 public WebApplicationDefinition getWebApplicationDefinition() { 102 return webApplication; 103 } 104 105 public RequestDispatcher getRequestDispatcher(ServletContext servletContext) { 106 ServletContext newContext = webApplication.getServletContext(servletContext); 107 if (newContext==null) { 108 return null; 109 } 110 return newContext.getRequestDispatcher(servletMapping.getUrlPattern()); 111 } 112 113 public long getAvailable() { 114 return available; 115 } 116 117 public boolean isUnavailable() { 118 if (available == 0) { 119 return false; 120 } else if (available <= System.currentTimeMillis()) { 121 available = 0; 122 return false; 123 } else { 124 return true; 125 } 126 } 127 128 130 public void postBuild(Object parameter) throws Exception { 131 setServletMapping((ServletMapping)parameter); 132 } 133 134 135 public void postLoad(Object parameter) throws Exception { 136 ((Support)descriptions).postLoad(parameter); 137 ((Support)displayNames).postLoad(parameter); 138 } 139 140 public void postStore(Object parameter) throws Exception { 141 } 143 144 public void preBuild(Object parameter) throws Exception { 145 setWebApplicationDefinition((WebApplicationDefinition)parameter); 146 } 147 148 public void preStore(Object parameter) throws Exception { 149 } 151 152 154 public String getCastorId() { 155 if (id.length() > 0) { 156 return getId().toString(); 157 } 158 return null; 159 } 160 161 public Collection getCastorInitParams() { 162 return(ParameterSetImpl)initParams; 163 } 164 165 public SecurityRoleRefSet getCastorInitSecurityRoleRefs() { 166 return initSecurityRoleRefs; 167 } 168 169 public Collection getCastorDisplayNames() { 170 return(DisplayNameSetImpl)displayNames; 171 } 172 173 public Collection getCastorDescriptions() { 174 return(DescriptionSetImpl)descriptions; 175 } 176 177 public Collection getDescriptions() { 178 return(DescriptionSetImpl)descriptions; 179 } 180 181 public SecurityRoleRefSet getInitSecurityRoleRefSet() { 182 return initSecurityRoleRefs; 183 } 184 185 public String getJspFile() { 186 return jspFile; 187 } 188 189 public void setCastorId(String id) { 190 setId(id); 191 } 192 193 public void setCastorInitSecurityRoleRefs(SecurityRoleRefSet castorInitSecurityRoleRefs) { 194 this.initSecurityRoleRefs = castorInitSecurityRoleRefs; 195 } 196 197 public void setCastorDisplayNames(DisplayNameSet castorDisplayNames) { 198 this.displayNames = castorDisplayNames; 199 } 200 201 public void setCastorDescriptions(DescriptionSet castorDescriptions) { 202 this.descriptions = castorDescriptions; 203 } 204 205 public void setDisplayNames(DisplayNameSet displayNames) { 206 this.displayNames = displayNames; 207 } 208 209 public void setDescriptions(DescriptionSet descriptions) { 210 this.descriptions = descriptions; 211 } 212 213 public void setId(String id) { 214 this.id = id; 215 this.objectId = null; 216 } 217 218 public void setServletClass(String servletClass) { 219 this.servletClass = servletClass; 220 } 221 222 public void setAvailable(long available) { 223 if (available > System.currentTimeMillis()) { 224 this.available = available; 225 } else { 226 this.available = 0; 227 } 228 } 229 230 public void setJspFile(String jspFile) { 231 this.jspFile = jspFile; 232 } 233 234 protected void setServletMapping(ServletMapping servletMapping) { 235 this.servletMapping = servletMapping; 236 } 237 238 public void setServletName(String servletName) { 239 this.servletName = servletName; 240 } 241 242 protected void setWebApplicationDefinition(WebApplicationDefinition webApplication) { 243 this.webApplication = webApplication; 244 } 245 246 } 247 | Popular Tags |