taylor 2004/08/05 11:54:47
Modified: components/deploy-tool/src/java/org/apache/jetspeed/tools/deploy
JetspeedWebApplicationRewriter.java
Log:
double check for register at init init paramwhen rewriting web.xml
CVS: ----------------------------------------------------------------------
CVS: PR:
CVS: If this change addresses a PR in the problem report tracking
CVS: database, then enter the PR number(s) here.
CVS: Obtained from:
CVS: If this change has been taken from another system, such as NCSA,
CVS: then name the system in this line, otherwise delete it.
CVS: Submitted by:
CVS: If this code has been contributed to Apache by someone else; i.e.,
CVS: they sent us a patch or a new module, then include their name/email
CVS: address here. If this is your work then delete this line.
CVS: Reviewed by:
CVS: If we are doing pre-commit code reviews and someone else has
CVS: reviewed your changes, include their name(s) here.
CVS: If you have not had it reviewed then delete this line.
Revision Changes Path
1.5 +39 -18
jakarta-jetspeed-2/components/deploy-tool/src/java/org/apache/jetspeed/tools/deploy/JetspeedWebApplicationRewriter.java
Index: JetspeedWebApplicationRewriter.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/components/deploy-tool/src/java/org/apache/jetspeed/tools/deploy/JetspeedWebApplicationRewriter.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- JetspeedWebApplicationRewriter.java 22 Jul 2004 23:38:39 -0000 1.4
+++ JetspeedWebApplicationRewriter.java 5 Aug 2004 18:54:47 -0000 1.5
@@ -40,7 +40,10 @@
*/
public class JetspeedWebApplicationRewriter
{
+ public static final String REGISTER_AT_INIT = "registerAtInit";
+ public static final String JETSPEED_CONTAINER = "JetspeedContainer";
public static final String JETSPEED_SERVLET_XPATH =
"/web-app/servlet/servlet-name[contains(child::text(), \"JetspeedContainer\")]";
+ public static final String REGISTER_AT_INIT_XPATH =
"/init-param/param-name[contains(child::text(), \"registerAtInit\")]";
public static final String JETSPEED_SERVLET_MAPPING_XPATH =
"/web-app/servlet-mapping/servlet-name[contains(child::text(),
\"JetspeedContainer\")]";
protected static final String WEB_XML_PATH = "WEB-INF/web.xml";
@@ -55,6 +58,7 @@
private boolean changed = false;
private boolean registerAtInit = false;
+
public JetspeedWebApplicationRewriter(Document doc, String portletApplication,
boolean registerAtInit)
{
this.document = doc;
@@ -119,7 +123,7 @@
if (jetspeedServlet == null)
{
Element jetspeedServletElement = new Element("servlet");
- Element servletName = (Element) new
Element("servlet-name").addContent("JetspeedContainer");
+ Element servletName = (Element) new
Element("servlet-name").addContent(JETSPEED_CONTAINER);
Element servletDspName = (Element) new
Element("display-name").addContent("Jetspeed Container");
Element servletDesc = (Element) new Element("description")
.addContent("MVC Servlet for Jetspeed Portlet
Applications");
@@ -131,33 +135,30 @@
jetspeedServletElement.addContent(servletClass);
if (this.registerAtInit)
{
- Element paramName = (Element) new
Element("param-name").addContent("registerAtInit");
- Element paramValue = (Element) new
Element("param-value").addContent("1");
- Element initParam = new Element("init-param");
- initParam.addContent(paramName);
- initParam.addContent(paramValue);
- jetspeedServletElement.addContent(initParam);
-
- Element param2Name = (Element) new
Element("param-name").addContent("portletApplication");
- Element param2Value = (Element) new
Element("param-value").addContent(portletApplication);
- Element init2Param = new Element("init-param");
- init2Param.addContent(param2Name);
- init2Param.addContent(param2Value);
- jetspeedServletElement.addContent(init2Param);
-
- Element loadOnStartup = (Element) new
Element("load-on-startup").addContent("100");
- jetspeedServletElement.addContent(loadOnStartup);
+ insertRegisterAtInit(jetspeedServletElement);
}
insertElementCorrectly(root, jetspeedServletElement,
ELEMENTS_BEFORE_SERVLET);
changed = true;
}
+ else
+ {
+ // double check for register at Init
+ if (this.registerAtInit && jetspeedServlet instanceof Element)
+ {
+ Element jetspeedServletElement =(Element)jetspeedServlet;
+ if (null == XPath.selectSingleNode(jetspeedServletElement,
REGISTER_AT_INIT_XPATH))
+ {
+ insertRegisterAtInit(jetspeedServletElement);
+ }
+ }
+ }
if (jetspeedServletMapping == null)
{
Element jetspeedServletMappingElement = new
Element("servlet-mapping");
- Element servletMapName = (Element) new
Element("servlet-name").addContent("JetspeedContainer");
+ Element servletMapName = (Element) new
Element("servlet-name").addContent(JETSPEED_CONTAINER);
Element servletUrlPattern = (Element) new
Element("url-pattern").addContent("/container/*");
jetspeedServletMappingElement.addContent(servletMapName);
@@ -172,6 +173,26 @@
throw new Exception("Unable to process web.xml for infusion " +
e.toString(), e);
}
+ }
+
+ private void insertRegisterAtInit(Element jetspeedServletElement)
+ {
+ Element paramName = (Element) new
Element("param-name").addContent(REGISTER_AT_INIT);
+ Element paramValue = (Element) new Element("param-value").addContent("1");
+ Element initParam = new Element("init-param");
+ initParam.addContent(paramName);
+ initParam.addContent(paramValue);
+ jetspeedServletElement.addContent(initParam);
+
+ Element param2Name = (Element) new
Element("param-name").addContent("portletApplication");
+ Element param2Value = (Element) new
Element("param-value").addContent(portletApplication);
+ Element init2Param = new Element("init-param");
+ init2Param.addContent(param2Name);
+ init2Param.addContent(param2Value);
+ jetspeedServletElement.addContent(init2Param);
+
+ Element loadOnStartup = (Element) new
Element("load-on-startup").addContent("100");
+ jetspeedServletElement.addContent(loadOnStartup);
}
public boolean isChanged()
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]