OPENJPA-100: <jar-file> processing bugfix, and logging improvements

git-svn-id: https://svn.apache.org/repos/asf/incubator/openjpa/trunk@495028 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Patrick Linskey 2007-01-10 23:06:42 +00:00
parent 9851f62748
commit 6055a34b42
4 changed files with 50 additions and 1 deletions

View File

@ -604,12 +604,18 @@ public abstract class AbstractCFMetaDataFactory
for (Iterator itr = files.iterator(); itr.hasNext();) { for (Iterator itr = files.iterator(); itr.hasNext();) {
file = (File) itr.next(); file = (File) itr.next();
if (file.isDirectory()) { if (file.isDirectory()) {
if (log.isTraceEnabled())
log.trace(_loc.get("scanning-directory", file));
scan(new FileMetaDataIterator(dir, newMetaDataFilter()), scan(new FileMetaDataIterator(dir, newMetaDataFilter()),
cparser, names, true); cparser, names, true);
} else if (file.getName().endsWith(".jar")) { } else if (file.getName().endsWith(".jar")) {
if (log.isTraceEnabled())
log.trace(_loc.get("scanning-jar", file));
scan(new ZipFileMetaDataIterator(new ZipFile(file), scan(new ZipFileMetaDataIterator(new ZipFile(file),
newMetaDataFilter()), cparser, names, true); newMetaDataFilter()), cparser, names, true);
} else { } else {
if (log.isTraceEnabled())
log.trace(_loc.get("scanning-file", file));
clss = cparser.parseTypeNames(new FileMetaDataIterator clss = cparser.parseTypeNames(new FileMetaDataIterator
(file)); (file));
names.addAll(Arrays.asList(clss)); names.addAll(Arrays.asList(clss));
@ -624,9 +630,19 @@ public abstract class AbstractCFMetaDataFactory
url = (URL) itr.next(); url = (URL) itr.next();
if ("jar".equals(url.getProtocol()) if ("jar".equals(url.getProtocol())
&& url.getPath().endsWith("!/")) { && url.getPath().endsWith("!/")) {
if (log.isTraceEnabled())
log.trace(_loc.get("scanning-jar-url", url));
scan(new ZipFileMetaDataIterator(url, scan(new ZipFileMetaDataIterator(url,
newMetaDataFilter()), cparser, names, true); 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 { } else {
if (log.isTraceEnabled())
log.trace(_loc.get("scanning-url", url));
clss = cparser.parseTypeNames(new URLMetaDataIterator clss = cparser.parseTypeNames(new URLMetaDataIterator
(url)); (url));
names.addAll(Arrays.asList(clss)); names.addAll(Arrays.asList(clss));
@ -642,11 +658,15 @@ public abstract class AbstractCFMetaDataFactory
if (rsrc.endsWith(".jar")) { if (rsrc.endsWith(".jar")) {
url = loader.getResource(rsrc); url = loader.getResource(rsrc);
if (url != null) { if (url != null) {
if (log.isTraceEnabled())
log.trace(_loc.get("scanning-jar-stream-url", url));
scan(new ZipStreamMetaDataIterator scan(new ZipStreamMetaDataIterator
(new ZipInputStream(url.openStream()), (new ZipInputStream(url.openStream()),
newMetaDataFilter()), cparser, names, true); newMetaDataFilter()), cparser, names, true);
} }
} else { } else {
if (log.isTraceEnabled())
log.trace(_loc.get("scanning-resource", rsrc));
mitr = new ResourceMetaDataIterator(rsrc, loader); mitr = new ResourceMetaDataIterator(rsrc, loader);
while (mitr.hasNext()) { while (mitr.hasNext()) {
url = (URL) mitr.next(); url = (URL) mitr.next();

View File

@ -281,3 +281,12 @@ no-metadatafactory: MetaDataFactory could not be configured \
of the task''s nested <config> element. This can also occur if your \ of the task''s nested <config> element. This can also occur if your \
OpenJPA distribution jars are corrupt, or if your security policy is \ OpenJPA distribution jars are corrupt, or if your security policy is \
overly strict. 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.

View File

@ -245,8 +245,21 @@ public class PersistenceMetaDataFactory
@Override @Override
protected void mapPersistentTypeNames(Object rsrc, String[] names) { 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; 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) if (_xml == null)
_xml = new HashMap<URL, Set>(); _xml = new HashMap<URL, Set>();

View File

@ -110,6 +110,13 @@ cant-convert-brokerfactory: Unable to convert EntityManagerFactory of type \
"{0}" into a BrokerFactory. "{0}" into a BrokerFactory.
cant-convert-broker: Unable to convert EntityManager of type "{0}" into a \ cant-convert-broker: Unable to convert EntityManager of type "{0}" into a \
Broker. 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-name: EntityManagerFactory implementation
EntityManagerFactory-desc: Allows extension of standard \ EntityManagerFactory-desc: Allows extension of standard \
org.apache.openjpa.persistence.EntityManagerFactoryImpl for custom behavior. org.apache.openjpa.persistence.EntityManagerFactoryImpl for custom behavior.