bloritsch 01/10/12 06:44:49
Modified: src/META-INF/services
org.apache.batik.util.ParsedURLProtocolHandler
src/org/apache/cocoon/components/url
ParsedContextURLProtocolHandler.java
Added: src/org/apache/cocoon/components/url
ParsedResourceURLProtocolHandler.java
Log:
Add support for the "resource://" protocol in Batik.
Revision Changes Path
1.2 +2 -1
xml-cocoon2/src/META-INF/services/org.apache.batik.util.ParsedURLProtocolHandler
Index: org.apache.batik.util.ParsedURLProtocolHandler
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/META-INF/services/org.apache.batik.util.ParsedURLProtocolHandler,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- org.apache.batik.util.ParsedURLProtocolHandler 2001/10/11 14:34:44
1.1
+++ org.apache.batik.util.ParsedURLProtocolHandler 2001/10/12 13:44:49
1.2
@@ -1 +1,2 @@
-org.apache.cocoon.components.url.ParsedContextURLProtocolHandler #context://
urls
+org.apache.cocoon.components.url.ParsedContextURLProtocolHandler
#context:// urls
+org.apache.cocoon.components.url.ParsedResourceURLProtocolHandler
#resource:// urls
1.3 +2 -2
xml-cocoon2/src/org/apache/cocoon/components/url/ParsedContextURLProtocolHandler.java
Index: ParsedContextURLProtocolHandler.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/components/url/ParsedContextURLProtocolHandler.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ParsedContextURLProtocolHandler.java 2001/10/11 19:18:29 1.2
+++ ParsedContextURLProtocolHandler.java 2001/10/12 13:44:49 1.3
@@ -11,8 +11,8 @@
import org.apache.batik.util.ParsedURL;
import org.apache.batik.util.ParsedURLData;
import org.apache.cocoon.environment.Context;
+
import java.net.MalformedURLException;
-import java.net.URL;
/**
@@ -22,7 +22,7 @@
* an uncontrolled manner (as far as Cocoon is concerned).
*
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
- * @version $Id: ParsedContextURLProtocolHandler.java,v 1.2 2001/10/11
19:18:29 bloritsch Exp $
+ * @version $Id: ParsedContextURLProtocolHandler.java,v 1.3 2001/10/12
13:44:49 bloritsch Exp $
*/
public class ParsedContextURLProtocolHandler extends
AbstractParsedURLProtocolHandler {
private static Context context = null;
1.1
xml-cocoon2/src/org/apache/cocoon/components/url/ParsedResourceURLProtocolHandler.java
Index: ParsedResourceURLProtocolHandler.java
===================================================================
/*****************************************************************************
* Copyright (C) The Apache Software Foundation. All rights reserved. *
* ------------------------------------------------------------------------- *
* This software is published under the terms of the Apache Software License *
* version 1.1, a copy of which has been included with this distribution in *
* the LICENSE file. *
*****************************************************************************/
package org.apache.cocoon.components.url;
import org.apache.batik.util.AbstractParsedURLProtocolHandler;
import org.apache.batik.util.ParsedURL;
import org.apache.batik.util.ParsedURLData;
/**
* Provide an extension to Batik to handle the "resource:" protocol. This
class
* uses the <code>Thread.getContextClassLoader()</code> classloader to get
resources.
* It is safe to use this URL with multiple Cocoon webapps running.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
* @version $Id: ParsedResourceURLProtocolHandler.java,v 1.1 2001/10/12
13:44:49 bloritsch Exp $
*/
public class ParsedResourceURLProtocolHandler extends
AbstractParsedURLProtocolHandler {
/**
* Create a new instance, this doesn't do much beyond register the type of
* protocol we handle.
*/
public ParsedResourceURLProtocolHandler() {
super("resource");
}
/**
* Getbase.getPath() the ParsedURLData for the context. Absolute URIs
are specified like
* "resource://".
*/
public ParsedURLData parseURL(String uri) {
ParsedURLData urldata = null;
String path = uri.substring("resource:/".length());
urldata = new
ParsedURLData(Thread.currentThread().getContextClassLoader().getResource(path));
if ("file".equals(urldata.protocol)) {
urldata.host = null;
urldata.port = -1;
} else if (null == urldata.host) {
urldata.port = -1;
} else if (urldata.port < 0) {
urldata.host = null;
}
return urldata;
}
/**
* The build the relative URL. Relative URIs are specified like
"resource:".
*/
public ParsedURLData parseURL(ParsedURL base, String uri) {
StringBuffer newURI = new StringBuffer("resource://");
newURI.append(base.getPath());
if ( !newURI.toString().endsWith("/") ) {
newURI.append("/");
}
newURI.append(uri.substring("resource:".length()));
return this.parseURL(newURI.toString());
}
}
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]