Package org.uberfire.java.nio.file

Examples of org.uberfire.java.nio.file.WatchKey


        @Override
        public void execute( final ConfigServiceWatchServiceExecutor wsExecutor ) {
            while ( active ) {
                try {

                    final WatchKey wk;
                    try {
                        wk = ws.take();
                    } catch ( final Exception ex ) {
                        break;
                    }

                    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;
                            }
                        }
                    }

                    if ( markerFileModified ) {
                        wsExecutor.execute( wk, localLastModifiedValue.get(), ConfigurationServiceImpl.this );
                    }

                    boolean valid = wk.reset();
                    if ( !valid ) {
                        break;
                    }
                } catch ( final Exception ignored ) {
                }
View Full Code Here


                               final List<WatchEvent<?>> elist ) {
        if ( this.events.isEmpty() ) {
            return;
        }

        final WatchKey wk = new WatchKey() {

            @Override
            public boolean isValid() {
                return true;
            }
View Full Code Here

        WatchService ws = null;
        ws = fs.newWatchService();
        final Path path = fs.getRootDirectories().iterator().next();
        path.register( ws, StandardWatchEventKind.ENTRY_CREATE, StandardWatchEventKind.ENTRY_MODIFY, StandardWatchEventKind.ENTRY_DELETE, StandardWatchEventKind.ENTRY_RENAME );

        final WatchKey k = ws.take();

        final List<WatchEvent<?>> events = k.pollEvents();
        for ( WatchEvent object : events ) {
            if ( object.kind() == StandardWatchEventKind.ENTRY_MODIFY ) {
                System.out.println( "Modify: " + object.context().toString() );
            }
            if ( object.kind() == StandardWatchEventKind.ENTRY_RENAME ) {
View Full Code Here

        final AsyncWatchService asyncWatchService = new AsyncWatchService() {
            @Override
            public void execute( final IOWatchServiceExecutor wsExecutor ) {
                while ( !isDisposed ) {
                    final WatchKey wk;
                    try {
                        wk = ws.take();
                    } catch ( final Exception ex ) {
                        break;
                    }

                    wsExecutor.execute( wk, AbstractIOWatchService.this );

                    // Reset the key -- this step is critical if you want to
                    // receive further watch events.  If the key is no longer valid,
                    // the directory is inaccessible so exit the loop.
                    boolean valid = wk.reset();
                    if ( !valid ) {
                        break;
                    }
                }
            }
View Full Code Here

TOP

Related Classes of org.uberfire.java.nio.file.WatchKey

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.