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/12 13:16:13 UTC
svn commit: r413638 - in
/cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main:
java/org/apache/cocoon/maven/deployer/monolithic/
java/org/apache/cocoon/maven/deployer/utils/
resources/org/apache/cocoon/maven/deployer/monolithic/ re...
Author: reinhard
Date: Mon Jun 12 04:16:12 2006
New Revision: 413638
URL: http://svn.apache.org/viewvc?rev=413638&view=rev
Log:
hopefully setting properties correctly now - svn:eol-style
Modified:
cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/monolithic/DeploymentException.java (props changed)
cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/monolithic/DevelopmentBlock.java (contents, props changed)
cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/monolithic/DevelopmentProperty.java (contents, props changed)
cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/monolithic/FileAlreadyDeployedException.java (props changed)
cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/monolithic/FileDeployer.java (props changed)
cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/monolithic/MonolithicCocoonDeployer.java (contents, props changed)
cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/monolithic/MonolithicServer22.java (contents, props changed)
cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/monolithic/NoRuleFoundException.java (props changed)
cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/monolithic/SingleFileDeployer.java (props changed)
cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/utils/FileUtils.java (props changed)
cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/utils/WildcardHelper.java (props changed)
cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/resources/org/apache/cocoon/maven/deployer/monolithic/WEB-INF/log4j.xconf (contents, props changed)
cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/resources/org/apache/cocoon/maven/deployer/monolithic/WEB-INF/properties/core.properties (props changed)
cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/resources/org/apache/cocoon/maven/deployer/monolithic/WEB-INF/web.xml (contents, props changed)
cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/resources/org/apache/cocoon/maven/deployer/monolithic/sitemap.xmap (props changed)
Propchange: cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/monolithic/DeploymentException.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/monolithic/DevelopmentBlock.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/DevelopmentBlock.java?rev=413638&r1=413637&r2=413638&view=diff
==============================================================================
--- cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/monolithic/DevelopmentBlock.java (original)
+++ cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/monolithic/DevelopmentBlock.java Mon Jun 12 04:16:12 2006
@@ -1,60 +1,60 @@
-/*
- * 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.
- */
-package org.apache.cocoon.maven.deployer.monolithic;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-
-/**
- * A container for configuration parameters. Depending on the localPath parameter,
- * all other 'path' parameters are set.
- *
- * @version $Id$
- */
-public class DevelopmentBlock {
-
- private static final String RESOURCES_DIR = "src/main/resources/";
-
- public String artifactId;
- public String groupId;
-
- public String springConfPath;
- public String xconfConfPath;
- public String sitemapAdditionsConfPath;
- public String targetClassesPath;
- public String cobInfPath;
-
- public void setLocalPath(String localPath) throws FileNotFoundException {
- File localPathDir = new File(localPath);
- if(!localPathDir.exists()) {
- throw new FileNotFoundException("Directory '" + localPath + "' does not exist!");
- }
-
- springConfPath = checkDir(new File(localPath, RESOURCES_DIR + "META-INF/spring"));
- xconfConfPath = checkDir(new File(localPath, RESOURCES_DIR + "META-INF/legacy/xconf"));
- sitemapAdditionsConfPath = checkDir(new File(localPath, RESOURCES_DIR + "META-INF/legacy/sitemap-additions"));
- targetClassesPath = checkDir(new File(localPath, "target/classes"));
- cobInfPath = checkDir(new File(localPath, RESOURCES_DIR + "COB-INF"));
- }
-
- private String checkDir(File dir) {
- if(dir.exists()) {
- return dir.toURI().toString();
- }
- return null;
- }
-
-}
+/*
+ * 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.
+ */
+package org.apache.cocoon.maven.deployer.monolithic;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+
+/**
+ * A container for configuration parameters. Depending on the localPath parameter,
+ * all other 'path' parameters are set.
+ *
+ * @version $Id$
+ */
+public class DevelopmentBlock {
+
+ private static final String RESOURCES_DIR = "src/main/resources/";
+
+ public String artifactId;
+ public String groupId;
+
+ public String springConfPath;
+ public String xconfConfPath;
+ public String sitemapAdditionsConfPath;
+ public String targetClassesPath;
+ public String cobInfPath;
+
+ public void setLocalPath(String localPath) throws FileNotFoundException {
+ File localPathDir = new File(localPath);
+ if(!localPathDir.exists()) {
+ throw new FileNotFoundException("Directory '" + localPath + "' does not exist!");
+ }
+
+ springConfPath = checkDir(new File(localPath, RESOURCES_DIR + "META-INF/spring"));
+ xconfConfPath = checkDir(new File(localPath, RESOURCES_DIR + "META-INF/legacy/xconf"));
+ sitemapAdditionsConfPath = checkDir(new File(localPath, RESOURCES_DIR + "META-INF/legacy/sitemap-additions"));
+ targetClassesPath = checkDir(new File(localPath, "target/classes"));
+ cobInfPath = checkDir(new File(localPath, RESOURCES_DIR + "COB-INF"));
+ }
+
+ private String checkDir(File dir) {
+ if(dir.exists()) {
+ return dir.toURI().toString();
+ }
+ return null;
+ }
+
+}
Propchange: cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/monolithic/DevelopmentBlock.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/monolithic/DevelopmentProperty.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/DevelopmentProperty.java?rev=413638&r1=413637&r2=413638&view=diff
==============================================================================
--- cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/monolithic/DevelopmentProperty.java (original)
+++ cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/monolithic/DevelopmentProperty.java Mon Jun 12 04:16:12 2006
@@ -1,26 +1,26 @@
-/*
- * 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.
- */
-package org.apache.cocoon.maven.deployer.monolithic;
-
-/**
- * A container for configuration parameters.
- *
- * @version $Id$
- */
-public class DevelopmentProperty {
-
- public String name;
- public String value;
-
-}
+/*
+ * 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.
+ */
+package org.apache.cocoon.maven.deployer.monolithic;
+
+/**
+ * A container for configuration parameters.
+ *
+ * @version $Id$
+ */
+public class DevelopmentProperty {
+
+ public String name;
+ public String value;
+
+}
Propchange: cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/monolithic/DevelopmentProperty.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/monolithic/FileAlreadyDeployedException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/monolithic/FileDeployer.java
------------------------------------------------------------------------------
svn:eol-style = native
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=413638&r1=413637&r2=413638&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 Mon Jun 12 04:16:12 2006
@@ -1,150 +1,150 @@
-/*
- * 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.
- */
-package org.apache.cocoon.maven.deployer.monolithic;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Properties;
-
-import org.antlr.stringtemplate.StringTemplate;
-import org.apache.cocoon.maven.deployer.monolithic.DevelopmentBlock;
-import org.apache.cocoon.maven.deployer.monolithic.DevelopmentProperty;
-import org.apache.cocoon.maven.deployer.monolithic.MonolithicServer22;
-import org.apache.cocoon.maven.deployer.monolithic.SingleFileDeployer;
-import org.apache.cocoon.maven.deployer.utils.FileUtils;
-import org.apache.commons.io.IOUtils;
-import org.apache.maven.plugin.logging.Log;
-
-/**
- * Deploy blocks to a monolithic Cocoon web application. The files contained by a block are copied to the right places.
- * based on rules.
- *
- * @version $Id$
- */
-public class MonolithicCocoonDeployer {
-
- private Log logger;
-
- public MonolithicCocoonDeployer(Log logger) {
- this.logger = logger;
- }
-
- public void deploy(final Map libraries, final File basedir, final String blocksdir,
- final DevelopmentBlock[] developmentBlocks, DevelopmentProperty[] developmentProperties)
- throws DeploymentException {
-
- // iterate over all blocks that need to be installed into a J2EE web application
- for(Iterator it = libraries.keySet().iterator(); it.hasNext();) {
- Object id = it.next();
- File lib = (File) libraries.get(id);
- try {
- MonolithicServer22 zipExtractor = new MonolithicServer22(basedir, logger);
- zipExtractor.addRule("**legacy/cocoon.xconf", new SingleFileDeployer("WEB-INF"));
- zipExtractor.addRule("**legacy**.xconf", new SingleFileDeployer("WEB-INF/xconf"));
- zipExtractor.addRule("**legacy**.xmap", new SingleFileDeployer("WEB-INF/sitemap-additions"));
- zipExtractor.addRule("**spring/**.xml", new SingleFileDeployer("WEB-INF/spring"));
- zipExtractor.addRule("COB-INF**", new SingleFileDeployer(blocksdir + "/" + (String) id, true));
- // extract all configurations files
- zipExtractor.extract(lib);
- } catch (IOException e) {
- throw new DeploymentException("Can't deploy '" + lib.getAbsolutePath() + "'.", e);
- }
- }
-
- // deploy all blocks that are under development by adding their src/main/java (--> <map:classpath>),
- // src/main/resources/COB-INF (--> <map:mount>), and src/main/resources/META-INF/*
- // (--> <map:include>) to the root sitemap.
- if(developmentBlocks != null && developmentBlocks.length > 0) {
- Map templateObjects = new HashMap();
- templateObjects.put("devblocks", developmentBlocks);
- writeStringTemplateToFile(basedir, "sitemap.xmap", templateObjects);
- writeStringTemplateToFile(basedir, "WEB-INF/cocoon.xconf", templateObjects);
-
- copyFile(basedir, "WEB-INF/log4j.xconf");
- copyFile(basedir, "WEB-INF/web.xml");
- copyFile(basedir, "WEB-INF/properties/core.properties");
- }
-
- // write properties
- if(developmentProperties != null && developmentProperties.length > 0) {
- Properties properties = new Properties();
- for(int i = 0; i < developmentProperties.length; i++) {
- properties.setProperty(developmentProperties[0].name, developmentProperties[0].value);
- }
- writeProperties(basedir, "WEB-INF/properties/dev/core.properties", properties);
- }
- }
-
- private void writeProperties(final File basedir, final String propertiesFile, final Properties properties) {
- try {
- File outFile = new File(basedir, propertiesFile);
- properties.save(new FileOutputStream(FileUtils.createDirectory(outFile)), null);
- this.logger.info("Deploying dev properties to " + propertiesFile);
- } catch (IOException e) {
- throw new DeploymentException("Can't save properties to " + propertiesFile, e);
- }
- }
-
- private void copyFile(final File basedir, final String fileName) {
- try {
- File outFile = FileUtils.createDirectory(new File(basedir, fileName));
- IOUtils.copy(readResourceFromClassloader(fileName), new FileOutputStream(outFile));
- this.logger.info("Deploying resource file to " + fileName);
- } catch (FileNotFoundException e) {
- throw new DeploymentException("Can't copy to " + fileName, e);
- } catch (IOException e) {
- throw new DeploymentException("Can't copy to " + fileName, e);
- }
- }
-
- private void writeStringTemplateToFile(final File basedir, final String fileName, final Map templateObjects) {
- FileOutputStream fos = null;
- try {
- File outFile = FileUtils.createDirectory(new File(basedir, fileName));
- fos = new FileOutputStream(outFile);
- InputStream fileIs = readResourceFromClassloader(fileName);
- StringTemplate stringTemplate = new StringTemplate(IOUtils.toString(fileIs));
- for(Iterator templateObjectsIt = templateObjects.keySet().iterator(); templateObjectsIt.hasNext();) {
- Object key = templateObjectsIt.next();
- stringTemplate.setAttribute((String) key, templateObjects.get(key));
- }
- IOUtils.write(stringTemplate.toString(), fos);
- this.logger.info("Deploying string-template to " + fileName);
- } catch (FileNotFoundException e) {
- throw new DeploymentException(fileName + " not found.", e);
- } catch (IOException e) {
- throw new DeploymentException("Error while reading or writing.", e);
- } finally {
- try {
- fos.close();
- } catch (IOException e) {
- throw new DeploymentException("Error while closing the output stream.", e);
- }
- }
- }
-
- private InputStream readResourceFromClassloader(String fileName) {
- return MonolithicCocoonDeployer.class.getClassLoader().
- getResourceAsStream("org/apache/cocoon/maven/deployer/monolithic/" + fileName);
- }
-
+/*
+ * 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.
+ */
+package org.apache.cocoon.maven.deployer.monolithic;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+
+import org.antlr.stringtemplate.StringTemplate;
+import org.apache.cocoon.maven.deployer.monolithic.DevelopmentBlock;
+import org.apache.cocoon.maven.deployer.monolithic.DevelopmentProperty;
+import org.apache.cocoon.maven.deployer.monolithic.MonolithicServer22;
+import org.apache.cocoon.maven.deployer.monolithic.SingleFileDeployer;
+import org.apache.cocoon.maven.deployer.utils.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.maven.plugin.logging.Log;
+
+/**
+ * Deploy blocks to a monolithic Cocoon web application. The files contained by a block are copied to the right places.
+ * based on rules.
+ *
+ * @version $Id$
+ */
+public class MonolithicCocoonDeployer {
+
+ private Log logger;
+
+ public MonolithicCocoonDeployer(Log logger) {
+ this.logger = logger;
+ }
+
+ public void deploy(final Map libraries, final File basedir, final String blocksdir,
+ final DevelopmentBlock[] developmentBlocks, DevelopmentProperty[] developmentProperties)
+ throws DeploymentException {
+
+ // iterate over all blocks that need to be installed into a J2EE web application
+ for(Iterator it = libraries.keySet().iterator(); it.hasNext();) {
+ Object id = it.next();
+ File lib = (File) libraries.get(id);
+ try {
+ MonolithicServer22 zipExtractor = new MonolithicServer22(basedir, logger);
+ zipExtractor.addRule("**legacy/cocoon.xconf", new SingleFileDeployer("WEB-INF"));
+ zipExtractor.addRule("**legacy**.xconf", new SingleFileDeployer("WEB-INF/xconf"));
+ zipExtractor.addRule("**legacy**.xmap", new SingleFileDeployer("WEB-INF/sitemap-additions"));
+ zipExtractor.addRule("**spring/**.xml", new SingleFileDeployer("WEB-INF/spring"));
+ zipExtractor.addRule("COB-INF**", new SingleFileDeployer(blocksdir + "/" + (String) id, true));
+ // extract all configurations files
+ zipExtractor.extract(lib);
+ } catch (IOException e) {
+ throw new DeploymentException("Can't deploy '" + lib.getAbsolutePath() + "'.", e);
+ }
+ }
+
+ // deploy all blocks that are under development by adding their src/main/java (--> <map:classpath>),
+ // src/main/resources/COB-INF (--> <map:mount>), and src/main/resources/META-INF/*
+ // (--> <map:include>) to the root sitemap.
+ if(developmentBlocks != null && developmentBlocks.length > 0) {
+ Map templateObjects = new HashMap();
+ templateObjects.put("devblocks", developmentBlocks);
+ writeStringTemplateToFile(basedir, "sitemap.xmap", templateObjects);
+ writeStringTemplateToFile(basedir, "WEB-INF/cocoon.xconf", templateObjects);
+
+ copyFile(basedir, "WEB-INF/log4j.xconf");
+ copyFile(basedir, "WEB-INF/web.xml");
+ copyFile(basedir, "WEB-INF/properties/core.properties");
+ }
+
+ // write properties
+ if(developmentProperties != null && developmentProperties.length > 0) {
+ Properties properties = new Properties();
+ for(int i = 0; i < developmentProperties.length; i++) {
+ properties.setProperty(developmentProperties[0].name, developmentProperties[0].value);
+ }
+ writeProperties(basedir, "WEB-INF/properties/dev/core.properties", properties);
+ }
+ }
+
+ private void writeProperties(final File basedir, final String propertiesFile, final Properties properties) {
+ try {
+ File outFile = new File(basedir, propertiesFile);
+ properties.save(new FileOutputStream(FileUtils.createDirectory(outFile)), null);
+ this.logger.info("Deploying dev properties to " + propertiesFile);
+ } catch (IOException e) {
+ throw new DeploymentException("Can't save properties to " + propertiesFile, e);
+ }
+ }
+
+ private void copyFile(final File basedir, final String fileName) {
+ try {
+ File outFile = FileUtils.createDirectory(new File(basedir, fileName));
+ IOUtils.copy(readResourceFromClassloader(fileName), new FileOutputStream(outFile));
+ this.logger.info("Deploying resource file to " + fileName);
+ } catch (FileNotFoundException e) {
+ throw new DeploymentException("Can't copy to " + fileName, e);
+ } catch (IOException e) {
+ throw new DeploymentException("Can't copy to " + fileName, e);
+ }
+ }
+
+ private void writeStringTemplateToFile(final File basedir, final String fileName, final Map templateObjects) {
+ FileOutputStream fos = null;
+ try {
+ File outFile = FileUtils.createDirectory(new File(basedir, fileName));
+ fos = new FileOutputStream(outFile);
+ InputStream fileIs = readResourceFromClassloader(fileName);
+ StringTemplate stringTemplate = new StringTemplate(IOUtils.toString(fileIs));
+ for(Iterator templateObjectsIt = templateObjects.keySet().iterator(); templateObjectsIt.hasNext();) {
+ Object key = templateObjectsIt.next();
+ stringTemplate.setAttribute((String) key, templateObjects.get(key));
+ }
+ IOUtils.write(stringTemplate.toString(), fos);
+ this.logger.info("Deploying string-template to " + fileName);
+ } catch (FileNotFoundException e) {
+ throw new DeploymentException(fileName + " not found.", e);
+ } catch (IOException e) {
+ throw new DeploymentException("Error while reading or writing.", e);
+ } finally {
+ try {
+ fos.close();
+ } catch (IOException e) {
+ throw new DeploymentException("Error while closing the output stream.", e);
+ }
+ }
+ }
+
+ private InputStream readResourceFromClassloader(String fileName) {
+ return MonolithicCocoonDeployer.class.getClassLoader().
+ getResourceAsStream("org/apache/cocoon/maven/deployer/monolithic/" + fileName);
+ }
+
}
Propchange: cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/monolithic/MonolithicCocoonDeployer.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/monolithic/MonolithicServer22.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/MonolithicServer22.java?rev=413638&r1=413637&r2=413638&view=diff
==============================================================================
--- cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/monolithic/MonolithicServer22.java (original)
+++ cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/monolithic/MonolithicServer22.java Mon Jun 12 04:16:12 2006
@@ -1,138 +1,138 @@
-/*
- * 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.
- */
-package org.apache.cocoon.maven.deployer.monolithic;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipInputStream;
-
-import org.apache.cocoon.maven.deployer.utils.WildcardHelper;
-import org.apache.commons.lang.Validate;
-import org.apache.maven.plugin.logging.Log;
-
-/**
- * This class performs the actual deployment based on rules. A rule is mapped to a
- * <code>FileDeployer</code> and when the rule is executed and returns true, the
- * file deployer is executed.
- *
- * @version $Id$
- */
-public class MonolithicServer22 {
-
- private Log logger;
- private File basedir;
- private List rules = new ArrayList();
- private Set alreadyDeployedFilesSet = new HashSet();
-
- public MonolithicServer22(File basedir, Log logger) {
- Validate.notNull(basedir, "The basedir of the server mustn't be null.");
- Validate.notNull(logger, "A logger must be set.");
- this.basedir = basedir;
- this.logger = logger;
- this.logger.debug("Basedir: " + basedir.getAbsolutePath());
- }
-
- public void addRule(String pattern, FileDeployer fileDeployer) {
- fileDeployer.setBasedir(this.basedir);
- fileDeployer.setLogger(this.logger);
- fileDeployer.setAlreadyDeployedFilesSet(alreadyDeployedFilesSet);
- rules.add(new Rule(pattern, fileDeployer));
- }
-
- public void extract(File zipFile) throws IOException {
- ZipInputStream zipStream = new ZipInputStream(new FileInputStream(zipFile));
- ZipEntry document = null;
- try {
- do {
- document = zipStream.getNextEntry();
- if (document != null) {
- // skip directories (only files have to be written)
- if (document.isDirectory()) {
- zipStream.closeEntry();
- continue;
- }
- OutputStream out = null;
- try {
- FileDeployer fileDeployer = findFileDeployer(document.getName());
- if(fileDeployer == null) {
- continue;
- }
-
- out = fileDeployer.writeResource(document.getName());
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- // loop over ZIP entry stream
- byte[] buffer = new byte[8192];
- int length = -1;
- while (zipStream.available() > 0) {
- length = zipStream.read(buffer, 0, 8192);
- if (length > 0) {
- baos.write(buffer, 0, length);
- }
- }
- // write it to the output stream provided by the file resource manager
- out.write(baos.toByteArray());
- } finally {
- if(out != null) {
- out.close();
- }
- }
- // go to next entry
- zipStream.closeEntry();
- }
- } while (document != null);
- } finally {
- zipStream.close();
- }
- }
-
- /**
- * Loop over all rules and if one matches, the corresponding @link FileDeployer is returned.
- */
- protected FileDeployer findFileDeployer(String name) {
- for(Iterator it = this.rules.iterator(); it.hasNext();) {
- Rule rule = (Rule) it.next();
- HashMap resultMap = new HashMap();
- if(WildcardHelper.match(resultMap, name, rule.compiledPattern)) {
- logger.debug("findFileDeployer: " + name + " matched with pattern '" + rule.patternString);
- return rule.fileDeployer;
- }
- }
- return null;
- }
-
- private static class Rule {
- String patternString;
- int[] compiledPattern;
- FileDeployer fileDeployer;
-
- public Rule(String pattern, FileDeployer fileDeployer) {
- this.patternString = pattern;
- this.compiledPattern = WildcardHelper.compilePattern(pattern);
- this.fileDeployer = fileDeployer;
- }
- }
-
-}
+/*
+ * 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.
+ */
+package org.apache.cocoon.maven.deployer.monolithic;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+import org.apache.cocoon.maven.deployer.utils.WildcardHelper;
+import org.apache.commons.lang.Validate;
+import org.apache.maven.plugin.logging.Log;
+
+/**
+ * This class performs the actual deployment based on rules. A rule is mapped to a
+ * <code>FileDeployer</code> and when the rule is executed and returns true, the
+ * file deployer is executed.
+ *
+ * @version $Id$
+ */
+public class MonolithicServer22 {
+
+ private Log logger;
+ private File basedir;
+ private List rules = new ArrayList();
+ private Set alreadyDeployedFilesSet = new HashSet();
+
+ public MonolithicServer22(File basedir, Log logger) {
+ Validate.notNull(basedir, "The basedir of the server mustn't be null.");
+ Validate.notNull(logger, "A logger must be set.");
+ this.basedir = basedir;
+ this.logger = logger;
+ this.logger.debug("Basedir: " + basedir.getAbsolutePath());
+ }
+
+ public void addRule(String pattern, FileDeployer fileDeployer) {
+ fileDeployer.setBasedir(this.basedir);
+ fileDeployer.setLogger(this.logger);
+ fileDeployer.setAlreadyDeployedFilesSet(alreadyDeployedFilesSet);
+ rules.add(new Rule(pattern, fileDeployer));
+ }
+
+ public void extract(File zipFile) throws IOException {
+ ZipInputStream zipStream = new ZipInputStream(new FileInputStream(zipFile));
+ ZipEntry document = null;
+ try {
+ do {
+ document = zipStream.getNextEntry();
+ if (document != null) {
+ // skip directories (only files have to be written)
+ if (document.isDirectory()) {
+ zipStream.closeEntry();
+ continue;
+ }
+ OutputStream out = null;
+ try {
+ FileDeployer fileDeployer = findFileDeployer(document.getName());
+ if(fileDeployer == null) {
+ continue;
+ }
+
+ out = fileDeployer.writeResource(document.getName());
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ // loop over ZIP entry stream
+ byte[] buffer = new byte[8192];
+ int length = -1;
+ while (zipStream.available() > 0) {
+ length = zipStream.read(buffer, 0, 8192);
+ if (length > 0) {
+ baos.write(buffer, 0, length);
+ }
+ }
+ // write it to the output stream provided by the file resource manager
+ out.write(baos.toByteArray());
+ } finally {
+ if(out != null) {
+ out.close();
+ }
+ }
+ // go to next entry
+ zipStream.closeEntry();
+ }
+ } while (document != null);
+ } finally {
+ zipStream.close();
+ }
+ }
+
+ /**
+ * Loop over all rules and if one matches, the corresponding @link FileDeployer is returned.
+ */
+ protected FileDeployer findFileDeployer(String name) {
+ for(Iterator it = this.rules.iterator(); it.hasNext();) {
+ Rule rule = (Rule) it.next();
+ HashMap resultMap = new HashMap();
+ if(WildcardHelper.match(resultMap, name, rule.compiledPattern)) {
+ logger.debug("findFileDeployer: " + name + " matched with pattern '" + rule.patternString);
+ return rule.fileDeployer;
+ }
+ }
+ return null;
+ }
+
+ private static class Rule {
+ String patternString;
+ int[] compiledPattern;
+ FileDeployer fileDeployer;
+
+ public Rule(String pattern, FileDeployer fileDeployer) {
+ this.patternString = pattern;
+ this.compiledPattern = WildcardHelper.compilePattern(pattern);
+ this.fileDeployer = fileDeployer;
+ }
+ }
+
+}
Propchange: cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/monolithic/MonolithicServer22.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/monolithic/NoRuleFoundException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/monolithic/SingleFileDeployer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/utils/FileUtils.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/utils/WildcardHelper.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/resources/org/apache/cocoon/maven/deployer/monolithic/WEB-INF/log4j.xconf
URL: http://svn.apache.org/viewvc/cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/resources/org/apache/cocoon/maven/deployer/monolithic/WEB-INF/log4j.xconf?rev=413638&r1=413637&r2=413638&view=diff
==============================================================================
--- cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/resources/org/apache/cocoon/maven/deployer/monolithic/WEB-INF/log4j.xconf (original)
+++ cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/resources/org/apache/cocoon/maven/deployer/monolithic/WEB-INF/log4j.xconf Mon Jun 12 04:16:12 2006
@@ -1,34 +1,34 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
- 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.
--->
-<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
-
- <!-- This is a sample configuration for log4j.
- It simply just logs everything into a single
- log file.
- Note, that you can use properties for value substitution.
- -->
- <appender name="COCOON_DEFAULT" class="org.apache.log4j.FileAppender">
- <param name="File" value="${log-dir}/log4j.log" />
- <param name="Append" value="false" />
- <layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern" value="%t %-5p %c{2} - %m%n"/>
- </layout>
- </appender>
-
- <root>
- <priority value="error"/>
- <appender-ref ref="COCOON_DEFAULT" />
- </root>
-</log4j:configuration>
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ 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.
+-->
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+ <!-- This is a sample configuration for log4j.
+ It simply just logs everything into a single
+ log file.
+ Note, that you can use properties for value substitution.
+ -->
+ <appender name="COCOON_DEFAULT" class="org.apache.log4j.FileAppender">
+ <param name="File" value="${log-dir}/log4j.log" />
+ <param name="Append" value="false" />
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%t %-5p %c{2} - %m%n"/>
+ </layout>
+ </appender>
+
+ <root>
+ <priority value="error"/>
+ <appender-ref ref="COCOON_DEFAULT" />
+ </root>
+</log4j:configuration>
Propchange: cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/resources/org/apache/cocoon/maven/deployer/monolithic/WEB-INF/log4j.xconf
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/resources/org/apache/cocoon/maven/deployer/monolithic/WEB-INF/properties/core.properties
------------------------------------------------------------------------------
svn:eol-style = native
Modified: cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/resources/org/apache/cocoon/maven/deployer/monolithic/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/resources/org/apache/cocoon/maven/deployer/monolithic/WEB-INF/web.xml?rev=413638&r1=413637&r2=413638&view=diff
==============================================================================
--- cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/resources/org/apache/cocoon/maven/deployer/monolithic/WEB-INF/web.xml (original)
+++ cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/resources/org/apache/cocoon/maven/deployer/monolithic/WEB-INF/web.xml Mon Jun 12 04:16:12 2006
@@ -1,48 +1,48 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright 1999-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.
--->
-
-<!--+
- | This is the Cocoon web-app configurations file
- +-->
-
-<!DOCTYPE web-app
- PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
- "http://java.sun.com/dtd/web-app_2_3.dtd">
-
-<web-app>
-
- <servlet>
- <servlet-name>Cocoon</servlet-name>
- <display-name>Cocoon</display-name>
- <description>Cocoon demo web application</description>
-
- <servlet-class>org.apache.cocoon.servlet.CocoonServlet</servlet-class>
-
- <init-param>
- <param-name>container-encoding</param-name>
- <param-value>ISO-8859-1</param-value>
- </init-param>
-
- <load-on-startup>1</load-on-startup>
- </servlet>
-
- <servlet-mapping>
- <servlet-name>Cocoon</servlet-name>
- <url-pattern>/</url-pattern>
- </servlet-mapping>
-
-</web-app>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 1999-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.
+-->
+
+<!--+
+ | This is the Cocoon web-app configurations file
+ +-->
+
+<!DOCTYPE web-app
+ PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
+
+<web-app>
+
+ <servlet>
+ <servlet-name>Cocoon</servlet-name>
+ <display-name>Cocoon</display-name>
+ <description>Cocoon demo web application</description>
+
+ <servlet-class>org.apache.cocoon.servlet.CocoonServlet</servlet-class>
+
+ <init-param>
+ <param-name>container-encoding</param-name>
+ <param-value>ISO-8859-1</param-value>
+ </init-param>
+
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>Cocoon</servlet-name>
+ <url-pattern>/</url-pattern>
+ </servlet-mapping>
+
+</web-app>
Propchange: cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/resources/org/apache/cocoon/maven/deployer/monolithic/WEB-INF/web.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/resources/org/apache/cocoon/maven/deployer/monolithic/sitemap.xmap
------------------------------------------------------------------------------
svn:eol-style = native