public synchronized void refresh ( ApplicationMonitorConfig config ) { if ( config != null && config . isDropinsMonitored ( ) ) { //ApplicationMonitorConfig prevConfig = _config.getAndSet(config); _config . set ( config ) ; // keep track of the old monitored directory to see if we need to uninstall apps File previousMonitoredDirectory = null ; boolean createdPreviousDirectory = createdMonitoredDir . get ( ) ; String newMonitoredFolder = config . getLocation ( ) ; //if the user set the monitored folder location to be empty or it is somehow null if ( ( newMonitoredFolder != null ) && ( ! newMonitoredFolder . equals ( "" ) ) ) { previousMonitoredDirectory = updateMonitoredDirectory ( newMonitoredFolder ) ; } if ( ! ! ! _coreMonitor . isRegistered ( ) ) { stopRemovedApplications ( ) ; // The service has not been started yet. // load the pids for applications already setup before starting the service fully configureCoreMonitor ( config ) ; _coreMonitor . register ( _ctx , FileMonitor . class , new FileMonitorImpl ( ) ) ; Tr . audit ( _tc , "APPLICATION_MONITOR_STARTED" , newMonitoredFolder ) ; } else if ( ! ! ! monitoredDirectory . get ( ) . equals ( previousMonitoredDirectory ) ) { // The directory has changed so stop the old applications stopAllStartedApplications ( ) ; // Need to re-register because file monitor doesn't appear to work from modified events. _coreMonitor . unregister ( ) ; // Update the registration with new config before registering the service again configureCoreMonitor ( config ) ; _coreMonitor . register ( _ctx , FileMonitor . class , new FileMonitorImpl ( ) ) ; // Tidy up old location if we built it tidyUpMonitoredDirectory ( createdPreviousDirectory , previousMonitoredDirectory ) ; } } else { // the monitoring service has been disabled: stop/deregister the service stopAllStartedApplications ( ) ; stop ( ) ; } }
Initialize the dropins manager based on configured properties