Hello there,

I have an idea for a Tuscany extension. Would it not be possible to
introduce an additional attribute "package" on the implementation.java
element, the purpose of which would be to specify all classes in
one (or more) Java package(s) as collectively making up the component
implementation. Tuscany could then inject proxies for the referenced
services at any point where the @Reference annotation is used in any
class of the packages. Similarly for @Context etc. (The value of the
"class" attribute would still denote the main class, which provides
the component's external interface.)

Would this make sense in your opinion? Would it be hard to implement?

-- Sebastian


> -----Original Message-----
> From: Simon Nash [mailto:[email protected]]
> Sent: Tuesday, September 21, 2010 8:26 PM
> To: [email protected]
> Subject: Re: Q: Best practice for making service references available
> in a component?
> 
> Millies, Sebastian wrote:
> > Hello there,
> >
> > this is a question about coding style. SCA components are coarse
> grained,
> > i. e. the actual component implementation can consist of many
> classes, only
> > one of which is defined as _the_ component implementation class in
> the composite
> > XML. It is only on this class that annotations like @Reference can be
> used to
> > inject dependencies to other services. It is likely, however, that
> the referenced
> > services really need to be called from one of the other classes in
> the component
> > implementation.
> >
> > How do you pass the values of these reference variables to those
> ordinary Java
> > classes? Is there a special "SCA way" of doing this, perhaps making
> these References
> > globally available in a component, or do you just use normal Java
> programming idioms
> > like property setters, or constructor/method parameters?
> >
> > -- Sebastian
> >
> There isn't any specific SCA way of doing this.  You can treat
> the injected proxy as a regular Java object and pass it around
> however you wish.  However it's useful to bear in mind that SCA
> offers 3 different ways to obtain the reference proxy:
>    as a constructor parameter
>    as a setter parameter
>    as an injected field
> 
> Depending on how you want to pass the value around, one or other
> of these might be more appropriate.
> 
>    Simon

Reply via email to