로컬 파일의 변경 모니터링

Liberty에는 구성, 애플리케이션 및 기타 자원의 변경에 대한 응답으로 고도의 동적 동작이 있습니다. 이러한 동적 동작의 대부분은 로컬 파일 시스템에서 모니터링하는 변경에 따른 것입니다. 이 모니터링을 수행하는 서비스는 FileMonitor SPI를 통해 모든 Liberty 기능에서 사용 가능합니다. Liberty 커널에서 파일 모니터 서비스를 제공하므로, server.xml 파일에 기능을 지정하여 이를 사용 가능하도록 할 필요가 없습니다.

이 태스크 정보

FileMonitor SPI는 여러 가지 특성을 지정하여 모니터링되는 자원과 빈도를 지정합니다. FileMonitor 인터페이스를 구현하고 구현 클래스를 서비스 레지스트리에 등록해야 합니다.

각 Liberty SPI에 대한 Java™ API 문서는 ${wlp.install.dir}/dev 디렉토리의 javadoc 서브디렉토리 중 하나의 별도 .zip 파일에서 사용 가능합니다.

...
import com.ibm.wsspi.kernel.filemonitor.FileMonitor;
...

public class MyFileMonitor implements FileMonitor {
  ...

  	 private final BundleContext bundleContex;
    ...

  public MyFileMonitor(BundleContext bundleContext) {
    this.bundleContext = BundleContext;
    ...
  }
	
  public ServiceRegistration<FileMonitor> monitorFiles(Collection<String> paths, long monitorInterval) {
    ...
    final Hashtable<String, Object> fileMonitorProps = new Hashtable<String, Object>();
    fileMonitorProps.put(FileMonitor.MONITOR_FILES, paths);
    fileMonitorProps.put(FileMonitor.MONITOR_INTERVAL, monitorInterval);
    ...
    return bundleContext.registerService(FileMonitor.class, this, fileMonitorProps);
  }
  ...
}

주제의 유형을 표시하는 아이콘 태스크 주제

파일 이름: twlp_monitor_local_files.html