Home > Guides > Core Developers Guide > DispatcherListener |

Apache Struts 2 Documentation
DispatcherListener
Edit Page Browse Space Add Page Add News

Use a DispatcherListener object to execute code when a Dispatcher is initalized or destroyed. A DispatcherListener is an easy way to associate customizable components like a ConfigurationManager with a Dispatcher.

## Example

      static {
         Dispatcher.addDispatcherListener(new DispatcherListener() {
             public void dispatcherInitialized(Dispatcher du) {
                // do something to Dispatcher after it is initialized eg.
                du.setConfigurationManager(....);
             }

             public void dispatcherDestroyed(Dispatcher du) {
                // do some cleanup after Dispatcher is destroyed.
             }
         });
      }

## Next: PreResultListener