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);
}
}