geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: rev 55986 - in geronimo/trunk/modules: deployment/src/java/org/apache/geronimo/deployment deployment/src/java/org/apache/geronimo/deployment/service kernel/src/java/org/apache/geronimo/gbean kernel/src/java/org/apache/geronimo/kernel
Date Fri, 29 Oct 2004 18:53:35 GMT
Author: dain
Date: Fri Oct 29 11:53:34 2004
New Revision: 55986

Modified:
   geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java
   geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/service/GBeanBuilder.java
   geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/service/GBeanHelper.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanInfo.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/Kernel.java
Log:
Added apis to allow use of GBeanData instead of GBeanMBean
Changed GBeanHelper to get the default type of an attribute from the GBeanInfo
Added getAttribute(name) to GBeanInfo


Modified: geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java
==============================================================================
--- geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java
(original)
+++ geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java
Fri Oct 29 11:53:34 2004
@@ -49,6 +49,7 @@
 
 import org.apache.geronimo.deployment.util.DeploymentUtil;
 import org.apache.geronimo.gbean.jmx.GBeanMBean;
+import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.repository.Repository;
 import org.apache.geronimo.kernel.config.Configuration;
@@ -152,6 +153,11 @@
 
     public void addGBean(ObjectName name, GBeanMBean gbean) {
         gbeans.put(name, gbean);
+    }
+
+    public void addGBean(ObjectName name, GBeanData gbean, ClassLoader classLoader) {
+        GBeanMBean gbeanMBean = new GBeanMBean(gbean, classLoader);
+        gbeans.put(name, gbeanMBean);
     }
 
     public void addDependency(URI uri) {

Modified: geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/service/GBeanBuilder.java
==============================================================================
--- geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/service/GBeanBuilder.java
(original)
+++ geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/service/GBeanBuilder.java
Fri Oct 29 11:53:34 2004
@@ -20,13 +20,14 @@
 import java.beans.PropertyEditor;
 import java.util.HashSet;
 import java.util.Set;
-import javax.management.AttributeNotFoundException;
 import javax.management.MalformedObjectNameException;
 import javax.management.ObjectName;
 
 import org.apache.geronimo.common.propertyeditor.PropertyEditors;
 import org.apache.geronimo.deployment.DeploymentException;
-import org.apache.geronimo.gbean.jmx.GBeanMBean;
+import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GAttributeInfo;
 
 /**
  *
@@ -35,7 +36,8 @@
  */
 public class GBeanBuilder {
     private final ObjectName name;
-    private final GBeanMBean gbean;
+    private final GBeanData gbean;
+    private final ClassLoader classLoader;
 
     public GBeanBuilder(String name, ClassLoader classLoader, String className) throws DeploymentException
{
         try {
@@ -43,8 +45,11 @@
         } catch (MalformedObjectNameException e) {
             throw new DeploymentException("Invalid ObjectName: " + name, e);
         }
+
+        this.classLoader = classLoader;
+
         try {
-            this.gbean = new GBeanMBean(className, classLoader);
+            gbean = new GBeanData(GBeanInfo.getGBeanInfo(className, classLoader));
         } catch (Exception e) {
             throw new DeploymentException("Unable to create GBean from class " + className,
e);
         }
@@ -53,7 +58,12 @@
     public void setAttribute(String name, String type, String text) throws DeploymentException
{
         try {
             // @todo we should not need all of common just for this
-            PropertyEditor editor = PropertyEditors.findEditor(type, gbean.getClassLoader());
+            if (type == null) {
+                GAttributeInfo attribute = gbean.getGBeanInfo().getAttribute(name);
+                type = attribute.getType();
+            }
+
+            PropertyEditor editor = PropertyEditors.findEditor(type, classLoader);
             if (editor == null) {
                 throw new DeploymentException("Unable to find PropertyEditor for " + type);
             }
@@ -62,8 +72,6 @@
             gbean.setAttribute(name, value);
         } catch (ClassNotFoundException e) {
             throw new DeploymentException("Unable to find PropertyEditor for " + type, e);
-        } catch (AttributeNotFoundException e) {
-            throw new DeploymentException("Unknown attribute " + name);
         } catch (Exception e) {
             throw new DeploymentException("Unable to set attribute " + name + " to " + text,
e);
         }
@@ -85,7 +93,7 @@
         gbean.setReferencePatterns(name, patternNames);
     }
 
-    public GBeanMBean getGBean() {
+    public GBeanData getGBeanData() {
         return gbean;
     }
 

Modified: geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/service/GBeanHelper.java
==============================================================================
--- geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/service/GBeanHelper.java
(original)
+++ geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/service/GBeanHelper.java
Fri Oct 29 11:53:34 2004
@@ -45,6 +45,6 @@
             builder.setReference(gbean.getReferencesName(j), gbean.getReferencesPatternArray(j));
         }
 
-        context.addGBean(builder.getName(), builder.getGBean());
+        context.addGBean(builder.getName(), builder.getGBeanData(), cl);
     }
 }

Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanInfo.java
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanInfo.java	(original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanInfo.java	Fri Oct
29 11:53:34 2004
@@ -26,6 +26,8 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
+import java.util.Map;
+import java.util.HashMap;
 
 /**
  * Describes a GBean.
@@ -64,6 +66,7 @@
     private final String name;
     private final String className;
     private final Set attributes;
+    private final Map attributesByName;
     private final GConstructorInfo constructor;
     private final Set operations;
     private final Set notifications;
@@ -78,8 +81,15 @@
         this.className = className;
         if (attributes == null) {
             this.attributes = Collections.EMPTY_SET;
+            this.attributesByName = Collections.EMPTY_MAP;
         } else {
-            this.attributes = Collections.unmodifiableSet(new HashSet(attributes));
+            Map map = new HashMap();
+            for (Iterator iterator = attributes.iterator(); iterator.hasNext();) {
+                GAttributeInfo attribute = (GAttributeInfo) iterator.next();
+                map.put(attribute.getName(), attribute);
+            }
+            this.attributesByName = Collections.unmodifiableMap(map);
+            this.attributes = Collections.unmodifiableSet(new HashSet(map.values()));
         }
         if (constructor == null) {
             this.constructor = new GConstructorInfo(Collections.EMPTY_LIST);
@@ -111,6 +121,10 @@
         return className;
     }
 
+    public GAttributeInfo getAttribute(String name) {
+        return (GAttributeInfo) attributesByName.get(name);
+    }
+    
     public Set getAttributes() {
         return attributes;
     }

Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/Kernel.java
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/Kernel.java	(original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/Kernel.java	Fri Oct
29 11:53:34 2004
@@ -282,6 +282,17 @@
         }
     }
 
+    public void loadGBean(ObjectName name, GBeanData gbeanData, ClassLoader classLoader)
throws InstanceAlreadyExistsException, InvalidConfigException {
+        try {
+            GBeanMBean gbean = new GBeanMBean(gbeanData, classLoader);
+            mbServer.registerMBean(gbean, name);
+        } catch (MBeanRegistrationException e) {
+            throw new InvalidConfigException("Invalid GBean configuration for " + name, e);
+        } catch (NotCompliantMBeanException e) {
+            throw new InvalidConfigException("Invalid GBean configuration for " + name, e);
+        }
+    }
+
     public void loadGBean(ObjectName name, GBeanMBean gbean) throws InstanceAlreadyExistsException,
InvalidConfigException {
         try {
             mbServer.registerMBean(gbean, name);

Mime
View raw message