Package org.springframework.roo.file.monitor.event

Examples of org.springframework.roo.file.monitor.event.FileDetails


     */
    @Override
    protected PhysicalPath getApplicablePhysicalPath(final String identifier) {
        Validate.notNull(identifier, "Identifier required");
        for (final PhysicalPath pi : rootModulePaths.values()) {
            final FileDetails possibleParent = new FileDetails(
                    pi.getLocation(), null);
            if (possibleParent.isParentOf(identifier)) {
                return pi;
            }
        }
        return null;
    }
View Full Code Here


                iter.remove(); // We've processed it
                // Skip this file if it doesn't exist
                final File thisFile = new File(filePath);
                if (thisFile.exists()) {
                    // Record the notification
                    createEvents.add(new FileEvent(new FileDetails(thisFile,
                            thisFile.lastModified()), FileOperation.CREATED,
                            null));
                    // Update the prior execution map so it isn't notified again
                    // next round
                    priorFiles.put(thisFile, thisFile.lastModified());
View Full Code Here

                // Skip this file if it suddenly exists again (it shouldn't be
                // in the notify deleted in this case!)
                final File thisFile = new File(filePath);
                if (!thisFile.exists()) {
                    // Record the notification
                    deleteEvents.add(new FileEvent(new FileDetails(thisFile,
                            null), FileOperation.DELETED, null));
                    // Update the prior execution map so it isn't notified again
                    // next round
                    priorFiles.remove(thisFile);
                }
View Full Code Here

                iter.remove(); // We've processed it
                // Skip this file if it doesn't exist
                final File thisFile = new File(filePath);
                if (thisFile.exists()) {
                    // Record the notification
                    updateEvents.add(new FileEvent(new FileDetails(thisFile,
                            thisFile.lastModified()), FileOperation.UPDATED,
                            null));
                    // Update the prior execution map so it isn't notified again
                    // next round
                    priorFiles.put(thisFile, thisFile.lastModified());
View Full Code Here

            for (final MonitoringRequest request : requests) {
                if (priorExecution.containsKey(request)) {
                    final Map<File, Long> priorFiles = priorExecution
                            .get(request);
                    for (final Entry<File, Long> entry : priorFiles.entrySet()) {
                        monitored.add(new FileDetails(entry.getKey(), entry
                                .getValue()));
                    }
                }
            }
View Full Code Here

            return;
        }
        for (final File f : listFiles) {
            try {
                if (FileUtils.matchesAntPath(antPath, f.getCanonicalPath())) {
                    result.add(new FileDetails(f, f.lastModified()));
                }
            }
            catch (final IOException ignored) {
            }
View Full Code Here

                final Map<File, Long> priorFiles = priorExecution.get(request);
                for (final Entry<File, Long> entry : priorFiles.entrySet()) {
                    final File thisFile = entry.getKey();
                    final Long lastModified = entry.getValue();
                    eventsToPublish.add(new FileEvent(new FileDetails(thisFile,
                            lastModified), FileOperation.MONITORING_FINISH,
                            null));
                }
                publish(eventsToPublish);
            }
View Full Code Here

                        final File thisFile = entry.getKey();
                        final Long currentTimestamp = entry.getValue();
                        if (!priorFiles.containsKey(thisFile)) {
                            // This file did not exist last execution, so it
                            // must be new
                            eventsToPublish.add(new FileEvent(new FileDetails(
                                    thisFile, currentTimestamp),
                                    FileOperation.CREATED, null));
                            try {
                                // If this file was already going to be
                                // notified, there is no need to do it twice
                                notifyCreated.remove(thisFile
                                        .getCanonicalPath());
                            }
                            catch (final IOException ignored) {
                            }
                            continue;
                        }

                        final Long previousTimestamp = priorFiles.get(thisFile);
                        if (!currentTimestamp.equals(previousTimestamp)) {
                            // Modified
                            eventsToPublish.add(new FileEvent(new FileDetails(
                                    thisFile, currentTimestamp),
                                    FileOperation.UPDATED, null));
                            try {
                                // If this file was already going to be
                                // notified, there is no need to do it twice
                                notifyChanged.remove(thisFile
                                        .getCanonicalPath());
                            }
                            catch (final IOException ignored) {
                            }
                        }
                    }

                    // Now locate deleted files
                    priorFiles.keySet().removeAll(currentExecution.keySet());
                    for (final Entry<File, Long> entry : priorFiles.entrySet()) {
                        final File deletedFile = entry.getKey();
                        eventsToPublish.add(new FileEvent(new FileDetails(
                                deletedFile, entry.getValue()),
                                FileOperation.DELETED, null));
                        try {
                            // If this file was already going to be notified,
                            // there is no need to do it twice
                            notifyDeleted
                                    .remove(deletedFile.getCanonicalPath());
                        }
                        catch (final IOException ignored) {
                        }
                    }
                }
                else {
                    // No data from previous execution, so it's a
                    // newly-monitored location
                    for (final Entry<File, Long> entry : currentExecution
                            .entrySet()) {
                        eventsToPublish.add(new FileEvent(new FileDetails(entry
                                .getKey(), entry.getValue()),
                                FileOperation.MONITORING_START, null));
                    }
                }

                // Record the monitored location's contents, ready for next
                // execution
                priorExecution.put(request, currentExecution);

                // We can discard the created and deleted notifications, as they
                // would have been correctly discovered in the above loop
                notifyCreated.clear();
                notifyDeleted.clear();

                // Explicitly handle any undiscovered update notifications, as
                // this indicates an identical millisecond update occurred
                for (final String canonicalPath : notifyChanged) {
                    final File file = new File(canonicalPath);
                    eventsToPublish.add(new FileEvent(new FileDetails(file,
                            file.lastModified()), FileOperation.UPDATED, null));
                }
                notifyChanged.clear();
                publish(eventsToPublish);
View Full Code Here

    public String getRelativeSegment(final String identifier) {
        final PhysicalPath parent = getApplicablePhysicalPath(identifier);
        if (parent == null) {
            return null;
        }
        final FileDetails parentFile = new FileDetails(parent.getLocation(),
                null);
        return parentFile.getRelativeSegment(identifier);
    }
View Full Code Here

                    && removeTrailingSeparator(pom.getRoot()).length() > longest) {
                longest = removeTrailingSeparator(pom.getRoot()).length();
                int nextLongest = 0;
                for (final PhysicalPath thisPhysicalPath : pom
                        .getPhysicalPaths()) {
                    final String possibleParent = new FileDetails(
                            thisPhysicalPath.getLocation(), null)
                            .getCanonicalPath();
                    if (removeTrailingSeparator(identifier).startsWith(
                            possibleParent)
                            && possibleParent.length() > nextLongest) {
View Full Code Here

TOP

Related Classes of org.springframework.roo.file.monitor.event.FileDetails

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.