001/******************************************************************************* 002 * Copyright (c) 2006-2014 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the Eclipse Public License v1.0 006 * which accompanies this distribution, and is available at 007 * http://www.eclipse.org/legal/epl-v10.html 008 ******************************************************************************/ 009package org.nuxeo.runtime.trackers.files; 010 011import org.nuxeo.runtime.services.event.Event; 012import org.nuxeo.runtime.services.event.EventListener; 013 014/* 015 * Wrap a {@link FileEventHandler} for being enlisted in the 016 * {@link EventService}. 017 * 018 * @since 6.0 019 */ 020public class FileEventListener implements EventListener { 021 022 protected final FileEventHandler handler; 023 024 public FileEventListener(FileEventHandler anHandler) { 025 handler = anHandler; 026 } 027 028 @Override 029 public boolean aboutToHandleEvent(Event event) { 030 return true; 031 } 032 033 @Override 034 public void handleEvent(Event anEvent) { 035 ((FileEvent) anEvent).handle(handler); 036 } 037 038 public void install() { 039 FileEvent.listen(this); 040 } 041 042 public void uninstall() { 043 FileEvent.ignore(this); 044 } 045}