230 likes | 366 Vues
This document provides a comprehensive overview of Service Component Architecture (SCA) and its support for various Java-based component implementation types, including POJOs, Spring Beans, and EJBs. It covers key principles like simplifying component development, promoting loose coupling, and enhancing service-based designs through strong contracts. Additionally, it discusses asynchronous interactions, callback mechanisms, and metadata specifications for defining services, along with examples of Java implementations. The focus is on streamlining service integration and enhancing reusability in enterprise applications.
E N D
SCA and Java • SCA provides support for multiple Java-based component implementation types • Java POJOs (implementation.java) • Spring Beans (implementation.spring) • EJB (implementation.ejb) • Common annotations and API • May be used by all Java-based implementations • Metadata service contracts based on Java interfaces • Metadata component type information • Metadata container-component implementation contract • Asynchronous interactions and callbacks • APIs (few) for accessing assembly information
An example Java implementation type • Just Java with a few (optional) annotations public class LoanServiceImpl implements LoanService { private CreditService creditService; public LoanServiceImpl(@Reference CreditService creditService) { this.creditService = creditService; } public void apply(Application application) { String id = application.getCustomerID(); int rating = creditService.getCreditScore(id); } }
Key Principles • Simplify component development • Use POJOs • Minimal container coupling to implementations • Achieved through Inversion of Control or IoC • Simplify reuse through service-based design • Strongly defined contracts that pass data • Remove need to interact directly with binding protocols and transports most of the time • Focus on loosely-coupled interactions
Metadata for Service Contracts • @Remotable • Defines a service that may be visible across process boundaries • @Conversational, @EndsConversation • Deals with conversational services • More on this later • @OneWay • Denotes a non-blocking operation • More on this later • @Callback • Defines callback interface and injection
Metadata for defining component type information • @Service • Defines services offered by an implementation • @Property • Identifies a component type property • Setter-based, ctor-based and field-based injection supported • @Reference • Identifies a component type reference • Setter-based, ctor-based and field-based injection supported • SCA defines heuristics for unannotated POJOs as well
Container-Component Implementation Contract Metadata • @AllowsPassByReference • Per-class or per-operation • @Scope • Specifies visibility and lifecycle contract • STATELESS (default), REQUEST, CONVERSATION, COMPOSITE • Containers may also add custom scopes • Conversation semantics • Always between two parties • May be long-running
Asynchronous Interactions • @OneWay • Indicate a non-blocking call on an interface public interface Counter { int getCount(); @OneWay void increment(); @EndsConversation int reset(); }
Callbacks • Stateful and stateless • Non-blocking or blocking @Callback(MyCallback.class) public interface MyService { void call(); } public interface MyCallback { void call(); } public class MyServiceImpl { @Callback public void setCallback(MyCallback callback){ //... } //... }
Stateful Callbacks • LoanShark service Conversational @Callback(Borrower.class) public interface LoanShark { void borrow(double amount); @EndsConversation void payback(); @OneWay void delay(); } public interface Borrower { warn(); breakArm(); @EndsConversation kill(); }
APIs • Only a few, deal with specific use cases, e.g. • Component context, name • Request contexts • Service references (may be passed) • Conversation id • Set callback
www.oasis-open.org SCA - Spring Integration
Spring • Spring application contexts can be used as component implementations • Spring beans can be wired to SCA or external services services • Spring beans can have services exposed • Other SCA components may be wired to them • Beans may be bound using an SCA binding Spring Beans SCA Service SCA Reference implementation.spring
www.oasis-open.org SCA - Java EE Integration
www.oasis-open.org Why SCA With Java EE Platform? Java EE gets • Additional implementation types and bindings on the application level: • BPEL, Spring,... • More to expect: For example ESB style interactions • Move protocol specifics to configuration via bindings • Cross-Application Assembly • Domain assembly extends Enterprise App Assembly to the cross-app level SCA gets • Reuse of existing assets, know-how, tooling.
www.oasis-open.org Types of Integration • Bindings • JMS, Session Beans, JCA • Implementation Types • Java EE Components (SessionBeans, WebComponents, etc) asimplementation types. • Java EE Archives (EARs, WARs, EJB-JARs) as implementation types.
www.oasis-open.org Use Cases for Bindings Binding.ejb • Consume session beans from service components • Expose SCA services as session beans, so that they can be consumed by unmodified Java EE components Binding.jms, Binding.jca • Several other binding types relate to Java EE, but are the focus of other working groups.
www.oasis-open.org Use Cases for Java EE Components as Implementation Types • Java EE components use SCA‘s programming model to consume SCA-exposed services. • Use session beans as Service Component Implementations that may be consumed by other SCA components. • Use recursive SCA assembly in enterprise applications. • DeploySCA Components as a part of a Java EE application SCA is the Scale-Out model for Java EE
www.oasis-open.org Use Cases for Java EE Applications as Implementation Types • Use Java EE applications as Service Component Implementations • Modified • Unmodified • Allow unmodified Java EE applications to be rewired by SCA. • Exposure of Java EE services at any level of recursive assembly. SCA is the level of assembly above Java EE
Programming Model in JEE Components • Will be shown during demo:
Contribution is JEE Archive:Sample Assembly I Composite with a session bean component <?xml version="1.0" encoding="UTF-8"?> <composite name="beancomposite" targetNamespace="http://www.sample.org" xmlns="http://www.osoa.org/xmlns/sca/1.0"> <component name="org.sample.Accounting"> <implementation.ejb ejb-link="module.jar#RemotableAccountingBean"/> </component> </composite>
Contribution is JEE Archive:Sample Assembly II Including it into the domain Declare sample:beancomposite as Deployment Composite in In META-INF/sca-contribution.xml: <?xml version="1.0" encoding="UTF-8"?> <contribution xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:sample="http://www.sample.org"> <deployable composite=“sample:beancomposite"/> </contribution>
Open Questions • What is the componentType of an unmodified EAR (ie, one with no application.composite)? • Can ejb-ref‘s be rewired by SCA?