/** * Checks if method is createHIT and appends 'myHIT' to the set of keywords */ @Override public Reply execute(Message m) throws ServiceException { if (m.getMethodName().equals("CreateHIT")) { CreateHITRequest[] requestArray = (CreateHITRequest[]) m.getRequests(); for (CreateHITRequest request : requestArray) { StringBuffer keywords = new StringBuffer(); //append existing keywords to string buffer if (request.getKeywords() != null) { keywords.append(request.getKeywords()); keywords.append(", "); } keywords.append("myHIT"); request.setKeywords(keywords.toString()); } } //pass the message to the next filter return passMessage(m); }
public Reply execute(Message m) { if (m.getMethodName().equals("CreateHIT")) { CreateHITRequest[] requestArray = (CreateHITRequest[]) m.getRequests(); for (CreateHITRequest request : requestArray) { if (request.getReward().getAmount().doubleValue() < 0.05) { request.getReward().setAmount(new BigDecimal(0.05)); } } } return passMessage(m); }
/** * Returns the message that is/was send to the requester service */ public Message getMessage() { return message; }
/** * Enqueues the request array in the Axis work queue for asynchronous sending. * The result can be obtained through the future contained in the AsyncReply * * The work queue is using a pool of daemon threads to process the submitted tasks. * To guarantee that all work submitted to the queue was processed before the JVM * exits, this requires to wait for all future results of the submitted work items. * This can conveniently be done using the getResult() method of the AsyncReply * object returned by this method. A typical usage pattern would be to first submit * all requests to the work queue, store the AsyncReply objects in an array and then * call getResult() for each of the objects in the array. * * @param requests * @param axisMethodName * @param resultAccessorName * @param callback Callback interface to invoke when the request has been processed (optional) * @return */ protected AsyncReply executeAsyncRequests(Object requests, String axisMethodName, String resultAccessorName, AsyncCallback callback) { Message message = new Message(requests, axisMethodName, resultAccessorName, null); return WorkQueue.submit(new AsyncRequest(message, this.filterList.getFirst(), callback)); }
/** * Constructs a new reply once the message is submitted to the Axis work * queue * * @param msg * The request message to send * @param f * The future contain the result of the asynchronous call */ public AsyncReply(Message msg, Future<Object> f) { this.future = f; this.requestMsg = msg; }
/** * Returns the request for this reply * * @return */ public Message getRequestMessage() { return requestMsg; }
/** * Creates a new asynchronous request * * @param msg The request to send to the requester endpoint * @param f The first filter to invoke * @param callback (Optional) A callback handler to invoke when the work queue processed the request */ public AsyncRequest(Message msg, Filter f, AsyncCallback callback) { this.message = msg; this.firstFilter = f; this.cb = callback; }
/** * Sets the common parameters, sends an array of AWS requests to the service, * and returns results. * * @see http://docs.amazonwebservices.com/AWSMechanicalTurkRequester/2006-10-31/ApiReference_CommonParametersArticle.html * @param requests * @param axisMethodName * @param resultAccessorName * @param credential * @return Result * @throws ServiceException */ protected Object [] executeRequests(Object requests, String axisMethodName, String resultAccessorName, String credential) { Message message = new Message(requests, axisMethodName, resultAccessorName, credential); return this.filterList.getFirst().execute(message).getResults(); }