Topic
  • 4 replies
  • Latest Post - ‏2010-09-29T15:08:49Z by HasanMuhammad
Rohit_R
Rohit_R
24 Posts

Pinned topic How to use Spring sca:reference tag to bind tp SCA services in other app?

‏2010-09-27T21:15:25Z |
We have a SCA component present in App1 created using implementation.spring.

Now we have another application App2 which is spring based. App2 does not have any SCA services but spring beans in App2 need to use the services provided by SCA component in App1.

If we just put a spring sca:reference tag in the spring context file as shown below, then the reference does not get resolved.

How do we get this scenario working? Do we need to deploy any sca composite file to complete this binding?


<?xml version=
"1.0" encoding=
"UTF-8"?>   <beans xmlns=
"http://www.springframework.org/schema/beans" xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance" xmlns:context=
"http://www.springframework.org/schema/context" xmlns:sca=
"http://www.springframework.org/schema/sca" xsi:schemaLocation=
"http://www.springframework.org/schema/beans http:
//www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/context http:
//www.springframework.org/schema/context/spring-context-2.5.xsd http:
//www.springframework.org/schema/sca http://www.osoa.org/xmlns/sca/1.0/spring-sca.xsd"> <bean id=
"AppAuditServiceBean" class=
"com.abc.AppAuditServiceFacadeImpl"> <property name=
"appAuditService" ref=
"AppAuditService"/> </bean> <sca:reference name=
"AppAuditService" type=
"com.abc.AppAuditService"/> </beans>
Updated on 2010-09-29T15:08:49Z at 2010-09-29T15:08:49Z by HasanMuhammad
  • JenniferThompson
    JenniferThompson
    5 Posts

    Re: How to use Spring sca:reference tag to bind tp SCA services in other app?

    ‏2010-09-28T15:05:16Z  
    In order to use the SCA reference in App2, App2 must also be an SCA application. So you need to create a composite file where you define App2 as a component with a reference to the service exposed in App1. For example, your composite file might looks something like the following (except you would want the "targetNamespace" to be the same as App1, "target" would point to the actual component/service name you defined in App1, and have "location" point to the actual name of the context for App2.)

    
    <?xml version=
    "1.0" encoding=
    "UTF-8"?> <composite xmlns=
    "http://www.osoa.org/xmlns/sca/1.0" targetNamespace=
    "http://spring.example" xmlns:wsdli=
    "http://www.w3.org/2004/08/wsdl-instance" name=
    "App2Composite"> <component name=
    "App2Component"> <implementation.spring location=
    "META-INF/app2-context.xml"/> <reference name=
    "AppAuditService" target=
    "App1Component/App1Service"> <interface.java interface=
    "com.abc.AppAuditService"/> </reference> </component> </composite>
    


    Regards,

    Jennifer Thompson
  • Rohit_R
    Rohit_R
    24 Posts

    Re: How to use Spring sca:reference tag to bind tp SCA services in other app?

    ‏2010-09-28T21:07:37Z  
    In order to use the SCA reference in App2, App2 must also be an SCA application. So you need to create a composite file where you define App2 as a component with a reference to the service exposed in App1. For example, your composite file might looks something like the following (except you would want the "targetNamespace" to be the same as App1, "target" would point to the actual component/service name you defined in App1, and have "location" point to the actual name of the context for App2.)

    <pre class="jive-pre"> <?xml version= "1.0" encoding= "UTF-8"?> <composite xmlns= "http://www.osoa.org/xmlns/sca/1.0" targetNamespace= "http://spring.example" xmlns:wsdli= "http://www.w3.org/2004/08/wsdl-instance" name= "App2Composite"> <component name= "App2Component"> <implementation.spring location= "META-INF/app2-context.xml"/> <reference name= "AppAuditService" target= "App1Component/App1Service"> <interface.java interface= "com.abc.AppAuditService"/> </reference> </component> </composite> </pre>

    Regards,

    Jennifer Thompson
    Jennifer, thanks for the reply.
    I probably should have mentioned that the spring beans in App2 are inside an enterprise application (AbcAuditClient.ear). So based on the sample in your post, to get our spring sca:reference working we deployed an application.composite file in the ear META-INF folder with the composite definition looking like this.
    
    <?xml version=
    "1.0" encoding=
    "UTF-8"?> <composite xmlns=
    "http://www.osoa.org/xmlns/sca/1.0" targetNamespace=
    "http://abc/audit" xmlns:auditns=
    "http://abc/audit" xmlns:wsdli=
    "http://www.w3.org/2004/08/wsdl-instance" name=
    "AuditCompositeSpringClient"> <component name=
    "AppAuditServiceSpringSCAClient"> <implementation.spring location=
    "spring-context/application-context.xml"/> <reference name=
    "AppAuditService" target=
    "AppAuditServiceSpringSCA/AppAuditService"> <interface.java interface=
    "com.abc.AppAuditService"/> </reference> </component> </composite>
    


    but this composite file does not seem to be getting used when we create a new BLA with this AbcAuditClient.ear file deployed from asset.

    Then in this BLA along with the AbcAuditClient.ear we deployed a new jar file with composite using implementation.jee and pointing to the above AbcAuditClient.ear as below
    
    <?xml version=
    "1.0" encoding=
    "UTF-8"?> <composite xmlns=
    "http://www.osoa.org/xmlns/sca/1.0" targetNamespace=
    "http://abc/audit" xmlns:auditns=
    "http://abc/audit" xmlns:wsdli=
    "http://www.w3.org/2004/08/wsdl-instance" name=
    "AuditCompositeSpringJee"> <component name=
    "AbcAuditClient"> <implementation.jee archive=
    "AbcAuditClient.ear"/> </component> </composite>
    

    After this the application.composite in the ear gets picked up by SCA runtime but we still dont see our spring context getting initialized. As a result we haven't been able to the get spring sca:reference working.

    Would really appreciate any help regarding the above.
  • SystemAdmin
    SystemAdmin
    126 Posts

    Re: How to use Spring sca:reference tag to bind tp SCA services in other app?

    ‏2010-09-29T13:49:06Z  
    • Rohit_R
    • ‏2010-09-28T21:07:37Z
    Jennifer, thanks for the reply.
    I probably should have mentioned that the spring beans in App2 are inside an enterprise application (AbcAuditClient.ear). So based on the sample in your post, to get our spring sca:reference working we deployed an application.composite file in the ear META-INF folder with the composite definition looking like this.
    <pre class="jive-pre"> <?xml version= "1.0" encoding= "UTF-8"?> <composite xmlns= "http://www.osoa.org/xmlns/sca/1.0" targetNamespace= "http://abc/audit" xmlns:auditns= "http://abc/audit" xmlns:wsdli= "http://www.w3.org/2004/08/wsdl-instance" name= "AuditCompositeSpringClient"> <component name= "AppAuditServiceSpringSCAClient"> <implementation.spring location= "spring-context/application-context.xml"/> <reference name= "AppAuditService" target= "AppAuditServiceSpringSCA/AppAuditService"> <interface.java interface= "com.abc.AppAuditService"/> </reference> </component> </composite> </pre>

    but this composite file does not seem to be getting used when we create a new BLA with this AbcAuditClient.ear file deployed from asset.

    Then in this BLA along with the AbcAuditClient.ear we deployed a new jar file with composite using implementation.jee and pointing to the above AbcAuditClient.ear as below
    <pre class="jive-pre"> <?xml version= "1.0" encoding= "UTF-8"?> <composite xmlns= "http://www.osoa.org/xmlns/sca/1.0" targetNamespace= "http://abc/audit" xmlns:auditns= "http://abc/audit" xmlns:wsdli= "http://www.w3.org/2004/08/wsdl-instance" name= "AuditCompositeSpringJee"> <component name= "AbcAuditClient"> <implementation.jee archive= "AbcAuditClient.ear"/> </component> </composite> </pre>
    After this the application.composite in the ear gets picked up by SCA runtime but we still dont see our spring context getting initialized. As a result we haven't been able to the get spring sca:reference working.

    Would really appreciate any help regarding the above.
    Tyo my knowledge there is no possibility to make EARs and BLAs work together in an out of the box way. So our EARs communicate with the BLAs via web services. Maybe that's a solution which works for you too.
  • HasanMuhammad
    HasanMuhammad
    8 Posts

    Re: How to use Spring sca:reference tag to bind tp SCA services in other app?

    ‏2010-09-29T15:08:49Z  
    • Rohit_R
    • ‏2010-09-28T21:07:37Z
    Jennifer, thanks for the reply.
    I probably should have mentioned that the spring beans in App2 are inside an enterprise application (AbcAuditClient.ear). So based on the sample in your post, to get our spring sca:reference working we deployed an application.composite file in the ear META-INF folder with the composite definition looking like this.
    <pre class="jive-pre"> <?xml version= "1.0" encoding= "UTF-8"?> <composite xmlns= "http://www.osoa.org/xmlns/sca/1.0" targetNamespace= "http://abc/audit" xmlns:auditns= "http://abc/audit" xmlns:wsdli= "http://www.w3.org/2004/08/wsdl-instance" name= "AuditCompositeSpringClient"> <component name= "AppAuditServiceSpringSCAClient"> <implementation.spring location= "spring-context/application-context.xml"/> <reference name= "AppAuditService" target= "AppAuditServiceSpringSCA/AppAuditService"> <interface.java interface= "com.abc.AppAuditService"/> </reference> </component> </composite> </pre>

    but this composite file does not seem to be getting used when we create a new BLA with this AbcAuditClient.ear file deployed from asset.

    Then in this BLA along with the AbcAuditClient.ear we deployed a new jar file with composite using implementation.jee and pointing to the above AbcAuditClient.ear as below
    <pre class="jive-pre"> <?xml version= "1.0" encoding= "UTF-8"?> <composite xmlns= "http://www.osoa.org/xmlns/sca/1.0" targetNamespace= "http://abc/audit" xmlns:auditns= "http://abc/audit" xmlns:wsdli= "http://www.w3.org/2004/08/wsdl-instance" name= "AuditCompositeSpringJee"> <component name= "AbcAuditClient"> <implementation.jee archive= "AbcAuditClient.ear"/> </component> </composite> </pre>
    After this the application.composite in the ear gets picked up by SCA runtime but we still dont see our spring context getting initialized. As a result we haven't been able to the get spring sca:reference working.

    Would really appreciate any help regarding the above.
    Rohit

    We do not support this scenario and it wont work. You can simply use the CurrentCompositeContext API to get a reference to the SCA service inside of your Spring application App2.

    1. SCA component present in App1 created using implementation.spring exposing Spring beans as SCA services over default binding.
    2. App2 would continue to be a normal JEE application without any application.composite.
    3. You can then in your App2 use the CurrentCompositeContext API to invoke SCA services exposed via SCA Component in App1