geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: rev 56525 - in geronimo/trunk/modules: kernel/src/java/org/apache/geronimo/gbean/jmx system/src/test/org/apache/geronimo/system/configuration
Date Wed, 03 Nov 2004 20:45:37 GMT
Author: dain
Date: Wed Nov  3 12:45:34 2004
New Revision: 56525

Modified:
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanMBean.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanMBeanAttribute.java
   geronimo/trunk/modules/system/src/test/org/apache/geronimo/system/configuration/LocalConfigStoreTest.java
Log:
You can now disable gbeans by setting gbeanEnabled=false
A disabled gbean can not be started and is not started as part of startRecursive


Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanMBean.java
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanMBean.java	(original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanMBean.java	Wed
Nov  3 12:45:34 2004
@@ -949,7 +949,9 @@
                                 setEnabled(enabled.booleanValue());
                                 return null;
                             }
-                        }));
+                        },
+                        true,
+                        Boolean.TRUE));
 
         //
         // Normal attributes

Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanMBeanAttribute.java
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanMBeanAttribute.java
(original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanMBeanAttribute.java
Wed Nov  3 12:45:34 2004
@@ -115,6 +115,10 @@
 
 
     GBeanMBeanAttribute(GBeanMBean gmbean, String name, Class type, MethodInvoker getInvoker,
MethodInvoker setInvoker) {
+        this(gmbean, name, type, getInvoker, setInvoker, false, null);
+    }
+
+    GBeanMBeanAttribute(GBeanMBean gmbean, String name, Class type, MethodInvoker getInvoker,
MethodInvoker setInvoker, boolean persistent, Object persistentValue) {
         if (gmbean == null || name == null || type == null) {
             throw new IllegalArgumentException("null param(s) supplied");
         }
@@ -130,7 +134,8 @@
         this.writable = (setInvoker != null);
         this.setInvoker = setInvoker;
         this.isConstructorArg = false;
-        this.persistent = false;
+        this.persistent = persistent;
+        initializePersistentValue(persistentValue);
         if (!readable && !writable) {
             this.mbeanAttributeInfo = null;
         } else {
@@ -217,26 +222,33 @@
 
         mbeanAttributeInfo = new MBeanAttributeInfo(attributeInfo.getName(), type.getName(),
null, readable, writable, isIs);
 
-        if (persistent && type.isPrimitive()) {
-            if (type == Boolean.TYPE) {
-                persistentValue = Boolean.FALSE;
-            } else if (type == Byte.TYPE) {
-                persistentValue = new Byte((byte) 0);
-            } else if (type == Short.TYPE) {
-                persistentValue = new Short((short) 0);
-            } else if (type == Integer.TYPE) {
-                persistentValue = new Integer(0);
-            } else if (type == Long.TYPE) {
-                persistentValue = new Long(0);
-            } else if (type == Character.TYPE) {
-                persistentValue = new Character((char) 0);
-            } else if (type == Float.TYPE) {
-                persistentValue = new Float(0);
-            } else /** if (type == Double.TYPE) */ {
-                persistentValue = new Double(0);
+        initializePersistentValue(null);
+        special = false;
+    }
+
+    private void initializePersistentValue(Object value) {
+        if (persistent) {
+            if (value == null && type.isPrimitive()) {
+                if (type == Boolean.TYPE) {
+                    value = Boolean.FALSE;
+                } else if (type == Byte.TYPE) {
+                    value = new Byte((byte) 0);
+                } else if (type == Short.TYPE) {
+                    value = new Short((short) 0);
+                } else if (type == Integer.TYPE) {
+                    value = new Integer(0);
+                } else if (type == Long.TYPE) {
+                    value = new Long(0);
+                } else if (type == Character.TYPE) {
+                    value = new Character((char) 0);
+                } else if (type == Float.TYPE) {
+                    value = new Float(0);
+                } else /** if (type == Double.TYPE) */ {
+                    value = new Double(0);
+                }
             }
+            persistentValue = value;
         }
-        special = false;
     }
 
     public String getName() {

Modified: geronimo/trunk/modules/system/src/test/org/apache/geronimo/system/configuration/LocalConfigStoreTest.java
==============================================================================
--- geronimo/trunk/modules/system/src/test/org/apache/geronimo/system/configuration/LocalConfigStoreTest.java
(original)
+++ geronimo/trunk/modules/system/src/test/org/apache/geronimo/system/configuration/LocalConfigStoreTest.java
Wed Nov  3 12:45:34 2004
@@ -50,6 +50,7 @@
     private Kernel kernel;
     private byte[] state;
     private ObjectName gbeanName1;
+    private ObjectName gbeanName2;
     private ObjectName storeName;
 
     public void testInstall() throws Exception {
@@ -85,10 +86,13 @@
         ObjectName configName = configurationManager.load(uri);
         kernel.invoke(configName, "startRecursive", null, null);
 
-        // make sure the config and the gbean are running
+        // make sure the config and the enabled gbean are running
         assertEquals(new Integer(State.RUNNING_INDEX), kernel.getAttribute(configName, "state"));
         assertEquals(new Integer(State.RUNNING_INDEX), kernel.getAttribute(gbeanName1, "state"));
 
+        // make sure the config and the disabled gbean are NOT running
+        assertEquals(new Integer(State.STOPPED_INDEX), kernel.getAttribute(gbeanName2, "state"));
+
         // set the value
         kernel.setAttribute(gbeanName1, "value", "9900990099");
         assertEquals("9900990099", kernel.getAttribute(gbeanName1, "value"));
@@ -121,8 +125,14 @@
             GBeanMBean mockBean1 = new GBeanMBean(MockGBean.getGBeanInfo());
             mockBean1.setAttribute("value", "1234");
 
+            gbeanName2 = new ObjectName("geronimo.test:name=MyMockGMBean2");
+            GBeanMBean mockBean2 = new GBeanMBean(MockGBean.getGBeanInfo());
+            mockBean2.setAttribute("gbeanEnabled", Boolean.FALSE);
+            mockBean2.setAttribute("value", "1234");
+
             Map gbeans = new HashMap();
             gbeans.put(gbeanName1, mockBean1);
+            gbeans.put(gbeanName2, mockBean2);
             state = Configuration.storeGBeans(gbeans);
 
             root = new File(System.getProperty("java.io.tmpdir") + "/config-store");

Mime
View raw message