Millies, Sebastian wrote:
no, it's probably not worth the trouble.

My concern was especially with infrastructure services (e. g. a
ConfigurationReader), which should be available to ordinary Java-Classes.
Such services are typically stateless, and the service methods don't
need arguments that depend on the calling service's component context.

Therefore, it is simple to provide a composite-scoped container component, which makes a reference to the infrastructure service available as a static Java variable. The container itself exposes no service interface at all, it's really just there to be loaded by the Tuscany runtime and make the target reference globally available. Perhaps this isn't pretty, but it works for me.

This seems like a reasonable approach as long as everything is running
in the same JVM.  One way to ensure this would be to define a local
service on the composite-scoped infrastructure component and wire the
other components to this service.

By the way, an interesting "feature" (actually a limitation) of SCA 1.0
and Tuscany 1.x is that it isn't possible to have a Java component that
exposes no services.  If no service interfaces are defined, the
implementation class will automatically be exposed as a local service.
You could wire the other components to this service, or you could
define references with autowire and multiplicity="1..1" to save the
trouble of explicitly writing the wire targets.

The SCA 1.1 spec has taken care of this unintended anomaly, so in
SCA 1.1 and Tuscany 2.x it is possible to create a Java component with
no services, only references.

  Simon

-- Sebastian


-----Original Message-----
From: Simon Nash [mailto:[email protected]]
Sent: Wednesday, September 22, 2010 10:56 AM
To: [email protected]
Subject: Re: Q: Best practice for making service references available
in a component?

[snip]
Using the approach described above, I can see that it would be possible
to make this work.  I'm still not convinced that the benefit is worth
the complexity.

   Simon

[snip]


Reply via email to