cziegeler 2003/10/19 08:58:15
Modified: lib jars.xml
src/java/org/apache/cocoon cocoon.roles
src/java/org/apache/cocoon/components
CocoonComponentManager.java
Added: src/java/org/apache/cocoon/components/source
CocoonSourceResolver.java
Log:
Removing SourceResolver hack from the CocoonComponentManager
by separating this into an own class.
Revision Changes Path
1.114 +13 -2 cocoon-2.2/lib/jars.xml
Index: jars.xml
===================================================================
RCS file: /home/cvs/cocoon-2.2/lib/jars.xml,v
retrieving revision 1.113
retrieving revision 1.114
diff -u -r1.113 -r1.114
--- jars.xml 15 Oct 2003 09:12:19 -0000 1.113
+++ jars.xml 19 Oct 2003 15:58:15 -0000 1.114
@@ -194,7 +194,18 @@
support high level server development.
</description>
<used-by>Cocoon</used-by>
- <lib>core/avalon-framework-4.1.4.jar</lib>
+ <lib>core/avalon-framework-api-4.1.5.jar</lib>
+ <homepage>http://avalon.apache.org/framework/</homepage>
+ </file>
+
+ <file>
+ <title>Avalon Framework - Implementation</title>
+ <description>
+ Part of avalon, it is a set of classes and patterns that
+ support high level server development.
+ </description>
+ <used-by>Cocoon</used-by>
+ <lib>core/avalon-framework-impl-4.1.5.jar</lib>
<homepage>http://avalon.apache.org/framework/</homepage>
</file>
1.11 +4 -1 cocoon-2.2/src/java/org/apache/cocoon/cocoon.roles
Index: cocoon.roles
===================================================================
RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/cocoon.roles,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- cocoon.roles 5 Sep 2003 11:40:42 -0000 1.10
+++ cocoon.roles 19 Oct 2003 15:58:15 -0000 1.11
@@ -19,9 +19,12 @@
default-class="org.apache.avalon.excalibur.component.ExcaliburComponentSelector">
</role>
+ <!-- This is the source resolver for Cocoon - do not change this!
+ If you want to use your own source resolver, define a
+ component for the role
org.apache.excalibur.source.SourceResolver/Cocoon -->
<role name="org.apache.excalibur.source.SourceResolver"
shorthand="source-resolver"
- default-class="org.apache.excalibur.source.impl.SourceResolverImpl"/>
+
default-class="org.apache.cocoon.components.source.CocoonSourceResolver"/>
<!-- The entity resolver used by most parsers -->
<role name="org.apache.excalibur.xml.EntityResolver"
1.1
cocoon-2.2/src/java/org/apache/cocoon/components/source/CocoonSourceResolver.java
Index: CocoonSourceResolver.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.components.source;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.Map;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.cocoon.components.CocoonComponentManager;
import org.apache.cocoon.environment.Environment;
import org.apache.cocoon.environment.SourceResolver;
import org.apache.excalibur.source.Source;
import org.apache.excalibur.source.SourceException;
import org.apache.excalibur.source.impl.SourceResolverImpl;
/**
* This is the default implementation of the [EMAIL PROTECTED]
SourceResolver} for
* Cocoon.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
* @version CVS $Id: CocoonSourceResolver.java,v 1.1 2003/10/19 15:58:15
cziegeler Exp $
*/
public class CocoonSourceResolver
extends SourceResolverImpl
implements SourceResolver {
/** A (optional) custom source resolver */
protected org.apache.excalibur.source.SourceResolver customResolver;
/* (non-Javadoc)
* @see
org.apache.excalibur.source.SourceResolver#resolveURI(java.lang.String,
java.lang.String, java.util.Map)
*/
public Source resolveURI(String location, String baseURI, Map parameters)
throws MalformedURLException, IOException, SourceException {
if ( baseURI == null ) {
// TODO (CZ) Change this!
final Environment env =
CocoonComponentManager.getCurrentEnvironment();
if ( env != null ) {
baseURI = env.getContext();
}
}
if ( this.customResolver != null ) {
return this.customResolver.resolveURI(location, baseURI,
parameters);
} else {
return super.resolveURI(location, baseURI, parameters);
}
}
/* (non-Javadoc)
* @see
org.apache.excalibur.source.SourceResolver#resolveURI(java.lang.String)
*/
public Source resolveURI(String location)
throws MalformedURLException, IOException, SourceException {
return this.resolveURI(location, null, null);
}
/* (non-Javadoc)
* @see
org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
*/
public void service(ServiceManager manager) throws ServiceException {
super.service(manager);
if (
manager.hasService(org.apache.excalibur.source.SourceResolver.ROLE+"/Cocoon")) {
this.customResolver = (org.apache.excalibur.source.SourceResolver)
manager.lookup(org.apache.excalibur.source.SourceResolver.ROLE+"/Cocoon");
}
}
/* (non-Javadoc)
* @see org.apache.avalon.framework.activity.Disposable#dispose()
*/
public void dispose() {
if ( this.m_manager != null ) {
this.m_manager.release( this.customResolver );
this.customResolver = null;
}
super.dispose();
}
/* (non-Javadoc)
* @see
org.apache.excalibur.source.SourceResolver#release(org.apache.excalibur.source.Source)
*/
public void release(Source source) {
if ( this.customResolver != null ) {
this.customResolver.release( source );
} else {
super.release(source);
}
}
}
1.20 +1 -44
cocoon-2.2/src/java/org/apache/cocoon/components/CocoonComponentManager.java
Index: CocoonComponentManager.java
===================================================================
RCS file:
/home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/CocoonComponentManager.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- CocoonComponentManager.java 17 Oct 2003 17:49:24 -0000 1.19
+++ CocoonComponentManager.java 19 Oct 2003 15:58:15 -0000 1.20
@@ -87,7 +87,6 @@
*/
public final class CocoonComponentManager
extends ExcaliburComponentManager
-implements SourceResolver
{
/** The key used to store the current process environment */
@@ -305,12 +304,6 @@
throw new ServiceException( role, message );
}
- if ( role.equals(SourceResolver.ROLE) ) {
- if ( null == this.sourceResolver ) {
- this.sourceResolver = (SourceResolver) super.lookup( role );
- }
- return this;
- }
final EnvironmentStack stack =
(EnvironmentStack)environmentStack.get();
if ( null != stack && !stack.empty()) {
@@ -414,9 +407,6 @@
|| component instanceof GlobalRequestLifecycleComponent) {
return;
}
- if ( component == this ) {
- return;
- }
super.release( component);
}
@@ -494,39 +484,6 @@
}
super.dispose();
}
-
- /**
- * Get a <code>Source</code> object.
- */
- public Source resolveURI(final String location)
- throws MalformedURLException, IOException, SourceException {
- return this.resolveURI(location, null, null);
- }
-
- /**
- * Get a <code>Source</code> object.
- */
- public Source resolveURI(final String location,
- String baseURI,
- final Map parameters)
- throws MalformedURLException, IOException, SourceException {
- if (baseURI == null) {
- final EnvironmentStack stack =
(EnvironmentStack)environmentStack.get();
- if ( null != stack && !stack.empty()) {
- final Object[] objects = (Object[])stack.getCurrent();
- baseURI = ((Environment)objects[0]).getContext();
- }
- }
- return this.sourceResolver.resolveURI(location, baseURI, parameters);
- }
-
- /**
- * Releases a resolved resource
- */
- public void release( final Source source ) {
- this.sourceResolver.release( source );
- }
-
/* (non-Javadoc)
* @see
org.apache.avalon.excalibur.component.ExcaliburComponentManager#addComponent(java.lang.String,
java.lang.Class, org.apache.avalon.framework.configuration.Configuration)