cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ghow...@apache.org
Subject cvs commit: cocoon-2.1/tools/src blocks-build.xsl
Date Fri, 23 May 2003 02:48:04 GMT
ghoward     2003/05/22 19:48:04

  Modified:    tools/src/anttasks XConfToolTask.java
               src/webapp/WEB-INF web.xml
               .        build.properties
               tools/src blocks-build.xsl
  Added:       src/blocks/databases/conf postgresql.driver.xweb
                        odbc.driver.xweb oracle.driver.xweb
               src/blocks/hsqldb/conf hsql.driver.xweb
  Log:
  New build feature to patch web.xml with .xweb files in 
  blocks conf directories.  .xweb files included for drivers 
  for odbc, oracle, postgre, and hsql
  
  Revision  Changes    Path
  1.1                  cocoon-2.1/src/blocks/databases/conf/postgresql.driver.xweb
  
  Index: postgresql.driver.xweb
  ===================================================================
  <xweb xpath="/web-app/servlet/init-param[param-name='load-class']/param-value"
  	unless="text()[contains(string(.),'org.postgresql.Driver')] | 
  	comment()[contains(string(.),'org.postgresql.Driver')]"
  	if-prop="include.driver.postgre">
          <!-- For PostgeSQL Database: -->
               org.postgresql.Driver 
  </xweb>
  
  
  1.1                  cocoon-2.1/src/blocks/databases/conf/odbc.driver.xweb
  
  Index: odbc.driver.xweb
  ===================================================================
  <xweb xpath="/web-app/servlet/init-param[param-name='load-class']/param-value"
  	unless="text()[contains(string(.),'sun.jdbc.odbc.JdbcOdbcDriver')] | 
  	comment()[contains(string(.),'sun.jdbc.odbc.JdbcOdbcDriver')]"
  	if-prop="include.driver.odbc">
          <!-- ODBC -->
               sun.jdbc.odbc.JdbcOdbcDriver
  </xweb>
  
  
  1.1                  cocoon-2.1/src/blocks/databases/conf/oracle.driver.xweb
  
  Index: oracle.driver.xweb
  ===================================================================
  <xweb xpath="/web-app/servlet/init-param[param-name='load-class']/param-value"
  	unless="text()[contains(string(.),'oracle.jdbc.driver.OracleDriver')] | 
  	comment()[contains(string(.),'oracle.jdbc.driver.OracleDriver')]"
  	if-prop="include.driver.oracle">
          <!-- For Oracle Database: -->
               oracle.jdbc.driver.OracleDriver 
  </xweb>
  
  
  1.5       +41 -4     cocoon-2.1/tools/src/anttasks/XConfToolTask.java
  
  Index: XConfToolTask.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/tools/src/anttasks/XConfToolTask.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- XConfToolTask.java	16 May 2003 07:06:10 -0000	1.4
  +++ XConfToolTask.java	23 May 2003 02:48:03 -0000	1.5
  @@ -54,6 +54,7 @@
   import org.apache.tools.ant.Project;
   import org.apache.tools.ant.Task;
   import org.apache.tools.ant.taskdefs.MatchingTask;
  +import org.apache.tools.ant.types.XMLCatalog;
   import org.apache.xpath.XPathAPI;
   import org.w3c.dom.Document;
   import org.w3c.dom.DocumentType;
  @@ -78,6 +79,7 @@
   import java.io.FileInputStream;
   import java.io.FileWriter;
   import java.io.IOException;
  +import java.net.UnknownHostException;
   
   /**
    * Ant task to patch xmlfiles.
  @@ -94,6 +96,8 @@
       private File file;
       private File directory;
       private File srcdir;
  +    /** for resolving entities such as dtds */
  +    private XMLCatalog xmlCatalog = new XMLCatalog();
   
       /**
        * Set file, which should be patched.
  @@ -114,6 +118,25 @@
       }
   
       /**
  +     * Add the catalog to our internal catalog
  +     *
  +     * @param xmlCatalog the XMLCatalog instance to use to look up DTDs
  +     */
  +    public void addConfiguredXMLCatalog(XMLCatalog xmlCatalog)
  +    {
  +      this.xmlCatalog.addConfiguredXMLCatalog(xmlCatalog);
  +    }
  +
  +    /**
  +     * Initialize internal instance of XMLCatalog
  +     */
  +    public void init() throws BuildException
  +    {
  +      super.init();
  +      xmlCatalog.setProject(project);
  +    }
  +
  +    /**
        * Execute task.
        */
       public void execute() throws BuildException {
  @@ -124,7 +147,14 @@
           }
   
           try {
  -            final DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
  +            final DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
  +            builderFactory.setValidating(false);
  +            builderFactory.setExpandEntityReferences(false);
  +            builderFactory.setNamespaceAware(false);
  +            builderFactory.setAttribute(
  +                "http://apache.org/xml/features/nonvalidating/load-external-dtd",
  +                new Boolean(false));
  +            final DocumentBuilder builder = builderFactory.newDocumentBuilder();
               final Transformer transformer = TransformerFactory.newInstance().newTransformer();
   
               // load xml
  @@ -173,6 +203,8 @@
               throw new BuildException("SAXException: "+e);
           } catch (ParserConfigurationException e) {
               throw new BuildException("ParserConfigurationException: "+e);
  +        } catch (UnknownHostException e) {
  +            throw new BuildException("UnknownHostException.  Probable cause: The parser
is " +
                "trying to resolve a dtd from the internet and no connection exists.\n"
+
                "You can either connect to the internet during the build, or patch \n" +
               "XConfToolTask.java to ignore DTD declarations when your parser is in use.");
           } catch (IOException ioe) {
               throw new BuildException("IOException: "+ioe);
           }
  @@ -216,8 +248,13 @@
   
           // Test that 'root' node satisfies 'component' insertion criteria
           String test = component.getDocumentElement().getAttribute("unless");
  -
  -        if ((test!=null) && (test.length()>0) &&
  +        String ifProp = component.getDocumentElement().getAttribute("if-prop");
  +        boolean ifValue = Boolean.valueOf(project.getProperty(ifProp)).booleanValue();
  +     
  +        if (ifProp != null && (ifProp.length()>0) && !ifValue ) {
  +            log("Skipping: " + file, Project.MSG_DEBUG);
  +            return false;
  +        } else if ((test!=null) && (test.length()>0) &&
               (XPathAPI.selectNodeList(root, test).getLength()!=0)) {
               log("Skipping: " + file, Project.MSG_DEBUG);
               return false;
  
  
  
  1.5       +5 -17     cocoon-2.1/src/webapp/WEB-INF/web.xml
  
  Index: web.xml
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/webapp/WEB-INF/web.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- web.xml	20 May 2003 12:38:27 -0000	1.4
  +++ web.xml	23 May 2003 02:48:03 -0000	1.5
  @@ -109,29 +109,17 @@
       <!--
         This parameter is used to list classes that should be loaded
         at initialization time of the servlet.
  -      Usually this classes are JDBC Drivers used
  +      For example, JDBC Drivers used need to be named here.
  +      Additional entries may be inserted here during build depending on your 
  +      build properties.
       -->
       <init-param>
         <param-name>load-class</param-name>
         <param-value>
  +        <!-- For parent ComponentManager sample:
  +        org.apache.cocoon.samples.parentcm.Configurator -->
           <!-- For IBM WebSphere:
           com.ibm.servlet.classloader.Handler -->
  -
  -        <!-- For Database Driver: -->
  -        org.hsqldb.jdbcDriver
  -
  -        <!-- For PostgeSQL Database: 
  -             org.postgresql.Driver -->
  -
  -        <!-- For Oracle Database:
  -             oracle.jdbc.driver.OracleDriver -->
  -
  -        <!-- ODBC 
  -             sun.jdbc.odbc.JdbcOdbcDriver -->
  - 
  -        <!-- For parent ComponentManager sample:
  -        org.apache.cocoon.samples.parentcm.Configurator
  -        -->
         </param-value>
       </init-param>
   
  
  
  
  1.1                  cocoon-2.1/src/blocks/hsqldb/conf/hsql.driver.xweb
  
  Index: hsql.driver.xweb
  ===================================================================
  <xweb xpath="/web-app/servlet/init-param[param-name='load-class']/param-value"
  	unless="text()[contains(string(.),'org.hsqldb.jdbcDriver')] | 
  		comment()[contains(string(.),'org.hsqldb.jdbcDriver')]">
          <!-- For Database Driver: -->
          org.hsqldb.jdbcDriver
  
  </xweb>
  
  
  1.19      +6 -0      cocoon-2.1/build.properties
  
  Index: build.properties
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/build.properties,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- build.properties	21 May 2003 15:15:49 -0000	1.18
  +++ build.properties	23 May 2003 02:48:04 -0000	1.19
  @@ -22,6 +22,12 @@
   #exclude.javadocs=true
   #exclude.idldocs=true
   
  +# ---- Configuration -----------------------------------------------------------
  +
  +#include.driver.oracle=true
  +#include.driver.postgre=true
  +#include.driver.odbc=true
  +
   # ---- Validation --------------------------------------------------------------
   
   validate.config=true
  
  
  
  1.19      +7 -0      cocoon-2.1/tools/src/blocks-build.xsl
  
  Index: blocks-build.xsl
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/tools/src/blocks-build.xsl,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- blocks-build.xsl	14 May 2003 15:21:44 -0000	1.18
  +++ blocks-build.xsl	23 May 2003 02:48:04 -0000	1.19
  @@ -100,6 +100,13 @@
                  <include name="{$block-name}/conf/**/*.xlog" unless="unless.exclude.block.{$block-name}"/>
               </xsl:for-each>
            </xpatch>
  +         <xpatch file="{string('${build.webapp}')}/WEB-INF/web.xml"
  +                 srcdir="{string('${blocks}')}">
  +            <xsl:for-each select="project[contains(@name,'cocoon-block-')]">
  +               <xsl:variable name="block-name" select="substring-after(@name,'cocoon-block-')"/>
  +               <include name="{$block-name}/conf/**/*.xweb" unless="unless.exclude.block.{$block-name}"/>
  +            </xsl:for-each>
  +         </xpatch>
         </target>
   
         <target name="patch-samples" depends="init">
  
  
  

Mime
View raw message