// Add the WAR client
component.getClients().add(
createWarClient(component.getContext(), getServletConfig()));
// Copy all the servlet parameters into the context
final ComponentContext componentContext = (ComponentContext) component
.getContext();
String initParam;
// Copy all the Servlet container initialization parameters
final javax.servlet.ServletConfig servletConfig = getServletConfig();
for (final Enumeration<String> enum1 = servletConfig
.getInitParameterNames(); enum1.hasMoreElements();) {
initParam = enum1.nextElement();
componentContext.getParameters().add(initParam,
servletConfig.getInitParameter(initParam));
}
// Copy all the Servlet application initialization parameters
for (final Enumeration<String> enum1 = getServletContext()
.getInitParameterNames(); enum1.hasMoreElements();) {
initParam = enum1.nextElement();
componentContext.getParameters().add(initParam,
getServletContext().getInitParameter(initParam));
}
// Copy all Servlet's context attributes
String attributeName;
for (final Enumeration<String> namesEnum = getServletContext()
.getAttributeNames(); namesEnum.hasMoreElements();) {
attributeName = namesEnum.nextElement();
componentContext.getAttributes().put(attributeName,
getServletContext().getAttribute(attributeName));
}
return component;
}