[jbossseam-issues] [JBoss JIRA] Commented: (JBSEAM-696) Spring integration

youngm (JIRA) jira-events at jboss.com
Thu Feb 8 17:02:34 EST 2007


    [ http://jira.jboss.com/jira/browse/JBSEAM-696?page=comments#action_12352677 ] 
            
youngm commented on JBSEAM-696:
-------------------------------

I've done up an initial integration with spring 2.x that I believe provides 1,2,3, and 5 of the above requirements.  I've attached the source and a .jar for anyone who wants to try it out.

This integration takes advantage of the custom scope ability introduced in Spring 2.x  It will allow you to define a seam component in spring with a specific seam scope.  You can then inject properties in the spring style which act more like arguments for a seam component instance.

<bean id="someSeamComponent" class="example.SomeBean" scope="seam.conversation">
     <property name="seamComponent" ref="someOtherSeamComponent"/>
</bean>

<bean id="someOtherSeamComponent" class="example.SomeOtherBean" scope="seam.event">
     <property name="someProperty" ref="someSpringBean"/>
</bean>

A property injected through spring syntax (like above) acts following standard spring injection rules.  So, unlike Seam Component injection using @In those properties are not injected and then disjected for every method invocation bringing forth the usual Scope impedance mismatching situations.

However, using Seam's @In injection mechanism will follow standard seam Injection rules using the Bijection interceptor.  So for example if you wish to use the Bijection Interceptor for the "someOtherSeamComponent" and "SomeBean" dependency illustrated above like so:

public class SomeBean {
     @In("someOtherSeamComponent")
     private SomeOtherBean seamComponent;
}

To enable all of the above functionality you just have to declare the SeamPostProcessor in your Bean factory like so:

<bean class="org.jboss.seam.spring.SeamPostProcessor"/>

To fulfill requirements 2 and 3 I use the Spring provided DelegatingVariableResolver so if you wish to inject a spring bean that is not a seam component into a Seam component and take advantage of the Bijection Interceptor then you would have to do it using EL with springs DelegatingVariableResolver:

public class SomeBean {
     @In("#{someSpringBean}")
     private SomeSpringBean springBean;
}


Requirement #1: If you wish to inject a non spring configured seam component into an existing spring bean you can use the provided SeamFactoryBean providing a name and optionally a scope and/or a "created" attribute you can inject a Seam component into a spring bean like so:

<bean id="someSpringBean" class="example.SomeSpringBean" scope="singleton">
     <property name="seamComponent">
          <bean class="org.jboss.seam.spring.SeamFactoryBean">
                <property name="name" value="someSeamComponent"/>
          </bean>
     </property>
</bean>

It would be trivial to create a Namespace handler to inject seam components which could look something like this (though I have not yet done it):

<bean id="someSpringBean" class="example.SomeSpringBean" scope="singleton">
     <property name="seamComponent">
          <seam:instance name="someSeamComponent"/>
     </property>
</bean>


I would be interested in any feedback anyone has.  With this functionality in place I next plan to tackle requirement #4 adding the ability to inject transactionManagers, hibernateFactories, entityManagerFactories, etc. into seam components configured in spring.

Mike

> Spring integration
> ------------------
>
>                 Key: JBSEAM-696
>                 URL: http://jira.jboss.com/jira/browse/JBSEAM-696
>             Project: JBoss Seam
>          Issue Type: Feature Request
>          Components: Spring, Core
>            Reporter: Gavin King
>         Assigned To: Norman Richards
>            Priority: Critical
>             Fix For: 1.1.7.GA
>
>
> The Spring integration package will support:
> (1) injection of Seam components into Spring beans, using beans.xml
> (2) injection of Spring beans into Seam components using @In
> (3) access to Spring beans via EL
> (4) use of Seam-managed PC from Spring DAOs
> We'll probably even go as far as:
>  (5) The ability to treat a Spring bean as a Seam STATELESS JAVA_BEAN component, with a full stack of Seam interceptors 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the seam-issues mailing list