dispatchServletClass.trim().length() == 0) {
dispatchServletClass = DISPATCH_SERVLET_CLASS;
}
WebAppDescriptorService descriptorSvc = new WebAppDescriptorServiceImpl();
WebAppDD webAppDDIn = descriptorSvc.read(webXmlIn);
PortletAppDescriptorService portletAppDescriptorService =
new PortletAppDescriptorServiceImpl();
PortletAppDD portletAppDD = portletAppDescriptorService.read(portletXmlIn);
portletXmlIn.close();
for (Iterator it = portletAppDD.getPortlets().iterator();
it.hasNext(); ) {
// Read portlet definition.
PortletDD portlet = (PortletDD) it.next();
String name = portlet.getPortletName();
ServletDD servlet = new ServletDD();
servlet.setServletName(name);
servlet.setServletClass(dispatchServletClass);
InitParamDD initParam = new InitParamDD();
initParam.setParamName("portlet-name");
initParam.setParamValue(name);
servlet.getInitParams().add(initParam);
LoadOnStartupDD onStartup = new LoadOnStartupDD();
onStartup.setPriority(1);
servlet.setLoadOnStartup(onStartup);
ServletMappingDD servletMapping = new ServletMappingDD();
servletMapping.setServletName(name);
servletMapping.setUrlPattern("/PlutoInvoker/" + name);
webAppDDIn.getServlets().add(servlet);
webAppDDIn.getServletMappings().add(servletMapping);
}
descriptorSvc.write(webAppDDIn, webXmlOut);
}