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

Gavin King gavin.king at jboss.com
Wed Feb 21 17:32:47 EST 2007


  User: gavin   
  Date: 07/02/21 17:32:47

  Modified:    src/main/org/jboss/seam/init  Initialization.java
  Log:
  JBSEAM-897
  
  Revision  Changes    Path
  1.152     +24 -5     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.151
  retrieving revision 1.152
  diff -u -b -r1.151 -r1.152
  --- Initialization.java	17 Feb 2007 04:08:02 -0000	1.151
  +++ Initialization.java	21 Feb 2007 22:32:47 -0000	1.152
  @@ -57,7 +57,7 @@
   /**
    * @author Gavin King
    * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
  - * @version $Revision: 1.151 $
  + * @version $Revision: 1.152 $
    */
   public class Initialization
   {
  @@ -184,22 +184,41 @@
            {
               String name = elem.attributeValue("name");
               String elemName = toCamelCase( elem.getName(), true );
  +            
               String className = nsInfo.getPackage().getName() + '.' + elemName;
               try
               {
  +               //get the class implied by the namespaced XML element name
                  Class<Object> clazz = Reflections.classForName(className);
  -               if (name == null)
  -               {
                     Name nameAnnotation = clazz.getAnnotation(Name.class);
  -                  if (nameAnnotation!=null) name = nameAnnotation.value();
  +               
  +               //if the name attribute is not explicitly specified in the XML,
  +               //imply the name from the @Name annotation on the class implied
  +               //by the XML element name
  +               if (name == null && nameAnnotation!=null) 
  +               {
  +                  name = nameAnnotation.value();
  +               }
  +               
  +               //if this class already has the @Name annotation, the XML element 
  +               //is just adding configuration to the existing component, don't
  +               //add another ComponentDescriptor (this is super-important to
  +               //allow overriding!)
  +               if ( nameAnnotation!=null && nameAnnotation.value().equals(name) )
  +               {
  +                  className = null;
                  }
               }
               catch (ClassNotFoundException cnfe)
               {
  -               // if it isn't a classname, set
  +               //there is no class implied by the XML element name so the
  +               //component must be defined some other way, assume that we are
  +               //just adding configuration, don't add a ComponentDescriptor 
                  className = null;
               }
   
  +            //finally, if we could not get the name from the XML name attribute,
  +            //or from an @Name annotation on the class, imply it
               if (name == null)
               {
                  String prefix = nsInfo.getNamespace().prefix();
  
  
  



More information about the jboss-cvs-commits mailing list