/** * This method is called to send a the results of an asynchronous service execution to a * requesting component. * * @param input Object containing information on the requesting component * @param atts AttributeNameValues containing the service results * @return result of sending the service results * @see CommunicationsHandler#userRequest(DataObject,String,String,int) */ protected DataObject sendServiceResult(ServiceInput input, Attributes atts) { Vector v = new Vector(); v.addElement(new DataObject(Constants.ID, input.getId())); input.setInput(null); v.addElement(input.toDataObject()); v.addElement(atts.toDataObject()); DataObject result = new DataObject(SERVICE_RESULT, v); try { return comm.userRequest( result, SERVICE_RESULT, input.getHostname(), Integer.parseInt(input.getPort())); } catch (DecodeException de) { System.out.println("Service sendServiceResult() Decode: " + de); } catch (EncodeException ee) { System.out.println("Service sendServiceResult() Encode: " + ee); } catch (InvalidDecoderException ide) { System.out.println("Service sendServiceResult() InvalidDecoder: " + ide); } catch (InvalidEncoderException iee) { System.out.println("Service sendServiceResult() InvalidEncoder: " + iee); } catch (InvalidProtocolException ipe) { System.out.println("Service sendServiceResult() InvalidProtocol: " + ipe); } catch (ProtocolException pe) { System.out.println("Service sendServiceResult() Protocol: " + pe); } catch (IOException io) { System.out.println("Service sendServiceResult() IOException: " + io); } return null; }
@Override public DataObject execute(ServiceInput serviceInput) { String warning_value = String.valueOf(serviceInput.getInput().getAttributeValue(WarningWidget.WARNING_FIRE)); int last = warningTextArea.getLineCount() - 1; int start; int end; String lastLine = ""; try { if (last > 0) { start = warningTextArea.getLineStartOffset(last - 1); end = warningTextArea.getLineEndOffset(last); lastLine = warningTextArea.getText().substring(start, end - 1); } } catch (BadLocationException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (!warning_value.equals(lastLine)) warningTextArea.append(warning_value + "\n"); return new DataObject(); // no particular info to return }