public void cleanUpListeners(){
synchronized (listenerObjectMap) {
    for (    ObjectName objectName : listenerObjectMap.keySet()) {
      NotificationHubListener listener=listenerObjectMap.get(objectName);
      if (listener != null) {
        try {
          mbeanServer.removeNotificationListener(objectName,listener);
        }
 catch (        ListenerNotFoundException e) {
        }
catch (        InstanceNotFoundException e) {
        }
      }
    }
  }
  listenerObjectMap.clear();
}

public void cleanUpListeners ( ) { synchronized ( listenerObjectMap ) { for ( ObjectName objectName : listenerObjectMap . keySet ( ) ) { NotificationHubListener listener = listenerObjectMap . get ( objectName ) ; if ( listener != null ) { try { mbeanServer . removeNotificationListener ( objectName , listener ) ; } catch ( ListenerNotFoundException e ) { } catch ( InstanceNotFoundException e ) { } } } } listenerObjectMap . clear ( ) ; }
this method is basically to cleanup resources which might cause leaks if the same vm is used again for cache creation .
