server = (Server)servletContext.getAttribute(id);
if (null == server) {
String spec = getSpec(config);
try {
server = new Server(spec, false);
CommonContext commonContext = server.getCommonContext();
if (null != overrides) {
commonContext.putAll(overrides);
}
if (!commonContext.contains(MojasefConstants.MOJASEF_SERVER_NAME)) {
commonContext.put(MojasefConstants.MOJASEF_SERVER_NAME, servletName);
}
servletContext.setAttribute(id, server);
Integer obj = (Integer)servletContext.getAttribute(MOJASEF_SERVLET_INSTANCE_COUNT);
int icount = (obj != null) ? obj.intValue() + 1 : 1;
servletContext.setAttribute(MOJASEF_SERVLET_INSTANCE_COUNT, new Integer(icount));
@SuppressWarnings("unchecked")
Enumeration<String> at = servletContext.getAttributeNames();
while (at.hasMoreElements()) {
String name = at.nextElement();
Object value = servletContext.getAttribute(name);
commonContext.put(name, value);
}
@SuppressWarnings("unchecked")
Enumeration<String> pn = config.getInitParameterNames();
while (pn.hasMoreElements()) {
String name = pn.nextElement();
Object value = config.getInitParameter(name);
commonContext.put(name, value);
}
} catch (IOException e) {
throw new ServletException(e);
}
}