You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jb...@apache.org on 2003/09/04 07:33:39 UTC

cvs commit: incubator-geronimo/modules/core/src/java/org/apache/geronimo/xml/deployment EjbJarLoader.java J2EELoader.java

jboynes     2003/09/03 22:33:39

  Modified:    modules/core/src/java/org/apache/geronimo/xml/deployment
                        EjbJarLoader.java J2EELoader.java
  Log:
  GERONIMO-68 patch from Aaron Mulder
  
  Revision  Changes    Path
  1.2       +203 -2    incubator-geronimo/modules/core/src/java/org/apache/geronimo/xml/deployment/EjbJarLoader.java
  
  Index: EjbJarLoader.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/xml/deployment/EjbJarLoader.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- EjbJarLoader.java	2 Sep 2003 17:04:21 -0000	1.1
  +++ EjbJarLoader.java	4 Sep 2003 05:33:39 -0000	1.2
  @@ -1,3 +1,58 @@
  +/* ====================================================================
  + * The Apache Software License, Version 1.1
  + *
  + * Copyright (c) 2003 The Apache Software Foundation.  All rights
  + * reserved.
  + *
  + * Redistribution and use in source and binary forms, with or without
  + * modification, are permitted provided that the following conditions
  + * are met:
  + *
  + * 1. Redistributions of source code must retain the above copyright
  + *    notice, this list of conditions and the following disclaimer.
  + *
  + * 2. Redistributions in binary form must reproduce the above copyright
  + *    notice, this list of conditions and the following disclaimer in
  + *    the documentation and/or other materials provided with the
  + *    distribution.
  + *
  + * 3. The end-user documentation included with the redistribution,
  + *    if any, must include the following acknowledgment:
  + *       "This product includes software developed by the
  + *        Apache Software Foundation (http://www.apache.org/)."
  + *    Alternately, this acknowledgment may appear in the software itself,
  + *    if and wherever such third-party acknowledgments normally appear.
  + *
  + * 4. The names "Apache" and "Apache Software Foundation" and
  + *    "Apache Geronimo" must not be used to endorse or promote products
  + *    derived from this software without prior written permission. For
  + *    written permission, please contact apache@apache.org.
  + *
  + * 5. Products derived from this software may not be called "Apache",
  + *    "Apache Geronimo", nor may "Apache" appear in their name, without
  + *    prior written permission of the Apache Software Foundation.
  + *
  + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  + * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  + * SUCH DAMAGE.
  + * ====================================================================
  + *
  + * This software consists of voluntary contributions made by many
  + * individuals on behalf of the Apache Software Foundation.  For more
  + * information on the Apache Software Foundation, please see
  + * <http://www.apache.org/>.
  + *
  + * ====================================================================
  + */
   package org.apache.geronimo.xml.deployment;
   
   import org.w3c.dom.Document;
  @@ -16,11 +71,23 @@
   import org.apache.geronimo.deployment.model.ejb.ActivationConfig;
   import org.apache.geronimo.deployment.model.ejb.ActivationConfigProperty;
   import org.apache.geronimo.deployment.model.ejb.EjbJarDocument;
  +import org.apache.geronimo.deployment.model.ejb.Relationships;
  +import org.apache.geronimo.deployment.model.ejb.EjbRelation;
  +import org.apache.geronimo.deployment.model.ejb.EjbRelationshipRole;
  +import org.apache.geronimo.deployment.model.ejb.CmrField;
  +import org.apache.geronimo.deployment.model.ejb.RelationshipRoleSource;
  +import org.apache.geronimo.deployment.model.ejb.AssemblyDescriptor;
  +import org.apache.geronimo.deployment.model.ejb.ContainerTransaction;
  +import org.apache.geronimo.deployment.model.ejb.Method;
  +import org.apache.geronimo.deployment.model.ejb.SecurityRole;
  +import org.apache.geronimo.deployment.model.ejb.MethodPermission;
  +import org.apache.geronimo.deployment.model.ejb.ExcludeList;
   
   /**
  - * 
  + * Knows how to load a set of POJOs from a DOM representing an ejb-jar.xml
  + * deployment descriptor.
    *
  - * @version $Revision$
  + * @version $Revision$ $Date$
    */
   public class EjbJarLoader {
       public static EjbJarDocument load(Document doc) {
  @@ -37,9 +104,143 @@
               eb.setEntity(loadEntities(ebe));
               eb.setMessageDriven(loadMessageDrivens(ebe));
           }
  +        Element re = LoaderUtil.getChild(root, "relationships");
  +        if(re != null) {
  +            Relationships rel = new Relationships();
  +            J2EELoader.loadDescribable(re, rel);
  +            rel.setEjbRelation(loadEjbRelations(re));
  +            jar.setRelationships(rel);
  +        }
  +        Element ade = LoaderUtil.getChild(root, "assembly-descriptor");
  +        if(ade != null) {
  +            AssemblyDescriptor ad = new AssemblyDescriptor();
  +            ad.setContainerTransaction(loadContainerTransactions(ade));
  +            ad.setExcludeList(loadExcludeList(LoaderUtil.getChild(ade, "exclude-list")));
  +            ad.setMessageDestination(J2EELoader.loadMessageDestinations(ade));
  +            ad.setMethodPermission(loadMethodPermissions(ade));
  +            ad.setSecurityRole(loadSecurityRoles(ade));
  +            jar.setAssemblyDescriptor(ad);
  +        }
           EjbJarDocument result = new EjbJarDocument();
           result.setEjbJar(jar);
           return result;
  +    }
  +
  +    private static ExcludeList loadExcludeList(Element parent) {
  +        if(parent == null) {
  +            return null;
  +        }
  +        ExcludeList list = new ExcludeList();
  +        J2EELoader.loadDescribable(parent, list);
  +        list.setMethod(loadMethods(parent));
  +        return list;
  +    }
  +
  +    private static MethodPermission[] loadMethodPermissions(Element parent) {
  +        Element[] roots = LoaderUtil.getChildren(parent, "method-permission");
  +        MethodPermission[] perms = new MethodPermission[roots.length];
  +        for(int i = 0; i < roots.length; i++) {
  +            Element root = roots[i];
  +            perms[i] = new MethodPermission();
  +            J2EELoader.loadDescribable(root, perms[i]);
  +            perms[i].setUnchecked(LoaderUtil.getChild(root, "unchecked") != null);
  +            perms[i].setRoleName(LoaderUtil.getChildContent(root, "role-name"));
  +            perms[i].setMethod(loadMethods(root));
  +        }
  +        return perms;
  +    }
  +
  +    private static SecurityRole[] loadSecurityRoles(Element parent) {
  +        Element[] roots = LoaderUtil.getChildren(parent, "security-role");
  +        SecurityRole[] roles = new SecurityRole[roots.length];
  +        for(int i = 0; i < roots.length; i++) {
  +            Element root = roots[i];
  +            roles[i] = new SecurityRole();
  +            J2EELoader.loadDescribable(root, roles[i]);
  +            roles[i].setRoleName(LoaderUtil.getChildContent(root, "role-name"));
  +        }
  +        return roles;
  +    }
  +
  +    private static ContainerTransaction[] loadContainerTransactions(Element parent) {
  +        Element[] roots = LoaderUtil.getChildren(parent, "container-transaction");
  +        ContainerTransaction[] tx = new ContainerTransaction[roots.length];
  +        for(int i = 0; i < roots.length; i++) {
  +            Element root = roots[i];
  +            tx[i] = new ContainerTransaction();
  +            J2EELoader.loadDescribable(root, tx[i]);
  +            tx[i].setTransAttribute(LoaderUtil.getChildContent(root, "trans-attribute"));
  +            tx[i].setMethod(loadMethods(root));
  +        }
  +        return tx;
  +    }
  +
  +    private static Method[] loadMethods(Element parent) {
  +        Element[] roots = LoaderUtil.getChildren(parent, "method");
  +        Method[] meth = new Method[roots.length];
  +        for(int i = 0; i < roots.length; i++) {
  +            Element root = roots[i];
  +            meth[i] = new Method();
  +            J2EELoader.loadDescribable(root, meth[i]);
  +            meth[i].setEjbName(LoaderUtil.getChildContent(root, "ejb-name"));
  +            meth[i].setMethodIntf(LoaderUtil.getChildContent(root, "method-intf"));
  +            meth[i].setMethodName(LoaderUtil.getChildContent(root, "method-name"));
  +            Element e = LoaderUtil.getChild(root, "method-params");
  +            if(e != null) {
  +                meth[i].setMethodParam(LoaderUtil.getChildrenContent(e, "method-param"));
  +            }
  +        }
  +        return meth;
  +    }
  +
  +    private static EjbRelation[] loadEjbRelations(Element parent) {
  +        Element[] roots = LoaderUtil.getChildren(parent, "ejb-relation");
  +        EjbRelation[] rels = new EjbRelation[roots.length];
  +        for(int i = 0; i < roots.length; i++) {
  +            Element root = roots[i];
  +            rels[i] = new EjbRelation();
  +            J2EELoader.loadDescribable(root, rels[i]);
  +            rels[i].setEjbRelationName(LoaderUtil.getChildContent(root, "ejb-relation-name"));
  +            rels[i].setEjbRelationshipRole(loadRelationshipRoles(root));
  +        }
  +        return rels;
  +    }
  +
  +    private static EjbRelationshipRole[] loadRelationshipRoles(Element parent) {
  +        Element[] roots = LoaderUtil.getChildren(parent, "ejb-relationship-role");
  +        EjbRelationshipRole[] roles = new EjbRelationshipRole[roots.length];
  +        for(int i = 0; i < roots.length; i++) {
  +            Element root = roots[i];
  +            roles[i] = new EjbRelationshipRole();
  +            J2EELoader.loadDescribable(root, roles[i]);
  +            roles[i].setEjbRelationshipRoleName(LoaderUtil.getChildContent(root, "ejb-relationship-role-name"));
  +            roles[i].setMultiplicity(LoaderUtil.getChildContent(root, "multiplicity"));
  +            roles[i].setCascadeDelete(LoaderUtil.getChild(root, "cascade-delete") != null);
  +            roles[i].setRelationshipRoleSource(loadRelationshipRoleSource(LoaderUtil.getChild(root, "relationship-role-source")));
  +            roles[i].setCmrField(loadCmrField(LoaderUtil.getChild(root, "cmr-field")));
  +        }
  +        return roles;
  +    }
  +
  +    private static RelationshipRoleSource loadRelationshipRoleSource(Element parent) {
  +        if(parent == null) {
  +            return null;
  +        }
  +        RelationshipRoleSource source = new RelationshipRoleSource();
  +        J2EELoader.loadDescribable(parent, source);
  +        source.setEjbName(LoaderUtil.getChildContent(parent, "ejb-name"));
  +        return source;
  +    }
  +
  +    private static CmrField loadCmrField(Element parent) {
  +        if(parent == null) {
  +            return null;
  +        }
  +        CmrField field = new CmrField();
  +        J2EELoader.loadDescribable(parent, field);
  +        field.setCmrFieldName(LoaderUtil.getChildContent(parent, "cmr-field-name"));
  +        field.setCmrFieldType(LoaderUtil.getChildContent(parent, "cmr-field-type"));
  +        return field;
       }
   
       private static MessageDriven[] loadMessageDrivens(Element parent) {
  
  
  
  1.3       +11 -11    incubator-geronimo/modules/core/src/java/org/apache/geronimo/xml/deployment/J2EELoader.java
  
  Index: J2EELoader.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/xml/deployment/J2EELoader.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- J2EELoader.java	2 Sep 2003 17:04:21 -0000	1.2
  +++ J2EELoader.java	4 Sep 2003 05:33:39 -0000	1.3
  @@ -77,7 +77,8 @@
   import org.w3c.dom.NodeList;
   
   /**
  - *
  + * Knows how to load common J2EE deployment descriptor elements from a DOM
  + * into POJOs.
    *
    * @version $Revision$ $Date$
    */
  @@ -240,16 +241,15 @@
       }
   
       public static MessageDestination[] loadMessageDestinations(Element parent) {
  -        NodeList nodes = parent.getElementsByTagName("message-destination");
  -        int length = nodes.getLength();
  -        MessageDestination[] result = new MessageDestination[length];
  -        for (int i = 0; i < length; i++) {
  -            Element e = (Element) nodes.item(i);
  -            MessageDestination msgDdest = new MessageDestination();
  -            msgDdest.setMessageDestinationName(LoaderUtil.getChildContent(e, "message-destination-name"));
  -            result[i] = msgDdest;
  +        Element[] roots = LoaderUtil.getChildren(parent, "message-destination");
  +        MessageDestination[] dest = new MessageDestination[roots.length];
  +        for(int i = 0; i < roots.length; i++) {
  +            Element root = roots[i];
  +            dest[i] = new MessageDestination();
  +            loadDisplayable(root, dest[i]);
  +            dest[i].setMessageDestinationName(LoaderUtil.getChildContent(root, "message-destination-name"));
           }
  -        return result;
  +        return dest;
       }
   
       public static MessageDestinationRef[] loadMessageDestinationRefs(Element parent) {