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

Gavin King gavin.king at jboss.com
Tue Jul 25 16:15:17 EDT 2006


  User: gavin   
  Date: 06/07/25 16:15:17

  Modified:    src/main/org/jboss/seam  Component.java
  Log:
  cleanup all those static methods
  
  Revision  Changes    Path
  1.152     +26 -15    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.151
  retrieving revision 1.152
  diff -u -b -r1.151 -r1.152
  --- Component.java	25 Jul 2006 19:51:43 -0000	1.151
  +++ Component.java	25 Jul 2006 20:15:17 -0000	1.152
  @@ -88,7 +88,7 @@
    *
    * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
    * @author Gavin King
  - * @version $Revision: 1.151 $
  + * @version $Revision: 1.152 $
    */
   @Scope(ScopeType.APPLICATION)
   public class Component
  @@ -1330,8 +1330,8 @@
               {
                  throw new IllegalArgumentException( "value found for In attribute has the wrong type: " + name );
               }
  +            result = component.unwrap(result);
            }
  -         result = unwrap( component, result );
         }
         return result;
      }
  @@ -1355,7 +1355,7 @@
            else if (factoryMethod!=null)
            {
               Object factory = Component.getInstance( factoryMethod.component.getName(), true );
  -            Object result = callComponentMethod(factoryMethod.component, factory, factoryMethod.method);
  +            Object result = factoryMethod.component.callComponentMethod(factory, factoryMethod.method);
               return handleFactoryMethodResult(name, factoryMethod.component, result, factoryMethod.scope);
            }
            else
  @@ -1408,21 +1408,29 @@
            if (component.getScope()!=ScopeType.STATELESS)
            {
               component.getScope().getContext().set(name, instance); //put it in the context _before_ calling the create method
  -            callCreateMethod(component, instance);
  +            component.callCreateMethod(instance);
            }
            return instance;
         }
      }
   
  -   private static void callCreateMethod(Component component, Object instance)
  +   public void callCreateMethod(Object instance)
      {
  -      if (component.hasCreateMethod())
  +      if ( hasCreateMethod() )
         {
  -         callComponentMethod( component, instance, component.getCreateMethod() );
  +         callComponentMethod( instance, getCreateMethod() );
         }
      }
   
  -   public static Object callComponentMethod(Component component, Object instance, Method method) {
  +   public void callDestroyMethod(Object instance)
  +   {
  +      if ( hasDestroyMethod() )
  +      {
  +         callComponentMethod( instance, getDestroyMethod() );
  +      }
  +   }
  +
  +   public Object callComponentMethod(Object instance, Method method) {
         Class[] paramTypes = method.getParameterTypes();
         String createMethodName = method.getName();
         try
  @@ -1433,13 +1441,13 @@
               return Reflections.invokeAndWrap( interfaceMethod, instance );
            }
            else {
  -            return Reflections.invokeAndWrap( interfaceMethod, instance, component );
  +            return Reflections.invokeAndWrap( interfaceMethod, instance, this );
            }
         }
         catch (NoSuchMethodException e)
         {
  -         String message = "method not found: " + method.getName() + " for component: " + component.getName();
  -         if ( component.getType()==ComponentType.STATELESS_SESSION_BEAN || component.getType()==ComponentType.STATEFUL_SESSION_BEAN )
  +         String message = "method not found: " + method.getName() + " for component: " + name;
  +         if ( getType()==ComponentType.STATELESS_SESSION_BEAN || getType()==ComponentType.STATEFUL_SESSION_BEAN )
            {
                message += " (check that it is declared on the session bean business interface)";
            }
  @@ -1447,14 +1455,17 @@
         }
      }
   
  -   private static Object unwrap(Component component, Object instance)
  +   private Object unwrap(Object instance)
      {
  -      if (component!=null && component.hasUnwrapMethod())
  +      if ( hasUnwrapMethod() )
         {
  -         instance = callComponentMethod(component, instance, component.getUnwrapMethod() );
  +         return callComponentMethod( instance, getUnwrapMethod() );
         }
  +      else
  +      {
         return instance;
      }
  +   }
   
      private Object getInstanceToInject(In in, String name, Object bean)
      {
  
  
  



More information about the jboss-cvs-commits mailing list