Hi Sebastien Some comments in line...
Simon On Mon, Sep 20, 2010 at 9:11 AM, Millies, Sebastian <[email protected]> wrote: > Hello there, > > I have two elementary question about interaction patterns in SCA. > In section 4.1 of “Tuscany SCA in Action”, it says: > > <quote> > Remote – The interacting components are running in two different Tuscany > nodes, in > the same or separate Java virtual machines (JVMs), and could be running on > different > physical computers. An SCA binding such as web services or JMS is required to > allow > the components to communicate. Data passed between remote components is passed > by value. > > Local – The interacting components are running in the same node and JVM. The > Tuscany runtime uses in-memory communication in this case. Data passed between > local components is passed by reference. > </quote> > > First question with regard to remote interaction: > I work with JDK 1.6 on Windows XP. Any time I start a node through any of the > APIs (NodeLauncher, SCANodeFactory or SCADomain) I see a new Java process > (JVM) > started up. I would probably expect new JVMs to be started when nodes are started from the domain manager but not in other circumstances. For example, see samples/calculated-distributed. If you run this sample with Maven it runs several nodes in the same JVM (if you run is with Ant you run the nodes in separate JVMs). I do see two JVMs in the maven case but one is for running Maven and the second is running Surefire which is turn runs the sample. > Also, when I want to start a remote node in a distributed domain I > will use java.exe on the command-line. So there seems to be a one-to-one > correspondence > between nodes and JVMs, contrary to the assumption in the above quote. Or is > there an > API that will simply start a new thread and use a separate classloader to > create a new > node, or something? Or is this operating system dependent? If so, in what > system, and how, > could I set up two separate nodes running in the same JVM and interacting > remotely? You should just be able to create a node factory and from that create nodes as required... SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); nodeC = nodeFactory.createSCANodeFromURL("http://localhost:9990/node-config/NodeC"); This is from the distributed calculator so it's pulling the node configuration (which contributions to load and which composite to run) from a URL in this case. There are several createNode type methods which allow you to provide this configuration in different ways. > > Follow-up question with regard to local interactions: If two components > communicate > through local interfaces only, is there anything from a design point of view > against > passing normal Java references as method parameters, e. g. > "addListener(this)" as opposed > to > "addListener(componentContext.createSelfReference(myLocalInterface.class))" ? Local interaction will follow a pass by reference approach if the service interface is not marked as remotable. If the service interface is remotable, i.e. it's a Java interface and has th @Remotable annotation or it's a WSDL interface, then parameters will always be passed by value regarless of whether the reference and service are in the same JVM or not Having said this, whether you pass an SCA service reference or a normal Java reference into a service operation will depend on the parameter type of the operation. createSelfReference() will return a ServiceReference<B>. You could take the ServiceReference and call getService() on it to get a proxy of the Java type. The question then becomes should you pass the proxy or "this"? If you pass the proxy then the SCA runtime handles and calls to the service and gets to apply any policy that's been configured for the service. If you pass "this" then that's not the case. > > -- Sebastian >
