geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r411001 - in /geronimo/branches/1.1: assemblies/minimal-jetty-server/src/var/config/ modules/system/src/java/org/apache/geronimo/system/configuration/ modules/system/src/test/org/apache/geronimo/system/configuration/
Date Thu, 01 Jun 2006 23:48:56 GMT
Author: djencks
Date: Thu Jun  1 16:48:55 2006
New Revision: 411001

URL: http://svn.apache.org/viewvc?rev=411001&view=rev
Log:
GERONIMO-2058 object if config.xml contains info for nonexistent gbeans

Modified:
    geronimo/branches/1.1/assemblies/minimal-jetty-server/src/var/config/config.xml
    geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java
    geronimo/branches/1.1/modules/system/src/test/org/apache/geronimo/system/configuration/LocalAttributeManagerTest.java

Modified: geronimo/branches/1.1/assemblies/minimal-jetty-server/src/var/config/config.xml
URL: http://svn.apache.org/viewvc/geronimo/branches/1.1/assemblies/minimal-jetty-server/src/var/config/config.xml?rev=411001&r1=411000&r2=411001&view=diff
==============================================================================
--- geronimo/branches/1.1/assemblies/minimal-jetty-server/src/var/config/config.xml (original)
+++ geronimo/branches/1.1/assemblies/minimal-jetty-server/src/var/config/config.xml Thu Jun
 1 16:48:55 2006
@@ -40,7 +40,7 @@
             <attribute name="host">${PlanServerHostname}</attribute>
             <attribute name="port">${PlanHTTPSPortPrimary}</attribute>
         </gbean>
-        <gbean name="JettyAJPConnector">
+        <gbean name="JettyAJP13Connector">
             <attribute name="host">0.0.0.0</attribute>
             <attribute name="port">8009</attribute>
         </gbean>

Modified: geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java
URL: http://svn.apache.org/viewvc/geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java?rev=411001&r1=411000&r2=411001&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java
(original)
+++ geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java
Thu Jun  1 16:48:55 2006
@@ -116,6 +116,7 @@
         for (Iterator iterator = gbeanDatas.iterator(); iterator.hasNext();) {
             GBeanData gbeanData = (GBeanData) iterator.next();
             datasByName.put(gbeanData.getAbstractName(), gbeanData);
+            datasByName.put(gbeanData.getAbstractName().getName().get("name"), gbeanData);
         }
 
         // add the new GBeans
@@ -123,11 +124,20 @@
             Map.Entry entry = (Map.Entry) iterator.next();
             Object name = entry.getKey();
             GBeanOverride gbean = (GBeanOverride) entry.getValue();
-            if (!datasByName.containsKey(name) && gbean.getGBeanInfo() != null &&
gbean.isLoad()) {
-                if (!(name instanceof AbstractName)) {
-                    throw new InvalidConfigException("New GBeans must be specified with a
full abstractName:" +
-                            " configuration=" + configName +
-                            " gbeanName=" + name);
+            if (!datasByName.containsKey(name) && gbean.isLoad()) {
+                if (gbean.getGBeanInfo() == null || !(name instanceof AbstractName)) {
+                    String sep = "";
+                    StringBuffer message = new StringBuffer("New GBeans must be specified
with ");
+                    if (gbean.getGBeanInfo() == null) {
+                        message.append("a GBeanInfo ");
+                        sep = "and ";
+                    }
+                    if (!(name instanceof AbstractName)) {
+                        message.append(sep).append("a full AbstractName ");
+                    }
+                    message.append("configuration=").append(configName);
+                    message.append(" gbeanName=").append(name);
+                    throw new InvalidConfigException(message.toString());
                 }
                 GBeanInfo gbeanInfo = GBeanInfo.getGBeanInfo(gbean.getGBeanInfo(), classLoader);
                 AbstractName abstractName = (AbstractName)name;
@@ -191,15 +201,15 @@
 
         //Clear attributes
         for (Iterator iterator = gbean.getClearAttributes().iterator(); iterator.hasNext();){
-           String attribute = (String) iterator.next(); 
+           String attribute = (String) iterator.next();
            if (gbean.getClearAttribute(attribute)){
                data.clearAttribute(attribute);
-           }    
-        }   
-        
+           }
+        }
+
         //Null attributes
         for (Iterator iterator = gbean.getNullAttributes().iterator(); iterator.hasNext();){
-           String attribute = (String) iterator.next(); 
+           String attribute = (String) iterator.next();
            if (gbean.getNullAttribute(attribute)){
                data.setAttribute(attribute, null);
            }
@@ -222,7 +232,7 @@
 
         //Clear references
         for (Iterator iterator = gbean.getClearReferences().iterator(); iterator.hasNext();){
-           String reference = (String) iterator.next(); 
+           String reference = (String) iterator.next();
            if (gbean.getClearReference(reference)){
                data.clearReference(reference);
            }
@@ -361,13 +371,13 @@
                                  "http://www.w3.org/2001/XMLSchema");
             dFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource",
                                  LocalAttributeManager.class.getResourceAsStream("/META-INF/schema/local-attributes-1.1.xsd"));
-            
+
             DocumentBuilder builder = dFactory.newDocumentBuilder();
             builder.setErrorHandler(new ErrorHandler() {
                 public void error(SAXParseException exception) {
                     log.error("Unable to read saved manageable attributes. " +
                         "SAX parse error: " + exception.getMessage() +
-                        " at line " + exception.getLineNumber() + 
+                        " at line " + exception.getLineNumber() +
                         ", column " + exception.getColumnNumber() +
                         " in entity " + exception.getSystemId());
                     // TODO throw an exception here?
@@ -376,20 +386,20 @@
                 public void fatalError(SAXParseException exception) {
                     log.error("Unable to read saved manageable attributes. " +
                             "Fatal SAX parse error: " + exception.getMessage() +
-                            " at line " + exception.getLineNumber() + 
+                            " at line " + exception.getLineNumber() +
                             ", column " + exception.getColumnNumber() +
                             " in entity " + exception.getSystemId());
-                    // TODO throw an exception here?                    
+                    // TODO throw an exception here?
                 }
 
                 public void warning(SAXParseException exception) {
                     log.error("SAX parse warning whilst reading saved manageable attributes:
" +
                             exception.getMessage() +
-                            " at line " + exception.getLineNumber() + 
+                            " at line " + exception.getLineNumber() +
                             ", column " + exception.getColumnNumber() +
                             " in entity " + exception.getSystemId());
                 }
-            });            
+            });
             Document doc = builder.parse(in);
             Element root = doc.getDocumentElement();
             serverOverride = new ServerOverride(root);

Modified: geronimo/branches/1.1/modules/system/src/test/org/apache/geronimo/system/configuration/LocalAttributeManagerTest.java
URL: http://svn.apache.org/viewvc/geronimo/branches/1.1/modules/system/src/test/org/apache/geronimo/system/configuration/LocalAttributeManagerTest.java?rev=411001&r1=411000&r2=411001&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/system/src/test/org/apache/geronimo/system/configuration/LocalAttributeManagerTest.java
(original)
+++ geronimo/branches/1.1/modules/system/src/test/org/apache/geronimo/system/configuration/LocalAttributeManagerTest.java
Thu Jun  1 16:48:55 2006
@@ -28,9 +28,11 @@
 import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.geronimo.kernel.Naming;
 import org.apache.geronimo.kernel.Jsr77Naming;
+import org.apache.geronimo.kernel.config.InvalidConfigException;
 import org.apache.geronimo.system.serverinfo.BasicServerInfo;
 
 import javax.management.ObjectName;
+
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -118,7 +120,7 @@
         assertEquals(attributeValue, gbeanData.getAttribute(attributeInfo.getName()));
     }
 
-    public void testSetAtrribute() throws Exception {
+    public void testSetAttribute() throws Exception {
         String attributeValue = "attribute value";
         localAttributeManager.setValue(configurationName, gbeanName, attributeInfo, attributeValue);
         Collection gbeanDatas = new ArrayList();
@@ -145,7 +147,7 @@
 
         AbstractName referencePattern1 = naming.createRootName(gbeanName.getArtifact(), "name",
"referencePattern1");
         AbstractName referencePattern2 = naming.createRootName(gbeanName.getArtifact(), "name",
"referencePattern2");
-        ReferencePatterns referencePatterns = new ReferencePatterns(new LinkedHashSet(Arrays.asList(new
AbstractName[] {referencePattern1, referencePattern2})));
+        ReferencePatterns referencePatterns = new ReferencePatterns(new LinkedHashSet(Arrays.asList(new
AbstractName[]{referencePattern1, referencePattern2})));
         localAttributeManager.setReferencePatterns(configurationName, gbeanName, referenceInfo,
referencePatterns);
         Collection gbeanDatas = new ArrayList();
         GBeanData gbeanData = new GBeanData(gbeanName, GBEAN_INFO);
@@ -175,6 +177,18 @@
         assertSame(gbeanData.getAbstractName(), newGBeanData.getAbstractName());
         assertEquals(Collections.singleton(referencePattern), newGBeanData.getReferencePatterns(referenceInfo.getName()).getPatterns());
         assertEquals(attributeValue, newGBeanData.getAttribute(attributeInfo.getName()));
+    }
+
+    public void testBadGBeanSpec() throws Exception {
+        String attributeValue = "attribute value";
+        localAttributeManager.addConfiguration(configurationName);
+        localAttributeManager.setValue(configurationName, gbeanName, attributeInfo, attributeValue);
+        try {
+            localAttributeManager.applyOverrides(configurationName, Collections.EMPTY_SET,
getClass().getClassLoader());
+            fail("no gbeans were specified in the 'plan' so overrides should fail");
+        } catch (InvalidConfigException e) {
+            //pass
+        }
     }
 
     protected void setUp() throws Exception {



Mime
View raw message