cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r398724 - in /incubator/cayenne/jpa/trunk/cayenne-jpa/src: main/java/org/apache/cayenne/jpa/bridge/ main/java/org/apache/cayenne/jpa/conf/ main/java/org/apache/cayenne/jpa/cspi/ main/java/org/apache/cayenne/jpa/enhancer/ main/java/org/apach...
Date Mon, 01 May 2006 23:08:10 GMT
Author: aadamchik
Date: Mon May  1 16:08:04 2006
New Revision: 398724

URL: http://svn.apache.org/viewcvs?rev=398724&view=rev
Log:
finished integrating enahcer in the loading procedure.
Enhancer itself still needs work

Added:
    incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/spi/JpaUnitClassLoader.java
Modified:
    incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/bridge/DataMapConverter.java
    incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/EntityMapLoader.java
    incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/EntityMapLoaderContext.java
    incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/EntityMapXMLLoader.java
    incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/cspi/CjpaPersistenceProvider.java
    incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/enhancer/UnitClassTranformer.java
    incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/instrument/CayenneAgent.java
    incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/spi/JpaUnit.java
    incubator/cayenne/jpa/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/bridge/DataMapConverterTest.java
    incubator/cayenne/jpa/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/conf/EntityMapAnnotationLoaderTest.java
    incubator/cayenne/jpa/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/conf/EntityMapDefaultsProcessorTest.java
    incubator/cayenne/jpa/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/conf/EntityMapXMLLoaderTest.java

Modified: incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/bridge/DataMapConverter.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/bridge/DataMapConverter.java?rev=398724&r1=398723&r2=398724&view=diff
==============================================================================
--- incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/bridge/DataMapConverter.java
(original)
+++ incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/bridge/DataMapConverter.java
Mon May  1 16:08:04 2006
@@ -382,6 +382,8 @@
             JpaQueryHint hint = jpaQuery.getHint(QueryHints.QUERY_TYPE_HINT);
             if (hint != null && !Util.isEmptyString(hint.getValue())) {
                 try {
+
+                    // query class is not enhanced, so use normal class loader
                     Class cayenneQueryClass = Class.forName(hint.getValue(), true, Thread
                             .currentThread()
                             .getContextClassLoader());

Modified: incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/EntityMapLoader.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/EntityMapLoader.java?rev=398724&r1=398723&r2=398724&view=diff
==============================================================================
--- incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/EntityMapLoader.java
(original)
+++ incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/EntityMapLoader.java
Mon May  1 16:08:04 2006
@@ -86,7 +86,7 @@
     protected void loadEntityMap(PersistenceUnitInfo persistenceUnit)
             throws JpaProviderException {
 
-        this.context = new EntityMapLoaderContext();
+        this.context = new EntityMapLoaderContext(persistenceUnit);
 
         try {
             loadFromAnnotations(persistenceUnit);
@@ -121,18 +121,17 @@
      * present anywhere on the classpath. An orm.xml file or other mapping file is loaded
      * as a resource by the persistence provider.
      */
-    protected void updateFromXML(PersistenceUnitInfo persistenceUnit) throws IOException
{
+    protected void updateFromXML(PersistenceUnitInfo unit) throws IOException {
 
         EntityMapMergeProcessor merger = new EntityMapMergeProcessor(context);
 
         Set loadedLocations = new HashSet();
-        EntityMapXMLLoader loader = new EntityMapXMLLoader();
+        EntityMapXMLLoader loader = new EntityMapXMLLoader(unit.getClassLoader(), false);
 
         // 1. load from the standard file called orm.xml
         loadedLocations.add(DESCRIPTOR_LOCATION);
-        Enumeration<URL> standardDescriptors = persistenceUnit
-                .getClassLoader()
-                .getResources(DESCRIPTOR_LOCATION);
+        Enumeration<URL> standardDescriptors = unit.getClassLoader().getResources(
+                DESCRIPTOR_LOCATION);
 
         while (standardDescriptors.hasMoreElements()) {
             JpaEntityMap map = loader.getEntityMap(standardDescriptors.nextElement());
@@ -143,15 +142,14 @@
         // TODO: andrus, 4/20/2006 - load from the jar files
 
         // 3. load from explicitly specified descriptors
-        for (String descriptor : persistenceUnit.getMappingFileNames()) {
+        for (String descriptor : unit.getMappingFileNames()) {
 
             // avoid loading duplicates, such as META-INF/orm.xml that is also explicitly
             // mentioned in the unit...
             if (loadedLocations.add(descriptor)) {
 
-                Enumeration<URL> mappedDescriptors = persistenceUnit
-                        .getClassLoader()
-                        .getResources(descriptor);
+                Enumeration<URL> mappedDescriptors = unit.getClassLoader().getResources(
+                        descriptor);
                 while (mappedDescriptors.hasMoreElements()) {
                     JpaEntityMap map = loader.getEntityMap(mappedDescriptors
                             .nextElement());
@@ -168,6 +166,8 @@
 
         if (!persistenceUnit.getManagedClassNames().isEmpty()) {
 
+            // must use Unit class loader to prevent loading an un-enahnced class in the
+            // app ClassLoader.
             ClassLoader loader = persistenceUnit.getClassLoader();
             EntityMapAnnotationLoader annotationLoader = new EntityMapAnnotationLoader(
                     context);

Modified: incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/EntityMapLoaderContext.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/EntityMapLoaderContext.java?rev=398724&r1=398723&r2=398724&view=diff
==============================================================================
--- incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/EntityMapLoaderContext.java
(original)
+++ incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/EntityMapLoaderContext.java
Mon May  1 16:08:04 2006
@@ -40,9 +40,14 @@
     protected JpaEntityMap entityMap;
     protected PersistenceUnitInfo unit;
 
-    public EntityMapLoaderContext() {
+    public EntityMapLoaderContext(PersistenceUnitInfo unit) {
+        this.unit = unit;
         this.conflicts = new ValidationResult();
         this.entityMap = new JpaEntityMap();
+    }
+
+    public PersistenceUnitInfo getUnit() {
+        return unit;
     }
 
     public JpaEntityMap getEntityMap() {

Modified: incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/EntityMapXMLLoader.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/EntityMapXMLLoader.java?rev=398724&r1=398723&r2=398724&view=diff
==============================================================================
--- incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/EntityMapXMLLoader.java
(original)
+++ incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/EntityMapXMLLoader.java
Mon May  1 16:08:04 2006
@@ -31,8 +31,8 @@
 import org.xml.sax.SAXException;
 
 /**
- * {@link org.apache.cayenne.jpa.map.JpaEntityMap} loader that reads mapping
- * information from the XML sources compatible with the JPA ORM schema.
+ * {@link org.apache.cayenne.jpa.map.JpaEntityMap} loader that reads mapping information
+ * from the XML sources compatible with the JPA ORM schema.
  * 
  * @author Andrus Adamchik
  */
@@ -43,11 +43,15 @@
 
     Schema schema;
 
+    protected ClassLoader classLoader;
+
     public EntityMapXMLLoader() {
-        this(false);
+        this(Thread.currentThread().getContextClassLoader(), false);
     }
 
-    public EntityMapXMLLoader(boolean validateDescriptors) {
+    public EntityMapXMLLoader(ClassLoader classLoader, boolean validateDescriptors) {
+
+        this.classLoader = classLoader;
 
         // TODO: andrus, 04/18/2006 - merge validation capabilities to the XMLDecoder...
         if (validateDescriptors) {
@@ -60,8 +64,7 @@
             // xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm
             // http://java.sun.com/xml/ns/persistence/orm/orm_1_0.xsd">
 
-            URL schemaURL = Thread.currentThread().getContextClassLoader().getResource(
-                    ORM_SCHEMA);
+            URL schemaURL = classLoader.getResource(ORM_SCHEMA);
 
             SchemaFactory factory = SchemaFactory
                     .newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
@@ -85,8 +88,7 @@
 
         // TODO: andrus, 04/18/2006 XMLDecoder should support classpath locations for
         // mapping descriptors
-        URL mappingURL = Thread.currentThread().getContextClassLoader().getResource(
-                XML_CODER_MAPPING);
+        URL mappingURL = classLoader.getResource(XML_CODER_MAPPING);
         if (mappingURL == null) {
             throw new RuntimeException("No code mapping found: " + XML_CODER_MAPPING);
         }

Modified: incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/cspi/CjpaPersistenceProvider.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/cspi/CjpaPersistenceProvider.java?rev=398724&r1=398723&r2=398724&view=diff
==============================================================================
--- incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/cspi/CjpaPersistenceProvider.java
(original)
+++ incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/cspi/CjpaPersistenceProvider.java
Mon May  1 16:08:04 2006
@@ -111,7 +111,9 @@
 
             EntityMapLoader loader = new EntityMapLoader(info);
 
-            // now that all entities are resolved, add an enhancer...
+            // we must set enhancer in this exact place, between JPA and Cayenne mapping
+            // loading. By now all the JpaEntities are loaded (using separate unit class
+            // loader) and Cayenne mapping will be using the App ClassLoader.
             info.addTransformer(new UnitClassTranformer(
                     loader.getEntityMap(),
                     new CglibEnhancer()));
@@ -173,8 +175,10 @@
         }
 
         try {
-            Class dbAdapterClass = Class.forName(adapterClass, true, info
-                    .getClassLoader());
+            // adapter class is not enhanced, so use a normal class loader
+            Class dbAdapterClass = Class.forName(adapterClass, true, Thread
+                    .currentThread()
+                    .getContextClassLoader());
             return (DbAdapter) dbAdapterClass.newInstance();
         }
         catch (Exception e) {

Modified: incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/enhancer/UnitClassTranformer.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/enhancer/UnitClassTranformer.java?rev=398724&r1=398723&r2=398724&view=diff
==============================================================================
--- incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/enhancer/UnitClassTranformer.java
(original)
+++ incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/enhancer/UnitClassTranformer.java
Mon May  1 16:08:04 2006
@@ -17,10 +17,14 @@
 
 import java.lang.instrument.IllegalClassFormatException;
 import java.security.ProtectionDomain;
+import java.util.HashSet;
+import java.util.Set;
 
 import javax.persistence.spi.ClassTransformer;
 
+import org.apache.cayenne.jpa.map.JpaEntity;
 import org.apache.cayenne.jpa.map.JpaEntityMap;
+import org.apache.cayenne.jpa.map.JpaMappedSuperclass;
 
 /**
  * A ClassTransformer decorator that passes through classes mentioned in the JpaEntityMap
@@ -30,12 +34,22 @@
  */
 public class UnitClassTranformer implements ClassTransformer {
 
-    protected JpaEntityMap entityMap;
     protected ClassTransformer transformer;
+    protected Set<String> managedClasses;
 
     public UnitClassTranformer(JpaEntityMap entityMap, ClassTransformer transformer) {
-        this.entityMap = entityMap;
         this.transformer = transformer;
+        this.managedClasses = new HashSet<String>();
+
+        for (JpaMappedSuperclass entity : entityMap.getMappedSuperclasses()) {
+            managedClasses.add(entity.getClassName().replace('.', '/'));
+        }
+
+        for (JpaEntity entity : entityMap.getEntities()) {
+            // TODO: andrus, 5/1/2006 - need not enhance entities extending mapped
+            // superclasses
+            managedClasses.add(entity.getClassName().replace('.', '/'));
+        }
     }
 
     public byte[] transform(
@@ -57,6 +71,6 @@
      * expected in the internal format, separated by "/", not ".".
      */
     protected boolean isManagedClass(String className) {
-        return true;
+        return managedClasses.contains(className);
     }
 }

Modified: incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/instrument/CayenneAgent.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/instrument/CayenneAgent.java?rev=398724&r1=398723&r2=398724&view=diff
==============================================================================
--- incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/instrument/CayenneAgent.java
(original)
+++ incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/instrument/CayenneAgent.java
Mon May  1 16:08:04 2006
@@ -28,7 +28,7 @@
  * the JVM with the "-javaagent:" option. E.g.:
  * 
  * <pre>
- *   java -javaagent:/path/to/cayenne-jpa-3.0.jar org.example.Main
+ *         java -javaagent:/path/to/cayenne-jpa-3.0.jar org.example.Main
  * </pre>
  * 
  * @author Andrus Adamchik
@@ -42,6 +42,29 @@
     public static void premain(String agentArgs, Instrumentation instrumentation) {
         System.out.println("*** CayenneAgent starting...");
         InstrumentingUnit.setInstrumentation(instrumentation);
+
+        // TODO: andrus, 5/1/2006 - add explicit debugging option to the agent
+        
+        // This can be used to debug enhancer:
+        // instrumentation.addTransformer(new ClassFileTransformer() {
+        //
+        // public byte[] transform(
+        // ClassLoader loader,
+        // String className,
+        // Class<?> classBeingRedefined,
+        // ProtectionDomain protectionDomain,
+        // byte[] classfileBuffer) throws IllegalClassFormatException {
+        //
+        // if (className.indexOf("jpa") > 0) {
+        // System.out.println("*** className..."
+        // + className
+        // + ", loader: "
+        // + loader);
+        // }
+        // return null;
+        // }
+        // });
+
         System.setProperty(JpaPersistenceProvider.UNIT_FACTORY_PROPERTY, FACTORY_CLASS);
     }
 }

Modified: incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/spi/JpaUnit.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/spi/JpaUnit.java?rev=398724&r1=398723&r2=398724&view=diff
==============================================================================
--- incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/spi/JpaUnit.java
(original)
+++ incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/spi/JpaUnit.java
Mon May  1 16:08:04 2006
@@ -60,9 +60,7 @@
         this.managedClassNames = new ArrayList<String>(30);
         this.properties = new Properties();
 
-        // create a class loader that is separate from the app class loader, as we want
-        // all app class loader classes to go through the enhancers
-        this.classLoader = new URLClassLoader(new URL[0], getClass().getClassLoader());
+        setDefaultClassLoader();
     }
 
     public String getPersistenceUnitName() {
@@ -113,6 +111,7 @@
         }
 
         try {
+            // use app class loader - this is not the class to enhance...
             return (JpaDataSourceFactory) Class.forName(
                     factory,
                     true,
@@ -201,10 +200,17 @@
      */
     public void setClassLoader(ClassLoader classLoader) {
         if (classLoader == null) {
-            classLoader = Thread.currentThread().getContextClassLoader();
+            setDefaultClassLoader();
         }
+        else {
+            this.classLoader = classLoader;
+        }
+    }
 
-        this.classLoader = classLoader;
+    protected void setDefaultClassLoader() {
+        this.classLoader = new JpaUnitClassLoader(Thread
+                .currentThread()
+                .getContextClassLoader());
     }
 
     public void addManagedClassName(String managedClassName) {

Added: incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/spi/JpaUnitClassLoader.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/spi/JpaUnitClassLoader.java?rev=398724&view=auto
==============================================================================
--- incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/spi/JpaUnitClassLoader.java
(added)
+++ incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/spi/JpaUnitClassLoader.java
Mon May  1 16:08:04 2006
@@ -0,0 +1,99 @@
+/*
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.cayenne.jpa.spi;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.SecureClassLoader;
+
+/**
+ * A special class loader that uses parent loader to get resoirces, but does not load any
+ * classes though the parent to avoid parent pollution with un-enhanced classes.
+ * 
+ * @author Andrus Adamchik
+ */
+public class JpaUnitClassLoader extends SecureClassLoader {
+
+    public JpaUnitClassLoader(ClassLoader parent) {
+        super(parent);
+    }
+
+    @Override
+    protected synchronized Class<?> loadClass(String name, boolean resolve)
+            throws ClassNotFoundException {
+
+        if (name.startsWith("java.") || name.startsWith("javax.")) {
+            return super.loadClass(name, resolve);
+        }
+
+        Class c = findLoadedClass(name);
+
+        if (c == null) {
+            c = findClass(name);
+        }
+
+        if (resolve) {
+            resolveClass(c);
+        }
+
+        return c;
+    }
+
+    /**
+     * Loads a class bypassing parent class loader.
+     */
+    @Override
+    protected Class<?> findClass(String name) throws ClassNotFoundException {
+        String path = name.replace('.', '/') + ".class";
+
+        InputStream in = getResourceAsStream(path);
+        if (in == null) {
+            throw new ClassNotFoundException(name);
+        }
+
+        try {
+            ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
+            byte[] buffer = new byte[1024];
+            int read;
+
+            while ((read = in.read(buffer, 0, 1024)) > 0) {
+                out.write(buffer, 0, read);
+            }
+
+            out.close();
+            byte[] classBytes = out.toByteArray();
+
+            return defineClass(name, classBytes, 0, classBytes.length);
+        }
+        catch (SecurityException e) {
+            // JVM doesn't allow us to define class here... Is there a way to detect this
+            // upfront?
+            return super.findClass(name);
+        }
+        catch (IOException e) {
+            throw new ClassNotFoundException(name, e);
+        }
+        finally {
+            try {
+                in.close();
+            }
+            catch (IOException e) {
+                // ignore close exceptions...
+            }
+        }
+    }
+}

Modified: incubator/cayenne/jpa/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/bridge/DataMapConverterTest.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/jpa/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/bridge/DataMapConverterTest.java?rev=398724&r1=398723&r2=398724&view=diff
==============================================================================
--- incubator/cayenne/jpa/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/bridge/DataMapConverterTest.java
(original)
+++ incubator/cayenne/jpa/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/bridge/DataMapConverterTest.java
Mon May  1 16:08:04 2006
@@ -26,12 +26,14 @@
 import org.apache.cayenne.jpa.entity.cayenne.MockCayenneTargetEntity1;
 import org.apache.cayenne.jpa.entity.cayenne.MockCayenneTargetEntity2;
 import org.apache.cayenne.jpa.map.JpaEntityMap;
+import org.apache.cayenne.jpa.spi.MockPersistenceUnitInfo;
 import org.objectstyle.cayenne.map.DataMap;
 
 public class DataMapConverterTest extends TestCase {
 
     public void testDataMapDefaults() {
-        EntityMapLoaderContext context = new EntityMapLoaderContext();
+        EntityMapLoaderContext context = new EntityMapLoaderContext(
+                new MockPersistenceUnitInfo());
         JpaEntityMap jpaMap = context.getEntityMap();
         jpaMap.setPackageName("p1");
         jpaMap.setSchema("s1");
@@ -49,7 +51,8 @@
      * @see org.apache.cayenne.jpa.conf.EntityMapAnnotationLoaderTest#testLoadClassMapping()
      */
     public void testLoadClassMapping() throws Exception {
-        EntityMapLoaderContext context = new EntityMapLoaderContext();
+        EntityMapLoaderContext context = new EntityMapLoaderContext(
+                new MockPersistenceUnitInfo());
         EntityMapAnnotationLoader loader = new EntityMapAnnotationLoader(context);
 
         loader.loadClassMapping(MockCayenneEntity1.class);

Modified: incubator/cayenne/jpa/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/conf/EntityMapAnnotationLoaderTest.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/jpa/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/conf/EntityMapAnnotationLoaderTest.java?rev=398724&r1=398723&r2=398724&view=diff
==============================================================================
--- incubator/cayenne/jpa/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/conf/EntityMapAnnotationLoaderTest.java
(original)
+++ incubator/cayenne/jpa/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/conf/EntityMapAnnotationLoaderTest.java
Mon May  1 16:08:04 2006
@@ -40,13 +40,14 @@
 import org.apache.cayenne.jpa.map.JpaAttributeOverride;
 import org.apache.cayenne.jpa.map.JpaEntity;
 import org.apache.cayenne.jpa.map.JpaEntityMap;
+import org.apache.cayenne.jpa.spi.MockPersistenceUnitInfo;
 
 public class EntityMapAnnotationLoaderTest extends TestCase {
 
     public void testSortAnnotations() throws Exception {
 
         EntityMapAnnotationLoader loader = new EntityMapAnnotationLoader(
-                new EntityMapLoaderContext());
+                new EntityMapLoaderContext(new MockPersistenceUnitInfo()));
 
         Annotation[] a1 = new Annotation[3];
         a1[0] = MockAnnotatedBean1.class.getAnnotation(NamedQuery.class);
@@ -66,7 +67,8 @@
      */
     public void testAttributeOverride() {
 
-        EntityMapLoaderContext context = new EntityMapLoaderContext();
+        EntityMapLoaderContext context = new EntityMapLoaderContext(
+                new MockPersistenceUnitInfo());
         EntityMapAnnotationLoader loader = new EntityMapAnnotationLoader(context);
         loader.loadClassMapping(MockAnnotatedBean2.class);
 
@@ -97,7 +99,8 @@
      */
     public void testLoadClassMapping() throws Exception {
 
-        EntityMapLoaderContext context = new EntityMapLoaderContext();
+        EntityMapLoaderContext context = new EntityMapLoaderContext(
+                new MockPersistenceUnitInfo());
         EntityMapAnnotationLoader loader = new EntityMapAnnotationLoader(context);
 
         loader.loadClassMapping(MockEntity1.class);

Modified: incubator/cayenne/jpa/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/conf/EntityMapDefaultsProcessorTest.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/jpa/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/conf/EntityMapDefaultsProcessorTest.java?rev=398724&r1=398723&r2=398724&view=diff
==============================================================================
--- incubator/cayenne/jpa/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/conf/EntityMapDefaultsProcessorTest.java
(original)
+++ incubator/cayenne/jpa/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/conf/EntityMapDefaultsProcessorTest.java
Mon May  1 16:08:04 2006
@@ -25,6 +25,7 @@
 import org.apache.cayenne.jpa.map.JpaEntity;
 import org.apache.cayenne.jpa.map.JpaEntityMap;
 import org.apache.cayenne.jpa.map.JpaId;
+import org.apache.cayenne.jpa.spi.MockPersistenceUnitInfo;
 
 public class EntityMapDefaultsProcessorTest extends TestCase {
 
@@ -36,7 +37,7 @@
         // sanity check - test object must not be serializable to be rejected...
         assertFalse(Serializable.class.isAssignableFrom(MockAnnotatedBean3.class));
 
-        context = new EntityMapLoaderContext();
+        context = new EntityMapLoaderContext(new MockPersistenceUnitInfo());
         EntityMapAnnotationLoader loader = new EntityMapAnnotationLoader(context);
         loader.loadClassMapping(MockAnnotatedBean1.class);
         loader.loadClassMapping(MockAnnotatedBean3.class);

Modified: incubator/cayenne/jpa/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/conf/EntityMapXMLLoaderTest.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/jpa/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/conf/EntityMapXMLLoaderTest.java?rev=398724&r1=398723&r2=398724&view=diff
==============================================================================
--- incubator/cayenne/jpa/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/conf/EntityMapXMLLoaderTest.java
(original)
+++ incubator/cayenne/jpa/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/conf/EntityMapXMLLoaderTest.java
Mon May  1 16:08:04 2006
@@ -33,7 +33,9 @@
 
     public void testSampleSchemaHeadersValidating() throws Exception {
 
-        EntityMapXMLLoader loader = new EntityMapXMLLoader(true);
+        EntityMapXMLLoader loader = new EntityMapXMLLoader(
+                getClass().getClassLoader(),
+                true);
 
         loader.getEntityMap(resourceLoader
                 .getResource("xml-samples/orm-schema-headers.xml"));
@@ -50,7 +52,9 @@
     }
 
     public void testDetails() throws Exception {
-        EntityMapXMLLoader loader = new EntityMapXMLLoader(true);
+        EntityMapXMLLoader loader = new EntityMapXMLLoader(
+                getClass().getClassLoader(),
+                true);
 
         // long t0 = System.currentTimeMillis();
         JpaEntityMap map = loader.getEntityMap(resourceLoader



Mime
View raw message