SlideShare ist ein Scribd-Unternehmen logo
1 von 30
Data Binding Unleashed for Composite Applications Raymond Feng LucianoResende Apache Tuscany committer  Shutterfly Inc.
Agenda Introduction Data binding SCA Composite application Apache Tuscany project Data bindings in a composite application Tuscany data binding framework Extending Tuscany data binding framework
IntroductionUnderstanding the concepts: Data binding and SCA composite application
What’s a data binding? A data binding (in this talk) denotes how business data are represented in memory as Java objects. For example, we can represent a customer as: JavaBean (customer.Customer) JAXB (customer.Customer) SDO (DataObject or customer.Customer) StAXXMLStreamReader DOM Node (org.w3c.dom.Node) XML String/byte[]/InputStream JSON String/byte[]/InputStream org.json.JSONObject … The same information with different representations JAXB JavaBean Customer Id lastName firstName … DOM JSON InputStream
SCA composite application SCA (Service Component Architecture, being standardized at OASIS) Composite (a collection of collaborating components) Component (encapsulation of reusable business logic) Implementation (the code/script) Service (the function it provides) Interface Binding (how is the service exposed) Reference (the function it consumes) Interface Binding (how is the service accessed)
What is Apache Tuscany? Apache Tuscany (http://tuscany.apache.org) implements Service Component Architecture (SCA) standard. With SCA as it's foundation, Tuscany offers solution developers the following advantages:  Provides a model for creating composite applications by defining the services in the fabric and their relationships with one another. The services can be implemented in any technology. Enables service developers to create reusable services that only contain business logic. Protocols are pushed out of business logic and are handled through pluggable bindings. This lowers development cost. Applications can easily adapt to infrastructure changes without recoding since protocols are handled via pluggable bindings and quality of services (transaction, security) are handled declaratively. Existing applications can work with new SCA compositions. This allows for incremental growth towards a more flexible architecture, outsourcing or providing services to others.
Data bindings in a composite applicationModeling, representing and flowing data across components and protocols
A simple scenario Two SCA components: Payment and CreditCardPayment (Payment calls CreditCardPayment to authorize credit card charges) Two developers: Bob and Mary Payment communicates with CreditCardPayment using SOAP/HTTP web service The Payment component will be exposed as a JSON-RPC service
The SCA composite file <composite xmlns=“http://docs.oasis-open.org/ns/opencsa/sca/200912” xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1" targetNamespace="http://tuscanyscatours.com/" name=”Store”>     <component name="Payment">         <implementation.java class="com.tuscanyscatours.payment.impl.PaymentImpl" />         <service name="Payment">             <tuscany:binding.jsonrpcuri="http://localhost:8080/Payment" />        </service> 	<reference name="creditCardPayment">             <binding.wsuri="http://localhost:8080/CreditCardPayment" />         </reference> </component>     <component name="CreditCardPayment">         <implementation.java class="com.tuscanyscatours.payment.creditcard.impl.CreditCardPaymentImpl" />         <service name="CreditCardPayment"> 	<binding.wsuri="http://localhost:8080/CreditCardPayment" />        </service>     </component> </composite>
Interface and data modeling Bob and Mary first agree on what data needs to be exchanged between the two components The agreement is then described as an interface (which in turn references the data types) The interface becomes the key contract between the SCA reference and service that are wired together The interfaces can be described using different IDLs such as WSDL (w/ XSD) or Java interface Interface compatibility  Things to consider: efficiency, simplicity, remotablity and interoperability.
Sample interfaces JAX-WS w/ JAXB (annotations omitted…): public interface CreditCardPayment { 	String authorize(JAXBCreditCardDetailsTypecreditCard,  float amount); } SDO: public interface CreditCardPayment { 	String authorize(SDOCreditCardDetailsTypecreditCard,  float amount); }
How are data represented in a composite application? Component implementations Business logic needs to consume/produce data in a representation it supports Handling incoming service calls Calling other services Receiving property values Certain implementation containers impose the data representations (such as DOM for Apache ODE BPEL) Protocol stacks behind the bindings Protocol stacks need to marshal/unmarshal data Internal data representation  Wire format (XML, JSON, binary, etc)
Data representations between two components at runtime
The reality check Enforcing one data binding is not flexible or even not feasible Components can be implemented using different technologies which could impose the data binding requirements, for example, a BEPL engine may require DOM Components may choose to use different data bindings to represent the business data (input/output/fault), for example, JAXB vs. SDO for the XML manipulations.  Service providers or consumers are decoupled and it is impossible to have a fixed data binding A service can serve different consumers that can only handle certain data bindings natively The service providers for a given consumer can be replaced The same service can be accessed over different protocols with different data bindings
Data transformation Data transformations are required to get two components talk to each other Having application code to deal with technological data transformation is a nightmare and it will defeat the whole purpose and promise of SCA
Tuscany’s data binding frameworkIntrospect/transform data without application coding
What does the framework need to figure out? Understand the data binding requirements at different places for the data flow Transform the data from one data binding to the other transparently without the interventions from the application developers Separate the data transformation/marshaling/unmarshaling from the business logic
Data type introspection Marker interface commonj.sdo.DataObject, org.w3c.dom.Node Annotations JAXB annotations What information is captured? Java class Java generic type Logic type (XML element/type, Mime types, etc)
The magic behind the scenes
Transformation paths Types of transformations Unmarshal/Deserialize ( InputStream Object ) Marshal/Serialize ( Object OutputStream ) Convert/Transform ( Object  Object) Direct vs. Multi-hops JAXB DOM JAXB  DOM  SDO Weight of a transformation Private vs. Public Some data bindings are not good as intermediaries (data round-trip issues)
The complete data flow Customer data come in JSON from HTTP requests The JSON data is unmarshaled into JAXB for the Payment code to consume Payment passes CreditCard (JAXB) to the reference binding layer which in turn converts JAXB into AXIOM The service binding layer unmarshals the XML data into AXIOM and transform it into SDO for the CreditCardPayment The response path is reverse for the data transformations
Data bindings out of the box DOM JAXB (JavaBeans are treated as JAXB) SDO JSON StAX …
Data bindings for RESTful servicesIntegrating with JAX-RS entity providers
JAX-RS entity providers Entity providers supply mapping services between representations and their associated Java types.  Entity providers come in two flavors:  MessageBodyReader MessageBodyWriter
Tuscany’s generic entity providers based on the data binding framework  JAX-RS runtime (such as Apache Wink) Tuscany data binding framework Entity Providers Entity Providers Message Writer Message Reader Entity (JAXB, SDO, DOM, etc) InputStream OutputStream
Extending the data binding frameworkSupport your favorite data bindings
The DataBinding SPI public interface DataBinding { String getName(); booleanintrospect(DataTypedataType, Operation operation); DataTypeintrospect(Object value, Operation operation); WrapperHandlergetWrapperHandler(); Object copy(Object object, DataTypesourceDataType, DataTypetargetDataType, Operation sourceOperation, Operation targetOperation); XMLTypeHelpergetXMLTypeHelper(); }
The Transformer SPI public interface PullTransformer<S, R> extends Transformer { R transform(S source, TransformationContext context); } public interface PushTransformer<S, R> extends Transformer { void transform(S source, R sink, TransformationContext context); }
Registering your data bindings/transformers META-INF/services/org.apache.tuscany.sca.databinding.DataBinding org.apache.tuscany.sca.databinding.xml.DOMDataBinding;name=org.w3c.dom.Node META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer org.apache.tuscany.sca.databinding.xml.Node2XMLStreamReader;source=org.w3c.dom.Node,target=javax.xml.stream.XMLStreamReader,weight=80 META-INF/services/org.apache.tuscany.sca.databinding.PushTransformer org.apache.tuscany.sca.databinding.xml.Node2OutputStream;source=org.w3c.dom.Node,target=java.io.OutputStream,weight=80
Q&AFind more details from:Chapter 9 of Tuscany In SCA Actionhttp://www.manning.com/laws/Save 40% at manning.com.Enter “javaone2010” in the promotional code box at check out.

Weitere ähnliche Inhalte

Was ist angesagt?

Topic6 Basic Web Services Technology
Topic6 Basic Web Services TechnologyTopic6 Basic Web Services Technology
Topic6 Basic Web Services Technology
sanjoysanyal
 
How to process Flat Files documents (TXT, CSV …) in BizTalk Server
How to process Flat Files documents (TXT, CSV …) in BizTalk ServerHow to process Flat Files documents (TXT, CSV …) in BizTalk Server
How to process Flat Files documents (TXT, CSV …) in BizTalk Server
Sandro Pereira
 
Presentation
PresentationPresentation
Presentation
Videoguy
 
Intro to web services
Intro to web servicesIntro to web services
Intro to web services
Neil Ghosh
 

Was ist angesagt? (20)

Topic6 Basic Web Services Technology
Topic6 Basic Web Services TechnologyTopic6 Basic Web Services Technology
Topic6 Basic Web Services Technology
 
WebServices SOAP WSDL and UDDI
WebServices SOAP WSDL and UDDIWebServices SOAP WSDL and UDDI
WebServices SOAP WSDL and UDDI
 
Web services
Web servicesWeb services
Web services
 
Java web services
Java web servicesJava web services
Java web services
 
Description of soa and SOAP,WSDL & UDDI
Description of soa and SOAP,WSDL & UDDIDescription of soa and SOAP,WSDL & UDDI
Description of soa and SOAP,WSDL & UDDI
 
Java Web Services [1/5]: Introduction to Web Services
Java Web Services [1/5]: Introduction to Web ServicesJava Web Services [1/5]: Introduction to Web Services
Java Web Services [1/5]: Introduction to Web Services
 
WSDL 2.0 and Apache Woden
WSDL 2.0 and Apache WodenWSDL 2.0 and Apache Woden
WSDL 2.0 and Apache Woden
 
How to process Flat Files documents (TXT, CSV …) in BizTalk Server
How to process Flat Files documents (TXT, CSV …) in BizTalk ServerHow to process Flat Files documents (TXT, CSV …) in BizTalk Server
How to process Flat Files documents (TXT, CSV …) in BizTalk Server
 
The importance of Exchange 2013 CAS in Exchange 2013 coexistence | Part 1/2 |...
The importance of Exchange 2013 CAS in Exchange 2013 coexistence | Part 1/2 |...The importance of Exchange 2013 CAS in Exchange 2013 coexistence | Part 1/2 |...
The importance of Exchange 2013 CAS in Exchange 2013 coexistence | Part 1/2 |...
 
Presentation
PresentationPresentation
Presentation
 
Introduction To Dot Net Siddhesh
Introduction To Dot Net SiddheshIntroduction To Dot Net Siddhesh
Introduction To Dot Net Siddhesh
 
BizTalk Server- Schema
BizTalk Server-  SchemaBizTalk Server-  Schema
BizTalk Server- Schema
 
Web services
Web servicesWeb services
Web services
 
Web Services ppt
Web Services pptWeb Services ppt
Web Services ppt
 
Xml schema
Xml schemaXml schema
Xml schema
 
Cloud computing 20 service modelling
Cloud computing 20 service modellingCloud computing 20 service modelling
Cloud computing 20 service modelling
 
Jdbc Dao it-slideshares.blogspot.com
Jdbc Dao it-slideshares.blogspot.comJdbc Dao it-slideshares.blogspot.com
Jdbc Dao it-slideshares.blogspot.com
 
Webservices
WebservicesWebservices
Webservices
 
SynapseIndia dotnet web applications development
SynapseIndia  dotnet web applications developmentSynapseIndia  dotnet web applications development
SynapseIndia dotnet web applications development
 
Intro to web services
Intro to web servicesIntro to web services
Intro to web services
 

Ähnlich wie Data Binding Unleashed for Composite Applications

The Story of How an Oracle Classic Stronghold successfully embraced SOA (ODTU...
The Story of How an Oracle Classic Stronghold successfully embraced SOA (ODTU...The Story of How an Oracle Classic Stronghold successfully embraced SOA (ODTU...
The Story of How an Oracle Classic Stronghold successfully embraced SOA (ODTU...
Lucas Jellema
 
Automated Syntactic Mediation for Web Service Integration
Automated Syntactic Mediation for Web Service IntegrationAutomated Syntactic Mediation for Web Service Integration
Automated Syntactic Mediation for Web Service Integration
Martin Szomszor
 
Ado.Net Data Services (Astoria)
Ado.Net Data Services (Astoria)Ado.Net Data Services (Astoria)
Ado.Net Data Services (Astoria)
Igor Moochnick
 
Kafka Summit NYC 2017 - The Data Dichotomy: Rethinking Data and Services with...
Kafka Summit NYC 2017 - The Data Dichotomy: Rethinking Data and Services with...Kafka Summit NYC 2017 - The Data Dichotomy: Rethinking Data and Services with...
Kafka Summit NYC 2017 - The Data Dichotomy: Rethinking Data and Services with...
confluent
 
Service Oriented Architecture Updated Luqman
Service Oriented Architecture Updated  LuqmanService Oriented Architecture Updated  Luqman
Service Oriented Architecture Updated Luqman
guesteb791b
 

Ähnlich wie Data Binding Unleashed for Composite Applications (20)

The Story of How an Oracle Classic Stronghold successfully embraced SOA
The Story of How an Oracle Classic Stronghold successfully embraced SOAThe Story of How an Oracle Classic Stronghold successfully embraced SOA
The Story of How an Oracle Classic Stronghold successfully embraced SOA
 
Introducing SOA and Oracle SOA Suite 11g for Database Professionals
Introducing SOA and Oracle SOA Suite 11g for Database ProfessionalsIntroducing SOA and Oracle SOA Suite 11g for Database Professionals
Introducing SOA and Oracle SOA Suite 11g for Database Professionals
 
The Story of How an Oracle Classic Stronghold successfully embraced SOA (ODTU...
The Story of How an Oracle Classic Stronghold successfully embraced SOA (ODTU...The Story of How an Oracle Classic Stronghold successfully embraced SOA (ODTU...
The Story of How an Oracle Classic Stronghold successfully embraced SOA (ODTU...
 
Automated Syntactic Mediation for Web Service Integration
Automated Syntactic Mediation for Web Service IntegrationAutomated Syntactic Mediation for Web Service Integration
Automated Syntactic Mediation for Web Service Integration
 
Ado.Net Data Services (Astoria)
Ado.Net Data Services (Astoria)Ado.Net Data Services (Astoria)
Ado.Net Data Services (Astoria)
 
Modern Database Development Oow2008 Lucas Jellema
Modern Database Development Oow2008 Lucas JellemaModern Database Development Oow2008 Lucas Jellema
Modern Database Development Oow2008 Lucas Jellema
 
jkljklj
jkljkljjkljklj
jkljklj
 
Overview of atg framework
Overview of atg frameworkOverview of atg framework
Overview of atg framework
 
Web services SOAP Notes
Web services SOAP NotesWeb services SOAP Notes
Web services SOAP Notes
 
Building apps with tuscany
Building apps with tuscanyBuilding apps with tuscany
Building apps with tuscany
 
SOA and web services
SOA and web servicesSOA and web services
SOA and web services
 
Strata Software Architecture NY: The Data Dichotomy
Strata Software Architecture NY: The Data DichotomyStrata Software Architecture NY: The Data Dichotomy
Strata Software Architecture NY: The Data Dichotomy
 
Kafka Summit NYC 2017 - The Data Dichotomy: Rethinking Data and Services with...
Kafka Summit NYC 2017 - The Data Dichotomy: Rethinking Data and Services with...Kafka Summit NYC 2017 - The Data Dichotomy: Rethinking Data and Services with...
Kafka Summit NYC 2017 - The Data Dichotomy: Rethinking Data and Services with...
 
The RESTful Soa Datagrid with Oracle
The RESTful Soa Datagrid with OracleThe RESTful Soa Datagrid with Oracle
The RESTful Soa Datagrid with Oracle
 
Event Driven Services Part 1: The Data Dichotomy
Event Driven Services Part 1: The Data Dichotomy Event Driven Services Part 1: The Data Dichotomy
Event Driven Services Part 1: The Data Dichotomy
 
The Data Dichotomy- Rethinking the Way We Treat Data and Services
The Data Dichotomy- Rethinking the Way We Treat Data and ServicesThe Data Dichotomy- Rethinking the Way We Treat Data and Services
The Data Dichotomy- Rethinking the Way We Treat Data and Services
 
Interoperable Web Services with JAX-WS and WSIT
Interoperable Web Services with JAX-WS and WSITInteroperable Web Services with JAX-WS and WSIT
Interoperable Web Services with JAX-WS and WSIT
 
Service Oriented Architecture Updated Luqman
Service Oriented Architecture Updated  LuqmanService Oriented Architecture Updated  Luqman
Service Oriented Architecture Updated Luqman
 
Lecture 16 - Web Services
Lecture 16 - Web ServicesLecture 16 - Web Services
Lecture 16 - Web Services
 
Json
JsonJson
Json
 

Mehr von Raymond Feng

OSGi Remote Services With SCA using Apache Tuscany
OSGi Remote Services With SCA using Apache TuscanyOSGi Remote Services With SCA using Apache Tuscany
OSGi Remote Services With SCA using Apache Tuscany
Raymond Feng
 

Mehr von Raymond Feng (7)

Working with LoopBack Models
Working with LoopBack ModelsWorking with LoopBack Models
Working with LoopBack Models
 
Building a Node.js API backend with LoopBack in 5 Minutes
Building a Node.js API backend with LoopBack in 5 MinutesBuilding a Node.js API backend with LoopBack in 5 Minutes
Building a Node.js API backend with LoopBack in 5 Minutes
 
Building Flexible APIs for Web 2.x/Cloud Applications (JavaOne 2011 Session ...
Building Flexible APIs for Web 2.x/Cloud Applications (JavaOne 2011 Session ...Building Flexible APIs for Web 2.x/Cloud Applications (JavaOne 2011 Session ...
Building Flexible APIs for Web 2.x/Cloud Applications (JavaOne 2011 Session ...
 
RESTful SCA with Apache Tuscany
RESTful SCA with Apache TuscanyRESTful SCA with Apache Tuscany
RESTful SCA with Apache Tuscany
 
Apache Tuscany 2.x Extensibility And SPIs
Apache Tuscany 2.x Extensibility And SPIsApache Tuscany 2.x Extensibility And SPIs
Apache Tuscany 2.x Extensibility And SPIs
 
OSGi Enablement For Apache Tuscany
OSGi Enablement For Apache TuscanyOSGi Enablement For Apache Tuscany
OSGi Enablement For Apache Tuscany
 
OSGi Remote Services With SCA using Apache Tuscany
OSGi Remote Services With SCA using Apache TuscanyOSGi Remote Services With SCA using Apache Tuscany
OSGi Remote Services With SCA using Apache Tuscany
 

Kürzlich hochgeladen

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Kürzlich hochgeladen (20)

Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 

Data Binding Unleashed for Composite Applications

  • 1. Data Binding Unleashed for Composite Applications Raymond Feng LucianoResende Apache Tuscany committer Shutterfly Inc.
  • 2. Agenda Introduction Data binding SCA Composite application Apache Tuscany project Data bindings in a composite application Tuscany data binding framework Extending Tuscany data binding framework
  • 3. IntroductionUnderstanding the concepts: Data binding and SCA composite application
  • 4. What’s a data binding? A data binding (in this talk) denotes how business data are represented in memory as Java objects. For example, we can represent a customer as: JavaBean (customer.Customer) JAXB (customer.Customer) SDO (DataObject or customer.Customer) StAXXMLStreamReader DOM Node (org.w3c.dom.Node) XML String/byte[]/InputStream JSON String/byte[]/InputStream org.json.JSONObject … The same information with different representations JAXB JavaBean Customer Id lastName firstName … DOM JSON InputStream
  • 5. SCA composite application SCA (Service Component Architecture, being standardized at OASIS) Composite (a collection of collaborating components) Component (encapsulation of reusable business logic) Implementation (the code/script) Service (the function it provides) Interface Binding (how is the service exposed) Reference (the function it consumes) Interface Binding (how is the service accessed)
  • 6. What is Apache Tuscany? Apache Tuscany (http://tuscany.apache.org) implements Service Component Architecture (SCA) standard. With SCA as it's foundation, Tuscany offers solution developers the following advantages: Provides a model for creating composite applications by defining the services in the fabric and their relationships with one another. The services can be implemented in any technology. Enables service developers to create reusable services that only contain business logic. Protocols are pushed out of business logic and are handled through pluggable bindings. This lowers development cost. Applications can easily adapt to infrastructure changes without recoding since protocols are handled via pluggable bindings and quality of services (transaction, security) are handled declaratively. Existing applications can work with new SCA compositions. This allows for incremental growth towards a more flexible architecture, outsourcing or providing services to others.
  • 7. Data bindings in a composite applicationModeling, representing and flowing data across components and protocols
  • 8. A simple scenario Two SCA components: Payment and CreditCardPayment (Payment calls CreditCardPayment to authorize credit card charges) Two developers: Bob and Mary Payment communicates with CreditCardPayment using SOAP/HTTP web service The Payment component will be exposed as a JSON-RPC service
  • 9. The SCA composite file <composite xmlns=“http://docs.oasis-open.org/ns/opencsa/sca/200912” xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1" targetNamespace="http://tuscanyscatours.com/" name=”Store”> <component name="Payment"> <implementation.java class="com.tuscanyscatours.payment.impl.PaymentImpl" /> <service name="Payment"> <tuscany:binding.jsonrpcuri="http://localhost:8080/Payment" /> </service> <reference name="creditCardPayment"> <binding.wsuri="http://localhost:8080/CreditCardPayment" /> </reference> </component> <component name="CreditCardPayment"> <implementation.java class="com.tuscanyscatours.payment.creditcard.impl.CreditCardPaymentImpl" /> <service name="CreditCardPayment"> <binding.wsuri="http://localhost:8080/CreditCardPayment" /> </service> </component> </composite>
  • 10. Interface and data modeling Bob and Mary first agree on what data needs to be exchanged between the two components The agreement is then described as an interface (which in turn references the data types) The interface becomes the key contract between the SCA reference and service that are wired together The interfaces can be described using different IDLs such as WSDL (w/ XSD) or Java interface Interface compatibility Things to consider: efficiency, simplicity, remotablity and interoperability.
  • 11. Sample interfaces JAX-WS w/ JAXB (annotations omitted…): public interface CreditCardPayment { String authorize(JAXBCreditCardDetailsTypecreditCard, float amount); } SDO: public interface CreditCardPayment { String authorize(SDOCreditCardDetailsTypecreditCard, float amount); }
  • 12. How are data represented in a composite application? Component implementations Business logic needs to consume/produce data in a representation it supports Handling incoming service calls Calling other services Receiving property values Certain implementation containers impose the data representations (such as DOM for Apache ODE BPEL) Protocol stacks behind the bindings Protocol stacks need to marshal/unmarshal data Internal data representation Wire format (XML, JSON, binary, etc)
  • 13. Data representations between two components at runtime
  • 14. The reality check Enforcing one data binding is not flexible or even not feasible Components can be implemented using different technologies which could impose the data binding requirements, for example, a BEPL engine may require DOM Components may choose to use different data bindings to represent the business data (input/output/fault), for example, JAXB vs. SDO for the XML manipulations. Service providers or consumers are decoupled and it is impossible to have a fixed data binding A service can serve different consumers that can only handle certain data bindings natively The service providers for a given consumer can be replaced The same service can be accessed over different protocols with different data bindings
  • 15. Data transformation Data transformations are required to get two components talk to each other Having application code to deal with technological data transformation is a nightmare and it will defeat the whole purpose and promise of SCA
  • 16. Tuscany’s data binding frameworkIntrospect/transform data without application coding
  • 17. What does the framework need to figure out? Understand the data binding requirements at different places for the data flow Transform the data from one data binding to the other transparently without the interventions from the application developers Separate the data transformation/marshaling/unmarshaling from the business logic
  • 18. Data type introspection Marker interface commonj.sdo.DataObject, org.w3c.dom.Node Annotations JAXB annotations What information is captured? Java class Java generic type Logic type (XML element/type, Mime types, etc)
  • 19. The magic behind the scenes
  • 20. Transformation paths Types of transformations Unmarshal/Deserialize ( InputStream Object ) Marshal/Serialize ( Object OutputStream ) Convert/Transform ( Object  Object) Direct vs. Multi-hops JAXB DOM JAXB  DOM  SDO Weight of a transformation Private vs. Public Some data bindings are not good as intermediaries (data round-trip issues)
  • 21. The complete data flow Customer data come in JSON from HTTP requests The JSON data is unmarshaled into JAXB for the Payment code to consume Payment passes CreditCard (JAXB) to the reference binding layer which in turn converts JAXB into AXIOM The service binding layer unmarshals the XML data into AXIOM and transform it into SDO for the CreditCardPayment The response path is reverse for the data transformations
  • 22. Data bindings out of the box DOM JAXB (JavaBeans are treated as JAXB) SDO JSON StAX …
  • 23. Data bindings for RESTful servicesIntegrating with JAX-RS entity providers
  • 24. JAX-RS entity providers Entity providers supply mapping services between representations and their associated Java types. Entity providers come in two flavors: MessageBodyReader MessageBodyWriter
  • 25. Tuscany’s generic entity providers based on the data binding framework JAX-RS runtime (such as Apache Wink) Tuscany data binding framework Entity Providers Entity Providers Message Writer Message Reader Entity (JAXB, SDO, DOM, etc) InputStream OutputStream
  • 26. Extending the data binding frameworkSupport your favorite data bindings
  • 27. The DataBinding SPI public interface DataBinding { String getName(); booleanintrospect(DataTypedataType, Operation operation); DataTypeintrospect(Object value, Operation operation); WrapperHandlergetWrapperHandler(); Object copy(Object object, DataTypesourceDataType, DataTypetargetDataType, Operation sourceOperation, Operation targetOperation); XMLTypeHelpergetXMLTypeHelper(); }
  • 28. The Transformer SPI public interface PullTransformer<S, R> extends Transformer { R transform(S source, TransformationContext context); } public interface PushTransformer<S, R> extends Transformer { void transform(S source, R sink, TransformationContext context); }
  • 29. Registering your data bindings/transformers META-INF/services/org.apache.tuscany.sca.databinding.DataBinding org.apache.tuscany.sca.databinding.xml.DOMDataBinding;name=org.w3c.dom.Node META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer org.apache.tuscany.sca.databinding.xml.Node2XMLStreamReader;source=org.w3c.dom.Node,target=javax.xml.stream.XMLStreamReader,weight=80 META-INF/services/org.apache.tuscany.sca.databinding.PushTransformer org.apache.tuscany.sca.databinding.xml.Node2OutputStream;source=org.w3c.dom.Node,target=java.io.OutputStream,weight=80
  • 30. Q&AFind more details from:Chapter 9 of Tuscany In SCA Actionhttp://www.manning.com/laws/Save 40% at manning.com.Enter “javaone2010” in the promotional code box at check out.