geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgenen...@apache.org
Subject svn commit: r380696 - in /geronimo/trunk/modules: kernel/src/java/org/apache/geronimo/gbean/ system/src/java/org/apache/geronimo/system/configuration/ system/src/schema/
Date Fri, 24 Feb 2006 15:59:12 GMT
Author: jgenender
Date: Fri Feb 24 07:59:09 2006
New Revision: 380696

URL: http://svn.apache.org/viewcvs?rev=380696&view=rev
Log:
Added empty attribute to the config.xml attribute and reference tags.  Updated to spit out
the proper writeXml() too.

Modified:
    geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanData.java
    geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/GBeanOverride.java
    geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java
    geronimo/trunk/modules/system/src/schema/local-attribute.xsd

Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanData.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanData.java?rev=380696&r1=380695&r2=380696&view=diff
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanData.java (original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanData.java Fri Feb
24 07:59:09 2006
@@ -94,6 +94,13 @@
     public void setAttribute(String name, Object value) {
         attributes.put(name, value);
     }
+    
+    public void clearAttribute(String name){
+        attributes.remove(name);
+    }
+    public void clearReference(String name){
+        references.remove(name);
+    }
 
     public Map getReferences() {
         return new HashMap(references);

Modified: geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/GBeanOverride.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/GBeanOverride.java?rev=380696&r1=380695&r2=380696&view=diff
==============================================================================
--- geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/GBeanOverride.java
(original)
+++ geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/GBeanOverride.java
Fri Feb 24 07:59:09 2006
@@ -29,6 +29,7 @@
 import javax.management.ObjectName;
 import java.beans.PropertyEditor;
 import java.io.PrintWriter;
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
@@ -43,7 +44,9 @@
     private final Object name;
     private boolean load;
     private final Map attributes = new LinkedHashMap();
+    private final ArrayList clearAttributes = new ArrayList();
     private final Map references = new LinkedHashMap();
+    private final ArrayList clearReferences = new ArrayList();
     private final String gbeanInfo;
 
     public GBeanOverride(String name, boolean load) {
@@ -110,6 +113,12 @@
             Element attribute = (Element) attributes.item(a);
 
             String attributeName = attribute.getAttribute("name");
+            String emptyStr = attribute.getAttribute("empty");
+            boolean empty = "true".equals(emptyStr);
+            if (empty){
+                clearAttributes.add(attributeName);
+                return;
+            }
             String attributeValue = (String)EncryptionManager.decrypt(getContentsAsText(attribute));
             setAttribute(attributeName, attributeValue);
         }
@@ -120,6 +129,12 @@
             Element reference = (Element) references.item(r);
 
             String referenceName = reference.getAttribute("name");
+            String emptyStr = reference.getAttribute("empty");
+            boolean empty = "true".equals(emptyStr);
+            if (empty){
+                clearReferences.add(referenceName);
+                return;
+            }
 
             Set objectNamePatterns = new LinkedHashSet();
             NodeList patterns = reference.getElementsByTagName("pattern");
@@ -175,6 +190,23 @@
     public String getAttribute(String attributeName) {
         return (String) attributes.get(attributeName);
     }
+    
+    public ArrayList getClearAttributes(){
+        return clearAttributes;
+    }
+    
+    public boolean getClearAttribute(String attributeName){
+        return clearAttributes.contains(attributeName);
+    }
+    
+    public ArrayList getClearRefrences(){
+        return clearReferences;
+    }
+    
+    public boolean getClearReference(String referenceName){
+        return clearReferences.contains(referenceName);
+    }
+
 
     public void setAttribute(String attributeName, Object attributeValue, String attributeType)
throws InvalidAttributeException {
         String stringValue = getAsText(attributeValue, attributeType);
@@ -228,6 +260,12 @@
             }
             out.println("      <attribute name=\"" + name + "\">" +  value + "</attribute>");
         }
+        
+        // cleared attributes
+        for (Iterator iterator = clearAttributes.iterator(); iterator.hasNext();) {
+            String name = (String) iterator.next();
+            out.println("      <attribute name=\"" + name + "\" empty=\"true\" />");
+        }
 
         // references
         for (Iterator iterator = references.entrySet().iterator(); iterator.hasNext();) {
@@ -243,6 +281,11 @@
                 out.println("</gbean-name></pattern>");
             }
             out.println("      </reference>");
+        }
+        // cleared references
+        for (Iterator iterator = clearReferences.iterator(); iterator.hasNext();) {
+            String name = (String) iterator.next();
+            out.println("      <reference name=\"" + name + "\" empty=\"true\" />");
         }
 
         out.println("    </gbean>");

Modified: geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java?rev=380696&r1=380695&r2=380696&view=diff
==============================================================================
--- geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java
(original)
+++ geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java
Fri Feb 24 07:59:09 2006
@@ -181,6 +181,14 @@
             Object value = getValue(attributeInfo, valueString, configName, gbeanName, classLoader);
             data.setAttribute(attributeName, value);
         }
+        
+        //Clear attributes
+        for (Iterator iterator = gbean.getClearAttributes().iterator(); iterator.hasNext();){
+           String attribute = (String) iterator.next(); 
+           if (gbean.getClearAttribute(attribute)){
+               data.clearAttribute(attribute);
+           }
+        }
 
         // set references
         for (Iterator iterator = gbean.getReferences().entrySet().iterator(); iterator.hasNext();)
{
@@ -196,6 +204,15 @@
 
             data.setReferencePatterns(referenceName, referencePatterns);
         }
+        
+        //Clear references
+        for (Iterator iterator = gbean.getClearRefrences().iterator(); iterator.hasNext();){
+           String reference = (String) iterator.next(); 
+           if (gbean.getClearReference(reference)){
+               data.clearReference(reference);
+           }
+        }
+
         return true;
     }
 

Modified: geronimo/trunk/modules/system/src/schema/local-attribute.xsd
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/system/src/schema/local-attribute.xsd?rev=380696&r1=380695&r2=380696&view=diff
==============================================================================
--- geronimo/trunk/modules/system/src/schema/local-attribute.xsd (original)
+++ geronimo/trunk/modules/system/src/schema/local-attribute.xsd Fri Feb 24 07:59:09 2006
@@ -88,6 +88,7 @@
         <xsd:simpleContent>
             <xsd:extension base="xsd:string">
                 <xsd:attribute name="name" use="required"/>
+                <xsd:attribute name="empty" use="optional" type="xsd:boolean" default="false"/>
             </xsd:extension>
         </xsd:simpleContent>
     </xsd:complexType>
@@ -103,5 +104,6 @@
             </xsd:element>
         </xsd:sequence>
         <xsd:attribute name="name" type="xsd:string"/>
+        <xsd:attribute name="empty" use="optional" type="xsd:boolean" default="false"/>
     </xsd:complexType>
   </xsd:schema>



Mime
View raw message