You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by re...@apache.org on 2006/06/29 18:38:23 UTC
svn commit: r418080 - in
/cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main:
java/org/apache/cocoon/maven/deployer/
java/org/apache/cocoon/maven/deployer/monolithic/
resources/org/apache/cocoon/maven/deployer/monolithic/ resource...
Author: reinhard
Date: Thu Jun 29 09:38:23 2006
New Revision: 418080
URL: http://svn.apache.org/viewvc?rev=418080&view=rev
Log:
fix problems with sitemap mounts of blocks; refactor AbstractDeployMojo: move web.xml rewritting code into a method
Added:
cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/resources/org/apache/cocoon/maven/deployer/monolithic/blocks/
cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/resources/org/apache/cocoon/maven/deployer/monolithic/blocks/sitemap.xmap (with props)
Modified:
cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/AbstractDeployMojo.java
cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/monolithic/MonolithicCocoonDeployer.java
cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/resources/org/apache/cocoon/maven/deployer/monolithic/sitemap.xmap
Modified: cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/AbstractDeployMojo.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/AbstractDeployMojo.java?rev=418080&r1=418079&r2=418080&view=diff
==============================================================================
--- cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/AbstractDeployMojo.java (original)
+++ cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/AbstractDeployMojo.java Thu Jun 29 09:38:23 2006
@@ -179,52 +179,9 @@
// take care of paranoid classloading
if ( this.useShieldingClassloader ) {
- String webXmlLocation = this.getWebXml();
- if ( webXmlLocation == null ) {
- webXmlLocation = getWarSourceDirectory().getAbsolutePath() + File.separatorChar + "WEB-INF" + File.separatorChar + "web.xml";
- }
- this.getLog().info("Adding shielded classloader configuration to webapp configuration.");
- this.getLog().debug("Reading web.xml: " + webXmlLocation);
- try {
- final Document webAppDoc = XMLUtils.parseXml(new FileInputStream(new File(webXmlLocation)));
- WebApplicationRewriter.rewrite(webAppDoc);
- final String dest = webappDirectory_.getAbsolutePath() + File.separatorChar + "WEB-INF" + File.separatorChar + "web.xml";
- this.getLog().debug("Writing web.xml: " + dest);
- XMLUtils.write(webAppDoc, new FileOutputStream(dest));
- } catch (Exception e) {
- throw new MojoExecutionException("Unable to read web.xml from " + webXmlLocation, e);
- }
- if ( this.useShieldingRepository ) {
- this.getLog().info("Moving classes and libs to shielded location.");
- final String webInfDir = webappDirectory_.getAbsolutePath() + File.separatorChar + "WEB-INF";
- this.move(webInfDir, "lib", "cocoon-lib");
- this.move(webInfDir, "classes", "cocoon-classes");
- }
- }
- }
-
- protected void move(String parentDir, String srcDir, String destDir) {
- final File srcDirectory = new File(parentDir, srcDir);
- if ( srcDirectory.exists() && srcDirectory.isDirectory() ) {
- File destDirectory = new File(parentDir, destDir);
- destDirectory.delete();
- destDirectory = new File(parentDir, destDir);
- destDirectory.mkdir();
- final File[] files = srcDirectory.listFiles();
- if ( files != null && files.length > 0 ) {
- for(int i=0; i<files.length; i++) {
- // TODO - replace this hard-coded exlclude with something configurable
- boolean exclude = false;
- if ( "lib".equals(srcDir) && files[i].getName().startsWith("cocoon-bootstrap") ) {
- exclude = true;
- }
- if ( !exclude ) {
- files[i].renameTo(new File(destDirectory, files[i].getName()));
- }
- }
- }
+ rewriteWebXml();
}
- }
+ }
/**
* Deploy a particular block at development time.
@@ -296,4 +253,54 @@
return false;
}
+ // ~~~~~~~~~~ utility methods ~~~~~~~~~~~
+
+ private void rewriteWebXml() throws MojoExecutionException {
+ File webappDirectory_ = getWebappDirectory();
+ String webXmlLocation = this.getWebXml();
+ if ( webXmlLocation == null ) {
+ webXmlLocation = getWarSourceDirectory().getAbsolutePath() + File.separatorChar + "WEB-INF" + File.separatorChar + "web.xml";
+ }
+ this.getLog().info("Adding shielded classloader configuration to webapp configuration.");
+ this.getLog().debug("Reading web.xml: " + webXmlLocation);
+ try {
+ final Document webAppDoc = XMLUtils.parseXml(new FileInputStream(new File(webXmlLocation)));
+ WebApplicationRewriter.rewrite(webAppDoc);
+ final String dest = webappDirectory_.getAbsolutePath() + File.separatorChar + "WEB-INF" + File.separatorChar + "web.xml";
+ this.getLog().debug("Writing web.xml: " + dest);
+ XMLUtils.write(webAppDoc, new FileOutputStream(dest));
+ } catch (Exception e) {
+ throw new MojoExecutionException("Unable to read web.xml from " + webXmlLocation, e);
+ }
+ if ( this.useShieldingRepository ) {
+ this.getLog().info("Moving classes and libs to shielded location.");
+ final String webInfDir = webappDirectory_.getAbsolutePath() + File.separatorChar + "WEB-INF";
+ this.move(webInfDir, "lib", "cocoon-lib");
+ this.move(webInfDir, "classes", "cocoon-classes");
+ }
+ }
+
+ private void move(String parentDir, String srcDir, String destDir) {
+ final File srcDirectory = new File(parentDir, srcDir);
+ if ( srcDirectory.exists() && srcDirectory.isDirectory() ) {
+ File destDirectory = new File(parentDir, destDir);
+ destDirectory.delete();
+ destDirectory = new File(parentDir, destDir);
+ destDirectory.mkdir();
+ final File[] files = srcDirectory.listFiles();
+ if ( files != null && files.length > 0 ) {
+ for(int i=0; i<files.length; i++) {
+ // TODO - replace this hard-coded exlclude with something configurable
+ boolean exclude = false;
+ if ( "lib".equals(srcDir) && files[i].getName().startsWith("cocoon-bootstrap") ) {
+ exclude = true;
+ }
+ if ( !exclude ) {
+ files[i].renameTo(new File(destDirectory, files[i].getName()));
+ }
+ }
+ }
+ }
+ }
+
}
Modified: cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/monolithic/MonolithicCocoonDeployer.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/monolithic/MonolithicCocoonDeployer.java?rev=418080&r1=418079&r2=418080&view=diff
==============================================================================
--- cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/monolithic/MonolithicCocoonDeployer.java (original)
+++ cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/monolithic/MonolithicCocoonDeployer.java Thu Jun 29 09:38:23 2006
@@ -79,6 +79,7 @@
writeStringTemplateToFile(basedir, "sitemap.xmap", templateObjects);
writeStringTemplateToFile(basedir, "WEB-INF/cocoon.xconf", templateObjects);
+ copyFile(basedir, "blocks/sitemap.xmap");
copyFile(basedir, "WEB-INF/log4j.xconf");
copyFile(basedir, "WEB-INF/web.xml");
copyFile(basedir, "WEB-INF/properties/core.properties");
Added: cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/resources/org/apache/cocoon/maven/deployer/monolithic/blocks/sitemap.xmap
URL: http://svn.apache.org/viewvc/cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/resources/org/apache/cocoon/maven/deployer/monolithic/blocks/sitemap.xmap?rev=418080&view=auto
==============================================================================
--- cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/resources/org/apache/cocoon/maven/deployer/monolithic/blocks/sitemap.xmap (added)
+++ cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/resources/org/apache/cocoon/maven/deployer/monolithic/blocks/sitemap.xmap Thu Jun 29 09:38:23 2006
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 2006 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
+ <map:pipelines>
+ <map:pipeline>
+ <map:match pattern="*/**">
+ <map:mount uri-prefix="{1}/" src="{1}/"/>
+ </map:match>
+ </map:pipeline>
+ </map:pipelines>
+</map:sitemap>
Propchange: cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/resources/org/apache/cocoon/maven/deployer/monolithic/blocks/sitemap.xmap
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/resources/org/apache/cocoon/maven/deployer/monolithic/blocks/sitemap.xmap
------------------------------------------------------------------------------
svn:keywords = Id
Modified: cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/resources/org/apache/cocoon/maven/deployer/monolithic/sitemap.xmap
URL: http://svn.apache.org/viewvc/cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/resources/org/apache/cocoon/maven/deployer/monolithic/sitemap.xmap?rev=418080&r1=418079&r2=418080&view=diff
==============================================================================
--- cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/resources/org/apache/cocoon/maven/deployer/monolithic/sitemap.xmap (original)
+++ cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/resources/org/apache/cocoon/maven/deployer/monolithic/sitemap.xmap Thu Jun 29 09:38:23 2006
@@ -26,15 +26,17 @@
<map:pipelines>
<map:pipeline>
-
$devblocks:{ devblock |
$if(devblock.cobInfPath)$
- <map:match pattern="$devblock.artifactId$/**">
- <map:mount uri-prefix="$devblock.artifactId$" src="$devblock.cobInfPath$"/>
+ <map:match pattern="blocks/$devblock.artifactId$/**">
+ <map:mount uri-prefix="blocks/$devblock.artifactId$" src="$devblock.cobInfPath$"/>
</map:match>
$endif$
}$
-
+ <map:match pattern="*/**">
+ <map:mount src="{1}/" uri-prefix="{1}"/>
+ </map:match>
</map:pipeline>
+
</map:pipelines>
</map:sitemap>