}
if (servletName == null) {
// classname is default servletName as annotation has no name!
servletName = className;
}
ServletDef servletDef = fragment.getServlets().get(servletName);
boolean isWebXMLservletDef;
if (servletDef == null) {
servletDef = new ServletDef();
servletDef.setServletName(servletName);
servletDef.setServletClass(className);
isWebXMLservletDef = false;
} else {
isWebXMLservletDef = true;
}
boolean urlPatternsSet = false;
String[] urlPatterns = null;
// ElementValuePair[] evps = ae.getElementValuePairs();
for (ElementValuePair evp : evps) {
String name = evp.getNameString();
if ("value".equals(name) || "urlPatterns".equals(name)) {
if (urlPatternsSet) {
throw new IllegalArgumentException(sm.getString(
"contextConfig.urlPatternValue", className));
}
urlPatternsSet = true;
urlPatterns = processAnnotationsStringArray(evp.getValue());
} else if ("description".equals(name)) {
if (servletDef.getDescription() == null) {
servletDef.setDescription(evp.getValue().stringifyValue());
}
} else if ("displayName".equals(name)) {
if (servletDef.getDisplayName() == null) {
servletDef.setDisplayName(evp.getValue().stringifyValue());
}
} else if ("largeIcon".equals(name)) {
if (servletDef.getLargeIcon() == null) {
servletDef.setLargeIcon(evp.getValue().stringifyValue());
}
} else if ("smallIcon".equals(name)) {
if (servletDef.getSmallIcon() == null) {
servletDef.setSmallIcon(evp.getValue().stringifyValue());
}
} else if ("asyncSupported".equals(name)) {
if (servletDef.getAsyncSupported() == null) {
servletDef.setAsyncSupported(evp.getValue()
.stringifyValue());
}
} else if ("loadOnStartup".equals(name)) {
if (servletDef.getLoadOnStartup() == null) {
servletDef
.setLoadOnStartup(evp.getValue().stringifyValue());
}
} else if ("initParams".equals(name)) {
Map<String, String> initParams = processAnnotationWebInitParams(evp
.getValue());
if (isWebXMLservletDef) {
Map<String, String> webXMLInitParams = servletDef
.getParameterMap();
for (Map.Entry<String, String> entry : initParams
.entrySet()) {
if (webXMLInitParams.get(entry.getKey()) == null) {
servletDef.addInitParameter(entry.getKey(), entry
.getValue());
}
}
} else {
for (Map.Entry<String, String> entry : initParams
.entrySet()) {
servletDef.addInitParameter(entry.getKey(), entry
.getValue());
}
}
}
}