Package org.apache.tuscany.sca.node

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


*/
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/imports/ContextImports.composite").toURI().toURL().toString(),
                new Contribution("TestContribution", new File("src/main/resources/context/imports/").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();
    }
View Full Code Here


public class StockQuoteServer {

    public static void main(String[] args) throws Exception {

      NodeFactory factory = NodeFactory.newInstance();
        Node node = factory.createNode(new File("src/main/resources/context/multiple/MultipleContext.composite").toURI().toURL().toString(),
                new Contribution("TestContribution", new File("src/main/resources/context/multiple/").toURI().toURL().toString()));
        node.start();
       
        // Method 1: To access the Spring Application Context instance
        ApplicationContext ctx = SCAApplicationContextProvider.getApplicationContext();
        if (ctx.containsBean("StockQuoteServiceBean"))
            System.out.println("StockQuoteServiceBean is now available for use...");       
       
        System.out.println("Press Enter to Exit...");
        Thread.sleep(1000);

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

    @Test
    public void test_providedNameServer() {
        TestCorbaHost.setCorbaHost(new TnsDefaultCorbaHost());
        try {
            // just make sure we can obtain and use the reference with success
            Node node = NodeFactory.getInstance().createNode("ScenarioFive.composite", getClass().getClassLoader()).start();
            ScenarioFive scenarioFive =
                node.getService(ScenarioFiveComponent.class, "ScenarioFive").getScenarioFive();
            scenarioFive.doNothing();
            node.stop();
        } catch (Exception e) {
            e.printStackTrace();
            fail();
        }
    }
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

            System.setProperty("java.security.auth.login.config", CalculatorClient.class.getClassLoader()
                .getResource("implementation/policies/CalculatorJass.config").toString());
        }

        NodeFactory factory = NodeFactory.newInstance();
        Node node = factory.createNode(new File("src/main/resources/implementation/policies/ImplementationPolicies.composite").toURI().toURL().toString(),
                new Contribution("TestContribution", new File("src/main/resources/implementation/policies/").toURI().toURL().toString()));
        node.start();
             
        CalculatorService calculatorService =
            node.getService(CalculatorService.class, "CalculatorServiceComponent");

        // Calculate
        System.out.println("Calling CalculatorServiceComponent configured with 'logging' " +
                "policy for subtract and divide operations...");
        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));
       
        calculatorService =
            node.getService(CalculatorService.class, "AnotherCalculatorServiceComponent");

        // Calculate
        System.out.println("Calling CalculatorServiceComponent configured with 'logging' " +
                "for all operations in the implementation...");
        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

        if (!isSCABundle(bundle)) {
            return;
        }
        try {
            NodeConfiguration configuration = factory.getConfiguration(bundle, null);
            Node node = factory.createNode(configuration);
            node.start();
        } catch (Throwable e) {
            logger.log(Level.SEVERE, e.getMessage(), e);
        }
    }
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.