Package org.apache.tuscany.sca.node

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


        System.out.println("receiveResult on thread " + Thread.currentThread());
        System.out.println("Result: " + result)// callback from the server
    }

    public static void main(String[] args) throws Exception {
        SCANode node = SCANodeFactory.createNodeWithComposite("myapp.composite");
        MyClient myClient = node.getDomain().getService(MyClient.class, "MyClientComponent");
        myClient.aClientMethod();
        Thread.sleep(5000)// don't exit before callback arrives
        System.out.println("Closing the domain");
        node.destroy();
    }
View Full Code Here


*/
public class CallbackServer {

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

        SCANode node = SCANodeFactory.createNodeWithComposite("callbackws.composite");

        try {
            System.out.println("Callback server started (press enter to shutdown)");
            System.in.read();
        } catch (IOException e) {
            e.printStackTrace();
        }

        node.destroy();
        System.out.println("Callback server stopped");
    }
View Full Code Here

            // TODO - not caching local domains as currently the local domain can
            //        - only handle one node
            //        - provides the management endpoint for that node
           
            // Add the dummy node as there will be no real node in this case
            SCANode scaNode = new SCADummyNodeImpl(scaDomain);
            ((SCADomainProxyImpl)scaDomain).addNode(scaNode);
        }
        return scaDomain;
    }
View Full Code Here

     * @param args
     */
    public static void main(String[] args) {
        System.out.println("Tuscany starting...");

        SCANode node = null;
        try {
            String compositeFile = args[0];
            System.out.println("Composite: " + compositeFile);
           
            SCANodeFactory nodeFactory = SCANodeFactory.newInstance();
            node = nodeFactory.createSCANode(null, "http://localhost:9999");

            ClassLoader classLoader = SCANodeLauncher.class.getClassLoader();
            URL contribution = SCAContributionUtil.findContributionFromResource(classLoader, compositeFile);
            node.addContribution(compositeFile, contribution);
           
            node.addToDomainLevelComposite(compositeFile);
           
            node.start();
           
        } catch (Exception e) {
            System.err.println("Exception starting node");
            e.printStackTrace();
            System.exit(0);
        }
       
        System.out.println("Node ready...");
        System.out.println("Press enter to shutdown");
        try {
            System.in.read();
        } catch (IOException e) {
        }
       
        try {
            node.destroy();
        } catch (Exception e) {
            System.err.println("Exception stopping node");
            e.printStackTrace();
        }
       
View Full Code Here

    //@Test
    public void testNodeMemoryUseage() throws Exception {  
       
        ClassLoader cl = NodeMemoryTestCase.class.getClassLoader();
        SCANodeFactory nodeFactory;
        SCANode   node;
        CalculatorService calculatorServiceB;
        SubtractService subtractServiceC;

        for(int i=0; i < 40; i++) {
           
            nodeFactory = SCANodeFactory.newInstance();
            node = nodeFactory.createSCANode("http://localhost:8200/node", null);
            node.addContribution("nodeB", cl.getResource("nodeB/"));
            node.addContribution("nodeC", cl.getResource("nodeC/"));
            node.addToDomainLevelComposite(new QName("http://sample", "CalculatorB"));
            node.addToDomainLevelComposite(new QName("http://sample", "CalculatorC"));
            node.start();  
           
            calculatorServiceB = node.getDomain().getService(CalculatorService.class, "CalculatorServiceComponentB");
            subtractServiceC = node.getDomain().getService(SubtractService.class, "SubtractServiceComponentC");
           
            for(int j=0; j < 20; j++){
                Assert.assertEquals(calculatorServiceB.subtract(3, 2), 1.0);
                Assert.assertEquals(subtractServiceC.subtract(3, 2), 1.0);
            }
           
            node.destroy();
        }
       
        //com.ibm.jvm.Dump.HeapDump();         
    }         
View Full Code Here

    protected boolean isExplodedContribution(File folder) {
        return getJARsInFolder(folder).length < 1 && containsCompositeFile(folder);
    }

    protected void addContributionFolder(File folder) {
        SCANode repoNode;
        try {
            repoNode = createNode(cp);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
       
        try {
            repoNode.addContribution(folder.toURL().toString(), folder.toURL());
            logger.info("added contribution folder: " + folder.toURL());
        } catch (Exception e) {
            e.printStackTrace();
            logger.log(Level.WARNING, "exception adding contribution folder: " + folder, e);
        }
View Full Code Here

            logger.log(Level.WARNING, "exception adding contribution folder: " + folder, e);
        }
    }

    protected URL[] addTopLevelJARs(File repository) {
        SCANode repoNode;
        try {
            repoNode = createNode(cp);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
       
        URL[] jars = getJARsInFolder(repository);
        for (URL jarURL : jars) {
            try {
                repoNode.addContribution(jarURL.toString(), jarURL);
                logger.info("added contribution: " + jarURL);
            } catch (NodeException e) {
                e.printStackTrace();
                logger.log(Level.WARNING, "exception adding contribution: " + jarURL, e);
            }
View Full Code Here

    protected URL[] addSubFolders(File repository) {
        URL[] folders = getSubFolders(repository);
        for (URL folderURL : folders) {
            try {
                SCANode scaNode = createNode(cp + "/" + folderURL);
                scaNode.addContribution(folderURL.toString(), folderURL);
                logger.info("added contribution: " + folderURL);
            } catch (Exception e) {
                e.printStackTrace();
                logger.log(Level.WARNING, "exception adding contribution: " + folderURL, e);
            }
View Full Code Here

        }
        return folders;
    }

    public void addContribution(URL contributionURL) throws NodeException {
        SCANode scaNode = createNode(cp + "/" + contributionURL);

        if (started && domainName == null) {
            scaNode.stop();
        }
       
        scaNode.addContribution(contributionURL.toString(), contributionURL);
        logger.info("added contribution: " + contributionURL);
       
        if (started) {
            if (domainName == null) {
                scaNode.addToDomainLevelComposite((QName)null);
                scaNode.start();
            } else {
                scaNode.addToDomainLevelComposite((QName)null);
                scaNode.start();
            }
        }
    }
View Full Code Here

    /**
     * Creates a new SCA Node unless running as a standalone node in
     * which case just a single node is used to run for all contributions
     */
    protected SCANode createNode(String nodeName) throws NodeException {
        SCANode scaNode;

        if (domainName == null || domainName.length() < 1) {
            if (scaNodes.size() < 1) {
                scaNode = scaNodeFactory.createSCANode(nodeName, null);
                scaNodes.add(scaNode);
View Full Code Here

TOP

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

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.