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

Michael Youngstrom youngm at gmail.com
Tue Mar 20 12:11:36 EDT 2007


  User: myoungstrom
  Date: 07/03/20 12:11:36

  Modified:    src/ioc/org/jboss/seam/ioc/spring    spring-seam-1.2.xsd
                        SeamNamespaceHandler.java SeamTargetSource.java
  Log:
  Committ for JBSEAM-1077
  
  Revision  Changes    Path
  1.3       +18 -11    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.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- spring-seam-1.2.xsd	19 Mar 2007 21:28:30 -0000	1.2
  +++ spring-seam-1.2.xsd	20 Mar 2007 16:11:36 -0000	1.3
  @@ -126,7 +126,7 @@
               </xsd:appinfo>
           </xsd:annotation>
           <xsd:complexType>
  -            <xsd:attribute name="seamName" type="xsd:string" use="optional">
  +            <xsd:attribute name="name" type="xsd:string" use="optional">
                   <xsd:annotation>
                       <xsd:documentation>
                           <![CDATA[
  @@ -136,27 +136,27 @@
                       </xsd:documentation>
                   </xsd:annotation>
               </xsd:attribute>
  -            <xsd:attribute name="springName" type="xsd:string" use="optional">
  +            <xsd:attribute name="spring-name" type="xsd:string" use="optional">
                   <xsd:annotation>
                       <xsd:documentation>
                           <![CDATA[
  -                                 What spring bean name should seam use to obtain an instance of this bean.  Only necessary when spring-seam cannot
  +                                 What spring bean name should seam use to obtain an instance of this bean.  Only necessary when seam-spring cannot
                                    property detect the name of the spring bean which some spring NamespaceHandlers can do (eg. <aop:scoped-proxy/>, etc.).
                           ]]>
                       </xsd:documentation>
                   </xsd:annotation>
               </xsd:attribute>
  -            <xsd:attribute name="beanClass" type="xsd:string" use="optional">
  +            <xsd:attribute name="class" type="xsd:string" use="optional">
                   <xsd:annotation>
                       <xsd:documentation>
                           <![CDATA[
  -                                 The component beanClass seam will use to get annotations from and to wrap it's interceptors around.  Optional unless the
  -                                 correct class is not being detected seam-spring.
  +                                 The component class seam will use to get annotations from and to wrap it's interceptors around.  Optional unless the
  +                                 correct class is not being detected by seam-spring.
                           ]]>
                       </xsd:documentation>
                   </xsd:annotation>
               </xsd:attribute>
  -            <xsd:attribute name="intercept" use="optional" default="AUTO">
  +            <xsd:attribute name="intercept-type" use="optional">
                   <xsd:annotation>
                       <xsd:documentation>
                           <![CDATA[
  @@ -168,7 +168,6 @@
                   </xsd:annotation>
                   <xsd:simpleType>
                       <xsd:restriction base="xsd:string">
  -                        <xsd:enumeration value="AUTO" />
                           <xsd:enumeration value="NEVER" />
                           <xsd:enumeration value="AFTER_RESTORE_VIEW" />
                           <xsd:enumeration value="AFTER_UPDATE_MODEL_VALUES" />
  @@ -177,18 +176,26 @@
                       </xsd:restriction>
                   </xsd:simpleType>
               </xsd:attribute>
  -            <xsd:attribute name="scope" use="optional" default="STATELESS">
  +            <xsd:attribute name="auto-create" type="xsd:boolean" use="optional" default="true">
                   <xsd:annotation>
                       <xsd:documentation>
                           <![CDATA[
  -The optional scope this component should have.  STATELESS will allow spring to manage the scope.
  +							Should instances of this component be auto-created.  Defaults to true since the STATELESS
  +							scope is going to be used most of the time when using this namespace handler.
                           ]]>
                       </xsd:documentation>
                   </xsd:annotation>
  +            </xsd:attribute>
  +            <xsd:attribute name="scope" use="optional" default="STATELESS">
  +                <xsd:annotation>
  +                    <xsd:documentation>
  +                        <![CDATA[
  +The optional scope this component should have.  STATELESS will allow spring to manage the scope.                        ]]>
  +                    </xsd:documentation>
  +                </xsd:annotation>
                   <xsd:simpleType>
                       <xsd:restriction base="xsd:string">
                           <xsd:enumeration value="STATELESS" />
  -                        <xsd:enumeration value="METHOD" />
                           <xsd:enumeration value="EVENT" />
                           <xsd:enumeration value="PAGE" />
                           <xsd:enumeration value="CONVERSATION" />
  
  
  
  1.6       +171 -160  jboss-seam/src/ioc/org/jboss/seam/ioc/spring/SeamNamespaceHandler.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: SeamNamespaceHandler.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/ioc/org/jboss/seam/ioc/spring/SeamNamespaceHandler.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -b -r1.5 -r1.6
  --- SeamNamespaceHandler.java	21 Feb 2007 01:08:51 -0000	1.5
  +++ SeamNamespaceHandler.java	20 Mar 2007 16:11:36 -0000	1.6
  @@ -2,6 +2,7 @@
   
   import org.jboss.seam.InterceptionType;
   import org.jboss.seam.ScopeType;
  +import org.jboss.seam.core.Init;
   import org.springframework.beans.factory.BeanDefinitionStoreException;
   import org.springframework.beans.factory.BeanFactory;
   import org.springframework.beans.factory.config.BeanDefinition;
  @@ -22,11 +23,12 @@
    *
    * @author youngm
    */
  -public class SeamNamespaceHandler
  -    extends NamespaceHandlerSupport
  +public class SeamNamespaceHandler extends NamespaceHandlerSupport
   {
       public static final String SEAM_SCOPE_POST_PROCESSOR = "org.jboss.seam.ioc.spring.SeamScopePostProcessor";
  +
       public static final String SEAM_COMPONENT_POST_PROCESSOR = "org.jboss.seam.ioc.spring.SeamComponentPostProcessor";
  +
       public static final String SEAM_COMPONENT_POST_PROCESSOR_BEAN_NAME = "org.jboss.seam.ioc.spring.seamComponentPostProcessor";
   
       /**
  @@ -40,21 +42,20 @@
       }
   
       /**
  -     * Registers the SeamScopePostProcessor in this bean factory under
  -     * the name defined in SEAM_SCOPE_POST_PROCESSOR.
  -     * &lt;seam:configure-scope/&gt;
  +    * Registers the SeamScopePostProcessor in this bean factory under the name
  +    * defined in SEAM_SCOPE_POST_PROCESSOR. &lt;seam:configure-scope/&gt;
        *
        * @see SeamScopePostProcessor
        * @author youngm
        */
  -    private static class SeamConfigureScopeParser
  -        extends AbstractSimpleBeanDefinitionParser
  +   private static class SeamConfigureScopeParser extends AbstractSimpleBeanDefinitionParser
       {
           /**
            * @see org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser#getBeanClass(org.w3c.dom.Element)
            */
           @Override
  -        protected Class getBeanClass(Element element) {
  +      protected Class getBeanClass(Element element)
  +      {
               return SeamScopePostProcessor.class;
           }
   
  @@ -64,22 +65,21 @@
            *      org.springframework.beans.factory.xml.ParserContext)
            */
           @Override
  -        protected String resolveId(Element element, AbstractBeanDefinition definition, ParserContext parserContext)
  -            throws BeanDefinitionStoreException
  +      protected String resolveId(Element element, AbstractBeanDefinition definition,
  +               ParserContext parserContext) throws BeanDefinitionStoreException
           {
               return SEAM_SCOPE_POST_PROCESSOR;
           }
       }
   
       /**
  -     * Makes a SeamFactoryBean available for use in a spring ApplicationContext. &lt;seam:instance
  -     * name="someSeamComponent"/&gt;
  +    * Makes a SeamFactoryBean available for use in a spring ApplicationContext.
  +    * &lt;seam:instance name="someSeamComponent"/&gt;
        *
        * @see SeamFactoryBean
        * @author youngm
        */
  -    private static class SeamInstanceBeanDefinitionParser
  -        extends AbstractSimpleBeanDefinitionParser
  +   private static class SeamInstanceBeanDefinitionParser extends AbstractSimpleBeanDefinitionParser
       {
          @Override
          protected Class getBeanClass(Element element)
  @@ -89,13 +89,12 @@
       }
   
       /**
  -     * Makes an existing spring bean definition a seam component or
  -     * provides hints in the creation of a seam component.  Will use
  -     * the bean definitions name and class by default and the classes
  -     * annotatated InterceptionType.
  +    * Makes an existing spring bean definition a seam component or provides
  +    * hints in the creation of a seam component. Will use the bean definitions
  +    * name and class by default and the classes annotatated InterceptionType.
        *
  -     * If proxy=true will wrap the spring bean in a cglib proxy for
  -     * safe injection into singletons.
  +    * If proxy=true will wrap the spring bean in a cglib proxy for safe
  +    * injection into singletons.
        *
        * &lt;seam:component/&gt;
        *
  @@ -103,34 +102,45 @@
        */
       private static class SeamComponentBeanDefinitionDecorator implements BeanDefinitionDecorator
       {
  -        private static final String INTERCEPT_ATTR = "intercept";
  -        private static final String SPRING_NAME_ATTR = "springName";
  -        private static final String SEAM_NAME_ATTR = "seamName";
  -        private static final String BEAN_CLASS_ATTR = "beanClass";
  -        public  static final String AUTO_INTERCEPTION_TYPE = "AUTO";
  +      private static final String INTERCEPT_TYPE_ATTR = "intercept-type";
  +
  +      private static final String SPRING_NAME_ATTR = "spring-name";
  +
  +      private static final String SEAM_NAME_ATTR = "name";
  +
  +      private static final String BEAN_CLASS_ATTR = "class";
  +
  +      private static final String AUTO_CREATE_ATTR = "auto-create";
   
           /**
            * @see org.springframework.beans.factory.xml.BeanDefinitionDecorator#decorate(org.w3c.dom.Node,
            *      org.springframework.beans.factory.config.BeanDefinitionHolder,
            *      org.springframework.beans.factory.xml.ParserContext)
            */
  -        public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition, ParserContext parserContext)
  +      public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition,
  +               ParserContext parserContext)
           {
  -            // Add the Seam Component Post Processor to the bean factory if it doesn't already exist
  -            if (!parserContext.getRegistry().containsBeanDefinition(SEAM_COMPONENT_POST_PROCESSOR_BEAN_NAME))
  +         // Add the Seam Component Post Processor to the bean factory if it
  +         // doesn't already exist
  +         if (!parserContext.getRegistry().containsBeanDefinition(
  +                  SEAM_COMPONENT_POST_PROCESSOR_BEAN_NAME))
               {
                   Class cls;
                   try
                   {
                       cls = ClassUtils.forName(SEAM_COMPONENT_POST_PROCESSOR);
  -                } catch (ClassNotFoundException e) {
  -                    throw new IllegalStateException("Unable to load class '" + SEAM_COMPONENT_POST_PROCESSOR
  +            }
  +            catch (ClassNotFoundException e)
  +            {
  +               throw new IllegalStateException("Unable to load class '"
  +                        + SEAM_COMPONENT_POST_PROCESSOR
                                                       + "' make sure you have the jboss-seam-spring.jar in your classpath.");
                   }
                   RootBeanDefinition beanDefinition = new RootBeanDefinition(cls);
                   beanDefinition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
                   beanDefinition.getPropertyValues().addPropertyValue("order", Ordered.LOWEST_PRECEDENCE);
  -                parserContext.getRegistry().registerBeanDefinition(SEAM_COMPONENT_POST_PROCESSOR_BEAN_NAME, beanDefinition);
  +            parserContext.getRegistry().registerBeanDefinition(
  +                     SEAM_COMPONENT_POST_PROCESSOR_BEAN_NAME, beanDefinition);
               }
               // get the optional beanClass
               String beanClassName = definition.getBeanDefinition().getBeanClassName();
  @@ -153,23 +163,17 @@
               }
               // get the interception type to use
               InterceptionType interceptionType = null;
  -            if (AUTO_INTERCEPTION_TYPE.equals(node.getAttributes().getNamedItem(INTERCEPT_ATTR).getNodeValue()))
  -            {
  -                if (definition.getBeanDefinition().isSingleton())
  +         if (node.getAttributes().getNamedItem(INTERCEPT_TYPE_ATTR) != null)
                   {
  -                    interceptionType = InterceptionType.NEVER;
  +            interceptionType = InterceptionType.valueOf(node.getAttributes().getNamedItem(
  +                     INTERCEPT_TYPE_ATTR).getNodeValue());
                   }
  -            }
  -            else
  -            {
  -                interceptionType = InterceptionType.valueOf(node.getAttributes().getNamedItem(INTERCEPT_ATTR)
  -                                                            .getNodeValue());
  -            }
  -
               // get the requested scope
  -            ScopeType scope = ScopeType.valueOf(node.getAttributes().getNamedItem("scope").getNodeValue());
  +         ScopeType scope = ScopeType.valueOf(node.getAttributes().getNamedItem("scope")
  +                  .getNodeValue());
               if (scope != ScopeType.STATELESS
  -                && !BeanDefinition.SCOPE_PROTOTYPE.equals(definition.getBeanDefinition().getScope()))
  +                  && !BeanDefinition.SCOPE_PROTOTYPE.equals(definition.getBeanDefinition()
  +                           .getScope()))
               {
                   throw new IllegalStateException(
   						"The spring bean scope must be prototype to use a seam scope other than STATELESS.");
  @@ -179,8 +183,15 @@
               {
                   throw new RuntimeException("For some reason your registry is not a BeanFactory");
               }
  -            SpringComponent.addSpringComponent(seamName, springName, beanClassName, scope, (BeanFactory) parserContext
  -                                               .getRegistry(), interceptionType);
  +         SpringComponent.addSpringComponent(seamName, springName, beanClassName, scope,
  +                  (BeanFactory) parserContext.getRegistry(), interceptionType);
  +         if (node.getAttributes().getNamedItem(AUTO_CREATE_ATTR) != null)
  +         {
  +            if (Boolean.valueOf(node.getAttributes().getNamedItem(AUTO_CREATE_ATTR).getNodeValue()))
  +            {
  +               Init.instance().addAutocreateVariable(seamName);
  +            }
  +         }
               return definition;
           }
       }
  
  
  
  1.7       +15 -10    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.6
  retrieving revision 1.7
  diff -u -b -r1.6 -r1.7
  --- SeamTargetSource.java	19 Mar 2007 21:28:30 -0000	1.6
  +++ SeamTargetSource.java	20 Mar 2007 16:11:36 -0000	1.7
  @@ -28,12 +28,14 @@
   public class SeamTargetSource implements TargetSource, Serializable
   {
      private ScopeType scope;
  +
      private String name;
  +
      private Boolean create;
  -   private ValueBinding valueBinding;
  -   private Class type;
      
  +   private ValueBinding valueBinding;
      
  +   private Class type;
   
      public SeamTargetSource(String name, ScopeType scope, Boolean create, Class type)
      {
  @@ -99,17 +101,20 @@
      }
   
      /**
  -    * Obtains the seam component beanClass or the defined type for this TargetSource.
  +    * Obtains the seam component beanClass or the defined type for this
  +    * TargetSource.
       *
       * @see org.springframework.aop.TargetSource#getTargetClass()
       */
      public Class getTargetClass()
      {
  -      if(type != null) {
  +      if (type != null)
  +      {
            return type;
         }
         Component component = getComponent();
  -      if(component == null) {
  +      if (component == null)
  +      {
            return null;
         }
         if (component.hasUnwrapMethod())
  
  
  



More information about the jboss-cvs-commits mailing list