public ServiceRegistration < FileMonitor > monitorFiles ( String ID , Collection < String > paths , long pollingRate , String trigger ) { BundleContext bundleContext = actionable . getBundleContext ( ) ; final Hashtable < String , Object > fileMonitorProps = new Hashtable < String , Object > ( ) ; fileMonitorProps . put ( FileMonitor . MONITOR_FILES , paths ) ; //Adding INTERNAL parameter MONITOR_IDENTIFICATION_NAME to identify this monitor. fileMonitorProps . put ( com . ibm . ws . kernel . filemonitor . FileMonitor . MONITOR_IDENTIFICATION_NAME , com . ibm . ws . kernel . filemonitor . FileMonitor . SECURITY_MONITOR_IDENTIFICATION_VALUE ) ; //Adding parameter MONITOR_IDENTIFICATION_CONFIG_ID to identify this monitor by the ID. fileMonitorProps . put ( com . ibm . ws . kernel . filemonitor . FileMonitor . MONITOR_KEYSTORE_CONFIG_ID , ID ) ; if ( ! ( trigger . equalsIgnoreCase ( "disabled" ) ) ) { if ( trigger . equals ( "mbean" ) ) { fileMonitorProps . put ( FileMonitor . MONITOR_TYPE , FileMonitor . MONITOR_TYPE_EXTERNAL ) ; } else { fileMonitorProps . put ( FileMonitor . MONITOR_TYPE , FileMonitor . MONITOR_TYPE_TIMED ) ; fileMonitorProps . put ( FileMonitor . MONITOR_INTERVAL , pollingRate ) ; } } // Don't attempt to register the file monitor if the server is stopping if ( FrameworkState . isStopping ( ) ) return null ; return bundleContext . registerService ( FileMonitor . class , this , fileMonitorProps ) ; }
Registers this file monitor to start monitoring the specified files either by mbean notification or polling rate .