SCA and Java n SCA provides support for multiple Java-based component implementation types l Java POJOs (implementation.java) l Spring Beans (implementation.spring) l EJB (implementation.ejb) n Common annotations and API l May be used by all Java-based implementations l Metadata service contracts based on Java interfaces l Metadata component type information l Metadata container-component implementation contract l Asynchronous interactions and callbacks l APIs (few) for accessing assembly information
An example Java implementation type n Just Java with a few (optional) annotations public class LoanServiceImpl implements LoanService { private CreditService creditService; public CreditService creditService) { this.creditService = creditService; } public void apply(Application application) { String id = application.getCustomerID(); int rating = creditService.getCreditScore(id); }
Key Principles n Simplify component development l Use POJOs l Minimal container coupling to implementations l Achieved through Inversion of Control or IoC n Simplify reuse through service-based design l Strongly defined contracts that pass data l Remove need to interact directly with binding protocols and transports most of the time l Focus on loosely-coupled interactions
Metadata for Service Contracts l Defines a service that may be visible across process l Deals with conversational services l More on this later l Denotes a non-blocking operation l More on this later l Defines callback interface and injection
Metadata for defining component type information l Defines services offered by an implementation l Identifies a component type property l Setter-based, ctor-based and field-based injection supported l Identifies a component type reference l Setter-based, ctor-based and field-based injection supported n SCA defines heuristics for unannotated POJOs as well
Container-Component Implementation Contract Metadata l Per-class or per-operation l Specifies visibility and lifecycle contract l STATELESS (default), REQUEST, CONVERSATION, COMPOSITE l Containers may also add custom scopes n Conversation semantics l Always between two parties l May be long-running
More on Conversations n Making an implementation public interface Counter { int getCount(); void int reset(); public class CounterImpl implements Counter { private int count; public int getCount() { return count; } public void increment() { ++i; } public void reset() { i = 0; }
Asynchronous Interactions l Indicate a non-blocking call on an interface public interface Counter { int void int reset(); }
Callbacks n Stateful and stateless n Non-blocking or public interface MyService { void call(); } public interface MyCallback { void call(); } public class MyServiceImpl public void setCallback(MyCallback callback){ //... } //... }
Stateful Callbacks n LoanShark service public interface LoanShark { void borrow(double void void delay(); } public interface Borrower { warn(); kill(); }
APIs n Only a few, deal with specific use cases, e.g. n Component context, name n Request contexts n Service references (may be passed) n Conversation id n Set callback
SCA - Spring Integration
Spring n Spring application contexts can be used as component implementations n Spring beans can be wired to SCA or external services services n Spring beans can have services exposed l Other SCA components may be wired to them l Beans may be bound using an SCA binding Spring Beans SCA Reference SCA Service implementation.spring
SCA - Java EE Integration
Why SCA With Java EE Platform? Java EE gets n Additional implementation types and bindings on the application level: l BPEL, Spring,... l More to expect: For example ESB style interactions n Move protocol specifics to configuration via bindings n Cross-Application Assembly l Domain assembly extends Enterprise App Assembly to the cross-app level SCA gets n Reuse of existing assets, know-how, tooling.
Types of Integration n Bindings l JMS, Session Beans, JCA n Implementation Types l Java EE Components (SessionBeans, WebComponents, etc) as implementation types. l Java EE Archives (EARs, WARs, EJB-JARs) as implementation types.
Use Cases for Bindings Binding.ejb n Consume session beans from service components n Expose SCA services as session beans, so that they can be consumed by unmodified Java EE components Binding.jms, Binding.jca n Several other binding types relate to Java EE, but are the focus of other working groups.
Use Cases for Java EE Components as Implementation Types n Java EE components use SCA‘s programming model to consume SCA-exposed services. n Use session beans as Service Component Implementations that may be consumed by other SCA components. n Use recursive SCA assembly in enterprise applications. n Deploy SCA Components as a part of a Java EE application SCA is the Scale-Out model for Java EE
Use Cases for Java EE Applications as Implementation Types n Use Java EE applications as Service Component Implementations l Modified l Unmodified n Allow unmodified Java EE applications to be rewired by SCA. n 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 n Will be shown during demo:
Composite with a session bean component Contribution is JEE Archive: Sample Assembly I <composite name="beancomposite" targetNamespace=" xmlns=" <implementation.ejb ejb-link="module.jar#RemotableAccountingBean"/>
Including it into the domain <contribution xmlns=" xmlns:sample=" > Declare sample:beancomposite as Deployment Composite in In META-INF/sca-contribution.xml: Contribution is JEE Archive: Sample Assembly II
Contribution containing a Java EE archive
Open Questions n What is the componentType of an unmodified EAR (ie, one with no application.composite)? n Can ejb-ref‘s be rewired by SCA?