Class DefaultRestMethodGenerator

  • All Implemented Interfaces:
    IRestMethodGenerator

    public class DefaultRestMethodGenerator
    extends java.lang.Object
    implements IRestMethodGenerator
    The default rest method generator. Analyses the Jadex service interface and possible the baseclass (which can be a concrete or abstract class or an interface).
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected static void addMethodWrapper​(MethodWrapper mw, java.util.Set<MethodWrapper> methods)
      A a method wrapper.
      protected static void addPath​(java.lang.String path, java.util.Set<java.lang.String> paths)
      Add a path to the set of paths.
      java.util.List<RestMethodInfo> generateRestMethodInfos​(IServiceIdentifier serviceid, java.lang.ClassLoader classloader, java.lang.Class<?> baseclass, java.util.Map<java.lang.String,​java.lang.Object> mapprops)
      Generate the rest method infos.
      protected static java.lang.String getPathName​(java.lang.String path, java.util.Set<java.lang.String> paths)
      Get a path name based on a start name.
      java.lang.Class<?> guessRestType​(java.lang.reflect.Method method)
      Guess the http type (GET, POST, PUT, DELETE, ...) of a method.
      boolean hasStringConvertableParameters​(java.lang.reflect.Method method, java.lang.Class<?> rettype, java.lang.Class<?>[] paramtypes)
      Test if a method has parameters that are all convertible from string.
      static boolean isStringConvertableType​(java.lang.Class<?> type)
      Test if a class is convertible from string.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DefaultRestMethodGenerator

        public DefaultRestMethodGenerator()
    • Method Detail

      • generateRestMethodInfos

        public java.util.List<RestMethodInfo> generateRestMethodInfos​(IServiceIdentifier serviceid,
                                                                      java.lang.ClassLoader classloader,
                                                                      java.lang.Class<?> baseclass,
                                                                      java.util.Map<java.lang.String,​java.lang.Object> mapprops)
                                                               throws java.lang.Exception
        Generate the rest method infos.
        Specified by:
        generateRestMethodInfos in interface IRestMethodGenerator
        Parameters:
        service - The Jadex service.
        classloader - The classloader.
        baseclass - The (abstract or concrete) baseclass or interface.
        mapprops - Additional mapping properties.
        Returns:
        The method infos.
        Throws:
        java.lang.Exception
      • guessRestType

        public java.lang.Class<?> guessRestType​(java.lang.reflect.Method method)
        Guess the http type (GET, POST, PUT, DELETE, ...) of a method.
        Parameters:
        method - The method.
        Returns:
        The rs annotation of the method type to use
      • addMethodWrapper

        protected static void addMethodWrapper​(MethodWrapper mw,
                                               java.util.Set<MethodWrapper> methods)
        A a method wrapper.
        Parameters:
        mw - The method mapper.
        methods - The set of method wrapper.
      • getPathName

        protected static java.lang.String getPathName​(java.lang.String path,
                                                      java.util.Set<java.lang.String> paths)
        Get a path name based on a start name.
        Parameters:
        path - The path name.
        paths - The already taken paths.
        Returns:
        The available path.
      • addPath

        protected static void addPath​(java.lang.String path,
                                      java.util.Set<java.lang.String> paths)
        Add a path to the set of paths. Add the path plus the path with trailing slash.
        Parameters:
        path - The path.
        paths - The paths.
      • hasStringConvertableParameters

        public boolean hasStringConvertableParameters​(java.lang.reflect.Method method,
                                                      java.lang.Class<?> rettype,
                                                      java.lang.Class<?>[] paramtypes)
        Test if a method has parameters that are all convertible from string.
        Parameters:
        method - The method.
        rettype - The return types (possibly unwrapped from future type).
        paramtypes - The parameter types.
        Returns:
        True, if is convertible.
      • isStringConvertableType

        public static boolean isStringConvertableType​(java.lang.Class<?> type)
        Test if a class is convertible from string. Tests if is simple type (string, boolean, int, double, etc.) or if it contains a static method 'fromString' or 'valueOf' for Jersey.