geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r831112 - /geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/runtime/GBeanInstance.java
Date Thu, 29 Oct 2009 22:10:16 GMT
Author: djencks
Date: Thu Oct 29 22:10:15 2009
New Revision: 831112

URL: http://svn.apache.org/viewvc?rev=831112&view=rev
Log:
GERONIMO-4907 Complain about all attempts to set non-existent gbean properties at once

Modified:
    geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/runtime/GBeanInstance.java

Modified: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/runtime/GBeanInstance.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/runtime/GBeanInstance.java?rev=831112&r1=831111&r2=831112&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/runtime/GBeanInstance.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/runtime/GBeanInstance.java
Thu Oct 29 22:10:15 2009
@@ -57,6 +57,7 @@
 import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.xbean.recipe.ConstructionException;
 import org.apache.xbean.recipe.ObjectRecipe;
+import org.apache.xbean.recipe.Option;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 
@@ -308,18 +309,19 @@
         List<String> cstrNames = beanInfo.getConstructor().getAttributeNames();
         Class[] cstrTypes = new Class[cstrNames.size()];
         for (int i = 0; i < cstrTypes.length; i++) {
-            String argumentName = (String) cstrNames.get(i);
+            String argumentName = cstrNames.get(i);
             if (referenceIndex.containsKey(argumentName)) {
-                Integer index = (Integer) referenceIndex.get(argumentName);
-                GBeanReference reference = references[index.intValue()];
+                Integer index = referenceIndex.get(argumentName);
+                GBeanReference reference = references[index];
                 cstrTypes[i] = reference.getProxyType();
             } else if (attributeIndex.containsKey(argumentName)) {
-                Integer index = (Integer) attributeIndex.get(argumentName);
-                GBeanAttribute attribute = attributes[index.intValue()];
+                Integer index = attributeIndex.get(argumentName);
+                GBeanAttribute attribute = attributes[index];
                 cstrTypes[i] = attribute.getType();
             }
         }
         ObjectRecipe objectRecipe = new ObjectRecipe(type, cstrNames.toArray(new String[0]),
cstrTypes);
+        objectRecipe.allow(Option.IGNORE_MISSING_PROPERTIES);
 
         // set the initial attribute values
         Map<String, Object> dataAttributes = gbeanData.getAttributes();
@@ -925,6 +927,10 @@
                 stateReason = "the service constructor threw an exception. \n" + printException(e);
                 throw e;
             }
+            Map<String, Object> unsetProperties = objectRecipe.getUnsetProperties();
+            if (unsetProperties.size() > 0) {
+                throw new ConstructionException("Error creating gbean of class: " + gbeanInfo.getClassName()
+ ", attempting to set nonexistent properties: " + unsetProperties.keySet());
+            }
             
             // write the target variable in a synchronized block so it is available to all
threads
             // we do this before calling the setters or start method so the bean can be called
back



Mime
View raw message