openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ppod...@apache.org
Subject svn commit: r1190716 [4/10] - in /openjpa/trunk: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/ant/ openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/ openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/ openjpa-jdbc/src/main/java/org/...
Date Sat, 29 Oct 2011 00:44:18 GMT
Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCClassFileTransformer.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCClassFileTransformer.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCClassFileTransformer.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCClassFileTransformer.java Sat Oct 29 00:44:11 2011
@@ -43,16 +43,15 @@ import serp.bytecode.lowlevel.ConstantPo
 public class PCClassFileTransformer
     implements ClassFileTransformer {
 
-    private static final Localizer _loc = Localizer.forPackage
-        (PCClassFileTransformer.class);
+    private static final Localizer _loc = Localizer.forPackage(PCClassFileTransformer.class);
 
     private final MetaDataRepository _repos;
     private final PCEnhancer.Flags _flags;
     private final ClassLoader _tmpLoader;
     private final Log _log;
-    private final Set _names;
+    private final Set<String> _names;
     private boolean _transforming = false;
-
+    private static final String PERSISTENCE_CAPABLE = "org/apache/openjpa/enhance/PersistenceCapable";
     /**
      * Constructor.
      *
@@ -94,17 +93,20 @@ public class PCClassFileTransformer
         _repos = repos;
         _tmpLoader = tmpLoader;
 
-        _log = repos.getConfiguration().
-            getLog(OpenJPAConfiguration.LOG_ENHANCE);
+        _log = repos.getConfiguration().getLog(OpenJPAConfiguration.LOG_ENHANCE);
         _flags = flags;
-
-        _names = repos.getPersistentTypeNames(devscan, tmpLoader);
+        repos.getConfiguration().addClassLoader(tmpLoader);
+        _names = repos.getPersistentTypeNames(devscan);
         if (_names == null && _log.isInfoEnabled())
             _log.info(_loc.get("runtime-enhance-pcclasses"));
     }
 
+    /**
+     * The hook to transform byte code as they are loaded in Java Virtual Machine.
+     * 
+     */
     public byte[] transform(ClassLoader loader, String className,
-        Class redef, ProtectionDomain domain, byte[] bytes)
+        Class<?> redef, ProtectionDomain domain, byte[] bytes)
         throws IllegalClassFormatException {
         if (loader == _tmpLoader)
             return null;
@@ -129,29 +131,27 @@ public class PCClassFileTransformer
      * ClassCircularityError when executing method using pure-JIT JVMs
      * such as JRockit.
      */
-    private byte[] transform0(String className, Class redef, byte[] bytes)
+    private byte[] transform0(String className, Class<?> redef, byte[] bytes)
         throws IllegalClassFormatException {
         
-        byte[] returnBytes = null;
         try {
             Boolean enhance = needsEnhance(className, redef, bytes);
-            if (enhance != null && _log.isTraceEnabled())
-                _log.trace(_loc.get("needs-runtime-enhance", className,
-                    enhance));
-            if (enhance != Boolean.TRUE)
+            if (enhance != null && _log.isTraceEnabled()) {
+                _log.trace(_loc.get("needs-runtime-enhance", className,  enhance));
+            } 
+            if (enhance != Boolean.TRUE) {
                 return null;
+            }
 
             PCEnhancer enhancer = new PCEnhancer(_repos.getConfiguration(),
-                new Project().loadClass(new ByteArrayInputStream(bytes),
-                    _tmpLoader), _repos);
+                new Project().loadClass(new ByteArrayInputStream(bytes),  _tmpLoader), _repos);
             enhancer.setAddDefaultConstructor(_flags.addDefaultConstructor);
-            enhancer.setEnforcePropertyRestrictions
-                (_flags.enforcePropertyRestrictions);
+            enhancer.setEnforcePropertyRestrictions(_flags.enforcePropertyRestrictions);
 
-            if (enhancer.run() == PCEnhancer.ENHANCE_NONE)
+            if (enhancer.run() == PCEnhancer.ENHANCE_NONE) {
                 return null;
-            returnBytes = enhancer.getPCBytecode().toByteArray();
-            return returnBytes;
+            }
+            return enhancer.getPCBytecode().toByteArray();
         } catch (Throwable t) {
             _log.warn(_loc.get("cft-exception-thrown", className), t);
             if (t instanceof RuntimeException)
@@ -161,40 +161,38 @@ public class PCClassFileTransformer
             throw new GeneralException(t);
         } finally {
             _transforming = false;
-            if (returnBytes != null && _log.isTraceEnabled())
-                _log.trace(_loc.get("runtime-enhance-complete", className,
-                    bytes.length, returnBytes.length));
         }
     }
 
     /**
      * Return whether the given class needs enhancement.
      */
-    private Boolean needsEnhance(String clsName, Class redef, byte[] bytes) {
+    private Boolean needsEnhance(String clsName, Class<?> redef, byte[] bytes) {
         if (redef != null) {
-            Class[] intfs = redef.getInterfaces();
-            for (int i = 0; i < intfs.length; i++)
-                if (PersistenceCapable.class.getName().
-                    equals(intfs[i].getName()))
-                    return Boolean.valueOf(!isEnhanced(bytes));
+            Class<?>[] intfs = redef.getInterfaces();
+            for (int i = 0; i < intfs.length; i++) {
+                if (PersistenceCapable.class.getName().equals(intfs[i].getName())) {
+                    return !isEnhanced(bytes);
+                }
+            }
             return null;
         }
 
         if (_names != null) {
             if (_names.contains(clsName.replace('/', '.')))
-                return Boolean.valueOf(!isEnhanced(bytes));
+                return !isEnhanced(bytes);
             return null;
         }
 
-        if (clsName.startsWith("java/") || clsName.startsWith("javax/"))
+        if (clsName.startsWith("java/") || clsName.startsWith("javax/")) {
             return null;
+        }
         if (isEnhanced(bytes))
             return Boolean.FALSE;
 
         try {
-            Class c = Class.forName(clsName.replace('/', '.'), false,
-                _tmpLoader);
-            if (_repos.getMetaData(c, null, false) != null)
+            Class<?> c = Class.forName(clsName.replace('/', '.'), false,  _tmpLoader);
+            if (_repos.getMetaData(c, false) != null)
                 return Boolean.TRUE;
             return null;
         } catch (ClassNotFoundException cnfe) {
@@ -229,7 +227,7 @@ public class PCClassFileTransformer
             clsEntry = table.readUnsignedShort(idx);
             utfEntry = table.readUnsignedShort(table.get(clsEntry));
             name = table.readString(table.get(utfEntry));
-            if ("org/apache/openjpa/enhance/PersistenceCapable".equals(name))
+            if (PERSISTENCE_CAPABLE.equals(name))
                 return true;
         }
         return false;

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java Sat Oct 29 00:44:11 2011
@@ -249,18 +249,14 @@ public class PCEnhancer { 
      * @deprecated use {@link #PCEnhancer(OpenJPAConfiguration, BCClass,
         MetaDataRepository, ClassLoader)} instead. 
      */
-    public PCEnhancer(OpenJPAConfiguration conf, BCClass type,
-        MetaDataRepository repos) {
-        this(conf, type, repos, null);
-    }
 
     /**
      * Constructor. Supply configuration.
      *
-     * @param type the bytecode representation fo the type to
+     * @param type the bytecode representation for the type to
      * enhance; this can be created from any stream or file
      * @param repos a metadata repository to use for metadata access,
-     * or null to create a new reporitory; the repository
+     * or null to create a new repository; the repository
      * from the given configuration isn't used by default
      * because the configuration might be an
      * implementation-specific subclass whose metadata
@@ -268,8 +264,7 @@ public class PCEnhancer { 
      * @param loader the environment classloader to use for loading
      * classes and resources.
      */
-    public PCEnhancer(OpenJPAConfiguration conf, BCClass type,
-        MetaDataRepository repos, ClassLoader loader) {
+    public PCEnhancer(OpenJPAConfiguration conf, BCClass type, MetaDataRepository repos) {
         _managedType = type;
         _pc = type;
 
@@ -278,9 +273,10 @@ public class PCEnhancer { 
         if (repos == null) {
             _repos = conf.newMetaDataRepositoryInstance();
             _repos.setSourceMode(MetaDataRepository.MODE_META);
-        } else
+        } else {
             _repos = repos;
-        _meta = _repos.getMetaData(type.getType(), loader, false);
+        }
+        _meta = _repos.getMetaData(type.getType(), false);
     }
 
     /**
@@ -1132,7 +1128,7 @@ public class PCEnhancer { 
         if (_meta != null && _meta.getDescribedType().isInterface())
             return _meta;
 
-        return _repos.getMetaData(f.getDeclaringClass(), null, false);
+        return _repos.getMetaData(f.getDeclaringClass(), false);
     }
 
     /**
@@ -4686,22 +4682,18 @@ public class PCEnhancer { 
             PCEnhancer.class.getName() + "#bytecodeWriter");
 
         Configurations.populateConfiguration(conf, opts);
-        return run(conf, args, flags, null, writer, null);
+        return run(conf, args, flags, null, writer);
     }
 
     /**
      * Enhance the given classes.
      */
     public static boolean run(OpenJPAConfiguration conf, String[] args,
-        Flags flags, MetaDataRepository repos, BytecodeWriter writer,
-        ClassLoader loader)
+        Flags flags, MetaDataRepository repos, BytecodeWriter writer)
         throws IOException {
-        if (loader == null)
-            loader = conf.getClassResolverInstance().
-                getClassLoader(PCEnhancer.class, null);
-        if (flags.tmpClassLoader)
-            loader = AccessController.doPrivileged(J2DoPrivHelper
-                .newTemporaryClassLoaderAction(loader));
+        ClassLoader loader = conf.getClassLoader();
+//        if (flags.tmpClassLoader)
+//            loader = AccessController.doPrivileged(J2DoPrivHelper.newTemporaryClassLoaderAction(loader));
 
         if (repos == null) {
             repos = conf.newMetaDataRepositoryInstance();
@@ -4712,7 +4704,7 @@ public class PCEnhancer { 
         Collection classes;
         if (args == null || args.length == 0) {
             log.info(_loc.get("running-all-classes"));
-            classes = repos.getPersistentTypeNames(true, loader);
+            classes = repos.getPersistentTypeNames(true);
             if (classes == null) {
             	log.warn(_loc.get("no-class-to-enhance"));
             	return false;
@@ -4722,8 +4714,9 @@ public class PCEnhancer { 
                 getMetaDataFactory().newClassArgParser();
             cap.setClassLoader(loader);
             classes = new HashSet();
-            for (int i = 0; i < args.length; i++)
+            for (int i = 0; i < args.length; i++) {
                 classes.addAll(Arrays.asList(cap.parseTypes(args[i])));
+            }
         }
 
         Project project = new Project();
@@ -4739,7 +4732,7 @@ public class PCEnhancer { 
                 bc = project.loadClass((String) o, loader);
             else
                 bc = project.loadClass((Class) o);
-            enhancer = new PCEnhancer(conf, bc, repos, loader);
+            enhancer = new PCEnhancer(conf, bc, repos);
             if (writer != null)
                 enhancer.setBytecodeWriter(writer);
             enhancer.setDirectory(flags.directory);

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancerAgent.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancerAgent.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancerAgent.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancerAgent.java Sat Oct 29 00:44:11 2011
@@ -74,38 +74,38 @@ public class PCEnhancerAgent {
     private static boolean disableDynamicAgent = false;
 
     /**
-     * @return True if the Agent has ran successfully. False otherwise.
+     * Affirms if the Agent has ran successfully. 
      */
     public static synchronized boolean getLoadSuccessful() {
         return loadSuccessful;
     }
     /**
-     * @return True if the dynamic agent was disabled via configuration. 
+     * disables dynamic agent. 
      */
     public static void disableDynamicAgent(){
-        disableDynamicAgent=true;
+        disableDynamicAgent = true;
     }
     
     /**
-     * @param log
+     * @param configuration
      * @return True if the agent is loaded successfully
      */
-    public static synchronized boolean loadDynamicAgent(Log log) {
-        if (loadAttempted == false && disableDynamicAgent == false) {
-            Instrumentation inst =
-                InstrumentationFactory.getInstrumentation(log);
-            if (inst != null) {
-                premain("", inst);
-                return true;
-            } 
-            // If we successfully get the Instrumentation, we will call premain
-            // where loadAttempted will be set to true. This case is the path 
-            // where we were unable to get Instrumentation so we need to set the
-            // loadAttempted flag to true. We do this so we will only run
-            // through this code one time.
-            loadAttempted = true;
+    public static synchronized boolean loadDynamicAgent(OpenJPAConfiguration conf) {
+        if (loadAttempted || disableDynamicAgent) {
+        	return false;
         }
-
+        
+        Instrumentation inst = InstrumentationFactory.getInstrumentation(conf);
+        if (inst != null) {
+            premain("", inst);
+            return true;
+        } 
+        // If we successfully get the Instrumentation, we will call premain
+        // where loadAttempted will be set to true. This case is the path 
+        // where we were unable to get Instrumentation so we need to set the
+        // loadAttempted flag to true. We do this so we will only run
+        // through this code one time.
+        loadAttempted = true;
         return false;
     }
 
@@ -116,7 +116,7 @@ public class PCEnhancerAgent {
         // The agent will be disabled when running in an application
         // server.
         synchronized (PCEnhancerAgent.class) {
-            if (loadAttempted == true) {
+            if (loadAttempted) {
                 return;
             }
             // See the comment in loadDynamicAgent as to why we set this to true
@@ -128,15 +128,11 @@ public class PCEnhancerAgent {
 
         if (opts.containsKey("ClassLoadEnhancement") ||
             opts.containsKey("classLoadEnhancement")) {
-            if (opts.getBooleanProperty(
-                "ClassLoadEnhancement", "classLoadEnhancement", true))
+            if (opts.getBooleanProperty("ClassLoadEnhancement", "classLoadEnhancement", true))
                 registerClassLoadEnhancer(inst, opts);
-        }
-        else if (opts.containsKey("RuntimeEnhancement") ||
-            opts.containsKey("runtimeEnhancement")) {
+        } else if (opts.containsKey("RuntimeEnhancement") || opts.containsKey("runtimeEnhancement")) {
             // Deprecated property setting
-            if (opts.getBooleanProperty(
-                "RuntimeEnhancement", "runtimeEnhancement", true))
+            if (opts.getBooleanProperty("RuntimeEnhancement", "runtimeEnhancement", true))
                 registerClassLoadEnhancer(inst, opts);
         } else {
             // if neither is set, then we should be turning it on. We need this
@@ -145,8 +141,7 @@ public class PCEnhancerAgent {
             registerClassLoadEnhancer(inst, opts);
         }
 
-        if (opts.getBooleanProperty(
-            "RuntimeRedefinition", "runtimeRedefinition", true)) {
+        if (opts.getBooleanProperty("RuntimeRedefinition", "runtimeRedefinition", true)) {
             InstrumentationFactory.setInstrumentation(inst);
         } else {
             InstrumentationFactory.setDynamicallyInstallAgent(false);
@@ -154,10 +149,8 @@ public class PCEnhancerAgent {
         loadSuccessful = true;
     }
 
-    private static void registerClassLoadEnhancer(Instrumentation inst,
-        Options opts) {
-    	List<String> anchors = Configurations.
-            getFullyQualifiedAnchorsInPropertiesLocation(opts);
+    private static void registerClassLoadEnhancer(Instrumentation inst,  Options opts) {
+    	List<String> anchors = Configurations.getFullyQualifiedAnchorsInPropertiesLocation(opts);
     	for (String a : anchors) {
     		Options clonedOptions = (Options) opts.clone();
     		clonedOptions.setProperty("properties", a);
@@ -175,12 +168,7 @@ public class PCEnhancerAgent {
     		    .newTemporaryClassLoaderAction(AccessController
     		    .doPrivileged(J2DoPrivHelper.getContextClassLoaderAction())
     		    ));
-    		conf.setClassResolver(new ClassResolver() {
-    		    public ClassLoader getClassLoader(Class context,
-                    ClassLoader env) {
-    		        return tmpLoader;
-    		    }
-    		});
+    		conf.addClassLoader(tmpLoader);
     		conf.setReadOnly(Configuration.INIT_STATE_FREEZING);
     		conf.instantiateAll(); // avoid threading issues
 

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/ReflectingPersistenceCapable.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/ReflectingPersistenceCapable.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/ReflectingPersistenceCapable.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/ReflectingPersistenceCapable.java Sat Oct 29 00:44:11 2011
@@ -64,7 +64,7 @@ public class ReflectingPersistenceCapabl
         Class type = o.getClass();
         pcSubclassInstance = PCRegistry.newInstance(type, null, false);
         meta = conf.getMetaDataRepositoryInstance()
-            .getMetaData(type, null, true);
+            .getMetaData(type, true);
     }
 
     public int pcGetEnhancementContractVersion() {

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/instrumentation/InstrumentationManager.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/instrumentation/InstrumentationManager.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/instrumentation/InstrumentationManager.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/instrumentation/InstrumentationManager.java Sat Oct 29 00:44:11 2011
@@ -38,7 +38,7 @@ public interface InstrumentationManager 
      * @param conf the configuration to use for initialization
      * @param providers one or more providers as supplied via plugin list value
      */
-    public void initialize(OpenJPAConfiguration conf, PluginListValue providers);
+    public void initialize(OpenJPAConfiguration conf, PluginListValue<InstrumentationProvider> providers);
 
     /**
      * Manage a given provider.  This will plug the instruments managed by the 

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/instrumentation/InstrumentationManagerImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/instrumentation/InstrumentationManagerImpl.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/instrumentation/InstrumentationManagerImpl.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/instrumentation/InstrumentationManagerImpl.java Sat Oct 29 00:44:11 2011
@@ -43,9 +43,8 @@ public class InstrumentationManagerImpl 
      * @param conf
      * @param providers
      */
-    public void initialize(OpenJPAConfiguration conf, PluginListValue pluginVal) {
-        InstrumentationProvider[] providers = 
-            (InstrumentationProvider[])pluginVal.instantiate(InstrumentationProvider.class, conf);
+    public void initialize(OpenJPAConfiguration conf, PluginListValue<InstrumentationProvider> pluginVal) {
+        InstrumentationProvider[] providers = pluginVal.instantiate(conf);
         _providers.addAll(Arrays.asList(providers));
     }
     

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java Sat Oct 29 00:44:11 2011
@@ -105,7 +105,7 @@ public abstract class AbstractBrokerFact
     // cache the class names loaded from the persistent classes property so
     // that we can re-load them for each new broker
     private transient Collection<String> _pcClassNames = null;
-    private transient Collection<ClassLoader> _pcClassLoaders = null;
+//    private transient Collection<ClassLoader> _pcClassLoaders = null;
     private transient boolean _persistentTypesLoaded = false;
 
     // lifecycle listeners to pass to each broker
@@ -155,7 +155,6 @@ public abstract class AbstractBrokerFact
     protected AbstractBrokerFactory(OpenJPAConfiguration config) {
         _conf = config;
         _brokers = newBrokerSet();
-        getPcClassLoaders();
     }
 
     /**
@@ -235,7 +234,7 @@ public abstract class AbstractBrokerFact
         if (remote.areRemoteEventsEnabled())
             broker.addTransactionListener(remote);
 
-       loadPersistentTypes(broker.getClassLoader());
+       loadPersistentTypes();
         _brokers.add(broker);
         _conf.setReadOnly(Configuration.INIT_STATE_FROZEN);
     }
@@ -262,7 +261,7 @@ public abstract class AbstractBrokerFact
      * Load the configured persistent classes list. Performed automatically
      * whenever a broker is created.
      */
-    public void loadPersistentTypes(ClassLoader envLoader) {
+    public void loadPersistentTypes() {
         // if we've loaded the persistent types and the class name list
         // is empty, then we can simply return. Note that there is a
         // potential threading scenario in which _persistentTypesLoaded is
@@ -275,12 +274,11 @@ public abstract class AbstractBrokerFact
             return;
 
         // cache persistent type names if not already
-        ClassLoader loader = _conf.getClassResolverInstance().
-            getClassLoader(getClass(), envLoader);
+        ClassLoader loader = _conf.getClassLoader();
         Collection<Class<?>> toRedefine = new ArrayList<Class<?>>();
         if (!_persistentTypesLoaded) {
             Collection<Class<?>> clss = _conf.getMetaDataRepositoryInstance().
-                loadPersistentTypes(false, loader, _conf.isInitializeEagerly());
+                loadPersistentTypes(false, _conf.isInitializeEagerly());
             if (clss.isEmpty())
                 _pcClassNames = Collections.emptyList();
             else {
@@ -291,27 +289,27 @@ public abstract class AbstractBrokerFact
                     if (needsSub(cls))
                         toRedefine.add(cls);
                 }
-                getPcClassLoaders().add(loader);
+//                getPcClassLoaders().add(loader);
                 _pcClassNames = c;
             }
             _persistentTypesLoaded = true;
         } else {
             // reload with this loader
-            if (getPcClassLoaders().add(loader)) {
-                for (String clsName : _pcClassNames) {
-                    try {
-                        Class<?> cls = Class.forName(clsName, true, loader);
-                        if (needsSub(cls))
-                            toRedefine.add(cls);
-                    } catch (Throwable t) {
-                        _conf.getLog(OpenJPAConfiguration.LOG_RUNTIME).warn(null, t);
-                    }
-                }
-            }
+//            if (getPcClassLoaders().add(loader)) {
+//                for (String clsName : _pcClassNames) {
+//                    try {
+//                        Class<?> cls = Class.forName(clsName, true, loader);
+//                        if (needsSub(cls))
+//                            toRedefine.add(cls);
+//                    } catch (Throwable t) {
+//                        _conf.getLog(OpenJPAConfiguration.LOG_RUNTIME).warn(null, t);
+//                    }
+//                }
+//            }
         }
 
         // get the ManagedClassSubclasser into the loop
-        ManagedClassSubclasser.prepareUnenhancedClasses(_conf, toRedefine, envLoader);
+        ManagedClassSubclasser.prepareUnenhancedClasses(_conf, toRedefine);
     }
 
     private boolean needsSub(Class<?> cls) {
@@ -813,12 +811,12 @@ public abstract class AbstractBrokerFact
     /**
      * Method insures that deserialized EMF has this reference re-instantiated
      */
-    private Collection<ClassLoader> getPcClassLoaders() {
-       if (_pcClassLoaders == null)
-         _pcClassLoaders = new ConcurrentReferenceHashSet<ClassLoader>(ConcurrentReferenceHashSet.WEAK);
-          
-       return _pcClassLoaders;
-    }
+//    private Collection<ClassLoader> getPcClassLoaders() {
+//       if (_pcClassLoaders == null)
+//         _pcClassLoaders = new ConcurrentReferenceHashSet<ClassLoader>(ConcurrentReferenceHashSet.WEAK);
+//          
+//       return _pcClassLoaders;
+//    }
 
     /**
      * <P>
@@ -861,14 +859,13 @@ public abstract class AbstractBrokerFact
         }
         // Don't catch any exceptions here because we want to fail-fast if something bad happens when we're preloading.
         Options o = Configurations.parseProperties(Configurations.getProperties(_conf.getMetaDataRepository()));
-        if (MetaDataRepository.needsPreload(o) == true) {
+        if (MetaDataRepository.needsPreload(o)) {
             MetaDataRepository mdr = _conf.getMetaDataRepositoryInstance();
             mdr.setValidate(MetaDataRepository.VALIDATE_RUNTIME, true);
             mdr.setResolve(MetaDataRepository.MODE_MAPPING_INIT, true);
 
             // Load persistent classes and hook in subclasser
-            loadPersistentTypes((ClassLoader) AccessController.doPrivileged(J2DoPrivHelper
-                .getContextClassLoaderAction()));
+            loadPersistentTypes();
             mdr.preload();
         }
 

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractPCResultObjectProvider.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractPCResultObjectProvider.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractPCResultObjectProvider.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractPCResultObjectProvider.java Sat Oct 29 00:44:11 2011
@@ -62,13 +62,10 @@ public abstract class AbstractPCResultOb
         load(sm, fetch);
     }
 
-    public Object getResultObject()
-        throws Exception {
-        Class type = getPCType();
-        MetaDataRepository repos = ctx.getConfiguration().
-            getMetaDataRepositoryInstance();
-        ClassMetaData meta = repos.getMetaData
-            (type, ctx.getClassLoader(), true);
+    public Object getResultObject() throws Exception {
+        Class<?> type = getPCType();
+        MetaDataRepository repos = ctx.getConfiguration().getMetaDataRepositoryInstance();
+        ClassMetaData meta = repos.getMetaData(type, true);
 
         Object oid = getObjectId(meta);
         Object res = ctx.find(oid, null, null, this, 0);
@@ -81,30 +78,25 @@ public abstract class AbstractPCResultOb
      * Implement this method to extract the object id value from the
      * current record of the input.
      */
-    protected abstract Object getObjectId(ClassMetaData meta)
-        throws Exception;
+    protected abstract Object getObjectId(ClassMetaData meta) throws Exception;
 
     /**
      * Implement this method to extract the type of the pc stored
      * in the current record of the input.
      */
-    protected abstract Class getPCType()
-        throws Exception;
+    protected abstract Class<?> getPCType() throws Exception;
 
     /**
      * Load data from the current input record into the given state
      * manager. Remember to call {@link OpenJPAStateManager#setVersion} to set
      * the optimistic versioning information, if it has any.
      */
-    protected abstract void load(OpenJPAStateManager sm, 
-        FetchConfiguration fetch)
-        throws Exception;
+    protected abstract void load(OpenJPAStateManager sm, FetchConfiguration fetch) throws Exception;
 
     /**
      * Override if desired. Does nothing by default.
      */
-    public void open()
-        throws Exception {
+    public void open() throws Exception {
     }
 
     /**
@@ -121,16 +113,14 @@ public abstract class AbstractPCResultOb
      *
      * @see ResultObjectProvider#next
      */
-    public abstract boolean next()
-        throws Exception;
+    public abstract boolean next() throws Exception;
 
     /**
      * Override if desired. Throws an exception by default.
      *
      * @see ResultObjectProvider#absolute
      */
-    public boolean absolute(int pos)
-        throws Exception {
+    public boolean absolute(int pos) throws Exception {
         throw new UnsupportedOperationException();
     }
 
@@ -139,8 +129,7 @@ public abstract class AbstractPCResultOb
      *
      * @see ResultObjectProvider#size
      */
-    public int size()
-        throws Exception {
+    public int size() throws Exception {
         return Integer.MAX_VALUE;
     }
 
@@ -149,8 +138,7 @@ public abstract class AbstractPCResultOb
      *
      * @see ResultObjectProvider#reset
      */
-    public void reset()
-        throws Exception {
+    public void reset() throws Exception {
         throw new UnsupportedOperationException();
     }
 
@@ -159,8 +147,7 @@ public abstract class AbstractPCResultOb
      *
      * @see ResultObjectProvider#close
      */
-    public void close()
-        throws Exception {
+    public void close() throws Exception {
     }
 
     /**

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AttachManager.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AttachManager.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AttachManager.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AttachManager.java Sat Oct 29 00:44:11 2011
@@ -247,8 +247,7 @@ public class AttachManager {
         //### need to handle ACT_RUN without also ACT_CASCADE
         ClassMetaData meta = _broker.getConfiguration().
             getMetaDataRepositoryInstance().getMetaData(
-                ImplHelper.getManagedInstance(toAttach).getClass(),
-                _broker.getClassLoader(), true);
+                ImplHelper.getManagedInstance(toAttach).getClass(), true);
         return getStrategy(toAttach).attach(this, toAttach, meta, into,
             owner, ownerMeta, explicit);
     }

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/Bootstrap.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/Bootstrap.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/Bootstrap.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/Bootstrap.java Sat Oct 29 00:44:11 2011
@@ -39,11 +39,7 @@ import org.apache.openjpa.util.UserExcep
  */
 public class Bootstrap {
 
-    private static final Class<?>[] CONFIGURATION_ARG =
-        new Class<?>[]{ ConfigurationProvider.class };
-    
-    private static final Class<?>[] CONFIGURATION_CLASSLOADER_ARGS =
-        new Class<?>[] { ConfigurationProvider.class, ClassLoader.class };
+    private static final Class<?>[] CONFIGURATION_ARG = { ConfigurationProvider.class };
 
     private static Localizer s_loc = Localizer.forPackage(Bootstrap.class);
 
@@ -51,30 +47,24 @@ public class Bootstrap {
      * Return a new factory for the default configuration.
      */
     public static BrokerFactory newBrokerFactory() {
-        return Bootstrap.newBrokerFactory(null, null);
+        return Bootstrap.newBrokerFactory(null);
     }
 
     /**
-     * Return a new factory for the given configuration. The classloader
-     * will be used to load the factory class. If no classloader is given,
-     * the thread's context classloader is used.
+     * Return a new factory for the given configuration. 
      */
-    public static BrokerFactory newBrokerFactory(ConfigurationProvider conf,
-        ClassLoader loader) {
+    public static BrokerFactory newBrokerFactory(ConfigurationProvider conf) {
         try {
-            BrokerFactory factory =
-                invokeFactory(conf, loader, "newInstance", CONFIGURATION_ARG, new Object[] { conf });
+            BrokerFactory factory = invokeFactory(conf, "newInstance", CONFIGURATION_ARG, new Object[] { conf });
             factory.postCreationCallback();
             return factory;
         } catch (InvocationTargetException ite) {
             Throwable cause = ite.getTargetException();
             if (cause instanceof OpenJPAException)
                 throw (OpenJPAException) cause;
-            throw new InternalException(s_loc.get("new-brokerfactory-excep",
-                getFactoryClassName(conf, loader)), cause);
+            throw new InternalException(s_loc.get("new-brokerfactory-excep", getFactoryClassName(conf), cause));
         } catch (Exception e) {
-            throw new UserException(s_loc.get("bad-new-brokerfactory",
-                getFactoryClassName(conf, loader)), e).setFatal(true);
+            throw new UserException(s_loc.get("bad-new-brokerfactory", getFactoryClassName(conf)), e).setFatal(true);
         }
     }
 
@@ -82,59 +72,41 @@ public class Bootstrap {
      * Return a pooled factory for the default configuration.
      */
     public static BrokerFactory getBrokerFactory() {
-        return Bootstrap.getBrokerFactory(null, null);
+        return Bootstrap.getBrokerFactory(null);
     }
 
     /**
-     * Return a pooled factory for the given configuration. The classloader
-     * will be used to load the factory class. If no classloader is given,
-     * the thread's context classloader is used.
+     * Return a pooled factory for the given configuration. 
      */
-    public static BrokerFactory getBrokerFactory(ConfigurationProvider conf,
-        ClassLoader loader) {
+    public static BrokerFactory getBrokerFactory(ConfigurationProvider conf) {
         try {
-            return invokeFactory(conf, loader, "getInstance", CONFIGURATION_CLASSLOADER_ARGS, new Object[] { conf,
-                loader });
+            return invokeFactory(conf, "getInstance", CONFIGURATION_ARG, new Object[] { conf});
         } catch (InvocationTargetException ite) {
             Throwable cause = ite.getTargetException();
             if (cause instanceof OpenJPAException)
                 throw (OpenJPAException) cause;
-            throw new InternalException(s_loc.get("brokerfactory-excep",
-                getFactoryClassName(conf, loader)), cause);
+            throw new InternalException(s_loc.get("brokerfactory-excep", getFactoryClassName(conf)), cause);
         } catch (Exception e) {
-            throw new UserException(s_loc.get("bad-brokerfactory",
-                getFactoryClassName(conf, loader)), e).setFatal(true);
+            throw new UserException(s_loc.get("bad-brokerfactory", getFactoryClassName(conf)), e).setFatal(true);
         }
     }
 
-    private static BrokerFactory invokeFactory(ConfigurationProvider conf,
-        ClassLoader loader, String methodName, Class<?>[] argTypes, Object[] args)
-        throws InvocationTargetException, NoSuchMethodException,
-            IllegalAccessException {
+    private static BrokerFactory invokeFactory(ConfigurationProvider conf, String methodName, 
+    		Class<?>[] argTypes, Object[] args)
+        throws InvocationTargetException, NoSuchMethodException, IllegalAccessException {
         if (conf == null)
             conf = new MapConfigurationProvider();
         ProductDerivations.beforeConfigurationConstruct(conf);
 
-        Class cls = getFactoryClass(conf, loader);
-        Method meth;
-        try {
-            meth = cls.getMethod(methodName, argTypes); 
-        } catch (NoSuchMethodException nsme) {
-            // handle cases where there is a mismatch between loaders by falling
-            // back to the configuration's class loader for broker resolution
-            cls = getFactoryClass(conf,
-                AccessController.doPrivileged(
-                    J2DoPrivHelper.getClassLoaderAction(conf.getClass()))); 
-            meth = cls.getMethod(methodName, argTypes); 
-        }
+        Class<?> cls = getFactoryClass(conf);
+        Method meth = cls.getMethod(methodName, argTypes); 
 
         return (BrokerFactory) meth.invoke(null, args);
     }
 
-    private static String getFactoryClassName(ConfigurationProvider conf,
-        ClassLoader loader) {
+    private static String getFactoryClassName(ConfigurationProvider conf) {
         try {
-            return getFactoryClass(conf, loader).getName();
+            return getFactoryClass(conf).getName();
         } catch (Exception e) {
             return "<" + e.toString() + ">";
         }
@@ -143,28 +115,21 @@ public class Bootstrap {
     /**
      * Instantiate the factory class designated in properties.
      */
-    private static Class getFactoryClass(ConfigurationProvider conf,
-        ClassLoader loader) {
-        if (loader == null)
-            loader = AccessController.doPrivileged(
-                J2DoPrivHelper.getContextClassLoaderAction()); 
-
+    private static Class<?> getFactoryClass(ConfigurationProvider conf) {
         Object cls = BrokerFactoryValue.get(conf);
         if (cls instanceof Class)
-            return (Class) cls;
+            return (Class<?>) cls;
 
         BrokerFactoryValue value = new BrokerFactoryValue();
         value.setString((String) cls);
         String clsName = value.getClassName();
         if (clsName == null)
-            throw new UserException(s_loc.get("no-brokerfactory", 
-                conf.getProperties())).setFatal(true);
+            throw new UserException(s_loc.get("no-brokerfactory", conf.getProperties())).setFatal(true);
 
         try {
-            return Class.forName(clsName, true, loader);
+            return Class.forName(clsName, true, conf.getClassLoader());
         } catch (Exception e) {
-            throw new UserException(s_loc.get("bad-brokerfactory-class",
-                clsName), e).setFatal(true);
+            throw new UserException(s_loc.get("bad-brokerfactory-class", clsName), e).setFatal(true);
 		}
 	}
 }

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/Broker.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/Broker.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/Broker.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/Broker.java Sat Oct 29 00:44:11 2011
@@ -53,8 +53,7 @@ public interface Broker
      * after the first invocation with non-null arguments,
      * subsequent invocations of this method are ignored.
      */
-    public void setImplicitBehavior(OpCallbacks call,
-        RuntimeExceptionTranslator ex);
+    public void setImplicitBehavior(OpCallbacks call, RuntimeExceptionTranslator ex);
 
     /**
      * Return the factory that produced this broker.
@@ -288,7 +287,7 @@ public interface Broker
      *
      * @since 0.3.3
      */
-    public void addLifecycleListener(Object listener, Class[] classes);
+    public void addLifecycleListener(Object listener, Class<?>[] classes);
 
     /**
      * Remove a listener for lifecycle-related events.
@@ -469,7 +468,7 @@ public interface Broker
     /**
      * Persist the given objects.
      */
-    public void persistAll(Collection objs, OpCallbacks call);
+    public void persistAll(Collection<?> objs, OpCallbacks call);
 
     /**
      * Make the given instance persistent. Unlike other persist operations,
@@ -490,7 +489,7 @@ public interface Broker
     /**
      * Delete the given objects.
      */
-    public void deleteAll(Collection objs, OpCallbacks call);
+    public void deleteAll(Collection<?> objs, OpCallbacks call);
 
     /**
      * Release the given object from management. This operation is not
@@ -502,7 +501,7 @@ public interface Broker
      * Release the given objects from management. This operation is not
      * recursive.
      */
-    public void releaseAll(Collection objs, OpCallbacks call);
+    public void releaseAll(Collection<?> objs, OpCallbacks call);
 
     /**
      * Refresh the state of the given object.
@@ -512,7 +511,7 @@ public interface Broker
     /**
      * Refresh the state of the given objects.
      */
-    public void refreshAll(Collection objs, OpCallbacks call);
+    public void refreshAll(Collection<?> objs, OpCallbacks call);
 
     /**
      * Evict the given object.
@@ -522,7 +521,7 @@ public interface Broker
     /**
      * Evict the given objects.
      */
-    public void evictAll(Collection objs, OpCallbacks call);
+    public void evictAll(Collection<?> objs, OpCallbacks call);
 
     /**
      * Evict all clean objects.
@@ -533,7 +532,7 @@ public interface Broker
      * Evict all persistent-clean and persistent-nontransactional
      * instances in the given {@link Extent}.
      */
-    public void evictAll(Extent extent, OpCallbacks call);
+    public void evictAll(Extent<?> extent, OpCallbacks call);
 
     /**
      * Detach all objects in place.  A flush will be performed before
@@ -573,7 +572,7 @@ public interface Broker
      * @param objs the instances to detach
      * @return the detached instances
      */
-    public Object[] detachAll(Collection objs, OpCallbacks call);
+    public Object[] detachAll(Collection<?> objs, OpCallbacks call);
 
     /**
      * Import the specified detached object into the broker.
@@ -594,8 +593,7 @@ public interface Broker
      * @return the re-attached instances
      * @param copyNew whether to copy new instances
      */
-    public Object[] attachAll(Collection objs, boolean copyNew,
-        OpCallbacks call);
+    public Object[] attachAll(Collection<?> objs, boolean copyNew,  OpCallbacks call);
 
     /**
      * Create a new instance of type <code>cls</code>. If <code>cls</code> is
@@ -608,7 +606,7 @@ public interface Broker
      * @throws IllegalArgumentException if <code>cls</code> is not a managed
      * type or interface.
      */
-    public Object newInstance(Class cls);
+    public Object newInstance(Class<?> cls);
 
     /**
      * Returns <code>true</code> if <code>obj</code> is a detached object
@@ -620,13 +618,13 @@ public interface Broker
     /**
      * Return an extent of the given class, optionally including subclasses.
      */
-    public Extent newExtent(Class cls, boolean subs);
+    public <T> Extent<T> newExtent(Class<T> cls, boolean subs);
 
     /**
      * Create a new query from the given data, with the given candidate class
      * and language.
      */
-    public Query newQuery(String language, Class cls, Object query);
+    public Query newQuery(String language, Class<?> cls, Object query);
 
     /**
      * Create a new query in the given language.
@@ -674,8 +672,7 @@ public interface Broker
      * giving up, or -1 for no limit
      * @since 0.3.1
      */
-    public void lockAll(Collection objs, int level, int timeout,
-        OpCallbacks call);
+    public void lockAll(Collection<?> objs, int level, int timeout, OpCallbacks call);
 
     /**
      * Ensure that the given instances are locked at the current lock level, as
@@ -683,7 +680,7 @@ public interface Broker
      *
      * @since 0.3.1
      */
-    public void lockAll(Collection objs, OpCallbacks call);
+    public void lockAll(Collection<?> objs, OpCallbacks call);
 
     /**
      * Cancel all pending data store statements. If statements are cancelled
@@ -700,7 +697,7 @@ public interface Broker
      *
      * @since 0.3.0
      */
-    public void dirtyType(Class cls);
+    public void dirtyType(Class<?> cls);
 
     /**
      * Begin a logical operation. This indicates to the broker the

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java Sat Oct 29 00:44:11 2011
@@ -180,9 +180,6 @@ public class BrokerImpl
     private transient OpenJPAConfiguration _conf = null;
     private transient MetaDataRepository _repo = null;
 
-    // cache class loader associated with the broker
-    private transient ClassLoader _loader = null;
-
     // user state
     private Synchronization _sync = null;
     private Map<Object, Object> _userObjects = null;
@@ -329,8 +326,6 @@ public class BrokerImpl
         boolean fromDeserialization, boolean fromWriteBehindCallback) {
         _fromWriteBehindCallback = fromWriteBehindCallback;
         _initializeWasInvoked = true;
-        _loader = AccessController.doPrivileged(
-            J2DoPrivHelper.getContextClassLoaderAction());
         if (!fromDeserialization){
             _conf = factory.getConfiguration();
             _repo = _conf.getMetaDataRepositoryInstance();
@@ -487,10 +482,6 @@ public class BrokerImpl
         return _runtime;
     }
 
-    public ClassLoader getClassLoader() {
-        return _loader;
-    }
-
     public DelegatingStoreManager getStoreManager() {
         return _store;
     }
@@ -744,7 +735,7 @@ public class BrokerImpl
     // Events
     // ////////
 
-    public void addLifecycleListener(Object listener, Class[] classes) {
+    public void addLifecycleListener(Object listener, Class<?>[] classes) {
         beginOperation(false);
         try {
             _lifeEventManager.addListener(listener, classes);
@@ -1041,23 +1032,22 @@ public class BrokerImpl
         return sm;
     }
 
-    public Object[] findAll(Collection oids, boolean validate,
-        FindCallbacks call) {
+    public Object[] findAll(Collection<?> oids, boolean validate, FindCallbacks call) {
         int flags = OID_COPY | OID_ALLOW_NEW | OID_NODELETED;
-        if (!validate)
+        if (!validate) {
             flags |= OID_NOVALIDATE;
+        }
         return findAll(oids, _fc, null, null, flags, call);
     }
 
-    public Object[] findAll(Collection oids, FetchConfiguration fetch,
-        BitSet exclude, Object edata, int flags) {
+    public Object[] findAll(Collection<?> oids, FetchConfiguration fetch, BitSet exclude, Object edata, int flags) {
         return findAll(oids, fetch, exclude, edata, flags, null);
     }
 
     /**
      * Internal finder.
      */
-    protected Object[] findAll(Collection oids, FetchConfiguration fetch,
+    protected Object[] findAll(Collection<?> oids, FetchConfiguration fetch,
         BitSet exclude, Object edata, int flags, FindCallbacks call) {
         findAllDepth ++;
 
@@ -1120,10 +1110,8 @@ public class BrokerImpl
             // pass all state managers in need of loading or validation to the
             // store manager
             if (load != null) {
-                PCState state = (transState) ? PCState.PCLEAN
-                    : PCState.PNONTRANS;
-                Collection<Object> failed = _store.loadAll(load, state,
-                    StoreManager.FORCE_LOAD_NONE, fetch, edata);
+                PCState state = (transState) ? PCState.PCLEAN : PCState.PNONTRANS;
+                Collection<Object> failed = _store.loadAll(load, state, StoreManager.FORCE_LOAD_NONE, fetch, edata);
 
                 // set failed instances to null
                 if (failed != null && !failed.isEmpty()) {
@@ -1235,7 +1223,7 @@ public class BrokerImpl
 
         beginOperation(false);
         try {
-            ClassMetaData meta = _repo.getMetaData(cls, _loader, false);
+            ClassMetaData meta = _repo.getMetaData(cls, false);
             if (meta == null
                 || meta.getIdentityType() == ClassMetaData.ID_UNKNOWN)
                 return null;
@@ -1258,7 +1246,7 @@ public class BrokerImpl
 
         beginOperation(false);
         try {
-            ClassMetaData meta = _repo.getMetaData(cls, _loader, true);
+            ClassMetaData meta = _repo.getMetaData(cls, true);
             switch (meta.getIdentityType()) {
             case ClassMetaData.ID_DATASTORE:
                 // delegate to store manager for datastore ids
@@ -1320,9 +1308,9 @@ public class BrokerImpl
         Class<?> pcType = _store.getManagedType(oid);
         ClassMetaData meta;
         if (pcType != null)
-            meta = _repo.getMetaData(pcType, _loader, true);
+            meta = _repo.getMetaData(pcType, true);
         else
-            meta = _repo.getMetaData(oid, _loader, true);
+            meta = _repo.getMetaData(oid, true);
 
         // copy the oid if needed
         if (copy && _compat.getCopyObjectIds()) {
@@ -2087,7 +2075,7 @@ public class BrokerImpl
     protected void flush(int reason) {
         // this will enlist proxied states as necessary so we know whether we
         // have anything to flush
-        Collection transactional = getTransactionalStates();
+        Collection<StateManagerImpl> transactional = getTransactionalStates();
 
         // do we actually have to flush?  only if our flags say so, or if
         // we have transaction listeners that need to be invoked for commit
@@ -2102,13 +2090,14 @@ public class BrokerImpl
         if (!flush && (reason != FLUSH_COMMIT || !listeners))
             return;
 
-        Collection mobjs = null;
+        ManagedObjectCollection mobjs = null;
         _flags |= FLAG_PRESTORING;
         try {
             if (flush) {
                 // call pre store on all currently transactional objs
-                for (Iterator itr = transactional.iterator(); itr.hasNext();)
-                    ((StateManagerImpl) itr.next()).beforeFlush(reason, _call);
+                for (StateManagerImpl sm : transactional) {
+                    sm.beforeFlush(reason, _call);
+                }
                 flushAdditions(transactional, reason);
             }
 
@@ -2183,9 +2172,7 @@ public class BrokerImpl
 
             // mark states as flushed
             if (flush) {
-                StateManagerImpl sm;
-                for (Iterator itr = transactional.iterator(); itr.hasNext();) {
-                    sm = (StateManagerImpl) itr.next();
+                for (StateManagerImpl sm : transactional) {
                     try {
                         // the state may have become transient, such as if
                         // it is embedded and the owner has been deleted during
@@ -2223,7 +2210,7 @@ public class BrokerImpl
     /**
      * Flush newly-transactional objects.
      */
-    private void flushAdditions(Collection transactional, int reason) {
+    private void flushAdditions(Collection<StateManagerImpl> transactional, int reason) {
         boolean loop;
         do {
             // flush new transactional instances; note logical or
@@ -2235,7 +2222,7 @@ public class BrokerImpl
     /**
      * Flush transactional additions.
      */
-    private boolean flushTransAdditions(Collection transactional, int reason) {
+    private boolean flushTransAdditions(Collection<StateManagerImpl> transactional, int reason) {
         if (_transAdditions == null || _transAdditions.isEmpty())
             return false;
 
@@ -2243,8 +2230,7 @@ public class BrokerImpl
         transactional.addAll(_transAdditions);
 
         // copy the change set, then clear it for the next iteration
-        StateManagerImpl[] states = (StateManagerImpl[]) _transAdditions.
-            toArray(new StateManagerImpl[_transAdditions.size()]);
+        StateManagerImpl[] states = _transAdditions.toArray(new StateManagerImpl[_transAdditions.size()]);
         _transAdditions = null;
 
         for (int i = 0; i < states.length; i++)
@@ -2255,15 +2241,14 @@ public class BrokerImpl
     /**
      * Delete new dereferenced objects.
      */
-    private boolean deleteDerefAdditions(Collection derefs) {
+    private boolean deleteDerefAdditions(Collection<StateManagerImpl> derefs) {
         if (_derefAdditions == null || _derefAdditions.isEmpty())
             return false;
 
         // remember these additions in case one becomes derefed again later
         derefs.addAll(_derefAdditions);
 
-        StateManagerImpl[] states = (StateManagerImpl[]) _derefAdditions.
-            toArray(new StateManagerImpl[_derefAdditions.size()]);
+        StateManagerImpl[] states = _derefAdditions.toArray(new StateManagerImpl[_derefAdditions.size()]);
         _derefAdditions = null;
 
         for (int i = 0; i < states.length; i++)
@@ -2275,8 +2260,7 @@ public class BrokerImpl
      * Delete a dereferenced dependent.
      */
     private void deleteDeref(StateManagerImpl sm) {
-        int action = processArgument(OpCallbacks.OP_DELETE,
-            sm.getManagedInstance(), sm, null);
+        int action = processArgument(OpCallbacks.OP_DELETE, sm.getManagedInstance(), sm, null);
         if ((action & OpCallbacks.ACT_RUN) != 0)
             sm.delete();
         if ((action & OpCallbacks.ACT_CASCADE) != 0)
@@ -2287,8 +2271,7 @@ public class BrokerImpl
      * Determine the action to take based on the user's given callbacks and
      * our implicit behavior.
      */
-    private int processArgument(int op, Object obj, OpenJPAStateManager sm,
-        OpCallbacks call) {
+    private int processArgument(int op, Object obj, OpenJPAStateManager sm, OpCallbacks call) {
         if (call != null)
             return call.processArgument(op, obj, sm);
         if (_call != null)
@@ -2358,14 +2341,15 @@ public class BrokerImpl
         _fc.setWriteLockLevel(LOCK_NONE);
         _fc.setLockTimeout(-1);
 
-        Collection transStates;
-        if (hasTransactionalObjects())
+        TransactionalCache transStates;
+        if (hasTransactionalObjects()) {
             transStates = _transCache;
-        else
-            transStates = Collections.EMPTY_SET;
+        } else {
+        	transStates = new TransactionalCache(true);
+        }
 
         // fire after rollback/commit event
-        Collection mobjs = null;
+        ManagedObjectCollection mobjs = null;
         if (_transEventManager.hasEndListeners()) {
             mobjs = new ManagedObjectCollection(transStates);
             int eventType = (rollback) ? TransactionEvent.AFTER_ROLLBACK
@@ -2400,9 +2384,7 @@ public class BrokerImpl
         }
 
         // perform commit or rollback state transitions on each instance
-        StateManagerImpl sm;
-        for (Iterator itr = transStates.iterator(); itr.hasNext();) {
-            sm = (StateManagerImpl) itr.next();
+        for (StateManagerImpl sm : transStates) {
             try {
                 if (rollback) {
                     // tell objects that may have been derefed then flushed
@@ -2462,7 +2444,7 @@ public class BrokerImpl
         return persist(obj, id, true, call);
     }
 
-    public void persistAll(Collection objs, OpCallbacks call) {
+    public void persistAll(Collection<?> objs, OpCallbacks call) {
         persistAll(objs, true, call);
     }
 
@@ -2470,7 +2452,7 @@ public class BrokerImpl
      * Persist the given objects.  Indicate whether this was an explicit persist
      * (PNEW) or a provisonal persist (PNEWPROVISIONAL).
      */
-    public void persistAll(Collection objs, boolean explicit, 
+    public void persistAll(Collection<?> objs, boolean explicit, 
         OpCallbacks call) {
         if (objs.isEmpty())
             return;
@@ -2629,7 +2611,7 @@ public class BrokerImpl
             }
         }
 
-        ClassMetaData meta = _repo.getMetaData(obj.getClass(), _loader, true);
+        ClassMetaData meta = _repo.getMetaData(obj.getClass(), true);
         if (fireEvent) {
             fireLifecycleEvent(obj, null, meta, LifecycleEvent.BEFORE_PERSIST);
         }
@@ -2683,7 +2665,7 @@ public class BrokerImpl
         if (pc.pcGetStateManager() != null)
             throw newDetachedException(obj, errOp);
 
-        ClassMetaData meta = _repo.getMetaData(obj.getClass(), _loader, true);
+        ClassMetaData meta = _repo.getMetaData(obj.getClass(), true);
         StateManagerImpl sm = newStateManagerImpl(StateManagerId.
             newInstance(this), meta);
         sm.initialize(pc, PCState.TLOADED);
@@ -2707,7 +2689,7 @@ public class BrokerImpl
         }
     }
 
-    public void deleteAll(Collection objs, OpCallbacks call) {
+    public void deleteAll(Collection<?> objs, OpCallbacks call) {
         beginOperation(true);
         try {
             assertWriteOperation();
@@ -2804,7 +2786,7 @@ public class BrokerImpl
             Exceptions.toString(obj))).setFailedObject(obj);
     }
 
-    public void releaseAll(Collection objs, OpCallbacks call) {
+    public void releaseAll(Collection<?> objs, OpCallbacks call) {
         beginOperation(false);
         try {
             List<Exception> exceps = null;
@@ -2947,7 +2929,7 @@ public class BrokerImpl
             if (sm == null) {
                 MetaDataRepository repos = _conf.
                     getMetaDataRepositoryInstance();
-                ClassMetaData meta = repos.getMetaData(type, _loader, true);
+                ClassMetaData meta = repos.getMetaData(type, true);
                 // construct a new state manager with all info known
                 sm = newStateManagerImpl(oid, meta);
                 sm.setObjectId(oid);
@@ -2959,7 +2941,7 @@ public class BrokerImpl
         }
     }
     
-    public void refreshAll(Collection objs, OpCallbacks call) {
+    public void refreshAll(Collection<?> objs, OpCallbacks call) {
         if (objs == null || objs.isEmpty())
             return;
 
@@ -3025,7 +3007,7 @@ public class BrokerImpl
      * This method is called with the full set of objects reachable via
      * cascade-refresh relations from the user-given instances.
      */
-    protected void refreshInternal(Collection objs, OpCallbacks call) {
+    protected void refreshInternal(Collection<?> objs, OpCallbacks call) {
     	if (objs == null || objs.isEmpty())
     		return;
         List<Exception> exceps = null;
@@ -3142,8 +3124,7 @@ public class BrokerImpl
     }
     
     
-    public void retrieveAll(Collection objs, boolean dfgOnly,
-        OpCallbacks call) {
+    public void retrieveAll(Collection<?> objs, boolean dfgOnly, OpCallbacks call) {
         if (objs == null || objs.isEmpty())
             return;
         if (objs.size() == 1) {
@@ -3279,7 +3260,7 @@ public class BrokerImpl
         }
     }
 
-    public void evictAll(Collection objs, OpCallbacks call) {
+    public void evictAll(Collection<?> objs, OpCallbacks call) {
         List<Exception> exceps = null;
         beginOperation(false);
         try {
@@ -3296,7 +3277,7 @@ public class BrokerImpl
         throwNestedExceptions(exceps, false);
     }
 
-    public void evictAll(Extent extent, OpCallbacks call) {
+    public void evictAll(Extent<?> extent, OpCallbacks call) {
         if (extent == null)
             return;
 
@@ -3368,7 +3349,7 @@ public class BrokerImpl
         }
     }
 
-    public Object[] detachAll(Collection objs, OpCallbacks call) {
+    public Object[] detachAll(Collection<?> objs, OpCallbacks call) {
         if (objs == null)
             return null;
         if (objs.isEmpty())
@@ -3485,8 +3466,7 @@ public class BrokerImpl
         }
     }
 
-    public Object[] attachAll(Collection objs, boolean copyNew,
-        OpCallbacks call) {
+    public Object[] attachAll(Collection<?> objs, boolean copyNew, OpCallbacks call) {
         if (objs == null)
             return null;
         if (objs.isEmpty())
@@ -3512,7 +3492,7 @@ public class BrokerImpl
         }
     }
 
-    public void nontransactionalAll(Collection objs, OpCallbacks call) {
+    public void nontransactionalAll(Collection<?> objs, OpCallbacks call) {
         beginOperation(true);
         try {
             List<Exception> exceps = null;
@@ -3553,7 +3533,7 @@ public class BrokerImpl
     /**
      * Make the given instances transactional.
      */
-    public void transactionalAll(Collection objs, boolean updateVersion,
+    public void transactionalAll(Collection<?> objs, boolean updateVersion,
         OpCallbacks call) {
         if (objs.isEmpty())
             return;
@@ -3585,7 +3565,7 @@ public class BrokerImpl
 
                     if (sm == null) {
                         // manage transient instance
-                        meta = _repo.getMetaData(obj.getClass(), _loader, true);
+                        meta = _repo.getMetaData(obj.getClass(), true);
 
                         sm = newStateManagerImpl
                             (StateManagerId.newInstance(this), meta);
@@ -3656,7 +3636,7 @@ public class BrokerImpl
                 _flags |= FLAG_FLUSH_REQUIRED; // version check/up
             } else if (sm == null) {
                 // manage transient instance
-                ClassMetaData meta = _repo.getMetaData(obj.getClass(), _loader, true);
+                ClassMetaData meta = _repo.getMetaData(obj.getClass(), true);
                 Object id = StateManagerId.newInstance(this);
                 sm = newStateManagerImpl(id, meta);
                 sm.initialize(assertPersistenceCapable(obj),
@@ -3675,12 +3655,10 @@ public class BrokerImpl
     /**
      * Transition the given state managers to transactional.
      */
-    private void transactionalStatesAll(Collection sms, Collection failed,
-        List<Exception> exceps) {
+    private void transactionalStatesAll(Collection<StateManagerImpl> sms, Collection<?> failed, 
+    		List<Exception> exceps) {
         // make instances transactional and make sure they are loaded
-        StateManagerImpl sm;
-        for (Iterator<?> itr = sms.iterator(); itr.hasNext();) {
-            sm = (StateManagerImpl) itr.next();
+        for (StateManagerImpl sm : sms) {
             if (failed != null && failed.contains(sm.getId()))
                 continue;
 
@@ -3698,15 +3676,14 @@ public class BrokerImpl
     // Extent, Query
     /////////////////
 
-    public Extent newExtent(Class type, boolean subclasses) {
+    public <T> Extent<T> newExtent(Class<T> type, boolean subclasses) {
         return newExtent(type, subclasses, null);
     }
 
-    private Extent newExtent(Class type, boolean subclasses,
-        FetchConfiguration fetch) {
+    private <T> Extent<T> newExtent(Class<T> type, boolean subclasses, FetchConfiguration fetch) {
         beginOperation(true);
         try {
-            ExtentImpl extent = new ExtentImpl(this, type, subclasses, fetch);
+            ExtentImpl<T> extent = new ExtentImpl<T>(this, type, subclasses, fetch);
             if (_extents == null)
                 _extents = new ReferenceHashSet(ReferenceHashSet.WEAK);
             _extents.add(extent);
@@ -3721,14 +3698,14 @@ public class BrokerImpl
         }
     }
 
-    public Iterator extentIterator(Class type, boolean subclasses,
-        FetchConfiguration fetch, boolean ignoreChanges) {
-        Extent extent = newExtent(type, subclasses, fetch);
+    public <T> Iterator<T> extentIterator(Class<T> type, boolean subclasses,
+    		FetchConfiguration fetch, boolean ignoreChanges) {
+        Extent<T> extent = newExtent(type, subclasses, fetch);
         extent.setIgnoreChanges(ignoreChanges);
         return extent.iterator();
     }
 
-    public Query newQuery(String lang, Class cls, Object query) {
+    public Query newQuery(String lang, Class<?> cls, Object query) {
         Query q = newQuery(lang, query);
         q.setCandidateType(cls, true);
         return q;
@@ -3815,7 +3792,7 @@ public class BrokerImpl
                 SequenceMetaData smd = (fmd == null)
                     ? meta.getIdentitySequenceMetaData()
                     : fmd.getValueSequenceMetaData();
-                return smd.getInstance(_loader);
+                return smd.getInstance();
             default:
                 // use store manager for native sequence
                 if (fmd == null) {
@@ -3834,7 +3811,7 @@ public class BrokerImpl
                     }
 
                     if (smd != null) {
-                        return smd.getInstance(_loader);
+                        return smd.getInstance();
                     } else {
                         return _store.getDataStoreIdSequence(meta);
                     }
@@ -3885,7 +3862,7 @@ public class BrokerImpl
         }
     }
 
-    public void lockAll(Collection objs, OpCallbacks call) {
+    public void lockAll(Collection<?> objs, OpCallbacks call) {
         if (objs.isEmpty())
             return;
 
@@ -3898,8 +3875,7 @@ public class BrokerImpl
         }
     }
 
-    public void lockAll(Collection objs, int level, int timeout,
-        OpCallbacks call) {
+    public void lockAll(Collection<?> objs, int level, int timeout, OpCallbacks call) {
         if (objs.isEmpty())
             return;
         if (objs.size() == 1) {
@@ -3928,8 +3904,9 @@ public class BrokerImpl
             }
 
             _lm.lockAll(sms, level, timeout, null);
-            for (Iterator<StateManagerImpl> itr = sms.iterator(); itr.hasNext();)
+            for (Iterator<StateManagerImpl> itr = sms.iterator(); itr.hasNext();) {
                 itr.next().readLocked(level, level);
+            }
         } catch (OpenJPAException ke) {
             throw ke;
         } catch (RuntimeException re) {
@@ -4001,7 +3978,7 @@ public class BrokerImpl
     // Cache
     /////////
 
-    public Collection getManagedObjects() {
+    public Collection<Object> getManagedObjects() {
         beginOperation(false);
         try {
             return new ManagedObjectCollection(getManagedStates());
@@ -4010,7 +3987,7 @@ public class BrokerImpl
         }
     }
 
-    public Collection getTransactionalObjects() {
+    public Collection<Object> getTransactionalObjects() {
         beginOperation(false);
         try {
             return new ManagedObjectCollection(getTransactionalStates());
@@ -4019,17 +3996,16 @@ public class BrokerImpl
         }
     }
 
-    public Collection getPendingTransactionalObjects() {
+    public Collection<Object> getPendingTransactionalObjects() {
         beginOperation(false);
         try {
-            return new ManagedObjectCollection
-                (getPendingTransactionalStates());
+            return new ManagedObjectCollection(getPendingTransactionalStates());
         } finally {
             endOperation();
         }
     }
 
-    public Collection getDirtyObjects() {
+    public Collection<Object> getDirtyObjects() {
         beginOperation(false);
         try {
             return new ManagedObjectCollection(getDirtyStates());
@@ -4049,7 +4025,7 @@ public class BrokerImpl
     /**
      * Return a copy of all managed state managers.
      */
-    protected Collection getManagedStates() {
+    protected Collection<StateManagerImpl> getManagedStates() {
         return _cache.copy();
     }
 
@@ -4077,9 +4053,9 @@ public class BrokerImpl
     /**
      * Return a copy of all dirty state managers.
      */
-    protected Collection getDirtyStates() {
+    protected Collection<StateManagerImpl> getDirtyStates() {
         if (!hasTransactionalObjects())
-            return Collections.EMPTY_SET;
+            return Collections.emptySet();
 
         return _transCache.copyDirty();
     }
@@ -4088,9 +4064,9 @@ public class BrokerImpl
      * Return a copy of all state managers which will become
      * transactional upon the next transaction.
      */
-    protected Collection getPendingTransactionalStates() {
+    protected Collection<StateManagerImpl> getPendingTransactionalStates() {
         if (_pending == null)
-            return Collections.EMPTY_SET;
+            return Collections.emptySet();
         return new LinkedHashSet<StateManagerImpl>(_pending);
     }
 
@@ -4299,7 +4275,7 @@ public class BrokerImpl
         }
     }
 
-    public void dirtyType(Class cls) {
+    public void dirtyType(Class<?> cls) {
         if (cls == null)
             return;
 
@@ -4313,21 +4289,21 @@ public class BrokerImpl
         }
     }
 
-    public Collection getPersistedTypes() {
+    public Collection<Class<?>> getPersistedTypes() {
         if (_persistedClss == null || _persistedClss.isEmpty())
-            return Collections.EMPTY_SET;
+            return Collections.emptySet();
         return Collections.unmodifiableCollection(_persistedClss);
     }
 
-    public Collection getUpdatedTypes() {
+    public Collection<Class<?>> getUpdatedTypes() {
         if (_updatedClss == null || _updatedClss.isEmpty())
-            return Collections.EMPTY_SET;
+            return Collections.emptySet();
         return Collections.unmodifiableCollection(_updatedClss);
     }
 
-    public Collection getDeletedTypes() {
+    public Collection<Class<?>> getDeletedTypes() {
         if (_deletedClss == null || _deletedClss.isEmpty())
-            return Collections.EMPTY_SET;
+            return Collections.emptySet();
         return Collections.unmodifiableCollection(_deletedClss);
     }
 
@@ -4383,7 +4359,6 @@ public class BrokerImpl
         _deletedClss = null;
         _derefCache = null;
         _pending = null;
-        _loader = null;
         _transEventManager = null;
         _lifeEventManager = null;
 
@@ -4407,9 +4382,9 @@ public class BrokerImpl
         }
 
         if (_extents != null) {
-            Extent e;
+            Extent<?> e;
             for (Iterator<?> itr = _extents.iterator(); itr.hasNext();) {
-                e = (Extent) itr.next();
+                e = (Extent<?>) itr.next();
                 try {
                     e.closeAll();
                 } catch (RuntimeException re) {
@@ -4454,12 +4429,11 @@ public class BrokerImpl
     // State management
     ////////////////////
 
-    public Object newInstance(Class cls) {
+    public Object newInstance(Class<?> cls) {
         assertOpen();
 
         if (!cls.isInterface() && Modifier.isAbstract(cls.getModifiers()))
-            throw new UnsupportedOperationException(_loc.get
-                ("new-abstract", cls).getMessage());
+            throw new UnsupportedOperationException(_loc.get("new-abstract", cls).getMessage());
 
         // 1.5 doesn't initialize classes without a true Class.forName
         if (!PCRegistry.isRegistered(cls)) {
@@ -4471,7 +4445,7 @@ public class BrokerImpl
             }
         }
 
-        if (_repo.getMetaData(cls, getClassLoader(), false) == null)
+        if (_repo.getMetaData(cls, false) == null)
             throw new IllegalArgumentException(
                 _loc.get("no-interface-metadata", cls.getName()).getMessage());
 
@@ -4493,7 +4467,7 @@ public class BrokerImpl
                 if (pc.pcGetStateManager() == null) {
                     // If the statemanager is null the call to pcFetchObjectId always returns null. Create a new object
                     // id.
-                    return ApplicationIds.create(pc, _repo.getMetaData(pc.getClass(), null, true));
+                    return ApplicationIds.create(pc, _repo.getMetaData(pc.getClass(), true));
                 }
                 return pc.pcFetchObjectId();
             }
@@ -4582,7 +4556,7 @@ public class BrokerImpl
             return detached.booleanValue();
 
         // last resort: instance is detached if it has a store record
-        ClassMetaData meta = _repo.getMetaData(ImplHelper.getManagedInstance(pc).getClass(), _loader, true);
+        ClassMetaData meta = _repo.getMetaData(ImplHelper.getManagedInstance(pc).getClass(), true);
         Object oid = ApplicationIds.create(pc, meta);
         if (oid == null)
             return false;
@@ -4711,8 +4685,7 @@ public class BrokerImpl
      * Return an object not found exception containing nested exceptions
      * for all of the given failed objects.
      */
-    private static ObjectNotFoundException newObjectNotFoundException
-        (Collection failed) {
+    private static ObjectNotFoundException newObjectNotFoundException(Collection<?> failed) {
         Throwable[] t = new Throwable[failed.size()];
         int idx = 0;
         for (Iterator<?> itr = failed.iterator(); itr.hasNext(); idx++)
@@ -4801,11 +4774,11 @@ public class BrokerImpl
      * Transactional cache that holds soft refs to clean instances.
      */
     static class TransactionalCache
-        implements Set, Serializable {
+        implements Set<StateManagerImpl>, Serializable {
 
         private final boolean _orderDirty;
-        private Set<StateManagerImpl> _dirty = null;
-        private Set<StateManagerImpl> _clean = null;
+        private Set<StateManagerImpl> _dirty;
+        private Set<StateManagerImpl> _clean;
 
         public TransactionalCache(boolean orderDirty) {
             _orderDirty = orderDirty;
@@ -4814,31 +4787,31 @@ public class BrokerImpl
         /**
          * Return a copy of all transactional state managers.
          */
-        public Collection copy() {
+        public Collection<StateManagerImpl> copy() {
             if (isEmpty()) {
                 // Transaction Listeners may add entities to the transaction. 
-                return new LinkedHashSet();
+                return new LinkedHashSet<StateManagerImpl>();
             }
 
             // size may not be entirely accurate due to refs expiring, so
             // manually copy each object; doesn't matter this way if size too
             // big by some
-            Set copy = new LinkedHashSet(size());
+            Set<StateManagerImpl> copy = new LinkedHashSet<StateManagerImpl>(size());
             if (_dirty != null)
-                for (Iterator<StateManagerImpl> itr = _dirty.iterator(); itr.hasNext();)
-                    copy.add(itr.next());
+                for (StateManagerImpl dirty : _dirty)
+                    copy.add(dirty);
             if (_clean != null)
-                for (Iterator<StateManagerImpl> itr = _clean.iterator(); itr.hasNext();)
-                    copy.add(itr.next());
+                for (StateManagerImpl clean : _clean)
+                    copy.add(clean);
             return copy;
         }
 
         /**
          * Return a copy of all dirty state managers.
          */
-        public Collection copyDirty() {
+        public Collection<StateManagerImpl> copyDirty() {
             if (_dirty == null || _dirty.isEmpty())
-                return Collections.EMPTY_SET;
+                return Collections.emptySet();
             return new LinkedHashSet<StateManagerImpl>(_dirty);
         }
 
@@ -4890,7 +4863,7 @@ public class BrokerImpl
             return _clean != null && _clean.remove(sm);
         }
 
-        public Iterator iterator() {
+        public Iterator<StateManagerImpl> iterator() {
             IteratorChain chain = new IteratorChain();
             if (_dirty != null && !_dirty.isEmpty())
                 chain.addIterator(_dirty.iterator());
@@ -4904,7 +4877,7 @@ public class BrokerImpl
                 || (_clean != null && _clean.contains(obj));
         }
 
-        public boolean containsAll(Collection coll) {
+        public boolean containsAll(Collection<?> coll) {
             for (Iterator<?> itr = coll.iterator(); itr.hasNext();)
                 if (!contains(itr.next()))
                     return false;
@@ -4932,11 +4905,11 @@ public class BrokerImpl
             return size;
         }
 
-        public boolean add(Object obj) {
+        public boolean add(StateManagerImpl obj) {
             throw new UnsupportedOperationException();
         }
 
-        public boolean addAll(Collection coll) {
+        public boolean addAll(Collection<? extends StateManagerImpl> coll) {
             throw new UnsupportedOperationException();
         }
 
@@ -4944,11 +4917,11 @@ public class BrokerImpl
             throw new UnsupportedOperationException();
         }
 
-        public boolean removeAll(Collection coll) {
+        public boolean removeAll(Collection<?> coll) {
             throw new UnsupportedOperationException();
         }
 
-        public boolean retainAll(Collection c) {
+        public boolean retainAll(Collection<?> c) {
             throw new UnsupportedOperationException();
         }
 
@@ -4956,9 +4929,10 @@ public class BrokerImpl
             throw new UnsupportedOperationException();
         }
 
-        public Object[] toArray(Object[] arr) {
+		@Override
+		public <T> T[] toArray(T[] a) {
             throw new UnsupportedOperationException();
-        }
+		}
     }
 
     /**
@@ -5015,15 +4989,15 @@ public class BrokerImpl
      * with the corresponding managed objects.
      */
     private static class ManagedObjectCollection
-        extends AbstractCollection {
+        extends AbstractCollection<Object> {
 
-        private final Collection _states;
+        private final Collection<? extends OpenJPAStateManager> _states;
 
-        public ManagedObjectCollection(Collection states) {
+        public ManagedObjectCollection(Collection<? extends OpenJPAStateManager> states) {
             _states = states;
         }
 
-        public Collection getStateManagers() {
+        public Collection<? extends OpenJPAStateManager> getStateManagers() {
             return _states;
         }
 
@@ -5031,17 +5005,16 @@ public class BrokerImpl
             return _states.size();
         }
 
-        public Iterator iterator() {
-            return new Iterator() {
-                private final Iterator _itr = _states.iterator();
+        public Iterator<Object> iterator() {
+            return new Iterator<Object>() {
+                private final Iterator<? extends OpenJPAStateManager> _itr = _states.iterator();
 
                 public boolean hasNext() {
                     return _itr.hasNext();
                 }
 
                 public Object next() {
-                    return ((OpenJPAStateManager) _itr.next()).
-                        getManagedInstance();
+                    return ((OpenJPAStateManager) _itr.next()).getManagedInstance();
                 }
 
                 public void remove() {

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DelegatingBroker.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DelegatingBroker.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DelegatingBroker.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DelegatingBroker.java Sat Oct 29 00:44:11 2011
@@ -170,14 +170,6 @@ public class DelegatingBroker
         }
     }
 
-    public ClassLoader getClassLoader() {
-        try {
-            return _broker.getClassLoader();
-        } catch (RuntimeException re) {
-            throw translate(re);
-        }
-    }
-
     public LockManager getLockManager() {
         try {
             return _broker.getLockManager();

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DelegatingStoreManager.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DelegatingStoreManager.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DelegatingStoreManager.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DelegatingStoreManager.java Sat Oct 29 00:44:11 2011
@@ -127,7 +127,7 @@ public abstract class DelegatingStoreMan
         _store.beforeStateChange(sm, fromState, toState);
     }
 
-    public Collection<Exception> flush(Collection<OpenJPAStateManager> sms) {
+    public Collection<Exception> flush(Collection<? extends OpenJPAStateManager> sms) {
         return _store.flush(sms);
     }
 

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DetachedStateAttachStrategy.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DetachedStateAttachStrategy.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DetachedStateAttachStrategy.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DetachedStateAttachStrategy.java Sat Oct 29 00:44:11 2011
@@ -48,12 +48,10 @@ class DetachedStateAttachStrategy
             return null;
 
         Broker broker = manager.getBroker();
-        PersistenceCapable pc = ImplHelper.toPersistenceCapable(toAttach,
-            broker.getConfiguration());
+        PersistenceCapable pc = ImplHelper.toPersistenceCapable(toAttach, broker.getConfiguration());
         ClassMetaData meta = broker.getConfiguration().
             getMetaDataRepositoryInstance().getMetaData(
-                ImplHelper.getManagedInstance(toAttach).getClass(),
-                broker.getClassLoader(), true);
+                ImplHelper.getManagedInstance(toAttach).getClass(), true);
 
         switch (meta.getIdentityType()) {
             case ClassMetaData.ID_DATASTORE:

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DetachedValueStateManager.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DetachedValueStateManager.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DetachedValueStateManager.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DetachedValueStateManager.java Sat Oct 29 00:44:11 2011
@@ -52,8 +52,7 @@ public class DetachedValueStateManager
     public DetachedValueStateManager(Object pc, StoreContext ctx) {
         this(ImplHelper.toPersistenceCapable(pc, ctx.getConfiguration()),
             ctx.getConfiguration().getMetaDataRepositoryInstance()
-                .getMetaData(ImplHelper.getManagedInstance(pc).getClass(),
-            ctx.getClassLoader(), true), ctx);
+                .getMetaData(ImplHelper.getManagedInstance(pc).getClass(), true), ctx);
     }
 
     public DetachedValueStateManager(PersistenceCapable pc, ClassMetaData meta,

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ExpressionStoreQuery.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ExpressionStoreQuery.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ExpressionStoreQuery.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ExpressionStoreQuery.java Sat Oct 29 00:44:11 2011
@@ -94,8 +94,8 @@ public class ExpressionStoreQuery
         new StringContains(), new WildcardMatch(),
     };
 
-    private final ExpressionParser _parser;
-    private transient Object _parsed;
+    protected final ExpressionParser _parser;
+    protected transient Object _parsed;
 
     /**
      * Construct a query with a parser for the language.
@@ -172,7 +172,7 @@ public class ExpressionStoreQuery
 
     public Executor newInMemoryExecutor(ClassMetaData meta, boolean subs) {
         return new InMemoryExecutor(this, meta, subs, _parser,
-            ctx.getCompilation());
+            ctx.getCompilation(), new InMemoryExpressionFactory());
     }
 
     public Executor newDataStoreExecutor(ClassMetaData meta, boolean subs) {
@@ -576,7 +576,7 @@ public class ExpressionStoreQuery
     /**
      * Runs the expression query in memory.
      */
-    private static class InMemoryExecutor
+    public static class InMemoryExecutor
         extends AbstractExpressionExecutor
         implements Executor, Serializable {
 
@@ -588,10 +588,10 @@ public class ExpressionStoreQuery
 
         public InMemoryExecutor(ExpressionStoreQuery q,
             ClassMetaData candidate, boolean subclasses,
-            ExpressionParser parser, Object parsed) {
+            ExpressionParser parser, Object parsed, InMemoryExpressionFactory factory) {
             _meta = candidate;
             _subs = subclasses;
-            _factory = new InMemoryExpressionFactory();
+            _factory = factory;
 
             _exps = new QueryExpressions[] {
                 parser.eval(parsed, q, _factory, _meta)
@@ -637,9 +637,9 @@ public class ExpressionStoreQuery
                 Object obj;
                 while (itr.hasNext()) {
                     obj = itr.next();
-                    if (_factory.matches(_exps[0], _meta, _subs, obj, ctx,
-                        params))
+                    if (_factory.matches(_exps[0], _meta, _subs, obj, ctx, params)) {
                         results.add(obj);
+                    }
                 }
             }
             finally {
@@ -703,6 +703,7 @@ public class ExpressionStoreQuery
         public Class[] getProjectionTypes(StoreQuery q) {
             return _projTypes;
         }
+        
 
         /**
          * Throws an exception if a variable is found.



Mime
View raw message