...
- XML/Java databinding frameworks
- SDO
- JAXB
- XMLBeans
- Castor
- AxiomAXIOM
- JavaBeansFastInfoset
- XML Parsing Technologies
- SAX (InputSource, ContentHandler)
- DOM (Node)
- StAX (XMLStreamReader/XMLStreamWriter/XMLEventReader/XMLEventWriter)
- I/O
- InputStream/OutputStream
- Reader/Writer
- byte[] or String
- Other
- JavaBeans
- Simple Java Types
- JSON
Note | ||
---|---|---|
| ||
Please note the I/O kind of databindings are further defined by the type of the content. For example, the InputStream can feed XML stream, fastinfoset, or something else. The context of a String can be a XML document, a JSON string or a CSV. |
...
interfaces for services and references are the contracts for SCA assembly.
1. Incoming data for component implementation
2. Interace mapping
- interface.java <--> interface.java
- interface.wsdl <--> interface.java
- interface.wsdl <--> interface.wsdl
- interface.* <--> other
Mapping from interface.wsdl to interface.java
JaxbAddress getAddress(JaxbCustomer customer)
SdoAddress getAddress(SdoCustomer customer)
Data Transformations
How to transform data across databindings
Data Transformations
How to transform data across databindings
- A databinding is a terminal for the data transformation
- Three types of databindings depending on how the data is represented by the databinding
- Some databindings can feed the data for consumption
- Some databindings serve a sink to receive data
- Some databindings
- A databinding is a terminal for the data transformation
- Three types of databindings depending on how the data is represented by the databinding
- Some databindings can feed the data for consumption
- Some databindings serve a sink to receive data
- Some databindings can bridge the sink so that data coming into the sink can be consumed by others
Scenario 1: Source --> Source
Scenario 2: Source --> Sink
Scenario 3: Sink --> Source (Pipe)
How to use databindings?
Declare the data binding for the interfaces
- Data Binding requirement can be expressed as:
- SCDL extension
Code Block |
---|
<interface.wsdl ...>
<db:databinding xmlns:db="http://tuscany.apache.org/xmlns/sca/databinding/1.0" name="commonj.sdo.DataObject">
</interface.wsdl>
|
Java annotations for a remotable interface
- @DataType can be applied to remotable interfaces at type and method level
@Remotable
@DataType(name="org.w3c.dom.Node")
public interface Interface2
the data binding for the interfaces
- Data Binding requirement can be expressed as:
- SCDL extension
Code Block |
---|
@Remotable
public interface MyInterface {
|
Code Block |
{ Node call(Node msg); @DataType(name="javax.xml.stream.XMLStreamReader") XMLStreamReader call1(XMLStreamReader msg); } |
Fine-grained databinding control
Java annotations for a remotable interface
What's behind the magic?
Load and build the data binding metadata
...
- The transformers are registered and selected using the following algorithm.
- The data transformation capabilities for various databindings can be nicely modeled as a weighted, directed graph with the following rules. (Illustrated in the attached diagram).
- Each databinding is mapped to a vertex.
- If databinding A can be transformed to databinding B, then an edge will be added from vertex A to vertex B.
- The weight of the edge is the cost of the transformation from the source to the sink.
- In the data interceptor on the wire, if we find out that the data needs to be transformed from databinding A to databinding E. Then we can apply Dijkstra's Shortest Path Algorithm to the graph and figure the most performed path. It can be A->E, or A>C->E depending on the weights. If no path can be found, then the data cannot be mediated.
Transform data - Direct transformation
- Multi-hop transformation
Deal with different IDLs
Dealing with WSDL/XSD based IDLs
- SCA allows the interfaces to be defined using various IDLs, for example, java interface or WSDL portType
- IDLs may have different ways to represent the input/output/fault data
- The databinding framework is designed to support the transformation across IDLs
- Some special databindings are internally used for this purpose:
- idl:input
- idl:ouput
Dealing with WSDL/XSD based IDLs
- WrapperHandler
- Provide WrapperStyle WSDL wrapping/unwrapping support
...