From scm-return-12701-apmail-geronimo-scm-archive=geronimo.apache.org@geronimo.apache.org Thu Jun 01 23:49:19 2006 Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 82572 invoked from network); 1 Jun 2006 23:49:18 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 1 Jun 2006 23:49:18 -0000 Received: (qmail 44624 invoked by uid 500); 1 Jun 2006 23:49:18 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 44476 invoked by uid 500); 1 Jun 2006 23:49:17 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 44459 invoked by uid 99); 1 Jun 2006 23:49:17 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Jun 2006 16:49:17 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Jun 2006 16:49:16 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id D2BE61A983A; Thu, 1 Jun 2006 16:48:56 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: scm@geronimo.apache.org From: djencks@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060601234856.D2BE61A983A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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 @@ ${PlanServerHostname} ${PlanHTTPSPortPrimary} - + 0.0.0.0 8009 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 {