/** * @see org.apache.airavata.xbaya.invoker.WorkflowInvoker#setup() */ public void setup() throws WorkflowException { Class[] parameters = new Class[] { URL.class }; URLClassLoader sysloader = (URLClassLoader) ClassLoader.getSystemClassLoader(); Class sysclass = URLClassLoader.class; try { Method method = sysclass.getDeclaredMethod("addURL", parameters); method.setAccessible(true); method.invoke(sysloader, new Object[] { this.jarUrl }); } catch (Throwable t) { t.printStackTrace(); throw new WorkflowException("Error, could not add URL to system classloader"); } }
/** * @see org.apache.airavata.xbaya.invoker.WorkflowInvoker#setup() */ public void setup() throws WorkflowException { Class[] parameters = new Class[] { URL.class }; URLClassLoader sysloader = (URLClassLoader) ClassLoader.getSystemClassLoader(); Class sysclass = URLClassLoader.class; try { Method method = sysclass.getDeclaredMethod("addURL", parameters); method.setAccessible(true); method.invoke(sysloader, new Object[] { this.jarUrl }); } catch (Throwable t) { t.printStackTrace(); throw new WorkflowException("Error, could not add URL to system classloader"); } }
/** * @see org.apache.airavata.xbaya.invoker.WorkflowInvoker#invoke() */ public boolean invoke() throws WorkflowException { try { Class<?> targetClass = Class.forName(this.className); Object obj = targetClass.newInstance(); Method[] methods = targetClass.getDeclaredMethods(); Method targetMethod = null; for (Method method : methods) { if (this.operationName.equals(method.getName())) { targetMethod = method; break; } } if (targetMethod == null) { throw new WorkflowException("Could not find the method using reflection: " + this.operationName); } targetMethod.setAccessible(true); this.result = targetMethod.invoke(obj, inputs); } catch (Exception e) { throw new WorkflowException(e); } return true; }
/** * @see org.apache.airavata.xbaya.invoker.WorkflowInvoker#invoke() */ public boolean invoke() throws WorkflowException { try { Class<?> targetClass = Class.forName(this.className); Object obj = targetClass.newInstance(); Method[] methods = targetClass.getDeclaredMethods(); Method targetMethod = null; for (Method method : methods) { if (this.operationName.equals(method.getName())) { targetMethod = method; break; } } if (targetMethod == null) { throw new WorkflowException("Could not find the method using reflection: " + this.operationName); } targetMethod.setAccessible(true); this.result = targetMethod.invoke(obj, inputs); } catch (Exception e) { throw new WorkflowException(e); } return true; }
/** * @see org.apache.airavata.xbaya.invoker.Invoker#invoke() */ public boolean invoke() throws WorkflowException { try { boolean success = this.operation.executeRequestResponseOperation(this.inputMessage, this.outputMessage, this.faultMessage); while(this.outputMessage == null){ } return success; } catch (RuntimeException e) { String message = "Error in invoking a service."; throw new WorkflowException(message, e); } }
/** * @see org.apache.airavata.workflow.engine.invoker.Invoker#invoke() */ public boolean invoke() throws WorkflowException { try { boolean success = this.operation.executeRequestResponseOperation(this.inputMessage, this.outputMessage, this.faultMessage); while(this.outputMessage == null){ } return success; } catch (RuntimeException e) { String message = "Error in invoking a service."; throw new WorkflowException(message, e); } }
/** * Sends an event. * * @param event * @throws org.apache.airavata.workflow.model.exceptions.WorkflowException */ public void sendEvent(Event event) throws WorkflowException { Throwable exception = null; for (EventListener listener : this.listeners) { try { listener.eventReceived(event); } catch (Throwable e) { logger.error(e.getMessage(), e); // Just remember the first one. if (exception == null) { exception = e; } } } if (exception != null) { if (exception instanceof WorkflowException) { throw (WorkflowException) exception; } else { throw new WorkflowException(exception); } } }
/** * Sends an event. * * @param event * @throws WorkflowException */ public void sendEvent(Event event) throws WorkflowException { Throwable exception = null; for (EventListener listener : this.listeners) { try { listener.eventReceived(event); } catch (Throwable e) { logger.error(e.getMessage(), e); // Just remember the first one. if (exception == null) { exception = e; } } } if (exception != null) { if (exception instanceof WorkflowException) { throw (WorkflowException) exception; } else { throw new WorkflowException(exception); } } }
/** * * @param operationName * The name of the operation * @throws WorkflowException */ public void setOperation(String operationName) throws WorkflowException { try { this.invoker.setOperation(operationName); } catch (WorkflowException e) { logger.error(e.getMessage(), e); // An appropriate message has been set in the exception. this.notifier.invocationFailed(e.getMessage(), e); throw e; } catch (RuntimeException e) { logger.error(e.getMessage(), e); String message = "The WSDL does not conform to the invoking service: " + this.serviceInformation; this.notifier.invocationFailed(message, e); throw new WorkflowException(message, e); } catch (Error e) { logger.error(e.getMessage(), e); String message = "Unexpected error: " + this.serviceInformation; this.notifier.invocationFailed(message, e); throw new WorkflowException(message, e); } }
public Object getOutput(String name) throws WorkflowException { try { waitToFinish(); Object output = super.getOutput(name); if (output instanceof XmlElement) { logger.debug("output: " + XMLUtil.xmlElementToString((XmlElement) output)); } return output; } catch (WorkflowException e) { logger.error(e.getMessage(), e); // An appropriate message has been set in the exception. if (!this.failerSent) { this.notifier.invocationFailed(e.getMessage(), e); } throw e; } catch (RuntimeException e) { logger.error(e.getMessage(), e); String message = "Error while waiting for a output: " + name; this.notifier.invocationFailed(message, e); throw new WorkflowException(message, e); } catch (Error e) { logger.error(e.getMessage(), e); String message = "Unexpected error: " + this.serviceInformation; this.notifier.invocationFailed(message, e); throw new WorkflowException(message, e); } }
public void createService(String code) throws WorkflowException { try { WsdlDefinitions definitions = null; if (this.dynamicFactoryWSDLLocation != null && !this.dynamicFactoryWSDLLocation.equals("")) { definitions = WsdlResolver.getInstance().loadWsdl(new File(".").toURI(), new URI(this.dynamicFactoryWSDLLocation)); } // Create Invoker // FIXME: Should pass the right leadcontext header for last argument Invoker invoker = InvokerFactory.createInvoker(new QName("http://extreme.indiana.edu", "ServiceCreatorPortType"), definitions, null, null, null); invoker.setup(); invoker.setOperation("deployServiceFromClass"); invoker.setInput("classAsString", code); invoker.invoke(); invoker.getOutput("return"); } catch (Exception e) { throw new WorkflowException(e); } }
public static Invoker createInvoker(QName portTypeQName, WsdlDefinitions definitions, String gfacURL, String messageBoxURL, WorkflowContextHeaderBuilder builder, boolean differ) throws WorkflowException { Invoker invoker = null; if (definitions != null && definitions.getServices().iterator().hasNext()) { // check if this web service supports asynchronous invocation if (WSDLUtil.isAsynchronousSupported(WSDLUtil.wsdlDefinitions3ToWsdlDefintions5(definitions))) { invoker = new AsynchronousInvoker(definitions, messageBoxURL); } else { invoker = new SimpleInvoker(definitions); } } else if (gfacURL != null && gfacURL.length() != 0) { invoker = new GFacInvoker(portTypeQName, gfacURL, messageBoxURL, builder); } if (invoker == null) { String message = "Cannot find an appropriate way to invoke the service"; throw new WorkflowException(message); } return invoker; } }
/** * @see org.apache.airavata.xbaya.invoker.Invoker#setOperation(java.lang.String) */ public void setOperation(String operationName) throws WorkflowException { try { WSIFPort port = this.client.getPort(); this.operation = port.createOperation(operationName); this.inputMessage = this.operation.createInputMessage(); this.outputMessage = this.operation.createOutputMessage(); this.faultMessage = this.operation.createFaultMessage(); } catch (RuntimeException e) { String message = "The WSDL does not conform to the invoking service."; throw new WorkflowException(message, e); } }
/** * @see org.apache.airavata.workflow.engine.invoker.Invoker#setOperation(java.lang.String) */ public void setOperation(String operationName) throws WorkflowException { try { WSIFPort port = this.client.getPort(); this.operation = port.createOperation(operationName); this.inputMessage = this.operation.createInputMessage(); this.outputMessage = this.operation.createOutputMessage(); this.faultMessage = this.operation.createFaultMessage(); } catch (RuntimeException e) { String message = "The WSDL does not conform to the invoking service."; throw new WorkflowException(message, e); } }
/** * @param portTypeQName * @param definitions * @param gfacURL * @param messageBoxURL * @return The invoker * @throws WorkflowException */ public static Invoker createInvoker(QName portTypeQName, WsdlDefinitions definitions, String gfacURL, String messageBoxURL, LeadContextHeader leadContext) throws WorkflowException { Invoker invoker = null; if (definitions != null && definitions.getServices().iterator().hasNext()) { // check if this web service supports asynchronous invocation if (WSDLUtil.isAsynchronousSupported(WSDLUtil.wsdlDefinitions3ToWsdlDefintions5(definitions))) { invoker = new AsynchronousInvoker(definitions, messageBoxURL); } else { invoker = new SimpleInvoker(definitions); } } else if (gfacURL != null && gfacURL.length() != 0) { invoker = new GFacInvoker(portTypeQName, gfacURL, messageBoxURL, leadContext); } if (invoker == null) { String message = "Cannot find an appropriate way to invoke the service"; throw new WorkflowException(message); } return invoker; }
/** * @see org.apache.airavata.xbaya.invoker.Invoker#setup() */ public void setup() throws WorkflowException { try { WSIFService service = WSIFServiceFactory.newInstance().getService(this.definitions); WSIFPort port = service.getPort(); this.client = WSIFRuntime.getDefault().newClientFor(port); this.client.setAsyncResponseTimeoutInMs(999999999); } catch (RuntimeException e) { String message = "The WSDL is in the wrong format"; throw new WorkflowException(message, e); } }
/** * @see org.apache.airavata.workflow.engine.invoker.Invoker#setup() */ public void setup() throws WorkflowException { try { WSIFService service = WSIFServiceFactory.newInstance().getService(this.definitions); WSIFPort port = service.getPort(); this.client = WSIFRuntime.getDefault().newClientFor(port); this.client.setAsyncResponseTimeoutInMs(999999999); } catch (RuntimeException e) { String message = "The WSDL is in the wrong format"; throw new WorkflowException(message, e); } }
/** * @see org.apache.airavata.workflow.engine.invoker.Invoker#setInput(java.lang.String, java.lang.Object) */ public void setInput(String name, Object value) throws WorkflowException { try { if (value instanceof XmlElement) { // If the value is a complex type, change the name of the // element to the correct one. XmlElement valueElement = (XmlElement) value; valueElement.setName(name); } else if (value instanceof String) { if(XMLUtil.isXML((String)value)){ XmlElement valueElement = XMLUtil.stringToXmlElement3((String) value); valueElement.setName(name); value = valueElement; } // Simple case. } else { // convert int, doule to string. value = "" + value; } this.inputMessage.setObjectPart(name, value); } catch (RuntimeException e) { String message = "Error in setting an input. name: " + name + " value: " + value; throw new WorkflowException(message, e); } }
/** * Constructs a GFacServiceCreater. * * @param wsdlURI * The URI of the GFac service * @throws WorkflowException */ public GFacServiceCreator(URI wsdlURI) throws WorkflowException { try { WsdlDefinitions definitions = WsdlResolver.getInstance().loadWsdl(wsdlURI); WSIFService service = WSIFServiceFactory.newInstance().getService(definitions); WSIFPort port = service.getPort(); this.gFacOperation = port.createOperation(CREATE_SERVICE_OPERATION); } catch (RuntimeException e) { String message = "Failed to connect to the Generic Factory: " + wsdlURI; throw new WorkflowException(message, e); } }
/** * Shutdowns the service created. * * @throws WorkflowException */ public void shutdownService() throws WorkflowException { WSIFService service = WSIFServiceFactory.newInstance().getService(this.serviceDefinitions); WSIFPort port = service.getPort(); WSIFOperation operation = port.createOperation(SHUTDOWN_OPERATION); WSIFMessage inputMessage = operation.createInputMessage(); WSIFMessage outputMessage = operation.createOutputMessage(); WSIFMessage faultMessage = operation.createFaultMessage(); boolean success = operation.executeRequestResponseOperation(inputMessage, outputMessage, faultMessage); if (!success) { // An implementation of WSIFMessage, WSIFMessageElement, // implements toString(), which serialize the message XML. String message = "Failed to shutdown the service: " + faultMessage.toString(); throw new WorkflowException(message); } } }