/**
   * Factory method for auto-adding JAXB Transformers for a Service interface.
   *
   * @param serviceClass The Service class.
   * @return The list of JAX Transformers to be added for the supplied service class.
   * @throws SwitchYardException Unsupported JAXB type defined on interface.
   */
  public static List<Transformer<?, ?>> newTransformers(Class<?> serviceClass)
      throws SwitchYardException {
    List<Transformer<?, ?>> transformers = new ArrayList<Transformer<?, ?>>();
    Set<Class<?>> inputTypeSet = new HashSet<Class<?>>();
    Set<Class<?>> outputTypeSet = new HashSet<Class<?>>();

    if (serviceClass.isInterface()) {
      Method[] serviceOperations = serviceClass.getMethods();

      for (Method serviceOperation : serviceOperations) {
        Class<?>[] inTypes = serviceOperation.getParameterTypes();
        Class<?> outType = serviceOperation.getReturnType();

        if (inTypes.length == 1) {
          inputTypeSet.add(inTypes[0]);
        }
        if (outType != null && !Void.TYPE.isAssignableFrom(outType)) {
          outputTypeSet.add(outType);
        }
      }
    }

    // Add input and output transformers...
    for (Class<?> inputType : inputTypeSet) {
      addJAXBUnmarshalTransformer(inputType, transformers);
    }
    for (Class<?> outputType : outputTypeSet) {
      addJAXBMarshalTransformer(outputType, transformers);
    }

    return transformers;
  }
Ejemplo n.º 2
0
 protected Object invokeAsynchronous(final Method method, final InterceptorContext context)
     throws Exception {
   if (Void.TYPE.isAssignableFrom(method.getReturnType())) {
     return new AsyncVoidInterceptor(getAsynchronousExecutor()).processInvocation(context);
   } else {
     return new AsyncFutureInterceptor(getAsynchronousExecutor()).processInvocation(context);
   }
 }