Class JclObjectFactory


  • public class JclObjectFactory
    extends Object
    A factory class that loads classes from specified JarClassLoader and tries to instantiate their objects
    Author:
    Kamran Zafar
    • Method Detail

      • getInstance

        public static JclObjectFactory getInstance()
        Returns the instance of the singleton factory
        Returns:
        JclObjectFactory
      • getInstance

        public static JclObjectFactory getInstance​(boolean autoProxy)
        Returns the instance of the singleton factory that can be used to create auto proxies for jcl-created objects
        Returns:
        JclObjectFactory
      • create

        public Object create​(JarClassLoader jcl,
                             String className)
        Creates an instance of the specified class using its default constructor.
        Parameters:
        jcl - class loader to load the class from
        className - binary name of the class to instantiate
        Returns:
        new instance
      • create

        public Object create​(JarClassLoader jcl,
                             String className,
                             Object... args)
        Creates an instance of the specified class using a matching constructor.
        Parameters:
        jcl - class loader to load the class from
        className - binary name of the class to instantiate
        args - constructor arguments
        Returns:
        new instance
      • create

        public Object create​(JarClassLoader jcl,
                             String className,
                             Object[] args,
                             Class<?>[] types)
        Creates an instance of the specified class using a constructor matched by parameter types.
        Parameters:
        jcl - class loader to load the class from
        className - binary name of the class to instantiate
        args - constructor arguments
        types - constructor parameter types
        Returns:
        new instance
      • create

        public Object create​(JarClassLoader jcl,
                             String className,
                             String methodName,
                             Object... args)
        Creates an instance via a static factory method with no arguments.
        Parameters:
        jcl - class loader to load the class from
        className - binary name of the class
        methodName - static factory method name
        args - method arguments
        Returns:
        object returned by the factory method
      • create

        public Object create​(JarClassLoader jcl,
                             String className,
                             String methodName,
                             Object[] args,
                             Class<?>[] types)
        Creates an instance via a static factory method matched by parameter types.
        Parameters:
        jcl - class loader to load the class from
        className - binary name of the class
        methodName - static factory method name
        args - method arguments
        types - method parameter types
        Returns:
        object returned by the factory method