Class ServiceHelper

java.lang.Object
i5.las2peer.execution.ServiceHelper

public abstract class ServiceHelper extends Object
static helper methods for invocation of service methods via reflection
  • Constructor Details

    • ServiceHelper

      public ServiceHelper()
  • Method Details

    • getWrapperClass

      public static Class<?> getWrapperClass(Class<?> c)
      returns the wrapper class for a native class
      Parameters:
      c - a Class
      Returns:
      a Class
    • isWrapperClass

      public static boolean isWrapperClass(Class<?> c)
      checks if the given class is a wrapper class for a java native
      Parameters:
      c - a Class
      Returns:
      a boolean
    • isSubclass

      public static boolean isSubclass(Class<?> subClass, Class<?> superClass)
      check, if the first given class is a subclass of the second one
      Parameters:
      subClass - A class to check
      superClass - A super class to check
      Returns:
      true, if the first parameter class is a subclass of the second one
    • getUnwrappedClass

      public static Class<?> getUnwrappedClass(Class<?> c)
      returns the native class for a wrapper
      Parameters:
      c - a Class
      Returns:
      a Class
    • execute

      Executes a service method.
      Parameters:
      service - A service to use
      method - the service method
      Returns:
      result of the method invocation
      Throws:
      ServiceMethodNotFoundException - If the method was not found in the given class
      IllegalArgumentException - Thrown to indicate that a method has been passed an illegal or inappropriate argument.
      IllegalAccessException - if this Method object is enforcing Java language access control and the underlying method is inaccessible.
      InvocationTargetException - if the underlying method throws an exception.
    • execute

      Executes a service method.
      Parameters:
      service - A service to use
      method - the service method
      parameters - A bunch of parameters
      Returns:
      result of the method invocation
      Throws:
      ServiceMethodNotFoundException - If the method was not found in the given class
      IllegalArgumentException - Thrown to indicate that a method has been passed an illegal or inappropriate argument.
      IllegalAccessException - if this Method object is enforcing Java language access control and the underlying method is inaccessible.
      InvocationTargetException - if the underlying method throws an exception.
    • searchMethod

      public static Method searchMethod(Class<? extends Service> serviceClass, String methodName, Object[] params) throws ServiceMethodNotFoundException
      Searches the service method fitting to the given parameter classes.
      Parameters:
      serviceClass - A service class to search in
      methodName - the service method
      params - A bunch of parameters
      Returns:
      a Method
      Throws:
      ServiceMethodNotFoundException - If the method was not found in the given class
    • getParameterString

      public static String getParameterString(Object[] params)
      Creates a string with all classes from an array of parameters.
      Parameters:
      params - A bunch of parameters
      Returns:
      a string describing a parameter list for the given actual parameters