geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vamsic...@apache.org
Subject svn commit: r497782 - in /geronimo/server: branches/1.2/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/ branches/1.2/modules/geronimo-system/src/test/java/org/apache/geronimo/system/configuration/ trunk/modules/geronimo-...
Date Fri, 19 Jan 2007 12:03:02 GMT
Author: vamsic007
Date: Fri Jan 19 04:03:01 2007
New Revision: 497782

URL: http://svn.apache.org/viewvc?view=rev&rev=497782
Log:
GERONIMO-2105 When redeploying with no version number, new entries in config.xml break
  o This was fixed in rev 413342 in branches\1.1 (though the entries in config.xml are migrated
properly, attribute value changes get reflected only upon restarting the configuration). Neither
the revision was merged into trunk nor the JIRA was updated about the revision.
  o Merging rev 413342 into branches\1.2 and trunk

Modified:
    geronimo/server/branches/1.2/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/ConfigurationOverride.java
    geronimo/server/branches/1.2/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/GBeanOverride.java
    geronimo/server/branches/1.2/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java
    geronimo/server/branches/1.2/modules/geronimo-system/src/test/java/org/apache/geronimo/system/configuration/LocalAttributeManagerTest.java
    geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/ConfigurationOverride.java
    geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/GBeanOverride.java
    geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java
    geronimo/server/trunk/modules/geronimo-system/src/test/java/org/apache/geronimo/system/configuration/LocalAttributeManagerTest.java

Modified: geronimo/server/branches/1.2/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/ConfigurationOverride.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/1.2/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/ConfigurationOverride.java?view=diff&rev=497782&r1=497781&r2=497782
==============================================================================
--- geronimo/server/branches/1.2/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/ConfigurationOverride.java
(original)
+++ geronimo/server/branches/1.2/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/ConfigurationOverride.java
Fri Jan 19 04:03:01 2007
@@ -52,11 +52,21 @@
         this.load = load;
     }
 
+    /**
+     * Create a copy of a ConfigurationOverride with a new Artifact name
+     * @param base The original
+     * @param name The new Artifact name
+     */
     public ConfigurationOverride(ConfigurationOverride base, Artifact name) {
         this.name = name;
         this.load = base.load;
         this.condition = base.condition;
-        this.gbeans.putAll(base.gbeans);
+        for (Iterator it = base.gbeans.keySet().iterator(); it.hasNext();) {
+            Object gbeanName = it.next();
+            GBeanOverride gbean = (GBeanOverride) base.gbeans.get(gbeanName);
+            GBeanOverride replacement = new GBeanOverride(gbean, base.name.toString(), name.toString());
+            gbeans.put(replacement.getName(), replacement);
+        }
     }
 
     public ConfigurationOverride(Element element) throws InvalidGBeanException {

Modified: geronimo/server/branches/1.2/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/GBeanOverride.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/1.2/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/GBeanOverride.java?view=diff&rev=497782&r1=497781&r2=497782
==============================================================================
--- geronimo/server/branches/1.2/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/GBeanOverride.java
(original)
+++ geronimo/server/branches/1.2/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/GBeanOverride.java
Fri Jan 19 04:03:01 2007
@@ -77,6 +77,42 @@
         gbeanInfo = null;
     }
 
+    public GBeanOverride(GBeanOverride original, String oldArtifact, String newArtifact)
{
+        Object name = original.name;
+        if(name instanceof String) {
+            name = replace((String)name, oldArtifact, newArtifact);
+        } else if(name instanceof AbstractName) {
+            String value = name.toString();
+            value = replace(value, oldArtifact, newArtifact);
+            name = new AbstractName(URI.create(value));
+        }
+        this.name = name;
+        this.load = original.load;
+        this.attributes.putAll(original.attributes);
+        this.references.putAll(original.references);
+        this.clearAttributes.addAll(original.clearAttributes);
+        this.nullAttributes.addAll(original.nullAttributes);
+        this.clearReferences.addAll(original.clearReferences);
+        this.gbeanInfo = original.gbeanInfo;
+    }
+
+    private static String replace(String original, String oldArtifact, String newArtifact)
{
+        int pos = original.indexOf(oldArtifact);
+        if(pos == -1) {
+            return original;
+        }
+        int last = -1;
+        StringBuffer buf = new StringBuffer();
+        while(pos > -1) {
+            buf.append(original.substring(last+1, pos));
+            buf.append(newArtifact);
+            last = pos+oldArtifact.length()-1;
+            pos = original.indexOf(oldArtifact, last);
+        }
+        buf.append(original.substring(last+1));
+        return buf.toString();
+    }
+
     public GBeanOverride(GBeanData gbeanData) throws InvalidAttributeException {
         GBeanInfo gbeanInfo = gbeanData.getGBeanInfo();
         this.gbeanInfo = gbeanInfo.getSourceClass();

Modified: geronimo/server/branches/1.2/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/1.2/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java?view=diff&rev=497782&r1=497781&r2=497782
==============================================================================
--- geronimo/server/branches/1.2/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java
(original)
+++ geronimo/server/branches/1.2/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java
Fri Jan 19 04:03:01 2007
@@ -27,6 +27,7 @@
 import java.util.List;
 import java.util.SortedSet;
 import java.util.Set;
+import java.util.Collections;
 import java.util.jar.JarFile;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipOutputStream;
@@ -201,12 +202,16 @@
                 location = new File(location, moduleName);
             }
 
-            if (location.isDirectory()) {
-                Set matches = IOUtil.search(location, path);
-                return matches;
+            if(path == null) {
+                return Collections.singleton(location.toURL());
             } else {
-                Set matches = IOUtil.search(location, path);
-                return matches;
+                if (location.isDirectory()) {
+                    Set matches = IOUtil.search(location, path);
+                    return matches;
+                } else {
+                    Set matches = IOUtil.search(location, path);
+                    return matches;
+                }
             }
         } else {
             Set matches = IOUtil.search(location, moduleName + "/" +path);

Modified: geronimo/server/branches/1.2/modules/geronimo-system/src/test/java/org/apache/geronimo/system/configuration/LocalAttributeManagerTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/1.2/modules/geronimo-system/src/test/java/org/apache/geronimo/system/configuration/LocalAttributeManagerTest.java?view=diff&rev=497782&r1=497781&r2=497782
==============================================================================
--- geronimo/server/branches/1.2/modules/geronimo-system/src/test/java/org/apache/geronimo/system/configuration/LocalAttributeManagerTest.java
(original)
+++ geronimo/server/branches/1.2/modules/geronimo-system/src/test/java/org/apache/geronimo/system/configuration/LocalAttributeManagerTest.java
Fri Jan 19 04:03:01 2007
@@ -191,11 +191,36 @@
         }
     }
 
+    public void testMigrate() throws Exception {
+        String attributeValue = "attribute value";
+        AbstractNameQuery referencePattern = new AbstractNameQuery(LocalAttributeManagerTest.class.getName());
+
+        localAttributeManager.addConfiguration(configurationName);
+        localAttributeManager.setValue(configurationName, gbeanName, attributeInfo, attributeValue);
+
+        Collection gbeanDatas = new ArrayList();
+        GBeanData gbeanData = new GBeanData(gbeanName, GBEAN_INFO);
+        gbeanDatas.add(gbeanData);
+        gbeanDatas = localAttributeManager.applyOverrides(configurationName, gbeanDatas,
getClass().getClassLoader());
+        assertEquals(attributeValue, gbeanData.getAttribute(attributeInfo.getName()));
+
+        Artifact newArtifact = Artifact.create("configuration/name/2/car");
+        localAttributeManager.migrateConfiguration(configurationName, newArtifact, null);
+        ObjectName objectName = ObjectName.getInstance(":name=gbean,parent="+newArtifact+",foo=bar");
+        AbstractName newGBeanName = new AbstractName(newArtifact, objectName.getKeyPropertyList(),
objectName);
+
+        gbeanDatas = new ArrayList();
+        gbeanData = new GBeanData(newGBeanName, GBEAN_INFO);
+        gbeanDatas.add(gbeanData);
+        gbeanDatas = localAttributeManager.applyOverrides(newArtifact, gbeanDatas, getClass().getClassLoader());
+        assertEquals(attributeValue, gbeanData.getAttribute(attributeInfo.getName()));
+    }
+
     protected void setUp() throws Exception {
         super.setUp();
         localAttributeManager = new LocalAttributeManager("target/test-config.xml", false,
new BasicServerInfo(basedir));
         configurationName = Artifact.create("configuration/name/1/car");
-        ObjectName objectName = ObjectName.getInstance(":name=gbean");
+        ObjectName objectName = ObjectName.getInstance(":name=gbean,parent="+configurationName+",foo=bar");
         gbeanName = new AbstractName(configurationName, objectName.getKeyPropertyList(),
objectName);
         attributeInfo = GBEAN_INFO.getAttribute("attribute");
         referenceInfo = GBEAN_INFO.getReference("reference");

Modified: geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/ConfigurationOverride.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/ConfigurationOverride.java?view=diff&rev=497782&r1=497781&r2=497782
==============================================================================
--- geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/ConfigurationOverride.java
(original)
+++ geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/ConfigurationOverride.java
Fri Jan 19 04:03:01 2007
@@ -52,11 +52,21 @@
         this.load = load;
     }
 
+    /**
+     * Create a copy of a ConfigurationOverride with a new Artifact name
+     * @param base The original
+     * @param name The new Artifact name
+     */
     public ConfigurationOverride(ConfigurationOverride base, Artifact name) {
         this.name = name;
         this.load = base.load;
         this.condition = base.condition;
-        this.gbeans.putAll(base.gbeans);
+        for (Iterator it = base.gbeans.keySet().iterator(); it.hasNext();) {
+            Object gbeanName = it.next();
+            GBeanOverride gbean = (GBeanOverride) base.gbeans.get(gbeanName);
+            GBeanOverride replacement = new GBeanOverride(gbean, base.name.toString(), name.toString());
+            gbeans.put(replacement.getName(), replacement);
+        }
     }
 
     public ConfigurationOverride(Element element) throws InvalidGBeanException {

Modified: geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/GBeanOverride.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/GBeanOverride.java?view=diff&rev=497782&r1=497781&r2=497782
==============================================================================
--- geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/GBeanOverride.java
(original)
+++ geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/GBeanOverride.java
Fri Jan 19 04:03:01 2007
@@ -77,6 +77,42 @@
         gbeanInfo = null;
     }
 
+    public GBeanOverride(GBeanOverride original, String oldArtifact, String newArtifact)
{
+        Object name = original.name;
+        if(name instanceof String) {
+            name = replace((String)name, oldArtifact, newArtifact);
+        } else if(name instanceof AbstractName) {
+            String value = name.toString();
+            value = replace(value, oldArtifact, newArtifact);
+            name = new AbstractName(URI.create(value));
+        }
+        this.name = name;
+        this.load = original.load;
+        this.attributes.putAll(original.attributes);
+        this.references.putAll(original.references);
+        this.clearAttributes.addAll(original.clearAttributes);
+        this.nullAttributes.addAll(original.nullAttributes);
+        this.clearReferences.addAll(original.clearReferences);
+        this.gbeanInfo = original.gbeanInfo;
+    }
+
+    private static String replace(String original, String oldArtifact, String newArtifact)
{
+        int pos = original.indexOf(oldArtifact);
+        if(pos == -1) {
+            return original;
+        }
+        int last = -1;
+        StringBuffer buf = new StringBuffer();
+        while(pos > -1) {
+            buf.append(original.substring(last+1, pos));
+            buf.append(newArtifact);
+            last = pos+oldArtifact.length()-1;
+            pos = original.indexOf(oldArtifact, last);
+        }
+        buf.append(original.substring(last+1));
+        return buf.toString();
+    }
+
     public GBeanOverride(GBeanData gbeanData) throws InvalidAttributeException {
         GBeanInfo gbeanInfo = gbeanData.getGBeanInfo();
         this.gbeanInfo = gbeanInfo.getSourceClass();

Modified: geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java?view=diff&rev=497782&r1=497781&r2=497782
==============================================================================
--- geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java
(original)
+++ geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java
Fri Jan 19 04:03:01 2007
@@ -27,6 +27,7 @@
 import java.util.List;
 import java.util.SortedSet;
 import java.util.Set;
+import java.util.Collections;
 import java.util.jar.JarFile;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipOutputStream;
@@ -201,12 +202,16 @@
                 location = new File(location, moduleName);
             }
 
-            if (location.isDirectory()) {
-                Set matches = IOUtil.search(location, path);
-                return matches;
+            if(path == null) {
+                return Collections.singleton(location.toURL());
             } else {
-                Set matches = IOUtil.search(location, path);
-                return matches;
+                if (location.isDirectory()) {
+                    Set matches = IOUtil.search(location, path);
+                    return matches;
+                } else {
+                    Set matches = IOUtil.search(location, path);
+                    return matches;
+                }
             }
         } else {
             Set matches = IOUtil.search(location, moduleName + "/" +path);

Modified: geronimo/server/trunk/modules/geronimo-system/src/test/java/org/apache/geronimo/system/configuration/LocalAttributeManagerTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-system/src/test/java/org/apache/geronimo/system/configuration/LocalAttributeManagerTest.java?view=diff&rev=497782&r1=497781&r2=497782
==============================================================================
--- geronimo/server/trunk/modules/geronimo-system/src/test/java/org/apache/geronimo/system/configuration/LocalAttributeManagerTest.java
(original)
+++ geronimo/server/trunk/modules/geronimo-system/src/test/java/org/apache/geronimo/system/configuration/LocalAttributeManagerTest.java
Fri Jan 19 04:03:01 2007
@@ -191,11 +191,36 @@
         }
     }
 
+    public void testMigrate() throws Exception {
+        String attributeValue = "attribute value";
+        AbstractNameQuery referencePattern = new AbstractNameQuery(LocalAttributeManagerTest.class.getName());
+
+        localAttributeManager.addConfiguration(configurationName);
+        localAttributeManager.setValue(configurationName, gbeanName, attributeInfo, attributeValue);
+
+        Collection gbeanDatas = new ArrayList();
+        GBeanData gbeanData = new GBeanData(gbeanName, GBEAN_INFO);
+        gbeanDatas.add(gbeanData);
+        gbeanDatas = localAttributeManager.applyOverrides(configurationName, gbeanDatas,
getClass().getClassLoader());
+        assertEquals(attributeValue, gbeanData.getAttribute(attributeInfo.getName()));
+
+        Artifact newArtifact = Artifact.create("configuration/name/2/car");
+        localAttributeManager.migrateConfiguration(configurationName, newArtifact, null);
+        ObjectName objectName = ObjectName.getInstance(":name=gbean,parent="+newArtifact+",foo=bar");
+        AbstractName newGBeanName = new AbstractName(newArtifact, objectName.getKeyPropertyList(),
objectName);
+
+        gbeanDatas = new ArrayList();
+        gbeanData = new GBeanData(newGBeanName, GBEAN_INFO);
+        gbeanDatas.add(gbeanData);
+        gbeanDatas = localAttributeManager.applyOverrides(newArtifact, gbeanDatas, getClass().getClassLoader());
+        assertEquals(attributeValue, gbeanData.getAttribute(attributeInfo.getName()));
+    }
+
     protected void setUp() throws Exception {
         super.setUp();
         localAttributeManager = new LocalAttributeManager("target/test-config.xml", false,
new BasicServerInfo(basedir));
         configurationName = Artifact.create("configuration/name/1/car");
-        ObjectName objectName = ObjectName.getInstance(":name=gbean");
+        ObjectName objectName = ObjectName.getInstance(":name=gbean,parent="+configurationName+",foo=bar");
         gbeanName = new AbstractName(configurationName, objectName.getKeyPropertyList(),
objectName);
         attributeInfo = GBEAN_INFO.getAttribute("attribute");
         referenceInfo = GBEAN_INFO.getReference("reference");



Mime
View raw message