Package com.jk.core.factory
Class JKFactory
java.lang.Object
com.jk.core.factory.JKFactory
This class provides methods for creating instances, associating
 implementations, and checking for the existence of beans in a Spring context.
- Version:
 - 1.0
 - Author:
 - Dr. Jalal H. Kiswani
 
- 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionstatic voidThis method outputs the names of all beans registered in the Spring context.static booleanThis method checks whether a bean of the specified class exists in the Spring context.static <T> TThis method retrieves an instance of the provided superclass, either from a predefined map, the Spring context, or by directly instantiating the class.static <T> TThis method retrieves an instance of the provided superclass and falls back to a default handler if no bean definition is found in the Spring context.static voidThis main method makes an instance of theJKFactorywith theTestclass.static voidThis method registers an instance of the provided class in the Spring context.static voidsetImplementation(Class<?> clas, Class<?> impl) This method associates an interface or superclass with its corresponding implementation class.static <T> Class<? extends T>This method gets the runtime class of an instance created from the provided class. 
- 
Constructor Details
- 
JKFactory
public JKFactory() 
 - 
 - 
Method Details
- 
register
This method registers an instance of the provided class in the Spring context.- Parameters:
 implementation- Represents the class to be registered as a bean in the Spring context.
 - 
instance
This method retrieves an instance of the provided superclass, either from a predefined map, the Spring context, or by directly instantiating the class.- Type Parameters:
 T- Specifies the type of the class to be instantiated.- Parameters:
 superClass- Specifies the superclass or interface class to obtain an instance of.- Returns:
 - an instance of the provided superclass or interface.
 
 - 
dumpBeansNames
public static void dumpBeansNames()This method outputs the names of all beans registered in the Spring context. - 
main
This main method makes an instance of theJKFactorywith theTestclass.- Parameters:
 args- The command-line arguments.
 - 
type
This method gets the runtime class of an instance created from the provided class.- Type Parameters:
 T- Specifies the type of the class and instance- Parameters:
 class1- Specifies the class for which the runtime class of an instance is to be obtained- Returns:
 - the runtime class of an instance created from the provided class.
 
 - 
exists
This method checks whether a bean of the specified class exists in the Spring context.- Parameters:
 clas- Specifies the class to check for bean existence.- Returns:
 - true, if a bean of the specified class exists, false otherwise.
 
 - 
setImplementation
This method associates an interface or superclass with its corresponding implementation class.- Parameters:
 clas- Specifies the interface or superclass class to be associated.impl- Specifies the implementation class to be associated with the interface or superclass.
 - 
instance
This method retrieves an instance of the provided superclass and falls back to a default handler if no bean definition is found in the Spring context.- Type Parameters:
 T- Specifies the type of the class to be instantiated.- Parameters:
 superClass- Specifies the superclass class for which an instance is to be obtained.defaultHandler- Specifies the default handler class to use if no bean definition is found.- Returns:
 - an instance of the provided superclass or the default handler.
 
 
 -