tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r504433 - in /incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb: assembler/classic/ config/ core/cmp/cmp2/
Date Wed, 07 Feb 2007 05:04:46 GMT
Author: dain
Date: Tue Feb  6 21:04:45 2007
New Revision: 504433

URL: http://svn.apache.org/viewvc?view=rev&rev=504433
Log:
Complex primary keys aren't implemented but shouldn't cause a deployment to fail

Modified:
    incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/AssemblerTool.java
    incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/CmpJpaConversion.java
    incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/OpenEjb2CmpConversion.java
    incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java
    incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/cmp/cmp2/Cmp2Generator.java

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/AssemblerTool.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/AssemblerTool.java?view=diff&rev=504433&r1=504432&r2=504433
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/AssemblerTool.java
(original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/AssemblerTool.java
Tue Feb  6 21:04:45 2007
@@ -227,6 +227,9 @@
          At the very least, log a warning or two.
          */
 
+        // todo local permissions cause exception
+        if (intrface == null) return;
+
         if (mi.methodName.equals("*")) {
             Method[] mthds = intrface.getMethods();
             for (int i = 0; i < mthds.length; i++)

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/CmpJpaConversion.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/CmpJpaConversion.java?view=diff&rev=504433&r1=504432&r2=504433
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/CmpJpaConversion.java
(original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/CmpJpaConversion.java
Tue Feb  6 21:04:45 2007
@@ -16,44 +16,41 @@
  */
 package org.apache.openejb.config;
 
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-import java.lang.reflect.Field;
-
-import javax.xml.bind.JAXBException;
-
+import org.apache.openejb.OpenEJBException;
+import org.apache.openejb.core.cmp.jpa.JpaCmpEngine;
 import org.apache.openejb.jee.CmpField;
+import org.apache.openejb.jee.CmpVersion;
 import org.apache.openejb.jee.EjbJar;
 import org.apache.openejb.jee.EjbRelation;
 import org.apache.openejb.jee.EjbRelationshipRole;
 import org.apache.openejb.jee.EntityBean;
 import org.apache.openejb.jee.Multiplicity;
+import org.apache.openejb.jee.PersistenceContextRef;
 import org.apache.openejb.jee.PersistenceType;
 import org.apache.openejb.jee.RelationshipRoleSource;
 import org.apache.openejb.jee.Relationships;
-import org.apache.openejb.jee.PersistenceContextRef;
-import org.apache.openejb.jee.CmpVersion;
-import org.apache.openejb.jee.jpa.EntityMappings;
-import org.apache.openejb.jee.jpa.Entity;
 import org.apache.openejb.jee.jpa.Attributes;
-import org.apache.openejb.jee.jpa.Id;
 import org.apache.openejb.jee.jpa.Basic;
-import org.apache.openejb.jee.jpa.OneToOne;
-import org.apache.openejb.jee.jpa.OneToMany;
-import org.apache.openejb.jee.jpa.ManyToOne;
+import org.apache.openejb.jee.jpa.CascadeType;
+import org.apache.openejb.jee.jpa.Entity;
+import org.apache.openejb.jee.jpa.EntityMappings;
+import org.apache.openejb.jee.jpa.Id;
 import org.apache.openejb.jee.jpa.ManyToMany;
+import org.apache.openejb.jee.jpa.ManyToOne;
+import org.apache.openejb.jee.jpa.OneToMany;
+import org.apache.openejb.jee.jpa.OneToOne;
 import org.apache.openejb.jee.jpa.RelationField;
-import org.apache.openejb.jee.jpa.CascadeType;
 import org.apache.openejb.jee.jpa.Transient;
-import org.apache.openejb.jee.jpa.JpaJaxbUtil;
 import org.apache.openejb.jee.jpa.unit.Persistence;
 import org.apache.openejb.jee.jpa.unit.PersistenceUnit;
 import org.apache.openejb.jee.jpa.unit.TransactionType;
-import org.apache.openejb.OpenEJBException;
-import org.apache.openejb.core.cmp.jpa.JpaCmpEngine;
+
+import java.lang.reflect.Field;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
 
 public class CmpJpaConversion implements DynamicDeployer {
     private static final String CMP_PERSISTENCE_UNIT_NAME = "cmp";

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/OpenEjb2CmpConversion.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/OpenEjb2CmpConversion.java?view=diff&rev=504433&r1=504432&r2=504433
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/OpenEjb2CmpConversion.java
(original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/OpenEjb2CmpConversion.java
Tue Feb  6 21:04:45 2007
@@ -16,13 +16,9 @@
  */
 package org.apache.openejb.config;
 
-import java.io.InputStream;
 import java.util.List;
 import java.util.Map;
 import java.util.TreeMap;
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.JAXBException;
-import javax.xml.namespace.QName;
 
 import org.apache.openejb.OpenEJBException;
 import org.apache.openejb.jee.jpa.Attributes;
@@ -43,42 +39,19 @@
 import org.apache.openejb.jee.oejb2.EjbRelationshipRoleType;
 import org.apache.openejb.jee.oejb2.EnterpriseBean;
 import org.apache.openejb.jee.oejb2.EntityBeanType;
-import org.apache.openejb.jee.oejb2.JaxbOpenejbJar2;
 import org.apache.openejb.jee.oejb2.OpenejbJarType;
-import org.apache.openejb.jee.oejb2.GeronimoEjbJarType;
 
 public class OpenEjb2CmpConversion implements DynamicDeployer {
     public AppModule deploy(AppModule appModule) throws OpenEJBException {
         for (EjbModule ejbModule : appModule.getEjbModules()) {
-            ClassLoader classLoader = ejbModule.getClassLoader();
-            OpenejbJarType openejbJarType = loadOpenEjbJar(classLoader);
-            if (openejbJarType != null) {
-                mergeEntityMappings(appModule.getCmpMappings(), openejbJarType);
-                OpenejbJarType o2 = (OpenejbJarType) openejbJarType;
-
-//                String result = createGeronimoOpenejb(o2);
+            Object altDD = ejbModule.getAltDDs().get("openejb-jar.xml");
+            if (altDD instanceof OpenejbJarType) {
+                mergeEntityMappings(appModule.getCmpMappings(), (OpenejbJarType) altDD);
             }
         }
         return appModule;
     }
 
-    public OpenejbJarType loadOpenEjbJar(ClassLoader classLoader) {
-        InputStream in = classLoader.getResourceAsStream("META-INF/openejb-jar.xml");
-        if (in == null) {
-            return null;
-        }
-
-        JAXBElement element;
-        try {
-            element = (JAXBElement) JaxbOpenejbJar2.unmarshal(OpenejbJarType.class, in, false);
-        } catch (Exception e) {
-            return null;
-        }
-        return (OpenejbJarType) element.getValue();
-    }
-
-
-
     public void mergeEntityMappings(EntityMappings entityMappings, OpenejbJarType openejbJarType)
{
         Map<String, EntityData> entities =  new TreeMap<String, EntityData>();
         for (Entity entity : entityMappings.getEntity()) {
@@ -117,12 +90,15 @@
 
             // todo this doesn't seem to parse?
             if (bean.getKeyGenerator() != null) {
-                Id id = entityData.entity.getAttributes().getId().get(0);
-
-                // todo detect specific generation strategy
-                GeneratedValue generatedValue = new GeneratedValue();
-                generatedValue.setGenerator("IDENTITY");
-                id.setGeneratedValue(generatedValue);
+                // todo support complex primary keys
+                if (entityData.entity.getAttributes().getId().size() == 1) {
+                    Id id = entityData.entity.getAttributes().getId().get(0);
+
+                    // todo detect specific generation strategy
+                    GeneratedValue generatedValue = new GeneratedValue();
+                    generatedValue.setGenerator("IDENTITY");
+                    id.setGeneratedValue(generatedValue);
+                }
             }
         }
 

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java?view=diff&rev=504433&r1=504432&r2=504433
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java
(original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java
Tue Feb  6 21:04:45 2007
@@ -96,12 +96,12 @@
                 ejbModule.setOpenejbJar(openejbJar);
             } catch (Exception e) {
                 OpenejbJar openejbJar = new OpenejbJar();
-                ejbModule.getAltDDs().put("openejb-jar.xml", openejbJar);
                 ejbModule.setOpenejbJar(openejbJar);
 
                 try {
                     JAXBElement element = (JAXBElement) JaxbOpenejbJar2.unmarshal(OpenejbJarType.class,
source.get());
                     OpenejbJarType o2 = (OpenejbJarType) element.getValue();
+                    ejbModule.getAltDDs().put("openejb-jar.xml", o2);
 
                     GeronimoEjbJarType g2 = new GeronimoEjbJarType();
 

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/cmp/cmp2/Cmp2Generator.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/cmp/cmp2/Cmp2Generator.java?view=diff&rev=504433&r1=504432&r2=504433
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/cmp/cmp2/Cmp2Generator.java
(original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/cmp/cmp2/Cmp2Generator.java
Tue Feb  6 21:04:45 2007
@@ -53,10 +53,10 @@
         }
 
         this.pkField = cmpFields.get(pkField);
-        if (this.pkField == null) {
+        // todo warn about unsupported complex primary key
+        if (pkField != null && this.pkField == null) {
             throw new IllegalArgumentException("No such property " + pkField + " defined
on bean class " + beanClassName);
         }
-
         cw = new ClassWriter(true);
     }
 
@@ -306,6 +306,9 @@
     }
 
     private void createSimplePrimaryKeyGetter(CmpField pkField) {
+        // todo complex pk
+        if (pkField == null) return;
+
         String descriptor = pkField.getType().getDescriptor();
 
         String methodName = "OpenEJB_getPrimaryKey";



Mime
View raw message