dain        2005/05/08 15:37:14

  Modified:    modules/openejb-builder/src/test/org/openejb/deployment
                        AbstractDeploymentTest.java DeploymentHelper.java
                        DeploymentTestSuite.java EarDeploymentTest.java
                        EjbJarModuleDeploymentTest.java KernelHelper.java
  Log:

  Added KernelFactory for pluggable kernel
  Kernel is now an interface
  Moved Kernel implementation  to basic kernel
  Converted JMX registry and config manager to plain old gbeans (they do not 
require special access to the kernel)
  Magic attributes such as state and enabled are now accessed via kernel methods
  Use of getAttribute and invoke for magic attributes and state transition is 
now deprecated
  Cleaned up cruft in GBean infos such as declaration of non existent attributes
  Upgraded to newest CGLIB, asm, and commons-collections
  
  Revision  Changes    Path
  1.4       +2 -3      
openejb/modules/openejb-builder/src/test/org/openejb/deployment/AbstractDeploymentTest.java
  
  Index: AbstractDeploymentTest.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/openejb-builder/src/test/org/openejb/deployment/AbstractDeploymentTest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AbstractDeploymentTest.java       10 Feb 2005 11:00:00 -0000      1.3
  +++ AbstractDeploymentTest.java       8 May 2005 19:37:14 -0000       1.4
  @@ -171,7 +171,6 @@
       }
   
       public static void assertRunning(Kernel kernel, ObjectName objectName) 
throws Exception {
  -        int state = ((Integer) kernel.getAttribute(objectName, 
"state")).intValue();
  -        assertEquals("should be running: " + objectName, 
State.RUNNING_INDEX, state);
  +        assertEquals("should be running: " + objectName, 
State.RUNNING_INDEX, kernel.getGBeanState(objectName));
       }
   }
  
  
  
  1.10      +3 -2      
openejb/modules/openejb-builder/src/test/org/openejb/deployment/DeploymentHelper.java
  
  Index: DeploymentHelper.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/openejb-builder/src/test/org/openejb/deployment/DeploymentHelper.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- DeploymentHelper.java     19 Feb 2005 22:26:55 -0000      1.9
  +++ DeploymentHelper.java     8 May 2005 19:37:14 -0000       1.10
  @@ -67,6 +67,7 @@
   import org.apache.geronimo.kernel.GBeanNotFoundException;
   import org.apache.geronimo.kernel.InternalKernelException;
   import org.apache.geronimo.kernel.Kernel;
  +import org.apache.geronimo.kernel.Kernel;
   import org.apache.geronimo.kernel.jmx.JMXUtil;
   import org.apache.geronimo.pool.ThreadPool;
   import org.apache.geronimo.timer.vm.VMStoreThreadPooledNonTransactionalTimer;
  @@ -137,7 +138,7 @@
   
       public static void setUpTimer(Kernel kernel) throws Exception {
           GBeanData threadPoolGBean = new GBeanData(THREADPOOL_NAME, 
ThreadPool.GBEAN_INFO);
  -        threadPoolGBean.setAttribute("keepAliveTime", new Integer(5000));
  +        threadPoolGBean.setAttribute("keepAliveTime", new Long(5000));
           threadPoolGBean.setAttribute("poolSize", new Integer(5));
           threadPoolGBean.setAttribute("poolName", "DefaultThreadPool");
           start(kernel, threadPoolGBean);
  
  
  
  1.5       +8 -18     
openejb/modules/openejb-builder/src/test/org/openejb/deployment/DeploymentTestSuite.java
  
  Index: DeploymentTestSuite.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/openejb-builder/src/test/org/openejb/deployment/DeploymentTestSuite.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DeploymentTestSuite.java  15 Mar 2005 00:07:46 -0000      1.4
  +++ DeploymentTestSuite.java  8 May 2005 19:37:14 -0000       1.5
  @@ -47,11 +47,7 @@
    */
   package org.openejb.deployment;
   
  -import java.io.BufferedInputStream;
   import java.io.File;
  -import java.io.FileInputStream;
  -import java.io.InputStream;
  -import java.io.ObjectInputStream;
   import java.net.URL;
   import java.net.URLClassLoader;
   import java.sql.Connection;
  @@ -73,7 +69,9 @@
   import org.apache.geronimo.j2ee.management.impl.J2EEServerImpl;
   import org.apache.geronimo.kernel.GBeanNotFoundException;
   import org.apache.geronimo.kernel.Kernel;
  +import org.apache.geronimo.kernel.config.ConfigurationData;
   import org.apache.geronimo.kernel.management.State;
  +import org.apache.geronimo.system.configuration.ExecutableConfigurationUtil;
   import org.apache.geronimo.system.serverinfo.ServerInfo;
   import org.openejb.ContainerIndex;
   import org.openejb.corba.compiler.OpenORBSkeletonGenerator;
  @@ -176,10 +174,11 @@
               );
   
               JarFile jarFile = null;
  +            ConfigurationData configurationData = null;
               try {
                   jarFile =DeploymentUtil.createJarFile(moduleFile);
                   Object plan = earConfigBuilder.getDeploymentPlan(null, 
jarFile);
  -                earConfigBuilder.buildConfiguration(plan, jarFile, tempDir);
  +                configurationData = 
earConfigBuilder.buildConfiguration(plan, jarFile, tempDir);
               } finally {
                   if (jarFile != null) {
                       jarFile.close();
  @@ -187,18 +186,10 @@
               }
   
               // start the configuration
  -            GBeanData config = new GBeanData();
  -            InputStream in = new FileInputStream(new File(tempDir, 
"META-INF/config.ser"));
  -            try {
  -                ObjectInputStream ois = new ObjectInputStream(new 
BufferedInputStream(in));
  -                config.readExternal(ois);
  -            } finally {
  -                in.close();
  -            }
  -
  +            GBeanData config = 
ExecutableConfigurationUtil.getConfigurationGBeanData(configurationData);
               config.setName(CONFIGURATION_OBJECT_NAME);
               config.setAttribute("baseURL", tempDir.toURL());
  -            config.setAttribute("parentID", KernelHelper.DEFAULT_PARENTID);
  +            config.setAttribute("parentId", KernelHelper.DEFAULT_PARENTID);
   
               ObjectName containerIndexObjectName = 
ObjectName.getInstance(DOMAIN_NAME + ":type=ContainerIndex");
               GBeanData containerIndexGBean = new 
GBeanData(containerIndexObjectName, ContainerIndex.GBEAN_INFO);
  @@ -285,7 +276,6 @@
       }
   
       private static void assertRunning(Kernel kernel, ObjectName objectName) 
throws Exception {
  -        int state = ((Integer) kernel.getAttribute(objectName, 
"state")).intValue();
  -        assertEquals("should be running: " + objectName, 
State.RUNNING_INDEX, state);
  +        assertEquals("should be running: " + objectName, 
State.RUNNING_INDEX, kernel.getGBeanState(objectName));
       }
   }
  
  
  
  1.3       +2 -1      
openejb/modules/openejb-builder/src/test/org/openejb/deployment/EarDeploymentTest.java
  
  Index: EarDeploymentTest.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/openejb-builder/src/test/org/openejb/deployment/EarDeploymentTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- EarDeploymentTest.java    19 Feb 2005 09:46:41 -0000      1.2
  +++ EarDeploymentTest.java    8 May 2005 19:37:14 -0000       1.3
  @@ -51,6 +51,7 @@
   
   import junit.framework.Test;
   import org.apache.geronimo.kernel.Kernel;
  +import org.apache.geronimo.kernel.Kernel;
   
   /**
    * @version $Revision$ $Date$
  
  
  
  1.2       +2 -1      
openejb/modules/openejb-builder/src/test/org/openejb/deployment/EjbJarModuleDeploymentTest.java
  
  Index: EjbJarModuleDeploymentTest.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/openejb-builder/src/test/org/openejb/deployment/EjbJarModuleDeploymentTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- EjbJarModuleDeploymentTest.java   10 Feb 2005 06:38:32 -0000      1.1
  +++ EjbJarModuleDeploymentTest.java   8 May 2005 19:37:14 -0000       1.2
  @@ -51,6 +51,7 @@
   
   import junit.framework.Test;
   import org.apache.geronimo.kernel.Kernel;
  +import org.apache.geronimo.kernel.Kernel;
   
   /**
    * @version $Revision$ $Date$
  
  
  
  1.3       +44 -25    
openejb/modules/openejb-builder/src/test/org/openejb/deployment/KernelHelper.java
  
  Index: KernelHelper.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/openejb-builder/src/test/org/openejb/deployment/KernelHelper.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- KernelHelper.java 24 Jan 2005 21:16:49 -0000      1.2
  +++ KernelHelper.java 8 May 2005 19:37:14 -0000       1.3
  @@ -23,18 +23,23 @@
   import java.net.URI;
   import java.net.URL;
   import java.util.List;
  +import java.util.Collections;
   import javax.management.MalformedObjectNameException;
  +import javax.management.ObjectName;
   
   import org.apache.geronimo.gbean.GBeanData;
   import org.apache.geronimo.gbean.GBeanInfo;
   import org.apache.geronimo.gbean.GBeanInfoBuilder;
  +import org.apache.geronimo.kernel.KernelFactory;
   import org.apache.geronimo.kernel.Kernel;
  +import org.apache.geronimo.kernel.config.ConfigurationManagerImpl;
   import org.apache.geronimo.kernel.config.Configuration;
   import org.apache.geronimo.kernel.config.ConfigurationStore;
   import org.apache.geronimo.kernel.config.InvalidConfigException;
   import org.apache.geronimo.kernel.config.NoSuchConfigException;
  +import org.apache.geronimo.kernel.config.ConfigurationData;
  +import org.apache.geronimo.kernel.config.ConfigurationManager;
   import org.apache.geronimo.kernel.jmx.JMXUtil;
  -import org.apache.geronimo.kernel.registry.BasicGBeanRegistry;
   import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
   
   /**
  @@ -44,57 +49,71 @@
       public static final URI DEFAULT_PARENTID = 
URI.create("org/apache/geronimo/Server");
   
       public static Kernel getPreparedKernel() throws Exception {
  -        Kernel kernel = new Kernel("bar", new BasicGBeanRegistry());
  +        Kernel kernel = KernelFactory.newInstance().createKernel("bar");
           kernel.boot();
           GBeanData store = new 
GBeanData(JMXUtil.getObjectName("foo:j2eeType=ConfigurationStore,name=mock"), 
MockConfigStore.GBEAN_INFO);
           kernel.loadGBean(store, KernelHelper.class.getClassLoader());
           kernel.startGBean(store.getName());
   
  -        GBeanData baseConfig = (GBeanData) kernel.invoke(store.getName(), 
"getConfiguration", new Object[]{DEFAULT_PARENTID}, new 
String[]{URI.class.getName()});
  -        kernel.loadGBean(baseConfig, KernelHelper.class.getClassLoader());
  -        kernel.startGBean(baseConfig.getName());
  +        ObjectName configurationManagerName = new 
ObjectName(":j2eeType=ConfigurationManager,name=Basic");
  +        GBeanData configurationManagerData = new 
GBeanData(configurationManagerName, ConfigurationManagerImpl.GBEAN_INFO);
  +        configurationManagerData.setReferencePatterns("Stores", 
Collections.singleton(store.getName()));
  +        kernel.loadGBean(configurationManagerData, 
KernelHelper.class.getClassLoader());
  +        kernel.startGBean(configurationManagerName);
  +        ConfigurationManager configurationManager = (ConfigurationManager) 
kernel.getProxyManager().createProxy(configurationManagerName, 
ConfigurationManager.class);
  +
  +        ObjectName baseConfigName = 
configurationManager.load(DEFAULT_PARENTID);
  +        kernel.startGBean(baseConfigName);
   
           return kernel;
       }
   
   
       public static class MockConfigStore implements ConfigurationStore {
  -        public URI install(URL source) throws IOException, 
InvalidConfigException {
  -            return null;
  +        private final Kernel kernel;
  +
  +        public MockConfigStore(Kernel kernel) {
  +            this.kernel = kernel;
           }
   
  -        public URI install(File source) throws IOException, 
InvalidConfigException {
  +        public URI install(URL source) throws IOException, 
InvalidConfigException {
               return null;
           }
   
  -        public void uninstall(URI configID) throws NoSuchConfigException, 
IOException {
  -
  +        public void install(ConfigurationData configurationData, File 
source) throws IOException, InvalidConfigException {
           }
   
  -        public boolean containsConfiguration(URI configID) {
  -            return true;
  +        public void uninstall(URI configID) throws NoSuchConfigException, 
IOException {
           }
   
  -        public GBeanData getConfiguration(URI id) throws 
NoSuchConfigException, IOException, InvalidConfigException {
  -            GBeanData configData = null;
  +        public ObjectName loadConfiguration(URI configId) throws 
NoSuchConfigException, IOException, InvalidConfigException {
  +            ObjectName configurationObjectName = null;
               try {
  -                configData = new 
GBeanData(Configuration.getConfigurationObjectName(id), 
Configuration.GBEAN_INFO);
  +                configurationObjectName = 
Configuration.getConfigurationObjectName(configId);
               } catch (MalformedObjectNameException e) {
                   throw new InvalidConfigException(e);
               }
  -            configData.setAttribute("ID", id);
  +            GBeanData configData = new GBeanData(configurationObjectName, 
Configuration.GBEAN_INFO);
  +            configData.setAttribute("id", configId);
               configData.setAttribute("domain", "test");
               configData.setAttribute("server", "bar");
               configData.setAttribute("gBeanState", NO_OBJECTS_OS);
  -            return configData;
  -        }
   
  -        public void updateConfiguration(Configuration configuration) throws 
NoSuchConfigException, Exception {
  +            try {
  +                kernel.loadGBean(configData, 
Configuration.class.getClassLoader());
  +            } catch (Exception e) {
  +                throw new InvalidConfigException("Unable to register 
configuration", e);
  +            }
   
  +            return configurationObjectName;
           }
   
  -        public URL getBaseURL(URI id) throws NoSuchConfigException {
  -            return null;
  +        public boolean containsConfiguration(URI configID) {
  +            return true;
  +        }
  +
  +        public void updateConfiguration(ConfigurationData configurationData) 
throws NoSuchConfigException, Exception {
  +
           }
   
           public String getObjectName() {
  @@ -116,6 +135,8 @@
           static {
               GBeanInfoBuilder infoBuilder = new 
GBeanInfoBuilder(MockConfigStore.class, NameFactory.CONFIGURATION_STORE);
               infoBuilder.addInterface(ConfigurationStore.class);
  +            infoBuilder.addAttribute("kernel", Kernel.class, false);
  +            infoBuilder.setConstructor(new String[] {"kernel"});
               GBEAN_INFO = infoBuilder.getBeanInfo();
   
               ByteArrayOutputStream baos = new ByteArrayOutputStream();
  @@ -127,7 +148,5 @@
                   throw new RuntimeException(e);
               }
           }
  -    };
  -
  -
  +    }
   }
  
  
  

Reply via email to