tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblev...@apache.org
Subject svn commit: r592609 - in /openejb/trunk/openejb3/container: openejb-core/src/main/java/org/apache/openejb/config/ openejb-jee/src/main/java/org/apache/openejb/jee/oejb3/ openejb-jee/src/main/java/org/apache/openejb/jee/wls/
Date Wed, 07 Nov 2007 04:54:30 GMT
Author: dblevins
Date: Tue Nov  6 20:54:30 2007
New Revision: 592609

URL: http://svn.apache.org/viewvc?rev=592609&view=rev
Log:
Beginning of a wls to openejb converter

Added:
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/WlsConversion.java
Modified:
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
    openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/oejb3/Jndi.java
    openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/wls/EjbReferenceDescription.java
    openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/wls/WeblogicEnterpriseBean.java

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java?rev=592609&r1=592608&r2=592609&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
Tue Nov  6 20:54:30 2007
@@ -169,6 +169,7 @@
         chain.add(new CmpJpaConversion());
         chain.add(new OpenEjb2Conversion());
         chain.add(new SunConversion());
+        chain.add(new WlsConversion());
 
         if (System.getProperty("duct tape") != null){
             // must be after CmpJpaConversion since it adds new persistence-context-refs

Added: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/WlsConversion.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/WlsConversion.java?rev=592609&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/WlsConversion.java
(added)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/WlsConversion.java
Tue Nov  6 20:54:30 2007
@@ -0,0 +1,162 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.openejb.config;
+
+import org.apache.openejb.jee.sun.JaxbSun;
+import org.apache.openejb.jee.sun.SunEjbJar;
+import org.apache.openejb.jee.sun.SunCmpMappings;
+import org.apache.openejb.jee.sun.ResourceRef;
+import org.apache.openejb.jee.sun.ResourceEnvRef;
+import org.apache.openejb.jee.sun.MessageDestinationRef;
+import org.apache.openejb.jee.sun.PortInfo;
+import org.apache.openejb.jee.sun.StubProperty;
+import org.apache.openejb.jee.sun.SunCmpMapping;
+import org.apache.openejb.jee.sun.WebserviceEndpoint;
+import org.apache.openejb.jee.sun.Ejb;
+import org.apache.openejb.jee.sun.Cmp;
+import org.apache.openejb.jee.sun.OneOneFinders;
+import org.apache.openejb.jee.sun.Finder;
+import org.apache.openejb.jee.sun.EntityMapping;
+import org.apache.openejb.jee.sun.ColumnPair;
+import org.apache.openejb.jee.sun.CmpFieldMapping;
+import org.apache.openejb.jee.sun.ColumnName;
+import org.apache.openejb.jee.sun.CmrFieldMapping;
+import org.apache.openejb.jee.ServiceRef;
+import org.apache.openejb.jee.PortComponentRef;
+import org.apache.openejb.jee.WebserviceDescription;
+import org.apache.openejb.jee.PortComponent;
+import org.apache.openejb.jee.EjbJar;
+import org.apache.openejb.jee.EnterpriseBean;
+import org.apache.openejb.jee.ServiceImplBean;
+import org.apache.openejb.jee.EntityBean;
+import org.apache.openejb.jee.PersistenceType;
+import org.apache.openejb.jee.CmpField;
+import org.apache.openejb.jee.wls.JaxbWls;
+import org.apache.openejb.jee.wls.WeblogicEjbJar;
+import org.apache.openejb.jee.wls.WeblogicEnterpriseBean;
+import org.apache.openejb.jee.oejb3.OpenejbJar;
+import org.apache.openejb.jee.oejb3.EjbDeployment;
+import org.apache.openejb.jee.oejb3.EjbLink;
+import org.apache.openejb.jee.oejb3.ResourceLink;
+import org.apache.openejb.jee.oejb3.Jndi;
+import org.apache.openejb.jee.jpa.EntityMappings;
+import org.apache.openejb.jee.jpa.Entity;
+import org.apache.openejb.jee.jpa.NamedQuery;
+import org.apache.openejb.jee.jpa.Table;
+import org.apache.openejb.jee.jpa.SecondaryTable;
+import org.apache.openejb.jee.jpa.PrimaryKeyJoinColumn;
+import org.apache.openejb.jee.jpa.Field;
+import org.apache.openejb.jee.jpa.Column;
+import org.apache.openejb.jee.jpa.RelationField;
+import org.apache.openejb.jee.jpa.OneToOne;
+import org.apache.openejb.jee.jpa.JoinColumn;
+import org.apache.openejb.jee.jpa.OneToMany;
+import org.apache.openejb.jee.jpa.ManyToOne;
+import org.apache.openejb.jee.jpa.JoinTable;
+import org.apache.openejb.jee.jpa.Id;
+import org.apache.openejb.jee.jpa.Attributes;
+import org.apache.openejb.jee.jpa.Basic;
+import org.apache.openejb.jee.jpa.AttributeOverride;
+
+import java.io.ByteArrayInputStream;
+import java.net.URL;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.HashMap;
+import java.util.Collection;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Collections;
+import java.util.StringTokenizer;
+import java.util.Arrays;
+import java.util.LinkedList;
+
+public class WlsConversion implements DynamicDeployer {
+    public AppModule deploy(AppModule appModule) {
+        for (EjbModule ejbModule : appModule.getEjbModules()) {
+            convertModule(ejbModule, appModule.getCmpMappings());
+        }
+        return appModule;
+    }
+
+    private <T> T getDescriptor(EjbModule ejbModule, String descriptor, Class<T>
type) {
+        Object altDD = ejbModule.getAltDDs().get(descriptor);
+        if (altDD instanceof String) {
+            try {
+                altDD = JaxbWls.unmarshal(type, new ByteArrayInputStream(((String)altDD).getBytes()));
+            } catch (Exception e) {
+                // todo warn about not being able to parse sun descriptor
+            }
+        }
+        if (altDD instanceof URL) {
+            try {
+                altDD = JaxbWls.unmarshal(type, ((URL)altDD).openStream());
+            } catch (Exception e) {
+                e.printStackTrace();
+                // todo warn about not being able to parse sun descriptor
+            }
+        }
+        if (altDD != null && type.isAssignableFrom(altDD.getClass())) {
+            return (T) altDD;
+        }
+        return null;
+    }
+
+    public void convertModule(EjbModule ejbModule, EntityMappings entityMappings) {
+
+        // merge data from weblogic-ejb-jar.xml file
+        WeblogicEjbJar weblogicEjbJar = getDescriptor(ejbModule, "weblogic-ejb-jar.xml",
WeblogicEjbJar.class);
+        mergeEjbConfig(ejbModule, weblogicEjbJar);
+
+    }
+
+    private void mergeEjbConfig(EjbModule ejbModule, WeblogicEjbJar weblogicEjbJar) {
+        EjbJar ejbJar = ejbModule.getEjbJar();
+        OpenejbJar openejbJar = ejbModule.getOpenejbJar();
+
+        if (openejbJar == null) return;
+        if (weblogicEjbJar == null) return;
+        if (weblogicEjbJar.getWeblogicEnterpriseBean().size() == 0) return;
+
+        for (WeblogicEnterpriseBean ejb : weblogicEjbJar.getWeblogicEnterpriseBean()) {
+
+            EjbDeployment deployment = openejbJar.getDeploymentsByEjbName().get(ejb.getEjbName());
+            if (deployment == null) {
+                // warn no matching deployment
+                continue;
+            }
+
+            // JNDI name of the remote home (legacy remote interface)
+            if (ejb.getJndiName() != null) {
+                deployment.getJndi().add(new Jndi(ejb.getJndiName(), "RemoteHome"));
+            }
+
+            // JNDI name of the remote home (legacy remote interface)
+            if (ejb.getLocalJndiName() != null) {
+                deployment.getJndi().add(new Jndi(ejb.getLocalJndiName(), "LocalHome"));
+            }
+
+            // TODO: What would be the default JNDI name for a business remote interface?
+            //deployment.getJndi().add(new Jndi("{theFormat}", "Remote"));
+
+            // TODO: What would be the default JNDI name for a business local interface?
+            //deployment.getJndi().add(new Jndi("{theFormat}", "Local"));
+
+        }
+    }
+
+}

Modified: openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/oejb3/Jndi.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/oejb3/Jndi.java?rev=592609&r1=592608&r2=592609&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/oejb3/Jndi.java
(original)
+++ openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/oejb3/Jndi.java
Tue Nov  6 20:54:30 2007
@@ -36,9 +36,9 @@
     public Jndi() {
     }
 
-    public Jndi(String ejbRefName, String deployentId) {
-        this.intrface = ejbRefName;
-        this.name = deployentId;
+    public Jndi(String name, String intrface) {
+        this.name = intrface;
+        this.intrface = name;
     }
 
     public String getName() {

Modified: openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/wls/EjbReferenceDescription.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/wls/EjbReferenceDescription.java?rev=592609&r1=592608&r2=592609&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/wls/EjbReferenceDescription.java
(original)
+++ openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/wls/EjbReferenceDescription.java
Tue Nov  6 20:54:30 2007
@@ -41,8 +41,10 @@
 
     @XmlElement(name = "ejb-ref-name", required = true)
     protected String ejbRefName;
+
     @XmlElement(name = "jndi-name", required = true)
     protected String jndiName;
+
     @XmlAttribute
     @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
     @XmlID

Modified: openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/wls/WeblogicEnterpriseBean.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/wls/WeblogicEnterpriseBean.java?rev=592609&r1=592608&r2=592609&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/wls/WeblogicEnterpriseBean.java
(original)
+++ openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/wls/WeblogicEnterpriseBean.java
Tue Nov  6 20:54:30 2007
@@ -83,50 +83,72 @@
 
     @XmlElement(name = "ejb-name", required = true)
     protected String ejbName;
+
     @XmlElement(name = "entity-descriptor")
     protected EntityDescriptor entityDescriptor;
+
     @XmlElement(name = "stateless-session-descriptor")
     protected StatelessSessionDescriptor statelessSessionDescriptor;
+
     @XmlElement(name = "stateful-session-descriptor")
     protected StatefulSessionDescriptor statefulSessionDescriptor;
+
     @XmlElement(name = "message-driven-descriptor")
     protected MessageDrivenDescriptor messageDrivenDescriptor;
+
     @XmlElement(name = "transaction-descriptor")
     protected TransactionDescriptor transactionDescriptor;
+
     @XmlElement(name = "iiop-security-descriptor")
     protected IiopSecurityDescriptor iiopSecurityDescriptor;
+
     @XmlElement(name = "resource-description")
     protected List<ResourceDescription> resourceDescription;
+
     @XmlElement(name = "resource-env-description")
     protected List<ResourceEnvDescription> resourceEnvDescription;
+
     @XmlElement(name = "ejb-reference-description")
     protected List<EjbReferenceDescription> ejbReferenceDescription;
+
     @XmlElement(name = "service-reference-description")
     protected List<ServiceReferenceDescription> serviceReferenceDescription;
+
     @XmlElement(name = "enable-call-by-reference")
     @XmlJavaTypeAdapter(TrueFalseAdapter.class)
     protected Boolean enableCallByReference;
+
     @XmlElement(name = "network-access-point")
     protected String networkAccessPoint;
+
     @XmlElement(name = "clients-on-same-server")
     @XmlJavaTypeAdapter(TrueFalseAdapter.class)
     protected Boolean clientsOnSameServer;
+
     @XmlElement(name = "run-as-principal-name")
     protected String runAsPrincipalName;
+
     @XmlElement(name = "create-as-principal-name")
     protected String createAsPrincipalName;
+
     @XmlElement(name = "remove-as-principal-name")
     protected String removeAsPrincipalName;
+
     @XmlElement(name = "passivate-as-principal-name")
     protected String passivateAsPrincipalName;
+
     @XmlElement(name = "jndi-name")
     protected String jndiName;
+
     @XmlElement(name = "local-jndi-name")
     protected String localJndiName;
+
     @XmlElement(name = "dispatch-policy")
     protected String dispatchPolicy;
+
     @XmlElement(name = "remote-client-timeout")
     protected BigInteger remoteClientTimeout;
+
     @XmlAttribute
     @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
     @XmlID



Mime
View raw message