You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 11 Next »

Spring BigBank Sample Scenario

Scenario 1
This scenario represents the implementation from Spring Bigbank Samples. Before we get into more details we need to understand how the Spring Framework can be used with SCA.

How Spring Framework is used with SCA?

*A Spring Application Context is used as an implementation within an SCA composite component.
*A component that uses Spring for an implementation can wire SCA services and references without introducing SCA metadata into the Spring configuration. The Spring context knows very little about the SCA environment. All policy enforcement occurs in the SCA runtime implementation and does not enter into the Spring space.
*It should be possible to generate an SCA Composite from any Spring context and use that composite within an SCA assembly.

1. Use implementation.composite as a component implementation - Implicit declaration

A Spring component acts within a business process accepting call from client components and send on calls to other components. The operation of the component in the Spring assembly is controlled through SCA properties.Here the component type is derived from the spring implementation with no SCA specific entries in the spring application context.

<beans xmlns=...>

    <bean id="testBean" class="org.apache.tuscany.sca.implementation.spring.itests.helloworld.HelloWorldBean">
        <property name="bean" ref="testReference"/>
        <property name="hello" ref="testProperty"/>
    </bean>
</beans>

where the composite file is

    <component name="ClientComponent">
        <implementation.java class="org.apache.tuscany.sca.implementation.spring.itests.helloworld.HelloWorldProxy"/>
        <reference name="delegate" target="SpringComponent"/>
    </component>

    <component name="SpringComponent">
        <implementation.spring location="META-INF/sca/SpringComponent-context.xml"/>
        <reference name="testReference" target="ReferenceComponent"/>
        <property name="testProperty">Hello</property>
    </component>

    <component name="ReferenceComponent">
        <implementation.java class="org.apache.tuscany.sca.implementation.spring.itests.helloworld.HelloWorldImpl"/>
    </component>

2. Use implementation.composite as a component implementation - Explicit declaration

A Spring component acts within a business process accepting call from client components and send on calls to other components. The operation of the component in the Spring assembly is controlled through SCA properties. Here the component type is derived from the spring implementation with no SCA specific entries in the spring application context.

<beans xmlns=...>

    <sca:service name="testService" 
                 type="org.apache.tuscany.sca.implementation.spring.itests.helloworld.HelloWorld" 
                 target="testBean"/>

    <bean id="testBean" class="org.apache.tuscany.sca.implementation.spring.itests.helloworld.HelloWorldBean">
        <property name="bean" ref="testReference"/>
        <property name="hello" ref="testProperty"/>
    </bean>

    <sca:reference name="testReference" type="org.apache.tuscany.sca.implementation.spring.itests.helloworld.HelloWorld"/>

    <sca:property id="foo" name="testProperty" type="java.lang.String"/>
</beans>

where the composite file is

    <component name="ClientComponent">
        <implementation.java class="org.apache.tuscany.sca.implementation.spring.itests.helloworld.HelloWorldProxy"/>
        <reference name="delegate" target="SpringComponent"/>
    </component>

    <component name="SpringComponent">
        <implementation.spring location="META-INF/sca/SpringComponent-context.xml"/>
        <reference name="testReference" target="ReferenceComponent"/>
        <property name="testProperty">Hello</property>
    </component>

    <component name="ReferenceComponent">
        <implementation.java class="org.apache.tuscany.sca.implementation.spring.itests.helloworld.HelloWorldImpl"/>
    </component>

The SpringComponent successfully operates performs HelloWorld actions in the context of the configuration from the composite file.

3. Working with different SCA bindings within Spring

The SpringComponent implementation remains the same but different bindings are chosen.

Working with SCA WebServices Binding

Declaring Service

<composite name="StockQuote">
    
    <service name="StockQuoteService" promote="StockQuoteServiceComponent">
        <interface.java interface="bigbank.stockquote.StockQuoteService"/>
        <binding.ws uri="http://localhost:8081/services/StockQuoteWebService"/>
    </service>

    <component name="StockQuoteServiceComponent">
        <implementation.spring location="META-INF/spring/StockQuoteService-context.xml"/>
    </component>

</composite>

Declaring Reference

<component name="AccountServiceComponent">
    <implementation.spring location="spring-context/Account-spring-context.xml"/>

    <reference name="stockQuoteService">
       <binding.ws uri="http://localhost:8081/services/StockQuoteWebService"/>
    </reference>
</component>

Working with JMS Binding

Declaring Service

<composite name="CheckingsAccountDept">	
    <service name="CheckingsAccountService" promote="CheckingAccountServiceComponent" requires="authentication">
        <interface.java interface="bigbank.account.checking.CheckingAccountService"/>
        <binding.jms initialContextFactory="org.apache.activemq.jndi.ActiveMQInitialContextFactory"
                      jndiURL="tcp://localhost:61619">
             <destination name="RequestQueue" create="ifnotexist"/>
             <response>
                 <destination name="ResponseQueue" create="ifnotexist"/>
             </response> 
        </binding.jms>
    </service>

    <component name="CheckingAccountServiceComponent">
        <implementation.spring location="spring-context/META-INF/spring/CheckingAccountService-context.xml" requires="bba:authorization"/>
    </component>
</composite>

Declaring Reference

<component name="AccountServiceComponent">
    <implementation.spring location="spring-context/Account-spring-context.xml"/>
    
    <reference name="checkingAccountService">
          <interface.java interface="bigbank.account.checking.CheckingAccountService"/>
          <binding.jms initialContextFactory="org.apache.activemq.jndi.ActiveMQInitialContextFactory"
                       jndiURL="tcp://localhost:61619">
              <destination name="RequestQueue" create="always"/>
              <response>
                  <destination name="ResponseQueue" create="always"/>
              </response> 
          </binding.jms>
     </reference>
</component>

Working with RMI binding

Declaring Service

<composite name="Calculator">
    <service name="CalculatorService" promote="CalculatorServiceComponent">
        <interface.java interface="bigbank.calculator.CalculatorService"/>
        <tuscany:binding.rmi host="localhost" port="8099" serviceName="CalculatorRMIService"/>
    </service>

    <component name="CalculatorServiceComponent">
        <implementation.spring location="META-INF/spring/CalculatorService-context.xml"/>
        <reference name="addService" target="AddServiceComponent" />
        <reference name="subtractService" target="SubtractServiceComponent" />
        <reference name="multiplyService" target="MultiplyServiceComponent" />
        <reference name="divideService" target="DivideServiceComponent" />
    </component>
</composite>

Declaring Reference

<component name="AccountServiceComponent">
    <implementation.spring location="spring-context/Account-spring-context.xml"/>
    
    <reference name="calculatorService">
        <tuscany:binding.rmi host="localhost" port="8099" serviceName="CalculatorRMIService"/>
    </reference>
</component>

Policy - Security

TBD

Policy - Transaction

TBD

  • No labels