Package org.ogce.gfac.context

Examples of org.ogce.gfac.context.InvocationContext


public class PropertiesBasedServiceImplTest {

  @Test
  public void testInit() {
    try{
      InvocationContext ct = new InvocationContext();
      ct.setExecutionContext(new ExecutionContextImpl());
     
      PropertiesBasedServiceImpl service = new PropertiesBasedServiceImpl();
      service.init();
    }catch(Exception e){
      e.printStackTrace();
View Full Code Here


  }

  @Test
  public void testExecute() {
    try{
      InvocationContext ct = new InvocationContext();
      ct.setExecutionContext(new ExecutionContextImpl());
           
      ct.getExecutionContext().setNotificationService(new DummyNotification());

      GSISecurityContext gsiSecurityContext = new GSISecurityContext();
      gsiSecurityContext.setMyproxyServer("myproxy.teragrid.org");
      gsiSecurityContext.setMyproxyUserName("ogce");
      gsiSecurityContext.setMyproxyPasswd("Jdas7wph");
      gsiSecurityContext.setMyproxyLifetime(14400);     
      ct.addSecurityContext("myproxy", gsiSecurityContext);     
     
      ct.setServiceName("{http://www.extreme.indiana.edu/namespaces/2004/01/gFac}Echo_Service");
     
      //parameter
      ParameterContextImpl x = new ParameterContextImpl();
      StringParameter parameter = new StringParameter();
      parameter.fromString("Hello");
      x.addParameter("echo", parameter.getTypeName(), parameter);
      ct.addMessageContext("input", x);
     
      PropertiesBasedServiceImpl service = new PropertiesBasedServiceImpl();
      service.init();
      service.execute(ct);
     
      Assert.assertNotNull(ct.getMessageContext("output"));
      Assert.assertNotNull(ct.getMessageContext("output").getParameterValue("Echoed_Output"));
      Assert.assertEquals("\"Hello\"", ct.getMessageContext("output").getParameterValue("Echoed_Output").toString());
     
    }catch(Exception e){
      e.printStackTrace();
      fail("ERROR");
    }
View Full Code Here

  }

  @Test
  public void testDispose() {
    try{
      InvocationContext ct = new InvocationContext();
      ct.setExecutionContext(new ExecutionContextImpl());     

      PropertiesBasedServiceImpl service = new PropertiesBasedServiceImpl();
      service.dispose();
    }catch(Exception e){
      e.printStackTrace();
View Full Code Here

  public OMElement invoke(String serviceName, OMElement input) {
   
    OMElement output = null;

    try {
      InvocationContext ct = new InvocationContext();
      ct.setExecutionContext(new ExecutionContextImpl());

      ct.getExecutionContext().setNotificationService(new DummyNotification());

      MessageContext msgContext = MessageContext.getCurrentMessageContext();     
      Map<String, Object> m = (Map)msgContext.getProperty(SECURITY_CONTEXT);
      for (String key : m.keySet()) {
        ct.addSecurityContext(key, (SecurityContext)m.get(key));
      }
      ct.setServiceName(serviceName);

      // TODO define real parameter passing in SOAP body
      //handle parameter
      for (Iterator iterator = input.getChildren(); iterator.hasNext();) {
        OMElement element = (OMElement) iterator.next();
        String name = element.getQName().getLocalPart();
        String type = element.getAttribute(new QName("type")).getAttributeValue();
        String value = element.getText();
       
        ParameterContextImpl x = new ParameterContextImpl();
        x.addParameter(name, type, value)
        ct.addMessageContext("input", x)
      }

      if (service == null) {
        service = new PropertyServiceFactory().createService();
      }
     
      //invoke service
      service.execute(ct);
     
     
      //TODO also define how output too
      /*
       * Process Output
       */
      OMFactory fac = OMAbstractFactory.getOMFactory();
          OMNamespace omNs = fac.createOMNamespace("http://ws.apache.org/axis2/xsd", "ns1");
          output = fac.createOMElement("output", omNs);         
   
      org.ogce.gfac.context.MessageContext context = ct.getMessageContext("output");
      for (Iterator<String> iterator = context.getParameterNames(); iterator.hasNext();) {
        String name = iterator.next();
        OMElement ele = fac.createOMElement(name, omNs);
        ele.addAttribute("type", context.getParameterType(name), omNs);
        ele.setText(context.getParameterValue(name).toString());
View Full Code Here

TOP

Related Classes of org.ogce.gfac.context.InvocationContext

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.