dain        2004/04/01 17:36:52

  Modified:    modules/core/src/java/org/openejb
                        AbstractContainerBuilder.java
                        GenericEJBContainer.java
  Added:       modules/core/src/java/org/openejb EJBModule.java
  Log:

  Stubbed in a deployer and a simple test.
  Deployment doesn't actually work, but we have a start.
  
  Revision  Changes    Path
  1.2       +56 -5     
openejb/modules/core/src/java/org/openejb/AbstractContainerBuilder.java
  
  Index: AbstractContainerBuilder.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/AbstractContainerBuilder.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractContainerBuilder.java     21 Mar 2004 21:26:34 -0000      1.1
  +++ AbstractContainerBuilder.java     1 Apr 2004 22:36:51 -0000       1.2
  @@ -53,10 +53,12 @@
   import javax.transaction.TransactionManager;
   
   import 
org.apache.geronimo.connector.outbound.connectiontracking.TrackedConnectionAssociator;
  +import org.apache.geronimo.gbean.jmx.GBeanMBean;
   import org.apache.geronimo.kernel.ClassLoading;
   import org.apache.geronimo.naming.java.ReadOnlyContext;
   
   import org.openejb.cache.InstanceFactory;
  +import org.openejb.cache.InstancePool;
   import org.openejb.deployment.TransactionPolicySource;
   import org.openejb.dispatch.InterfaceMethodSignature;
   import org.openejb.dispatch.VirtualOperation;
  @@ -68,11 +70,12 @@
   import org.openejb.util.SoftLimitedInstancePool;
   
   /**
  - * 
  - * 
  + *
  + *
    * @version $Revision$ $Date$
    */
   public abstract class AbstractContainerBuilder {
  +    private ClassLoader classLoader;
       private Object containerId;
       private String ejbName;
       private String beanClassName;
  @@ -89,6 +92,18 @@
       private TransactionManager transactionManager;
       private TrackedConnectionAssociator trackedConnectionAssociator;
   
  +    public ClassLoader getClassLoader() {
  +        if(classLoader != null) {
  +            return classLoader;
  +        } else {
  +            return Thread.currentThread().getContextClassLoader();
  +        }
  +    }
  +
  +    public void setClassLoader(ClassLoader classLoader) {
  +        this.classLoader = classLoader;
  +    }
  +
       public Object getContainerId() {
           return containerId;
       }
  @@ -226,7 +241,7 @@
       }
   
       protected EJBProxyFactory createProxyFactory(InterfaceMethodSignature[] 
signatures) throws ClassNotFoundException {
  -        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
  +        ClassLoader classLoader = getClassLoader();
           Class homeInterface = loadOptionalClass(homeInterfaceName, classLoader);
           Class remoteInterface = loadOptionalClass(remoteInterfaceName, classLoader);
           Class localHomeInterface = loadOptionalClass(localHomeInterfaceName, 
classLoader);
  @@ -250,9 +265,45 @@
       protected abstract LinkedHashMap buildVopMap(Class beanClass);
   
       private static Class loadOptionalClass(String className, ClassLoader 
classLoader) throws ClassNotFoundException {
  -        if(className == null) {
  +        if (className == null) {
               return null;
           }
           return ClassLoading.loadClass(className, classLoader);
       }
  +
  +    protected EJBContainer createContainer(
  +            EJBProxyFactory proxyFactory,
  +            InterfaceMethodSignature[] signatures,
  +            InterceptorBuilder interceptorBuilder,
  +            InstancePool pool) throws Exception {
  +
  +        return new GenericEJBContainer(
  +                getContainerId(),
  +                getEJBName(),
  +                proxyFactory,
  +                signatures,
  +                interceptorBuilder,
  +                pool,
  +                getUserTransaction(),
  +                getTransactionManager(),
  +                getTrackedConnectionAssociator());
  +    }
  +
  +    protected GBeanMBean createConfiguration(
  +            EJBProxyFactory proxyFactory,
  +            InterfaceMethodSignature[] signatures,
  +            InterceptorBuilder interceptorBuilder,
  +            InstancePool pool) throws Exception {
  +
  +        GBeanMBean gbean = new GBeanMBean(GenericEJBContainer.GBEAN_INFO);
  +        gbean.setAttribute("containerId", getContainerId());
  +        gbean.setAttribute("ejbName", getEJBName());
  +        gbean.setAttribute("proxyFactory", proxyFactory);
  +        gbean.setAttribute("signatures", signatures);
  +        gbean.setAttribute("interceptorBuilder", interceptorBuilder);
  +        gbean.setAttribute("pool", pool);
  +        gbean.setAttribute("userTransaction", getUserTransaction());
  +
  +        return gbean;
  +    }
   }
  
  
  
  1.2       +7 -7      
openejb/modules/core/src/java/org/openejb/GenericEJBContainer.java
  
  Index: GenericEJBContainer.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/GenericEJBContainer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- GenericEJBContainer.java  21 Mar 2004 21:26:34 -0000      1.1
  +++ GenericEJBContainer.java  1 Apr 2004 22:36:51 -0000       1.2
  @@ -228,21 +228,21 @@
       public static final GBeanInfo GBEAN_INFO;
   
       static {
  -        GBeanInfoFactory infoFactory = new 
GBeanInfoFactory(GenericEJBContainer.class.getName(), AbstractEJBContainer.GBEAN_INFO);
  +        GBeanInfoFactory infoFactory = new 
GBeanInfoFactory(GenericEJBContainer.class);
   
           infoFactory.setConstructor(
  -                new String[]{"containerId", "ejbName", "proxyFactory", 
"signatures", "interceptorBuilder", "pool", "transactionManager", 
"trackedConnectionAssociator"},
  -                new Class[]{Object.class, String.class, EJBProxyFactory.class, 
InterfaceMethodSignature[].class, EntityInterceptorBuilder.class, InstancePool.class, 
TransactionManager.class, TrackedConnectionAssociator.class});
  +                new String[]{"containerId", "ejbName", "proxyFactory", 
"signatures", "interceptorBuilder", "pool", "userTransaction", "transactionManager", 
"trackedConnectionAssociator"},
  +                new Class[]{Object.class, String.class, EJBProxyFactory.class, 
InterfaceMethodSignature[].class, InterceptorBuilder.class, InstancePool.class, 
EJBUserTransaction.class, TransactionManager.class, 
TrackedConnectionAssociator.class});
   
           infoFactory.addAttribute("containerId", true);
  -        infoFactory.addAttribute("containerId", true);
           infoFactory.addAttribute("ejbName", true);
           infoFactory.addAttribute("proxyFactory", true);
           infoFactory.addAttribute("signatures", true);
           infoFactory.addAttribute("interceptorBuilder", true);
           infoFactory.addAttribute("pool", true);
  -        infoFactory.addAttribute("transactionManager", true);
  -        infoFactory.addAttribute("trackedConnectionAssociator", true);
  +        infoFactory.addAttribute("userTransaction", true);
  +        infoFactory.addReference("transactionManager", TransactionManager.class);
  +        infoFactory.addReference("trackedConnectionAssociator", 
TrackedConnectionAssociator.class);
   
           GBEAN_INFO = infoFactory.getBeanInfo();
       }
  
  
  
  1.1                  openejb/modules/core/src/java/org/openejb/EJBModule.java
  
  Index: EJBModule.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 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.
   *
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the OpenEJB Project.  For more information
   * please see <http://openejb.org/>.
   *
   * ====================================================================
   */
  package org.openejb;
  
  import java.util.Collection;
  import java.util.Iterator;
  
  import org.apache.geronimo.gbean.GBeanInfo;
  import org.apache.geronimo.gbean.GBeanInfoFactory;
  import org.apache.geronimo.kernel.management.ManagedObject;
  
  /**
   * 
   * 
   * @version $Revision: 1.1 $ $Date: 2004/04/01 22:36:51 $
   */
  public class EJBModule {
      private final Collection ejbs;
  
      public EJBModule(Collection ejbs) {
          this.ejbs = ejbs;
      }
  
      public String[] getEjbs() {
          String[] ejbsArray = new String[ejbs.size()];
          int i = 0;
          for (Iterator iterator = ejbs.iterator(); iterator.hasNext();) {
              ejbsArray[i++] =((ManagedObject) iterator.next()).getObjectName();
          }
          return ejbsArray;
      }
  
      public static final GBeanInfo GBEAN_INFO;
  
      static {
          GBeanInfoFactory infoFactory = new GBeanInfoFactory(EJBModule.class);
          infoFactory.addReference("ejbs", ManagedObject.class);
          infoFactory.setConstructor(
                  new String[]{"ejbs"},
                  new Class[]{Collection.class}
          );
          GBEAN_INFO = infoFactory.getBeanInfo();
      }
  
      public static GBeanInfo getGBeanInfo() {
          return GBEAN_INFO;
      }
  }
  
  
  

Reply via email to