You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@tuscany.apache.org by "Malisetti, Ramanjaneyulu" <Ra...@ca.com> on 2010/02/23 15:05:11 UTC

singleton references in SCA service

We have SCA based service implementation class that contains reference
to other Java class let me refer it as external class. It is pretty much
similar to CalculatorServiceImpl class which holds references to
addservice, subtractService, etc.  Service also has getter methods to
return references of external classes. We are creating SCA node with
service composite and starting Node from simple java application. Now,
if we call methods  of external class on external references from same
java application where Node is created and started,  SCA runtime is
creating new instance of external class for every function invocation on
external   references. I guess this is expected behavior. Is there way
to control in creating instances? Can we make SCA runtime to create
singleton object for references?

Here I have attached sample for your reference.

Regards
Raman <<jms-sdodatabinding-modified.zip>> 

RE: singleton references in SCA service

Posted by "Malisetti, Ramanjaneyulu" <Ra...@ca.com>.
I tried @Scope composite. Nope.

Regards
Raman 

-----Original Message-----
From: Hatfield, Dan [mailto:dan.hatfield@hp.com] 
Sent: Tuesday, 23 February 2010 7:42 PM
To: user@tuscany.apache.org
Subject: RE: singleton references in SCA service

Refer to the @Scope SCA annotation.

________________________________
From: Malisetti, Ramanjaneyulu [Ramanjaneyulu.Malisetti@ca.com]
Sent: Tuesday, February 23, 2010 9:05 AM
To: user@tuscany.apache.org
Subject: singleton references in SCA service


We have SCA based service implementation class that contains reference
to other Java class let me refer it as external class. It is pretty much
similar to CalculatorServiceImpl class which holds references to
addservice, subtractService, etc.  Service also has getter methods to
return references of external classes. We are creating SCA node with
service composite and starting Node from simple java application. Now,
if we call methods  of external class on external references from same
java application where Node is created and started,  SCA runtime is
creating new instance of external class for every function invocation on
external   references. I guess this is expected behavior. Is there way
to control in creating instances? Can we make SCA runtime to create
singleton object for references?

Here I have attached sample for your reference.

Regards

Raman <<jms-sdodatabinding-modified.zip>>


how to deploy the SDO into apache-felix osgi framework?

Posted by ext2 <xu...@tongtech.com>.
  The tuscany-sdo use the eclipse-emf underlying. And the eclipse-emf will
require eclipse-core-runtime bundles. And the eclipse-core-runtime bundle
will require even more other eclipse bundles;

  So if I directly deploy the Tuscany sdo to apache-felix, too many eclipse
bundles will be required. And they wil conflict with apache-felix.(To avoid
this conflict, I just think of change the Tuscany sdo's library and wrapper
the emf jar inside the Tuscany sdo's library. But this will corrupt the
apache-tuscany-sdo 's release jars)

  Do anyone know how to deploy Tuscany sdo into apache-felix osgi framework?

Thanks for any suggestion



Re: singleton references in SCA service

Posted by Simon Laws <si...@googlemail.com>.
Ok, so each time an instance of the SCA component that uses
MyServiceImpl  as its implementation is created a new instance of
MyExternalObject  will also be created. As it stands this component
implementation has stateless scope so this will happen when each
message arrives, I.e. each call to getMyExternalObject() will return a
new instance of MyExternalObject.

Also note that you will only be given access to the actual instance
that was created in very specific circumstances, i.e. when the service
interface/proxy is @Local and pass by reference semantics can be used
or when the service interface is @Remotable but the operation/proxy
has @AllowsPassByReference set and again the runtime chooses to use
pass by reference semantics. There is ongoing discussion to make the
pass by reference semantics work properly in 2.x.

In other cases, the obvious being where a remote binding is involved
such as binding,ws, pass by value semantics are uses and the
MyExternalObject  object will be copied and transformed as it's
marshalled to/from the protocol stack.

Hope this helps

Simon

RE: singleton references in SCA service

Posted by "Malisetti, Ramanjaneyulu" <Ra...@ca.com>.
Yes.

Regards
Raman

-----Original Message-----
From: Simon Laws [mailto:simonslaws@googlemail.com] 
Sent: Wednesday, 24 February 2010 3:13 PM
To: user@tuscany.apache.org
Subject: Re: singleton references in SCA service

So you have a component implementation like...

@Service(MyService.class)
class MyServiceImpl implements MyService {

    private MyExternalObject myExternalObject;

    public MyServiceImpl(){
        myExternalOject = new MyExternalObject();
    }

    public void myMethod (){
        ...
    }

    public MyExternalObject getMyExternalObject(){
        return myExternalObject;
    }
}

Just off the top of my head so can't say this actually compiles but is
this what you're getting at?

Simon


Re: singleton references in SCA service

Posted by Simon Laws <si...@googlemail.com>.
So you have a component implementation like...

@Service(MyService.class)
class MyServiceImpl implements MyService {

    private MyExternalObject myExternalObject;

    public MyServiceImpl(){
        myExternalOject = new MyExternalObject();
    }

    public void myMethod (){
        ...
    }

    public MyExternalObject getMyExternalObject(){
        return myExternalObject;
    }
}

Just off the top of my head so can't say this actually compiles but is
this what you're getting at?

Simon

RE: singleton references in SCA service

Posted by "Malisetti, Ramanjaneyulu" <Ra...@ca.com>.
I found alternative way of achieving same. That is, instead of having
reference through component, we are having external class as field of
SCA service implementation class and instantiating this object in SCA
service constructor. 

Does it have any side effects? I would like take your comments and
suggestions with this approach.

Regards
Raman

-----Original Message-----
From: Malisetti, Ramanjaneyulu 
Sent: Tuesday, 23 February 2010 7:58 PM
To: user@tuscany.apache.org
Subject: RE: singleton references in SCA service

I tried @Scope composite. Nope.

Regards
Raman 

-----Original Message-----
From: Hatfield, Dan [mailto:dan.hatfield@hp.com] 
Sent: Tuesday, 23 February 2010 7:42 PM
To: user@tuscany.apache.org
Subject: RE: singleton references in SCA service

Refer to the @Scope SCA annotation.

________________________________
From: Malisetti, Ramanjaneyulu [Ramanjaneyulu.Malisetti@ca.com]
Sent: Tuesday, February 23, 2010 9:05 AM
To: user@tuscany.apache.org
Subject: singleton references in SCA service


We have SCA based service implementation class that contains reference
to other Java class let me refer it as external class. It is pretty much
similar to CalculatorServiceImpl class which holds references to
addservice, subtractService, etc.  Service also has getter methods to
return references of external classes. We are creating SCA node with
service composite and starting Node from simple java application. Now,
if we call methods  of external class on external references from same
java application where Node is created and started,  SCA runtime is
creating new instance of external class for every function invocation on
external   references. I guess this is expected behavior. Is there way
to control in creating instances? Can we make SCA runtime to create
singleton object for references?

Here I have attached sample for your reference.

Regards

Raman <<jms-sdodatabinding-modified.zip>>


RE: singleton references in SCA service

Posted by "Hatfield, Dan" <da...@hp.com>.
Refer to the @Scope SCA annotation.

________________________________
From: Malisetti, Ramanjaneyulu [Ramanjaneyulu.Malisetti@ca.com]
Sent: Tuesday, February 23, 2010 9:05 AM
To: user@tuscany.apache.org
Subject: singleton references in SCA service


We have SCA based service implementation class that contains reference to other Java class let me refer it as external class. It is pretty much similar to CalculatorServiceImpl class which holds references to addservice, subtractService, etc.  Service also has getter methods to return references of external classes. We are creating SCA node with service composite and starting Node from simple java application. Now, if we call methods  of external class on external references from same java application where Node is created and started,  SCA runtime is creating new instance of external class for every function invocation on external   references. I guess this is expected behavior. Is there way to control in creating instances? Can we make SCA runtime to create singleton object for references?

Here I have attached sample for your reference.

Regards

Raman <<jms-sdodatabinding-modified.zip>>