当前位置: 首页>>代码示例>>Java>>正文


Java FileListener类代码示例

本文整理汇总了Java中org.apache.commons.vfs2.FileListener的典型用法代码示例。如果您正苦于以下问题:Java FileListener类的具体用法?Java FileListener怎么用?Java FileListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FileListener类属于org.apache.commons.vfs2包,在下文中一共展示了FileListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: removeListener

import org.apache.commons.vfs2.FileListener; //导入依赖的package包/类
/**
 * Removes a listener from a file in this file system.
 * @param file The FileObject to be monitored.
 * @param listener The FileListener
 */
public void removeListener(final FileObject file,
                           final FileListener listener)
{
    synchronized (listenerMap)
    {
        final ArrayList<?> listeners = listenerMap.get(file.getName());
        if (listeners != null)
        {
            listeners.remove(listener);
            if (listeners.isEmpty())
            {
                listenerMap.remove(file.getName());
            }
        }
    }
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:22,代码来源:AbstractFileSystem.java

示例2: addListener

import org.apache.commons.vfs2.FileListener; //导入依赖的package包/类
/**
 * Adds a listener on a file in this file system.
 * @param file The FileObject to be monitored.
 * @param listener The FileListener
 */
public void addListener(final FileObject file,
                        final FileListener listener)
{
    synchronized (listenerMap)
    {
        ArrayList<FileListener> listeners = listenerMap.get(file.getName());
        if (listeners == null)
        {
            listeners = new ArrayList<FileListener>();
            listenerMap.put(file.getName(), listeners);
        }
        listeners.add(listener);
    }
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:20,代码来源:AbstractFileSystem.java

示例3: fireEvent

import org.apache.commons.vfs2.FileListener; //导入依赖的package包/类
/**
 * Fires an event.
 */
private void fireEvent(final AbstractFileChangeEvent event)
{
    FileListener[] fileListeners = null;
    final FileObject file = event.getFile();

    synchronized (listenerMap)
    {
        final ArrayList<?> listeners = listenerMap.get(file.getName());
        if (listeners != null)
        {
            fileListeners = listeners.toArray(new FileListener[listeners.size()]);
        }
    }

    if (fileListeners != null)
    {
        for (int i = 0; i < fileListeners.length; i++)
        {
            final FileListener fileListener = fileListeners[i];
            try
            {
                event.notify(fileListener);
            }
            catch (final Exception e)
            {
                final String message = Messages.getString("vfs.provider/notify-listener.warn", file);
                // getLogger().warn(message, e);
                VfsLog.warn(getLogger(), LOG, message, e);
            }
        }
    }
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:36,代码来源:AbstractFileSystem.java

示例4: installListener

import org.apache.commons.vfs2.FileListener; //导入依赖的package包/类
/**
 * This will install the <code>listener</code> at the given <code>file</code>.
 * @param file The FileObject to listen on.
 * @param listener The FileListener
 */
public static void installListener(final FileObject file, final FileListener listener)
{
    WeakRefFileListener weakListener = new WeakRefFileListener(file, listener);

    file.getFileSystem().addListener(file, new WeakRefFileListener(file, weakListener));
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:12,代码来源:WeakRefFileListener.java

示例5: getListener

import org.apache.commons.vfs2.FileListener; //导入依赖的package包/类
/**
 * returns the wrapped listener. If it is gone, the WeakRefFileListener wrapper will
 * remove itself from the list of listeners.
 * @return The FileListener.
 * @throws Exception if an error occurs.
 */
protected FileListener getListener() throws Exception
{
    FileListener listener = this.listener.get();
    if (listener == null)
    {
        FileObject file = fs.resolveFile(name);
        file.getFileSystem().removeListener(file, this);
    }
    return listener;
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:17,代码来源:WeakRefFileListener.java

示例6: fileCreated

import org.apache.commons.vfs2.FileListener; //导入依赖的package包/类
/**
 * Called when a file is created.
 * @param event The FileChangeEvent.
 * @throws Exception if an error occurs.
 */
public void fileCreated(final FileChangeEvent event) throws Exception
{
    FileListener listener = getListener();
    if (listener == null)
    {
        return;
    }
    listener.fileCreated(event);
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:15,代码来源:WeakRefFileListener.java

示例7: fileDeleted

import org.apache.commons.vfs2.FileListener; //导入依赖的package包/类
/**
 * Called when a file is deleted.
 * @param event The FileChangeEvent.
 * @throws Exception if an error occurs.
 */
public void fileDeleted(final FileChangeEvent event) throws Exception
{
    FileListener listener = getListener();
    if (listener == null)
    {
        return;
    }
    listener.fileDeleted(event);
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:15,代码来源:WeakRefFileListener.java

示例8: fileChanged

import org.apache.commons.vfs2.FileListener; //导入依赖的package包/类
/**
 * Called when a file is changed.
 * <p/>
 * This will only happen if you monitor the file using {@link org.apache.commons.vfs2.FileMonitor}.
 * @param event The FileChangeEvent.
 * @throws Exception if an error occurs.
 */
public void fileChanged(FileChangeEvent event) throws Exception
{
    FileListener listener = getListener();
    if (listener == null)
    {
        return;
    }
    listener.fileChanged(event);
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:17,代码来源:WeakRefFileListener.java

示例9: addListener

import org.apache.commons.vfs2.FileListener; //导入依赖的package包/类
public void addListener(FileObject path, FileListener listener) throws Exception {
    stop();
    try {
        monitor = new DefaultFileMonitor(listener);
        monitor.addFile(path);
    } finally {
        start();
    }

}
 
开发者ID:OlegNyr,项目名称:GisGMP,代码行数:11,代码来源:ScannerPath.java

示例10: notify

import org.apache.commons.vfs2.FileListener; //导入依赖的package包/类
@Override
public void notify(final FileListener listener) throws Exception
{
    listener.fileCreated(this);
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:6,代码来源:CreateEvent.java

示例11: notify

import org.apache.commons.vfs2.FileListener; //导入依赖的package包/类
@Override
public void notify(final FileListener listener) throws Exception
{
    listener.fileDeleted(this);
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:6,代码来源:DeleteEvent.java

示例12: notify

import org.apache.commons.vfs2.FileListener; //导入依赖的package包/类
@Override
public void notify(final FileListener listener) throws Exception
{
    listener.fileChanged(this);
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:6,代码来源:ChangedEvent.java

示例13: WeakRefFileListener

import org.apache.commons.vfs2.FileListener; //导入依赖的package包/类
protected WeakRefFileListener(final FileObject file, final FileListener listener)
{
    this.fs = file.getFileSystem();
    this.name = file.getName();
    this.listener = new WeakReference<FileListener>(listener);
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:7,代码来源:WeakRefFileListener.java

示例14: DefaultFileMonitor

import org.apache.commons.vfs2.FileListener; //导入依赖的package包/类
public DefaultFileMonitor(final FileListener listener)
{
    this.listener = listener;
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:5,代码来源:DefaultFileMonitor.java

示例15: getFileListener

import org.apache.commons.vfs2.FileListener; //导入依赖的package包/类
/**
 * Access method to get the current FileListener object notified when there
 * are changes with the files added.
 * @return The FileListener.
 */
FileListener getFileListener()
{
    return this.listener;
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:10,代码来源:DefaultFileMonitor.java


注:本文中的org.apache.commons.vfs2.FileListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。