aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMehdi Houshmand <mehdi@apache.org>2012-09-19 15:37:57 +0000
committerMehdi Houshmand <mehdi@apache.org>2012-09-19 15:37:57 +0000
commitc9cbf7e0a418fb7735f6d4a42632b867f3dab36c (patch)
tree33a6758d61d589fe3a6163edf8e3e0dbd55b0022 /src
parentc5a2f0959ec4116022f8e87cd9114b7b152a6c98 (diff)
downloadxmlgraphics-fop-c9cbf7e0a418fb7735f6d4a42632b867f3dab36c.tar.gz
xmlgraphics-fop-c9cbf7e0a418fb7735f6d4a42632b867f3dab36c.zip
Moved the I/O interfaces to XGC and updated code with new resolution mechanism
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_XGC_URI_Resolution@1387645 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/java/org/apache/fop/afp/AFPStreamer.java3
-rw-r--r--src/java/org/apache/fop/apps/EnvironmentProfile.java7
-rw-r--r--src/java/org/apache/fop/apps/EnvironmentalProfileFactory.java21
-rw-r--r--src/java/org/apache/fop/apps/FOUserAgent.java32
-rw-r--r--src/java/org/apache/fop/apps/FopConfParser.java2
-rw-r--r--src/java/org/apache/fop/apps/FopFactory.java6
-rw-r--r--src/java/org/apache/fop/apps/FopFactoryBuilder.java7
-rw-r--r--src/java/org/apache/fop/apps/FopFactoryConfig.java10
-rw-r--r--src/java/org/apache/fop/apps/io/InternalResourceResolver.java4
-rw-r--r--src/java/org/apache/fop/apps/io/Resource.java59
-rw-r--r--src/java/org/apache/fop/apps/io/ResourceResolver.java51
-rw-r--r--src/java/org/apache/fop/apps/io/ResourceResolverFactory.java118
-rw-r--r--src/java/org/apache/fop/apps/io/TempResourceResolver.java48
-rw-r--r--src/java/org/apache/fop/apps/io/TempResourceURIGenerator.java57
-rw-r--r--src/java/org/apache/fop/area/CachedRenderPagesModel.java3
-rw-r--r--src/java/org/apache/fop/fonts/FontManagerConfigurator.java3
-rw-r--r--src/java/org/apache/fop/image/loader/batik/PreloaderSVG.java5
-rw-r--r--src/java/org/apache/fop/image/loader/batik/PreloaderWMF.java5
-rw-r--r--src/java/org/apache/fop/render/ps/PSDocumentHandler.java2
-rw-r--r--src/java/org/apache/fop/servlet/FopServlet.java5
20 files changed, 141 insertions, 307 deletions
diff --git a/src/java/org/apache/fop/afp/AFPStreamer.java b/src/java/org/apache/fop/afp/AFPStreamer.java
index fb2b282f6..5e6b5a79e 100644
--- a/src/java/org/apache/fop/afp/AFPStreamer.java
+++ b/src/java/org/apache/fop/afp/AFPStreamer.java
@@ -32,10 +32,11 @@ import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.xmlgraphics.io.TempResourceURIGenerator;
+
import org.apache.fop.afp.modca.ResourceGroup;
import org.apache.fop.afp.modca.StreamedResourceGroup;
import org.apache.fop.apps.io.InternalResourceResolver;
-import org.apache.fop.apps.io.TempResourceURIGenerator;
/**
* Manages the streaming of the AFP output
diff --git a/src/java/org/apache/fop/apps/EnvironmentProfile.java b/src/java/org/apache/fop/apps/EnvironmentProfile.java
index c964120e3..1a585353e 100644
--- a/src/java/org/apache/fop/apps/EnvironmentProfile.java
+++ b/src/java/org/apache/fop/apps/EnvironmentProfile.java
@@ -21,7 +21,9 @@ package org.apache.fop.apps;
import java.net.URI;
-import org.apache.fop.apps.io.ResourceResolver;
+import org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext.FallbackResolver;
+import org.apache.xmlgraphics.io.ResourceResolver;
+
import org.apache.fop.fonts.FontManager;
/**
@@ -52,4 +54,7 @@ public interface EnvironmentProfile {
* @return the default base URI
*/
URI getDefaultBaseURI();
+
+ /** @see FopFactoryConfig#getFallbackResolver() */
+ FallbackResolver getFallbackResolver();
}
diff --git a/src/java/org/apache/fop/apps/EnvironmentalProfileFactory.java b/src/java/org/apache/fop/apps/EnvironmentalProfileFactory.java
index 9ba7632d2..922ecff4b 100644
--- a/src/java/org/apache/fop/apps/EnvironmentalProfileFactory.java
+++ b/src/java/org/apache/fop/apps/EnvironmentalProfileFactory.java
@@ -21,8 +21,12 @@ package org.apache.fop.apps;
import java.net.URI;
+import org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext.FallbackResolver;
+import org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext.RestrictedFallbackResolver;
+import org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext.UnrestrictedFallbackResolver;
+import org.apache.xmlgraphics.io.ResourceResolver;
+
import org.apache.fop.apps.io.InternalResourceResolver;
-import org.apache.fop.apps.io.ResourceResolver;
import org.apache.fop.apps.io.ResourceResolverFactory;
import org.apache.fop.fonts.FontCacheManager;
import org.apache.fop.fonts.FontCacheManagerFactory;
@@ -51,7 +55,8 @@ public final class EnvironmentalProfileFactory {
return new Profile(defaultBaseUri, resourceResolver,
createFontManager(defaultBaseUri, resourceResolver,
FontDetectorFactory.createDefault(),
- FontCacheManagerFactory.createDefault()));
+ FontCacheManagerFactory.createDefault()),
+ new UnrestrictedFallbackResolver());
}
/**
@@ -67,7 +72,8 @@ public final class EnvironmentalProfileFactory {
return new Profile(defaultBaseUri, resourceResolver,
createFontManager(defaultBaseUri, resourceResolver,
FontDetectorFactory.createDisabled(),
- FontCacheManagerFactory.createDisabled()));
+ FontCacheManagerFactory.createDisabled()),
+ new RestrictedFallbackResolver());
}
private static final class Profile implements EnvironmentProfile {
@@ -78,8 +84,10 @@ public final class EnvironmentalProfileFactory {
private final URI defaultBaseURI;
+ private final FallbackResolver fallbackResolver;
+
private Profile(URI defaultBaseURI, ResourceResolver resourceResolver,
- FontManager fontManager) {
+ FontManager fontManager, FallbackResolver fallbackResolver) {
if (defaultBaseURI == null) {
throw new IllegalArgumentException("Default base URI must not be null");
}
@@ -92,6 +100,7 @@ public final class EnvironmentalProfileFactory {
this.defaultBaseURI = defaultBaseURI;
this.resourceResolver = resourceResolver;
this.fontManager = fontManager;
+ this.fallbackResolver = fallbackResolver;
}
public ResourceResolver getResourceResolver() {
@@ -105,6 +114,10 @@ public final class EnvironmentalProfileFactory {
public URI getDefaultBaseURI() {
return defaultBaseURI;
}
+
+ public FallbackResolver getFallbackResolver() {
+ return fallbackResolver;
+ }
}
private static FontManager createFontManager(URI defaultBaseUri, ResourceResolver resourceResolver,
diff --git a/src/java/org/apache/fop/apps/FOUserAgent.java b/src/java/org/apache/fop/apps/FOUserAgent.java
index 0ed5b7228..68064343e 100644
--- a/src/java/org/apache/fop/apps/FOUserAgent.java
+++ b/src/java/org/apache/fop/apps/FOUserAgent.java
@@ -131,21 +131,7 @@ public class FOUserAgent {
/** Set of keywords applicable to this document. */
protected String keywords = null;
- private ImageSessionContext imageSessionContext = new AbstractImageSessionContext() {
-
- public ImageContext getParentContext() {
- return factory;
- }
-
- public float getTargetResolution() {
- return FOUserAgent.this.getTargetResolution();
- }
-
- public Source resolveURI(String uri) {
- return FOUserAgent.this.resolveURI(uri);
- }
-
- };
+ private final ImageSessionContext imageSessionContext;
/**
* Main constructor. <b>This constructor should not be called directly. Please use the
@@ -154,11 +140,25 @@ public class FOUserAgent {
* @param resourceResolver the resolver used to acquire resources
* @see org.apache.fop.apps.FopFactory
*/
- FOUserAgent(FopFactory factory, InternalResourceResolver resourceResolver) {
+ FOUserAgent(final FopFactory factory, InternalResourceResolver resourceResolver) {
this.factory = factory;
this.resourceResolver = resourceResolver;
setTargetResolution(factory.getTargetResolution());
setAccessibility(factory.isAccessibilityEnabled());
+ imageSessionContext = new AbstractImageSessionContext(factory.getFallbackResolver()) {
+
+ public ImageContext getParentContext() {
+ return factory;
+ }
+
+ public float getTargetResolution() {
+ return FOUserAgent.this.getTargetResolution();
+ }
+
+ public Source resolveURI(String uri) {
+ return FOUserAgent.this.resolveURI(uri);
+ }
+ };
}
/**
diff --git a/src/java/org/apache/fop/apps/FopConfParser.java b/src/java/org/apache/fop/apps/FopConfParser.java
index c6e3dbd19..b4918ef30 100644
--- a/src/java/org/apache/fop/apps/FopConfParser.java
+++ b/src/java/org/apache/fop/apps/FopConfParser.java
@@ -39,9 +39,9 @@ import org.apache.commons.logging.LogFactory;
import org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry;
import org.apache.xmlgraphics.image.loader.util.Penalty;
+import org.apache.xmlgraphics.io.ResourceResolver;
import org.apache.fop.apps.io.InternalResourceResolver;
-import org.apache.fop.apps.io.ResourceResolver;
import org.apache.fop.apps.io.ResourceResolverFactory;
import org.apache.fop.fonts.FontManagerConfigurator;
import org.apache.fop.hyphenation.HyphenationTreeCache;
diff --git a/src/java/org/apache/fop/apps/FopFactory.java b/src/java/org/apache/fop/apps/FopFactory.java
index 80c957f9f..6bc744b7e 100644
--- a/src/java/org/apache/fop/apps/FopFactory.java
+++ b/src/java/org/apache/fop/apps/FopFactory.java
@@ -36,6 +36,7 @@ import org.apache.commons.logging.LogFactory;
import org.apache.xmlgraphics.image.loader.ImageContext;
import org.apache.xmlgraphics.image.loader.ImageManager;
+import org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext.FallbackResolver;
import org.apache.xmlgraphics.util.UnitConv;
import org.apache.fop.apps.io.InternalResourceResolver;
@@ -418,6 +419,11 @@ public final class FopFactory implements ImageContext {
return config.getFontManager();
}
+ /** @see FopFactoryConfig#getFallbackResolver() */
+ FallbackResolver getFallbackResolver() {
+ return config.getFallbackResolver();
+ }
+
/**
* Returns the color space cache for this instance.
* <p>
diff --git a/src/java/org/apache/fop/apps/FopFactoryBuilder.java b/src/java/org/apache/fop/apps/FopFactoryBuilder.java
index cfc47496c..b1fd5e979 100644
--- a/src/java/org/apache/fop/apps/FopFactoryBuilder.java
+++ b/src/java/org/apache/fop/apps/FopFactoryBuilder.java
@@ -30,8 +30,9 @@ import org.apache.avalon.framework.configuration.Configuration;
import org.apache.xmlgraphics.image.loader.ImageContext;
import org.apache.xmlgraphics.image.loader.ImageManager;
+import org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext.FallbackResolver;
+import org.apache.xmlgraphics.io.ResourceResolver;
-import org.apache.fop.apps.io.ResourceResolver;
import org.apache.fop.apps.io.ResourceResolverFactory;
import org.apache.fop.fonts.FontManager;
import org.apache.fop.layoutmgr.LayoutManagerMaker;
@@ -464,6 +465,10 @@ public final class FopFactoryBuilder {
public Map<String, String> getHyphenationPatternNames() {
return hyphPatNames;
}
+
+ public FallbackResolver getFallbackResolver() {
+ return enviro.getFallbackResolver();
+ }
}
private interface FopFactoryConfigBuilder {
diff --git a/src/java/org/apache/fop/apps/FopFactoryConfig.java b/src/java/org/apache/fop/apps/FopFactoryConfig.java
index 60e8d98e7..d3ea3127f 100644
--- a/src/java/org/apache/fop/apps/FopFactoryConfig.java
+++ b/src/java/org/apache/fop/apps/FopFactoryConfig.java
@@ -26,8 +26,9 @@ import java.util.Set;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.xmlgraphics.image.loader.ImageManager;
+import org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext.FallbackResolver;
+import org.apache.xmlgraphics.io.ResourceResolver;
-import org.apache.fop.apps.io.ResourceResolver;
import org.apache.fop.fonts.FontManager;
import org.apache.fop.layoutmgr.LayoutManagerMaker;
@@ -163,4 +164,11 @@ public interface FopFactoryConfig {
/** @return the hyphenation pattern names */
Map<String, String> getHyphenationPatternNames();
+
+ /**
+ * Controls the mechanisms that are used in the event that {@link javax.xml.transform.Source}
+ * used for resources couldn't be read.
+ * @return the fallback resolver
+ */
+ FallbackResolver getFallbackResolver();
}
diff --git a/src/java/org/apache/fop/apps/io/InternalResourceResolver.java b/src/java/org/apache/fop/apps/io/InternalResourceResolver.java
index 4d664c8f5..af0a26478 100644
--- a/src/java/org/apache/fop/apps/io/InternalResourceResolver.java
+++ b/src/java/org/apache/fop/apps/io/InternalResourceResolver.java
@@ -29,12 +29,14 @@ import javax.xml.transform.Source;
import javax.xml.transform.TransformerException;
import javax.xml.transform.stream.StreamSource;
+import org.apache.xmlgraphics.io.Resource;
+import org.apache.xmlgraphics.io.ResourceResolver;
import org.apache.xmlgraphics.util.uri.DataURIResolver;
/**
* This object holds the base URI from which to resolve URIs against as well as the resolver for
* resource acquisition. It also does some URI sanitization of common URI syntactical errors. This
- * class takes in a {@link org.apache.fop.apps.io.ResourceResolver} and delegates all relevant
+ * class takes in a {@link org.apache.xmlgraphics.io.ResourceResolver} and delegates all relevant
* URIs to it.
*/
public class InternalResourceResolver {
diff --git a/src/java/org/apache/fop/apps/io/Resource.java b/src/java/org/apache/fop/apps/io/Resource.java
deleted file mode 100644
index 0a8b8c22a..000000000
--- a/src/java/org/apache/fop/apps/io/Resource.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-/* $Id$ */
-
-package org.apache.fop.apps.io;
-
-import java.io.FilterInputStream;
-import java.io.InputStream;
-
-/**
- * This class represents a resolved resource. The type property is used by FOP to identify the resource
- * content.
- *
- */
-public class Resource extends FilterInputStream {
-
- private final String type;
-
- /**
- * @param type resource type
- * @param inputStream input stream of the resource
- */
- public Resource(String type, InputStream inputStream) {
- super(inputStream);
- this.type = type;
- }
-
- /**
- * Constructs a resource of 'unknown' type.
- *
- * @param inputStream input stream of the resource
- */
- public Resource(InputStream inputStream) {
- this("unknown", inputStream);
- }
-
- /**
- * @return the resource type
- */
- public String getType() {
- return this.type;
- }
-
-}
diff --git a/src/java/org/apache/fop/apps/io/ResourceResolver.java b/src/java/org/apache/fop/apps/io/ResourceResolver.java
deleted file mode 100644
index a3a9cf0c3..000000000
--- a/src/java/org/apache/fop/apps/io/ResourceResolver.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-/* $Id$ */
-
-package org.apache.fop.apps.io;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.net.URI;
-
-/**
- * Implementations of this resource resolver allow FOP users to control the URI resolution
- * mechanism. All resource and output stream acquisition goes through this when its implementation
- * is given to the {@link org.apache.fop.apps.EnvironmentProfile}.
- */
-public interface ResourceResolver {
-
- /**
- * Get a resource given the URI pointing to said resource.
- *
- * @param uri the resource URI
- * @return the resource
- * @throws IOException if an I/O error occured during resource acquisition
- */
- Resource getResource(URI uri) throws IOException;
-
- /**
- * Gets an output stream of a given URI.
- *
- * @param uri the output stream URI
- * @return the output stream
- * @throws IOException if an I/O error occured while creating an output stream
- */
- OutputStream getOutputStream(URI uri) throws IOException;
-
-}
diff --git a/src/java/org/apache/fop/apps/io/ResourceResolverFactory.java b/src/java/org/apache/fop/apps/io/ResourceResolverFactory.java
index 72eac456d..cdc9438b9 100644
--- a/src/java/org/apache/fop/apps/io/ResourceResolverFactory.java
+++ b/src/java/org/apache/fop/apps/io/ResourceResolverFactory.java
@@ -28,6 +28,11 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import org.apache.xmlgraphics.io.Resource;
+import org.apache.xmlgraphics.io.ResourceResolver;
+import org.apache.xmlgraphics.io.TempResourceResolver;
+import org.apache.xmlgraphics.io.TempResourceURIGenerator;
+
/**
* A factory class for {@link ResourceResolver}s.
*/
@@ -70,10 +75,10 @@ public final class ResourceResolverFactory {
}
/**
- * Creates a temporary-resource-schema aware resource resolver. Temporary resource URIs are
+ * Creates a temporary-resource-scheme aware resource resolver. Temporary resource URIs are
* created by {@link TempResourceURIGenerator}.
*
- * @param tempResourceResolver the temporary-resource-schema resolver to use
+ * @param tempResourceResolver the temporary-resource-scheme resolver to use
* @param defaultResourceResolver the default resource resolver to use
* @return the ressource resolver
*/
@@ -84,17 +89,17 @@ public final class ResourceResolverFactory {
}
/**
- * This creates the builder class for binding URI schemas to implementations of
- * {@link ResourceResolver}. This allows users to define their own URI schemas such that they
+ * This creates the builder class for binding URI schemes to implementations of
+ * {@link ResourceResolver}. This allows users to define their own URI schemes such that they
* have finer control over the acquisition of resources.
*
* @param defaultResolver the default resource resolver that should be used in the event that
- * none of the other registered resolvers match the schema
- * @return the schema aware {@link ResourceResolver} builder
+ * none of the other registered resolvers match the scheme
+ * @return the scheme aware {@link ResourceResolver} builder
*/
- public static SchemaAwareResourceResolverBuilder createSchemaAwareResourceResolverBuilder(
+ public static SchemeAwareResourceResolverBuilder createSchemeAwareResourceResolverBuilder(
ResourceResolver defaultResolver) {
- return new SchemaAwareResourceResolverBuilderImpl(defaultResolver);
+ return new SchemeAwareResourceResolverBuilderImpl(defaultResolver);
}
private static final class DefaultResourceResolver implements ResourceResolver {
@@ -132,13 +137,13 @@ public final class ResourceResolverFactory {
this.defaultResourceResolver = defaultResourceResolver;
}
- private static boolean isTempUri(URI uri) {
- return TempResourceURIGenerator.isTempUri(uri);
+ private static boolean isTempURI(URI uri) {
+ return TempResourceURIGenerator.isTempURI(uri);
}
/** {@inheritDoc} */
public Resource getResource(URI uri) throws IOException {
- if (isTempUri(uri)) {
+ if (isTempURI(uri)) {
return tempResourceResolver.getResource(uri.getPath());
} else {
return defaultResourceResolver.getResource(uri);
@@ -147,7 +152,7 @@ public final class ResourceResolverFactory {
/** {@inheritDoc} */
public OutputStream getOutputStream(URI uri) throws IOException {
- if (isTempUri(uri)) {
+ if (isTempURI(uri)) {
return tempResourceResolver.getOutputStream(uri.getPath());
} else {
return defaultResourceResolver.getOutputStream(uri);
@@ -188,23 +193,23 @@ public final class ResourceResolverFactory {
}
}
- private static final class SchemaAwareResourceResolver implements ResourceResolver {
+ private static final class SchemeAwareResourceResolver implements ResourceResolver {
- private final Map<String, ResourceResolver> schemaHandlingResourceResolvers;
+ private final Map<String, ResourceResolver> schemeHandlingResourceResolvers;
private final ResourceResolver defaultResolver;
- private SchemaAwareResourceResolver(
- Map<String, ResourceResolver> schemaHandlingResourceResolvers,
+ private SchemeAwareResourceResolver(
+ Map<String, ResourceResolver> schemEHandlingResourceResolvers,
ResourceResolver defaultResolver) {
- this.schemaHandlingResourceResolvers = schemaHandlingResourceResolvers;
+ this.schemeHandlingResourceResolvers = schemEHandlingResourceResolvers;
this.defaultResolver = defaultResolver;
}
- private ResourceResolver getResourceResolverForSchema(URI uri) {
- String schema = uri.getScheme();
- if (schemaHandlingResourceResolvers.containsKey(schema)) {
- return schemaHandlingResourceResolvers.get(schema);
+ private ResourceResolver getResourceResolverForScheme(URI uri) {
+ String scheme = uri.getScheme();
+ if (schemeHandlingResourceResolvers.containsKey(scheme)) {
+ return schemeHandlingResourceResolvers.get(scheme);
} else {
return defaultResolver;
}
@@ -212,58 +217,58 @@ public final class ResourceResolverFactory {
/** {@inheritDoc} */
public Resource getResource(URI uri) throws IOException {
- return getResourceResolverForSchema(uri).getResource(uri);
+ return getResourceResolverForScheme(uri).getResource(uri);
}
/** {@inheritDoc} */
public OutputStream getOutputStream(URI uri) throws IOException {
- return getResourceResolverForSchema(uri).getOutputStream(uri);
+ return getResourceResolverForScheme(uri).getOutputStream(uri);
}
}
/**
* Implementations of this interface will be builders for {@link ResourceResolver}, they bind
- * URI schemas to their respective resolver. This gives users more control over the mechanisms
+ * URI schemes to their respective resolver. This gives users more control over the mechanisms
* by which URIs are resolved.
* <p>
* Here is an example of how this could be used:
* </p>
* <p><code>
- * SchemaAwareResourceResolverBuilder builder
- * = ResourceResolverFactory.createSchemaAwareResourceResolverBuilder(defaultResolver);
- * builder.registerResourceResolverForSchema("test", testResolver);
- * builder.registerResourceResolverForSchema("anotherTest", test2Resolver);
+ * SchemeAwareResourceResolverBuilder builder
+ * = ResourceResolverFactory.createSchemeAwareResourceResolverBuilder(defaultResolver);
+ * builder.registerResourceResolverForScheme("test", testResolver);
+ * builder.registerResourceResolverForScheme("anotherTest", test2Resolver);
* ResourceResolver resolver = builder.build();
* </code></p>
* This will result in all URIs for the form "test:///..." will be resolved using the
* <code>testResolver</code> object; URIs of the form "anotherTest:///..." will be resolved
* using <code>test2Resolver</code>; all other URIs will be resolved from the defaultResolver.
*/
- public interface SchemaAwareResourceResolverBuilder {
+ public interface SchemeAwareResourceResolverBuilder {
/**
- * Register a schema with its respective {@link ResourceResolver}. This resolver will be
- * used as the only resolver for the specified schema.
+ * Register a scheme with its respective {@link ResourceResolver}. This resolver will be
+ * used as the only resolver for the specified scheme.
*
- * @param schema the schema to be used with the given resolver
+ * @param scheme the scheme to be used with the given resolver
* @param resourceResolver the resource resolver
*/
- void registerResourceResolverForSchema(String schema, ResourceResolver resourceResolver);
+ void registerResourceResolverForScheme(String scheme, ResourceResolver resourceResolver);
/**
* Builds a {@link ResourceResolver} that will delegate to the respective resource resolver
- * when a registered URI schema is given
+ * when a registered URI scheme is given
*
- * @return a resolver that delegates to the appropriate schema resolver
+ * @return a resolver that delegates to the appropriate scheme resolver
*/
ResourceResolver build();
}
- private static final class CompletedSchemaAwareResourceResolverBuilder
- implements SchemaAwareResourceResolverBuilder {
+ private static final class CompletedSchemeAwareResourceResolverBuilder
+ implements SchemeAwareResourceResolverBuilder {
- private static final SchemaAwareResourceResolverBuilder INSTANCE
- = new CompletedSchemaAwareResourceResolverBuilder();
+ private static final SchemeAwareResourceResolverBuilder INSTANCE
+ = new CompletedSchemeAwareResourceResolverBuilder();
/** {@inheritDoc} */
public ResourceResolver build() {
@@ -271,59 +276,58 @@ public final class ResourceResolverFactory {
}
/** {@inheritDoc} */
- public void registerResourceResolverForSchema(String schema,
+ public void registerResourceResolverForScheme(String scheme,
ResourceResolver resourceResolver) {
throw new IllegalStateException("Resource resolver already built");
}
}
- private static final class ActiveSchemaAwareResourceResolverBuilder
- implements SchemaAwareResourceResolverBuilder {
+ private static final class ActiveSchemeAwareResourceResolverBuilder
+ implements SchemeAwareResourceResolverBuilder {
- private final Map<String, ResourceResolver> schemaHandlingResourceResolvers
+ private final Map<String, ResourceResolver> schemeHandlingResourceResolvers
= new HashMap<String, ResourceResolver>();
private final ResourceResolver defaultResolver;
- private ActiveSchemaAwareResourceResolverBuilder(ResourceResolver defaultResolver) {
+ private ActiveSchemeAwareResourceResolverBuilder(ResourceResolver defaultResolver) {
this.defaultResolver = defaultResolver;
}
/** {@inheritDoc} */
- public void registerResourceResolverForSchema(String schema,
+ public void registerResourceResolverForScheme(String scheme,
ResourceResolver resourceResolver) {
- schemaHandlingResourceResolvers.put(schema, resourceResolver);
+ schemeHandlingResourceResolvers.put(scheme, resourceResolver);
}
/** {@inheritDoc} */
public ResourceResolver build() {
- return new SchemaAwareResourceResolver(
- Collections.unmodifiableMap(schemaHandlingResourceResolvers), defaultResolver);
+ return new SchemeAwareResourceResolver(
+ Collections.unmodifiableMap(schemeHandlingResourceResolvers), defaultResolver);
}
}
- private static final class SchemaAwareResourceResolverBuilderImpl
- implements SchemaAwareResourceResolverBuilder {
+ private static final class SchemeAwareResourceResolverBuilderImpl
+ implements SchemeAwareResourceResolverBuilder {
- private SchemaAwareResourceResolverBuilder delegate;
+ private SchemeAwareResourceResolverBuilder delegate;
- private SchemaAwareResourceResolverBuilderImpl(ResourceResolver defaultResolver) {
- this.delegate = new ActiveSchemaAwareResourceResolverBuilder(defaultResolver);
+ private SchemeAwareResourceResolverBuilderImpl(ResourceResolver defaultResolver) {
+ this.delegate = new ActiveSchemeAwareResourceResolverBuilder(defaultResolver);
}
/** {@inheritDoc} */
- public void registerResourceResolverForSchema(String schema,
+ public void registerResourceResolverForScheme(String scheme,
ResourceResolver resourceResolver) {
- delegate.registerResourceResolverForSchema(schema, resourceResolver);
+ delegate.registerResourceResolverForScheme(scheme, resourceResolver);
}
/** {@inheritDoc} */
public ResourceResolver build() {
ResourceResolver resourceResolver = delegate.build();
- delegate = CompletedSchemaAwareResourceResolverBuilder.INSTANCE;
+ delegate = CompletedSchemeAwareResourceResolverBuilder.INSTANCE;
return resourceResolver;
}
}
-
}
diff --git a/src/java/org/apache/fop/apps/io/TempResourceResolver.java b/src/java/org/apache/fop/apps/io/TempResourceResolver.java
deleted file mode 100644
index cf307fab6..000000000
--- a/src/java/org/apache/fop/apps/io/TempResourceResolver.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-/* $Id$ */
-
-package org.apache.fop.apps.io;
-
-import java.io.IOException;
-import java.io.OutputStream;
-
-/**
- * Implementations of this interface resolve URIs for temporary files used by FOP. The temporary-
- * resource URI scheme comes from {@link TempResourceURIGenerator#TMP_SCHEMA}.
- */
-public interface TempResourceResolver {
-
- /**
- * Get a temporary-resource given the URI pointing to said resource.
- *
- * @param uri the resource URI
- * @return the resource
- * @throws IOException if an I/O error occured during resource acquisition
- */
- Resource getResource(String uri) throws IOException;
-
- /**
- * Gets an temporary-output stream of a given URI.
- *
- * @param uri the output stream URI
- * @return the output stream
- * @throws IOException if an I/O error occured while creating an output stream
- */
- OutputStream getOutputStream(String uri) throws IOException;
-}
diff --git a/src/java/org/apache/fop/apps/io/TempResourceURIGenerator.java b/src/java/org/apache/fop/apps/io/TempResourceURIGenerator.java
deleted file mode 100644
index 8e6c3606c..000000000
--- a/src/java/org/apache/fop/apps/io/TempResourceURIGenerator.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.fop.apps.io;
-
-import java.net.URI;
-import java.util.concurrent.atomic.AtomicLong;
-
-/**
- * Creates a URI for any temporary resource used within FOP.
- */
-public final class TempResourceURIGenerator {
-
- public static final String TMP_SCHEMA = "tmp";
-
- private final String tempURIPrefix;
-
- private final AtomicLong counter;
-
- /**
- * @param uriPrefix a prefix used to name the unique URI
- */
- public TempResourceURIGenerator(String uriPrefix) {
- counter = new AtomicLong();
- tempURIPrefix = URI.create(TMP_SCHEMA + ":///" + uriPrefix).toASCIIString();
- }
-
- /**
- * Generate a unique URI for a temporary resource
- * @return the URI
- */
- public URI generate() {
- return URI.create(tempURIPrefix + getUniqueId());
- }
-
- private String getUniqueId() {
- return Long.toHexString(counter.getAndIncrement());
- }
-
- public static boolean isTempUri(URI uri) {
- return TMP_SCHEMA.equals(uri.getScheme());
- }
-}
diff --git a/src/java/org/apache/fop/area/CachedRenderPagesModel.java b/src/java/org/apache/fop/area/CachedRenderPagesModel.java
index fcc82cdd3..0837e5ae5 100644
--- a/src/java/org/apache/fop/area/CachedRenderPagesModel.java
+++ b/src/java/org/apache/fop/area/CachedRenderPagesModel.java
@@ -35,9 +35,10 @@ import org.xml.sax.SAXException;
import org.apache.commons.io.IOUtils;
+import org.apache.xmlgraphics.io.TempResourceURIGenerator;
+
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
-import org.apache.fop.apps.io.TempResourceURIGenerator;
import org.apache.fop.fonts.FontInfo;
/**
diff --git a/src/java/org/apache/fop/fonts/FontManagerConfigurator.java b/src/java/org/apache/fop/fonts/FontManagerConfigurator.java
index cf9296826..fc2ce06a6 100644
--- a/src/java/org/apache/fop/fonts/FontManagerConfigurator.java
+++ b/src/java/org/apache/fop/fonts/FontManagerConfigurator.java
@@ -29,9 +29,10 @@ import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.xmlgraphics.io.ResourceResolver;
+
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.io.InternalResourceResolver;
-import org.apache.fop.apps.io.ResourceResolver;
import org.apache.fop.apps.io.ResourceResolverFactory;
import org.apache.fop.fonts.substitute.FontSubstitutions;
import org.apache.fop.fonts.substitute.FontSubstitutionsConfigurator;
diff --git a/src/java/org/apache/fop/image/loader/batik/PreloaderSVG.java b/src/java/org/apache/fop/image/loader/batik/PreloaderSVG.java
index 022ff462f..3aa340a4a 100644
--- a/src/java/org/apache/fop/image/loader/batik/PreloaderSVG.java
+++ b/src/java/org/apache/fop/image/loader/batik/PreloaderSVG.java
@@ -45,6 +45,7 @@ import org.apache.xmlgraphics.image.loader.ImageSize;
import org.apache.xmlgraphics.image.loader.impl.AbstractImagePreloader;
import org.apache.xmlgraphics.image.loader.impl.ImageXMLDOM;
import org.apache.xmlgraphics.image.loader.util.ImageUtil;
+import org.apache.xmlgraphics.io.XmlSourceUtil;
import org.apache.xmlgraphics.util.MimeConstants;
import org.apache.xmlgraphics.util.UnitConv;
@@ -79,7 +80,7 @@ public class PreloaderSVG extends AbstractImagePreloader {
}
}
if (info != null) {
- ImageUtil.closeQuietly(src); //Image is fully read
+ XmlSourceUtil.closeQuietly(src); //Image is fully read
}
return info;
}
@@ -119,7 +120,7 @@ public class PreloaderSVG extends AbstractImagePreloader {
DOMSource domSrc = (DOMSource)src;
doc = (SVGDocument)domSrc.getNode();
} else {
- in = new UnclosableInputStream(ImageUtil.needInputStream(src));
+ in = new UnclosableInputStream(XmlSourceUtil.needInputStream(src));
int length = in.available();
in.mark(length + 1);
SAXSVGDocumentFactory factory = new SAXSVGDocumentFactory(
diff --git a/src/java/org/apache/fop/image/loader/batik/PreloaderWMF.java b/src/java/org/apache/fop/image/loader/batik/PreloaderWMF.java
index 3bef0f41d..43341cbe6 100644
--- a/src/java/org/apache/fop/image/loader/batik/PreloaderWMF.java
+++ b/src/java/org/apache/fop/image/loader/batik/PreloaderWMF.java
@@ -38,6 +38,7 @@ import org.apache.xmlgraphics.image.loader.ImageInfo;
import org.apache.xmlgraphics.image.loader.ImageSize;
import org.apache.xmlgraphics.image.loader.impl.AbstractImagePreloader;
import org.apache.xmlgraphics.image.loader.util.ImageUtil;
+import org.apache.xmlgraphics.io.XmlSourceUtil;
import org.apache.fop.util.UnclosableInputStream;
@@ -69,7 +70,7 @@ public class PreloaderWMF extends AbstractImagePreloader {
}
}
if (info != null) {
- ImageUtil.closeQuietly(src); //Image is fully read
+ XmlSourceUtil.closeQuietly(src); //Image is fully read
}
return info;
}
@@ -88,7 +89,7 @@ public class PreloaderWMF extends AbstractImagePreloader {
ImageContext context) {
// parse document and get the size attributes of the svg element
- InputStream in = new UnclosableInputStream(ImageUtil.needInputStream(src));
+ InputStream in = new UnclosableInputStream(XmlSourceUtil.needInputStream(src));
try {
in.mark(4 + 1);
diff --git a/src/java/org/apache/fop/render/ps/PSDocumentHandler.java b/src/java/org/apache/fop/render/ps/PSDocumentHandler.java
index 0ec5fdda6..897ed8fb8 100644
--- a/src/java/org/apache/fop/render/ps/PSDocumentHandler.java
+++ b/src/java/org/apache/fop/render/ps/PSDocumentHandler.java
@@ -39,6 +39,7 @@ import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.xmlgraphics.io.TempResourceURIGenerator;
import org.apache.xmlgraphics.java2d.Dimension2DDouble;
import org.apache.xmlgraphics.ps.DSCConstants;
import org.apache.xmlgraphics.ps.PSDictionary;
@@ -53,7 +54,6 @@ import org.apache.xmlgraphics.ps.dsc.events.DSCCommentBoundingBox;
import org.apache.xmlgraphics.ps.dsc.events.DSCCommentHiResBoundingBox;
import org.apache.fop.apps.MimeConstants;
-import org.apache.fop.apps.io.TempResourceURIGenerator;
import org.apache.fop.render.intermediate.AbstractBinaryWritingIFDocumentHandler;
import org.apache.fop.render.intermediate.IFContext;
import org.apache.fop.render.intermediate.IFDocumentHandlerConfigurator;
diff --git a/src/java/org/apache/fop/servlet/FopServlet.java b/src/java/org/apache/fop/servlet/FopServlet.java
index 9dcf10a2b..c65b6af3b 100644
--- a/src/java/org/apache/fop/servlet/FopServlet.java
+++ b/src/java/org/apache/fop/servlet/FopServlet.java
@@ -41,14 +41,15 @@ import javax.xml.transform.stream.StreamSource;
import org.apache.commons.io.output.ByteArrayOutputStream;
+import org.apache.xmlgraphics.io.Resource;
+import org.apache.xmlgraphics.io.ResourceResolver;
+
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FopFactory;
import org.apache.fop.apps.FopFactoryBuilder;
import org.apache.fop.apps.MimeConstants;
-import org.apache.fop.apps.io.Resource;
-import org.apache.fop.apps.io.ResourceResolver;
/**
* Example servlet to generate a PDF from a servlet.