It's already possible to configure it through the NodeFactory either through
the newInstance() or configure(). We can pass in a Map<String, Map<String,
String>>, the first level key is
"org.apache.tuscany.sca.binding.sca.provider.SCABindingMapper" and the
second level key is "mappedBinding".
Thanks,
Raymond
--------------------------------------------------
From: "ant elder" <[email protected]>
Sent: Wednesday, March 10, 2010 7:05 PM
To: <[email protected]>
Subject: Re: Mapping binding.sca to any bindings by configuration
On Wed, Mar 3, 2010 at 4:18 PM, ant elder <[email protected]> wrote:
On Wed, Mar 3, 2010 at 12:35 PM, Raymond Feng <[email protected]>
wrote:
Hi,
I have checked in the changes to allow us to map binding.sca to any of
the
bindings by configuration.
It turned out that the trick is as simple as follows:
* Add a new utility SPI
org.apache.tuscany.sca.binding.sca.provider.SCABindingMapper which
contains
the following methods to map Endpoint or EndpointReference with
binding.sca
to other bindings:
public RuntimeEndpoint map(RuntimeEndpoint endpoint);
public RuntimeEndpointReference map(RuntimeEndpointReference
endpointReference);
boolean isRemotable(); // Control if an binding.sca endpoint with
remotable interface should be published to the remote protocol
* Provide a default implementation
org.apache.tuscany.sca.binding.sca.provider.DefaultSCABindingMapper
* Receive the mapped binding QName via the
org.apache.tuscany.sca.binding.sca.provider.SCABindingMapper.mappedBinding
attribute or system property. By default, it's mapped to sca:binding.ws.
* Create an instance of binding and copy all attributes from
binding.sca
into the mapped binding (Simply speaking, <binding.sca/> is pretty much
like
<binding.xyz/>)
* Map endpoint and endpoint reference by replacing the SCABinding with
the
mapped binding instance
* Invoke the binding builder to build the mapped binding
* Create delegating SCA reference/service provider that delegates the
calls
to the mapped binding provider
Now you can plug in binding.sca using one of the following ways:
* Set the binding type via
org.apache.tuscany.sca.binding.sca.provider.SCABindingMapper.mappedBinding
system property
* Set the binding type via
org.apache.tuscany.sca.binding.sca.provider.SCABindingMapper.mappedBinding
attribute from the NodeFactory
* Add a new
META-INF/org.apache.tuscany.sca.binding.sca.provider.SCABindingMapper
with
the mappedBinding attribute and higher ranking (this also allows a
customized SCABindingMapper to replace the default one from Tuscany).
With this improvement, we can now remove the following modules (merging
the
tests into itest) as well as DistributedSCABinding model.
tuscany-binding-sca-axis2-runtime
tuscany-binding-sca-runtime-rmi
tuscany-sca-client-rmi
If there is no objection, I'll clean them up as the next step.
[1] http://svn.apache.org/viewvc?rev=918261&view=rev
Without having looked in detail that all sounds good to me. One thing
that would be nice would be instead of having only the WS binding be
the default would be to check that is available first and if not try
something else like the RMI binding, so then it would still work
automatically with no extra config needed even if the WS binding isn't
available on the classpath but the RMI binding is (which makes simple
demos easier as RMI has far fewer dependencies).
...ant
I've updated this to automatically try using binding.rmi if binding.ws
isn't available.
It would also be nice to be able to set the default binding from a
NodeFactory config property instead of a System property so I'll look
at doing that too.
...ant