Thanks Guys!. My requirement is to inject a non-SCA object into a singleton
SCA service composite. So, as Simon explained, if a
setMyObject(my_non_sca_object) works on an SCA service reference, then that
does my job!

Thanks & Regards,
Anil

On Thu, Feb 25, 2010 at 11:38 AM, Raymond Feng <[email protected]> wrote:

>  Hi,
>
> Are you trying to get a self reference to this composite-scoped service? If
> so, you can do the following:
>
> @Scope("COMPOSITE")
> @Service(MySevice.class)
> public class MyServiceImpl {
>
> @Context
> protected ComponentContext componentContext;
>
> ...
>
> ServiceReference<MyService> ref =
> componentContext.createSelfReference(MyService.class);
>
> To get the service reference in another component, you can do:
>
> @Reference
> protected ServiceReference<MyService> myService; // It will be injected by
> Tuscany if it's wired to MyService component.
>
> Thanks,
> Raymond
>
>  *From:* Blue Diamond <[email protected]>
> *Sent:* Wednesday, February 24, 2010 9:49 PM
> *To:* [email protected]
> *Subject:* object reference to a service
>
> Hi,
>
> I have a @scope(composite) annotated component (service). This is a
> singleton for me (correct me if I am wrong) and no matter how many clients
> call the service operations, its the same service instance that's going to
> handle them.
>
> SCA API provides a way to obtain service reference to this component
> through say SCANode.getServiceReference().
>
> But is there a way I can obtain the object reference to this instantiated
> service instance? I understand that SCA has boundaries, but is there any way
> by which this can be done?
>
> SCA creates a component, I want to obtain its object reference (I want to
> inject some other non-SCA created object into it). Is this doable?
>
> Thanks,
> Anil
>

Reply via email to