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

Gavin King gavin.king at jboss.com
Tue Jul 25 21:29:21 EDT 2006


  User: gavin   
  Date: 06/07/25 21:29:21

  Modified:    src/main/org/jboss/seam  Component.java
  Log:
  don't unwrap startup components
  
  Revision  Changes    Path
  1.153     +34 -32    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.152
  retrieving revision 1.153
  diff -u -b -r1.152 -r1.153
  --- Component.java	25 Jul 2006 20:15:17 -0000	1.152
  +++ Component.java	26 Jul 2006 01:29:21 -0000	1.153
  @@ -88,7 +88,7 @@
    *
    * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
    * @author Gavin King
  - * @version $Revision: 1.152 $
  + * @version $Revision: 1.153 $
    */
   @Scope(ScopeType.APPLICATION)
   public class Component
  @@ -742,19 +742,6 @@
         return inFields;
      }
   
  -   public Object newInstance()
  -   {
  -      if ( log.isDebugEnabled() ) log.debug("instantiating Seam component: " + name);
  -      try
  -      {
  -         return instantiate();
  -      }
  -      catch (Exception e)
  -      {
  -         throw new InstantiationException("Could not instantiate Seam component: " + name, e);
  -      }
  -   }
  -
       public boolean needsInjection() {
           return !getInFields().isEmpty() ||
               !getInMethods().isEmpty() ||
  @@ -1313,27 +1300,39 @@
      }
   
      private static Object getInstance(String name, boolean create, Object result) {
  -      if (result == null && create)
  +      Component component = Component.forName(name);
  +
  +      if (result==null && create)
         {
           result = getInstanceFromFactory(name);
           if (result==null)
           {
  -             result = newInstance(name);
  +           if (component==null)
  +           {
  +              //needed when this method is called by JSF
  +              if ( log.isDebugEnabled() ) log.debug("seam component not found: " + name);
  +           }
  +           else
  +           {
  +              result = component.newInstance();
  +           }
           }
         }
  +      
         if (result!=null)
         {
  -         Component component = Component.forName(name);
            if (component!=null)
            {
               if ( !component.isInstance(result) )
               {
  -               throw new IllegalArgumentException( "value found for In attribute has the wrong type: " + name );
  +               throw new IllegalArgumentException( "value of context variable is not an instance of the component bound to the context variable: " + name );
               }
               result = component.unwrap(result);
            }
         }
  +      
         return result;
  +      
      }
   
      public static Object getInstanceFromFactory(String name)
  @@ -1394,25 +1393,28 @@
         }
      }
   
  -   public static Object newInstance(String name)
  +   public Object newInstance()
      {
  -      Component component = Component.forName(name);
  -      if (component == null)
  +      if ( log.isDebugEnabled() ) log.debug("instantiating Seam component: " + name);
  +
  +      Object instance;
  +      try
         {
  -         if ( log.isDebugEnabled() ) log.debug("seam component not found: " + name);
  -         return null; //needed when this method is called by JSF
  +         instance = instantiate();
         }
  -      else
  +      catch (Exception e)
         {
  -         Object instance = component.newInstance();
  -         if (component.getScope()!=ScopeType.STATELESS)
  +         throw new InstantiationException("Could not instantiate Seam component: " + name, e);
  +      }
  +      
  +      if ( getScope()!=ScopeType.STATELESS )
            {
  -            component.getScope().getContext().set(name, instance); //put it in the context _before_ calling the create method
  -            component.callCreateMethod(instance);
  +         getScope().getContext().set(name, instance); //put it in the context _before_ calling the create method
  +         callCreateMethod(instance);
            }
  +      
            return instance;
         }
  -   }
   
      public void callCreateMethod(Object instance)
      {
  
  
  



More information about the jboss-cvs-commits mailing list