Package org.rribbit.creation
Class InstantiatingClassBasedListenerObjectCreator
java.lang.Object
org.rribbit.creation.ObjectBasedListenerObjectCreator
org.rribbit.creation.AbstractClassBasedListenerObjectCreator
org.rribbit.creation.InstantiatingClassBasedListenerObjectCreator
- All Implemented Interfaces:
ListenerObjectCreator
public class InstantiatingClassBasedListenerObjectCreator
extends AbstractClassBasedListenerObjectCreator
This
ListenerObjectCreator creates ListenerObjects from classes. Users can pass in Classes or packagenames and this class will scan the Classes
and create ListenerObjects for the public methods that are annotated with Listener. Note that public methods inherited from superclasses and superinterfaces will also be
scanned. This means that users must take care not to scan a method twice, once as a method of a class and once as a method of a superclass, by passing a class/interface and its
superclass/superinterface separately to this ListenerObjectCreator.
Please note that in Java, method annotations are NOT inherited. This means that, if you override/implement a method in a subclass or subinterface, and the overriding/implementing method
does not have the annotation, then that method will not inherit it. If a class or interface just inherits a method, without overriding it, then the annotation WILL exist.
To get the actual Objects that the listeners run on, this class simply attempts to instantiate an Object for each Class that it scans.
When there is no default constructor for a Class, the Class will simply be ignored.- Author:
- G.J. Schouten
-
Field Summary
Fields inherited from class org.rribbit.creation.AbstractClassBasedListenerObjectCreator
excludedClassesFields inherited from class org.rribbit.creation.ObjectBasedListenerObjectCreator
listenerObjects, observers -
Constructor Summary
ConstructorsConstructorDescriptionInstantiatingClassBasedListenerObjectCreator(Class<?>... classes) InstantiatingClassBasedListenerObjectCreator(Collection<Class<?>> excludedClasses, boolean scanSubPackages, String... packageNames) -
Method Summary
Modifier and TypeMethodDescriptionprotected ObjectgetTargetObjectForClass(Class<?> clazz) Gets a target executionObjectfor the given class to be used by aListenerObjectto execute itsMethod.Methods inherited from class org.rribbit.creation.AbstractClassBasedListenerObjectCreator
addClass, addPackage, excludeClass, findClassesInDirectory, findClassesInZipFile, getClasses, getClassLoaderMethods inherited from class org.rribbit.creation.ObjectBasedListenerObjectCreator
addObject, getIncompleteListenerObjectsFromClass, getListenerObjects, notifyObserversOnClassAdded, registerObserver
-
Constructor Details
-
InstantiatingClassBasedListenerObjectCreator
- Parameters:
classes-- See Also:
-
InstantiatingClassBasedListenerObjectCreator
public InstantiatingClassBasedListenerObjectCreator(Collection<Class<?>> excludedClasses, boolean scanSubPackages, String... packageNames) - Parameters:
excludedClasses-scanSubPackages-packageNames-- See Also:
-
-
Method Details
-
getTargetObjectForClass
Description copied from class:AbstractClassBasedListenerObjectCreatorGets a target executionObjectfor the given class to be used by aListenerObjectto execute itsMethod.- Specified by:
getTargetObjectForClassin classAbstractClassBasedListenerObjectCreator- Parameters:
clazz-- Returns:
- an
Objectthat has the type 'clazz' and can be used as an execution target, or 'null' if no suchObjectcan be found
-