1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271
|
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.tomcat.util.descriptor.web;
import java.io.Serial;
import java.io.Serializable;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.apache.tomcat.util.res.StringManager;
/**
* Representation of a servlet definition for a web application, as represented in a <code><servlet></code>
* element in the deployment descriptor.
*/
public class ServletDef implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
private static final StringManager sm = StringManager.getManager(Constants.PACKAGE_NAME);
// ------------------------------------------------------------- Properties
/**
* The description of this servlet.
*/
private String description = null;
public String getDescription() {
return this.description;
}
public void setDescription(String description) {
this.description = description;
}
/**
* The display name of this servlet.
*/
private String displayName = null;
public String getDisplayName() {
return this.displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
/**
* The small icon associated with this servlet.
*/
private String smallIcon = null;
public String getSmallIcon() {
return this.smallIcon;
}
public void setSmallIcon(String smallIcon) {
this.smallIcon = smallIcon;
}
/**
* The large icon associated with this servlet.
*/
private String largeIcon = null;
public String getLargeIcon() {
return this.largeIcon;
}
public void setLargeIcon(String largeIcon) {
this.largeIcon = largeIcon;
}
/**
* The name of this servlet, which must be unique among the servlets defined for a particular web application.
*/
private String servletName = null;
public String getServletName() {
return this.servletName;
}
public void setServletName(String servletName) {
if (servletName == null || servletName.isEmpty()) {
throw new IllegalArgumentException(sm.getString("servletDef.invalidServletName", servletName));
}
this.servletName = servletName;
}
/**
* The fully qualified name of the Java class that implements this servlet.
*/
private String servletClass = null;
public String getServletClass() {
return this.servletClass;
}
public void setServletClass(String servletClass) {
this.servletClass = servletClass;
}
/**
* The name of the JSP file to which this servlet definition applies
*/
private String jspFile = null;
public String getJspFile() {
return this.jspFile;
}
public void setJspFile(String jspFile) {
this.jspFile = jspFile;
}
/**
* The set of initialization parameters for this servlet, keyed by parameter name.
*/
private final Map<String,String> parameters = new HashMap<>();
public Map<String,String> getParameterMap() {
return this.parameters;
}
/**
* Add an initialization parameter to the set of parameters associated with this servlet.
*
* @param name The initialisation parameter name
* @param value The initialisation parameter value
*/
public void addInitParameter(String name, String value) {
if (parameters.containsKey(name)) {
// The spec does not define this but the TCK expects the first
// definition to take precedence
return;
}
parameters.put(name, value);
}
/**
* The load-on-startup order for this servlet
*/
private Integer loadOnStartup = null;
public Integer getLoadOnStartup() {
return this.loadOnStartup;
}
public void setLoadOnStartup(String loadOnStartup) {
this.loadOnStartup = Integer.valueOf(loadOnStartup);
}
/**
* The run-as configuration for this servlet
*/
private String runAs = null;
public String getRunAs() {
return this.runAs;
}
public void setRunAs(String runAs) {
this.runAs = runAs;
}
/**
* The set of security role references for this servlet
*/
private final Set<SecurityRoleRef> securityRoleRefs = new HashSet<>();
public Set<SecurityRoleRef> getSecurityRoleRefs() {
return this.securityRoleRefs;
}
/**
* Add a security-role-ref to the set of security-role-refs associated with this servlet.
*
* @param securityRoleRef The security role
*/
public void addSecurityRoleRef(SecurityRoleRef securityRoleRef) {
securityRoleRefs.add(securityRoleRef);
}
/**
* The multipart configuration, if any, for this servlet
*/
private MultipartDef multipartDef = null;
public MultipartDef getMultipartDef() {
return this.multipartDef;
}
public void setMultipartDef(MultipartDef multipartDef) {
this.multipartDef = multipartDef;
}
/**
* Does this servlet support async.
*/
private Boolean asyncSupported = null;
public Boolean getAsyncSupported() {
return this.asyncSupported;
}
public void setAsyncSupported(String asyncSupported) {
this.asyncSupported = Boolean.valueOf(asyncSupported);
}
/**
* Is this servlet enabled.
*/
private Boolean enabled = null;
public Boolean getEnabled() {
return this.enabled;
}
public void setEnabled(String enabled) {
this.enabled = Boolean.valueOf(enabled);
}
/**
* Can this ServletDef be overridden by an SCI?
*/
private boolean overridable = false;
public boolean isOverridable() {
return overridable;
}
public void setOverridable(boolean overridable) {
this.overridable = overridable;
}
}
|