Package ghidra.framework.plugintool.mgr
Class ServiceManager
java.lang.Object
ghidra.framework.plugintool.mgr.ServiceManager
Class for managing plugin services. A plugin may provide a service, or
it may depend on a service. The ServiceManager maintains a list of
service names and plugins that provide those services. A plugin may
dynamically add and remove services from the service registry. As services
are added and removed, all the plugins (ServiceListener)
in the tool are notified.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> voidaddService(Class<? extends T> interfaceClass, T service) Add the service to the tool.voidaddServiceListener(ServiceListener listener) Add listener that is notified when services are added or removed.Returns a array of all service implementors.<T> TgetService(Class<T> interfaceClass) Return the first implementation found for the given service class.<T> T[]getServices(Class<T> interfaceClass) Get an array of objects that implement the given interfaceClass.booleanReturns true if the specifiedserviceInterfaceis a valid service that exists in this service manager.voidremoveService(Class<?> interfaceClass, Object service) Remove the service from the tool.voidremoveServiceListener(ServiceListener listener) Remove the given listener from list of listeners notified when services are added or removed.voidsetServiceAddedNotificationsOn(boolean b) Set the indicator for whether service listeners should be notified.
-
Constructor Details
-
ServiceManager
public ServiceManager()Construct a new Service Registry.
-
-
Method Details
-
addServiceListener
Add listener that is notified when services are added or removed.- Parameters:
listener- listener to notify
-
removeServiceListener
Remove the given listener from list of listeners notified when services are added or removed.- Parameters:
listener- listener to remove
-
setServiceAddedNotificationsOn
public void setServiceAddedNotificationsOn(boolean b) Set the indicator for whether service listeners should be notified. While plugins are being restored from a tool state, this indicator is false, as a plugin may not be in the proper state to handle the notification.- Parameters:
b- true means to notify listeners of the services added to the tool
-
addService
Add the service to the tool. Notify the service listeners if the notification indicator is true; otherwise, add the service to a list that will be used to notify listeners when notifications are turned on again.- Parameters:
interfaceClass- class of the service interface being addedservice- implementation of the service; it may be a plugin or may be some object created by the plugin- See Also:
-
removeService
Remove the service from the tool.- Parameters:
interfaceClass- the service interfaceservice- the service implementation
-
getService
Return the first implementation found for the given service class.- Parameters:
interfaceClass- interface class for the service- Returns:
- null if the interfaceClass was not registered
-
getServices
Get an array of objects that implement the given interfaceClass.- Parameters:
interfaceClass- interface class for the service- Returns:
- zero length array if the interfaceClass was not registered
-
isService
Returns true if the specifiedserviceInterfaceis a valid service that exists in this service manager.- Parameters:
serviceInterface- the service interface- Returns:
- true if the specified
serviceInterface
-
getAllServices
Returns a array of all service implementors.- Returns:
- a array of all service implementors
-