Package io.github.connellite.jcl
Class JclObjectFactory
- java.lang.Object
-
- io.github.connellite.jcl.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 Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Objectcreate(JarClassLoader jcl, String className)Creates an instance of the specified class using its default constructor.Objectcreate(JarClassLoader jcl, String className, Object... args)Creates an instance of the specified class using a matching constructor.Objectcreate(JarClassLoader jcl, String className, Object[] args, Class<?>[] types)Creates an instance of the specified class using a constructor matched by parameter types.Objectcreate(JarClassLoader jcl, String className, String methodName, Object... args)Creates an instance via a static factory method with no arguments.Objectcreate(JarClassLoader jcl, String className, String methodName, Object[] args, Class<?>[] types)Creates an instance via a static factory method matched by parameter types.static JclObjectFactorygetInstance()Returns the instance of the singleton factorystatic JclObjectFactorygetInstance(boolean autoProxy)Returns the instance of the singleton factory that can be used to create auto proxies for jcl-created objects
-
-
-
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 fromclassName- 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 fromclassName- binary name of the class to instantiateargs- 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 fromclassName- binary name of the class to instantiateargs- constructor argumentstypes- 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 fromclassName- binary name of the classmethodName- static factory method nameargs- 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 fromclassName- binary name of the classmethodName- static factory method nameargs- method argumentstypes- method parameter types- Returns:
- object returned by the factory method
-
-