dblevins    2005/08/15 21:05:03

  Modified:    modules/core/src/java/org/openejb/alt/assembler/classic
                        AssemblerTool.java ContainerSystemInfo.java
                        EnterpriseBeanBuilder.java JndiEncBuilder.java
  Added:       modules/core/src/java/org/openejb/alt/assembler/classic
                        ContainerBuilder.java EjbJarInfo.java
  Log:

  Don't use SafeToolkit for loading EJB classes.  Construct a new classloader, 
use that and throw it away.
  Reworked container building to do this.
  
  Revision  Changes    Path
  1.9       +11 -128   
openejb1/modules/core/src/java/org/openejb/alt/assembler/classic/AssemblerTool.java
  
  Index: AssemblerTool.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb1/modules/core/src/java/org/openejb/alt/assembler/classic/AssemblerTool.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- AssemblerTool.java        12 Aug 2005 05:56:37 -0000      1.8
  +++ AssemblerTool.java        16 Aug 2005 01:05:03 -0000      1.9
  @@ -44,18 +44,10 @@
    */
   package org.openejb.alt.assembler.classic;
   
  +import org.openejb.Container;
   import org.openejb.OpenEJBException;
   import org.openejb.core.ContainerSystem;
   import org.openejb.core.DeploymentInfo;
  -import org.openejb.core.entity.EntityContainer;
  -import org.openejb.core.ivm.naming.IntraVmJndiReference;
  -import org.openejb.core.ivm.naming.IvmContext;
  -import org.openejb.core.ivm.naming.JndiReference;
  -import org.openejb.core.ivm.naming.NameNode;
  -import org.openejb.core.ivm.naming.ParsedName;
  -import org.openejb.core.ivm.naming.Reference;
  -import org.openejb.core.stateful.StatefulContainer;
  -import org.openejb.core.stateless.StatelessContainer;
   import org.openejb.spi.SecurityService;
   import org.openejb.spi.TransactionService;
   import org.openejb.util.Messages;
  @@ -67,17 +59,11 @@
   import javax.resource.spi.ConnectionManager;
   import javax.resource.spi.ManagedConnectionFactory;
   import java.lang.reflect.Method;
  -import java.util.ArrayList;
  -import java.util.Arrays;
   import java.util.HashMap;
   import java.util.HashSet;
  -import java.util.Iterator;
  +import java.util.List;
   import java.util.Properties;
   import java.util.Vector;
  -import java.net.URLClassLoader;
  -import java.net.URL;
  -import java.net.MalformedURLException;
  -import java.io.File;
   
   /**
    * This class provides a set of utility methods for constructing various 
artifacts
  @@ -102,7 +88,6 @@
       public static final Class PROXY_FACTORY = 
org.openejb.util.proxy.ProxyFactory.class;
       public static final Class SECURITY_SERVICE = 
org.openejb.spi.SecurityService.class;
       public static final Class TRANSACTION_SERVICE = 
org.openejb.spi.TransactionService.class;
  -    public static final Class CONTAINER = org.openejb.Container.class;
       public static final Class CONNECTION_MANAGER = 
javax.resource.spi.ConnectionManager.class;
       public static final Class CONNECTOR = 
javax.resource.spi.ManagedConnectionFactory.class;
   
  @@ -137,102 +122,17 @@
        * @see ContainerManagerInfo
        */
       public void assembleContainers(ContainerSystem containerSystem, 
ContainerSystemInfo containerSystemInfo) throws Exception {
  -        /*TODO: Add better exception handling, this method throws 
java.lang.Exception,
  -         which is not very specific. Only a very specific OpenEJBException 
should be
  -         thrown.
  -         */
  -
  -        ArrayList list = new ArrayList();
  -        if (containerSystemInfo.entityContainers != null) 
list.addAll(Arrays.asList(containerSystemInfo.entityContainers));
  -        if (containerSystemInfo.statefulContainers != null) 
list.addAll(Arrays.asList(containerSystemInfo.statefulContainers));
  -        if (containerSystemInfo.statelessContainers != null) 
list.addAll(Arrays.asList(containerSystemInfo.statelessContainers));
  -        Iterator iterator = list.iterator();
  -        while (iterator.hasNext()) {
  -            ContainerInfo containerInfo = (ContainerInfo) iterator.next();
  -            org.openejb.Container container = 
assembleContainer(containerInfo);
  -            containerSystem.addContainer(container.getContainerID(), 
container);
  -        }
  -
  -        // ADD deployments to container system and to Global JNDI name space
  -        org.openejb.Container[] containers = containerSystem.containers();
  -        for (int i = 0; i < containers.length; i++) {
  -            org.openejb.DeploymentInfo deployments [] = 
containers[i].deployments();
  -            for (int x = 0; x < deployments.length; x++) {
  -                
containerSystem.addDeployment((org.openejb.core.DeploymentInfo) deployments[x]);
  -            }
  -        }
  -
  -
  -    }
  -
  -    /**
  -     * This method can construct a Container of any kind based on 
information in the
  -     * ContainerInfo object: StatefulContainer, StatelessContainer, or 
EntityContainer
  -     * In addition to constructing the containers, this method also 
constructs all the
  -     * deployments declared in the containerInfo object and adds them to the 
containers
  -     * It constructs the deployment Info object using the 
assembleDeploymentInfo
  -     * method.
  -     *
  -     * @param containerInfo describes a Container and its deployments.
  -     * @return the Container that was constructed (StatefulContainer, 
StatelessContainer, EntityContainer)
  -     * @see org.openejb.alt.assembler.classic.ContainerInfo
  -     * @see 
org.openejb.alt.assembler.classic.Assembler#assembleDeploymentInfo(EnterpriseBeanInfo)
  -     */
  -    public org.openejb.Container assembleContainer(ContainerInfo 
containerInfo)
  -            throws org.openejb.OpenEJBException {
  -        HashMap deployments = new HashMap();
  -        for (int z = 0; z < containerInfo.ejbeans.length; z++) {
  -            DeploymentInfo deployment = 
assembleDeploymentInfo(containerInfo.ejbeans[z]);
  -            deployments.put(containerInfo.ejbeans[z].ejbDeploymentId, 
deployment);
  -        }
  -        org.openejb.Container container = null;
  -
  -        // This trick retains backward compatibility with version 0.7.3. 
Otherwise CMP
  -        // beans will be deployed in the default BMP container, and 
everything goes wrong
  -        if (containerInfo.className != null ||
  -                
"org.openejb.alt.containers.castor_cmp11.CastorCMP11_EntityContainer".equals(containerInfo.codebase))
 {
  -            if (containerInfo.className == null) {
  -                containerInfo.className = containerInfo.codebase;
  -            }
  -            // create the custom container
  -            try {
  -                //container = 
(org.openejb.Container)Class.forName(containerInfo.codebase).newInstance();
  -                // Support for an actual codebase.
  -                Class factory = 
SafeToolkit.loadClass(containerInfo.className, containerInfo.codebase);
  -
  -                checkImplementation(CONTAINER, factory, "Container", 
containerInfo.containerName);
  -
  -                container = (org.openejb.Container) factory.newInstance();
  -            } catch (OpenEJBException oee) {
  -                throw new OpenEJBException(messages.format("as0002", 
containerInfo, oee.getMessage()));
  -            } catch (InstantiationException ie) {
  -                throw new OpenEJBException(messages.format("as0003", 
containerInfo, ie.getMessage()));
  -            } catch (IllegalAccessException iae) {
  -                throw new OpenEJBException(messages.format("as0003", 
containerInfo, iae.getMessage()));
  -            }
  -        } else {
  -            // create a standard container
  -            switch (containerInfo.containerType) {
  -                case ContainerInfo.STATEFUL_SESSION_CONTAINER:
  -                    container = new StatefulContainer();
  -                    break;
  -                case ContainerInfo.ENTITY_CONTAINER:
  -                    container = new EntityContainer();
  -                    break;
  -                case ContainerInfo.STATELESS_SESSION_CONTAINER:
  -                    container = new StatelessContainer();
   
  +        ContainerBuilder containerBuilder = new 
ContainerBuilder(containerSystemInfo, this.props);
  +        List containers = (List) containerBuilder.build();
  +        for (int i = 0; i < containers.size(); i++) {
  +            Container container = (Container) containers.get(i);
  +            containerSystem.addContainer(container.getContainerID(), 
container);
  +            org.openejb.DeploymentInfo[] deployments = 
container.deployments();
  +            for (int j = 0; j < deployments.length; j++) {
  +                
containerSystem.addDeployment((org.openejb.core.DeploymentInfo) deployments[j]);
               }
           }
  -        try {
  -            Properties clonedProps = (Properties) (this.props.clone());
  -            clonedProps.putAll(containerInfo.properties);
  -            container.init(containerInfo.containerName, deployments, 
clonedProps);
  -        } catch (OpenEJBException e) {
  -            throw new OpenEJBException(messages.format("as0003", 
containerInfo.containerName, e.getMessage()));
  -        }
  -
  -        return container;
       }
   
       /*
  @@ -250,23 +150,6 @@
               // not a super serious error but assemble should be stoped.
               throw new org.openejb.OpenEJBException("The remote JNDI EJB 
references for remote-jndi-contexts = " + context.jndiContextId + "+ could not 
be resolved.", ne);
           }
  -    }
  -
  -    /**
  -     * This method assembles a org.openejb.core.DeploymentInfo object from a 
EnterpriseBeanInfo configuration
  -     * object of anyone of three types: EntityBeanInfo, StatelessBeanInfo, 
or StatefulBeanInfo.
  -     * The DeploymentInfo object is not complete, its component type and 
transaction type (bean or container)
  -     * is set and its JNDI ENC context is established with all its bean 
references, resource references,
  -     * and environment entries, BUT its method permissions, security role 
references and transaction attribute
  -     * method mapping are not established. These must be done in post 
processing using the methods
  -     * applyMethodPermissions(), applySecurityRoleReferences() and 
applyTransactionAttributes()
  -     *
  -     * @param beanInfo describes the enterprise bean deployment to be 
assembled.
  -     */
  -    public DeploymentInfo assembleDeploymentInfo(EnterpriseBeanInfo beanInfo)
  -            throws org.openejb.SystemException, org.openejb.OpenEJBException 
{
  -        EnterpriseBeanBuilder deploymentBuilder = new 
EnterpriseBeanBuilder(beanInfo);
  -        return (DeploymentInfo)deploymentBuilder.build();
       }
   
       /**
  
  
  
  1.3       +17 -54    
openejb1/modules/core/src/java/org/openejb/alt/assembler/classic/ContainerSystemInfo.java
  
  Index: ContainerSystemInfo.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb1/modules/core/src/java/org/openejb/alt/assembler/classic/ContainerSystemInfo.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ContainerSystemInfo.java  19 Jun 2005 22:40:27 -0000      1.2
  +++ ContainerSystemInfo.java  16 Aug 2005 01:05:03 -0000      1.3
  @@ -12,24 +12,24 @@
    *    following disclaimer in the documentation and/or other
    *    materials provided with the distribution.
    *
  - * 3. The name "Exolab" must not be used to endorse or promote
  + * 3. The name "OpenEJB" must not be used to endorse or promote
    *    products derived from this Software without prior written
  - *    permission of Exoffice Technologies.  For written permission,
  - *    please contact [EMAIL PROTECTED]
  + *    permission of The OpenEJB Group.  For written permission,
  + *    please contact [EMAIL PROTECTED]
    *
  - * 4. Products derived from this Software may not be called "Exolab"
  - *    nor may "Exolab" appear in their names without prior written
  - *    permission of Exoffice Technologies. Exolab is a registered
  - *    trademark of Exoffice Technologies.
  + * 4. Products derived from this Software may not be called "OpenEJB"
  + *    nor may "OpenEJB" appear in their names without prior written
  + *    permission of The OpenEJB Group. OpenEJB is a registered
  + *    trademark of The OpenEJB Group.
    *
  - * 5. Due credit should be given to the Exolab Project
  - *    (http://www.exolab.org/).
  + * 5. Due credit should be given to the OpenEJB Project
  + *    (http://openejb.org/).
    *
  - * THIS SOFTWARE IS PROVIDED BY EXOFFICE TECHNOLOGIES AND CONTRIBUTORS
  + * THIS SOFTWARE IS PROVIDED BY THE OPENEJB GROUP AND CONTRIBUTORS
    * ``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
  - * EXOFFICE TECHNOLOGIES OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  + * THE OPENEJB GROUP 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)
  @@ -38,56 +38,19 @@
    * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
    * OF THE POSSIBILITY OF SUCH DAMAGE.
    *
  - * Copyright 1999 (C) Exoffice Technologies Inc. All Rights Reserved.
  + * Copyright 2005 (C) The OpenEJB Group. All Rights Reserved.
    *
    * $Id$
    */
   
   package org.openejb.alt.assembler.classic;
   
  +public class ContainerSystemInfo extends InfoObject {
   
  -/**
  - * ContainerSystemInfo is part of the OpenEjbConfiguration object structure 
that provides
  - * the information about the configuration of OpenEJB and the container 
system.
  - * 
  - * <p>
  - * The OpenEjbConfiguration itself is created by a 
OpenEjbConfigurationFactory and
  - * is used by the org.openejb.alt.assembler.classic.Assembler to build a 
running unstance of
  - * OpenEJB.</p>
  - * 
  - * The default OpenEjbConfigurationFactory is 
DomOpenEjbConfigurationFactory, which
  - * creates an OpenEjbConfiguration object based on XML config files located 
on the
  - * local system.</p>
  - * 
  - * <p>
  - * Other OpenEjbConfigurationFactory implementations can be created that 
might populate
  - * this object using a different approach.  Other usefull implementations 
might be:<br>
  - * <UL>
  - * <LI>Populating the OpenEjbConfiguration from values in a RDBMS.
  - * <LI>Populating the OpenEjbConfiguration from values in a Properties file.
  - * <LI>Retrieving the OpenEjbConfiguration from a ODBMS.
  - * <LI>Creating the OpenEjbConfiguration using a JavaBeans enabled editing 
tool or wizard.
  - * </UL>
  - * 
  - * <p>
  - * If you are interested in creating alternate an 
OpenEjbConfigurationFactory to do
  - * any of the above techniques or a new approach, email the
  - * <a href="mailto:[email protected]";>OpenEJB Developer list</a> with a 
description
  - * of the new OpenEjbConfigurationFactory implementation.
  - * </p>
  - * 
  - * @author <a href="mailto:[EMAIL PROTECTED]">David Blevins</a>
  - * @author <a href="mailto:[EMAIL PROTECTED]">Richard Monson-Haefel</a>
  - * @see org.openejb.spi.Assembler
  - * @see org.openejb.alt.assembler.classic.Assembler
  - * @see org.openejb.alt.assembler.classic.OpenEjbConfiguration
  - * @see org.openejb.alt.assembler.classic.OpenEjbConfigurationFactory
  - */
  -public class ContainerSystemInfo extends InfoObject{
  -
  -    
       public ContainerInfo[] containers;
  -    
  +    public EnterpriseBeanInfo[] enterpriseBeans;
  +    public EjbJarInfo[] ejbJars;
  +
       public EntityContainerInfo[] entityContainers;
       public StatelessSessionContainerInfo[] statelessContainers;
       public StatefulSessionContainerInfo[] statefulContainers;
  
  
  
  1.2       +9 -7      
openejb1/modules/core/src/java/org/openejb/alt/assembler/classic/EnterpriseBeanBuilder.java
  
  Index: EnterpriseBeanBuilder.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb1/modules/core/src/java/org/openejb/alt/assembler/classic/EnterpriseBeanBuilder.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- EnterpriseBeanBuilder.java        12 Aug 2005 05:56:37 -0000      1.1
  +++ EnterpriseBeanBuilder.java        16 Aug 2005 01:05:03 -0000      1.2
  @@ -47,6 +47,7 @@
   
   import org.openejb.OpenEJBException;
   import org.openejb.SystemException;
  +import org.openejb.OpenEJB;
   import org.openejb.core.DeploymentContext;
   import org.openejb.core.DeploymentInfo;
   import org.openejb.core.ivm.naming.IvmContext;
  @@ -64,10 +65,12 @@
    * @version $Revision$ $Date$
    */
   class EnterpriseBeanBuilder {
  +    protected static final Messages messages = new 
Messages("org.openejb.util.resources");
       private final EnterpriseBeanInfo bean;
       private final EjbType ejbType;
  +    private final ClassLoader cl;
   
  -    public EnterpriseBeanBuilder(EnterpriseBeanInfo bean) {
  +    public EnterpriseBeanBuilder(ClassLoader cl, EnterpriseBeanInfo bean) {
           this.bean = bean;
   
           if (bean.type == EnterpriseBeanInfo.STATEFUL) {
  @@ -80,6 +83,7 @@
           } else {
               throw new UnsupportedOperationException("No building support for 
bean type: " + bean);
           }
  +        this.cl = cl;
       }
   
       static class Loader {
  @@ -125,12 +129,11 @@
   
           Class primaryKey = null;
           if (ejbType.isEntity() && ((EntityBeanInfo) bean).primKeyClass != 
null) {
  -            primaryKey = loadClass(((EntityBeanInfo) bean).primKeyClass, 
"classNotFound.primaryKey");
  +            String className = ((EntityBeanInfo) bean).primKeyClass;
  +            primaryKey = loadClass(className, "classNotFound.primaryKey");
           }
  -
           final String transactionType = bean.transactionType;
   
  -        /*[3] Populate a new DeploymentInfo object  */
           JndiEncBuilder jndiEncBuilder = new JndiEncBuilder(bean.jndiEnc, 
transactionType, ejbType);
           IvmContext root = (IvmContext) jndiEncBuilder.build();
   
  @@ -173,7 +176,6 @@
       }
   
       private Class loadClass(String className, String messageCode) throws 
OpenEJBException {
  -        ClassLoader cl = SafeToolkit.getCodebaseClassLoader(bean.codebase);
           try {
               return cl.loadClass(className);
           } catch (ClassNotFoundException cnfe) {
  
  
  
  1.2       +7 -6      
openejb1/modules/core/src/java/org/openejb/alt/assembler/classic/JndiEncBuilder.java
  
  Index: JndiEncBuilder.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb1/modules/core/src/java/org/openejb/alt/assembler/classic/JndiEncBuilder.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JndiEncBuilder.java       12 Aug 2005 05:56:37 -0000      1.1
  +++ JndiEncBuilder.java       16 Aug 2005 01:05:03 -0000      1.2
  @@ -81,14 +81,15 @@
        * @throws OpenEJBException
        */
       public JndiEncBuilder(JndiEncInfo jndiEnc, String transactionType, 
EjbType ejbType) throws OpenEJBException {
  -        if (ejbType.isEntity())
  +        if (ejbType.isEntity()) {
               referenceWrapper = new EntityRefereceWrapper();
  -        else if (ejbType == EjbType.STATEFUL)
  +        } else if (ejbType == EjbType.STATEFUL) {
               referenceWrapper = new StatefulRefereceWrapper();
  -        else if (ejbType == EjbType.STATELESS)
  +        } else if (ejbType == EjbType.STATELESS) {
               referenceWrapper = new StatelessRefereceWrapper();
  -        else
  +        } else {
               throw new org.openejb.OpenEJBException("Unknown component type");
  +        }
   
           beanManagedTransactions = transactionType != null && 
transactionType.equalsIgnoreCase("Bean");
   
  
  
  
  1.1                  
openejb1/modules/core/src/java/org/openejb/alt/assembler/classic/ContainerBuilder.java
  
  Index: ContainerBuilder.java
  ===================================================================
  /**
   * Redistribution and use of this software and associated documentation
   * ("Software"), with or without modification, are permitted provided
   * that the following conditions are met:
   *
   * 1. Redistributions of source code must retain copyright
   *    statements and notices.  Redistributions must also contain a
   *    copy of this document.
   *
   * 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 name "OpenEJB" must not be used to endorse or promote
   *    products derived from this Software without prior written
   *    permission of The OpenEJB Group.  For written permission,
   *    please contact [EMAIL PROTECTED]
   *
   * 4. Products derived from this Software may not be called "OpenEJB"
   *    nor may "OpenEJB" appear in their names without prior written
   *    permission of The OpenEJB Group. OpenEJB is a registered
   *    trademark of The OpenEJB Group.
   *
   * 5. Due credit should be given to the OpenEJB Project
   *    (http://openejb.org/).
   *
   * THIS SOFTWARE IS PROVIDED BY THE OPENEJB GROUP AND CONTRIBUTORS
   * ``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 OPENEJB GROUP 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.
   *
   * Copyright 2005 (C) The OpenEJB Group. All Rights Reserved.
   *
   * $Id: ContainerBuilder.java,v 1.1 2005/08/16 01:05:03 dblevins Exp $
   */
  
  package org.openejb.alt.assembler.classic;
  
  import org.openejb.Container;
  import org.openejb.OpenEJBException;
  import org.openejb.core.DeploymentInfo;
  import org.openejb.util.SafeToolkit;
  
  import java.io.File;
  import java.net.MalformedURLException;
  import java.net.URL;
  import java.net.URLClassLoader;
  import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.List;
  import java.util.Properties;
  
  /**
   * @version $Revision: 1.1 $ $Date: 2005/08/16 01:05:03 $
   */
  public class ContainerBuilder {
      private final Properties props;
      private final EjbJarInfo[] ejbJars;
      private final ContainerInfo[] containerInfos;
  
      public ContainerBuilder(ContainerSystemInfo containerSystemInfo, 
Properties props) {
          this.props = props;
          this.ejbJars = containerSystemInfo.ejbJars;
          this.containerInfos = containerSystemInfo.containers;
      }
  
      public Object build() throws OpenEJBException {
          HashMap deployments = new HashMap();
          for (int i = 0; i < this.ejbJars.length; i++) {
              EjbJarInfo ejbJar = this.ejbJars[i];
  
              ClassLoader classLoader;
              try {
                  classLoader = new URLClassLoader(new URL[]{new 
File(ejbJar.jarPath).toURL()}, org.openejb.OpenEJB.class.getClassLoader());
              } catch (MalformedURLException e) {
                  throw new 
OpenEJBException(AssemblerTool.messages.format("cl0001", ejbJar.jarPath, 
e.getMessage()));
              }
  
              EnterpriseBeanInfo[] ejbs = ejbJar.enterpriseBeans;
              for (int j = 0; j < ejbs.length; j++) {
                  EnterpriseBeanInfo ejbInfo = ejbs[j];
                  EnterpriseBeanBuilder deploymentBuilder = new 
EnterpriseBeanBuilder(classLoader, ejbInfo);
                  DeploymentInfo deployment = (DeploymentInfo) 
deploymentBuilder.build();
                  deployments.put(ejbInfo.ejbDeploymentId, deployment);
              }
          }
  
          List containers = new ArrayList();
          for (int i = 0; i < containerInfos.length; i++) {
              ContainerInfo containerInfo = containerInfos[i];
  
              HashMap deploymentsList = new HashMap();
              for (int z = 0; z < containerInfo.ejbeans.length; z++) {
                  String ejbDeploymentId = 
containerInfo.ejbeans[z].ejbDeploymentId;
                  DeploymentInfo deployment = (DeploymentInfo) 
deployments.get(ejbDeploymentId);
                  deploymentsList.put(ejbDeploymentId, deployment);
              }
  
              containers.add(buildContainer(containerInfo, deploymentsList));
          }
          return containers;
      }
  
      private Container buildContainer(ContainerInfo containerInfo, HashMap 
deploymentsList) throws OpenEJBException {
          String className = containerInfo.className;
          String codebase = containerInfo.codebase;
          String containerName = containerInfo.containerName;
  
          try {
              Class factory = SafeToolkit.loadClass(className, codebase);
              if (!Container.class.isAssignableFrom(factory)) {
                  throw new 
OpenEJBException(AssemblerTool.messages.format("init.0100", "Container", 
containerName, factory.getName(), Container.class.getName()));
              }
  
              Properties clonedProps = (Properties) (props.clone());
              clonedProps.putAll(containerInfo.properties);
  
              Container container = (Container) factory.newInstance();
              container.init(containerName, deploymentsList, clonedProps);
              return container;
          } catch (OpenEJBException e) {
              throw new 
OpenEJBException(AssemblerTool.messages.format("as0002", containerName, 
e.getMessage()));
          } catch (InstantiationException e) {
              throw new 
OpenEJBException(AssemblerTool.messages.format("as0003", containerName, 
e.getMessage()));
          } catch (IllegalAccessException e) {
              throw new 
OpenEJBException(AssemblerTool.messages.format("as0003", containerName, 
e.getMessage()));
          }
      }
  }
  
  
  
  1.1                  
openejb1/modules/core/src/java/org/openejb/alt/assembler/classic/EjbJarInfo.java
  
  Index: EjbJarInfo.java
  ===================================================================
  /**
   * Redistribution and use of this software and associated documentation
   * ("Software"), with or without modification, are permitted provided
   * that the following conditions are met:
   *
   * 1. Redistributions of source code must retain copyright
   *    statements and notices.  Redistributions must also contain a
   *    copy of this document.
   *
   * 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 name "OpenEJB" must not be used to endorse or promote
   *    products derived from this Software without prior written
   *    permission of The OpenEJB Group.  For written permission,
   *    please contact [EMAIL PROTECTED]
   *
   * 4. Products derived from this Software may not be called "OpenEJB"
   *    nor may "OpenEJB" appear in their names without prior written
   *    permission of The OpenEJB Group. OpenEJB is a registered
   *    trademark of The OpenEJB Group.
   *
   * 5. Due credit should be given to the OpenEJB Project
   *    (http://openejb.org/).
   *
   * THIS SOFTWARE IS PROVIDED BY THE OPENEJB GROUP AND CONTRIBUTORS
   * ``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 OPENEJB GROUP 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.
   *
   * Copyright 2005 (C) The OpenEJB Group. All Rights Reserved.
   *
   * $Id: EjbJarInfo.java,v 1.1 2005/08/16 01:05:03 dblevins Exp $
   */
  
  package org.openejb.alt.assembler.classic;
  
  /**
   * @version $Revision: 1.1 $ $Date: 2005/08/16 01:05:03 $
   */
  public class EjbJarInfo extends InfoObject {
      public String jarPath;
      public EnterpriseBeanInfo[] enterpriseBeans;
  }
  
  
  

Reply via email to