cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jheym...@apache.org
Subject svn commit: r330548 [6/132] - in /cocoon/whiteboard/maven2/cocoon-flat-layout: ./ cocoon-ajax-block/ cocoon-ajax-block/api/ cocoon-ajax-block/api/src/ cocoon-ajax-block/api/src/main/ cocoon-ajax-block/api/src/main/java/ cocoon-ajax-block/api/src/main/r...
Date Thu, 03 Nov 2005 14:00:48 GMT
Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-asciiart-block/samples/src/main/resources/sitemap.xmap
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-asciiart-block/samples/src/main/resources/sitemap.xmap?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-asciiart-block/samples/src/main/resources/sitemap.xmap (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-asciiart-block/samples/src/main/resources/sitemap.xmap Thu Nov  3 05:41:06 2005
@@ -0,0 +1,82 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 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:components>
+    <map:generators default="file">
+      <map:generator name="asciiart-svg" logger="sitemap.generator.asciiart-svg" 
+                     src="org.apache.cocoon.generation.asciiart.AsciiArtSVGGenerator"/>
+    </map:generators>
+  </map:components>
+
+<!-- =========================== Views =================================== -->
+
+  <map:views>
+    <map:view from-label="content" name="content">
+      <map:serialize type="xml"/>
+    </map:view>
+
+    <map:view from-label="content" name="pretty-content">
+      <map:transform src="context://stylesheets/system/xml2html.xslt"/>
+      <map:serialize type="html"/>
+    </map:view>
+
+    <map:view from-position="last" name="links">
+      <map:serialize type="links"/>
+    </map:view>
+  </map:views>
+
+<!-- =========================== Pipelines ================================= -->
+
+  <map:pipelines>
+    <map:pipeline>   
+ 
+      <map:match pattern="">
+        <map:redirect-to uri="welcome"/>
+      </map:match>
+
+      <map:match pattern="welcome">
+        <map:generate type="directory" src="data">
+          <map:parameter name="include" value="\.txt$"/>
+        </map:generate>
+        <map:transform src="dir2html.xsl"/>
+        <map:transform src="context://samples/common/style/xsl/html/simple-samples2html.xsl">
+          <map:parameter name="contextPath" value="{request:contextPath}"/>
+        </map:transform>
+        <map:serialize/>
+      </map:match>
+
+      <!-- expects format xxxyyyzzt.txt.png -->
+      <map:match pattern="*.jpg">
+        <map:generate type="asciiart-svg" src="data/{1}"/>
+        <map:serialize type="svg2jpeg"/>
+      </map:match>
+
+      <!-- expects format xxxyyyzzt.txt.png -->
+      <map:match pattern="*.png">
+        <map:generate type="asciiart-svg" src="data/{1}"/>
+        <map:serialize type="svg2png"/>
+      </map:match>
+
+      <map:match pattern="*.txt">
+        <map:read src="data/{1}.txt" mime-type="text/plain"/>
+      </map:match>
+
+    </map:pipeline>
+  </map:pipelines>
+</map:sitemap>

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-asciiart-block/samples/src/main/resources/sitemap.xmap
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/pom.xml
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/pom.xml?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/pom.xml (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/pom.xml Thu Nov  3 05:41:06 2005
@@ -0,0 +1,354 @@
+<?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.
+-->
+<!--+
+  | @version $Id:$
+  |
+  +-->
+<project>
+  <parent>
+    <groupId>apache-cocoon</groupId>
+    <artifactId>cocoon</artifactId>
+    <version>2.2-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>apache-cocoon</groupId>
+  <artifactId>cocoon-core</artifactId>
+  <version>2.2-SNAPSHOT</version>
+  <packaging>jar</packaging>
+  <name>Cocoon Core</name>
+  <build>
+    <!-- tests can be reused by other blocks -->
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jar-plugin</artifactId>
+        <executions>
+          <execution>
+            <goals>
+              <goal>test-jar</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+      <!-- exclude a few tests, set the loglevel so we don't get flooded -->
+      <plugin>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <includes>
+            <include implementation="java.lang.String">**/*TestCase.class</include>
+            <include implementation="java.lang.String">**/*Test.class</include>
+          </includes>
+          <excludes>
+            <exclude implementation="java.lang.String">**/AllTest.class</exclude>
+            <exclude implementation="java.lang.String">**/CocoonBeanTestCase.class</exclude>
+            <exclude implementation="java.lang.String">**/*$$*Test.class</exclude>
+            <exclude implementation="java.lang.String">**/Abstract*.class</exclude>
+            <exclude implementation="java.lang.String">**/SitemapComponentTestCase*</exclude>
+            <exclude implementation="java.lang.String">**/SitemapTestCase*</exclude>
+            <exclude implementation="java.lang.String">**/ContainerTestCase*</exclude>
+            <exclude implementation="java.lang.String">**/CocoonTestCase*</exclude>
+            <exclude implementation="java.lang.String">**/VirtualPipelineGeneratorTestCase*</exclude>
+          </excludes>
+          <systemProperties>
+            <property>
+              <name>junit.test.loglevel</name>
+              <value>3</value>
+            </property>
+          </systemProperties>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+  <dependencies>
+    <dependency>
+      <groupId>ant</groupId>
+      <artifactId>ant</artifactId>
+      <version>1.6.5</version>
+    </dependency>
+    <dependency>
+      <groupId>ant</groupId>
+      <artifactId>ant-launcher</artifactId>
+      <version>1.6.5</version>
+    </dependency>
+    <dependency>
+      <groupId>ant</groupId>
+      <artifactId>ant-trax</artifactId>
+      <version>1.6.5</version>
+    </dependency>
+    <dependency>
+      <groupId>avalon-framework</groupId>
+      <artifactId>avalon-framework-api</artifactId>
+      <version>4.3</version>
+    </dependency>
+    <dependency>
+      <groupId>avalon-framework</groupId>
+      <artifactId>avalon-framework-impl</artifactId>
+      <version>4.3</version>
+    </dependency>
+    <dependency>
+      <groupId>avalon-logkit</groupId>
+      <artifactId>avalon-logkit</artifactId>
+      <version>2.1</version>
+    </dependency>
+    <dependency>
+      <groupId>commons-cli</groupId>
+      <artifactId>commons-cli</artifactId>
+      <version>1.0</version>
+    </dependency>
+    <dependency>
+      <groupId>commons-collections</groupId>
+      <artifactId>commons-collections</artifactId>
+      <version>3.1</version>
+    </dependency>
+    <dependency>
+      <groupId>commons-httpclient</groupId>
+      <artifactId>commons-httpclient</artifactId>
+      <version>2.0.2</version>
+    </dependency>
+    <dependency>
+      <groupId>commons-javaflow</groupId>
+      <artifactId>commons-javaflow</artifactId>
+      <version>r306555</version>
+    </dependency>
+    <dependency>
+      <groupId>commons-jci</groupId>
+      <artifactId>commons-jci</artifactId>
+      <version>r306555</version>
+    </dependency>
+    <dependency>
+      <groupId>commons-jexl</groupId>
+      <artifactId>commons-jexl</artifactId>
+      <version>1.0</version>
+    </dependency>
+    <dependency>
+      <groupId>commons-jxpath</groupId>
+      <artifactId>commons-jxpath</artifactId>
+      <version>1.2</version>
+      <exclusions>
+        <exclusion>
+          <groupId>ant-optional</groupId>
+          <artifactId>ant-optional</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>xerces</groupId>
+          <artifactId>xerces</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+    <dependency>
+      <groupId>commons-lang</groupId>
+      <artifactId>commons-lang</artifactId>
+      <version>2.1</version>
+    </dependency>
+    <dependency>
+      <groupId>commons-logging</groupId>
+      <artifactId>commons-logging</artifactId>
+      <version>1.0.4</version>
+      <exclusions>
+        <exclusion>
+          <groupId>avalon-framework</groupId>
+          <artifactId>avalon-framework</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+    <dependency>
+      <groupId>concurrent</groupId>
+      <artifactId>concurrent</artifactId>
+      <version>1.3.4</version>
+    </dependency>
+    <dependency>
+      <groupId>ehcache</groupId>
+      <artifactId>ehcache</artifactId>
+      <version>1.1</version>
+    </dependency>
+    <dependency>
+      <groupId>excalibur-i18n</groupId>
+      <artifactId>excalibur-i18n</artifactId>
+      <version>1.1</version>
+    </dependency>
+    <dependency>
+      <groupId>excalibur-instrument</groupId>
+      <artifactId>excalibur-instrument-api</artifactId>
+      <version>2.1</version>
+    </dependency>
+    <dependency>
+      <groupId>excalibur-io</groupId>
+      <artifactId>excalibur-io</artifactId>
+      <version>1.1</version>
+    </dependency>
+    <dependency>
+      <groupId>excalibur-logger</groupId>
+      <artifactId>excalibur-logger</artifactId>
+      <version>2.1</version>
+    </dependency>
+    <dependency>
+      <groupId>excalibur-naming</groupId>
+      <artifactId>excalibur-naming</artifactId>
+      <version>1.0</version>
+    </dependency>
+    <dependency>
+      <groupId>excalibur-pool</groupId>
+      <artifactId>excalibur-pool-api</artifactId>
+      <version>2.1</version>
+    </dependency>
+    <dependency>
+      <groupId>excalibur-pool</groupId>
+      <artifactId>excalibur-pool-impl</artifactId>
+      <version>2.1</version>
+    </dependency>
+    <dependency>
+      <groupId>excalibur-pool</groupId>
+      <artifactId>excalibur-pool-instrumented</artifactId>
+      <version>2.1</version>
+    </dependency>
+    <dependency>
+      <groupId>excalibur-sourceresolve</groupId>
+      <artifactId>excalibur-sourceresolve</artifactId>
+      <version>2.1</version>
+    </dependency>
+    <dependency>
+      <groupId>excalibur-store</groupId>
+      <artifactId>excalibur-store</artifactId>
+      <version>2.1</version>
+    </dependency>
+    <dependency>
+      <groupId>excalibur-xmlutil</groupId>
+      <artifactId>excalibur-xmlutil</artifactId>
+      <version>2.1</version>
+    </dependency>
+    <dependency>
+      <groupId>jakarta-bcel</groupId>
+      <artifactId>jakarta-bcel</artifactId>
+      <version>20040329</version>
+    </dependency>
+    <dependency>
+      <groupId>jcs</groupId>
+      <artifactId>jcs</artifactId>
+      <version>1.2.5-dev-20050313</version>
+    </dependency>
+    <dependency>
+      <groupId>knopflerfish</groupId>
+      <artifactId>knopflerfish-cm_api</artifactId>
+      <version>1.0.0</version>
+    </dependency>
+    <dependency>
+      <groupId>knopflerfish</groupId>
+      <artifactId>knopflerfish-console_all</artifactId>
+      <version>1.0.0</version>
+    </dependency>
+    <dependency>
+      <groupId>knopflerfish</groupId>
+      <artifactId>knopflerfish-consoletty</artifactId>
+      <version>1.0.0</version>
+    </dependency>
+    <dependency>
+      <groupId>knopflerfish</groupId>
+      <artifactId>knopflerfish-framework</artifactId>
+      <version>1.3.3</version>
+    </dependency>
+    <dependency>
+      <groupId>knopflerfish</groupId>
+      <artifactId>knopflerfish-frameworkcommands</artifactId>
+      <version>1.0.0</version>
+    </dependency>
+    <dependency>
+      <groupId>knopflerfish</groupId>
+      <artifactId>knopflerfish-http_all</artifactId>
+      <version>1.1.0</version>
+    </dependency>
+    <dependency>
+      <groupId>knopflerfish</groupId>
+      <artifactId>knopflerfish-log_all</artifactId>
+      <version>1.0.0</version>
+    </dependency>
+    <dependency>
+      <groupId>knopflerfish</groupId>
+      <artifactId>knopflerfish-logcommands</artifactId>
+      <version>1.0.0</version>
+    </dependency>
+    <dependency>
+      <groupId>log4j</groupId>
+      <artifactId>log4j</artifactId>
+      <version>1.2.11</version>
+    </dependency>
+    <dependency>
+      <groupId>jakarta-regexp</groupId>
+      <artifactId>jakarta-regexp</artifactId>
+      <version>1.4</version>
+    </dependency>
+    <dependency>
+      <groupId>rhino</groupId>
+      <artifactId>rhino</artifactId>
+      <version>1.6R1</version>
+    </dependency>
+    <dependency>
+      <groupId>servletapi</groupId>
+      <artifactId>servletapi</artifactId>
+      <version>2.3</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>xalan</groupId>
+      <artifactId>xalan</artifactId>
+      <version>2.7.0</version>
+    </dependency>
+    <dependency>
+      <groupId>xerces</groupId>
+      <artifactId>xercesImpl</artifactId>
+      <version>2.7.1</version>
+    </dependency>
+    <dependency>
+      <groupId>xmlbeans</groupId>
+      <artifactId>xmlbeans</artifactId>
+      <version>1.0.3</version>
+    </dependency>
+    <dependency>
+      <groupId>xml-resolver</groupId>
+      <artifactId>xml-resolver</artifactId>
+      <version>1.1</version>
+    </dependency>
+    <dependency>
+      <groupId>xml-apis</groupId>
+      <artifactId>xml-apis</artifactId>
+      <version>1.3.02</version>
+    </dependency>
+    <dependency>
+      <groupId>easymock</groupId>
+      <artifactId>easymock</artifactId>
+      <version>1.1</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>jmock</groupId>
+      <artifactId>jmock</artifactId>
+      <version>1.0.1</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>xmlunit</groupId>
+      <artifactId>xmlunit</artifactId>
+      <version>0.8</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+</project>

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/CascadingIOException.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/CascadingIOException.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/CascadingIOException.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/CascadingIOException.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,148 @@
+/*
+ * Copyright 1999-2004 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;
+
+import java.io.IOException;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+
+import org.apache.avalon.framework.CascadingThrowable;
+import org.xml.sax.SAXParseException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.SourceLocator;
+
+/**
+ * This is a wrapping IOException.
+ * 
+ * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
+ * @version CVS $Id: CascadingIOException.java 30941 2004-07-29 19:56:58Z vgritsenko $
+ */
+
+public class CascadingIOException 
+extends IOException 
+implements CascadingThrowable {
+
+    /**
+     * The Throwable that caused this exception to be thrown.
+     */
+    private final Throwable m_throwable;
+
+
+    /**
+     * Construct a new <code>ProcessingException</code> instance.
+     */
+    public CascadingIOException(String message) {
+        this(message, null);
+    }
+    
+    /**
+     * Creates a new <code>ProcessingException</code> instance.
+     *
+     * @param ex an <code>Exception</code> value
+     */
+    public CascadingIOException(Exception ex) {
+        this(ex.getMessage(), ex);
+    }
+    
+    /**
+     * Construct a new <code>ProcessingException</code> that references
+     * a parent Exception.
+     */
+    public CascadingIOException(String message, Throwable t) {
+        super( message );
+        this.m_throwable = t;
+    }
+    
+    /**
+     * Retrieve root cause of the exception.
+     *
+     * @return the root cause
+     */
+    public final Throwable getCause()
+    {
+        return this.m_throwable;
+    }
+
+    public String toString() {
+        StringBuffer s = new StringBuffer();
+        s.append(super.toString());
+        final Throwable t = getCause();
+        if(t!=null) {
+            s.append(": ");
+            // be more verbose try to get location info
+            s.append( extraInfo(t) );
+            s.append(t.toString());
+        }
+        return s.toString();
+    }
+    
+    /**
+     * Examine Throwable and try to figure out location information.
+     * <p>
+     *   At the moment only SAXParseException, and TransformerException
+     *   are considered.
+     * </p>
+     *
+     * @return String containing location information of the format
+     *  <code>{file-name}:{line}:{column}:</code>, if no location info is 
+     *  available return empty string
+     */
+    private String extraInfo( Throwable t ) {
+        StringBuffer sb = new StringBuffer();
+        if (t instanceof SAXParseException) {
+            SAXParseException spe = (SAXParseException)t;
+            sb.append( String.valueOf(spe.getSystemId()));
+            sb.append( ":" );
+            sb.append( String.valueOf(spe.getLineNumber()));
+            sb.append( ":" );
+            sb.append( String.valueOf(spe.getColumnNumber()));
+            sb.append( ":" );
+        } else if (t instanceof TransformerException) {
+            TransformerException transformerException = (TransformerException) t;
+            SourceLocator sourceLocator = transformerException.getLocator();
+            
+            if( null != sourceLocator ) {
+                sb.append( String.valueOf(sourceLocator.getSystemId()));
+                sb.append( ":" );
+                sb.append( String.valueOf(sourceLocator.getLineNumber()));
+                sb.append( ":" );
+                sb.append( String.valueOf(sourceLocator.getColumnNumber()));
+                sb.append( ":" );
+            }
+        }
+        return sb.toString();
+    }
+    
+    public void printStackTrace() {
+        super.printStackTrace();
+        if(getCause()!=null)
+            getCause().printStackTrace();
+    }
+    
+    public void printStackTrace( PrintStream s ) {
+        super.printStackTrace(s);
+        if(getCause()!=null)
+            getCause().printStackTrace(s);
+    }
+    
+    public void printStackTrace( PrintWriter s ) {
+        super.printStackTrace(s);
+        if(getCause()!=null)
+            getCause().printStackTrace(s);
+    }
+
+}
+

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/CascadingIOException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/Cocoon.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/Cocoon.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/Cocoon.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/Cocoon.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,680 @@
+/*
+ * 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;
+
+import org.apache.avalon.excalibur.logger.LoggerManager;
+import org.apache.avalon.framework.activity.Disposable;
+import org.apache.avalon.framework.activity.Initializable;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.container.ContainerUtil;
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.context.ContextException;
+import org.apache.avalon.framework.context.Contextualizable;
+import org.apache.avalon.framework.context.DefaultContext;
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.avalon.framework.thread.ThreadSafe;
+
+import org.apache.cocoon.components.ContextHelper;
+import org.apache.cocoon.components.container.CocoonServiceManager;
+import org.apache.cocoon.components.container.ComponentContext;
+import org.apache.cocoon.components.source.SourceUtil;
+import org.apache.cocoon.components.source.impl.DelayedRefreshSourceWrapper;
+import org.apache.cocoon.configuration.ConfigurationBuilder;
+import org.apache.cocoon.core.Core;
+import org.apache.cocoon.core.Settings;
+import org.apache.cocoon.core.container.RoleManager;
+import org.apache.cocoon.environment.Environment;
+import org.apache.cocoon.environment.ObjectModelHelper;
+import org.apache.cocoon.environment.Request;
+import org.apache.cocoon.environment.Session;
+import org.apache.cocoon.environment.internal.EnvironmentHelper;
+import org.apache.cocoon.util.location.Location;
+import org.apache.cocoon.util.location.LocationImpl;
+import org.apache.cocoon.util.location.LocationUtils;
+
+import org.apache.commons.lang.SystemUtils;
+import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceResolver;
+import org.apache.excalibur.source.impl.URLSource;
+import org.xml.sax.InputSource;
+
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * The Cocoon Object is the main Kernel for the entire Cocoon system.
+ *
+ * @author <a href="mailto:pier@apache.org">Pierpaolo Fumagalli</a> (Apache Software Foundation)
+ * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
+ * @author <a href="mailto:leo.sutic@inspireinfrastructure.com">Leo Sutic</a>
+ * @version CVS $Id: Cocoon.java 312930 2005-10-11 18:13:35Z cziegeler $
+ */
+public class Cocoon
+        extends AbstractLogEnabled
+        implements ThreadSafe,
+                   Initializable,
+                   Disposable,
+                   Modifiable,
+                   Processor,
+                   Contextualizable,
+                   Serviceable {
+
+    // Register the location finder for Avalon configuration objects and exceptions
+    // and keep a strong reference to it.
+    private static final LocationUtils.LocationFinder confLocFinder = new LocationUtils.LocationFinder() {
+        public Location getLocation(Object obj, String description) {
+            if (obj instanceof Configuration) {
+                Configuration config = (Configuration)obj;
+                String locString = config.getLocation();
+                Location result = LocationUtils.parse(locString);
+                if (LocationUtils.isKnown(result)) {
+                    // Add description
+                    StringBuffer desc = new StringBuffer().append('<');
+                    // Unfortunately Configuration.getPrefix() is not public
+                    try {
+                        if (config.getNamespace().startsWith("http://apache.org/cocoon/sitemap/")) {
+                            desc.append("map:");
+                        }
+                    } catch (ConfigurationException e) {
+                        // no namespace: ignore
+                    }
+                    desc.append(config.getName()).append('>');
+                    return new LocationImpl(desc.toString(), result);
+                } else {
+                    return result;
+                }
+            }
+            
+            if (obj instanceof Exception) {
+                // Many exceptions in Cocoon have a message like "blah blah at file://foo/bar.xml:12:1"
+                String msg = ((Exception)obj).getMessage();
+                if (msg == null) return null;
+                
+                int pos = msg.lastIndexOf(" at ");
+                if (pos != -1) {
+                    return LocationUtils.parse(msg.substring(pos + 4));
+                } else {
+                    // Will try other finders
+                    return null;
+                }
+            }
+            
+            // Try next finders.
+            return null;
+        }
+    };
+    
+    static {
+        LocationUtils.addFinder(confLocFinder);
+    }
+    
+    static Cocoon instance;
+
+    /** The root Cocoon logger */
+    private Logger rootLogger;
+
+    /** The application context */
+    private Context context;
+
+    /** The configuration file */
+    private Source configurationFile;
+
+    /** The logger manager */
+    private LoggerManager loggerManager;
+
+    /** The parent service manager. */
+    private ServiceManager parentServiceManager;
+
+    /** Flag for disposed or not */
+    private boolean disposed;
+
+    /** Active request count */
+    private volatile int activeRequestCount;
+
+    /** the Processor */
+    private Processor processor;
+
+    /** The source resolver */
+    protected SourceResolver sourceResolver;
+
+    /** The environment helper */
+    protected EnvironmentHelper environmentHelper;
+
+    /** A service manager */
+    protected CocoonServiceManager serviceManager;
+
+    /** An optional Avalon Component that is called before and after processing all requests. */
+    protected RequestListener requestListener;
+
+    /** The Cocoon Core */
+    protected Core core;
+
+    /** Processor attributes */
+    protected Map processorAttributes = new HashMap();
+
+    /**
+     * Creates a new <code>Cocoon</code> instance.
+     */
+    public Cocoon() {
+        // Set the system properties needed by Xalan2.
+        setSystemProperties();
+
+        // HACK: Provide a way to share an instance of Cocoon object between
+        //       several servlets/portlets.
+        Cocoon.instance = this;
+    }
+
+    /**
+     * @see org.apache.avalon.framework.logger.LogEnabled#enableLogging(org.apache.avalon.framework.logger.Logger)
+     */
+    public void enableLogging(Logger logger) {
+        this.rootLogger = logger;
+        super.enableLogging(logger.getChildLogger("cocoon"));
+    }
+
+    /**
+     * Get the parent service manager. For purposes of
+     * avoiding extra method calls, the manager parameter may be null.
+     *
+     * @param manager the parent component manager. May be <code>null</code>
+     */
+    public void service(ServiceManager manager)
+    throws ServiceException {
+        this.parentServiceManager = manager;
+        this.core = (Core)this.parentServiceManager.lookup(Core.ROLE);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
+     */
+    public void contextualize(Context context) throws ContextException {
+        this.context = new ComponentContext(context);
+        ((DefaultContext)this.context).makeReadOnly();
+    }
+
+    /**
+     * The <code>setLoggerManager</code> method will get a <code>LoggerManager</code>
+     * for further use.
+     *
+     * @param loggerManager a <code>LoggerManager</code> value
+     */
+    public void setLoggerManager(LoggerManager loggerManager) {
+        this.loggerManager = loggerManager;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.avalon.framework.activity.Initializable#initialize()
+     */
+    public void initialize() throws Exception {
+        getLogger().debug("Initializing new Cocoon object.");
+        final Settings settings = this.core.getSettings();
+        try {
+            URLSource urlSource = new URLSource();
+            urlSource.init(new URL(settings.getConfiguration()), null);
+            this.configurationFile = new DelayedRefreshSourceWrapper(urlSource,
+                                                                     settings.getReloadDelay("config"));
+
+        } catch (IOException e) {
+            throw new ConfigurationException(
+                    "Could not open configuration file: " + settings.getConfiguration(), e);
+        }
+
+        this.serviceManager = new CocoonServiceManager(this.parentServiceManager);
+        ContainerUtil.enableLogging(this.serviceManager, this.rootLogger.getChildLogger("manager"));
+        ContainerUtil.contextualize(this.serviceManager, this.context);
+
+        // Log the System Properties.
+        dumpSystemProperties();
+
+        this.configure();
+
+        // add the logger manager to the component locator
+
+        ContainerUtil.initialize(this.serviceManager);
+
+        // Get the Processor and keep it
+        this.processor = (Processor)this.serviceManager.lookup(Processor.ROLE);
+
+        this.environmentHelper = new EnvironmentHelper(
+                (URL) this.context.get(ContextHelper.CONTEXT_ROOT_URL));
+        ContainerUtil.enableLogging(this.environmentHelper, this.rootLogger);
+        ContainerUtil.service(this.environmentHelper, this.serviceManager);
+
+        this.sourceResolver = (SourceResolver)this.serviceManager.lookup(SourceResolver.ROLE);
+
+        if (this.serviceManager.hasService(RequestListener.ROLE)){
+            this.requestListener = (RequestListener) this.serviceManager.lookup(RequestListener.ROLE);
+        }
+        Core.cleanup();
+    }
+
+    /** Dump System Properties */
+    private void dumpSystemProperties() {
+        if (getLogger().isDebugEnabled()) {
+            try {
+                Enumeration e = System.getProperties().propertyNames();
+                getLogger().debug("===== System Properties Start =====");
+                for (; e.hasMoreElements();) {
+                    String key = (String) e.nextElement();
+                    getLogger().debug(key + "=" + System.getProperty(key));
+                }
+                getLogger().debug("===== System Properties End =====");
+            } catch (SecurityException se) {
+                // Ignore Exceptions.
+            }
+        }
+    }
+
+    /**
+     * Configure this <code>Cocoon</code> instance.
+     *
+     * @exception ConfigurationException if an error occurs
+     * @exception ContextException if an error occurs
+     */
+    private void configure() throws Exception {
+        InputSource is = SourceUtil.getInputSource(this.configurationFile);
+
+        final Settings settings = this.core.getSettings();
+        ConfigurationBuilder builder = new ConfigurationBuilder(settings);
+        Configuration conf = builder.build(is);
+
+        if (getLogger().isDebugEnabled()) {
+            getLogger().debug("Root configuration: " + conf.getName());
+        }
+        if (!"cocoon".equals(conf.getName())) {
+            throw new ConfigurationException("Invalid configuration file\n" + conf.toString());
+        }
+        if (getLogger().isDebugEnabled()) {
+            getLogger().debug("Configuration version: " + conf.getAttribute("version"));
+        }
+        if (!Constants.CONF_VERSION.equals(conf.getAttribute("version"))) {
+            throw new ConfigurationException("Invalid configuration schema version. Must be '" + Constants.CONF_VERSION + "'.");
+        }
+
+        RoleManager drm = null;
+        String userRoles = conf.getAttribute("user-roles", "");
+        if (!"".equals(userRoles)) {
+            Configuration roles;
+            try {
+                org.apache.cocoon.environment.Context context =
+                    (org.apache.cocoon.environment.Context) this.context.get(Constants.CONTEXT_ENVIRONMENT_CONTEXT);
+                URL url = context.getResource(userRoles);
+                if (url == null) {
+                    throw new ConfigurationException("User-roles configuration '"+userRoles+"' cannot be found.");
+                }
+                is = new InputSource(new BufferedInputStream(url.openStream()));
+                is.setSystemId(url.toString());
+                roles = builder.build(is);
+            } catch (Exception e) {
+                throw new ConfigurationException("Error trying to load user-roles configuration", e);
+            }
+
+            RoleManager urm = new RoleManager(drm);
+            ContainerUtil.enableLogging(urm, this.rootLogger.getChildLogger("roles").getChildLogger("user"));
+            ContainerUtil.configure(urm, roles);
+            roles = null;
+            drm = urm;
+        }
+
+        this.serviceManager.setRoleManager(drm);
+        this.serviceManager.setLoggerManager(this.loggerManager);
+
+        getLogger().debug("Setting up components...");
+        ContainerUtil.configure(this.serviceManager, conf);
+    }
+
+    /**
+     * Queries the class to estimate its ergodic period termination.
+     *
+     * @param date a <code>long</code> value
+     * @return a <code>boolean</code> value
+     */
+    public boolean modifiedSince(long date) {
+        return date < this.configurationFile.getLastModified();
+    }
+
+    /**
+     * Helper method to retrieve system property.
+     * Returns default value if SecurityException is caught.
+     */
+    public static String getSystemProperty(String property, String value) {
+        try {
+            return System.getProperty(property, value);
+        } catch (SecurityException e) {
+            System.err.println("Caught a SecurityException reading the system property '" + property + "';" +
+                               " Cocoon will default to '" + value + "' value.");
+            return value;
+        }
+    }
+
+    /**
+     * Sets required system properties.
+     */
+    protected void setSystemProperties() {
+        try {
+            // FIXME We shouldn't have to specify the SAXParser...
+            // This is needed by Xalan2, it is used by org.xml.sax.helpers.XMLReaderFactory
+            // to locate the SAX2 driver.
+            if (getSystemProperty("org.xml.sax.driver", null) == null) {
+                System.setProperty("org.xml.sax.driver", "org.apache.xerces.parsers.SAXParser");
+            }
+        } catch (SecurityException e) {
+            // Ignore security exceptions
+            System.out.println("Caught a SecurityException writing the system property: " + e);
+        }
+
+        try {
+            // FIXME We shouldn't have to specify these. Needed to override jaxp implementation of weblogic.
+            if (getSystemProperty("javax.xml.parsers.DocumentBuilderFactory", "").startsWith("weblogic")) {
+                System.setProperty("javax.xml.parsers.DocumentBuilderFactory", "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
+                System.setProperty("javax.xml.parsers.SAXParserFactory","org.apache.xerces.jaxp.SAXParserFactoryImpl");
+            }
+        } catch (SecurityException e) {
+            // Ignore security exceptions
+            System.out.println("Caught a SecurityException writing the system property: " + e);
+        }
+    }
+
+    /**
+     * @see org.apache.avalon.framework.activity.Disposable#dispose()
+     */
+    public void dispose() {
+        if (this.serviceManager != null) {
+            this.serviceManager.release(this.requestListener);
+            this.requestListener = null;
+
+            this.serviceManager.release(this.processor);
+            this.processor = null;
+
+            this.serviceManager.release(this.sourceResolver);
+            this.sourceResolver = null;
+
+            ContainerUtil.dispose(this.serviceManager);
+            this.serviceManager = null;
+        }
+        if ( this.parentServiceManager != null ) {
+            this.parentServiceManager.release(this.core);
+            this.core = null;
+            this.parentServiceManager = null;
+        }
+        this.context = null;
+        if (Cocoon.instance == this) {
+            Cocoon.instance = null;
+        }
+        this.disposed = true;
+    }
+
+    /**
+     * Log debug information about the current environment.
+     *
+     * @param environment an <code>Environment</code> value
+     */
+    protected void debug(Environment environment, boolean internal) {
+        String lineSeparator = SystemUtils.LINE_SEPARATOR;
+        Map objectModel = environment.getObjectModel();
+        Request request = ObjectModelHelper.getRequest(objectModel);
+        Session session = request.getSession(false);
+        StringBuffer msg = new StringBuffer();
+        msg.append("DEBUGGING INFORMATION:").append(lineSeparator);
+        if (internal) {
+            msg.append("INTERNAL ");
+        }
+        msg.append("REQUEST: ").append(request.getRequestURI()).append(lineSeparator).append(lineSeparator);
+        msg.append("CONTEXT PATH: ").append(request.getContextPath()).append(lineSeparator);
+        msg.append("SERVLET PATH: ").append(request.getServletPath()).append(lineSeparator);
+        msg.append("PATH INFO: ").append(request.getPathInfo()).append(lineSeparator).append(lineSeparator);
+
+        msg.append("REMOTE HOST: ").append(request.getRemoteHost()).append(lineSeparator);
+        msg.append("REMOTE ADDRESS: ").append(request.getRemoteAddr()).append(lineSeparator);
+        msg.append("REMOTE USER: ").append(request.getRemoteUser()).append(lineSeparator);
+        msg.append("REQUEST SESSION ID: ").append(request.getRequestedSessionId()).append(lineSeparator);
+        msg.append("REQUEST PREFERRED LOCALE: ").append(request.getLocale().toString()).append(lineSeparator);
+        msg.append("SERVER HOST: ").append(request.getServerName()).append(lineSeparator);
+        msg.append("SERVER PORT: ").append(request.getServerPort()).append(lineSeparator).append(lineSeparator);
+
+        msg.append("METHOD: ").append(request.getMethod()).append(lineSeparator);
+        msg.append("CONTENT LENGTH: ").append(request.getContentLength()).append(lineSeparator);
+        msg.append("PROTOCOL: ").append(request.getProtocol()).append(lineSeparator);
+        msg.append("SCHEME: ").append(request.getScheme()).append(lineSeparator);
+        msg.append("AUTH TYPE: ").append(request.getAuthType()).append(lineSeparator).append(lineSeparator);
+        msg.append("CURRENT ACTIVE REQUESTS: ").append(activeRequestCount).append(lineSeparator);
+
+        // log all of the request parameters
+        Enumeration e = request.getParameterNames();
+
+        msg.append("REQUEST PARAMETERS:").append(lineSeparator).append(lineSeparator);
+
+        while (e.hasMoreElements()) {
+            String p = (String) e.nextElement();
+
+            msg.append("PARAM: '").append(p).append("' ")
+               .append("VALUES: '");
+            String[] params = request.getParameterValues(p);
+            for (int i = 0; i < params.length; i++) {
+                msg.append("[" + params[i] + "]");
+                if (i != (params.length - 1)) {
+                    msg.append(", ");
+                }
+            }
+
+            msg.append("'").append(lineSeparator);
+        }
+
+        // log all of the header parameters
+        Enumeration e2 = request.getHeaderNames();
+
+        msg.append("HEADER PARAMETERS:").append(lineSeparator).append(lineSeparator);
+
+        while (e2.hasMoreElements()) {
+            String p = (String) e2.nextElement();
+
+            msg.append("PARAM: '").append(p).append("' ")
+               .append("VALUES: '");
+            Enumeration e3 = request.getHeaders(p);
+            while (e3.hasMoreElements()) {
+                msg.append("[" + e3.nextElement() + "]");
+                if (e3.hasMoreElements()) {
+                    msg.append(", ");
+                }
+            }
+
+            msg.append("'").append(lineSeparator);
+        }
+
+        msg.append(lineSeparator).append("SESSION ATTRIBUTES:").append(lineSeparator).append(lineSeparator);
+
+        // log all of the session attributes
+        if (session != null) {
+            // Fix bug #12139: Session can be modified while still
+            // being enumerated here
+            synchronized (session) {
+                e = session.getAttributeNames();
+                while (e.hasMoreElements()) {
+                    String p = (String) e.nextElement();
+                    msg.append("PARAM: '").append(p).append("' ")
+                       .append("VALUE: '").append(session.getAttribute(p)).append("'")
+                       .append(lineSeparator);
+                }
+            }
+        }
+
+        getLogger().debug(msg.toString());
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.Processor#process(org.apache.cocoon.environment.Environment)
+     */
+    public boolean process(Environment environment)
+    throws Exception {
+
+        if (this.disposed) {
+            throw new IllegalStateException("You cannot process a Disposed Cocoon engine.");
+        }
+
+        environment.startingProcessing();
+        final int environmentDepth = EnvironmentHelper.markEnvironment();
+        EnvironmentHelper.enterProcessor(this, this.serviceManager, environment);
+        try {
+            boolean result;
+            if (getLogger().isDebugEnabled()) {
+                ++activeRequestCount;
+                debug(environment, false);
+            }
+
+
+            if (this.requestListener != null) {
+                try {
+                    requestListener.onRequestStart(environment);
+                } catch (Exception e) {
+                    getLogger().error("Error encountered monitoring request start: " + e.getMessage());
+                }
+            }
+
+            result = this.processor.process(environment);
+
+            if (this.requestListener != null) {
+                try {
+                    requestListener.onRequestEnd(environment);
+                } catch (Exception e) {
+                    getLogger().error("Error encountered monitoring request start: " + e.getMessage());
+                }
+            }
+
+            // commit response on success
+            environment.commitResponse();
+
+            return result;
+        } catch (Exception any) {
+            if (this.requestListener != null) {
+                try {
+                    requestListener.onRequestException(environment, any);
+                } catch (Exception e) {
+                    getLogger().error("Error encountered monitoring request start: " + e.getMessage());
+                }
+            }
+            // reset response on error
+            environment.tryResetResponse();
+            throw any;
+        } finally {
+            EnvironmentHelper.leaveProcessor();
+            environment.finishingProcessing();
+            if (getLogger().isDebugEnabled()) {
+                --activeRequestCount;
+            }
+            Core.cleanup();
+
+            EnvironmentHelper.checkEnvironment(environmentDepth, getLogger());
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.Processor#buildPipeline(org.apache.cocoon.environment.Environment)
+     */
+    public InternalPipelineDescription buildPipeline(Environment environment)
+    throws Exception {
+        if (disposed) {
+            throw new IllegalStateException("You cannot process a Disposed Cocoon engine.");
+        }
+
+        try {
+            if (getLogger().isDebugEnabled()) {
+                ++activeRequestCount;
+                debug(environment, true);
+            }
+
+            return this.processor.buildPipeline(environment);
+
+        } finally {
+            if (getLogger().isDebugEnabled()) {
+                --activeRequestCount;
+            }
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.Processor#getComponentConfigurations()
+     */
+    public Configuration[] getComponentConfigurations() {
+        return null;
+    }
+
+    /**
+     * Return this (Cocoon is always at the root of the processing chain).
+     * @since 2.1.1
+     */
+    public Processor getRootProcessor() {
+        return this;
+    }
+
+    /**
+     * Accessor for active request count
+     */
+    public int getActiveRequestCount() {
+        return activeRequestCount;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.Processor#getEnvironmentHelper()
+     */
+    public org.apache.cocoon.environment.SourceResolver getSourceResolver() {
+        return this.environmentHelper;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.Processor#getContext()
+     */
+    public String getContext() {
+        return this.environmentHelper.getContext();
+    }
+
+    /**
+     * FIXME -  Do we really need this method?
+     */
+    public ServiceManager getServiceManager() {
+        return this.serviceManager;
+    }
+
+    /**
+     * @see org.apache.cocoon.Processor#getAttribute(java.lang.String)
+     */
+    public Object getAttribute(String name) {
+        return this.processorAttributes.get(name);
+    }
+
+    /**
+     * @see org.apache.cocoon.Processor#removeAttribute(java.lang.String)
+     */
+    public Object removeAttribute(String name) {
+        return this.processorAttributes.remove(name);
+    }
+
+    /**
+     * @see org.apache.cocoon.Processor#setAttribute(java.lang.String, java.lang.Object)
+     */
+    public void setAttribute(String name, Object value) {
+        this.processorAttributes.put(name, value);
+    }
+
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/Cocoon.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/CocoonAccess.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/CocoonAccess.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/CocoonAccess.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/CocoonAccess.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,25 @@
+/*
+ * Copyright 1999-2004 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;
+
+/**
+ * Accessor to the Cocoon object instance
+ */
+public class CocoonAccess {
+    protected Cocoon getCocoon() {
+        return Cocoon.instance;
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/CocoonAccess.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/CocoonTask.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/CocoonTask.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/CocoonTask.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/CocoonTask.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,287 @@
+/*
+ * Copyright 1999-2004 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;
+
+import java.io.File;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.tools.ant.AntClassLoader;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.DynamicConfigurator;
+import org.apache.tools.ant.ExitException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.types.CommandlineJava;
+import org.apache.tools.ant.types.Path;
+import org.apache.tools.ant.types.Reference;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+
+/**
+ * Ant task for running Cocoon. Allows for the embedding of Cocoon into 
+ *
+ * @author <a href="mailto:uv@upaya.co.uk">Upayavira</a>
+ * @version CVS $Id: CocoonTask.java 179055 2005-05-30 14:08:23Z cziegeler $
+ */
+public class CocoonTask extends Task implements DynamicConfigurator {
+
+    private CommandlineJava cmdl = new CommandlineJava();
+    private boolean failOnError = false;
+    private Throwable caught = null;
+
+    private String uriGroup = null;
+    private Document xconf;
+    private Element root;
+    private ElementWrapper _wrapper;
+    
+    private static final String CLASS_DELEGATE = "org.apache.cocoon.bean.helpers.AntDelegate";
+            
+    public CocoonTask() {
+        try {
+            DocumentBuilder builder =
+                DocumentBuilderFactory.newInstance().newDocumentBuilder();
+            xconf = builder.newDocument();
+            root = xconf.createElement("cocoon");
+            xconf.appendChild(root);
+            _wrapper = new ElementWrapper(root);
+            cmdl.setClassname(CLASS_DELEGATE);
+        }
+        catch (ParserConfigurationException e) {
+            throw new BuildException(e);
+        }
+    }
+    
+    /**
+     * Adds a path to the classpath.
+     *
+     * @return created classpath
+     */
+    public Path createClasspath() {
+        return cmdl.createClasspath(getProject()).createPath();
+    }
+
+    /**
+     * Classpath to use, by reference.
+     *
+     * @param r a reference to an existing classpath
+     */
+    public void setClasspathRef(Reference r) {
+        createClasspath().setRefid(r);
+    }
+
+    /**
+     * Set the classpath to be used when running the Java class
+     *
+     * @param s an Ant Path object containing the classpath.
+     */
+    public void setClasspath(Path s) {
+        createClasspath().append(s);
+    }
+
+    public void setUrigroup(String group) {
+        this.uriGroup = group;
+    }
+ 
+    /**
+     * A dynamic configurator for each element.
+     */
+    private static class ElementWrapper
+                         implements DynamicConfigurator {
+
+        private Node node;
+
+        /** Instantiate a root wrapper */
+        private ElementWrapper(Node node) {
+            this.node = node;
+        }
+
+        /** Instantiate a child wrapper */
+        private ElementWrapper(Node parent, String childName) {
+            Document document = parent.getOwnerDocument();
+            if (document == null) {
+              document = (Document)parent; // Node is the document!
+            }
+            node = document.createElement(childName);
+            parent.appendChild(node);
+        }
+
+        //
+        // interface DynamicConfigurator
+        public void setDynamicAttribute(String name, String value)
+                    throws BuildException {
+            // Never called for anything by Element wrappers
+            Element element = (Element)node;
+            element.setAttribute(name, value);
+        }
+
+        public Object createDynamicElement(String name)
+                      throws BuildException {
+            return new ElementWrapper(node, name);
+        }
+    }
+
+    public File getLibDir() throws BuildException {
+        Element root = xconf.getDocumentElement();
+        String contextDir = null;
+        if (root!=null) {
+            if (hasAttribute(root, "context-dir")){
+                contextDir = getAttributeValue(root, "context-dir");
+            }
+        }
+        if (contextDir != null) {
+            return new File(contextDir + "/WEB-INF/lib");
+        }
+        throw new BuildException("No context directory specified. Cannot find Cocoon");
+    }
+
+    private static String getAttributeValue(Node node, String attr) throws IllegalArgumentException {
+        NamedNodeMap nodes = node.getAttributes();
+        if (nodes != null) {
+            Node attribute = nodes.getNamedItem(attr);
+            if (attribute != null && attribute.getNodeValue() != null) {
+                return attribute.getNodeValue();
+            }
+        }
+        throw new IllegalArgumentException("Missing " + attr + " attribute on <" + node.getNodeName() + "> node");
+    }
+
+    private static boolean hasAttribute(Node node, String attr) {
+        NamedNodeMap nodes = node.getAttributes();
+        if (nodes != null) {
+            Node attribute = nodes.getNamedItem(attr);
+            return (attribute != null);
+        }
+        return false;
+    }
+
+    //
+    // interface DynamicConfigurator
+    public void setDynamicAttribute(String name, String value)
+                throws BuildException {
+        root.setAttribute(name, value);
+    }
+
+    public Object createDynamicElement(String name)
+                  throws BuildException {
+        return _wrapper.createDynamicElement(name);
+    }
+
+    /**
+     * Do the execution .
+     *
+     * @throws BuildException if required parameters are missing
+     */
+    public void execute() throws BuildException {
+        if (cmdl.getClasspath() == null) {
+            throw new BuildException("Could not find a classpath that points to the Cocoon classes");
+        }
+        try {
+            try {
+                execute(cmdl);
+            } catch (ExitException ex) {
+                // ignore
+            }
+        } catch (BuildException e) {
+            if (failOnError) {
+                throw e;
+            }
+            log(e.getMessage(), Project.MSG_ERR);
+        } catch (Throwable t) {
+            if (failOnError) {
+                throw new BuildException(t);
+            }
+            log(t.getMessage(), Project.MSG_ERR);
+        }
+    }
+    
+    public void execute(CommandlineJava command) throws BuildException {
+        final String classname = command.getJavaCommand().getExecutable();
+
+        AntClassLoader loader = null;
+        try {
+            if (command.getSystemProperties() != null) {
+                command.getSystemProperties().setSystem();
+            }
+
+            final Class[] param = {Class.forName("org.w3c.dom.Document"), Class.forName("java.lang.String")};
+            Class target = null;
+            if (command.getClasspath() == null) {
+                target = Class.forName(classname);
+            } else {
+                loader = new AntClassLoader(getProject().getCoreLoader(), getProject(), 
+                                            command.getClasspath(), false);
+                loader.setIsolated(true);
+                loader.setThreadContextLoader();
+                target = loader.forceLoadClass(classname);
+                Class.forName(classname, true, loader);
+            }
+            Method method = target.getMethod("process", param);
+            if (method == null) {
+                throw new BuildException("Could not find process() method in "
+                                         + classname);
+            }
+
+            run(method);
+
+            if (caught != null) {
+                throw caught;
+            }
+
+        } catch (ClassNotFoundException e) {
+            throw new BuildException("Could not find " + classname + "."
+                                     + " Make sure you have it in your"
+                                     + " classpath");
+        } catch (SecurityException e) {
+            throw e;
+        } catch (Throwable e) {
+            throw new BuildException(e);
+        } finally {
+            if (loader != null) {
+                loader.resetThreadContextLoader();
+                loader.cleanup();
+            }
+            if (command.getSystemProperties() != null) {
+                command.getSystemProperties().restoreSystem();
+            }
+        }
+    }
+
+    public void run(Method method) {
+        final Object[] argument = {xconf, uriGroup};
+        try {
+            method.invoke(null, argument);
+        } catch (InvocationTargetException e) {
+            Throwable t = e.getTargetException();
+            if (!(t instanceof InterruptedException)) {
+                caught = t;
+            } /* else { swallow, probably due to timeout } */
+        } catch (Throwable t) {
+            caught = t;
+        } finally {
+            synchronized (this) {
+                notifyAll();
+            }
+        }
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/CocoonTask.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/ConnectionResetException.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/ConnectionResetException.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/ConnectionResetException.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/ConnectionResetException.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,46 @@
+/*
+ * Copyright 1999-2004 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;
+
+/**
+ * This Exception is thrown every time a component detects an exception
+ * due to a connection reset by peer.
+ *
+ * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
+ * @version CVS $Id: ConnectionResetException.java 233343 2005-08-18 18:06:44Z sylvain $
+ */
+public class ConnectionResetException extends ProcessingException {
+
+    /**
+     * Construct a new <code>ConnectionResetException</code> instance.
+     *
+     * @param message a <code>String</code> value
+     */
+    public ConnectionResetException(String message) {
+        super(message);
+    }
+
+    /**
+     * Construct a new <code>ConnectionResetException</code> that references
+     * a parent Exception.
+     *
+     * @param message a <code>String</code> value
+     * @param t a <code>Throwable</code> value
+     */
+    public ConnectionResetException(String message, Throwable t) {
+        super(message, t);
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/ConnectionResetException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/Constants.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/Constants.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/Constants.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/Constants.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,231 @@
+/*
+ * 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;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+/**
+ * The <code>Constants</code> used throughout the core of the Cocoon engine.
+ *
+ * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
+ * @author <a href="mailto:proyal@managingpartners.com">Peter Royal</a>
+ * @version CVS $Id: Constants.java 307410 2005-10-09 12:17:33Z reinhard $
+ */
+public final class Constants {
+
+    /** Our properties are now here: */
+    private static final String PROPS_FILE = "org/apache/cocoon/cocoon.properties";
+
+    static final Properties properties;
+
+    /**
+     * Load the cocoon properties
+     */
+    static {
+        properties = new Properties();
+        try {
+            final InputStream is = Constants.class.getClassLoader().getResourceAsStream(PROPS_FILE);
+            if ( null == is ) {
+                throw new ConstantsInitializationException("Cocoon cannot find required properties from " + PROPS_FILE);
+            }
+            properties.load(is);
+        } catch (IOException ioe) {
+            throw new ConstantsInitializationException("Cocoon cannot load required properties from " + PROPS_FILE, ioe);
+        }
+
+    }
+
+    /** The name of this project. */
+    public static final String NAME = properties.getProperty("name");
+
+    /** The version of this build. */
+    public static final String VERSION = properties.getProperty("version");
+
+    /** The full name of this project. */
+    public static final String COMPLETE_NAME = properties.getProperty("fullname") + " " + VERSION;
+
+    /** The version of the configuration schema */
+    public static final String CONF_VERSION  = "2.2";
+
+    /** The year of the build */
+    public static final String YEAR = properties.getProperty("year");
+
+    /** The build information */
+    public static final String BUILD_INFO = properties.getProperty("build.info");
+
+    /**
+     * The request parameter name to reload the configuration.
+     *
+     * FIXME(GP): Isn't this Servlet specific?
+     */
+    public static final String RELOAD_PARAM = "cocoon-reload";
+
+    /**
+     * The request parameter name to add a line of the request duration.
+     *
+     * FIXME(GP): Isn't this Servlet specific?
+     */
+    public static final String SHOWTIME_PARAM = "cocoon-showtime";
+
+    /**
+     * The request parameter name to request a specific view of a resource.
+     *
+     * FIXME(GP): Isn't this Servlet specific?
+     */
+    public static final String VIEW_PARAM = "cocoon-view";
+
+    /**
+     * The request parameter name to trigger a specific action.
+     *
+     * FIXME(GP): Isn't this Servlet specific?
+     */
+    public static final String ACTION_PARAM = "cocoon-action";
+
+    /**
+     * The request parameter prefix to trigger a specific action.
+     *
+     * FIXME(GP): Isn't this Servlet specific?
+     */
+    public static final String ACTION_PARAM_PREFIX = "cocoon-action-";
+
+    /** The URI for xml namespaces */
+    public static final String XML_NAMESPACE_URI = "http://www.w3.org/XML/1998/namespace";
+
+    /**
+     * Mime-type for the link view
+     *
+     * FIXME(GP): Isn't this Environment specific?
+     */
+    public static final String LINK_CONTENT_TYPE = "application/x-cocoon-links";
+
+    /**
+     * Name of the request value for the link view
+     *
+     * FIXME(GP): Isn't this Environment specific?
+     */
+    public static final String LINK_VIEW = "links";
+
+    /**
+     * Key of the Map of index translation table.
+     * <p>Presence of this Map in the ObjectModel indicates to the Sitemap that link
+     * translation mode has been requested by the environment. Sitemap adds LinkTranslator
+     * transformer to the pipeline, which replaces all the links in the input document with
+     * the links from this translation table.
+     * <p>
+     * TODO(VG): Move this declaration to ObjectModelHelper
+     * comment found at ObjectModelHelper(JH):
+     * LINK_OBJECT should also be moved to CommandLineEnvironment
+     */
+    public static final String LINK_OBJECT = "link";
+
+    /**
+     * Key of the List for collecting links.
+     * <p>Presence of this Map in the ObjectModel indicates to the Sitemap that link
+     * gathering mode has been requested by the environment. Sitemap adds LinkGatherer
+     * transformer to the pipeline, which gathers the links in the input document into
+     * this List.
+     * <p>
+     */
+    public static final String LINK_COLLECTION_OBJECT = "link-collection";
+
+    /**
+     * The name of a <code>NotifyingObject</code> in the so called objectModel <code>Map</code>.
+     */
+    public static final String NOTIFYING_OBJECT = "notifying-object";
+
+    /**
+     * The default URI to be used when a URI requested refers to
+     * a directory, e.g. http://localhost:8080/site/
+     */
+    public static final String INDEX_URI = "index";
+
+    /**
+     * The directory to use as context root.
+     */
+    public static final String DEFAULT_CONTEXT_DIR = "./webapp";
+
+    /**
+     * The diretory to use to use for the generated output.
+     */
+    public static final String DEFAULT_DEST_DIR = "./site";
+
+    /**
+     * The diretory to use for generated files.
+     */
+    public static final String DEFAULT_WORK_DIR = "./work";
+
+    /**
+     * How a default configuration file is named.
+     */
+    public static final String DEFAULT_CONF_FILE = "cocoon.xconf";
+
+    /** The namespace URI for the Error/Exception XML */
+    public static final String ERROR_NAMESPACE_URI = "http://apache.org/cocoon/error/2.1";
+
+    /** The namespace prefix for the Error/Exception XML */
+    public static final String ERROR_NAMESPACE_PREFIX = "error";
+
+    /** Application <code>Context</code> Key for the environmental Context */
+    public static final String CONTEXT_ENVIRONMENT_CONTEXT = "environment-context";
+
+    /** Application <code>Context</code> Key for the global classloader */
+    public static final String CONTEXT_CLASS_LOADER = "class-loader";
+
+    /** Application <code>Context</code> Key for the work directory path */
+    public static final String CONTEXT_WORK_DIR = "work-directory";
+
+    /** Application <code>Context</code> Key for the upload directory path */
+    public static final String CONTEXT_UPLOAD_DIR = "upload-directory";
+
+    /** Application <code>Context</code> Key for the cache directory path */
+    public static final String CONTEXT_CACHE_DIR = "cache-directory";
+
+    /** Application <code>Context</code> Key for the current classpath */
+    public static final String CONTEXT_CLASSPATH = "classpath";
+
+
+    /** Application <code>Context</code> key for the current environment URI */
+    public static final String CONTEXT_ENV_URI = "env-uri";
+
+    /** Application <code>Context</code> key for the current environment prefix */
+    public static final String CONTEXT_ENV_PREFIX = "env-prefix";
+
+    /** Application <code>Context</code> key for the current environment helper */
+    public static final String CONTEXT_ENV_HELPER = "env-helper";
+
+    /** Application <code>Context</code> key prefix for the current sitemap virtual components */
+    public static final String CONTEXT_VPC_PREFIX = "vpc-";
+
+    /** Path to the wiring.xml relative to the context root directory */
+    public static final String WIRING = "wiring.xml";    
+    
+    public static final String BLOCK_META_DIR = "COB-INF";
+    
+    /**
+     * Application <code>Context</code> Key for the URL to the configuration file
+     * (usually named cocoon.xconf)
+     * @deprecated Use {@link org.apache.cocoon.core.Settings#getConfiguration()}.
+     */
+    public static final String CONTEXT_CONFIG_URL = "config-url";
+
+    /** Application <code>Context</code> Key for the default encoding.
+     * @deprecated Use {@link org.apache.cocoon.core.Settings#getFormEncoding()}. */
+    public static final String CONTEXT_DEFAULT_ENCODING = "default-encoding";
+
+    
+}
\ No newline at end of file

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/Constants.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/ConstantsInitializationException.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/ConstantsInitializationException.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/ConstantsInitializationException.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/ConstantsInitializationException.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,31 @@
+/*
+ * 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;
+
+import org.apache.avalon.framework.CascadingRuntimeException;
+
+public final class ConstantsInitializationException extends CascadingRuntimeException
+{
+    public ConstantsInitializationException(String message)
+    {
+        super(message, null);
+    }
+
+    public ConstantsInitializationException(String message, Throwable cause)
+    {
+        super(message, cause);
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/ConstantsInitializationException.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message