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();) {
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();

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 \
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.

View File

@ -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<URL, Set>();
_xml.put((URL) rsrc, new HashSet(Arrays.asList(names)));

View File

@ -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.