Package org.uberfire.java.nio.base

Examples of org.uberfire.java.nio.base.WatchContext


                    final List<WatchEvent<?>> events = wk.pollEvents();

                    boolean markerFileModified = false;
                    for ( final WatchEvent<?> event : events ) {
                        final WatchContext context = (WatchContext) event.context();
                        if ( event.kind().equals( StandardWatchEventKind.ENTRY_MODIFY ) ) {
                            if ( context.getOldPath().getFileName().toString().equals( LAST_MODIFIED_MARKER_FILE ) ) {
                                markerFileModified = true;
                                break;
                            }
                        } else if ( event.kind().equals( StandardWatchEventKind.ENTRY_CREATE ) ) {
                            if ( context.getPath().getFileName().toString().equals( LAST_MODIFIED_MARKER_FILE ) ) {
                                markerFileModified = true;
                                break;
                            }
                        } else if ( event.kind().equals( StandardWatchEventKind.ENTRY_RENAME ) ) {
                            if ( context.getOldPath().getFileName().toString().equals( LAST_MODIFIED_MARKER_FILE ) ) {
                                markerFileModified = true;
                                break;
                            }
                        } else if ( event.kind().equals( StandardWatchEventKind.ENTRY_DELETE ) ) {
                            if ( context.getOldPath().getFileName().toString().equals( LAST_MODIFIED_MARKER_FILE ) ) {
                                markerFileModified = true;
                                break;
                            }
                        }
                    }
View Full Code Here


    }

    public void execute( final WatchKey wk,
                         final Filter<WatchEvent<?>> filter ) {
        final List<WatchEvent<?>> events = wk.pollEvents();
        WatchContext firstContext = null;

        if ( events.size() > 1 ) {
            final Map<Path, Collection<ResourceChange>> changes = new HashMap<Path, Collection<ResourceChange>>();
            for ( final WatchEvent event : events ) {
                if ( !filter.doFilter( event ) ) {
View Full Code Here

        return context.getMessage();
    }

    private <T extends ResourceEvent> Pair<Path, T> buildEvent( final Class<T> clazz,
                                                                final WatchEvent<?> event ) {
        final WatchContext context = (WatchContext) event.context();

        final Path _affectedPath;
        final T result;
        if ( event.kind().equals( StandardWatchEventKind.ENTRY_MODIFY ) ) {
            _affectedPath = convert( context.getOldPath() );
            result = (T) new ResourceUpdatedEvent( _affectedPath, context.getMessage(), sessionInfo( context ) );
        } else if ( event.kind().equals( StandardWatchEventKind.ENTRY_CREATE ) ) {
            _affectedPath = convert( context.getPath() );
            result = (T) new ResourceAddedEvent( _affectedPath, context.getMessage(), sessionInfo( context ) );
        } else if ( event.kind().equals( StandardWatchEventKind.ENTRY_RENAME ) ) {
            _affectedPath = convert( context.getOldPath() );
            result = (T) new ResourceRenamedEvent( _affectedPath, convert( context.getPath() ), context.getMessage(), sessionInfo( context ) );
        } else if ( event.kind().equals( StandardWatchEventKind.ENTRY_DELETE ) ) {
            _affectedPath = convert( context.getOldPath() );
            result = (T) new ResourceDeletedEvent( _affectedPath, context.getMessage(), sessionInfo( context ) );
        } else {
            _affectedPath = null;
            result = null;
        }
        if ( _affectedPath == null ) {
View Full Code Here

        return Pair.newPair( _affectedPath, result );
    }

    private Pair<Path, ResourceChange> buildChange( final WatchEvent<?> event ) {
        final WatchContext context = (WatchContext) event.context();

        final Path _affectedPath;
        final ResourceChange result;
        if ( event.kind().equals( StandardWatchEventKind.ENTRY_MODIFY ) ) {
            _affectedPath = convert( context.getOldPath() );
            result = new ResourceUpdated();
        } else if ( event.kind().equals( StandardWatchEventKind.ENTRY_CREATE ) ) {
            _affectedPath = convert( context.getPath() );
            result = new ResourceAdded();
        } else if ( event.kind().equals( StandardWatchEventKind.ENTRY_RENAME ) ) {
            _affectedPath = convert( context.getOldPath() );
            result = new ResourceRenamed( convert( context.getPath() ), context.getMessage() );
        } else if ( event.kind().equals( StandardWatchEventKind.ENTRY_DELETE ) ) {
            _affectedPath = convert( context.getOldPath() );
            result = new ResourceDeleted();
        } else {
            _affectedPath = null;
            result = null;
        }
View Full Code Here

@ApplicationScoped
public class IOWatchServiceNonDotImpl extends AbstractIOWatchService {

    @Override
    public boolean doFilter( WatchEvent<?> object ) {
        final WatchContext context = (WatchContext) object.context();
        if ( object.kind().equals( StandardWatchEventKind.ENTRY_MODIFY ) ) {
            if ( context.getOldPath().getFileName().toString().startsWith( "." ) ) {
                return true;
            }
        } else if ( object.kind().equals( StandardWatchEventKind.ENTRY_CREATE ) ) {
            if ( context.getPath().getFileName().toString().startsWith( "." ) ) {
                return true;
            }
        } else if ( object.kind().equals( StandardWatchEventKind.ENTRY_RENAME ) ) {
            if ( context.getOldPath().getFileName().toString().startsWith( "." ) ) {
                return true;
            }
        } else if ( object.kind().equals( StandardWatchEventKind.ENTRY_DELETE ) ) {
            if ( context.getOldPath().getFileName().toString().startsWith( "." ) ) {
                return true;
            }
        }
        return false;
    }
View Full Code Here

                    return 1;
                }

                @Override
                public Object context() {
                    return new WatchContext() {

                        @Override
                        public Path getPath() {
                            return newPath;
                        }
View Full Code Here

TOP

Related Classes of org.uberfire.java.nio.base.WatchContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.