org.apache.commons.vfs2.FileChangeEvent Java Examples

The following examples show how to use org.apache.commons.vfs2.FileChangeEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WeakRefFileListener.java    From commons-vfs with Apache License 2.0 5 votes vote down vote up
/**
 * Called when a file is created.
 *
 * @param event The FileChangeEvent.
 * @throws Exception if an error occurs.
 */
@Override
public void fileCreated(final FileChangeEvent event) throws Exception {
    final FileListener listener = getListener();
    if (listener == null) {
        return;
    }
    listener.fileCreated(event);
}
 
Example #2
Source File: ProviderWriteTests.java    From commons-vfs with Apache License 2.0 5 votes vote down vote up
@Override
public void fileChanged(final FileChangeEvent event) throws Exception {
    assertTrue("Unexpected changed event", events.size() > 0);
    assertSame("Expecting a changed event", CHANGED, events.remove(0));
    assertEquals(file, event.getFileObject());
    try {
        assertFalse(file.exists());
    } catch (final FileSystemException e) {
        fail();
    }
}
 
Example #3
Source File: ProviderWriteTests.java    From commons-vfs with Apache License 2.0 5 votes vote down vote up
/**
 * Called when a file is deleted.
 */
@Override
public void fileDeleted(final FileChangeEvent event) {
    assertTrue("Unexpected delete event", events.size() > 0);
    assertSame("Expecting a delete event", DELETE, events.remove(0));
    assertEquals(file, event.getFileObject());
    try {
        assertFalse(file.exists());
    } catch (final FileSystemException e) {
        fail();
    }
}
 
Example #4
Source File: ProviderWriteTests.java    From commons-vfs with Apache License 2.0 5 votes vote down vote up
/**
 * Called when a file is created.
 */
@Override
public void fileCreated(final FileChangeEvent event) {
    assertTrue("Unexpected create event", events.size() > 0);
    assertSame("Expecting a create event", CREATE, events.remove(0));
    assertEquals(file, event.getFileObject());
    try {
        assertTrue(file.exists());
    } catch (final FileSystemException e) {
        fail();
    }
}
 
Example #5
Source File: WeakRefFileListener.java    From commons-vfs with Apache License 2.0 5 votes vote down vote up
/**
 * Called when a file is deleted.
 *
 * @param event The FileChangeEvent.
 * @throws Exception if an error occurs.
 */
@Override
public void fileDeleted(final FileChangeEvent event) throws Exception {
    final FileListener listener = getListener();
    if (listener == null) {
        return;
    }
    listener.fileDeleted(event);
}
 
Example #6
Source File: TypeMetadataProvider.java    From datawave with Apache License 2.0 5 votes vote down vote up
@Override
public void fileCreated(FileChangeEvent event) throws FileSystemException {
    String metadataFileName = event.getFile().getName().toString();
    Matcher matcher = this.metadataTableNamePattern.matcher(metadataFileName);
    if (matcher.matches()) {
        String metadataTableName = matcher.group(1);
        typeMetadataMap.refresh(metadataTableName);
        if (log.isDebugEnabled()) {
            long modTime = event.getFile().getContent().getLastModifiedTime();
            log.debug("TypeMetadata file created, modified at: " + modTime);
        }
    }
}
 
Example #7
Source File: DelegateFileObject.java    From commons-vfs with Apache License 2.0 5 votes vote down vote up
/**
 * Called when a file is changed.
 * <p>
 * This will only happen if you monitor the file using {@link org.apache.commons.vfs2.FileMonitor}.
 * </p>
 *
 * @param event The FileChangeEvent.
 * @throws Exception if an error occurs.
 */
@Override
public void fileChanged(final FileChangeEvent event) throws Exception {
    if (event.getFileObject() != file) {
        return;
    }
    if (!ignoreEvent) {
        handleChanged();
    }
}
 
Example #8
Source File: DelegateFileObject.java    From commons-vfs with Apache License 2.0 5 votes vote down vote up
/**
 * Called when a file is deleted.
 *
 * @param event The FileChangeEvent.
 * @throws Exception if an error occurs.
 */
@Override
public void fileDeleted(final FileChangeEvent event) throws Exception {
    if (event.getFileObject() != file) {
        return;
    }
    if (!ignoreEvent) {
        handleDelete();
    }
}
 
Example #9
Source File: DelegateFileObject.java    From commons-vfs with Apache License 2.0 5 votes vote down vote up
/**
 * Called when a file is created.
 *
 * @param event The FileChangeEvent.
 * @throws Exception if an error occurs.
 */
@Override
public void fileCreated(final FileChangeEvent event) throws Exception {
    if (event.getFileObject() != file) {
        return;
    }
    if (!ignoreEvent) {
        handleCreate(file.getType());
    }
}
 
Example #10
Source File: TypeMetadataProvider.java    From datawave with Apache License 2.0 5 votes vote down vote up
@Override
public void fileChanged(FileChangeEvent event) throws FileSystemException {
    String metadataFileName = event.getFile().getName().toString();
    Matcher matcher = this.metadataTableNamePattern.matcher(metadataFileName);
    if (matcher.matches()) {
        String metadataTableName = matcher.group(1);
        typeMetadataMap.refresh(metadataTableName);
        if (log.isDebugEnabled()) {
            long modTime = event.getFile().getContent().getLastModifiedTime();
            log.debug("TypeMetadata file changed, modified at: " + modTime);
        }
    }
}
 
Example #11
Source File: TypeMetadataProvider.java    From datawave with Apache License 2.0 5 votes vote down vote up
@Override
public void fileDeleted(FileChangeEvent event) {
    String metadataFileName = event.getFile().getName().toString();
    Matcher matcher = this.metadataTableNamePattern.matcher(metadataFileName);
    if (matcher.matches()) {
        String metadataTableName = matcher.group(1);
        typeMetadataMap.refresh(metadataTableName);
        log.debug("TypeMetadata file deleted");
    }
}
 
Example #12
Source File: CustomFSChangeListener.java    From jbake with MIT License 4 votes vote down vote up
@Override
public void fileChanged(FileChangeEvent event) throws Exception {
    LOGGER.info("File changed event detected: {}", event.getFile().getURL());
    exec(event.getFile());
}
 
Example #13
Source File: CustomFSChangeListener.java    From jbake with MIT License 4 votes vote down vote up
@Override
public void fileDeleted(FileChangeEvent event) throws Exception {
    LOGGER.info("File deleted event detected: {}", event.getFile().getURL());
    exec(event.getFile());
}
 
Example #14
Source File: CustomFSChangeListener.java    From jbake with MIT License 4 votes vote down vote up
@Override
public void fileCreated(FileChangeEvent event) throws Exception {
    LOGGER.info("File created event detected: {}", event.getFile().getURL());
    exec(event.getFile());
}
 
Example #15
Source File: FileChangeListener.java    From yawl with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void fileChanged(FileChangeEvent fileChangeEvent) throws Exception {
    Config.reload();
}
 
Example #16
Source File: FileChangeListener.java    From yawl with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void fileDeleted(FileChangeEvent fileChangeEvent) throws Exception { }
 
Example #17
Source File: DefaultFileMonitorTest.java    From commons-vfs with Apache License 2.0 4 votes vote down vote up
@Override
public void fileCreated(final FileChangeEvent event)  {
    created.incrementAndGet();
}
 
Example #18
Source File: DefaultFileMonitorTest.java    From commons-vfs with Apache License 2.0 4 votes vote down vote up
@Override
public void fileDeleted(final FileChangeEvent event) {
    throw new UnsupportedOperationException();
}
 
Example #19
Source File: DefaultFileMonitorTest.java    From commons-vfs with Apache License 2.0 4 votes vote down vote up
@Override
public void fileChanged(final FileChangeEvent event) {
    throw new UnsupportedOperationException();
}
 
Example #20
Source File: DefaultFileMonitorTest.java    From commons-vfs with Apache License 2.0 4 votes vote down vote up
@Override
public void fileChanged(final FileChangeEvent event) throws Exception {
    changeStatus = 1;
}
 
Example #21
Source File: DefaultFileMonitorTest.java    From commons-vfs with Apache License 2.0 4 votes vote down vote up
@Override
public void fileDeleted(final FileChangeEvent event) throws Exception {
    changeStatus = 2;
}
 
Example #22
Source File: DefaultFileMonitorTest.java    From commons-vfs with Apache License 2.0 4 votes vote down vote up
@Override
public void fileCreated(final FileChangeEvent event) throws Exception {
    changeStatus = 3;
}
 
Example #23
Source File: FileChangeListener.java    From yawl with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void fileCreated(FileChangeEvent fileChangeEvent) throws Exception { }
 
Example #24
Source File: WeakRefFileListener.java    From commons-vfs with Apache License 2.0 3 votes vote down vote up
/**
 * Called when a file is changed.
 * <p>
 * This will only happen if you monitor the file using {@link org.apache.commons.vfs2.FileMonitor}.
 * </p>
 *
 * @param event The FileChangeEvent.
 * @throws Exception if an error occurs.
 */
@Override
public void fileChanged(final FileChangeEvent event) throws Exception {
    final FileListener listener = getListener();
    if (listener == null) {
        return;
    }
    listener.fileChanged(event);
}