From 80d1fddb751360dd654f70df3918d0fad2c1fc89 Mon Sep 17 00:00:00 2001 From: "Richard G. Curtis" Date: Tue, 5 Mar 2013 16:09:21 +0000 Subject: [PATCH] OPENJPA-2346: Minor performance improvement to MetaDataRepository. git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@1452872 13f79535-47bb-0310-9956-ffa450edef68 --- .../openjpa/meta/MetaDataRepository.java | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java b/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java index b5bdc94a2..9c08a30b0 100644 --- a/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java +++ b/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java @@ -39,8 +39,8 @@ import org.apache.openjpa.conf.OpenJPAConfiguration; import org.apache.openjpa.enhance.DynamicPersistenceCapable; import org.apache.openjpa.enhance.PCEnhancer; import org.apache.openjpa.enhance.PCRegistry; -import org.apache.openjpa.enhance.PersistenceCapable; import org.apache.openjpa.enhance.PCRegistry.RegisterClassListener; +import org.apache.openjpa.enhance.PersistenceCapable; import org.apache.openjpa.event.LifecycleEventManager; import org.apache.openjpa.lib.conf.Configurable; import org.apache.openjpa.lib.conf.Configuration; @@ -394,6 +394,8 @@ public class MetaDataRepository implements PCRegistry.RegisterClassListener, Con } private ClassMetaData getMetaDataInternal(Class cls, ClassLoader envLoader, boolean mustExist) { + ClassMetaData meta = getMetaDataInternal(cls, envLoader); + if (meta == null) { if (cls != null && DynamicPersistenceCapable.class.isAssignableFrom(cls)) cls = cls.getSuperclass(); @@ -401,20 +403,20 @@ public class MetaDataRepository implements PCRegistry.RegisterClassListener, Con // to locate metadata if (cls != null && _implGen != null && _implGen.isImplType(cls)) cls = _implGen.toManagedInterface(cls); + meta = getMetaDataInternal(cls, envLoader); + } + if (meta == null && mustExist) { + if (cls != null && !ImplHelper.isManagedType(_conf, cls)) + throw new MetaDataException(_loc.get("no-meta-notpc", cls)).setFatal(false); - ClassMetaData meta = getMetaDataInternal(cls, envLoader); - if (meta == null && mustExist) { - if (cls != null && !ImplHelper.isManagedType(_conf, cls)) - throw new MetaDataException(_loc.get("no-meta-notpc", cls)).setFatal(false); + Set pcNames = getPersistentTypeNames(false, envLoader); + if (pcNames != null && pcNames.size() > 0) + throw new MetaDataException(_loc.get("no-meta-types", cls, pcNames)); - Set pcNames = getPersistentTypeNames(false, envLoader); - if (pcNames != null && pcNames.size() > 0) - throw new MetaDataException(_loc.get("no-meta-types", cls, pcNames)); - - throw new MetaDataException(_loc.get("no-meta", cls)); - } - resolve(meta); - return meta; + throw new MetaDataException(_loc.get("no-meta", cls)); + } + resolve(meta); + return meta; } /** @@ -1920,8 +1922,8 @@ public class MetaDataRepository implements PCRegistry.RegisterClassListener, Con public void endConfiguration() { initializeMetaDataFactory(); - if (_implGen == null) - _implGen = new InterfaceImplGenerator(this); + if (_implGen == null) + _implGen = new InterfaceImplGenerator(this); if (_preload == true) { _oids = new HashMap, Class>(); _impls = new HashMap, Collection>>();