From 90332224f77bea9341d080d76e7d06b31471697f Mon Sep 17 00:00:00 2001 From: Patrick Linskey Date: Thu, 12 Jun 2008 00:00:06 +0000 Subject: [PATCH] Merge from ../branches/1.1.x. svn merge -c 657162 ../branches/1.1.x git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@666921 13f79535-47bb-0310-9956-ffa450edef68 --- .../openjpa/conf/CacheMarshallerImpl.java | 25 +++++++++++++++---- .../apache/openjpa/conf/localizer.properties | 4 ++- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/openjpa-kernel/src/main/java/org/apache/openjpa/conf/CacheMarshallerImpl.java b/openjpa-kernel/src/main/java/org/apache/openjpa/conf/CacheMarshallerImpl.java index ed18cfc4b..c552ccd6d 100644 --- a/openjpa-kernel/src/main/java/org/apache/openjpa/conf/CacheMarshallerImpl.java +++ b/openjpa-kernel/src/main/java/org/apache/openjpa/conf/CacheMarshallerImpl.java @@ -28,6 +28,8 @@ import java.io.ObjectOutputStream; import java.io.OutputStream; import java.net.URL; import java.util.Enumeration; +import java.util.List; +import java.util.ArrayList; import org.apache.openjpa.lib.conf.Configurable; import org.apache.openjpa.lib.conf.Configuration; @@ -218,15 +220,28 @@ public class CacheMarshallerImpl try { ClassLoader cl = _conf.getClassResolverInstance() .getClassLoader(getClass(), null); + List list = new ArrayList(); for (Enumeration e = cl.getResources(_inputResourceLocation); - e.hasMoreElements(); ) { - if (_inputURL == null) - _inputURL = (URL) e.nextElement(); - else + e.hasMoreElements(); ) + list.add(e); + + if (list.size() > 1) { + if (_consumeErrors) { + if (_log.isWarnEnabled()) + _log.warn(_loc.get( + "cache-marshaller-multiple-resources-warn", + getId(), _inputResourceLocation, list) + .getMessage()); + } else { throw new IllegalStateException( _loc.get("cache-marshaller-multiple-resources", - getId(), _inputResourceLocation).getMessage()); + getId(), _inputResourceLocation, list) + .getMessage()); + } } + + if (!list.isEmpty()) + _inputURL = (URL) list.get(0); } catch (IOException ioe) { IllegalStateException ise = new IllegalStateException( _loc.get("cache-marshaller-bad-url", getId(), diff --git a/openjpa-kernel/src/main/resources/org/apache/openjpa/conf/localizer.properties b/openjpa-kernel/src/main/resources/org/apache/openjpa/conf/localizer.properties index 377f5e993..0606930f3 100644 --- a/openjpa-kernel/src/main/resources/org/apache/openjpa/conf/localizer.properties +++ b/openjpa-kernel/src/main/resources/org/apache/openjpa/conf/localizer.properties @@ -572,7 +572,9 @@ cache-marshaller-input-url-and-resource-specified: An InputURL and an \ InputResource were specified for CacheMarshaller {0}. At most one of these \ can be specified. cache-marshaller-multiple-resources: Multiple resources exist for resource \ - location {1} for CacheMarshaller {0}. + location {1} for CacheMarshaller {0}: {2}. +cache-marshaller-multiple-resources-warn: Multiple resources exist for resource\ + location {1} for CacheMarshaller {0}: {2}. The first one will be used. cache-marshaller-bad-url: An error occurred while loading resource location \ {1} for CacheMarshaller {0}. cache-marshaller-null-validation-policy: No ValidationPolicy was set for \