Hi,

The following code shows what I have in mind for the standalone case:

public class SCAClientTestCase extends TestCase {

  private Node node;

  @Override
  protected void setUp() throws Exception {
NodeConfiguration config = ...; // Create or discover the node configuration, the domain URI will be part of the node config node = NodeFactory.newInstance().createNode(config); // Create a standalone node
      /*
Start the node. The node instance will be associated with some context, such as the thread, the classloader, the OSGi bundle. It can also potentially inject the default factory to SCAClientFactory class in the same scope
      */
      node.start();
  }

  public void testInvoke() throws Exception {
      /*
Create the SCAClient, some context can be passed in through the classloader or properties to help the runtime to associate the client with the node in scope
      */
SCAClient client = SCAClienfFactory.newInstance(); // The SCAClient can be implemented by NodeImpl as well
      /*
We might check if the domain URI matches the Node. If not, an exception can be thrown as the Node cannot deal with that SCA domain
      */
HelloworldService service = client.getService(HelloworldService.class, "HelloworldComponent", "urn:someDomainUri");
      assertEquals("Hello petra", service.sayHello("petra"));
  }

  @Override
  protected void tearDown() throws Exception {
      node.stop();
  }

}

Thanks,
Raymond

From: ant elder
Sent: Tuesday, April 14, 2009 4:14 AM
To: dev@tuscany.apache.org
Subject: Re: SCAClient API spec proposal


One general comment is that it i'm finding it a little hard to tell in
places if you're talking about things that already exist in the current code
or if you're talking about things we might be able to do in the future to
support this. I also wonder if we may be looking at this from different
angles so talking across each other.

So using the simplest scenario of a standalone/offline mode like we use in
most itests/samples could you post some pseudo code of what this might look
like? I'll post again here the example test i used earlier which is using
the Node APIs (the existing impl would need to be modified to work with
SCAClient and provide some way to give the Node a domain uri) but i'm now
wondering if we should have some sort of SCADomain API, but could you/others
modify this test code to show what you're thinking this could work like?

public class SCAClientTestCase extends TestCase {

  private Node node;

  @Override
  protected void setUp() throws Exception {
      node = NodeFactory.newInstance().createNode();

  }

  public void testInvoke() throws Exception {
      HelloworldService service =
SCAClientFactory.newInstance().getService(HelloworldService.class,
"HelloworldComponent", "urn:someDomainUri");
      assertEquals("Hello petra", service.sayHello("petra"));
  }

  @Override
  protected void tearDown() throws Exception {
      node.stop();
  }

}

...ant

Reply via email to