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

Gavin King gavin.king at jboss.com
Wed Jul 18 10:37:29 EDT 2007


  User: gavin   
  Date: 07/07/18 10:37:29

  Modified:    src/main/org/jboss/seam     Component.java Namespace.java
                        components-2.0.dtd components-2.0.xsd
  Log:
  global imports JBSEAM-1693
  
  Revision  Changes    Path
  1.271     +12 -6     jboss-seam/src/main/org/jboss/seam/Component.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Component.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/Component.java,v
  retrieving revision 1.270
  retrieving revision 1.271
  diff -u -b -r1.270 -r1.271
  --- Component.java	17 Jul 2007 22:17:58 -0000	1.270
  +++ Component.java	18 Jul 2007 14:37:29 -0000	1.271
  @@ -339,16 +339,13 @@
            {
               Namespace namespace = init.getRootNamespace();
               StringTokenizer tokens = new StringTokenizer(componentName, ".");
  -            StringBuffer path = new StringBuffer();
               while ( tokens.hasMoreTokens() )
               {
                  String token = tokens.nextToken();
  -               path.append(token).append('.');
  -               if ( tokens.hasMoreTokens() && !namespace.hasChild(token) )
  +               if ( tokens.hasMoreTokens() ) //we don't want to create a namespace for the name
                  {
  -                  namespace.addChild( token, new Namespace(path.toString()) );
  +                  namespace.getOrCreateChild(token);
                  }
  -               namespace = namespace.getChild(token);
               }
            }
         }
  @@ -2023,7 +2020,16 @@
            {
               log.debug("trying to inject with hierarchical context search: " + name);
            }
  -         result = getInstance( name, in.create() && !org.jboss.seam.contexts.Lifecycle.isDestroying() );
  +         boolean create = in.create() && !org.jboss.seam.contexts.Lifecycle.isDestroying();
  +         result = getInstance(name, create);
  +         if (result==null)
  +         {
  +            for ( Namespace namespace: Init.instance().getGlobalImports() )
  +            {
  +               result = namespace.getComponentInstance(name, create);
  +               if (result!=null) break; 
  +            }
  +         }
         }
         else
         {
  
  
  
  1.4       +27 -2     jboss-seam/src/main/org/jboss/seam/Namespace.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Namespace.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/Namespace.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -b -r1.3 -r1.4
  --- Namespace.java	16 Jul 2007 12:57:59 -0000	1.3
  +++ Namespace.java	18 Jul 2007 14:37:29 -0000	1.4
  @@ -25,8 +25,7 @@
       */
      public Object get(String key)
      {
  -      String qualifiedName = name==null ? key.toString() : name + key.toString();
  -      Object component = Component.getInstance(qualifiedName, true);
  +      Object component = getComponentInstance(key);
         return component==null ? children.get(key) : component;
      }
      
  @@ -35,6 +34,32 @@
         return children.get(key);
      }
      
  +   public Namespace getOrCreateChild(String key)
  +   {
  +      Namespace result = getChild(key);
  +      if (result==null)
  +      {
  +         result = new Namespace( qualifyName(key) + '.' );
  +         addChild(key, result);
  +      }
  +      return result;
  +   }
  +   
  +   public Object getComponentInstance(String key)
  +   {
  +      return getComponentInstance(key, true);
  +   }
  +
  +   public Object getComponentInstance(String key, boolean create)
  +   {
  +      return Component.getInstance( qualifyName(key), create );
  +   }
  +
  +   private String qualifyName(String key)
  +   {
  +      return name==null ? key : name + key;
  +   }
  +   
      public boolean hasChild(String key)
      {
         return children.containsKey(key);
  
  
  
  1.3       +2 -0      jboss-seam/src/main/org/jboss/seam/components-2.0.dtd
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: components-2.0.dtd
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/components-2.0.dtd,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- components-2.0.dtd	16 Jul 2007 09:19:15 -0000	1.2
  +++ components-2.0.dtd	18 Jul 2007 14:37:29 -0000	1.3
  @@ -31,6 +31,8 @@
   <!ELEMENT key (#PCDATA)>
   <!ELEMENT value (#PCDATA)>
   
  +<!ELEMENT import (#PCDATA)>
  +
   <!-- event handling -->
   
   <!ELEMENT event (action*)>
  
  
  
  1.3       +3 -0      jboss-seam/src/main/org/jboss/seam/components-2.0.xsd
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: components-2.0.xsd
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/components-2.0.xsd,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- components-2.0.xsd	16 Jul 2007 09:19:15 -0000	1.2
  +++ components-2.0.xsd	18 Jul 2007 14:37:29 -0000	1.3
  @@ -8,6 +8,7 @@
                   <xs:element ref="components:component"/>
                   <xs:element ref="components:factory"/>
                   <xs:element ref="components:event"/>
  +                <xs:element ref="components:import"/>
                   <xs:any namespace="##other" processContents="strict"/>
               </xs:choice>
           </xs:complexType>
  @@ -22,6 +23,8 @@
           </xs:complexType>
       </xs:element>
   
  +    <xs:element name="import" type="xs:string"/>
  +
       <xs:attributeGroup name="attlist.ejbcomponent">
           <xs:attribute name="jndi-name"/>
       </xs:attributeGroup>
  
  
  



More information about the jboss-cvs-commits mailing list