Examples of SCADomain


Examples of org.apache.tuscany.sca.host.embedded.SCADomain

*/
public class DomainNode {

    public static void main(String[] args) {

        SCADomain scaDomain = SCADomain.newInstance("domain/domain.composite");

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

        scaDomain.close();
        System.out.println("Domain node stopped");
    }
View Full Code Here

Examples of org.apache.tuscany.sca.host.embedded.SCADomain

            // network.
            DistributedSCADomain distributedDomain = new DistributedSCADomainNetworkImpl(domainName);
      
            // create the node that runs the calculator component
            EmbeddedNode node = new EmbeddedNode(nodeName);
            SCADomain domain = node.attachDomain(distributedDomain);
               
            // the application components are added. The null here just gets the node
            // implementation to read a directory from the classpath with the node name
            // TODO - should be done as a management action.      
            node.addContribution(domainName, null)
           
            // start the node
            // TODO - should be done as a management action.
            node.start();
                   
            // nodeA is the head node and runs some tests while all other nodes
            // simply listen for incoming messages
            if ( nodeName.equals("nodeA") ) {           
                // do some application stuff
                CalculatorService calculatorService =
                    domain.getService(CalculatorService.class, "CalculatorServiceComponent");
       
                // Calculate
                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));
            } else {
                // start up and wait for messages
                try {
                    System.out.println("Node started (press enter to shutdown)");
                    System.in.read();
                } catch (IOException e) {
                    e.printStackTrace();
               
            }
           
            // stop the node and all the domains in it
            domain.close();
       
        } catch(Exception ex) {
            System.err.println("Exception in node - " + ex.getMessage());
            ex.printStackTrace(System.err);
        }
View Full Code Here

Examples of org.apache.tuscany.sca.host.embedded.SCADomain

              + ": "
              + e.getMessage()
              + ". Valid and working Erlang/OTP distribution is required.");
      throw new IgnoreTest();
    }
    SCADomain scaDomain = SCADomain
        .newInstance("helloworlderlangservice.composite");
    HelloWorldService helloWorldService = scaDomain.getService(
        HelloWorldService.class,
        "HelloWorldServiceComponent/HelloWorldService");
    assertNotNull(helloWorldService);
    assertEquals("Hello Smith", helloWorldService.getGreetings("Smith"));
    scaDomain.close();
    epmdProcess.destroy();
  }
View Full Code Here

Examples of org.apache.tuscany.sca.host.embedded.SCADomain

                + e.getMessage()
                + ". Valid and working Erlang/OTP distribution is required.");
      }
      if (process != null) {
        System.out.println("EPMD server started");
        SCADomain scaDomain = SCADomain
            .newInstance("helloworlderlangservice.composite");
        System.out
            .println("HelloWorld server started (press enter to shutdown)");
        System.in.read();
        process.destroy();
        scaDomain.close();
        System.out.println("EPMD server stopped");
        System.out.println("HelloWorld server stopped");
      }
    } catch (IOException e) {
      e.printStackTrace();
View Full Code Here

Examples of org.apache.tuscany.sca.host.embedded.SCADomain

        OSGiRuntime.stop();
    }
   
    public void testOSGiComponent() throws Exception {
       
        SCADomain scaDomain = SCADomain.newInstance(compositeName);
        OSGiTestInterface testService = scaDomain.getService(OSGiTestInterface.class, "OSGiTestServiceComponent");
        assert(testService != null);
       
        assert(testService instanceof Proxy);
       
        String str = testService.testService();
       
        assertEquals(className, str);

        scaDomain.close();
             
    }
View Full Code Here

Examples of org.apache.tuscany.sca.host.embedded.SCADomain

              + ": "
              + e.getMessage()
              + ". Valid and working Erlang/OTP distribution is required.");
      throw new IgnoreTest();
    }
    SCADomain scaServiceDomain = SCADomain
        .newInstance("helloworlderlangservice.composite");
    SCADomain scaClientDomain = SCADomain
        .newInstance("helloworlderlangreference.composite");
    HelloWorldService helloWorldService = scaClientDomain.getService(
        HelloWorldService.class, "HelloWorldServiceComponent");
    String msg = helloWorldService.getGreetings("Smith");
    Assert.assertEquals("Hello Smith", msg);
    scaClientDomain.close();
    scaServiceDomain.close();
    epmdProcess.destroy();

  }
View Full Code Here

Examples of org.apache.tuscany.sca.host.embedded.SCADomain

    /**
     * Initializes the SCADomian associated with a webapp context. If a SCADomain
     * doesn't exist already then one is create based on the webapp config.
     */
    static SCADomain initSCADomain(ServletContext servletContext) {
        SCADomain scaDomain = (SCADomain)servletContext.getAttribute(SCA_DOMAIN_ATTRIBUTE);
       
        String domainURI = "http://localhost/" + servletContext.getServletContextName().replace(' ', '.');
        String contributionRoot = null;
       
        try {
View Full Code Here

Examples of org.apache.tuscany.sca.host.embedded.SCADomain

            throw new JspException("Exception initializing Tuscany webapp: " + e, e);
        }
        ServletContext servletContext = pageContext.getServletContext();
        ComponentContext componentContext = (ComponentContext)servletContext.getAttribute("org.osoa.sca.ComponentContext");
        SCADomain scaDomain = null;
        if (componentContext == null) {
            scaDomain = (SCADomain)servletContext.getAttribute(WebAppServletHost.SCA_DOMAIN_ATTRIBUTE);
            if (scaDomain == null) {
                throw new JspException("SCADomain is null. Check Tuscany configuration in web.xml");
            }
        }

        Class<?> typeClass;
        try {
            typeClass = Class.forName(type, true, Thread.currentThread().getContextClassLoader());
        } catch (ClassNotFoundException e) {
            throw new JspException("Reference '" + name + "' type class not found: " + type);
        }

        Object o;
        try {
            if (componentContext != null) {
                o = componentContext.getService(typeClass, name);
            } else {
                o = scaDomain.getService(typeClass, name);
            }
        } catch (Exception e) {
            throw new JspException("Exception getting service for reference'" + name + "': " + e, e);
        }
        if (o == null) {
View Full Code Here

Examples of org.apache.tuscany.sca.host.embedded.SCADomain

        }
    }

    public void contextDestroyed(ServletContextEvent event) {
        ServletContext servletContext = event.getServletContext();
        SCADomain scaDomain = (SCADomain) servletContext.getAttribute(WebAppServletHost.SCA_DOMAIN_ATTRIBUTE);
        if (scaDomain != null) {
            scaDomain.close();
        }
    }
View Full Code Here

Examples of org.apache.tuscany.sca.host.embedded.SCADomain

  @BeforeClass
  public static void init() throws IOException {
    try {
      epmdProcess = Runtime.getRuntime().exec(EPMD_COMMAND);
      SCADomain domain = SCADomain
          .newInstance("ErlangReference.composite");
      SCADomain.newInstance("ErlangService.composite");
      ReferenceTestComponentImpl component = domain.getService(
          ReferenceTestComponentImpl.class, "ReferenceTest");

      mboxReference = component.getMboxReference();
      timeoutMboxReference = component.getTimeoutMboxReference();
      moduleReference = component.getModuleReference();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.