Package org.apache.tuscany.sca.node

Examples of org.apache.tuscany.sca.node.Node


    @Test
    public void testNodeWithAbsoluteCompositeURI() throws MalformedURLException {
        NodeFactory factory = new NodeFactoryImpl();
        Contribution contribution = new Contribution("c1", new File("target/test-classes").toURL().toString());
        String compositeURI = new File("target/test-classes/HelloWorld.composite").toURL().toString();
        Node node = factory.createNode(compositeURI, contribution);
        testNode(node);
    }
View Full Code Here


    }

    @Test
    public void testAutoDestroy() throws Exception {
        NodeFactory nf = NodeFactory.newInstance();
        Node node = nf.createNode();
        node.start();
        Assert.assertTrue(((NodeFactoryImpl)nf).inited);
        node.stop();
        Assert.assertFalse(((NodeFactoryImpl)nf).inited);
       
        nf = NodeFactory.newInstance();
        nf.setAutoDestroy(false);
        node = nf.createNode();
        node.start();
        Assert.assertTrue(((NodeFactoryImpl)nf).inited);
        node.stop();
        Assert.assertTrue(((NodeFactoryImpl)nf).inited);
       
    }
View Full Code Here

                                                     "node.xml");
*/
        NodeFactory nodeFactory = NodeFactory.newInstance();
       
        URL nodeConfigURL = nodeDirectory.toURI().resolve("node.xml").toURL();
        Node node = nodeFactory.createNode(nodeConfigURL);
       
        try {
            node.start();
           
            // for testing we're going to set up a deamon that listens for
            // a shutdown message on a specified port (well it actually just
            // waits for a client to connect to the port as that's all we need
            // for now). If no port is specified then just stop straight away
           
            if (deamonPort >= 0){
                // Its a runtime that has to act as a deamon
                ServerSocket serverSocket = null;
                   
                try {
                    serverSocket = new ServerSocket(deamonPort);
                } catch (IOException e) {
                    System.out.println("Can't create a ServerSocket on port: " + deamonPort);
                    return;
                }
               
                // all we're doing here is waiting for a connection. If we wanted to implement
                // a real deamon we should perhaps listen to what's coming in over the resulting socket
                // and see if a shutdown has been requested
                Socket clientSocket = null;
                try {
                    clientSocket = serverSocket.accept();
                } catch (IOException e) {
                    System.out.println("Accept failed on port: " + deamonPort);
                    return;
                }
            }
       
        } finally {
            node.stop();
        }
    }
View Full Code Here

     * One NodeFactory and two nodes
     */
    @Test
    public void testOneFactoryTwoNodes() {
        NodeFactory factory1 = NodeFactory.getInstance();
        Node node1 = createClientNode(factory1);
        Node node2 = createServiceNode(factory1);
        node1.start();
        node2.start();
        try {
            runClient(node1);
        } finally {
            node2.stop();
            node1.stop();
            factory1.destroy();
        }
    }
View Full Code Here

            factory.createNodeConfiguration().setDomainURI(DOMAIN_URI).setURI("node2").addContribution("c2", ROOT)
                .addDeploymentComposite("c2", SERVICE).setDomainRegistryURI(REGISTRY_URI)
                .addBinding(WebServiceBinding.TYPE, "http://localhost:8085/").addBinding(SCABinding.TYPE,
                                                                                         "http://localhost:8085/");

        Node node2 = factory.createNode(config2);
        return node2;
    }
View Full Code Here

        NodeConfiguration config1 =
            factory.createNodeConfiguration().setDomainURI(DOMAIN_URI).setURI("node1").addContribution("c1", ROOT)
                .addDeploymentComposite("c1", CLIENT).setDomainRegistryURI(REGISTRY_URI)
                .addBinding(WebServiceBinding.TYPE, "http://localhost:8085/").addBinding(SCABinding.TYPE,
                                                                                         "http://localhost:8085/");
        Node node1 = factory.createNode(config1);
        return node1;
    }
View Full Code Here

     * Two node factories and two nodes
     */
    @Test
    public void testTwoFactoriesTwoNodes() throws Exception {
        NodeFactory factory1 = NodeFactory.newInstance();
        Node node1 = createClientNode(factory1);
        NodeFactory factory2 = NodeFactory.newInstance();
        Node node2 = createServiceNode(factory2);
        node1.start();
        node2.start();
        Thread.sleep(1000);
        try {
            // This call doesn't require the Local service, it should be successful
            createCustomer(node1);
            try {
                runClient(node1);
                // We cannot make local call to remote endpoints
                Assert.fail("ServiceRuntimeException should have been thrown.");
            } catch (ServiceRuntimeException e) {
                // ignore
            }
        } finally {
            node2.stop();
            node1.stop();
            factory2.destroy();
            factory1.destroy();
        }
    }
View Full Code Here

        NodeFactory factory = NodeFactory.getInstance();
        NodeConfiguration config1 =
            factory.createNodeConfiguration().setDomainURI(DOMAIN_URI).setURI("node1").addContribution("c1", ROOT)
                .addDeploymentComposite("c1", CLIENT).addDeploymentComposite("c1", SERVICE);

        Node node1 = factory.createNode(config1);
        node1.start();
        try {
            runClient(node1);
        } finally {
            node1.stop();
            factory.destroy();
        }
    }
View Full Code Here

*/
public class CalculatorClient {
    public static void main(String[] args) throws Exception {       

      NodeFactory factory = NodeFactory.newInstance();
        Node node = factory.createNode(new File("src/main/resources/spring/annotations/Calculator.composite").toURI().toURL().toString(),
                new Contribution("TestContribution", new File("src/main/resources/spring/annotations/").toURI().toURL().toString()));
        node.start();
             
        CalculatorService calculatorService =
            node.getService(CalculatorService.class, "CalculatorServiceComponent");
       
        System.out.println("3 + 2=" + calculatorService.add(3, 2));
        System.out.println("3 - 2=" + calculatorService.subtract(3, 2));
        System.out.println("3 * 2=" + calculatorService.multiply(3, 2));
        System.out.println("3 / 2=" + calculatorService.divide(3, 2));

        node.stop();
        System.out.println("Bye");
    }
View Full Code Here

*/
public class CalculatorClient {
    public static void main(String[] args) throws Exception {       
       
      NodeFactory factory = NodeFactory.newInstance();
        Node node = factory.createNode(new File("src/main/resources/context/access/ContextAccess.composite").toURI().toURL().toString(),
                new Contribution("TestContribution", new File("src/main/resources/context/access/").toURI().toURL().toString()));
        node.start();
       
        // Code: To access the Spring Application Context instance
        ApplicationContext ctx = SCAApplicationContextProvider.getApplicationContext();
        if (ctx.containsBean("CalculatorServiceBean"))
            System.out.println("CalculatorServiceBean is now available for use...");
             
        CalculatorService calculatorService =
            node.getService(CalculatorService.class, "CalculatorServiceComponent");
               
        System.out.println("3 + 2=" + calculatorService.add(3, 2));
        System.out.println("3 - 2=" + calculatorService.subtract(3, 2));
        System.out.println("3 * 2=" + calculatorService.multiply(3, 2));
        System.out.println("3 / 2=" + calculatorService.divide(3, 2));

        node.stop();
    }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.node.Node

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.