@Override public void run() { port.send(request); } }
private Class<? extends CustomJsonMarshaller<?>> searchForTransformationAnnotation( Annotation[] currentArgAnnotations) { for (Annotation annotation : currentArgAnnotations) { if (annotation instanceof UseCustomJasonMarshaller) { return ((UseCustomJasonMarshaller) annotation).value(); } } return null; }
public MethodCall(String methodName, Object[] args, Map<String, String> metaData) { this(methodName, args, metaData, null); classes = getRealClassImplementation(); }
private MethodResultMessage parseMethodResult(Document input) throws JAXBException { MethodResultMessage request = unmarshaller.unmarshal(input, MethodResultMessage.class).getValue(); MethodResult result = request.getResult(); Class<?> resultClass; try { resultClass = Class.forName(result.getClassName()); } catch (ClassNotFoundException e) { throw new FilterException(e); } JAXBContext jaxbContext = JAXBContext.newInstance(MethodResult.class, resultClass); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); Object parsedArg = unmarshaller.unmarshal((Node) result.getArg(), resultClass).getValue(); result.setArg(parsedArg); return request; }
public static void convertResult(MethodResult result) { Object convertArgument = convertArgument(result.getClassName(), result.getArg()); result.setArg(convertArgument); }
@Override protected SecureResponse doFilter(SecureRequest input, Map<String, Object> metaData) { try { verify(input); } catch (MessageVerificationFailedException e) { throw new FilterException(e); } return (SecureResponse) next.filter(input, metaData); }
@Override public MethodResult sendMethodCallWithResult(String portId, String destination, MethodCall call) { OutgoingPort port = getPort(portId); MethodCallRequest request = new MethodCallRequest(call, true); request.setDestination(destination); MethodResultMessage requestResult = port.sendSync(request); return requestResult.getResult(); }
@Override protected MethodResultMessage doFilter(MethodCallRequest input, Map<String, Object> metadata) { metadata.put("callId", input.getCallId()); metadata.put("answer", input.isAnswer()); MethodResult result = requestHandler.handleCall(input.getMethodCall()); return new MethodResultMessage(result, input.getCallId()); }
public static void sendRemoteEvent(String portId, String destination, RemoteEvent e, Map<String, String> metaData) throws PortNotAvailableException { MethodCall methodCall = new MethodCall("processRemoteEvent", new Object[]{ e }, metaData); OutgoingPortUtilService portUtilService = utilsService.getOsgiServiceProxy(OutgoingPortUtilService.class); portUtilService.sendMethodCall(portId, destination, methodCall); }
protected static final void checkNextInputAndOutputTypes(FilterAction next, Class<?> inputType, Class<?> outputType) throws FilterConfigurationException { if (!next.getSupportedInputType().isAssignableFrom(inputType)) { throw new FilterConfigurationException(String.format("inputTypes are not compatible %s (%s - %s)", next, next.getSupportedInputType(), inputType)); } if (!next.getSupportedOutputType().isAssignableFrom(outputType)) { throw new FilterConfigurationException(String.format("outputTypes are not compatible (%s - %s)", next.getSupportedOutputType(), outputType)); } } }
private HashMap<String, Object> getMetaDataMap(MethodCallRequest call) { HashMap<String, Object> metaData = new HashMap<String, Object>(); metaData.put("callId", call.getCallId()); metaData.put("destination", call.getDestination()); return metaData; }
@Override public Object filter(Object input, Map<String, Object> metaData) throws FilterException { return firstElement.filter(input, metaData); }
private FilterChainElement createFromClass(Object next) { try { return (FilterChainElement) ((Class<?>) next).newInstance(); } catch (InstantiationException e) { throw new FilterConfigurationException("Exception when instantiating FilterAction", e); } catch (IllegalAccessException e) { throw new FilterConfigurationException("Exception when instantiating FilterAction", e); } }
@Override public String doFilter(String input, Map<String, Object> metadata) throws FilterException { Document doc = parseDocument(input); Document result = (Document) next.filter(doc, metadata); try { return writeDocument(result); } catch (TransformerException e) { throw new FilterException(e); } }
public static void sendRemoteEvent(String portId, String destination, RemoteEvent e, Map<String, String> metaData) throws PortNotAvailableException { MethodCall methodCall = new MethodCall("processRemoteEvent", new Object[]{ e }, metaData); OutgoingPortUtilService portUtilService = utilsService.getOsgiServiceProxy(OutgoingPortUtilService.class); portUtilService.sendMethodCall(portId, destination, methodCall); }
public MethodCall(String methodName, Object[] args, Map<String, String> metaData) { this(methodName, args, metaData, getRealClassImplementation(null, args)); }
@Override public Document doFilter(Document input, Map<String, Object> metadata) throws FilterException { MethodCallRequest call; try { call = parseMethodCall(input); } catch (JAXBException e) { throw new FilterException(e); } MethodResultMessage result = (MethodResultMessage) next.filter(call, metadata); return serializeResult(result); }
@Override protected MethodResultMessage doFilter(MethodCallRequest input, Map<String, Object> metaData) throws FilterException { Document serializeRequest = serializeRequest(input); Document resultDocument = (Document) next.filter(serializeRequest, metaData); try { return parseMethodResult(resultDocument); } catch (JAXBException e) { throw new FilterException(e); } }
@Override public Document doFilter(Document input, Map<String, Object> metadata) throws FilterException { String docString; try { docString = writeDocument(input); } catch (TransformerException e) { throw new FilterException(e); } String result = (String) next.filter(docString, metadata); return parseDocument(result); }
@Override public String doFilter(String input, Map<String, Object> metadata) throws FilterException { ObjectMapper objectMapper = JsonUtils.createObjectMapperWithIntroSpectors(); MethodCallRequest call; try { call = objectMapper.readValue(input, MethodCallRequest.class); JsonUtils.convertAllArgs(call); MethodResultMessage returnValue = (MethodResultMessage) next.filter(call, metadata); return objectMapper.writeValueAsString(returnValue); } catch (IOException e) { throw new FilterException(e); } }