Class ManagerRegistry
java.lang.Object
com.zetaplugins.zetacore.services.di.ManagerRegistry
A registry for managing and injecting manager instances.
-
Constructor Summary
ConstructorsConstructorDescriptionManagerRegistry(JavaPlugin plugin) Creates a new ManagerRegistry for the given plugin. -
Method Summary
Modifier and TypeMethodDescription<T> TgetOrCreate(Class<T> cls) Gets an existing instance of the specified class, or creates one if it doesn't exist.voidinjectManagers(Object target) Injects manager instances into the fields of the target object.voidregisterInstance(Class<?> cls, Object instance) Registers an existing instance in the registry under a specific class.voidregisterInstance(Object instance) Registers an existing instance in the registry.
-
Constructor Details
-
ManagerRegistry
Creates a new ManagerRegistry for the given plugin.- Parameters:
plugin- The main plugin instance.
-
-
Method Details
-
registerInstance
Registers an existing instance in the registry.- Parameters:
instance- The instance to register.
-
registerInstance
Registers an existing instance in the registry under a specific class.- Parameters:
cls- The class to register the instance under.instance- The instance to register.
-
getOrCreate
Gets an existing instance of the specified class, or creates one if it doesn't exist.- Type Parameters:
T- The type of the instance.- Parameters:
cls- The class of the instance to get or create.- Returns:
- The existing or newly created instance.
-
injectManagers
Injects manager instances into the fields of the target object.- Parameters:
target- The target object to inject managers into.
-