geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pra...@apache.org
Subject svn commit: r499678 - in /geronimo/server/branches/2.0-M2/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment: EjbModuleBuilder.java EjbRefBuilder.java XmlUtil.java ejbref/
Date Thu, 25 Jan 2007 06:31:09 GMT
Author: prasad
Date: Wed Jan 24 22:31:08 2007
New Revision: 499678

URL: http://svn.apache.org/viewvc?view=rev&rev=499678
Log:
* Merging changes from trunk back to M2

Added:
    geronimo/server/branches/2.0-M2/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbRefBuilder.java
  (with props)
Removed:
    geronimo/server/branches/2.0-M2/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/ejbref/
Modified:
    geronimo/server/branches/2.0-M2/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModuleBuilder.java
    geronimo/server/branches/2.0-M2/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/XmlUtil.java

Modified: geronimo/server/branches/2.0-M2/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.0-M2/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModuleBuilder.java?view=diff&rev=499678&r1=499677&r2=499678
==============================================================================
--- geronimo/server/branches/2.0-M2/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModuleBuilder.java
(original)
+++ geronimo/server/branches/2.0-M2/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModuleBuilder.java
Wed Jan 24 22:31:08 2007
@@ -21,6 +21,7 @@
 import java.net.URI;
 import java.net.URL;
 import java.net.MalformedURLException;
+import java.net.URLClassLoader;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
@@ -83,6 +84,8 @@
 import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlObject;
 import org.apache.xbean.finder.ClassFinder;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 /**
  * Master builder for processing EJB JAR deployments and creating the
@@ -91,6 +94,7 @@
  * @version $Revision: 479481 $ $Date: 2006-11-26 16:52:20 -0800 (Sun, 26 Nov 2006) $
  */
 public class EjbModuleBuilder implements ModuleBuilder {
+    private static final Log log = LogFactory.getLog(EjbModuleBuilder.class);
     private static final String OPENEJBJAR_NAMESPACE = XmlUtil.OPENEJBJAR_QNAME.getNamespaceURI();
 
     private final Environment defaultEnvironment;
@@ -143,46 +147,12 @@
 
         // load the ejb-jar.xml
         String ejbJarXml = XmlUtil.loadEjbJarXml(specDDUrl, moduleFile);
-        if (ejbJarXml == null) {
-            // this is not an ejb module
-            URL moduleUrl = null;
-            try {
-                File file = new File(moduleFile.getName());
-                moduleUrl = file.toURL();
-            } catch (MalformedURLException e) {
-                return null;
-            }
-
-            try {
-                final ClassFinder classFinder = new ClassFinder(Thread.currentThread().getContextClassLoader(),
moduleUrl);
-
-                // DMB: getting this via reflection is a temporary fix.  Just want to avoid
having to
-                // make Geronimo dependent on an xbean snapshot right before we do the release.
-                // afterwards we can clean this up.
-                Map<String, List> annotated = (Map<String, List>) AccessController.doPrivileged(new
PrivilegedAction() {
-                    public Object run() {
-                        try {
-                            Field field = ClassFinder.class.getDeclaredField("annotated");
-                            field.setAccessible(true);
-                            return field.get(classFinder);
-                        } catch (Exception e2) {
-                        }
-                        return null;
-                    }
-                });
-
-                List<String> beans = new ArrayList<String>();
-                beans.addAll(annotated.get(javax.ejb.Stateless.class.getName()));
-                beans.addAll(annotated.get(javax.ejb.Stateful.class.getName()));
-                beans.addAll(annotated.get(javax.ejb.MessageDriven.class.getName()));
-                if (beans.size() <= 0){
-                    return null;
-                }
-            } catch (Throwable e) {
-                // how does one log this?
-                return null;
-            }
+        // if there is no ejb-jar.xml and the module does not contain any
+        // classes annotated with ejb annotations, it is not an ejb module
+        if (ejbJarXml == null && !isEjbAnnotatedModule(moduleFile)) {
+            return null;
         }
+
         EjbJar ejbJar = XmlUtil.unmarshal(EjbJar.class, ejbJarXml);
         if (ejbJar == null){
             ejbJar = new EjbJar();
@@ -258,6 +228,48 @@
         }
 
         return new EjbModule(standAlone, moduleName, environment, moduleFile, targetPath,
ejbJar, openejbJar, geronimoOpenejb, ejbJarXml, sharedContext);
+    }
+
+    private boolean isEjbAnnotatedModule(JarFile moduleFile) {
+        // this is not an ejb module
+        URL moduleUrl = null;
+        try {
+            File file = new File(moduleFile.getName());
+            moduleUrl = file.toURL();
+        } catch (MalformedURLException e) {
+            return false;
+        }
+
+        try {
+            URLClassLoader tempClassLoader = new URLClassLoader(new URL[]{moduleUrl}, Thread.currentThread().getContextClassLoader());
+            final ClassFinder classFinder = new ClassFinder(tempClassLoader, moduleUrl);
+
+            // DMB: getting this via reflection is a temporary fix.  Just want to avoid having
to
+            // make Geronimo dependent on an xbean snapshot right before we do the release.
+            // afterwards we can clean this up.
+            Map<String, List> annotated = AccessController.doPrivileged(new PrivilegedAction<Map<String,
List>>() {
+                public Map<String, List> run() {
+                    try {
+                        Field field = ClassFinder.class.getDeclaredField("annotated");
+                        field.setAccessible(true);
+                        return (Map<String, List>) field.get(classFinder);
+                    } catch (Exception e2) {
+                    }
+                    return null;
+                }
+            });
+
+            if (!isEmpty(annotated.get(javax.ejb.Stateless.class.getName()))) return true;
+            if (!isEmpty(annotated.get(javax.ejb.Stateful.class.getName()))) return true;
+            if (!isEmpty(annotated.get(javax.ejb.MessageDriven.class.getName()))) return
true;
+        } catch (Throwable e) {
+            log.warn("Error while attempting to determine if a module is an EJB moduel",
e);
+        }
+        return false;
+    }
+
+    private static boolean isEmpty(List l) {
+        return l == null || l.isEmpty();
     }
 
     protected static void unmapReferences(EjbJar ejbJar) {

Added: geronimo/server/branches/2.0-M2/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbRefBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.0-M2/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbRefBuilder.java?view=auto&rev=499678
==============================================================================
--- geronimo/server/branches/2.0-M2/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbRefBuilder.java
(added)
+++ geronimo/server/branches/2.0-M2/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbRefBuilder.java
Wed Jan 24 22:31:08 2007
@@ -0,0 +1,379 @@
+/**
+ * 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.geronimo.openejb.deployment;
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import javax.ejb.EJB;
+import javax.ejb.EJBHome;
+import javax.ejb.EJBLocalHome;
+import javax.ejb.Local;
+import javax.ejb.Remote;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.j2ee.deployment.Module;
+import org.apache.geronimo.j2ee.deployment.WebModule;
+import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.kernel.config.Configuration;
+import org.apache.geronimo.kernel.config.MultiParentClassLoader;
+import org.apache.geronimo.kernel.repository.Environment;
+import org.apache.geronimo.naming.deployment.AbstractNamingBuilder;
+import org.apache.geronimo.openejb.ClientEjbReference;
+import org.apache.geronimo.xbeans.javaee.EjbLocalRefType;
+import org.apache.geronimo.xbeans.javaee.EjbRefType;
+import org.apache.geronimo.xbeans.javaee.InjectionTargetType;
+import org.apache.openejb.OpenEJBException;
+import org.apache.openejb.alt.config.AnnotationDeployer;
+import org.apache.openejb.alt.config.JndiEncInfoBuilder;
+import org.apache.openejb.assembler.classic.EjbJarInfo;
+import org.apache.openejb.assembler.classic.JndiEncBuilder;
+import org.apache.openejb.assembler.classic.JndiEncInfo;
+import org.apache.openejb.core.ivm.naming.IntraVmJndiReference;
+import org.apache.openejb.jee.EjbLocalRef;
+import org.apache.openejb.jee.EjbRef;
+import org.apache.openejb.jee.InjectionTarget;
+import org.apache.openejb.jee.JndiConsumer;
+import org.apache.openejb.jee.SessionBean;
+import org.apache.xbean.finder.ClassFinder;
+import org.apache.xbean.finder.UrlSet;
+import org.apache.xmlbeans.QNameSet;
+import org.apache.xmlbeans.XmlObject;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class EjbRefBuilder extends AbstractNamingBuilder {
+    private static final Log log = LogFactory.getLog(EjbRefBuilder.class);
+
+    private final QNameSet ejbRefQNameSet;
+    private final QNameSet ejbLocalRefQNameSet;
+    private final URI uri;
+
+    public EjbRefBuilder(Environment defaultEnvironment, String[] eeNamespaces, String host,
int port) throws URISyntaxException {
+        super(defaultEnvironment);
+        if (host != null) {
+            uri = new URI("ejb", null, host, port, null, null, null);
+        } else {
+            uri = null;
+        }
+
+        ejbRefQNameSet = buildQNameSet(eeNamespaces, "ejb-ref");
+        ejbLocalRefQNameSet = buildQNameSet(eeNamespaces, "ejb-local-ref");
+        ejbRefQNameSet.union(ejbLocalRefQNameSet);
+    }
+
+    public QNameSet getSpecQNameSet() {
+        return ejbRefQNameSet;
+    }
+
+    public QNameSet getPlanQNameSet() {
+        return QNameSet.EMPTY;
+    }
+
+    protected boolean willMergeEnvironment(XmlObject specDD, XmlObject plan) {
+        return specDD.selectChildren(ejbRefQNameSet).length > 0 || specDD.selectChildren(ejbLocalRefQNameSet).length
> 0;
+    }
+
+    public void buildNaming(XmlObject specDD, XmlObject plan, Configuration localConfiguration,
Configuration remoteConfiguration, Module module, Map componentContext) throws DeploymentException
{
+        JndiConsumer consumer = createJndiConsumer(specDD);
+        processWebEjbAnnotations(module, consumer);
+
+        Map<String, Object> map = null;
+        try {
+            EjbModuleBuilder.EarData earData = (EjbModuleBuilder.EarData) module.getRootEarContext().getGeneralData().get(EjbModuleBuilder.EarData.class);
+            Collection<EjbJarInfo> ejbJars = Collections.emptySet();
+            if (earData != null) {
+                ejbJars = earData.getEjbJars();
+            }
+            JndiEncInfoBuilder jndiEncInfoBuilder = new JndiEncInfoBuilder(ejbJars);
+            JndiEncInfo jndiEncInfo = jndiEncInfoBuilder.build(consumer, "GeronimoEnc");
+            JndiEncBuilder jndiEncBuilder = new JndiEncBuilder(jndiEncInfo);
+            map = jndiEncBuilder.buildMap();
+        } catch (OpenEJBException e) {
+            throw new DeploymentException(e);
+        }
+
+        for (Map.Entry<String, Object> entry : map.entrySet()) {
+            String name = entry.getKey();
+            Object value = entry.getValue();
+
+            // work with names prefixed with java:comp/
+            if (name.startsWith("java:comp/")) {
+                name = name.substring("java:comp/".length());
+            }
+
+            // if this is a ref it will be prefixed with env/
+            if (name.startsWith("env/")) {
+                if (uri != null) {
+                    value = createClientRef(value);
+                }
+                getJndiContextMap(componentContext).put(name, value);
+            }
+        }
+    }
+
+    private Object createClientRef(Object value) {
+        IntraVmJndiReference intraVmJndiReference = (IntraVmJndiReference) value;
+        String deploymentId = intraVmJndiReference.getJndiName();
+        if (deploymentId.startsWith("java:openejb/ejb/")) {
+            deploymentId = deploymentId.substring("java:openejb/ejb/".length());
+        }
+        ClientEjbReference clientRef = new ClientEjbReference(uri.toString(), deploymentId);
+        return clientRef;
+    }
+
+    protected JndiConsumer createJndiConsumer(XmlObject specDD) throws DeploymentException
{
+        List<EjbRefType> ejbRefs = convert(specDD.selectChildren(ejbRefQNameSet), J2EE_CONVERTER,
EjbRefType.class, EjbRefType.type);
+        List<EjbLocalRefType> ejbLocalRefs = convert(specDD.selectChildren(ejbLocalRefQNameSet),
J2EE_CONVERTER, EjbLocalRefType.class, EjbLocalRefType.type);
+
+        // build jndi consumer
+        JndiConsumer jndiConsumer = new SessionBean();
+        for (EjbRefType xmlbeansRef : ejbRefs) {
+            // create the ejb-ref
+            EjbRef ref = new EjbRef();
+            jndiConsumer.getEjbRef().add(ref);
+
+            // ejb-ref-name
+            ref.setEjbRefName(getStringValue(xmlbeansRef.getEjbRefName()));
+
+            // ejb-ref-type
+            String refType = getStringValue(xmlbeansRef.getEjbRefType());
+            if ("SESSION".equalsIgnoreCase(refType)) {
+                ref.setEjbRefType(org.apache.openejb.jee.EjbRefType.SESSION);
+            } else if ("ENTITY".equalsIgnoreCase(refType)) {
+                ref.setEjbRefType(org.apache.openejb.jee.EjbRefType.ENTITY);
+            }
+
+            // home
+            ref.setHome(getStringValue(xmlbeansRef.getHome()));
+
+            // remote
+            ref.setRemote(getStringValue(xmlbeansRef.getRemote()));
+
+            // ejb-link
+            ref.setEjbLink(getStringValue(xmlbeansRef.getEjbLink()));
+
+            // mapped-name
+            ref.setMappedName(getStringValue(xmlbeansRef.getMappedName()));
+
+            // injection-targets
+            if (xmlbeansRef.getInjectionTargetArray() != null) {
+                for (InjectionTargetType injectionTargetType : xmlbeansRef.getInjectionTargetArray())
{
+                    InjectionTarget injectionTarget = new InjectionTarget();
+                    injectionTarget.setInjectionTargetClass(getStringValue(injectionTargetType.getInjectionTargetClass()));
+                    injectionTarget.setInjectionTargetName(getStringValue(injectionTargetType.getInjectionTargetName()));
+                    ref.getInjectionTarget().add(injectionTarget);
+                }
+            }
+        }
+
+        for (EjbLocalRefType xmlbeansRef : ejbLocalRefs) {
+            // create the ejb-ref
+            EjbLocalRef ref = new EjbLocalRef();
+            jndiConsumer.getEjbLocalRef().add(ref);
+
+            // ejb-ref-name
+            ref.setEjbRefName(getStringValue(xmlbeansRef.getEjbRefName()));
+
+            // ejb-ref-type
+            String refType = getStringValue(xmlbeansRef.getEjbRefType());
+            if ("SESSION".equalsIgnoreCase(refType)) {
+                ref.setEjbRefType(org.apache.openejb.jee.EjbRefType.SESSION);
+            } else if ("ENTITY".equalsIgnoreCase(refType)) {
+                ref.setEjbRefType(org.apache.openejb.jee.EjbRefType.ENTITY);
+            }
+
+            // home
+            ref.setLocalHome(getStringValue(xmlbeansRef.getLocalHome()));
+
+            // remote
+            ref.setLocal(getStringValue(xmlbeansRef.getLocal()));
+
+            // ejb-link
+            ref.setEjbLink(getStringValue(xmlbeansRef.getEjbLink()));
+
+            // mapped-name
+            ref.setMappedName(getStringValue(xmlbeansRef.getMappedName()));
+
+            // injection-targets
+            if (xmlbeansRef.getInjectionTargetArray() != null) {
+                for (InjectionTargetType injectionTargetType : xmlbeansRef.getInjectionTargetArray())
{
+                    InjectionTarget injectionTarget = new InjectionTarget();
+                    injectionTarget.setInjectionTargetClass(getStringValue(injectionTargetType.getInjectionTargetClass()));
+                    injectionTarget.setInjectionTargetName(getStringValue(injectionTargetType.getInjectionTargetName()));
+                    ref.getInjectionTarget().add(injectionTarget);
+                }
+            }
+        }
+        return jndiConsumer;
+    }
+
+    private void processWebEjbAnnotations(Module module, JndiConsumer consumer) throws DeploymentException
{
+        if (module instanceof WebModule) {
+            try {
+                ClassLoader classLoader = module.getEarContext().getClassLoader();
+                UrlSet urlSet = new UrlSet(classLoader);
+                if (classLoader instanceof MultiParentClassLoader) {
+                    MultiParentClassLoader multiParentClassLoader = (MultiParentClassLoader)
classLoader;
+                    for (ClassLoader parent : multiParentClassLoader.getParents()) {
+                        if (parent != null) {
+                            urlSet = urlSet.exclude(parent);
+                        }
+                    }
+                } else {
+                    ClassLoader parent = classLoader.getParent();
+                    if (parent != null) {
+                        urlSet = urlSet.exclude(parent);
+                    }
+                }
+                ClassFinder finder = new ClassFinder(classLoader, urlSet.getUrls());
+                for (Field field : finder.findAnnotatedFields(EJB.class)) {
+                    EJB ejb = field.getAnnotation(EJB.class);
+                    AnnotationDeployer.Member member = new AnnotationDeployer.FieldMember(field);
+                    buildEjbRef(consumer, ejb, member);
+                }
+
+                for (Method method : finder.findAnnotatedMethods(EJB.class)) {
+                    EJB ejb = method.getAnnotation(EJB.class);
+                    AnnotationDeployer.Member member = new AnnotationDeployer.MethodMember(method);
+                    buildEjbRef(consumer, ejb, member);
+                }
+
+            } catch (IOException e) {
+                // ignored... we tried
+                log.warn("Unable to process @EJB annotations for web module" + module.getName(),
e);
+            }
+        }
+    }
+
+    private void buildEjbRef(JndiConsumer consumer, EJB ejb, AnnotationDeployer.Member member)
{
+        EjbRef ejbRef = new EjbRef();
+
+        // This is how we deal with the fact that we don't know
+        // whether to use an EjbLocalRef or EjbRef (remote).
+        // We flag it uknown and let the linking code take care of
+        // figuring out what to do with it.
+        ejbRef.setRefType(EjbRef.Type.UNKNOWN);
+
+        if (member != null) {
+            // Set the member name where this will be injected
+            InjectionTarget target = new InjectionTarget();
+            target.setInjectionTargetClass(member.getDeclaringClass().getName());
+            target.setInjectionTargetName(member.getName());
+            ejbRef.getInjectionTarget().add(target);
+        }
+
+        Class interfce = ejb.beanInterface();
+        if (interfce.equals(Object.class)) {
+            interfce = (member == null) ? null : member.getType();
+        }
+
+        if (interfce != null && !interfce.equals(Object.class)) {
+            if (EJBHome.class.isAssignableFrom(interfce)) {
+                ejbRef.setHome(interfce.getName());
+                Method[] methods = interfce.getMethods();
+                for (Method method : methods) {
+                    if (method.getName().startsWith("create")) {
+                        ejbRef.setRemote(method.getReturnType().getName());
+                        break;
+                    }
+                }
+                ejbRef.setRefType(EjbRef.Type.REMOTE);
+            } else if (EJBLocalHome.class.isAssignableFrom(interfce)) {
+                ejbRef.setHome(interfce.getName());
+                Method[] methods = interfce.getMethods();
+                for (Method method : methods) {
+                    if (method.getName().startsWith("create")) {
+                        ejbRef.setRemote(method.getReturnType().getName());
+                        break;
+                    }
+                }
+                ejbRef.setRefType(EjbRef.Type.LOCAL);
+            } else {
+                ejbRef.setRemote(interfce.getName());
+                if (interfce.getAnnotation(Local.class) != null) {
+                    ejbRef.setRefType(EjbRef.Type.LOCAL);
+                } else if (interfce.getAnnotation(Remote.class) != null) {
+                    ejbRef.setRefType(EjbRef.Type.REMOTE);
+                }
+            }
+        }
+
+        // Get the ejb-ref-name
+        String refName = ejb.name();
+        if (refName.equals("")) {
+            refName = (member == null) ? null : member.getDeclaringClass().getName() + "/"
+ member.getName();
+        }
+        ejbRef.setEjbRefName(refName);
+
+        // Set the ejb-link, if any
+        String ejbName = ejb.beanName();
+        if (ejbName.equals("")) {
+            ejbName = null;
+        }
+        ejbRef.setEjbLink(ejbName);
+
+        // Set the mappedName, if any
+        String mappedName = ejb.mappedName();
+        if (mappedName.equals("")) {
+            mappedName = null;
+        }
+        ejbRef.setMappedName(mappedName);
+
+        switch (ejbRef.getRefType()) {
+            case UNKNOWN:
+            case REMOTE:
+                consumer.getEjbRef().add(ejbRef);
+                break;
+            case LOCAL:
+                consumer.getEjbLocalRef().add(new EjbLocalRef(ejbRef));
+                break;
+        }
+    }
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    static {
+        GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(EjbRefBuilder.class,
NameFactory.MODULE_BUILDER);
+
+        infoBuilder.addAttribute("eeNamespaces", String[].class, true, true);
+        infoBuilder.addAttribute("defaultEnvironment", Environment.class, true, true);
+        infoBuilder.addAttribute("host", String.class, true);
+        infoBuilder.addAttribute("port", int.class, true);
+
+        infoBuilder.setConstructor(new String[]{"defaultEnvironment", "eeNamespaces", "host",
"port"});
+
+        GBEAN_INFO = infoBuilder.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+
+}

Propchange: geronimo/server/branches/2.0-M2/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbRefBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/branches/2.0-M2/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbRefBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/branches/2.0-M2/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbRefBuilder.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/server/branches/2.0-M2/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/XmlUtil.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.0-M2/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/XmlUtil.java?view=diff&rev=499678&r1=499677&r2=499678
==============================================================================
--- geronimo/server/branches/2.0-M2/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/XmlUtil.java
(original)
+++ geronimo/server/branches/2.0-M2/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/XmlUtil.java
Wed Jan 24 22:31:08 2007
@@ -19,6 +19,7 @@
 
 import java.net.URL;
 import java.util.jar.JarFile;
+import java.util.Iterator;
 import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.IOException;
@@ -32,6 +33,8 @@
 import javax.xml.parsers.SAXParserFactory;
 import javax.xml.parsers.SAXParser;
 import javax.xml.transform.sax.SAXSource;
+import javax.ejb.SessionContext;
+import javax.ejb.EntityContext;
 
 import org.apache.geronimo.openejb.xbeans.ejbjar.OpenejbEjbJarDocument;
 import org.apache.geronimo.openejb.xbeans.ejbjar.OpenejbGeronimoEjbJarType;
@@ -48,6 +51,14 @@
 import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlDocumentProperties;
 import org.apache.openejb.jee.EjbJar;
+import org.apache.openejb.jee.EnterpriseBean;
+import org.apache.openejb.jee.MessageDestinationRef;
+import org.apache.openejb.jee.PersistenceContextRef;
+import org.apache.openejb.jee.PersistenceUnitRef;
+import org.apache.openejb.jee.ResourceRef;
+import org.apache.openejb.jee.ResourceEnvRef;
+import org.apache.openejb.jee.ServiceRef;
+import org.apache.openejb.jee.PersistenceContextType;
 import org.xml.sax.helpers.XMLFilterImpl;
 import org.xml.sax.XMLReader;
 import org.xml.sax.Attributes;
@@ -175,6 +186,15 @@
         // it would be nice if Jaxb had a way to convert the object to a
         // sax reader that could be fed directly into xmlbeans
         //
+
+        // the geronimo xml beans tree is totally broken... fix some obvious stuff here
+        for (EnterpriseBean enterpriseBean : ejbJar.getEnterpriseBeans()) {
+            for (PersistenceContextRef ref : enterpriseBean.getPersistenceContextRef()) {
+                if (ref.getPersistenceContextType() == PersistenceContextType.TRANSACTION)
{
+                    ref.setPersistenceContextType(null);
+                }
+            }
+        }
 
         // marshal to xml
         String xml = marshal(ejbJar);



Mime
View raw message