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:24:22 UTC

cvs commit: incubator-geronimo/modules/core/src/java/org/apache/geronimo/enterprise/deploy/tool AbstractDeployableObject.java EjbDeployableObject.java DDBeanImpl.java DDBeanRootImpl.java

jboynes     2003/09/03 22:24:22

  Modified:    modules/core/src/conf/twiddle geronimo.conf
               modules/core/src/java/org/apache/geronimo/enterprise/deploy/provider
                        EjbJarDeploymentConfiguration.java
               modules/core/src/java/org/apache/geronimo/enterprise/deploy/provider/jar
                        BaseEjbBean.java BaseEjbBeanBeanInfo.java
                        ContextParam.java EjbConverter.java
                        EjbLocalRefBean.java EntityBean.java
                        EntityBeanBeanInfo.java EnvEntryBean.java
                        ResourceEnvRefBean.java ResourceRefBean.java
                        SecurityRoleRefBean.java SessionBean.java
                        SessionBeanBeanInfo.java
               modules/core/src/java/org/apache/geronimo/enterprise/deploy/tool
                        DDBeanImpl.java DDBeanRootImpl.java
  Added:       modules/core/src/bin deploy deploy.bat
               modules/core/src/java/org/apache/geronimo/command
                        DeployCommand.java
               modules/core/src/java/org/apache/geronimo/enterprise/deploy/tool
                        AbstractDeployableObject.java
                        EjbDeployableObject.java
  Log:
  GERONIMO-10 patch (v5)  from Aaron Mulder
  
  Revision  Changes    Path
  1.1                  incubator-geronimo/modules/core/src/bin/deploy
  
  Index: deploy
  ===================================================================
  #!/bin/sh
  ##############################################################################
  ##                                                                          ##
  ##  Twiddle Proxy for UN*X                                                  ##
  ##                                                                          ##
  ##############################################################################
  
  ##
  ## $Revision: 1.1 $ $Date: 2003/09/04 05:24:21 $
  ##
  
  DIRNAME=`dirname "$0"`
  COMMAND_PATH="geronimo/deploy"
  
  exec "$DIRNAME/twiddle" $TWIDDLE_OPTS "$COMMAND_PATH" -- "$@"
  
  
  
  1.1                  incubator-geronimo/modules/core/src/bin/deploy.bat
  
  Index: deploy.bat
  ===================================================================
  @if "%DEBUG%" == "" @echo off
  @rem ##########################################################################
  @rem                                                                         ##
  @rem  Twiddle Proxy for Windowz                                              ##
  @rem                                                                         ##
  @rem ##########################################################################
  
  @rem 
  @rem $Revision: 1.1 $ $Date: 2003/09/04 05:24:21 $
  @rem 
  
  @rem Set local scope for the variables with windows NT shell
  if "%OS%"=="Windows_NT" setlocal
  
  @rem The path of the command to execute
  set COMMAND_PATH=geronimo/deploy
  
  :begin
  @rem Determine what directory it is in.
  set DIRNAME=%~dp0
  if "%DIRNAME%" == "" set DIRNAME=.\
  
  :init
  @rem Get command-line arguments, handling Windowz variants
  if not "%OS%" == "Windows_NT" goto win9xME_args
  if "%eval[2+2]" == "4" goto 4NT_args
  
  @rem Regular WinNT shell
  set CMD_LINE_ARGS=%*
  goto execute
  
  :win9xME_args
  @rem Slurp the command line arguments.
  set CMD_LINE_ARGS=
  
  :win9xME_args_slurp
  if "x%1" == "x" goto execute
  set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1
  shift
  goto win9xME_args_slurp
  
  :4NT_args
  @rem Get arguments from the 4NT Shell from JP Software
  set CMD_LINE_ARGS=%$
  
  :execute
  @rem Setup the command line
  set TWIDDLE_CMD=%DIRNAME%twiddle.bat
  
  @rem Execute Twiddle
  call "%TWIDDLE_CMD%" %TWIDDLE_OPTS% "%COMMAND_PATH%" -- %CMD_LINE_ARGS%
  
  :end
  @rem End local scope for the variables with windows NT shell
  if "%OS%"=="Windows_NT" endlocal
  
  
  
  
  1.4       +4 -1      incubator-geronimo/modules/core/src/conf/twiddle/geronimo.conf
  
  Index: geronimo.conf
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/conf/twiddle/geronimo.conf,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- geronimo.conf	28 Aug 2003 11:02:10 -0000	1.3
  +++ geronimo.conf	4 Sep 2003 05:24:21 -0000	1.4
  @@ -19,6 +19,9 @@
       <command name="geronimo/start"
                code="org.apache.geronimo.command.StartCommand"
                realm="twiddle.geronimo"/>
  +    <command name="geronimo/deploy"
  +             code="org.apache.geronimo.command.DeployCommand"
  +             realm="twiddle.geronimo"/>
     </commands>
   
   </configuration>
  
  
  
  1.1                  incubator-geronimo/modules/core/src/java/org/apache/geronimo/command/DeployCommand.java
  
  Index: DeployCommand.java
  ===================================================================
  /* ====================================================================
   * 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.command;
  
  import java.io.PrintWriter;
  import java.io.File;
  
  import org.apache.commons.cli.CommandLine;
  import org.apache.commons.cli.CommandLineParser;
  import org.apache.commons.cli.OptionBuilder;
  import org.apache.commons.cli.Options;
  import org.apache.commons.cli.PosixParser;
  import org.apache.geronimo.console.cli.Deployer;
  import org.apache.geronimo.common.NullArgumentException;
  import org.apache.geronimo.twiddle.command.AbstractCommand;
  import org.apache.geronimo.twiddle.command.Command;
  import org.apache.geronimo.twiddle.command.CommandInfo;
  import org.apache.geronimo.twiddle.util.HelpFormatter;
  
  /**
   * A <em>Twiddle</em> command to configure and/or deploy a J2EE module
   *
   * @version $Revision: 1.1 $ $Date: 2003/09/04 05:24:21 $
   */
  public class DeployCommand
      extends AbstractCommand
  {
  
      /**
       * Manages help and command line arguments, and hands control over to the
       * {@link Deployer} to handle the user interaction and resulting work. 
       */
      public int execute(String[] args) throws Exception
      {
          if (args == null) {
              throw new NullArgumentException("args");
          }
          
          // Get our output writer
          PrintWriter out = getWriter();
          
          // Create the Options
          Options options = new Options();
          options.addOption(OptionBuilder.withLongOpt("help")
                                         .withDescription("Display this help message")
                                         .create('h'));
  
          // Create the command line parser
          CommandLineParser parser = new PosixParser();
          
          // Carse the command line arguments
          CommandLine line = parser.parse(options, args);
          
          // Display help
          args = line.getArgs();
          if (line.hasOption('h') || args.length > 1) {
              CommandInfo info = getCommandInfo();
              if (info.hasDescription()) {
                  out.println(info.getDescription());
                  out.println();
              }
              
              HelpFormatter formatter = new HelpFormatter(out);
              formatter.print(info.getName() + " [options] [EJB_JAR_File]", options);
              
              return Command.SUCCESS;
          }
          
  //        String homeDir = Twiddle.getHomeDir().toString(); todo: do we need to use this when resolving the file?
          Deployer deployer;
          if(args.length == 1) {
              File file = new File(args[0]);
              if(!file.exists() || !file.canRead() || file.isDirectory()) {
                  out.println("ERROR: Unable to read file "+file.getAbsolutePath());
                  return Command.FAILURE;
              }
              deployer = new Deployer(file, out, getReader());
          } else {
              deployer = new Deployer(out, getReader());
          }
          deployer.run();
  
          return Command.SUCCESS;
      }
  }
  
  
  
  1.2       +20 -23    incubator-geronimo/modules/core/src/java/org/apache/geronimo/enterprise/deploy/provider/EjbJarDeploymentConfiguration.java
  
  Index: EjbJarDeploymentConfiguration.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/enterprise/deploy/provider/EjbJarDeploymentConfiguration.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- EjbJarDeploymentConfiguration.java	22 Aug 2003 19:03:37 -0000	1.1
  +++ EjbJarDeploymentConfiguration.java	4 Sep 2003 05:24:21 -0000	1.2
  @@ -60,19 +60,19 @@
   import java.io.InputStreamReader;
   import java.io.OutputStreamWriter;
   import java.io.IOException;
  +import java.io.Reader;
   import javax.enterprise.deploy.spi.DeploymentConfiguration;
   import javax.enterprise.deploy.spi.DConfigBeanRoot;
   import javax.enterprise.deploy.spi.exceptions.ConfigurationException;
   import javax.enterprise.deploy.spi.exceptions.BeanNotFoundException;
   import javax.enterprise.deploy.model.DeployableObject;
   import javax.enterprise.deploy.model.DDBeanRoot;
  -import org.exolab.castor.xml.Unmarshaller;
  -import org.exolab.castor.xml.MarshalException;
  -import org.exolab.castor.xml.ValidationException;
  -import org.exolab.castor.xml.Marshaller;
  -import org.apache.geronimo.enterprise.deploy.common.EjbJar;
  +import org.w3c.dom.Document;
   import org.apache.geronimo.enterprise.deploy.provider.jar.EjbConverter;
   import org.apache.geronimo.enterprise.deploy.provider.jar.EjbJarRoot;
  +import org.apache.geronimo.xml.deployment.GeronimoEjbJarLoader;
  +import org.apache.geronimo.xml.deployment.LoaderUtil;
  +import org.apache.geronimo.deployment.model.geronimo.ejb.GeronimoEjbJarDocument;
   
   /**
    * The Geronimo implementation of the JSR-88 DeploymentConfiguration.  This is what
  @@ -95,7 +95,7 @@
       }
   
       public DConfigBeanRoot getDConfigBeanRoot(DDBeanRoot bean) throws ConfigurationException {
  -        if(bean.equals(ejbDD)) {
  +        if(bean.equals(ejbDD.getDDBeanRoot())) {
               return geronimoDD;
           } else {
               throw new ConfigurationException("This DeploymentConfiguration does not handle the DDBeanRoot "+bean);
  @@ -122,24 +122,21 @@
       }
   
       public void restore(InputStream inputArchive) throws ConfigurationException {
  -        try {
  -            geronimoDD = EjbConverter.loadDConfigBeans((EjbJar)new Unmarshaller(EjbJar.class).unmarshal(new InputStreamReader(inputArchive)), ejbDD.getDDBeanRoot());
  -        } catch(MarshalException e) {
  -            throw new ConfigurationException("Unable to load configuration: "+e.getMessage());
  -        } catch(ValidationException e) {
  -            throw new ConfigurationException("Unable to load configuration: "+e.getMessage());
  -        }
  +        Reader reader = new InputStreamReader(inputArchive);
  +        Document doc = LoaderUtil.parseXML(reader, "geronimo-ejb-jar.xml");
  +        GeronimoEjbJarDocument parsed = GeronimoEjbJarLoader.load(doc);
  +        geronimoDD = EjbConverter.loadDConfigBeans(parsed.getEjbJar(), ejbDD.getDDBeanRoot());
       }
   
       public void save(OutputStream outputArchive) throws ConfigurationException {
  -        try {
  -            new Marshaller(new OutputStreamWriter(outputArchive)).marshal(EjbConverter.storeDConfigBeans(geronimoDD));
  -        } catch(MarshalException e) {
  -            throw new ConfigurationException("Unable to save configuration: "+e.getMessage());
  -        } catch(ValidationException e) {
  -            throw new ConfigurationException("Unable to save configuration: "+e.getMessage());
  -        } catch(IOException e) {
  -            throw new ConfigurationException("Unable to save configuration: "+e.getMessage());
  -        }
  +//        try {
  +//            new Marshaller(new OutputStreamWriter(outputArchive)).marshal(EjbConverter.storeDConfigBeans(geronimoDD));
  +//        } catch(MarshalException e) {
  +//            throw new ConfigurationException("Unable to save configuration: "+e.getMessage());
  +//        } catch(ValidationException e) {
  +//            throw new ConfigurationException("Unable to save configuration: "+e.getMessage());
  +//        } catch(IOException e) {
  +//            throw new ConfigurationException("Unable to save configuration: "+e.getMessage());
  +//        }
       }
   }
  
  
  
  1.3       +8 -44     incubator-geronimo/modules/core/src/java/org/apache/geronimo/enterprise/deploy/provider/jar/BaseEjbBean.java
  
  Index: BaseEjbBean.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/enterprise/deploy/provider/jar/BaseEjbBean.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BaseEjbBean.java	27 Aug 2003 10:33:34 -0000	1.2
  +++ BaseEjbBean.java	4 Sep 2003 05:24:21 -0000	1.3
  @@ -74,22 +74,19 @@
    * @version $Revision$ $Date$
    */
   public class BaseEjbBean extends BaseDConfigBean {
  -    private static final Log log = LogFactory.getLog(EnterpriseBeansBean.class);
  +    private static final Log log = LogFactory.getLog(BaseEjbBean.class);
       final static String EJB_NAME_XPATH = "ejb-name";
       final static String ENV_ENTRY_XPATH = "env-entry";
       final static String EJB_REF_XPATH = "ejb-ref";
       final static String EJB_LOCAL_REF_XPATH = "ejb-local-ref";
  -    final static String SECURITY_ROLE_REF_XPATH = "security-role-ref";
       final static String RESOURCE_REF_XPATH = "resource-ref";
       final static String RESOURCE_ENV_REF_XPATH = "resource-env-ref";
       private String ejbName;
  -    private String jndiName;
       private List envEntries = new ArrayList();
       private List ejbRefs = new ArrayList();
       private List ejbLocalRefs = new ArrayList();
       private List resourceRefs = new ArrayList();
       private List resourceEnvRefs = new ArrayList();
  -    private List securityRoleRefs = new ArrayList();
   
       /**
        * This is present for JavaBeans compliance, but if it is used, the
  @@ -98,13 +95,12 @@
        */
       public BaseEjbBean() {
           super(null);
  -        ejbName = jndiName = "";
  +        ejbName = "";
       }
   
       public BaseEjbBean(DDBean ddBean) {
           super(ddBean);
           ejbName = ddBean.getText(EJB_NAME_XPATH)[0];
  -        jndiName = ejbName;
           ddBean.addXpathListener(EJB_NAME_XPATH, new XpathListener() {
               public void fireXpathEvent(XpathEvent xpe) {
                   if(xpe.isChangeEvent() || xpe.isAddEvent()) {
  @@ -121,7 +117,6 @@
               ENV_ENTRY_XPATH,
               EJB_REF_XPATH,
               EJB_LOCAL_REF_XPATH,
  -            SECURITY_ROLE_REF_XPATH,
               RESOURCE_REF_XPATH,
               RESOURCE_ENV_REF_XPATH,
           }; // ejb-name is not included, since we don't have a DConfigBean for it
  @@ -156,10 +151,6 @@
               if(!envEntries.remove(bean)) {
                   throw new BeanNotFoundException("Could not find Env Entry "+((EnvEntryBean)bean).getEnvEntryName()+" to remove");
               }
  -        } else if(bean instanceof SecurityRoleRefBean) {
  -            if(!securityRoleRefs.remove(bean)) {
  -                throw new BeanNotFoundException("Could not find Security Role Reference "+((SecurityRoleRefBean)bean).getRoleName()+" to remove");
  -            }
           } else {
               throw new BeanNotFoundException("No such child bean "+bean.getClass().getName());
           }
  @@ -192,17 +183,7 @@
           pcs.firePropertyChange("ejbName", old, ejbName);
       }
   
  -    public String getJndiName() {
  -        return jndiName;
  -    }
  -
  -    public void setJndiName(String jndiName) {
  -        String old = this.jndiName;
  -        this.jndiName = jndiName;
  -        pcs.firePropertyChange("jndiName", old, jndiName);
  -    }
  -
  -    private DConfigBean getDConfigBean(DDBean bean, boolean create) {
  +    protected DConfigBean getDConfigBean(DDBean bean, boolean create) {
           if(bean.getXpath().equals(EJB_REF_XPATH)) {
               for(Iterator it = ejbRefs.iterator(); it.hasNext();) {
                   DConfigBean dcb = (DConfigBean)it.next();
  @@ -263,22 +244,14 @@
                   envEntries.add(entry);
                   return entry;
               }
  -        } else if(bean.getXpath().equals(SECURITY_ROLE_REF_XPATH)) {
  -            for(Iterator it = securityRoleRefs.iterator(); it.hasNext();) {
  -                DConfigBean dcb = (DConfigBean)it.next();
  -                if(dcb.getDDBean().equals(bean)) {
  -                    return dcb;
  -                }
  -            }
  -            if(create) {
  -                DConfigBean ref = new SecurityRoleRefBean(bean);
  -                securityRoleRefs.add(ref);
  -                return ref;
  -            }
           }
           return null;
       }
   
  +    public String toString() {
  +        return ejbName;
  +    }
  +
       /**
        * Used by other classes in this package to store and restore.  A JSR-88
        * tool implementation should get the child DConfigBeans by calling
  @@ -322,14 +295,5 @@
        */
       List getResourceEnvRef() {
           return resourceEnvRefs;
  -    }
  -
  -    /**
  -     * Used by other classes in this package to store and restore.  A JSR-88
  -     * tool implementation should get the child DConfigBeans by calling
  -     * getDConfigBean for each of the DDBeans.
  -     */
  -    List getSecurityRoleRef() {
  -        return securityRoleRefs;
       }
   }
  
  
  
  1.3       +2 -6      incubator-geronimo/modules/core/src/java/org/apache/geronimo/enterprise/deploy/provider/jar/BaseEjbBeanBeanInfo.java
  
  Index: BaseEjbBeanBeanInfo.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/enterprise/deploy/provider/jar/BaseEjbBeanBeanInfo.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BaseEjbBeanBeanInfo.java	27 Aug 2003 10:33:34 -0000	1.2
  +++ BaseEjbBeanBeanInfo.java	4 Sep 2003 05:24:21 -0000	1.3
  @@ -84,12 +84,8 @@
               name.setBound(true);
               name.setDisplayName("EJB Name");
               name.setShortDescription("The unique name for this EJB");
  -            PropertyDescriptor jndi = new PropertyDescriptor("jndiName", BaseEjbBean.class);
  -            jndi.setBound(true);
  -            jndi.setDisplayName("JNDI Name");
  -            jndi.setShortDescription("The JNDI location where this EJB should be bound");
               return new PropertyDescriptor[] {
  -                name, jndi,
  +                name,
               };
           } catch(IntrospectionException e) {
               log.error("Error in BeanInfo", e);
  
  
  
  1.3       +2 -2      incubator-geronimo/modules/core/src/java/org/apache/geronimo/enterprise/deploy/provider/jar/ContextParam.java
  
  Index: ContextParam.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/enterprise/deploy/provider/jar/ContextParam.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ContextParam.java	27 Aug 2003 10:33:34 -0000	1.2
  +++ ContextParam.java	4 Sep 2003 05:24:21 -0000	1.3
  @@ -105,6 +105,6 @@
       }
   
       public String toString() {
  -        return "Context Param "+paramName+"="+paramValue;
  +        return paramName == null || paramName.equals("") ? "Empty" : paramName;
       }
   }
  
  
  
  1.3       +113 -68   incubator-geronimo/modules/core/src/java/org/apache/geronimo/enterprise/deploy/provider/jar/EjbConverter.java
  
  Index: EjbConverter.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/enterprise/deploy/provider/jar/EjbConverter.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- EjbConverter.java	27 Aug 2003 10:33:34 -0000	1.2
  +++ EjbConverter.java	4 Sep 2003 05:24:21 -0000	1.3
  @@ -65,20 +65,19 @@
   import javax.enterprise.deploy.spi.exceptions.ConfigurationException;
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  -import org.apache.geronimo.enterprise.deploy.common.EjbJar;
  -import org.apache.geronimo.enterprise.deploy.common.MessageDriven;
  -import org.apache.geronimo.enterprise.deploy.common.EjbRef;
  -import org.apache.geronimo.enterprise.deploy.common.Session;
  -import org.apache.geronimo.enterprise.deploy.common.Entity;
  -import org.apache.geronimo.enterprise.deploy.common.EnterpriseBeans;
  -import org.apache.geronimo.enterprise.deploy.common.Ejb;
  -import org.apache.geronimo.enterprise.deploy.common.EnvEntry;
  -import org.apache.geronimo.enterprise.deploy.common.EjbLocalRef;
  -import org.apache.geronimo.enterprise.deploy.common.ResourceRef;
  -import org.apache.geronimo.enterprise.deploy.common.ResourceEnvRef;
  -import org.apache.geronimo.enterprise.deploy.common.SecurityRoleRef;
  -import org.apache.geronimo.enterprise.deploy.common.JndiContextParam;
  -import org.apache.geronimo.enterprise.deploy.common.JndiContextParams;
  +import org.apache.geronimo.deployment.model.geronimo.ejb.EjbJar;
  +import org.apache.geronimo.deployment.model.geronimo.ejb.EnterpriseBeans;
  +import org.apache.geronimo.deployment.model.geronimo.ejb.Ejb;
  +import org.apache.geronimo.deployment.model.geronimo.ejb.MessageDriven;
  +import org.apache.geronimo.deployment.model.geronimo.ejb.Entity;
  +import org.apache.geronimo.deployment.model.geronimo.ejb.Session;
  +import org.apache.geronimo.deployment.model.geronimo.j2ee.EnvEntry;
  +import org.apache.geronimo.deployment.model.geronimo.j2ee.EjbRef;
  +import org.apache.geronimo.deployment.model.geronimo.j2ee.JndiContextParam;
  +import org.apache.geronimo.deployment.model.geronimo.j2ee.EjbLocalRef;
  +import org.apache.geronimo.deployment.model.geronimo.j2ee.ResourceRef;
  +import org.apache.geronimo.deployment.model.geronimo.j2ee.ResourceEnvRef;
  +import org.apache.geronimo.deployment.model.geronimo.j2ee.SecurityRoleRef;
   
   /**
    * Maps DConfigBeans to POJOs and vice versa.
  @@ -92,60 +91,76 @@
           EjbJarRoot root = new EjbJarRoot(standard);
           EjbJarBean ejbJar = (EjbJarBean)root.getDConfigBean(standard.getChildBean(EjbJarRoot.EJB_JAR_XPATH)[0]);
           EnterpriseBeansBean beans = (EnterpriseBeansBean)ejbJar.getDConfigBean(ejbJar.getDDBean().getChildBean(EjbJarBean.ENTERPRISE_BEANS_XPATH)[0]);
  -        assignSession(beans, custom.getEnterpriseBeans().getSession(), standard.getChildBean("session"));
  -        assignEntity(beans, custom.getEnterpriseBeans().getEntity(), standard.getChildBean("entity"));
  -        assignMessageDriven(beans, custom.getEnterpriseBeans().getMessageDriven(), standard.getChildBean("message-driven"));
  +        assignSession(beans, custom.getEnterpriseBeans().getSession(), beans.getDDBean().getChildBean(EnterpriseBeansBean.SESSION_XPATH));
  +        assignEntity(beans, custom.getEnterpriseBeans().getEntity(), beans.getDDBean().getChildBean(EnterpriseBeansBean.ENTITY_XPATH));
  +        assignMessageDriven(beans, custom.getEnterpriseBeans().getMessageDriven(), beans.getDDBean().getChildBean(EnterpriseBeansBean.MESSAGE_DRIVEN_XPATH));
           return root;
       }
   
  -    public static EjbJar storeDConfigBeans(EjbJarRoot root) {
  +    public static org.apache.geronimo.deployment.model.geronimo.ejb.EjbJar storeDConfigBeans(EjbJarRoot root) throws ConfigurationException {
           EjbJar jar = new EjbJar();
           jar.setEnterpriseBeans(new EnterpriseBeans());
  -        storeSession(jar.getEnterpriseBeans(), root.getEjbJar().getEnterpriseBeans().getSession().iterator());
  -        storeEntity(jar.getEnterpriseBeans(), root.getEjbJar().getEnterpriseBeans().getEntity().iterator());
  -        storeMessageDriven(jar.getEnterpriseBeans(), root.getEjbJar().getEnterpriseBeans().getMessageDriven().iterator());
  +        if(root == null || root.getEjbJar() == null) {
  +            throw new ConfigurationException("Insufficient configuration information to save.");
  +        }
  +        EnterpriseBeansBean beans = root.getEjbJar().getEnterpriseBeans();
  +        if(beans == null) {
  +            throw new ConfigurationException("Insufficient configuration information to save.");
  +        }
  +        storeSession(jar.getEnterpriseBeans(), beans.getSession().iterator());
  +        storeEntity(jar.getEnterpriseBeans(), beans.getEntity().iterator());
  +        storeMessageDriven(jar.getEnterpriseBeans(), beans.getMessageDriven().iterator());
           return jar;
       }
   
       private static void storeEjb(Ejb dest, BaseEjbBean bean) {
           dest.setEjbName(bean.getEjbName());
  -        dest.setJndiName(bean.getJndiName());
           storeEnvEntries(dest, bean.getEnvEntry().iterator());
           storeEjbRefs(dest, bean.getEjbRef().iterator());
           storeEjbLocalRefs(dest, bean.getEjbLocalRef().iterator());
           storeResourceRefs(dest, bean.getResourceRef().iterator());
           storeResourceEnvRefs(dest, bean.getResourceEnvRef().iterator());
  -        storeSecurityRoleRefs(dest, bean.getSecurityRoleRef().iterator());
       }
   
       private static void storeMessageDriven(EnterpriseBeans beans, Iterator iterator) {
  +        List list = new ArrayList();
           while(iterator.hasNext()) {
               MessageDrivenBean bean = (MessageDrivenBean)iterator.next();
               MessageDriven md = new MessageDriven();
               storeEjb(md, bean);
  -            beans.addMessageDriven(md);
  +            list.add(md);
           }
  +        beans.setMessageDriven((MessageDriven[])list.toArray(new MessageDriven[list.size()]));
       }
   
       private static void storeEntity(EnterpriseBeans beans, Iterator iterator) {
  +        List list = new ArrayList();
           while(iterator.hasNext()) {
               EntityBean bean = (EntityBean)iterator.next();
               Entity e = new Entity();
               storeEjb(e, bean);
  -            beans.addEntity(e);
  +            e.setJndiName(bean.getJndiName());
  +            storeSecurityRoleRefs(e, bean.getSecurityRoleRef().iterator());
  +            list.add(e);
           }
  +        beans.setEntity((Entity[])list.toArray(new Entity[list.size()]));
       }
   
       private static void storeSession(EnterpriseBeans beans, Iterator iterator) {
  +        List list = new ArrayList();
           while(iterator.hasNext()) {
               SessionBean bean = (SessionBean)iterator.next();
               Session s = new Session();
               storeEjb(s, bean);
  -            beans.addSession(s);
  +            s.setJndiName(bean.getJndiName());
  +            storeSecurityRoleRefs(s, bean.getSecurityRoleRef().iterator());
  +            list.add(s);
           }
  +        beans.setSession((Session[])list.toArray(new Session[list.size()]));
       }
   
       private static void storeEnvEntries(Ejb dest, Iterator it) {
  +        List list = new ArrayList();
           while(it.hasNext()) {
               EnvEntryBean bean = (EnvEntryBean)it.next();
               String standard = bean.getDDBean().getText(EnvEntryBean.ENV_ENTRY_VALUE_XPATH)[0];
  @@ -153,12 +168,14 @@
                   EnvEntry e = new EnvEntry();
                   e.setEnvEntryName(bean.getEnvEntryName());
                   e.setEnvEntryValue(bean.getEnvEntryValue());
  -                dest.addEnvEntry(e);
  +                list.add(e);
               }
           }
  +        dest.setEnvEntry((EnvEntry[])list.toArray(new EnvEntry[list.size()]));
       }
   
       private static void storeEjbRefs(Ejb dest, Iterator it) {
  +        List outer = new ArrayList();
           while(it.hasNext()) {
               EjbRefBean bean = (EjbRefBean)it.next();
               if(isValid(bean.getJndiName())) {
  @@ -176,16 +193,16 @@
                       }
                   }
                   if(list.size() > 0) {
  -                    JndiContextParams set = new JndiContextParams();
  -                    set.setJndiContextParam((JndiContextParam[])list.toArray(new JndiContextParam[list.size()]));
  -                    ref.setJndiContextParams(set);
  +                    ref.setJndiContextParam((JndiContextParam[])list.toArray(new JndiContextParam[list.size()]));
                   }
  -                dest.addEjbRef(ref);
  +                outer.add(ref);
               }
           }
  +        dest.setEjbRef((EjbRef[])outer.toArray(new EjbRef[outer.size()]));
       }
   
       private static void storeEjbLocalRefs(Ejb dest, Iterator it) {
  +        List outer = new ArrayList();
           while(it.hasNext()) {
               EjbLocalRefBean bean = (EjbLocalRefBean)it.next();
               if(isValid(bean.getJndiName())) {
  @@ -203,16 +220,16 @@
                       }
                   }
                   if(list.size() > 0) {
  -                    JndiContextParams set = new JndiContextParams();
  -                    set.setJndiContextParam((JndiContextParam[])list.toArray(new JndiContextParam[list.size()]));
  -                    ref.setJndiContextParams(set);
  +                    ref.setJndiContextParam((JndiContextParam[])list.toArray(new JndiContextParam[list.size()]));
                   }
  -                dest.addEjbLocalRef(ref);
  +                outer.add(ref);
               }
           }
  +        dest.setEjbLocalRef((EjbLocalRef[])outer.toArray(new EjbLocalRef[outer.size()]));
       }
   
       private static void storeResourceRefs(Ejb dest, Iterator it) {
  +        List outer = new ArrayList();
           while(it.hasNext()) {
               ResourceRefBean bean = (ResourceRefBean)it.next();
               if(isValid(bean.getJndiName())) {
  @@ -230,28 +247,45 @@
                       }
                   }
                   if(list.size() > 0) {
  -                    JndiContextParams set = new JndiContextParams();
  -                    set.setJndiContextParam((JndiContextParam[])list.toArray(new JndiContextParam[list.size()]));
  -                    ref.setJndiContextParams(set);
  +                    ref.setJndiContextParam((JndiContextParam[])list.toArray(new JndiContextParam[list.size()]));
                   }
  -                dest.addResourceRef(ref);
  +                outer.add(ref);
               }
           }
  +        dest.setResourceRef((ResourceRef[])outer.toArray(new ResourceRef[outer.size()]));
       }
   
       private static void storeResourceEnvRefs(Ejb dest, Iterator it) {
  +        List list = new ArrayList();
           while(it.hasNext()) {
               ResourceEnvRefBean bean = (ResourceEnvRefBean)it.next();
               if(isValid(bean.getJndiName())) {
                   ResourceEnvRef ref = new ResourceEnvRef();
                   ref.setResourceEnvRefName(bean.getResourceEnvRefName());
                   ref.setJndiName(bean.getJndiName());
  -                dest.addResourceEnvRef(ref);
  +                list.add(ref);
  +            }
  +        }
  +        dest.setResourceEnvRef((ResourceEnvRef[])list.toArray(new ResourceEnvRef[list.size()]));
  +    }
  +
  +    private static void storeSecurityRoleRefs(Session dest, Iterator it) {
  +        List list = new ArrayList();
  +        while(it.hasNext()) {
  +            SecurityRoleRefBean bean = (SecurityRoleRefBean)it.next();
  +            String standard = bean.getDDBean().getText(SecurityRoleRefBean.ROLE_LINK_XPATH)[0];
  +            if(isValid(bean.getRoleLink()) && (standard == null || !standard.equals(bean.getRoleLink()))) {
  +                SecurityRoleRef ref = new SecurityRoleRef();
  +                ref.setRoleName(bean.getRoleName());
  +                ref.setRoleLink(bean.getRoleLink());
  +                list.add(ref);
               }
           }
  +        dest.setSecurityRoleRef((SecurityRoleRef[])list.toArray(new SecurityRoleRef[list.size()]));
       }
   
  -    private static void storeSecurityRoleRefs(Ejb dest, Iterator it) {
  +    private static void storeSecurityRoleRefs(Entity dest, Iterator it) {
  +        List list = new ArrayList();
           while(it.hasNext()) {
               SecurityRoleRefBean bean = (SecurityRoleRefBean)it.next();
               String standard = bean.getDDBean().getText(SecurityRoleRefBean.ROLE_LINK_XPATH)[0];
  @@ -259,9 +293,10 @@
                   SecurityRoleRef ref = new SecurityRoleRef();
                   ref.setRoleName(bean.getRoleName());
                   ref.setRoleLink(bean.getRoleLink());
  -                dest.addSecurityRoleRef(ref);
  +                list.add(ref);
               }
           }
  +        dest.setSecurityRoleRef((SecurityRoleRef[])list.toArray(new SecurityRoleRef[list.size()]));
       }
   
       private static void assignMessageDriven(EnterpriseBeansBean root, MessageDriven[] messageDriven, DDBean[] childBean) throws ConfigurationException {
  @@ -269,8 +304,10 @@
           for(int i=0; i<messageDriven.length; i++) {
               DDBean match = null;
               for(int j = 0; j < childBean.length; j++) {
  -                if(childBean[j].getText(BaseEjbBean.EJB_NAME_XPATH).equals(messageDriven[i].getEjbName())) {
  +                String[] names = childBean[j].getText(BaseEjbBean.EJB_NAME_XPATH);
  +                if(names.length == 1 && names[0].equals(messageDriven[i].getEjbName())) {
                       match = childBean[j];
  +                    break;
                   }
               }
               if(match == null) {
  @@ -287,7 +324,7 @@
               if(found.contains(bean)) {
                   continue;
               }
  -            log.info("Old DD does not contain an entry for Message-Driven EJB "+bean.getText(BaseEjbBean.EJB_NAME_XPATH)+"; adding a default entry");
  +            log.info("Old DD does not contain an entry for Message-Driven EJB "+bean.getText(BaseEjbBean.EJB_NAME_XPATH)[0]+"; adding a default entry");
               root.getDConfigBean(bean);
           }
       }
  @@ -297,8 +334,10 @@
           for(int i=0; i<sessions.length; i++) {
               DDBean match = null;
               for(int j = 0; j < childBean.length; j++) {
  -                if(childBean[j].getText(BaseEjbBean.EJB_NAME_XPATH).equals(sessions[i].getEjbName())) {
  +                String[] names = childBean[j].getText(BaseEjbBean.EJB_NAME_XPATH);
  +                if(names.length == 1 && names[0].equals(sessions[i].getEjbName())) {
                       match = childBean[j];
  +                    break;
                   }
               }
               if(match == null) {
  @@ -308,14 +347,16 @@
               found.add(match);
               SessionBean bean = (SessionBean)root.getDConfigBean(match);
               assignEjb(bean, sessions[i], match);
  -            //todo: any session-specific content
  +            //session-specific content
  +            bean.setJndiName(bean.getJndiName());
  +            assignSecurityRoleRefs(bean, sessions[i].getSecurityRoleRef(), match.getChildBean(EntityBean.SECURITY_ROLE_REF_XPATH));
           }
           for(int i = 0; i < childBean.length; i++) {
               DDBean bean = childBean[i];
               if(found.contains(bean)) {
                   continue;
               }
  -            log.info("Old DD does not contain an entry for Session EJB "+bean.getText(BaseEjbBean.EJB_NAME_XPATH)+"; adding a default entry");
  +            log.info("Old DD does not contain an entry for Session EJB "+bean.getText(BaseEjbBean.EJB_NAME_XPATH)[0]+"; adding a default entry");
               root.getDConfigBean(bean);
           }
       }
  @@ -325,8 +366,10 @@
           for(int i=0; i<entities.length; i++) {
               DDBean match = null;
               for(int j = 0; j < childBean.length; j++) {
  -                if(childBean[j].getText(BaseEjbBean.EJB_NAME_XPATH).equals(entities[i].getEjbName())) {
  +                String[] names = childBean[j].getText(BaseEjbBean.EJB_NAME_XPATH);
  +                if(names.length == 1 && names[0].equals(entities[i].getEjbName())) {
                       match = childBean[j];
  +                    break;
                   }
               }
               if(match == null) {
  @@ -336,27 +379,27 @@
               found.add(match);
               EntityBean bean = (EntityBean)root.getDConfigBean(match);
               assignEjb(bean, entities[i], match);
  -            //todo: any entity-specific content
  +            //entity-specific content
  +            bean.setJndiName(bean.getJndiName());
  +            assignSecurityRoleRefs(bean, entities[i].getSecurityRoleRef(), match.getChildBean(EntityBean.SECURITY_ROLE_REF_XPATH));
           }
           for(int i = 0; i < childBean.length; i++) {
               DDBean bean = childBean[i];
               if(found.contains(bean)) {
                   continue;
               }
  -            log.info("Old DD does not contain an entry for Entity EJB "+bean.getText(BaseEjbBean.EJB_NAME_XPATH)+"; adding a default entry");
  +            log.info("Old DD does not contain an entry for Entity EJB "+bean.getText(BaseEjbBean.EJB_NAME_XPATH)[0]+"; adding a default entry");
               root.getDConfigBean(bean);
           }
       }
   
       private static void assignEjb(BaseEjbBean dest, Ejb bean, DDBean standard) throws ConfigurationException {
           dest.setEjbName(bean.getEjbName());
  -        dest.setJndiName(bean.getJndiName());
           assignEnvEntries(dest, bean.getEnvEntry(), standard.getChildBean(BaseEjbBean.ENV_ENTRY_XPATH));
           assignEjbRefs(dest, bean.getEjbRef(), standard.getChildBean(BaseEjbBean.EJB_REF_XPATH));
           assignEjbLocalRefs(dest, bean.getEjbLocalRef(), standard.getChildBean(BaseEjbBean.EJB_LOCAL_REF_XPATH));
           assignResourceRefs(dest, bean.getResourceRef(), standard.getChildBean(BaseEjbBean.RESOURCE_REF_XPATH));
           assignResourceEnvRefs(dest, bean.getResourceEnvRef(), standard.getChildBean(BaseEjbBean.RESOURCE_ENV_REF_XPATH));
  -        assignSecurityRoleRefs(dest, bean.getSecurityRoleRef(), standard.getChildBean(BaseEjbBean.SECURITY_ROLE_REF_XPATH));
       }
   
       private static void assignEnvEntries(BaseEjbBean dest, EnvEntry[] entries, DDBean[] beans) throws ConfigurationException {
  @@ -364,7 +407,7 @@
           for(int i=0; i<entries.length; i++) {
               DDBean match = null;
               for(int j = 0; j < beans.length; j++) {
  -                if(beans[j].getText(EnvEntryBean.ENV_ENTRY_NAME_XPATH).equals(entries[i].getEnvEntryName())) {
  +                if(beans[j].getText(EnvEntryBean.ENV_ENTRY_NAME_XPATH)[0].equals(entries[i].getEnvEntryName())) {
                       match = beans[j];
                   }
               }
  @@ -376,13 +419,15 @@
               EnvEntryBean bean = (EnvEntryBean)dest.getDConfigBean(match);
               bean.setEnvEntryName(entries[i].getEnvEntryName());
               bean.setEnvEntryValue(entries[i].getEnvEntryValue());
  +            log.debug("Set env entry value for "+bean.hashCode()+" to "+bean.getEnvEntryValue()+" for "+match.hashCode());
  +            log.debug("Try reload: "+dest.getDConfigBean(match).hashCode()+" value is "+((EnvEntryBean)dest.getDConfigBean(match)).getEnvEntryValue());
           }
           for(int i = 0; i < beans.length; i++) {
               DDBean bean = beans[i];
               if(found.contains(bean)) {
                   continue;
               }
  -            log.info("Old DD does not contain an entry for Env Entry "+bean.getText(EnvEntryBean.ENV_ENTRY_NAME_XPATH)+"; adding a default entry");
  +            log.info("Old DD does not contain an entry for Env Entry "+bean.getText(EnvEntryBean.ENV_ENTRY_NAME_XPATH)[0]+"; adding a default entry");
               dest.getDConfigBean(bean);
           }
       }
  @@ -392,7 +437,7 @@
           for(int i=0; i<refs.length; i++) {
               DDBean match = null;
               for(int j = 0; j < beans.length; j++) {
  -                if(beans[j].getText(EjbRefBean.EJB_REF_NAME_XPATH).equals(refs[i].getEjbRefName())) {
  +                if(beans[j].getText(EjbRefBean.EJB_REF_NAME_XPATH)[0].equals(refs[i].getEjbRefName())) {
                       match = beans[j];
                   }
               }
  @@ -404,7 +449,7 @@
               EjbRefBean bean = (EjbRefBean)dest.getDConfigBean(match);
               bean.setEjbRefName(refs[i].getEjbRefName());
               bean.setJndiName(refs[i].getJndiName());
  -            JndiContextParam[] params = refs[i].getJndiContextParams().getJndiContextParam();
  +            JndiContextParam[] params = refs[i].getJndiContextParam();
               ContextParam[] cp = new ContextParam[params.length];
               for(int j=0; j<params.length; j++) {
                   cp[j] = new ContextParam();
  @@ -418,7 +463,7 @@
               if(found.contains(bean)) {
                   continue;
               }
  -            log.info("Old DD does not contain an entry for EJB Reference "+bean.getText(EjbRefBean.EJB_REF_NAME_XPATH)+"; adding a default entry");
  +            log.info("Old DD does not contain an entry for EJB Reference "+bean.getText(EjbRefBean.EJB_REF_NAME_XPATH)[0]+"; adding a default entry");
               dest.getDConfigBean(bean);
           }
       }
  @@ -428,7 +473,7 @@
           for(int i=0; i<refs.length; i++) {
               DDBean match = null;
               for(int j = 0; j < beans.length; j++) {
  -                if(beans[j].getText(EjbLocalRefBean.EJB_REF_NAME_XPATH).equals(refs[i].getEjbRefName())) {
  +                if(beans[j].getText(EjbLocalRefBean.EJB_REF_NAME_XPATH)[0].equals(refs[i].getEjbRefName())) {
                       match = beans[j];
                   }
               }
  @@ -440,7 +485,7 @@
               EjbLocalRefBean bean = (EjbLocalRefBean)dest.getDConfigBean(match);
               bean.setEjbRefName(refs[i].getEjbRefName());
               bean.setJndiName(refs[i].getJndiName());
  -            JndiContextParam[] params = refs[i].getJndiContextParams().getJndiContextParam();
  +            JndiContextParam[] params = refs[i].getJndiContextParam();
               ContextParam[] cp = new ContextParam[params.length];
               for(int j=0; j<params.length; j++) {
                   cp[j] = new ContextParam();
  @@ -454,7 +499,7 @@
               if(found.contains(bean)) {
                   continue;
               }
  -            log.info("Old DD does not contain an entry for EJB Reference "+bean.getText(EjbLocalRefBean.EJB_REF_NAME_XPATH)+"; adding a default entry");
  +            log.info("Old DD does not contain an entry for EJB Reference "+bean.getText(EjbLocalRefBean.EJB_REF_NAME_XPATH)[0]+"; adding a default entry");
               dest.getDConfigBean(bean);
           }
       }
  @@ -464,7 +509,7 @@
           for(int i=0; i<refs.length; i++) {
               DDBean match = null;
               for(int j = 0; j < beans.length; j++) {
  -                if(beans[j].getText(ResourceEnvRefBean.RESOURCE_ENV_REF_NAME_XPATH).equals(refs[i].getResourceEnvRefName())) {
  +                if(beans[j].getText(ResourceEnvRefBean.RESOURCE_ENV_REF_NAME_XPATH)[0].equals(refs[i].getResourceEnvRefName())) {
                       match = beans[j];
                   }
               }
  @@ -482,7 +527,7 @@
               if(found.contains(bean)) {
                   continue;
               }
  -            log.info("Old DD does not contain an entry for Resource Env Reference "+bean.getText(ResourceEnvRefBean.RESOURCE_ENV_REF_NAME_XPATH)+"; adding a default entry");
  +            log.info("Old DD does not contain an entry for Resource Env Reference "+bean.getText(ResourceEnvRefBean.RESOURCE_ENV_REF_NAME_XPATH)[0]+"; adding a default entry");
               dest.getDConfigBean(bean);
           }
       }
  @@ -492,7 +537,7 @@
           for(int i=0; i<refs.length; i++) {
               DDBean match = null;
               for(int j = 0; j < beans.length; j++) {
  -                if(beans[j].getText(ResourceRefBean.RES_REF_NAME_XPATH).equals(refs[i].getResRefName())) {
  +                if(beans[j].getText(ResourceRefBean.RES_REF_NAME_XPATH)[0].equals(refs[i].getResRefName())) {
                       match = beans[j];
                   }
               }
  @@ -504,7 +549,7 @@
               ResourceRefBean bean = (ResourceRefBean)dest.getDConfigBean(match);
               bean.setResRefName(refs[i].getResRefName());
               bean.setJndiName(refs[i].getJndiName());
  -            JndiContextParam[] params = refs[i].getJndiContextParams().getJndiContextParam();
  +            JndiContextParam[] params = refs[i].getJndiContextParam();
               ContextParam[] cp = new ContextParam[params.length];
               for(int j=0; j<params.length; j++) {
                   cp[j] = new ContextParam();
  @@ -518,7 +563,7 @@
               if(found.contains(bean)) {
                   continue;
               }
  -            log.info("Old DD does not contain an entry for Resource Reference "+bean.getText(ResourceRefBean.RES_REF_NAME_XPATH)+"; adding a default entry");
  +            log.info("Old DD does not contain an entry for Resource Reference "+bean.getText(ResourceRefBean.RES_REF_NAME_XPATH)[0]+"; adding a default entry");
               dest.getDConfigBean(bean);
           }
       }
  @@ -528,7 +573,7 @@
           for(int i=0; i<refs.length; i++) {
               DDBean match = null;
               for(int j = 0; j < beans.length; j++) {
  -                if(beans[j].getText(SecurityRoleRefBean.ROLE_NAME_XPATH).equals(refs[i].getRoleName())) {
  +                if(beans[j].getText(SecurityRoleRefBean.ROLE_NAME_XPATH)[0].equals(refs[i].getRoleName())) {
                       match = beans[j];
                   }
               }
  @@ -546,7 +591,7 @@
               if(found.contains(bean)) {
                   continue;
               }
  -            log.info("Old DD does not contain an entry for Security Role Reference "+bean.getText(SecurityRoleRefBean.ROLE_NAME_XPATH)+"; adding a default entry");
  +            log.info("Old DD does not contain an entry for Security Role Reference "+bean.getText(SecurityRoleRefBean.ROLE_NAME_XPATH)[0]+"; adding a default entry");
               dest.getDConfigBean(bean);
           }
       }
  
  
  
  1.3       +5 -1      incubator-geronimo/modules/core/src/java/org/apache/geronimo/enterprise/deploy/provider/jar/EjbLocalRefBean.java
  
  Index: EjbLocalRefBean.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/enterprise/deploy/provider/jar/EjbLocalRefBean.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- EjbLocalRefBean.java	27 Aug 2003 10:33:34 -0000	1.2
  +++ EjbLocalRefBean.java	4 Sep 2003 05:24:21 -0000	1.3
  @@ -155,4 +155,8 @@
           params[index] = param;
           pcs.firePropertyChange("contextParam", old, params);
       }
  +
  +    public String toString() {
  +        return ejbRefName;
  +    }
   }
  
  
  
  1.3       +72 -1     incubator-geronimo/modules/core/src/java/org/apache/geronimo/enterprise/deploy/provider/jar/EntityBean.java
  
  Index: EntityBean.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/enterprise/deploy/provider/jar/EntityBean.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- EntityBean.java	27 Aug 2003 10:33:34 -0000	1.2
  +++ EntityBean.java	4 Sep 2003 05:24:21 -0000	1.3
  @@ -55,7 +55,14 @@
    */
   package org.apache.geronimo.enterprise.deploy.provider.jar;
   
  +import java.util.List;
  +import java.util.ArrayList;
  +import java.util.Iterator;
   import javax.enterprise.deploy.model.DDBean;
  +import javax.enterprise.deploy.spi.DConfigBean;
  +import javax.enterprise.deploy.spi.exceptions.BeanNotFoundException;
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogFactory;
   
   /**
    * The DConfigBean for /ejb-jar/enterprise-beans/entity
  @@ -63,6 +70,11 @@
    * @version $Revision$ $Date$
    */
   public class EntityBean extends BaseEjbBean {
  +    private static final Log log = LogFactory.getLog(EntityBean.class);
  +    final static String SECURITY_ROLE_REF_XPATH = "security-role-ref";
  +    private String jndiName;
  +    private List securityRoleRefs = new ArrayList();
  +
       /**
        * This is present for JavaBeans compliance, but if it is used, the
        * DConfigBean won't be properly associated with a DDBean, so it
  @@ -70,9 +82,68 @@
        */
       public EntityBean() {
           super();
  +        jndiName = "";
       }
   
       public EntityBean(DDBean ddBean) {
           super(ddBean);
  +        jndiName = getEjbName();
  +    }
  +
  +    public String[] getXpaths() {
  +        return new String[] {
  +            ENV_ENTRY_XPATH,
  +            EJB_REF_XPATH,
  +            EJB_LOCAL_REF_XPATH,
  +            SECURITY_ROLE_REF_XPATH,
  +            RESOURCE_REF_XPATH,
  +            RESOURCE_ENV_REF_XPATH,
  +        }; // ejb-name is not included, since we don't have a DConfigBean for it
  +    }
  +
  +    public void removeDConfigBean(DConfigBean bean) throws BeanNotFoundException {
  +        if(bean instanceof SecurityRoleRefBean) {
  +            if(!securityRoleRefs.remove(bean)) {
  +                throw new BeanNotFoundException("Could not find Security Role Reference "+((SecurityRoleRefBean)bean).getRoleName()+" to remove");
  +            }
  +        } else {
  +            super.removeDConfigBean(bean);
  +        }
  +    }
  +
  +    public String getJndiName() {
  +        return jndiName;
  +    }
  +
  +    public void setJndiName(String jndiName) {
  +        String old = this.jndiName;
  +        this.jndiName = jndiName;
  +        pcs.firePropertyChange("jndiName", old, jndiName);
  +    }
  +
  +    protected DConfigBean getDConfigBean(DDBean bean, boolean create) {
  +        if(bean.getXpath().equals(SECURITY_ROLE_REF_XPATH)) {
  +            for(Iterator it = securityRoleRefs.iterator(); it.hasNext();) {
  +                DConfigBean dcb = (DConfigBean)it.next();
  +                if(dcb.getDDBean().equals(bean)) {
  +                    return dcb;
  +                }
  +            }
  +            if(create) {
  +                DConfigBean ref = new SecurityRoleRefBean(bean);
  +                securityRoleRefs.add(ref);
  +                return ref;
  +            }
  +        }
  +        return super.getDConfigBean(bean, create);
  +    }
  +
  +    /**
  +     * Used by other classes in this package to store and restore.  A JSR-88
  +     * tool implementation should get the child DConfigBeans by calling
  +     * getDConfigBean for each of the DDBeans.
  +     */
  +    List getSecurityRoleRef() {
  +        return securityRoleRefs;
       }
   }
  
  
  
  1.3       +22 -1     incubator-geronimo/modules/core/src/java/org/apache/geronimo/enterprise/deploy/provider/jar/EntityBeanBeanInfo.java
  
  Index: EntityBeanBeanInfo.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/enterprise/deploy/provider/jar/EntityBeanBeanInfo.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- EntityBeanBeanInfo.java	27 Aug 2003 10:33:34 -0000	1.2
  +++ EntityBeanBeanInfo.java	4 Sep 2003 05:24:21 -0000	1.3
  @@ -58,6 +58,10 @@
   
   import java.beans.BeanDescriptor;
   import java.beans.SimpleBeanInfo;
  +import java.beans.PropertyDescriptor;
  +import java.beans.IntrospectionException;
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogFactory;
   
   /**
    * BeanInfo descriptor for the EntityBean class
  @@ -65,10 +69,27 @@
    * @version $Revision$ $Date$
    */
   public class EntityBeanBeanInfo extends SimpleBeanInfo {
  +    private static final Log log = LogFactory.getLog(SessionBeanBeanInfo.class);
  +
       public BeanDescriptor getBeanDescriptor() {
           BeanDescriptor bd = new BeanDescriptor(EntityBean.class);
           bd.setDisplayName("Entity Bean");
           bd.setShortDescription("An Entity EJB");
           return bd;
  +    }
  +
  +    public PropertyDescriptor[] getPropertyDescriptors() {
  +        try {
  +            PropertyDescriptor jndi = new PropertyDescriptor("jndiName", EntityBean.class);
  +            jndi.setBound(true);
  +            jndi.setDisplayName("JNDI Name");
  +            jndi.setShortDescription("The JNDI location where this EJB should be bound");
  +            return new PropertyDescriptor[] {
  +                jndi,
  +            };
  +        } catch(IntrospectionException e) {
  +            log.error("Error in BeanInfo", e);
  +            return null;
  +        }
       }
   }
  
  
  
  1.3       +5 -1      incubator-geronimo/modules/core/src/java/org/apache/geronimo/enterprise/deploy/provider/jar/EnvEntryBean.java
  
  Index: EnvEntryBean.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/enterprise/deploy/provider/jar/EnvEntryBean.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- EnvEntryBean.java	27 Aug 2003 10:33:34 -0000	1.2
  +++ EnvEntryBean.java	4 Sep 2003 05:24:21 -0000	1.3
  @@ -142,4 +142,8 @@
           this.envEntryValue = envEntryValue;
           pcs.firePropertyChange("envEntryValue", old, this.envEntryValue);
       }
  +
  +    public String toString() {
  +        return envEntryName;
  +    }
   }
  
  
  
  1.3       +5 -1      incubator-geronimo/modules/core/src/java/org/apache/geronimo/enterprise/deploy/provider/jar/ResourceEnvRefBean.java
  
  Index: ResourceEnvRefBean.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/enterprise/deploy/provider/jar/ResourceEnvRefBean.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ResourceEnvRefBean.java	27 Aug 2003 10:33:34 -0000	1.2
  +++ ResourceEnvRefBean.java	4 Sep 2003 05:24:21 -0000	1.3
  @@ -130,4 +130,8 @@
           this.jndiName = jndiName;
           pcs.firePropertyChange("jndiName", old, jndiName);
       }
  +
  +    public String toString() {
  +        return resourceEnvRefName;
  +    }
   }
  
  
  
  1.3       +5 -1      incubator-geronimo/modules/core/src/java/org/apache/geronimo/enterprise/deploy/provider/jar/ResourceRefBean.java
  
  Index: ResourceRefBean.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/enterprise/deploy/provider/jar/ResourceRefBean.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ResourceRefBean.java	27 Aug 2003 10:33:34 -0000	1.2
  +++ ResourceRefBean.java	4 Sep 2003 05:24:21 -0000	1.3
  @@ -155,4 +155,8 @@
           params[index] = param;
           pcs.firePropertyChange("contextParam", old, params);
       }
  +
  +    public String toString() {
  +        return resRefName;
  +    }
   }
  
  
  
  1.3       +5 -1      incubator-geronimo/modules/core/src/java/org/apache/geronimo/enterprise/deploy/provider/jar/SecurityRoleRefBean.java
  
  Index: SecurityRoleRefBean.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/enterprise/deploy/provider/jar/SecurityRoleRefBean.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SecurityRoleRefBean.java	27 Aug 2003 10:33:34 -0000	1.2
  +++ SecurityRoleRefBean.java	4 Sep 2003 05:24:21 -0000	1.3
  @@ -142,4 +142,8 @@
           this.roleLink = roleLink;
           pcs.firePropertyChange("roleLink", old, this.roleLink);
       }
  +
  +    public String toString() {
  +        return roleName;
  +    }
   }
  
  
  
  1.3       +72 -1     incubator-geronimo/modules/core/src/java/org/apache/geronimo/enterprise/deploy/provider/jar/SessionBean.java
  
  Index: SessionBean.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/enterprise/deploy/provider/jar/SessionBean.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SessionBean.java	27 Aug 2003 10:33:34 -0000	1.2
  +++ SessionBean.java	4 Sep 2003 05:24:21 -0000	1.3
  @@ -55,7 +55,14 @@
    */
   package org.apache.geronimo.enterprise.deploy.provider.jar;
   
  +import java.util.List;
  +import java.util.ArrayList;
  +import java.util.Iterator;
   import javax.enterprise.deploy.model.DDBean;
  +import javax.enterprise.deploy.spi.DConfigBean;
  +import javax.enterprise.deploy.spi.exceptions.BeanNotFoundException;
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogFactory;
   
   /**
    * The DConfigBean for /ejb-jar/enterprise-beans/session
  @@ -63,6 +70,11 @@
    * @version $Revision$ $Date$
    */
   public class SessionBean extends BaseEjbBean {
  +    private static final Log log = LogFactory.getLog(SessionBean.class);
  +    final static String SECURITY_ROLE_REF_XPATH = "security-role-ref";
  +    private String jndiName;
  +    private List securityRoleRefs = new ArrayList();
  +
       /**
        * This is present for JavaBeans compliance, but if it is used, the
        * DConfigBean won't be properly associated with a DDBean, so it
  @@ -70,9 +82,68 @@
        */
       public SessionBean() {
           super();
  +        jndiName = "";
       }
   
       public SessionBean(DDBean ddBean) {
           super(ddBean);
  +        jndiName = getEjbName();
  +    }
  +
  +    public String[] getXpaths() {
  +        return new String[] {
  +            ENV_ENTRY_XPATH,
  +            EJB_REF_XPATH,
  +            EJB_LOCAL_REF_XPATH,
  +            SECURITY_ROLE_REF_XPATH,
  +            RESOURCE_REF_XPATH,
  +            RESOURCE_ENV_REF_XPATH,
  +        }; // ejb-name is not included, since we don't have a DConfigBean for it
  +    }
  +
  +    public void removeDConfigBean(DConfigBean bean) throws BeanNotFoundException {
  +        if(bean instanceof SecurityRoleRefBean) {
  +            if(!securityRoleRefs.remove(bean)) {
  +                throw new BeanNotFoundException("Could not find Security Role Reference "+((SecurityRoleRefBean)bean).getRoleName()+" to remove");
  +            }
  +        } else {
  +            super.removeDConfigBean(bean);
  +        }
  +    }
  +
  +    public String getJndiName() {
  +        return jndiName;
  +    }
  +
  +    public void setJndiName(String jndiName) {
  +        String old = this.jndiName;
  +        this.jndiName = jndiName;
  +        pcs.firePropertyChange("jndiName", old, jndiName);
  +    }
  +
  +    protected DConfigBean getDConfigBean(DDBean bean, boolean create) {
  +        if(bean.getXpath().equals(SECURITY_ROLE_REF_XPATH)) {
  +            for(Iterator it = securityRoleRefs.iterator(); it.hasNext();) {
  +                DConfigBean dcb = (DConfigBean)it.next();
  +                if(dcb.getDDBean().equals(bean)) {
  +                    return dcb;
  +                }
  +            }
  +            if(create) {
  +                DConfigBean ref = new SecurityRoleRefBean(bean);
  +                securityRoleRefs.add(ref);
  +                return ref;
  +            }
  +        }
  +        return super.getDConfigBean(bean, create);
  +    }
  +
  +    /**
  +     * Used by other classes in this package to store and restore.  A JSR-88
  +     * tool implementation should get the child DConfigBeans by calling
  +     * getDConfigBean for each of the DDBeans.
  +     */
  +    List getSecurityRoleRef() {
  +        return securityRoleRefs;
       }
   }
  
  
  
  1.3       +22 -1     incubator-geronimo/modules/core/src/java/org/apache/geronimo/enterprise/deploy/provider/jar/SessionBeanBeanInfo.java
  
  Index: SessionBeanBeanInfo.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/enterprise/deploy/provider/jar/SessionBeanBeanInfo.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SessionBeanBeanInfo.java	27 Aug 2003 10:33:34 -0000	1.2
  +++ SessionBeanBeanInfo.java	4 Sep 2003 05:24:21 -0000	1.3
  @@ -58,6 +58,10 @@
   
   import java.beans.BeanDescriptor;
   import java.beans.SimpleBeanInfo;
  +import java.beans.PropertyDescriptor;
  +import java.beans.IntrospectionException;
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogFactory;
   
   /**
    * BeanInfo descriptor for the SessionBean class
  @@ -65,10 +69,27 @@
    * @version $Revision$ $Date$
    */
   public class SessionBeanBeanInfo extends SimpleBeanInfo {
  +    private static final Log log = LogFactory.getLog(SessionBeanBeanInfo.class);
  +
       public BeanDescriptor getBeanDescriptor() {
           BeanDescriptor bd = new BeanDescriptor(SessionBean.class);
           bd.setDisplayName("Session Bean");
           bd.setShortDescription("A Session EJB");
           return bd;
  +    }
  +
  +    public PropertyDescriptor[] getPropertyDescriptors() {
  +        try {
  +            PropertyDescriptor jndi = new PropertyDescriptor("jndiName", SessionBean.class);
  +            jndi.setBound(true);
  +            jndi.setDisplayName("JNDI Name");
  +            jndi.setShortDescription("The JNDI location where this EJB should be bound");
  +            return new PropertyDescriptor[] {
  +                jndi,
  +            };
  +        } catch(IntrospectionException e) {
  +            log.error("Error in BeanInfo", e);
  +            return null;
  +        }
       }
   }
  
  
  
  1.2       +45 -18    incubator-geronimo/modules/core/src/java/org/apache/geronimo/enterprise/deploy/tool/DDBeanImpl.java
  
  Index: DDBeanImpl.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/enterprise/deploy/tool/DDBeanImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DDBeanImpl.java	22 Aug 2003 19:03:38 -0000	1.1
  +++ DDBeanImpl.java	4 Sep 2003 05:24:21 -0000	1.2
  @@ -63,6 +63,8 @@
   import javax.enterprise.deploy.model.XpathListener;
   
   import org.dom4j.Node;
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogFactory;
   
   /**
    * The DDBeanImpl provides an implementation for javax.enterprise.deploy.model.DDBean.
  @@ -70,7 +72,8 @@
    * @version $Revision$ $Date$
    */
   public class DDBeanImpl implements DDBean {
  -    
  +    private final static Log log = LogFactory.getLog(DDBeanImpl.class);
  +
       protected Node node;
       protected String id;
       protected DDBeanRoot root;
  @@ -86,11 +89,11 @@
        * Creates a new instance of DDBeanImpl
        * @todo Grab DDBeanRoot
        */
  -    DDBeanImpl(Node node) {
  +    DDBeanImpl(Node node, String xpath) {
           this.node = node;
           this.id = node.getName();
           this.text = node.getText();
  -        this.xPath = node.getPath();
  +        this.xPath = xpath;
       }
       
       public void addXpathListener(String str, XpathListener xpathListener) {
  @@ -100,26 +103,39 @@
       
       public DDBean[] getChildBean(String str) {
           String tempXPath = createXPath(str);
  -                
  -        List nodes = node.getDocument().selectNodes(tempXPath);
  +
  +        List nodes = node.selectNodes(tempXPath);
           int count = nodes.size();
           DDBeanImpl[] ddBeans = new DDBeanImpl[count];
           for ( int i = 0; i < count; i++ ) {
               Node node = (Node)nodes.get(i);
  -            ddBeans[i] = new DDBeanImpl(node); // @todo doesn't this need a factory?
  +            ddBeans[i] = new DDBeanImpl(node, str); // @todo doesn't this need a factory?
           }
           return ddBeans;
       }
       
  +    public String[] getText(String str) {
  +        String tempXPath = createXPath(str);
  +
  +        List nodes = node.selectNodes(tempXPath);
  +        int count = nodes.size();
  +        String[] text = new String[count];
  +        for ( int i = 0; i < count; i++ ) {
  +            Node node = (Node)nodes.get(i);
  +            text[i] = node.getText();
  +        }
  +        return text;
  +    }
  +
       private String createXPath(String path) {
  -        //*[name()='ejb-jar']/*[name()='enterprise-beans']/*[name()='session']
           StringTokenizer tokens = new StringTokenizer(path, "/");
           StringBuffer buffer = new StringBuffer(100);
  -        buffer.append("/");
           while ( tokens.hasMoreTokens() ) {
  -            buffer.append("/*[name()='").append(tokens.nextToken()).append("']");
  +            if(buffer.length() > 0) {
  +                buffer.append("/");
  +            }
  +            buffer.append("*[name()='").append(tokens.nextToken()).append("']");
           }
  -        buffer.append("/*");
           return buffer.toString();
       }
       
  @@ -135,13 +151,6 @@
           return text;
       }
       
  -    /**
  -     *  This method is not described in the specs.
  -     */
  -    public String[] getText(String str) {
  -        return null;
  -    }
  -    
       public String getXpath() {
           return xPath;
       }
  @@ -158,5 +167,23 @@
       public String getAttributeValue(String attrName) {
           // @todo implement
           return null;
  +    }
  +
  +    /**
  +     * DDBeans are the same if nodes are the same
  +     */
  +    public int hashCode() {
  +        return node.hashCode();
  +    }
  +
  +    /**
  +     * DDBeans are the same if nodes are the same
  +     */
  +    public boolean equals(Object obj) {
  +        try {
  +            return node.equals(((DDBeanImpl)obj).node);
  +        } catch(ClassCastException e) {
  +            return false;
  +        }
       }
   }
  
  
  
  1.2       +9 -3      incubator-geronimo/modules/core/src/java/org/apache/geronimo/enterprise/deploy/tool/DDBeanRootImpl.java
  
  Index: DDBeanRootImpl.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/enterprise/deploy/tool/DDBeanRootImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DDBeanRootImpl.java	22 Aug 2003 19:03:38 -0000	1.1
  +++ DDBeanRootImpl.java	4 Sep 2003 05:24:21 -0000	1.2
  @@ -70,10 +70,12 @@
       
       private String moduleDTDVersion;
       private ModuleType type;
  -    
  +    private Document document;
  +
       /** Creates a new instance of DDBeanRootImpl */
       DDBeanRootImpl(Document document) {
  -        super(document.getRootElement());
  +        super(document, "/");
  +        this.document = document;
           moduleDTDVersion = document.getRootElement().valueOf("@version");
           if ("ejb-jar".equalsIgnoreCase(id)) {
               type = ModuleType.EJB;
  @@ -107,5 +109,9 @@
       public String getFilename() {
           // @todo implement
           return null;
  +    }
  +
  +    public Document getDocument() {
  +        return document;
       }
   }
  
  
  
  1.1                  incubator-geronimo/modules/core/src/java/org/apache/geronimo/enterprise/deploy/tool/AbstractDeployableObject.java
  
  Index: AbstractDeployableObject.java
  ===================================================================
  /* ====================================================================
   * 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.enterprise.deploy.tool;
  
  import java.io.InputStream;
  import java.io.IOException;
  import java.util.Enumeration;
  import java.util.jar.JarFile;
  import java.util.jar.JarEntry;
  import javax.enterprise.deploy.model.DeployableObject;
  import javax.enterprise.deploy.model.DDBeanRoot;
  import javax.enterprise.deploy.model.DDBean;
  import javax.enterprise.deploy.shared.ModuleType;
  
  /**
   * The base class for all DeployableObject implementations.  Each subclass
   * defines how to get specific deployment descriptors.
   *
   * @version $Revision: 1.1 $ $Date: 2003/09/04 05:24:21 $
   */
  public abstract class AbstractDeployableObject implements DeployableObject {
      private JarFile jar;
      private ModuleType type;
      private DDBeanRoot defaultRoot;
      private ClassLoader loader;
  
      public AbstractDeployableObject(JarFile jar, ModuleType type, DDBeanRoot defaultRoot, ClassLoader loader) {
          this.jar = jar;
          this.type = type;
          this.defaultRoot = defaultRoot;
          this.loader = loader;
      }
  
      public ModuleType getType() {
          return type;
      }
  
      public DDBeanRoot getDDBeanRoot() {
          return defaultRoot;
      }
  
      public DDBean[] getChildBean(String xpath) {
          return defaultRoot.getChildBean(xpath);
      }
  
      public String[] getText(String xpath) {
          return defaultRoot.getText(xpath);
      }
  
      public Class getClassFromScope(String className) {
          try {
              return loader.loadClass(className);
          } catch(ClassNotFoundException e) {
              return null;
          }
      }
  
      public String getModuleDTDVersion() {
          return defaultRoot.getModuleDTDVersion();
      }
  
      public Enumeration entries() {
          return new JarEnumerator(jar.entries());
      }
  
      public InputStream getEntry(String name) {
          try {
              return jar.getInputStream(jar.getEntry(name));
          } catch(IOException e) {
              return null;
          }
      }
  
      private static class JarEnumerator implements Enumeration {
          private Enumeration entries;
  
          public JarEnumerator(Enumeration entries) {
              this.entries = entries;
          }
  
          public boolean hasMoreElements() {
              return entries.hasMoreElements();
          }
  
          public Object nextElement() {
              return ((JarEntry)entries.nextElement()).getName();
          }
      }
  }
  
  
  
  1.1                  incubator-geronimo/modules/core/src/java/org/apache/geronimo/enterprise/deploy/tool/EjbDeployableObject.java
  
  Index: EjbDeployableObject.java
  ===================================================================
  /* ====================================================================
   * 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.enterprise.deploy.tool;
  
  import java.io.FileNotFoundException;
  import java.io.InputStream;
  import java.io.IOException;
  import java.util.jar.JarFile;
  import javax.enterprise.deploy.model.DDBeanRoot;
  import javax.enterprise.deploy.model.exceptions.DDBeanCreateException;
  import javax.enterprise.deploy.shared.ModuleType;
  import org.dom4j.io.SAXReader;
  import org.dom4j.DocumentException;
  import org.dom4j.Document;
  import org.dom4j.Element;
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  
  /**
   * A DeployableObject implementation for EJB JARs.  This knows how to load and
   * validate the deployment descriptors for EJB (currently v2.1 only).
   *
   * @version $Revision: 1.1 $ $Date: 2003/09/04 05:24:21 $
   */
  public class EjbDeployableObject extends AbstractDeployableObject {
      private final static Log log = LogFactory.getLog(EjbDeployableObject.class);
      private final static String EJB_JAR_DD = "META-INF/ejb-jar.xml";
  
      public EjbDeployableObject(JarFile jar, ClassLoader loader) {
          super(jar, ModuleType.EJB, createEjbJarRoot(jar), loader);
      }
  
      public DDBeanRoot getDDBeanRoot(String filename) throws FileNotFoundException, DDBeanCreateException {
          if(filename.equals(EJB_JAR_DD)) {
              return super.getDDBeanRoot();
          } else {
              return null; //todo: Web Services DDs
          }
      }
  
      private static DDBeanRootImpl createEjbJarRoot(JarFile jar) {
          DDBeanRootImpl beanRoot = createDDBeanRoot(jar, EJB_JAR_DD);
          Element root = beanRoot.getDocument().getRootElement();
          if(!root.getName().equals("ejb-jar") || !root.attribute("version").getValue().equals("2.1")) {
              log.error("Not an EJB 2.1 deployment descriptor");
              return null;
          }
          return beanRoot;
      }
  
      private static DDBeanRootImpl createDDBeanRoot(JarFile jar, String fileName) {
          try {
              InputStream in = jar.getInputStream(jar.getEntry(fileName));
              SAXReader reader = new SAXReader();
              Document document = reader.read(in);
              return new DDBeanRootImpl(document);
          } catch(IOException e) {
              log.error("Unable to locate DD "+fileName+" in EJB JAR", e);
              return null;
          } catch(DocumentException e) {
              log.error("Unable to parse DD "+fileName+" in EJB JAR", e);
              return null;
          }
      }
  
  }