Thank for your answers, for the first point i have another questions: if component is running, is it possible to obtain a reference to its service from a non sca-client code? The second point is connect to the firstm, since i cannot ( or i don't know) to obtain a reference to service from non sca client of a component that is running (called A) , i launch from non sca client a component (called B) that use the injection to use the first component (A), more accurately B use A to obtain a ServiceReference of another Component (C) and pass this reference to the rest of non sca method/code of the library, if i use this reference in B method it's all ok, but if I use this reference out of B method i get the error, i post the method example Non Sca Client Code:
nodelauncher.createnodeFromURL(...) //launch B ServiceReference Cserv=B.getCreferencefromA(); Cservice C=(Cservice) Cserv.getService(); <----- this get error NullpointerException the B.getCreferenceFromA() code is something like this 1 row: ServiceReference temp= A.getCServRef(); 2 row: return(temp); but if i modify the code like this 1 row: ServiceReference temp= A.getCServRef(); 2 row: Cservice C=(Cservice) Cserv.getService(); 3 row: return(temp); //is not an error i return temp all it's ok that i don't know is how can the presence of 2 row eliminate the NullpointerException. Thanks 2009/7/23 Simon Laws <[email protected]> > Hi Antonio > > ..snip > > but i don't know how obtained the "context". Is there an api that i've > not > > seen or an example how to do it? thanks a lot. > > > > There are two ways to access SCA component from non-SCA applications. > > Firstly you could put a remote binding, like web services or RMI, on > the SCA service and then access the service remotely from you client. > I'm assuming in this case that you've started a Tuscany node from the > command line to run the application > > Secondly, if you're starting a node programmatically, then we provide > a client API for retrieving proxies to local SCA services. > Communication between the proxy and the service will use the SCA > binding in this case. You can see an example of how to get a proxy > using the Client API here > ( > http://svn.apache.org/repos/asf/tuscany/branches/sca-java-1.x/samples/calculator/src/test/java/calculator/CalculatorTestCase.java > ). > This example also shows the node being created programmatically using > the node factory. > > > > > 2) I have this scenario: 3 Component A, B,C C send is ServiceReference > to B > > (Cref=context.createSelfReference(..) and B.registerReference(Cref)), A > is a > > part of code non SCA for example ia have a library that when it's > necessary > > launch A compoentn (nodelauncher.CreateNode(...)) A receive a Cref from > B, > > if A use Cref to access C service it's Ok, bui if i use Cref in other > > library method (example: ReceivedCref=A.getCref(); > > ReceiveCref.getService().somemethod()) i receive a > > java.lang.NullPoinerException. How can i use a Cref without using A > services > > in other library method if is it possible? > > > > I think it should be possible assuming that the other library has > access to the Tuscany libraries. Where is the null pointer happening? > > Regards > > Simon >
