Custom Destruction of Exported Services

When a service is exported it is sometimes necessary for it to be initialized in a domain specific manner. This is done in the hook method deactivate(). For example:

   protected void activate() {
     Timer timer = new Timer(3000);
     timer.startup();
     addExportedService(TimerService.SERVICE_NAME, timer, null);
   } 

To perform custom domain clean up of an exported service the hook method deactivate() should be overridden. For example:

   protected void deactivate() {
     Timer timer = (Timer) getExportedService(TimerService.SERVICE_NAME);
     timer.shutdown();
   }