Examples of ModuleContext


Examples of org.osoa.sca.ModuleContext

    private ClassLoader oldCL;

    public void testHelloWorld() throws Exception {
        TuscanyRuntime tuscany = new TuscanyRuntime("test", "foo");
        tuscany.start();
        ModuleContext moduleContext = CurrentModuleContext.getContext();
        assertNotNull(moduleContext);
        assertEquals("foo", moduleContext.getURI());
        HelloWorldService helloworldService = (HelloWorldService) moduleContext.locateService("HelloWorld");
        assertNotNull(helloworldService);

        String value = helloworldService .getGreetings("World");
        assertEquals("Hello World", value);
        tuscany.stop();
View Full Code Here

Examples of org.osoa.sca.ModuleContext

        // Start the Tuscany runtime and associate it with this thread
        tuscany.start();

        // Get the SCA module context.
        ModuleContext moduleContext = CurrentModuleContext.getContext();

        // Locate the CustomerInfo service
        Object customerInfoService = moduleContext.locateService("CustomerInfoServiceComponent");
       
        // Invoke the CustomerInfo service
        Method getCustomerInfo = customerInfoService.getClass().getMethod("getCustomerInfo", new Class[] {String.class});
        DataObject customer = (DataObject)getCustomerInfo.invoke(customerInfoService, "12345");
       
View Full Code Here

Examples of org.osoa.sca.ModuleContext

    public void invoke(Request request, Response response) throws IOException, ServletException {
        if (!enabled){
            return;
        }
        Object oldRequestId = request.getNote(REQUEST_ID);
        ModuleContext oldContext = CurrentModuleContext.getContext();
        // bind the current module context to the thread for use by CurrentModuleContext
        BINDER.setContext((ModuleContext) moduleComponentContext);
        try {
            if (oldRequestId != null) {
                // the request has already been started, just invoke the next valve
View Full Code Here

Examples of org.osoa.sca.ModuleContext

    }
   
    public void testGreetings() throws Exception {

        // Get the SCA module context.
        ModuleContext moduleContext = CurrentModuleContext.getContext();

        // Locate the HelloWorld service
        HelloWorldService helloworldService = (HelloWorldService) moduleContext.locateService("HelloWorldServiceComponent");
       
        // Invoke the HelloWorld service
        String value = helloworldService.getGreetings("World");
       
        assertEquals(value, "Hello World");
View Full Code Here

Examples of org.osoa.sca.ModuleContext

        // Start the Tuscany runtime and associate it with this thread
        tuscany.start();

        // Get the SCA module context.
        ModuleContext moduleContext = CurrentModuleContext.getContext();

        // Locate the HelloWorld service
        HelloWorldService helloworldService = (HelloWorldService) moduleContext.locateService("HelloWorldServiceComponent");
       
        // Invoke the HelloWorld service
        String value = helloworldService.getGreetings("World");
       
        System.out.println(value);
View Full Code Here

Examples of org.osoa.sca.ModuleContext

        Object module = getServletContext().getAttribute("org.apache.tuscany.core.webapp.ModuleComponentContext");
        if (module == null || "org.apache.tuscany.core.context.CompositeContext".equals(module.getClass().getName())) {
            throw new ServletException("Module composite not bound to org.apache.tuscany.core.webapp.ModuleComponentContext");
        }

        ModuleContext moduleContext = CurrentModuleContext.getContext();
        if (moduleContext == null) {
            throw new ServletException("No module context returned");
        }
        String name = moduleContext.getName();
        if (!"/testContext".equals(name)) {
            throw new ServletException("Invalid module context name: " + name);
        }

        HelloWorldService helloService = (HelloWorldService) moduleContext.locateService("HelloWorld");
        String greetings = helloService.getGreetings("World");
        if (!"Hello World".equals(greetings)) {
            throw new ServletException("Serivce returned " + greetings);
        }
    }
View Full Code Here

Examples of org.osoa.sca.ModuleContext

    }
   
    public void testCustomerInfo() throws Exception {

        // Get the SCA module context.
        ModuleContext moduleContext = CurrentModuleContext.getContext();

        // Locate the CustomerInfo service
        Object customerInfoService = moduleContext.locateService("CustomerInfoServiceComponent");
       
        // Invoke the CustomerInfo service
        Method getCustomerInfo = customerInfoService.getClass().getMethod("getCustomerInfo", new Class[] {String.class});
        DataObject customer = (DataObject)getCustomerInfo.invoke(customerInfoService, "12345");
       
View Full Code Here

Examples of org.osoa.sca.ModuleContext

        // Start the Tuscany runtime and associate it with this thread
        tuscany.start();

        // Get the SCA module context.
        ModuleContext moduleContext = CurrentModuleContext.getContext();
       
        // Locate the Calculator service
        CalculatorService calculatorService = (CalculatorService) moduleContext.locateService("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));
View Full Code Here

Examples of org.osoa.sca.ModuleContext

    public void testGetQuote() throws ConfigurationException, SecurityException, NoSuchMethodException, IllegalArgumentException,
            IllegalAccessException, InvocationTargetException {

        TuscanyRuntime tuscany = new TuscanyRuntime("getQuote", null);
        tuscany.start();
        ModuleContext moduleContext = CurrentModuleContext.getContext();

        Object serviceProxy = moduleContext.locateService("webserviceXSQ");
        Method m = serviceProxy.getClass().getMethod("GetQuote", new Class[] { String.class });

        String sqResponse = (String) m.invoke(serviceProxy, "IBM");

        assertTrue(sqResponse.startsWith("<StockQuotes><Stock><Symbol>IBM</Symbol>"));
View Full Code Here

Examples of org.osoa.sca.ModuleContext

    }
   
    public void testCalculator() throws Exception {

        // Get the SCA module context.
        ModuleContext moduleContext = CurrentModuleContext.getContext();

        // Locate the Calculator service
        CalculatorService calculatorService = (CalculatorService) moduleContext.locateService("CalculatorServiceComponent");
       
        // Calculate
        assertEquals(calculatorService.add(3, 2), 5.0);
        assertEquals(calculatorService.subtract(3, 2), 1.0);
        assertEquals(calculatorService.multiply(3, 2), 6.0);
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.