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/03/19 18:13:18 UTC
svn commit: r387003 - in /cocoon/trunk/cocoon-block-deployer: ./
cocoon-archetype-block/ cocoon-deployer-core/
cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/
cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/applicationserve...
Author: reinhard
Date: Sun Mar 19 09:13:14 2006
New Revision: 387003
URL: http://svn.apache.org/viewcvs?rev=387003&view=rev
Log:
Started to work on a deployment tool for monolithic web applications -> 2.3 - it uses wildcard patterns to decide where the files of the block jar should go, JUnit-Tests run through but I haven't tested the M2 plugin yet; I also need more information about the target direcory structure
Added:
cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/MonolithicCocoonDeployer.java
cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/applicationserver/MonolithicServer.java
cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/monolithic/
cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/monolithic/FileAlreadyDeployedException.java
cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/monolithic/FileDeployer.java
cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/monolithic/NoRuleFoundException.java
cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/monolithic/SingleFileDeployer.java
cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/util/WildcardHelper.java
cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/java/org/apache/cocoon/deployer/applicationserver/MonoliticServerTest.java
cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/java/org/apache/cocoon/deployer/monolithic/
cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/java/org/apache/cocoon/deployer/monolithic/SingleFileDeployerTest.java
cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/mocks/validMonolithicBlock-02/
cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/mocks/validMonolithicBlock-02/blockRoot/
cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/mocks/validMonolithicBlock-02/blockRoot/COB-INF/
cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/mocks/validMonolithicBlock-02/blockRoot/COB-INF/block-sitemap.xmap
cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/mocks/validMonolithicBlock-02/blockRoot/COB-INF/test.xml
cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/mocks/validMonolithicBlock-02/blockRoot/META-INF/
cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/mocks/validMonolithicBlock-02/blockRoot/META-INF/legacy/
cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/mocks/validMonolithicBlock-02/blockRoot/META-INF/legacy/sitemap-additions/
cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/mocks/validMonolithicBlock-02/blockRoot/META-INF/legacy/sitemap-additions/sa.xmap
cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/mocks/validMonolithicBlock-02/blockRoot/META-INF/legacy/xconf/
cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/mocks/validMonolithicBlock-02/blockRoot/META-INF/legacy/xconf/my-webdav-server.xconf
cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/mocks/validMonolithicBlock-02/valid-block-1.0.jar (with props)
Modified:
cocoon/trunk/cocoon-block-deployer/cocoon-archetype-block/ (props changed)
cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/ (props changed)
cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/java/org/apache/cocoon/deployer/AbstractDeployerTestCase.java
cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/mocks/build.xml
cocoon/trunk/cocoon-block-deployer/cocoon-deployer-minimal-webapp/ (props changed)
cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin/ (props changed)
cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin-demo/ (props changed)
cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin-demo/pom.xml
cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin-demo/src/main/resources/META-INF/block.xml
cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/AbstractDeployMojo.java
cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/DeployExplodedMojo.java
cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/MavenArtifactProvider.java
cocoon/trunk/cocoon-block-deployer/cocoon-deployer-webapp-sample/ (props changed)
cocoon/trunk/cocoon-block-deployer/cocoon-tutorial-simple-block/ (props changed)
cocoon/trunk/cocoon-block-deployer/pom.xml (props changed)
Propchange: cocoon/trunk/cocoon-block-deployer/cocoon-archetype-block/
------------------------------------------------------------------------------
eol-style = native
Propchange: cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/
------------------------------------------------------------------------------
eol-style = native
Added: cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/MonolithicCocoonDeployer.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/MonolithicCocoonDeployer.java?rev=387003&view=auto
==============================================================================
--- cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/MonolithicCocoonDeployer.java (added)
+++ cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/MonolithicCocoonDeployer.java Sun Mar 19 09:13:14 2006
@@ -0,0 +1,51 @@
+/*
+ * 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.deployer;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.cocoon.deployer.applicationserver.MonolithicServer;
+import org.apache.cocoon.deployer.logger.Logger;
+import org.apache.cocoon.deployer.monolithic.SingleFileDeployer;
+
+/**
+ * Deploy blocks to a monolithic Cocoon web application.
+ */
+public class MonolithicCocoonDeployer {
+
+ public static void deploy(Map libraries, File basedir, Logger logger) {
+
+ MonolithicServer zipExtractor = new MonolithicServer(basedir, logger);
+ zipExtractor.addRule("**legacy/*.xconf", new SingleFileDeployer("WEB-INF/xconf"));
+ zipExtractor.addRule("**legacy/*.xmap", new SingleFileDeployer("WEB-INF/sitemap-additions"));
+
+ for(Iterator it = libraries.entrySet().iterator(); it.hasNext();) {
+ File lib = (File) it.next();
+ try {
+ // extract all configurations files
+ zipExtractor.extract(lib);
+ // copy lib itself to WEB-INF/lib
+ // tbd
+ } catch (IOException e) {
+ throw new DeploymentException("Can't deploy '" + lib.getAbsolutePath() + "'.", e);
+ }
+ }
+ }
+
+}
Added: cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/applicationserver/MonolithicServer.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/applicationserver/MonolithicServer.java?rev=387003&view=auto
==============================================================================
--- cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/applicationserver/MonolithicServer.java (added)
+++ cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/applicationserver/MonolithicServer.java Sun Mar 19 09:13:14 2006
@@ -0,0 +1,123 @@
+/*
+ * 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.deployer.applicationserver;
+
+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.Iterator;
+import java.util.List;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+import org.apache.cocoon.deployer.logger.Logger;
+import org.apache.cocoon.deployer.monolithic.FileDeployer;
+import org.apache.cocoon.deployer.monolithic.NoRuleFoundException;
+import org.apache.cocoon.deployer.util.WildcardHelper;
+import org.apache.commons.lang.Validate;
+
+public class MonolithicServer {
+
+ private Logger logger;
+ private File basedir;
+ private List rules = new ArrayList();
+
+ public MonolithicServer(File basedir, Logger 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;
+ }
+
+ public void addRule(String pattern, FileDeployer fileDeployer) {
+ fileDeployer.setBasedir(this.basedir);
+ fileDeployer.setLogger(this.logger);
+ 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 {
+ out = findFileDeployer(document.getName()).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.verbose("findFileDeployer: " + name + " matched with pattern '" + rule.patternString);
+ return rule.fileDeployer;
+ }
+ }
+ throw new NoRuleFoundException("You have to specify a rule for the path '" + name + "'.");
+ }
+
+ 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;
+ }
+ }
+
+}
Added: cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/monolithic/FileAlreadyDeployedException.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/monolithic/FileAlreadyDeployedException.java?rev=387003&view=auto
==============================================================================
--- cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/monolithic/FileAlreadyDeployedException.java (added)
+++ cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/monolithic/FileAlreadyDeployedException.java Sun Mar 19 09:13:14 2006
@@ -0,0 +1,26 @@
+/*
+ * 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.deployer.monolithic;
+
+import org.apache.cocoon.deployer.DeploymentException;
+
+public class FileAlreadyDeployedException extends DeploymentException {
+
+ public FileAlreadyDeployedException(String message) {
+ super(message);
+ }
+
+}
Added: cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/monolithic/FileDeployer.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/monolithic/FileDeployer.java?rev=387003&view=auto
==============================================================================
--- cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/monolithic/FileDeployer.java (added)
+++ cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/monolithic/FileDeployer.java Sun Mar 19 09:13:14 2006
@@ -0,0 +1,38 @@
+/*
+ * 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.deployer.monolithic;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.apache.cocoon.deployer.logger.Logger;
+
+/**
+ * Use this interface for classes that are used by the @link org.apache.cocoon.maven.deployer.monolithic.ZipExtractor
+ * to extract ZIP files. Classes implementing this interface can be added together with a rule to the
+ * @link org.apache.cocoon.maven.deployer.monolithic.ZipExtractor and when the rule matches, the execute method
+ * is called.
+ */
+public interface FileDeployer {
+
+ public OutputStream writeResource(String documentName) throws IOException;
+
+ public void setBasedir(File file);
+
+ public void setLogger(Logger logger);
+
+}
Added: cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/monolithic/NoRuleFoundException.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/monolithic/NoRuleFoundException.java?rev=387003&view=auto
==============================================================================
--- cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/monolithic/NoRuleFoundException.java (added)
+++ cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/monolithic/NoRuleFoundException.java Sun Mar 19 09:13:14 2006
@@ -0,0 +1,24 @@
+/*
+ * 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.deployer.monolithic;
+
+public class NoRuleFoundException extends RuntimeException {
+
+ public NoRuleFoundException(String message) {
+ super(message);
+ }
+
+}
Added: cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/monolithic/SingleFileDeployer.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/monolithic/SingleFileDeployer.java?rev=387003&view=auto
==============================================================================
--- cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/monolithic/SingleFileDeployer.java (added)
+++ cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/monolithic/SingleFileDeployer.java Sun Mar 19 09:13:14 2006
@@ -0,0 +1,76 @@
+/*
+ * 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.deployer.monolithic;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.apache.cocoon.deployer.logger.Logger;
+import org.apache.commons.lang.Validate;
+
+/**
+ * Deploy a single file.
+ */
+public class SingleFileDeployer implements FileDeployer {
+
+ private File basedir;
+ private Logger logger;
+ private String outputDir;
+
+ public SingleFileDeployer(String outputDir) {
+ Validate.notNull(outputDir, "An outputDir has to be set.");
+ this.outputDir = outputDir;
+ }
+
+ public void setBasedir(final File basedir) {
+ this.basedir = basedir;
+ }
+
+ protected File getBasedir() {
+ return this.basedir;
+ }
+
+ public void setLogger(final Logger logger) {
+ this.logger = logger;
+ }
+
+ protected Logger getLogger() {
+ return this.logger;
+ }
+
+ protected String getFileName(String documentName) {
+ return documentName.substring(documentName.lastIndexOf('/') + 1);
+ }
+
+ protected String getOutputDir() {
+ return this.outputDir;
+ }
+
+ public OutputStream writeResource(String documentName) throws IOException {
+ File outDir = new File(this.getBasedir(), getOutputDir());
+ if(!outDir.exists()) {
+ outDir.mkdirs();
+ }
+ File targetFile = new File(outDir, this.getFileName(documentName));
+ if(targetFile.exists()) {
+ throw new FileAlreadyDeployedException("File '" + targetFile + "' already exists!");
+ }
+ return new FileOutputStream(targetFile);
+ }
+
+}
Added: cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/util/WildcardHelper.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/util/WildcardHelper.java?rev=387003&view=auto
==============================================================================
--- cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/util/WildcardHelper.java (added)
+++ cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/main/java/org/apache/cocoon/deployer/util/WildcardHelper.java Sun Mar 19 09:13:14 2006
@@ -0,0 +1,380 @@
+/*
+ * Copyright 1999-2005 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.deployer.util;
+
+import java.util.HashMap;
+
+/**
+ * This class is an utility class that perform wilcard-patterns matching and
+ * isolation.
+ *
+ * Copy from cocoon-core.
+ */
+public class WildcardHelper {
+
+ /** The int representing '*' in the pattern <code>int []</code>. */
+ protected static final int MATCH_FILE = -1;
+ /** The int representing '**' in the pattern <code>int []</code>. */
+ protected static final int MATCH_PATH = -2;
+ /** The int representing begin in the pattern <code>int []</code>. */
+ protected static final int MATCH_BEGIN = -4;
+ /** The int representing end in pattern <code>int []</code>. */
+ protected static final int MATCH_THEEND = -5;
+ /** The int value that terminates the pattern <code>int []</code>. */
+ protected static final int MATCH_END = -3;
+
+
+ /**
+ * Translate the given <code>String</code> into a <code>int []</code>
+ * representing the pattern matchable by this class.
+ * <br>
+ * This function translates a <code>String</code> into an int array
+ * converting the special '*' and '\' characters.
+ * <br>
+ * Here is how the conversion algorithm works:
+ * <ul>
+ * <li>The '*' character is converted to MATCH_FILE, meaning that zero
+ * or more characters (excluding the path separator '/') are to
+ * be matched.</li>
+ * <li>The '**' sequence is converted to MATCH_PATH, meaning that zero
+ * or more characters (including the path separator '/') are to
+ * be matched.</li>
+ * <li>The '\' character is used as an escape sequence ('\*' is
+ * translated in '*', not in MATCH_FILE). If an exact '\' character
+ * is to be matched the source string must contain a '\\'.
+ * sequence.</li>
+ * </ul>
+ * When more than two '*' characters, not separated by another character,
+ * are found their value is considered as '**' (MATCH_PATH).
+ * <br>
+ * The array is always terminated by a special value (MATCH_END).
+ * <br>
+ * All MATCH* values are less than zero, while normal characters are equal
+ * or greater.
+ *
+ * @param data The string to translate.
+ * @return The encoded string as an int array, terminated by the MATCH_END
+ * value (don't consider the array length).
+ * @exception NullPointerException If data is null.
+ */
+ public static int[] compilePattern(String data)
+ throws NullPointerException {
+
+ // Prepare the arrays
+ int expr[] = new int[data.length() + 2];
+ char buff[] = data.toCharArray();
+
+ // Prepare variables for the translation loop
+ int y = 0;
+ boolean slash = false;
+
+ // Must start from beginning
+ expr[y++] = MATCH_BEGIN;
+
+ if (buff.length > 0) {
+ if (buff[0]=='\\') {
+ slash = true;
+ } else if (buff[0] == '*') {
+ expr[y++] = MATCH_FILE;
+ } else {
+ expr[y++] = buff[0];
+ }
+
+ // Main translation loop
+ for (int x = 1; x < buff.length; x++) {
+ // If the previous char was '\' simply copy this char.
+ if (slash) {
+ expr[y++] = buff[x];
+ slash = false;
+ // If the previous char was not '\' we have to do a bunch of checks
+ } else {
+ // If this char is '\' declare that and continue
+ if (buff[x] == '\\') {
+ slash = true;
+ // If this char is '*' check the previous one
+ } else if (buff[x] == '*') {
+ // If the previous character als was '*' match a path
+ if (expr[y-1] <= MATCH_FILE) {
+ expr[y-1] = MATCH_PATH;
+ } else {
+ expr[y++] = MATCH_FILE;
+ }
+ } else {
+ expr[y++]=buff[x];
+ }
+ }
+ }
+ }
+
+ // Must match end at the end
+ expr[y] = MATCH_THEEND;
+ return expr;
+ }
+
+ /**
+ * match a pattern agains a string and isolates wildcard replacement into a
+ * <code>Stack</code>.
+ */
+ public static boolean match (HashMap map, String data, int[] expr)
+ throws NullPointerException {
+ if (data == null) {
+ throw new NullPointerException ("No data provided");
+ }
+ if (expr == null) {
+ throw new NullPointerException ("No pattern expression provided");
+ }
+
+
+ char buff[] = data.toCharArray();
+ // Allocate the result buffer
+ char rslt[] = new char[expr.length + buff.length];
+
+
+ // The previous and current position of the expression character
+ // (MATCH_*)
+ int charpos = 0;
+
+ // The position in the expression, input, translation and result arrays
+ int exprpos = 0;
+ int buffpos = 0;
+ int rsltpos = 0;
+ int offset = -1;
+
+ // The matching count
+ int mcount = 0;
+
+ if ( map != null ) {
+ // We want the complete data be in {0}
+ map.put(Integer.toString(mcount),data);
+ }
+
+ // First check for MATCH_BEGIN
+ boolean matchBegin = false;
+ if (expr[charpos] == MATCH_BEGIN) {
+ matchBegin = true;
+ exprpos = ++charpos;
+ }
+
+ // Search the fist expression character (except MATCH_BEGIN - already skipped)
+ while (expr[charpos] >= 0)
+ charpos++;
+
+ // The expression charater (MATCH_*)
+ int exprchr = expr[charpos];
+
+ while (true) {
+ // Check if the data in the expression array before the current
+ // expression character matches the data in the input buffer
+ if (matchBegin) {
+ if (!matchArray(expr, exprpos, charpos, buff, buffpos))
+ return (false);
+ matchBegin = false;
+ } else {
+ offset = indexOfArray (expr, exprpos, charpos, buff,
+ buffpos);
+ if (offset < 0)
+ return (false);
+ }
+
+ // Check for MATCH_BEGIN
+ if (matchBegin) {
+ if (offset != 0)
+ return (false);
+ matchBegin = false;
+ }
+
+ // Advance buffpos
+ buffpos += (charpos - exprpos);
+
+ // Check for END's
+ if (exprchr == MATCH_END) {
+ if (rsltpos > 0 && map != null) {
+ map.put(Integer.toString(++mcount),new String(rslt, 0, rsltpos));
+ }
+ // Don't care about rest of input buffer
+ return (true);
+ } else if (exprchr == MATCH_THEEND) {
+ if (rsltpos > 0 && map != null ) {
+ map.put (Integer.toString(++mcount),new String(rslt, 0, rsltpos));
+ }
+ // Check that we reach buffer's end
+ return (buffpos == buff.length);
+ }
+
+ // Search the next expression character
+ exprpos = ++charpos;
+ while (expr[charpos] >= 0)
+ charpos++;
+ int prevchr = exprchr;
+ exprchr = expr[charpos];
+
+ // We have here prevchr == * or **.
+ offset = (prevchr == MATCH_FILE) ?
+ indexOfArray (expr, exprpos, charpos, buff, buffpos) :
+ lastIndexOfArray (expr, exprpos, charpos, buff,
+ buffpos);
+
+ if (offset < 0)
+ return (false);
+
+ // Copy the data from the source buffer into the result buffer
+ // to substitute the expression character
+ if (prevchr == MATCH_PATH) {
+ while (buffpos < offset)
+ rslt[rsltpos++] = buff[buffpos++];
+ } else {
+ // Matching file, don't copy '/'
+ while (buffpos < offset) {
+ if (buff[buffpos] == '/')
+ return (false);
+ rslt[rsltpos++] = buff[buffpos++];
+ }
+ }
+
+ if ( map != null ) {
+ map.put(Integer.toString(++mcount),new String (rslt, 0, rsltpos));
+ }
+ rsltpos = 0;
+ }
+ }
+
+ /**
+ * Get the offset of a part of an int array within a char array.
+ * <br>
+ * This method return the index in d of the first occurrence after dpos of
+ * that part of array specified by r, starting at rpos and terminating at
+ * rend.
+ *
+ * @param r The array containing the data that need to be matched in d.
+ * @param rpos The index of the first character in r to look for.
+ * @param rend The index of the last character in r to look for plus 1.
+ * @param d The array of char that should contain a part of r.
+ * @param dpos The starting offset in d for the matching.
+ * @return The offset in d of the part of r matched in d or -1 if that was
+ * not found.
+ */
+ protected static int indexOfArray (int r[], int rpos, int rend,
+ char d[], int dpos) {
+ // Check if pos and len are legal
+ if (rend < rpos)
+ throw new IllegalArgumentException ("rend < rpos");
+ // If we need to match a zero length string return current dpos
+ if (rend == rpos)
+ return (d.length); //?? dpos?
+ // If we need to match a 1 char length string do it simply
+ if ((rend - rpos) == 1) {
+ // Search for the specified character
+ for (int x = dpos; x < d.length; x++)
+ if (r[rpos] == d[x])
+ return (x);
+ }
+ // Main string matching loop. It gets executed if the characters to
+ // match are less then the characters left in the d buffer
+ while ((dpos + rend - rpos) <= d.length) {
+ // Set current startpoint in d
+ int y = dpos;
+ // Check every character in d for equity. If the string is matched
+ // return dpos
+ for (int x = rpos; x <= rend; x++) {
+ if (x == rend)
+ return (dpos);
+ if (r[x] != d[y++])
+ break;
+ }
+ // Increase dpos to search for the same string at next offset
+ dpos++;
+ }
+ // The remaining chars in d buffer were not enough or the string
+ // wasn't matched
+ return (-1);
+ }
+
+ /**
+ * Get the offset of a last occurance of an int array within a char array.
+ * <br>
+ * This method return the index in d of the last occurrence after dpos of
+ * that part of array specified by r, starting at rpos and terminating at
+ * rend.
+ *
+ * @param r The array containing the data that need to be matched in d.
+ * @param rpos The index of the first character in r to look for.
+ * @param rend The index of the last character in r to look for plus 1.
+ * @param d The array of char that should contain a part of r.
+ * @param dpos The starting offset in d for the matching.
+ * @return The offset in d of the last part of r matched in d or -1 if that was
+ * not found.
+ */
+ protected static int lastIndexOfArray (int r[], int rpos, int rend,
+ char d[], int dpos) {
+ // Check if pos and len are legal
+ if (rend < rpos)
+ throw new IllegalArgumentException ("rend < rpos");
+ // If we need to match a zero length string return current dpos
+ if (rend == rpos)
+ return (d.length); //?? dpos?
+
+ // If we need to match a 1 char length string do it simply
+ if ((rend - rpos) == 1) {
+ // Search for the specified character
+ for (int x = d.length - 1; x > dpos; x--)
+ if (r[rpos] == d[x])
+ return (x);
+ }
+
+ // Main string matching loop. It gets executed if the characters to
+ // match are less then the characters left in the d buffer
+ int l = d.length - (rend - rpos);
+ while (l >= dpos) {
+ // Set current startpoint in d
+ int y = l;
+ // Check every character in d for equity. If the string is matched
+ // return dpos
+ for (int x = rpos; x <= rend; x++) {
+ if (x == rend)
+ return (l);
+ if (r[x] != d[y++])
+ break;
+ }
+ // Decrease l to search for the same string at next offset
+ l--;
+ }
+ // The remaining chars in d buffer were not enough or the string
+ // wasn't matched
+ return (-1);
+ }
+
+ /**
+ * Matches elements of array r from rpos to rend with array d, starting from dpos.
+ * <br>
+ * This method return true if elements of array r from rpos to rend
+ * equals elements of array d starting from dpos to dpos+(rend-rpos).
+ *
+ * @param r The array containing the data that need to be matched in d.
+ * @param rpos The index of the first character in r to look for.
+ * @param d The array of char that should start from a part of r.
+ * @param dpos The starting offset in d for the matching.
+ * @return true if array d starts from portion of array r.
+ */
+ protected static boolean matchArray (int r[], int rpos, int rend,
+ char d[], int dpos) {
+ if (d.length - dpos < rend - rpos)
+ return (false);
+ for (int i = rpos; i < rend; i++)
+ if (r[i] != d[dpos++])
+ return (false);
+ return (true);
+ }
+}
Modified: cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/java/org/apache/cocoon/deployer/AbstractDeployerTestCase.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/java/org/apache/cocoon/deployer/AbstractDeployerTestCase.java?rev=387003&r1=387002&r2=387003&view=diff
==============================================================================
--- cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/java/org/apache/cocoon/deployer/AbstractDeployerTestCase.java (original)
+++ cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/java/org/apache/cocoon/deployer/AbstractDeployerTestCase.java Sun Mar 19 09:13:14 2006
@@ -131,7 +131,4 @@
// just exist for Maven surfire ;-)
}
-
-
-
}
Added: cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/java/org/apache/cocoon/deployer/applicationserver/MonoliticServerTest.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/java/org/apache/cocoon/deployer/applicationserver/MonoliticServerTest.java?rev=387003&view=auto
==============================================================================
--- cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/java/org/apache/cocoon/deployer/applicationserver/MonoliticServerTest.java (added)
+++ cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/java/org/apache/cocoon/deployer/applicationserver/MonoliticServerTest.java Sun Mar 19 09:13:14 2006
@@ -0,0 +1,72 @@
+/*
+ * 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.deployer.applicationserver;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.apache.cocoon.deployer.AbstractDeployerTestCase;
+import org.apache.cocoon.deployer.logger.ConsoleLogger;
+import org.apache.cocoon.deployer.logger.Logger;
+import org.apache.cocoon.deployer.monolithic.FileAlreadyDeployedException;
+import org.apache.cocoon.deployer.monolithic.FileDeployer;
+import org.apache.cocoon.deployer.monolithic.SingleFileDeployer;
+
+public class MonoliticServerTest extends AbstractDeployerTestCase {
+
+ private static final String SERVER_DIR = "target/test/monolithicServer23";
+
+ public void testSimpleDeploy() throws Exception {
+ MonolithicServer monolithicServer = new MonolithicServer(new File(SERVER_DIR), new ConsoleLogger());
+ monolithicServer.addRule("**webdav*.xconf", new SingleFileDeployer("WEB-INF/xconf"));
+ monolithicServer.addRule("**legacy**.xmap", new SingleFileDeployer("WEB-INF/sitemap-additions"));
+ monolithicServer.addRule("**", new NullDeployer());
+ monolithicServer.extract(this.getMockArtefact("validMonolithicBlock-02/valid-block-1.0.jar"));
+ assertTrue(new File("target/test/monolithicServer23/WEB-INF/xconf/my-webdav-server.xconf").exists());
+ assertTrue(new File("target/test/monolithicServer23/WEB-INF/sitemap-additions/sa.xmap").exists());
+ }
+
+ public void testNotWorkingDeploy() throws Exception {
+ MonolithicServer monolithicServer = new MonolithicServer(new File(SERVER_DIR), new ConsoleLogger());
+ monolithicServer.addRule("**webdav*.xconf", new SingleFileDeployer("WEB-INF/xconf"));
+ monolithicServer.addRule("**", new NullDeployer());
+ monolithicServer.extract(this.getMockArtefact("validMonolithicBlock-02/valid-block-1.0.jar"));
+ try {
+ monolithicServer.extract(this.getMockArtefact("validMonolithicBlock-02/valid-block-1.0.jar"));
+ fail("If a file with the same name is deployed twice, an exception should be thrown.");
+ } catch(FileAlreadyDeployedException fade) {
+ // expected
+ }
+ }
+
+ static class NullDeployer implements FileDeployer {
+
+ public OutputStream writeResource(String documentName) throws IOException {
+ return new NullOutputStream();
+ }
+
+ public void setBasedir(File file) {}
+
+ public void setLogger(Logger logger) {}
+
+ }
+
+ static class NullOutputStream extends OutputStream {
+ public void write(int arg0) throws IOException {}
+ }
+
+}
Added: cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/java/org/apache/cocoon/deployer/monolithic/SingleFileDeployerTest.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/java/org/apache/cocoon/deployer/monolithic/SingleFileDeployerTest.java?rev=387003&view=auto
==============================================================================
--- cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/java/org/apache/cocoon/deployer/monolithic/SingleFileDeployerTest.java (added)
+++ cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/java/org/apache/cocoon/deployer/monolithic/SingleFileDeployerTest.java Sun Mar 19 09:13:14 2006
@@ -0,0 +1,27 @@
+/*
+ * 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.deployer.monolithic;
+
+import junit.framework.TestCase;
+
+public class SingleFileDeployerTest extends TestCase {
+
+ public void testGetFileName() {
+ String documentName = "blah/xyz.txt";
+ assertEquals("xyz.txt", new SingleFileDeployer("").getFileName(documentName));
+ }
+
+}
Modified: cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/mocks/build.xml
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/mocks/build.xml?rev=387003&r1=387002&r2=387003&view=diff
==============================================================================
--- cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/mocks/build.xml (original)
+++ cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/mocks/build.xml Sun Mar 19 09:13:14 2006
@@ -35,6 +35,7 @@
<create-mock-block target="validBlock-05"/>
<create-mock-block target="validBlock-06"/>
<create-mock-block target="validBlock-07"/>
+ <create-mock-block target="validMonolithicBlock-02"/>
</target>
</project>
Added: cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/mocks/validMonolithicBlock-02/blockRoot/COB-INF/block-sitemap.xmap
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/mocks/validMonolithicBlock-02/blockRoot/COB-INF/block-sitemap.xmap?rev=387003&view=auto
==============================================================================
--- cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/mocks/validMonolithicBlock-02/blockRoot/COB-INF/block-sitemap.xmap (added)
+++ cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/mocks/validMonolithicBlock-02/blockRoot/COB-INF/block-sitemap.xmap Sun Mar 19 09:13:14 2006
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 2005 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="test">
+ <map:generate src="test.xml"/>
+ <map:serialize/>
+ </map:match>
+ </map:pipeline>
+ </map:pipelines>
+</map:sitemap>
Added: cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/mocks/validMonolithicBlock-02/blockRoot/COB-INF/test.xml
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/mocks/validMonolithicBlock-02/blockRoot/COB-INF/test.xml?rev=387003&view=auto
==============================================================================
--- cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/mocks/validMonolithicBlock-02/blockRoot/COB-INF/test.xml (added)
+++ cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/mocks/validMonolithicBlock-02/blockRoot/COB-INF/test.xml Sun Mar 19 09:13:14 2006
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 2005 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.
+-->
+<test/>
\ No newline at end of file
Added: cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/mocks/validMonolithicBlock-02/blockRoot/META-INF/legacy/sitemap-additions/sa.xmap
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/mocks/validMonolithicBlock-02/blockRoot/META-INF/legacy/sitemap-additions/sa.xmap?rev=387003&view=auto
==============================================================================
--- cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/mocks/validMonolithicBlock-02/blockRoot/META-INF/legacy/sitemap-additions/sa.xmap (added)
+++ cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/mocks/validMonolithicBlock-02/blockRoot/META-INF/legacy/sitemap-additions/sa.xmap Sun Mar 19 09:13:14 2006
@@ -0,0 +1,17 @@
+<?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.
+-->
+<xconf/>
\ No newline at end of file
Added: cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/mocks/validMonolithicBlock-02/blockRoot/META-INF/legacy/xconf/my-webdav-server.xconf
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/mocks/validMonolithicBlock-02/blockRoot/META-INF/legacy/xconf/my-webdav-server.xconf?rev=387003&view=auto
==============================================================================
--- cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/mocks/validMonolithicBlock-02/blockRoot/META-INF/legacy/xconf/my-webdav-server.xconf (added)
+++ cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/mocks/validMonolithicBlock-02/blockRoot/META-INF/legacy/xconf/my-webdav-server.xconf Sun Mar 19 09:13:14 2006
@@ -0,0 +1,17 @@
+<?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.
+-->
+<xconf/>
\ No newline at end of file
Added: cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/mocks/validMonolithicBlock-02/valid-block-1.0.jar
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/mocks/validMonolithicBlock-02/valid-block-1.0.jar?rev=387003&view=auto
==============================================================================
Binary file - no diff available.
Propchange: cocoon/trunk/cocoon-block-deployer/cocoon-deployer-core/src/test/mocks/validMonolithicBlock-02/valid-block-1.0.jar
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Propchange: cocoon/trunk/cocoon-block-deployer/cocoon-deployer-minimal-webapp/
------------------------------------------------------------------------------
eol-style = native
Propchange: cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin/
------------------------------------------------------------------------------
eol-style = native
Propchange: cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin-demo/
------------------------------------------------------------------------------
eol-style = native
Modified: cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin-demo/pom.xml
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin-demo/pom.xml?rev=387003&r1=387002&r2=387003&view=diff
==============================================================================
--- cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin-demo/pom.xml (original)
+++ cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin-demo/pom.xml Sun Mar 19 09:13:14 2006
@@ -87,7 +87,7 @@
<groupId>org.apache.cocoon</groupId>
<artifactId>cocoon-default</artifactId>
<version>1.0-SNAPSHOT</version>
- </dependency>
+ </dependency>
</dependencies>
<pluginRepositories>
Modified: cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin-demo/src/main/resources/META-INF/block.xml
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin-demo/src/main/resources/META-INF/block.xml?rev=387003&r1=387002&r2=387003&view=diff
==============================================================================
--- cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin-demo/src/main/resources/META-INF/block.xml (original)
+++ cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin-demo/src/main/resources/META-INF/block.xml Sun Mar 19 09:13:14 2006
@@ -25,5 +25,7 @@
default="org.apache.cocoon:cocoon-tutorial-simple-block:1.0-SNAPSHOT"/>
<requires interface="http://cocoon.apache.org/blocks/core-components/1.0"
name="core" default="org.apache.cocoon:cocoon-core-components:1.0-SNAPSHOT"/>
+ <!--requires interface="http://cocoon.apache.org/blocks/template/1.0"
+ name="ctemplate" default="org.apache.cocoon:cocoon-template-impl:1.0-SNAPSHOT"/-->
</requirements>
</block>
Modified: cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/AbstractDeployMojo.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/AbstractDeployMojo.java?rev=387003&r1=387002&r2=387003&view=diff
==============================================================================
--- cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/AbstractDeployMojo.java (original)
+++ cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/AbstractDeployMojo.java Sun Mar 19 09:13:14 2006
@@ -18,11 +18,16 @@
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
+import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import org.apache.cocoon.deployer.BlockDeployer;
+import org.apache.cocoon.deployer.MonolithicCocoonDeployer;
import org.apache.cocoon.deployer.generated.deploy.x10.Deploy;
import org.apache.cocoon.deployer.resolver.NullVariableResolver;
+import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactResolver;
@@ -188,5 +193,26 @@
blockDeployer.deploy(deploy, false, true);
}
+
+ /**
+ * Deploy a monolithic Cocoon web application. This means it doesn't use
+ * the features that the blocks-fw offers.
+ */
+ protected void deployMonolithicCocoonApp() throws MojoExecutionException {
+ File webappDirectory_ = getWebappDirectory();
+
+ // build the web application
+ this.buildExplodedWebapp(webappDirectory_);
+
+ // loop over all artifacts and deploy them correctly
+ Map files = new HashMap();
+ for(Iterator it = this.project.getArtifacts().iterator(); it.hasNext(); ) {
+ Artifact artifact = (Artifact) it.next();
+ files.put(artifact.getGroupId() + ":" + artifact.getGroupId() + ":" + artifact.getVersion(), artifact.getFile());
+ }
+
+ MonolithicCocoonDeployer.deploy(files, webappDirectory_, new MavenLoggingWrapper(this.getLog()));
+ }
+
}
Modified: cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/DeployExplodedMojo.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/DeployExplodedMojo.java?rev=387003&r1=387002&r2=387003&view=diff
==============================================================================
--- cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/DeployExplodedMojo.java (original)
+++ cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/DeployExplodedMojo.java Sun Mar 19 09:13:14 2006
@@ -23,12 +23,21 @@
* @goal deploy
* @requiresProject true
* @phase package
- * @description Create a Cocoon web application based on a block deployment descriptor.
+ * @description Create a Cocoon web application.
*/
public class DeployExplodedMojo extends AbstractDeployMojo {
+ /**
+ * /@parameter expression="2.4"
+ */
+ private String version;
+
public void execute() throws MojoExecutionException {
- this.deployBlocks();
+ if(this.version.equals("2.3")) {
+ this.deployMonolithicCocoonApp();
+ } else {
+ this.deployBlocks();
+ }
}
}
Modified: cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/MavenArtifactProvider.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/MavenArtifactProvider.java?rev=387003&r1=387002&r2=387003&view=diff
==============================================================================
--- cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/MavenArtifactProvider.java (original)
+++ cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/MavenArtifactProvider.java Sun Mar 19 09:13:14 2006
@@ -129,7 +129,7 @@
try {
List dependencies = new ArrayList();
- Set artifacts = null;
+ Set artifacts = null;
for(int i = 0; i < artifactIds.length; i++) {
ArtifactBean artifactBean = getArtifactBeanFor(artifactIds[i]);
Propchange: cocoon/trunk/cocoon-block-deployer/cocoon-deployer-webapp-sample/
------------------------------------------------------------------------------
eol-style = native
Propchange: cocoon/trunk/cocoon-block-deployer/cocoon-tutorial-simple-block/
------------------------------------------------------------------------------
eol-style = native
Propchange: cocoon/trunk/cocoon-block-deployer/pom.xml
------------------------------------------------------------------------------
eol-style = native