Interface ComponentManager
- All Known Implementing Classes:
ComponentManagerImpl
- Author:
- Bogdan Stefanescu, Florent Guillaume
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
Listener interface for component manager events -
Method Summary
Modifier and TypeMethodDescriptionvoid
addComponentListener
(ComponentListener listener) Adds a component listener.void
addListener
(ComponentManager.Listener listener) Add a listener to be notified on manager actions like start / stop components.Gets the pending extensions by component.getComponent
(ComponentName name) Gets object instance managed by the named component.getComponentProvidingService
(Class<?> serviceClass) Gets the component that provides the given service.Returns the missing registrations, linked to missing target extension points.Gets the pending registrations and their dependencies.Gets the component if there is one having the given name.Gets the registered components.Gets the resolved component names in the order they were resolved<T> T
getService
(Class<T> serviceClass) Gets the service of type serviceClass if such a service was declared by a resolved runtime component.String[]
Get the list of all registered service names An empty array is returned if no registered services are found.Gets the components that fail on applicationStarted notificationboolean
Tests whether components were deployed over the initial snapshot (i.e. the actual registry differs from the snapshot) If no snapshot was done returns false.boolean
Check if a snapshot was doneboolean
isRegistered
(ComponentName name) Checks whether or not a component with the given name was registered.boolean
Tests whether the components are running.boolean
Tests whether the components are in standby mode.boolean
Tests whether the components were already started.boolean
Tests if the stash is emptydefault boolean
refresh()
Shortcut for refresh(false).boolean
refresh
(boolean reset) Refresh the registry using stashed registrations if any.void
Handles the registration of the given registration info.void
removeComponentListener
(ComponentListener listener) Removes a component listener.void
removeListener
(ComponentManager.Listener listener) Remove the component manager listener previously added byaddListener(Listener)
.boolean
reset()
Reset the registry to the last snapshot if any and stop the components (if they are currently started).void
restart
(boolean reset) Optionally reset the registry to the last snapshot and restart the components.void
resume()
Start standby components.void
setBlacklist
(Set<String> blacklist) void
shutdown()
Shuts down the component registry.int
size()
Gets the number of registered objects in this registry.void
snapshot()
Make a snapshot of the component registry.void
standby()
Stop all started components but don't deactivate them.void
standby
(int timeout) Same asstandby()
but log a warning if the timeout is reached while stopping componentsboolean
start()
Activate and start all resolved components.boolean
stop()
Stop and deactivate all resolved components.void
stop
(int timeout) Same asstop()
but log a warning if the timeout is reached while stopping componentsvoid
unregister
(ComponentName name) Unregisters a component given its name.void
Handles the unregistration of the given registration info.void
unstash()
Apply the stash if not empty.
-
Method Details
-
addComponentListener
Adds a component listener.Does nothing if the given listener is already registered.
- Parameters:
listener
- the component listener to add
-
removeComponentListener
Removes a component listener.Does nothing if the given listener is not registered.
- Parameters:
listener
- the component listener to remove
-
register
Handles the registration of the given registration info.This is called by the main registry when all dependencies of this registration info were solved and the object can be registered.
If true is returned, the object will be added to the main registry under the name given in RegistrationInfo.
- Parameters:
ri
- the registration info
-
unregister
Handles the unregistration of the given registration info.This is called by the main registry when the object is unregistered.
If true is returned, the object will be removed from the main registry.
- Parameters:
ri
- the registration info
-
unregister
Unregisters a component given its name.- Parameters:
name
- the component name
-
getRegistrationInfo
Gets the component if there is one having the given name.- Parameters:
name
- the component name- Returns:
- the component if any was registered with that name, null otherwise
-
getComponent
Gets object instance managed by the named component.- Parameters:
name
- the object name- Returns:
- the object instance if any. may be null
-
isRegistered
Checks whether or not a component with the given name was registered.- Parameters:
name
- the object name- Returns:
- true if an object with the given name was registered, false otherwise
-
getRegistrations
Collection<RegistrationInfo> getRegistrations()Gets the registered components.- Returns:
- a read-only collection of components
-
getPendingRegistrations
Map<ComponentName,Set<ComponentName>> getPendingRegistrations()Gets the pending registrations and their dependencies.- Returns:
- the pending registrations
-
getMissingRegistrations
Map<ComponentName,Set<Extension>> getMissingRegistrations()Returns the missing registrations, linked to missing target extension points.- Since:
- 8.10
-
getActivatingRegistrations
Collection<ComponentName> getActivatingRegistrations()Gets the pending extensions by component.- Returns:
- the pending extensions
-
getResolvedRegistrations
Collection<ComponentName> getResolvedRegistrations()Gets the resolved component names in the order they were resolved- Since:
- 9.2
-
getStartFailureRegistrations
Collection<ComponentName> getStartFailureRegistrations()Gets the components that fail on applicationStarted notification- Since:
- 7.4
-
size
int size()Gets the number of registered objects in this registry.- Returns:
- the number of registered objects
-
shutdown
void shutdown()Shuts down the component registry.This unregisters all objects registered in this registry.
-
getService
Gets the service of type serviceClass if such a service was declared by a resolved runtime component.If the component is not yet activated it will be prior to return the service.
- Type Parameters:
T
- the service type- Parameters:
serviceClass
- the service class- Returns:
- the service object
-
getServices
String[] getServices()Get the list of all registered service names An empty array is returned if no registered services are found.- Returns:
- an array of registered service.
-
getComponentProvidingService
Gets the component that provides the given service.- Parameters:
serviceClass
- the service class- Returns:
- the component or null if none
-
getBlacklist
-
setBlacklist
-
start
boolean start()Activate and start all resolved components. If components were already started do nothing.- Returns:
- false if components were already started, true otherwise
- Since:
- 9.2
-
stop
boolean stop()Stop and deactivate all resolved components. If components were not yet started do nothing- Returns:
- false if components were not yet started, true otherwise
- Since:
- 9.2
-
stop
void stop(int timeout) Same asstop()
but log a warning if the timeout is reached while stopping components- Since:
- 9.2
-
standby
void standby()Stop all started components but don't deactivate them. After calling this method you can safely contribute new extensions (i.e. modify extension registries).If any components were previously started do nothing
- Since:
- 9.2
-
standby
void standby(int timeout) Same asstandby()
but log a warning if the timeout is reached while stopping components- Since:
- 9.2
-
resume
void resume()Start standby components. If components are not in standby mode the it does nothing.- Since:
- 9.2
-
snapshot
void snapshot()Make a snapshot of the component registry. When calling restart- Since:
- 9.2
-
restart
void restart(boolean reset) Optionally reset the registry to the last snapshot and restart the components.When restarting components all components will be stopped, deactivated and re-instantiated. It means that all references to components before a restart will become invalid after the restart.
If no snapshot was created then the components will be restarted without changing the registry.
If the
reset
argument is true then the registry will be reverted to the last snapshot before starting the components.- Parameters:
reset
- whether or not to revert to the last snapshot- Since:
- 9.2
-
reset
boolean reset()Reset the registry to the last snapshot if any and stop the components (if they are currently started). After a reset all the components are stopped so we can contribute new components if needed. You must callstart()
to start again the components- Returns:
- true if the components were stopped, false otherwise
- Since:
- 9.2
-
refresh
boolean refresh(boolean reset) Refresh the registry using stashed registrations if any. If thereset
argument is true then the registry will be reverted to the last snapshot before applying the stash.If the stash is empty it does nothing and return true, otherwise it will:
- stop the components (if they are started)
- revert to the last snapshot (if reset flag is true)
- apply the stash (the stash will remain empty after this operation)
- start the components (if they was started)
- Parameters:
reset
- whether or not to revert to the last snapshot- Returns:
- false if stash is empty and nothing was done, true otherwise
- Since:
- 9.2
-
refresh
default boolean refresh()Shortcut for refresh(false).- Since:
- 9.2
- See Also:
-
isStarted
boolean isStarted()Tests whether the components were already started.- Returns:
- true if components are started, false
- Since:
- 9.2
-
isStandby
boolean isStandby()Tests whether the components are in standby mode. That means they were started and then stopped - waiting to be started again.When putting components in standby they are stopped but not deactivated. You start back the standby components by calling #resume
While in standby mode the component manager remains in running state.
- Since:
- 9.2
-
isRunning
boolean isRunning()Tests whether the components are running. That means they are either started either in standby mode.- Since:
- 9.2
-
hasChanged
boolean hasChanged()Tests whether components were deployed over the initial snapshot (i.e. the actual registry differs from the snapshot) If no snapshot was done returns false.- Since:
- 9.2
-
hasSnapshot
boolean hasSnapshot()Check if a snapshot was done- Returns:
- true if a snapshot already exists, false otherwise
- Since:
- 9.2
-
isStashEmpty
boolean isStashEmpty()Tests if the stash is empty- Since:
- 9.2
-
unstash
void unstash()Apply the stash if not empty. This is a low level operation and may not be safe to call when the component manager is runningisRunning()
.For compatibility reasons (to be able to emulate the old hot deploy mechanism or to speed up tests) this method will force a registry refresh in all 3 component manager states: stopped, standby, started.
Usually you should apply the stash by calling
refresh()
which is similar tostop(); [restoreSnapshot();] unstash(); start();
- Since:
- 9.2
-
addListener
Add a listener to be notified on manager actions like start / stop components.- Since:
- 9.2
-
removeListener
Remove the component manager listener previously added byaddListener(Listener)
. If the listener were not added then nothing is done.- Since:
- 9.2
-