Class SwiftletManager

java.lang.Object
com.swiftmq.swiftlet.SwiftletManager

public class SwiftletManager extends Object
The SwiftletManager is the single instance of a SwiftMQ router that is acting as a container for Swiftlets. It is responsible for:
  • startup/shutdown of the router (halt/reboot)
  • startup/shutdown of Kernel Swiftlets
  • startup/shutdown of Extension Swiftlets
  • load/save of the configuration file
During the startup phase of the router, the SwiftletManager loads the router's configuration file, and starts all Kernel Swiftlets. The startup order is defined in the 'startorder' attribute of the 'router' tag element 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.
The router is running after all Kernel Swiftlet's 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
  • Field Details

  • Constructor Details

    • SwiftletManager

      protected SwiftletManager()
  • Method Details

    • getInstance

      public static SwiftletManager getInstance()
      Returns the singleton instance of the SwiftletManager
      Returns:
      singleton instance
    • isHA

      public boolean isHA()
    • setDoFireKernelStartedEvent

      public void setDoFireKernelStartedEvent(boolean doFireKernelStartedEvent)
    • trace

      protected void trace(String message)
    • startSwiftletDeployer

      protected void startSwiftletDeployer()
    • stopSwiftletDeployer

      protected void stopSwiftletDeployer()
    • getConfiguration

      protected Configuration getConfiguration(Swiftlet swiftlet) throws Exception
      Throws:
      Exception
    • getConfiguration

      public Configuration getConfiguration(String name)
      Returns the configuration of a specific Swiftlet.
      Parameters:
      name - Swiftlet name, e.g. "sys$topicmanager".
      Returns:
      configuration
    • shutdownSwiftlet

      protected void shutdownSwiftlet(Swiftlet swiftlet) throws SwiftletException
      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

      public String getWorkingDirectory()
    • setWorkingDirectory

      public void setWorkingDirectory(String workingDirectory)
    • 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

      public String getLastSwiftlet()
    • loadExtensionSwiftlet

      public void loadExtensionSwiftlet(Bundle bundle) throws Exception
      Loads a new Extension Swiftlet. Will be used from the Deploy Swiftlet only.
      Parameters:
      bundle - deployment bundle.
      Throws:
      Exception - on error during load
    • unloadExtensionSwiftlet

      public void unloadExtensionSwiftlet(Bundle bundle)
      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

      protected Map<String,Bundle> createBundleTable(String kernelPath) throws Exception
      Throws:
      Exception
    • startRouter

      public void startRouter(String name) throws Exception
      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

      protected Swiftlet loadSwiftlet(String swiftletName) throws Exception
      Throws:
      Exception
    • getSwiftlet

      public Swiftlet getSwiftlet(String swiftletName)
      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

      public final int getSwiftletState(String swiftletName) throws UnknownSwiftletException
      Returns the state of a Swiftlet.
      Parameters:
      swiftletName - name of the Swiftlet.
      Returns:
      state.
      Throws:
      UnknownSwiftletException - if the Swiftlet is undefined.
    • isSwiftletDefined

      public final boolean isSwiftletDefined(String swiftletName)
      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

      public String 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

      protected String[] saveConfiguration(RouterConfigInstance entity)
    • addSurviveData

      public void addSurviveData(String key, Object data)
      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 the shutdown method of a Swiftlet under some key and fetched for reuse during the startup method.
      Parameters:
      key - some key.
      data - the data
    • removeSurviveData

      public void removeSurviveData(String key)
      Removes the survive data, stored under the given key.
      Parameters:
      key - key.
    • getSurviveData

      public Object getSurviveData(String key)
      Returns the survive data, stored under the given key.
      Parameters:
      key - key.
      Returns:
      survive data.
    • addSwiftletManagerListener

      public final void addSwiftletManagerListener(String swiftletName, SwiftletManagerListener l)
      Adds a SwiftletManagerListener for a specific Swiftlet.
      Parameters:
      swiftletName - Swiftlet Name.
      l - Listener.
    • addSwiftletManagerListener

      public final void addSwiftletManagerListener(SwiftletManagerListener l)
      Adds a SwiftletManagerListener for all Swiftlets.
      Parameters:
      l - Listener.
    • removeSwiftletManagerListener

      public final void removeSwiftletManagerListener(String swiftletName, SwiftletManagerListener l)
      Removes a SwiftletManagerListener for a specific Swiftlet.
      Parameters:
      swiftletName - Swiftlet Name.
      l - Listener.
    • removeSwiftletManagerListener

      public final void removeSwiftletManagerListener(SwiftletManagerListener l)
      Removes a SwiftletManagerListener for all Swiftlets.
      Parameters:
      l - Listener.
    • addKernelStartupListener

      public final void addKernelStartupListener(KernelStartupListener l)
      Adds a KernelStartupListener.
      Parameters:
      l - Listener.
    • removeKernelStartupListener

      public final void removeKernelStartupListener(KernelStartupListener l)
      Removes a KernelStartupListener.
      Parameters:
      l - Listener.
    • fireKernelStartedEvent

      protected void fireKernelStartedEvent()
    • fireSwiftletManagerEvent

      protected void fireSwiftletManagerEvent(String swiftletName, String methodName, SwiftletManagerEvent evt)