From 6055a34b4215b472dce012d28ead7a2a7c6f8f19 Mon Sep 17 00:00:00 2001 From: Patrick Linskey Date: Wed, 10 Jan 2007 23:06:42 +0000 Subject: [PATCH] OPENJPA-100: processing bugfix, and logging improvements git-svn-id: https://svn.apache.org/repos/asf/incubator/openjpa/trunk@495028 13f79535-47bb-0310-9956-ffa450edef68 --- .../meta/AbstractCFMetaDataFactory.java | 20 +++++++++++++++++++ .../apache/openjpa/meta/localizer.properties | 9 +++++++++ .../PersistenceMetaDataFactory.java | 15 +++++++++++++- .../openjpa/persistence/localizer.properties | 7 +++++++ 4 files changed, 50 insertions(+), 1 deletion(-) diff --git a/openjpa-kernel/src/main/java/org/apache/openjpa/meta/AbstractCFMetaDataFactory.java b/openjpa-kernel/src/main/java/org/apache/openjpa/meta/AbstractCFMetaDataFactory.java index de572f5b7..87257530e 100644 --- a/openjpa-kernel/src/main/java/org/apache/openjpa/meta/AbstractCFMetaDataFactory.java +++ b/openjpa-kernel/src/main/java/org/apache/openjpa/meta/AbstractCFMetaDataFactory.java @@ -604,12 +604,18 @@ public abstract class AbstractCFMetaDataFactory for (Iterator itr = files.iterator(); itr.hasNext();) { file = (File) itr.next(); if (file.isDirectory()) { + if (log.isTraceEnabled()) + log.trace(_loc.get("scanning-directory", file)); scan(new FileMetaDataIterator(dir, newMetaDataFilter()), cparser, names, true); } else if (file.getName().endsWith(".jar")) { + if (log.isTraceEnabled()) + log.trace(_loc.get("scanning-jar", file)); scan(new ZipFileMetaDataIterator(new ZipFile(file), newMetaDataFilter()), cparser, names, true); } else { + if (log.isTraceEnabled()) + log.trace(_loc.get("scanning-file", file)); clss = cparser.parseTypeNames(new FileMetaDataIterator (file)); names.addAll(Arrays.asList(clss)); @@ -624,9 +630,19 @@ public abstract class AbstractCFMetaDataFactory url = (URL) itr.next(); if ("jar".equals(url.getProtocol()) && url.getPath().endsWith("!/")) { + if (log.isTraceEnabled()) + log.trace(_loc.get("scanning-jar-url", url)); scan(new ZipFileMetaDataIterator(url, newMetaDataFilter()), cparser, names, true); + } else if (url.getPath().endsWith(".jar")) { + if (log.isTraceEnabled()) + log.trace(_loc.get("scanning-jar-at-url", url)); + scan(new ZipStreamMetaDataIterator( + new ZipInputStream(url.openStream()), + newMetaDataFilter()), cparser, names, true); } else { + if (log.isTraceEnabled()) + log.trace(_loc.get("scanning-url", url)); clss = cparser.parseTypeNames(new URLMetaDataIterator (url)); names.addAll(Arrays.asList(clss)); @@ -642,11 +658,15 @@ public abstract class AbstractCFMetaDataFactory if (rsrc.endsWith(".jar")) { url = loader.getResource(rsrc); if (url != null) { + if (log.isTraceEnabled()) + log.trace(_loc.get("scanning-jar-stream-url", url)); scan(new ZipStreamMetaDataIterator (new ZipInputStream(url.openStream()), newMetaDataFilter()), cparser, names, true); } } else { + if (log.isTraceEnabled()) + log.trace(_loc.get("scanning-resource", rsrc)); mitr = new ResourceMetaDataIterator(rsrc, loader); while (mitr.hasNext()) { url = (URL) mitr.next(); diff --git a/openjpa-kernel/src/main/resources/org/apache/openjpa/meta/localizer.properties b/openjpa-kernel/src/main/resources/org/apache/openjpa/meta/localizer.properties index fd14c38ac..4d079c96b 100644 --- a/openjpa-kernel/src/main/resources/org/apache/openjpa/meta/localizer.properties +++ b/openjpa-kernel/src/main/resources/org/apache/openjpa/meta/localizer.properties @@ -281,3 +281,12 @@ no-metadatafactory: MetaDataFactory could not be configured \ of the task''s nested element. This can also occur if your \ OpenJPA distribution jars are corrupt, or if your security policy is \ overly strict. +scanning-directory: Scanning directory "{0}" for persistent types. +scanning-jar: Scanning jar "{0}" for persistent types. +scanning-file: Scanning file "{0}" for persistent types. +scanning-jar-url: Scanning jar: URL "{0}" for persistent types. +scanning-jar-at-url: Scanning jar file from URL "{0}" for persistent types. +scanning-url: Scanning URL "{0}" for persistent types. +scanning-zip-stream-url: Scanning jar in stream from URL "{0}" for persistent \ + types. +scanning-resource: Scanning resource "{0}" for persistent types. diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceMetaDataFactory.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceMetaDataFactory.java index eedfbbd02..797d45eee 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceMetaDataFactory.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceMetaDataFactory.java @@ -245,9 +245,22 @@ public class PersistenceMetaDataFactory @Override protected void mapPersistentTypeNames(Object rsrc, String[] names) { - if (!(rsrc instanceof URL) || rsrc.toString().endsWith(".class")) + if (!(rsrc instanceof URL)) { + if (log.isTraceEnabled()) + log.trace( + _loc.get("map-persistent-types-skipping-non-url", rsrc)); return; + } else if (rsrc.toString().endsWith(".class")) { + if (log.isTraceEnabled()) + log.trace( + _loc.get("map-persistent-types-skipping-class", rsrc)); + return; + } + if (log.isTraceEnabled()) + log.trace(_loc.get( + "map-persistent-type-names", rsrc, Arrays.asList(names))); + if (_xml == null) _xml = new HashMap(); _xml.put((URL) rsrc, new HashSet(Arrays.asList(names))); diff --git a/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/localizer.properties b/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/localizer.properties index 93099142b..e8c9a8cc5 100644 --- a/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/localizer.properties +++ b/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/localizer.properties @@ -110,6 +110,13 @@ cant-convert-brokerfactory: Unable to convert EntityManagerFactory of type \ "{0}" into a BrokerFactory. cant-convert-broker: Unable to convert EntityManager of type "{0}" into a \ Broker. +map-persistent-type-names: Mapping resource location "{0}" to persistent \ + types "{1}". +map-persistent-types-skipping-non-url: Skipping mapping for location "{0}" \ + since it is not a URL. +map-persistent-types-skipping-class: Skipping mapping for location "{0}" since \ + it is a class, and will not need to be re-parsed later. + EntityManagerFactory-name: EntityManagerFactory implementation EntityManagerFactory-desc: Allows extension of standard \ org.apache.openjpa.persistence.EntityManagerFactoryImpl for custom behavior.