Package com.swiftmq.swiftlet
Class SwiftletManager
java.lang.Object
com.swiftmq.swiftlet.SwiftletManager
The SwiftletManager is the single instance of a SwiftMQ router that is
acting as a container for Swiftlets. It is responsible for:
For each Swiftlet defined in the startorder attribute, the following tasks are performed:
A shutdown of a router is processed in the reverse order and the
Extension Swiftlets are loaded/unloaded on request through the methods
- startup/shutdown of the router (halt/reboot)
- startup/shutdown of Kernel Swiftlets
- startup/shutdown of Extension Swiftlets
- load/save of the configuration file
For each Swiftlet defined in the startorder attribute, the following tasks are performed:
- Instantiating the Swiftlet class from the kernel classloader
- Invoking the
startup
method of the Swiftlet. The Swiftlet configuration is passed as parameter.
startup
methods have been processed without exceptions.
A shutdown of a router is processed in the reverse order and the
shutdown
method of each Swiftlet is invoked.
Extension Swiftlets are loaded/unloaded on request through the methods
loadExtensionSwiftlet
and unloadExtensionSwiftlet
.- Author:
- IIT GmbH, Bremen/Germany, Copyright (c) 2000-2002, All Rights Reserved
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal void
Adds a KernelStartupListener.void
addSurviveData
(String key, Object data) Adds data to the survive data store.final void
Adds a SwiftletManagerListener for all Swiftlets.final void
addSwiftletManagerListener
(String swiftletName, SwiftletManagerListener l) Adds a SwiftletManagerListener for a specific Swiftlet.createBundleTable
(String kernelPath) protected void
void
protected void
protected void
fireSwiftletManagerEvent
(String swiftletName, String methodName, SwiftletManagerEvent evt) protected Configuration
getConfiguration
(Swiftlet swiftlet) getConfiguration
(String name) Returns the configuration of a specific Swiftlet.static SwiftletManager
Returns the singleton instance of the SwiftletManagerprotected org.dom4j.Element[]
Returns the name of this routergetSurviveData
(String key) Returns the survive data, stored under the given key.getSwiftlet
(String swiftletName) Returns the Swiftlet with the given name.final int
getSwiftletState
(String swiftletName) Returns the state of a Swiftlet.boolean
isHA()
boolean
boolean
Returns true if the router is within the reboot phase.boolean
boolean
Returns true if the router is within the startup phase.boolean
final boolean
isSwiftletDefined
(String swiftletName) Checks if the Swiftlet is defined.boolean
Returns true if the router is configured to use a smart management tree to avoid overloading management tools like SwiftMQ Explorer or CLI with management messages when connected to a router running a high load.void
loadExtensionSwiftlet
(Bundle bundle) Loads a new Extension Swiftlet.protected Swiftlet
loadSwiftlet
(String swiftletName) protected void
parseOptionalConfiguration
(org.dom4j.Element root) void
reboot()
Reboots this router without delay.void
reboot
(long delay) Reboots this router with delay.final void
Removes a KernelStartupListener.void
removeSurviveData
(String key) Removes the survive data, stored under the given key.final void
Removes a SwiftletManagerListener for all Swiftlets.final void
removeSwiftletManagerListener
(String swiftletName, SwiftletManagerListener l) Removes a SwiftletManagerListener for a specific Swiftlet.void
void
Saves this router's configuration.protected String[]
void
setConfigDirty
(boolean configDirty) void
setDoFireKernelStartedEvent
(boolean doFireKernelStartedEvent) void
setQuietMode
(boolean quietMode) void
setRegisterShutdownHook
(boolean registerShutdownHook) void
setStrippedMode
(boolean strippedMode) void
setWorkingDirectory
(String workingDirectory) void
shutdown()
Performs a shutdown of the router.void
shutdown
(boolean removeShutdownHook) protected void
shutdownSwiftlet
(Swiftlet swiftlet) protected void
startKernelSwiftlet
(String actSwiftletName, Map<String, Swiftlet> table) protected void
void
startRouter
(String name) Starts the router.protected void
protected void
protected void
protected void
void
unloadExtensionSwiftlet
(Bundle bundle) Unloads an Extension Swiftlet.
-
Field Details
-
_instance
-
-
Constructor Details
-
SwiftletManager
protected SwiftletManager()
-
-
Method Details
-
getInstance
Returns the singleton instance of the SwiftletManager- Returns:
- singleton instance
-
isHA
public boolean isHA() -
setDoFireKernelStartedEvent
public void setDoFireKernelStartedEvent(boolean doFireKernelStartedEvent) -
trace
-
startSwiftletDeployer
protected void startSwiftletDeployer() -
stopSwiftletDeployer
protected void stopSwiftletDeployer() -
getConfiguration
- Throws:
Exception
-
getConfiguration
Returns the configuration of a specific Swiftlet.- Parameters:
name
- Swiftlet name, e.g. "sys$topicmanager".- Returns:
- configuration
-
shutdownSwiftlet
- Throws:
SwiftletException
-
startKernelSwiftlets
protected void startKernelSwiftlets() -
startKernelSwiftlet
protected void startKernelSwiftlet(String actSwiftletName, Map<String, Swiftlet> table) throws Exception- Throws:
Exception
-
stopKernelSwiftlets
protected void stopKernelSwiftlets() -
getWorkingDirectory
-
setWorkingDirectory
-
isRegisterShutdownHook
public boolean isRegisterShutdownHook() -
setRegisterShutdownHook
public void setRegisterShutdownHook(boolean registerShutdownHook) -
disableShutdownHook
public void disableShutdownHook() -
isQuietMode
public boolean isQuietMode() -
setQuietMode
public void setQuietMode(boolean quietMode) -
isStrippedMode
public boolean isStrippedMode() -
setStrippedMode
public void setStrippedMode(boolean strippedMode) -
setConfigDirty
public void setConfigDirty(boolean configDirty) -
saveConfigIfDirty
public void saveConfigIfDirty() -
getLastSwiftlet
-
loadExtensionSwiftlet
Loads a new Extension Swiftlet. Will be used from the Deploy Swiftlet only.- Parameters:
bundle
- deployment bundle.- Throws:
Exception
- on error during load
-
unloadExtensionSwiftlet
Unloads an Extension Swiftlet. Will be used from the Deploy Swiftlet only.- Parameters:
bundle
- deployment bundle.
-
isUseSmartTree
public boolean isUseSmartTree()Returns true if the router is configured to use a smart management tree to avoid overloading management tools like SwiftMQ Explorer or CLI with management messages when connected to a router running a high load. This is only a hint. Each Swiftlet is responsible which content it puts into the management tree, especially the usage part.- Returns:
- true/false.
-
isStartup
public boolean isStartup()Returns true if the router is within the startup phase.- Returns:
- true/false.
-
isRebooting
public boolean isRebooting()Returns true if the router is within the reboot phase.- Returns:
- true/false.
-
createBundleTable
- Throws:
Exception
-
startRouter
Starts the router. This method is called from the bootstrap class only.- Parameters:
name
- name of the configuration file.- Throws:
Exception
- on error.
-
parseOptionalConfiguration
protected void parseOptionalConfiguration(org.dom4j.Element root) -
createRouterCommands
protected void createRouterCommands() -
reboot
public void reboot()Reboots this router without delay. A separate thread is used. The method returns immediately. -
reboot
public void reboot(long delay) Reboots this router with delay. A separate thread is NOT used. The method return after the reboot is done. This method call must be used from a separate thread.- Parameters:
delay
- A reboot delay in ms
-
loadSwiftlet
- Throws:
Exception
-
getSwiftlet
Returns the Swiftlet with the given name. This method only returns Kernel Swiftlets. It is not possible to get Extension Swiftlets due to different class loaders. If the Swiftlet is undefined or not started, null is returned.- Parameters:
swiftletName
- name of the Swiftlet, e.g. "sys$timer".- Returns:
- Swiftlet.
-
getSwiftletState
Returns the state of a Swiftlet.- Parameters:
swiftletName
- name of the Swiftlet.- Returns:
- state.
- Throws:
UnknownSwiftletException
- if the Swiftlet is undefined.
-
isSwiftletDefined
Checks if the Swiftlet is defined.- Parameters:
swiftletName
- name of the Swiftlet.- Returns:
- true/false.
-
shutdown
public void shutdown(boolean removeShutdownHook) -
shutdown
public void shutdown()Performs a shutdown of the router. -
getRouterName
Returns the name of this router- Returns:
- router name.
-
saveConfiguration
public void saveConfiguration()Saves this router's configuration. -
getOptionalElements
protected org.dom4j.Element[] getOptionalElements() -
saveConfiguration
-
addSurviveData
Adds data to the survive data store. Due to different class loaders of the Extension Swiftlets, it is not possible to store data in static data structures within the Swiftlet that do survive a reboot (shutdown/restart) of a router. Normally, a Swiftlet shouldn't have any data that must survive, but there are some exceptions, e.g. server sockets which should be reused. This kind of data can be registered within theshutdown
method of a Swiftlet under some key and fetched for reuse during thestartup
method.- Parameters:
key
- some key.data
- the data
-
removeSurviveData
Removes the survive data, stored under the given key.- Parameters:
key
- key.
-
getSurviveData
Returns the survive data, stored under the given key.- Parameters:
key
- key.- Returns:
- survive data.
-
addSwiftletManagerListener
Adds a SwiftletManagerListener for a specific Swiftlet.- Parameters:
swiftletName
- Swiftlet Name.l
- Listener.
-
addSwiftletManagerListener
Adds a SwiftletManagerListener for all Swiftlets.- Parameters:
l
- Listener.
-
removeSwiftletManagerListener
Removes a SwiftletManagerListener for a specific Swiftlet.- Parameters:
swiftletName
- Swiftlet Name.l
- Listener.
-
removeSwiftletManagerListener
Removes a SwiftletManagerListener for all Swiftlets.- Parameters:
l
- Listener.
-
addKernelStartupListener
Adds a KernelStartupListener.- Parameters:
l
- Listener.
-
removeKernelStartupListener
Removes a KernelStartupListener.- Parameters:
l
- Listener.
-
fireKernelStartedEvent
protected void fireKernelStartedEvent() -
fireSwiftletManagerEvent
protected void fireSwiftletManagerEvent(String swiftletName, String methodName, SwiftletManagerEvent evt)
-