[jboss-cvs] jboss-seam/src/main/org/jboss/seam/init ...

Gavin King gavin.king at jboss.com
Sun Nov 19 15:12:29 EST 2006


  User: gavin   
  Date: 06/11/19 15:12:29

  Modified:    src/main/org/jboss/seam/init  Initialization.java
  Log:
  support attributes
  
  Revision  Changes    Path
  1.123     +30 -7     jboss-seam/src/main/org/jboss/seam/init/Initialization.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Initialization.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/init/Initialization.java,v
  retrieving revision 1.122
  retrieving revision 1.123
  diff -u -b -r1.122 -r1.123
  --- Initialization.java	19 Nov 2006 19:44:27 -0000	1.122
  +++ Initialization.java	19 Nov 2006 20:12:29 -0000	1.123
  @@ -22,6 +22,7 @@
   
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  +import org.dom4j.Attribute;
   import org.dom4j.Document;
   import org.dom4j.DocumentException;
   import org.dom4j.Element;
  @@ -56,7 +57,7 @@
   /**
    * @author Gavin King
    * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
  - * @version $Revision: 1.122 $
  + * @version $Revision: 1.123 $
    */
   public class Initialization
   {
  @@ -311,6 +312,26 @@
            String qualifiedPropName = name + '.' + toCamelCase(propName);
            properties.put(qualifiedPropName, getPropertyValue(prop, qualifiedPropName, replacements));
         }
  +      
  +      for (Attribute prop: (List<Attribute>) component.attributes())
  +      {
  +         String attributeName = prop.getName();
  +         boolean isProperty = !"name".equals(attributeName) && 
  +               !"installed".equals(attributeName) && 
  +               !"scope".equals(attributeName) &&
  +               !"jndi-name".equals(attributeName) &&
  +               !"auto-create".equals(attributeName);
  +         if (isProperty)
  +         {
  +            String qualifiedPropName = name + '.' + toCamelCase( prop.getQName().getName() );
  +            properties.put(qualifiedPropName, getPropertyValue(prop, replacements));
  +         }
  +      }
  +   }
  +
  +   private Conversions.PropertyValue getPropertyValue(Attribute prop, Properties replacements)
  +   {
  +      return new Conversions.FlatPropertyValue( trimmedText(prop, replacements) );
      }
   
      private Conversions.PropertyValue getPropertyValue(Element prop, String propName,
  @@ -319,10 +340,9 @@
         List<Element> keyElements = prop.elements("key");
         List<Element> valueElements = prop.elements("value");
   
  -      Conversions.PropertyValue propertyValue;
         if (valueElements.isEmpty() && keyElements.isEmpty())
         {
  -         propertyValue = new Conversions.FlatPropertyValue(
  +         return new Conversions.FlatPropertyValue(
                     trimmedText(prop, propName, replacements));
         }
         else if (keyElements.isEmpty())
  @@ -334,7 +354,7 @@
            {
               values[i] = trimmedText(valueElements.get(i), propName, replacements);
            }
  -         propertyValue = new Conversions.MultiPropertyValue(values);
  +         return new Conversions.MultiPropertyValue(values);
         }
         else
         {
  @@ -351,10 +371,8 @@
               String value = trimmedText(valueElements.get(i), propName, replacements);
               keyedValues.put(key, value);
            }
  -         propertyValue = new Conversions.AssociativePropertyValue(keyedValues);
  +         return new Conversions.AssociativePropertyValue(keyedValues);
         }
  -      return propertyValue;
  -
      }
   
      private String trimmedText(Element element, String propName, Properties replacements)
  @@ -368,6 +386,11 @@
         return replace(text, replacements);
      }
   
  +   private String trimmedText(Attribute attribute, Properties replacements)
  +   {
  +      return replace( attribute.getText(), replacements );
  +   }
  +
      public Initialization setProperty(String name, Conversions.PropertyValue value)
      {
         properties.put(name, value);
  
  
  



More information about the jboss-cvs-commits mailing list