You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@tuscany.apache.org by Nick May <nm...@bigpond.net.au> on 2008/09/02 02:44:05 UTC

Reference loading?

Hi,

I have a question about when references are bound...

I have a composite which consists of four components, one ReplicaManager and three Replicas. The manager promotes a single service. The replicas are bound to the manager with a single reference. eg.

<reference name="children" multiplicity="1..*" target="Replica1 Replica2 Replica3"/>

On the first call to the service the manager's 'children' property is successfully populated with an array of Replicas. However, it appears that this property is repopulated on every call to the manager's service. 

Is the manager re-initialised on every call, or are the references rebound? 
Is there a way to specify that a reference is bound on initialisation only?

Thanks,

Nick May


Re: Reference loading?

Posted by ant elder <an...@gmail.com>.
On Tue, Sep 2, 2008 at 1:44 AM, Nick May <nm...@bigpond.net.au> wrote:

> Hi,
>
> I have a question about when references are bound...
>
> I have a composite which consists of four components, one ReplicaManager
> and three Replicas. The manager promotes a single service. The replicas are
> bound to the manager with a single reference. eg.
>
> <reference name="children" multiplicity="1..*" target="Replica1 Replica2
> Replica3"/>
>
> On the first call to the service the manager's 'children' property is
> successfully populated with an array of Replicas. However, it appears that
> this property is repopulated on every call to the manager's service.
>
> Is the manager re-initialised on every call, or are the references rebound?
> Is there a way to specify that a reference is bound on initialisation only?
>
> Thanks,
>
> Nick May
>
>
Try adding the annotation @Scope("COMPOSITE") to ReplicaManager. By default
the scope is "STATELESS" which means a new instance is created and
initialized for each request. For more info about @Scope see section 1.2.4
of the SCA Java Annotations and APIs spec -
http://www.osoa.org/display/Main/Service+Component+Architecture+Specifications

   ...ant