[jboss-cvs] jboss-seam/src/ioc/org/jboss/seam/ioc/spring ...

Michael Youngstrom youngm at gmail.com
Mon Mar 19 17:28:31 EDT 2007


  User: myoungstrom
  Date: 07/03/19 17:28:30

  Modified:    src/ioc/org/jboss/seam/ioc/spring     SeamFactoryBean.java
                        ContextLoader.java spring-seam-1.2.xsd
                        SeamTargetSource.java
  Log:
  Fix for JBSEAM-1046 and a problem with ContextLoader's default location.
  
  Revision  Changes    Path
  1.6       +37 -14    jboss-seam/src/ioc/org/jboss/seam/ioc/spring/SeamFactoryBean.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: SeamFactoryBean.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/ioc/org/jboss/seam/ioc/spring/SeamFactoryBean.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -b -r1.5 -r1.6
  --- SeamFactoryBean.java	19 Feb 2007 23:36:15 -0000	1.5
  +++ SeamFactoryBean.java	19 Mar 2007 21:28:29 -0000	1.6
  @@ -19,10 +19,17 @@
   public class SeamFactoryBean extends AbstractFactoryBean implements InitializingBean
   {
      private ScopeType scope;
  +
      private String name;
  +
      private Boolean create;
  +
      private SeamTargetSource targetSource;
  +
      private Object proxyInstance;
  +
  +   private Class type;
  +
      private boolean proxy = false;
   
      /**
  @@ -40,12 +47,14 @@
         // If we're creating a proxy then we want this to be a singleton
         setSingleton(proxy);
   
  -      this.targetSource = new SeamTargetSource(name, scope, create);
  +      this.targetSource = new SeamTargetSource(name, scope, create, type);
   
         if (proxy)
         {
  -         if(targetSource.getTargetClass() == null) {
  -            throw new IllegalStateException("Cannot use 'proxy' for an expression.");
  +         Class targetClass = targetSource.getTargetClass();
  +         if (targetClass == null)
  +         {
  +            throw new IllegalStateException("Cannot use 'proxy' for an expression without specifying a type.");
            }
            // Not sure if I should allow people to change these proxy
            // parameters or not. We'll see what issues we get hard coding them.
  @@ -58,9 +67,12 @@
            pf.setTargetSource(this.targetSource);
   
            List<Class> interfaces = targetSource.getSeamInterfaces();
  +         //For some reason the targetClass cannot be an interface
  +         if(targetClass.isInterface()) {
  +            interfaces.add(targetClass);
  +         }
            pf.setInterfaces(interfaces.toArray(new Class[interfaces.size()]));
   
  -
            this.proxyInstance = pf.getProxy(Thread.currentThread().getContextClassLoader());
   
         }
  @@ -148,4 +160,15 @@
      {
         this.proxy = proxy;
      }
  +
  +   /**
  +    * Forces type of a proxy created. Useful when using EL where the type of the
  +    * object may not be available at Proxy creation time.
  +    * 
  +    * @param type
  +    */
  +   public void setType(Class type)
  +   {
  +      this.type = type;
  +   }
   }
  
  
  
  1.3       +1 -1      jboss-seam/src/ioc/org/jboss/seam/ioc/spring/ContextLoader.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ContextLoader.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/ioc/org/jboss/seam/ioc/spring/ContextLoader.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- ContextLoader.java	12 Mar 2007 20:37:05 -0000	1.2
  +++ ContextLoader.java	19 Mar 2007 21:28:30 -0000	1.3
  @@ -31,7 +31,7 @@
   public class ContextLoader
   {
      private WebApplicationContext webApplicationContext;
  -   private String[] configLocations;
  +   private String[] configLocations = {XmlWebApplicationContext.DEFAULT_CONFIG_LOCATION};
      
      @Create 
      public void create() throws Exception
  
  
  
  1.2       +11 -0     jboss-seam/src/ioc/org/jboss/seam/ioc/spring/spring-seam-1.2.xsd
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: spring-seam-1.2.xsd
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/ioc/org/jboss/seam/ioc/spring/spring-seam-1.2.xsd,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- spring-seam-1.2.xsd	12 Mar 2007 20:37:05 -0000	1.1
  +++ spring-seam-1.2.xsd	19 Mar 2007 21:28:30 -0000	1.2
  @@ -79,6 +79,17 @@
                       </xsd:restriction>
                   </xsd:simpleType>
               </xsd:attribute>
  +            <xsd:attribute name="type" type="xsd:string" use="optional">
  +                <xsd:annotation>
  +                    <xsd:documentation>
  +                        <![CDATA[
  +                                 The class type to use when creating a proxy of this instance.  Useful when using
  +                                 EL for the name because the type of the EL expression may not be available when the
  +                                 proxy is created.
  +                        ]]>
  +                    </xsd:documentation>
  +                </xsd:annotation>
  +            </xsd:attribute>
               <xsd:attribute name="create" type="xsd:boolean" use="optional">
                   <xsd:annotation>
                       <xsd:documentation>
  
  
  
  1.6       +13 -23    jboss-seam/src/ioc/org/jboss/seam/ioc/spring/SeamTargetSource.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: SeamTargetSource.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/ioc/org/jboss/seam/ioc/spring/SeamTargetSource.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -b -r1.5 -r1.6
  --- SeamTargetSource.java	19 Feb 2007 19:53:06 -0000	1.5
  +++ SeamTargetSource.java	19 Mar 2007 21:28:30 -0000	1.6
  @@ -31,6 +31,15 @@
      private String name;
      private Boolean create;
      private ValueBinding valueBinding;
  +   private Class type;
  +   
  +   
  +
  +   public SeamTargetSource(String name, ScopeType scope, Boolean create, Class type)
  +   {
  +      this(name, scope, create);
  +      this.type = type;
  +   }
   
      /**
       * @param name
  @@ -90,25 +99,15 @@
      }
   
      /**
  -    * Obtains the seam component beanClass for this TargetSource.
  +    * Obtains the seam component beanClass or the defined type for this TargetSource.
       *
       * @see org.springframework.aop.TargetSource#getTargetClass()
       */
      public Class getTargetClass()
      {
  -      Class trueClass = getTrueTargetClass();
  -      if(trueClass == null) {
  -         return null;
  -      }
  -      if (trueClass.isInterface())
  -      {
  -         return Object.class;
  +      if(type != null) {
  +         return type;
         }
  -      return trueClass;
  -   }
  -
  -   public Class getTrueTargetClass()
  -   {
         Component component = getComponent();
         if(component == null) {
            return null;
  @@ -123,19 +122,10 @@
      public List<Class> getSeamInterfaces()
      {
         List<Class> interfaces = new ArrayList<Class>();
  -      Class trueClass = getTrueTargetClass();
  -      if(trueClass == null) {
  -         return null;
  -      }
  -      // if the true class is an interface then add it
  -      if (trueClass.isInterface())
  -      {
  -         interfaces.add(trueClass);
  -      }
         Component component = getComponent();
         // Attempt to piece together all of the possible interfaces to apply
         // to our proxy.
  -      if (component.getInterceptionType() != InterceptionType.NEVER)
  +      if (component != null && component.getInterceptionType() != InterceptionType.NEVER)
         {
            if (component.getType().isSessionBean())
            {
  
  
  



More information about the jboss-cvs-commits mailing list