本文整理汇总了Java中org.apache.commons.vfs2.FileChangeEvent类的典型用法代码示例。如果您正苦于以下问题:Java FileChangeEvent类的具体用法?Java FileChangeEvent怎么用?Java FileChangeEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FileChangeEvent类属于org.apache.commons.vfs2包,在下文中一共展示了FileChangeEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: callRaptureAction
import org.apache.commons.vfs2.FileChangeEvent; //导入依赖的package包/类
private void callRaptureAction(EventType et, FileChangeEvent fe){
String actionForEvent = getActionForEvent(et);
if (!actionForEvent.isEmpty()) {
//get the action type
Scheme scheme = new RaptureURI(actionForEvent).getScheme();
ImmutableMap<String, String> params = ImmutableMap.of("filetoprocess", fe.getFile().getName().toString());
switch (scheme){
case SCRIPT:
String runScript = Kernel.getScript().runScript(ContextFactory.getKernelUser(), actionForEvent, params);
log.info("Started script: " + runScript + " with params: " + params.toString());
break;
case WORKFLOW:
String createWorkOrder = Kernel.getDecision().createWorkOrder(ContextFactory.getKernelUser(), actionForEvent, params);
log.info("Started workorder: " + createWorkOrder + " with params: " + params.toString());
break;
default:
log.error(scheme + " is not supported for " + folder + FilenameUtils.getName(fe.getFile().getName().getBaseName()));
break;
}
} else {
log.error(et + " has no associated action for monitor on " + folder);
}
}
示例2: fileCreated
import org.apache.commons.vfs2.FileChangeEvent; //导入依赖的package包/类
@Override
public void fileCreated(FileChangeEvent event) throws Exception {
FileObject file = event.getFile();
try {
log.info("LOG00040:load file {}", file);
long id = executtor.loadMessageFromFileBisFormat(file);
log.debug("SUCCESS load file {}", file);
moveFileObrab(file, id, false);
} catch (Throwable th) {
log.error("LOG00050:" + file, th);
try {
moveFileObrab(file, 0, true);
} catch (Exception e) {
log.error("LOG00030:", e);
}
}
}
示例3: start
import org.apache.commons.vfs2.FileChangeEvent; //导入依赖的package包/类
@PostConstruct
public void start() throws Exception {
log.info("LOG00100: {}", monitorPath);
fileJobPath = MyVFS.getManager().resolveFile(jobPath);
FileAlterationListener fl = new FileAlterationListener();
FileObject path = MyVFS.getManager().resolveFile(monitorPath);
scannerPath.addListener(path, fl);
FileObject[] fileList = path.getChildren();
for (FileObject file : fileList) {
fl.fileCreated(new FileChangeEvent(file));
}
}
示例4: fileCreated
import org.apache.commons.vfs2.FileChangeEvent; //导入依赖的package包/类
@Override
public void fileCreated(FileChangeEvent fileChangeEvent) throws IOException {
FileObject fileObject = fileChangeEvent.getFile();
LOGGER.info(String.format("Received file creation event for file: %s", fileObject));
File file = new File(fileObject.getName().getPath());
if (ConfigFileFilter.isFileSupported(file)) {
configurationService.addOrUpdate(file);
Map<String, Object> params = new HashMap<>();
params.put(ConfigurationConstants.FILE_PATH, file.getAbsolutePath());
sendEvent(ConfigurationConstants.FILE_CREATED_EVENT_SUBJECT, params);
}
}
示例5: fileChanged
import org.apache.commons.vfs2.FileChangeEvent; //导入依赖的package包/类
@Override
public void fileChanged(FileChangeEvent fileChangeEvent) {
FileObject fileObject = fileChangeEvent.getFile();
LOGGER.info(String.format("Received file update event for file: %s", fileObject));
File file = new File(fileObject.getName().getPath());
if (ConfigFileFilter.isFileSupported(file)) {
configurationService.addOrUpdate(file);
Map<String, Object> params = new HashMap<>();
params.put(ConfigurationConstants.FILE_PATH, file.getAbsolutePath());
sendEvent(ConfigurationConstants.FILE_CHANGED_EVENT_SUBJECT, params);
}
}
示例6: fileDeleted
import org.apache.commons.vfs2.FileChangeEvent; //导入依赖的package包/类
@Override
public void fileDeleted(FileChangeEvent fileChangeEvent) throws FileSystemException {
FileObject fileObject = fileChangeEvent.getFile();
LOGGER.info(String.format("Received file deletion event for file: %s", fileObject));
File file = new File(fileObject.getName().getPath());
if (ConfigFileFilter.isFileSupported(file)) {
configurationService.deleteByBundle(file.getParentFile().getName());
Map<String, Object> params = new HashMap<>();
params.put(ConfigurationConstants.FILE_PATH, file.getAbsolutePath());
sendEvent(ConfigurationConstants.FILE_DELETED_EVENT_SUBJECT, params);
}
}
示例7: shouldSaveConfigWhenNewFileCreated
import org.apache.commons.vfs2.FileChangeEvent; //导入依赖的package包/类
@Test
public void shouldSaveConfigWhenNewFileCreated() throws IOException {
final String fileName = "res:config/org.motechproject.motech-module1/somemodule.properties";
FileObject fileObject = VFS.getManager().resolveFile(fileName);
configFileMonitor.fileCreated(new FileChangeEvent(fileObject));
verify(configurationService).addOrUpdate(new File(fileObject.getName().getPath()));
}
示例8: shouldNotSaveConfigWhenNewFileCreatedIsNotSupported
import org.apache.commons.vfs2.FileChangeEvent; //导入依赖的package包/类
@Test
public void shouldNotSaveConfigWhenNewFileCreatedIsNotSupported() throws IOException {
final String fileName = "res:config/motech-settings.conf";
FileObject fileObject = VFS.getManager().resolveFile(fileName);
configFileMonitor.fileCreated(new FileChangeEvent(fileObject));
verifyZeroInteractions(configurationService);
}
示例9: shouldSaveConfigWhenFileIsChanged
import org.apache.commons.vfs2.FileChangeEvent; //导入依赖的package包/类
@Test
public void shouldSaveConfigWhenFileIsChanged() throws IOException {
final String fileName = "res:config/org.motechproject.motech-module1/somemodule.properties";
FileObject fileObject = VFS.getManager().resolveFile(fileName);
configFileMonitor.fileChanged(new FileChangeEvent(fileObject));
verify(configurationService).addOrUpdate(new File(fileObject.getName().getPath()));
}
示例10: shouldDeleteConfigWhenFileIsDeleted
import org.apache.commons.vfs2.FileChangeEvent; //导入依赖的package包/类
@Test
public void shouldDeleteConfigWhenFileIsDeleted() throws FileSystemException {
final String fileName = "res:config/org.motechproject.motech-module1/somemodule.properties";
FileObject fileObject = VFS.getManager().resolveFile(fileName);
configFileMonitor.fileDeleted(new FileChangeEvent(fileObject));
verify(configurationService).deleteByBundle(new File(fileObject.getName().getPath()).getParentFile().getName());
}
示例11: fileChanged
import org.apache.commons.vfs2.FileChangeEvent; //导入依赖的package包/类
@Override
public void fileChanged(FileChangeEvent arg0) throws Exception {
// TODO Auto-generated method stub
System.out.println("fileChanged");
IFileSystemCom file = FileSystemCom.getInstance();
// if(dob.get(0).getId() == Integer.parseInt(XMLConstruct.getIdXMLFiles())){
// file.encryptFile(destinationShareFolder, local)
// }
file.encryptFile(this.dob, true);
}
示例12: fileCreated
import org.apache.commons.vfs2.FileChangeEvent; //导入依赖的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
{
if (event.getFile() != file)
{
return;
}
if (!ignoreEvent)
{
handleCreate(file.getType());
}
}
示例13: fileDeleted
import org.apache.commons.vfs2.FileChangeEvent; //导入依赖的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
{
if (event.getFile() != file)
{
return;
}
if (!ignoreEvent)
{
handleDelete();
}
}
示例14: fileChanged
import org.apache.commons.vfs2.FileChangeEvent; //导入依赖的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
{
if (event.getFile() != file)
{
return;
}
if (!ignoreEvent)
{
handleChanged();
}
}
示例15: fileCreated
import org.apache.commons.vfs2.FileChangeEvent; //导入依赖的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);
}