SCA and Java

23
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

description

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 - PowerPoint PPT Presentation

Transcript of SCA and Java

Page 1: SCA and Java

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

Page 2: SCA and Java

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);}

}

Page 3: SCA and Java

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

Page 4: SCA and Java

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

Page 5: SCA and Java

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

Page 6: SCA and Java

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

Page 7: SCA and Java

Asynchronous Interactions @OneWay

Indicate a non-blocking call on an interface

public interface Counter {int getCount();

@OneWayvoid increment();

@EndsConversationint reset();

}

Page 8: SCA and Java

Callbacks Stateful and stateless Non-blocking or blocking

@Callback(MyCallback.class)public interface MyService {

void call();}

public interface MyCallback {void call();

}

public class MyServiceImpl {

@Callbackpublic void setCallback(MyCallback callback){

//...}//...

}

Page 9: SCA and Java

Stateful Callbacks LoanShark service

Conversational@Callback(Borrower.class)public interface LoanShark {

void borrow(double amount);

@EndsConversationvoid payback();

@OneWayvoid delay();

}

public interface Borrower {

warn();breakArm();

@EndsConversationkill();

}

Page 10: SCA and Java

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

Page 11: SCA and Java

SCA - Spring IntegrationSCA - Spring Integration

www.oasis-open.org

Page 12: SCA and Java

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 Reference

SCA Service

implementation.spring

Page 13: SCA and Java

SCA - Java EE IntegrationSCA - Java EE Integration

www.oasis-open.org

Page 14: SCA and Java

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.

Page 15: SCA and Java

www.oasis-open.org

Types of Integration Bindings

JMS, Session Beans, JCA Implementation Types

Java EE Components (SessionBeans, WebComponents, etc) as implementation types.

Java EE Archives (EARs, WARs, EJB-JARs) as implementation types.

Page 16: SCA and Java

www.oasis-open.org

Use Cases for BindingsBinding.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.

Page 17: SCA and Java

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.

Deploy SCA Components as a part of a Java EE application

SCA is the Scale-Out model for Java EE

Page 18: SCA and Java

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

Page 19: SCA and Java

Programming Model in JEE Components Will be shown during demo:

Page 20: SCA and Java

sample:beancomposite

org.sample.Accounting

module.jar

RemotableAccountingBeanComposite with a session bean component

Contribution is JEE Archive:Sample Assembly I

<?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>

Page 21: SCA and Java

domain composite

App1

sample:beancomposite

org.sample.Accounting

module.jar

RemotableAccountingBean

org.sample.Accounting

Including it into the domain

<?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>

Declare sample:beancomposite as Deployment Composite inIn META-INF/sca-contribution.xml:

Contribution is JEE Archive:Sample Assembly II

Page 22: SCA and Java

Contribution containing a Java EE archive

Contribution

some other composite

application.ear

module.jar

accounting_application

beancomponent

RemotableBean

binding.wsothercomponent

some_component

a non-Java EE contribution

a component using <implementation.jee archive=“application.ear“/>

D042678
Page 23: SCA and Java

Open Questions

What is the componentType of an unmodified EAR (ie, one with no application.composite)?

Can ejb-ref‘s be rewired by SCA?