Java Code Examples for org.apache.commons.vfs2.FileChangeEvent

The following examples show how to use org.apache.commons.vfs2.FileChangeEvent. These examples are extracted from open source projects. 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 Project: datawave   Source File: TypeMetadataProvider.java    License: 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 2
Source Project: datawave   Source File: TypeMetadataProvider.java    License: 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 3
Source Project: datawave   Source File: TypeMetadataProvider.java    License: 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 4
Source Project: commons-vfs   Source File: DelegateFileObject.java    License: 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 5
Source Project: commons-vfs   Source File: DelegateFileObject.java    License: 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 6
Source Project: commons-vfs   Source File: DelegateFileObject.java    License: 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 7
Source Project: commons-vfs   Source File: WeakRefFileListener.java    License: 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 8
Source Project: commons-vfs   Source File: WeakRefFileListener.java    License: 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 9
Source Project: commons-vfs   Source File: ProviderWriteTests.java    License: 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 10
Source Project: commons-vfs   Source File: ProviderWriteTests.java    License: 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 11
Source Project: commons-vfs   Source File: ProviderWriteTests.java    License: 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 12
@Override
public void fileCreated(FileChangeEvent fileChangeEvent) throws Exception { }
 
Example 13
@Override
public void fileDeleted(FileChangeEvent fileChangeEvent) throws Exception { }
 
Example 14
@Override
public void fileChanged(FileChangeEvent fileChangeEvent) throws Exception {
    Config.reload();
}
 
Example 15
Source Project: jbake   Source File: CustomFSChangeListener.java    License: 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 16
Source Project: jbake   Source File: CustomFSChangeListener.java    License: 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 17
Source Project: jbake   Source File: CustomFSChangeListener.java    License: 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 18
Source Project: commons-vfs   Source File: DefaultFileMonitorTest.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void fileCreated(final FileChangeEvent event)  {
    created.incrementAndGet();
}
 
Example 19
Source Project: commons-vfs   Source File: DefaultFileMonitorTest.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void fileDeleted(final FileChangeEvent event) {
    throw new UnsupportedOperationException();
}
 
Example 20
Source Project: commons-vfs   Source File: DefaultFileMonitorTest.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void fileChanged(final FileChangeEvent event) {
    throw new UnsupportedOperationException();
}
 
Example 21
Source Project: commons-vfs   Source File: DefaultFileMonitorTest.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void fileChanged(final FileChangeEvent event) throws Exception {
    changeStatus = 1;
}
 
Example 22
Source Project: commons-vfs   Source File: DefaultFileMonitorTest.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void fileDeleted(final FileChangeEvent event) throws Exception {
    changeStatus = 2;
}
 
Example 23
Source Project: commons-vfs   Source File: DefaultFileMonitorTest.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void fileCreated(final FileChangeEvent event) throws Exception {
    changeStatus = 3;
}
 
Example 24
Source Project: commons-vfs   Source File: WeakRefFileListener.java    License: 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);
}