Java 类org.springframework.boot.devtools.filewatch.ChangedFile 实例源码

项目:tapir    文件:DirectoryPcapStream.java   
@Override
public void onChange(Set<ChangedFiles> directories) {
    directories.stream()
            .map(ChangedFiles::getFiles)
            .flatMap(Set::stream)
            .map(ChangedFile::getFile)
            .filter(File::exists)
            .forEach(f -> {
                if (isGzipFile(f)) {
                    try {
                        GzipFileReader.read(f, this::openFilePcapStream);
                    } catch (Exception e) {
                        logger.error("Got exception...", e);
                    }
                } else {
                    openFilePcapStream(f);
                }
            });
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ClassPathFileChangeListenerTests.java   
private void testSendsEvent(boolean restart) {
    ClassPathFileChangeListener listener = new ClassPathFileChangeListener(
            this.eventPublisher, this.restartStrategy, this.fileSystemWatcher);
    File folder = new File("s1");
    File file = new File("f1");
    ChangedFile file1 = new ChangedFile(folder, file, ChangedFile.Type.ADD);
    ChangedFile file2 = new ChangedFile(folder, file, ChangedFile.Type.ADD);
    Set<ChangedFile> files = new LinkedHashSet<ChangedFile>();
    files.add(file1);
    files.add(file2);
    ChangedFiles changedFiles = new ChangedFiles(new File("source"), files);
    Set<ChangedFiles> changeSet = Collections.singleton(changedFiles);
    if (restart) {
        given(this.restartStrategy.isRestartRequired(file2)).willReturn(true);
    }
    listener.onChange(changeSet);
    verify(this.eventPublisher).publishEvent(this.eventCaptor.capture());
    ClassPathChangedEvent actualEvent = (ClassPathChangedEvent) this.eventCaptor
            .getValue();
    assertThat(actualEvent.getChangeSet()).isEqualTo(changeSet);
    assertThat(actualEvent.isRestartRequired()).isEqualTo(restart);
}
项目:spring-boot-concourse    文件:ClassPathFileChangeListenerTests.java   
private void testSendsEvent(boolean restart) {
    ClassPathFileChangeListener listener = new ClassPathFileChangeListener(
            this.eventPublisher, this.restartStrategy, this.fileSystemWatcher);
    File folder = new File("s1");
    File file = new File("f1");
    ChangedFile file1 = new ChangedFile(folder, file, ChangedFile.Type.ADD);
    ChangedFile file2 = new ChangedFile(folder, file, ChangedFile.Type.ADD);
    Set<ChangedFile> files = new LinkedHashSet<ChangedFile>();
    files.add(file1);
    files.add(file2);
    ChangedFiles changedFiles = new ChangedFiles(new File("source"), files);
    Set<ChangedFiles> changeSet = Collections.singleton(changedFiles);
    if (restart) {
        given(this.restartStrategy.isRestartRequired(file2)).willReturn(true);
    }
    listener.onChange(changeSet);
    verify(this.eventPublisher).publishEvent(this.eventCaptor.capture());
    ClassPathChangedEvent actualEvent = (ClassPathChangedEvent) this.eventCaptor
            .getValue();
    assertThat(actualEvent.getChangeSet()).isEqualTo(changeSet);
    assertThat(actualEvent.isRestartRequired()).isEqualTo(restart);
}
项目:contestparser    文件:ClassPathFileChangeListenerTests.java   
private void testSendsEvent(boolean restart) {
    ClassPathFileChangeListener listener = new ClassPathFileChangeListener(
            this.eventPublisher, this.restartStrategy, this.fileSystemWatcher);
    File folder = new File("s1");
    File file = new File("f1");
    ChangedFile file1 = new ChangedFile(folder, file, ChangedFile.Type.ADD);
    ChangedFile file2 = new ChangedFile(folder, file, ChangedFile.Type.ADD);
    Set<ChangedFile> files = new LinkedHashSet<ChangedFile>();
    files.add(file1);
    files.add(file2);
    ChangedFiles changedFiles = new ChangedFiles(new File("source"), files);
    Set<ChangedFiles> changeSet = Collections.singleton(changedFiles);
    if (restart) {
        given(this.restartStrategy.isRestartRequired(file2)).willReturn(true);
    }
    listener.onChange(changeSet);
    verify(this.eventPublisher).publishEvent(this.eventCaptor.capture());
    ClassPathChangedEvent actualEvent = (ClassPathChangedEvent) this.eventCaptor
            .getValue();
    assertThat(actualEvent.getChangeSet(), equalTo(changeSet));
    assertThat(actualEvent.isRestartRequired(), equalTo(restart));
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ClassPathChangeUploader.java   
private ClassLoaderFiles getClassLoaderFiles(ClassPathChangedEvent event)
        throws IOException {
    ClassLoaderFiles files = new ClassLoaderFiles();
    for (ChangedFiles changedFiles : event.getChangeSet()) {
        String sourceFolder = changedFiles.getSourceFolder().getAbsolutePath();
        for (ChangedFile changedFile : changedFiles) {
            files.addFile(sourceFolder, changedFile.getRelativeName(),
                    asClassLoaderFile(changedFile));
        }
    }
    return files;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ClassPathChangeUploader.java   
private ClassLoaderFile asClassLoaderFile(ChangedFile changedFile)
        throws IOException {
    ClassLoaderFile.Kind kind = TYPE_MAPPINGS.get(changedFile.getType());
    byte[] bytes = (kind == Kind.DELETED ? null
            : FileCopyUtils.copyToByteArray(changedFile.getFile()));
    long lastModified = (kind == Kind.DELETED ? System.currentTimeMillis()
            : changedFile.getFile().lastModified());
    return new ClassLoaderFile(kind, lastModified, bytes);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:PatternClassPathRestartStrategy.java   
@Override
public boolean isRestartRequired(ChangedFile file) {
    for (String pattern : this.excludePatterns) {
        if (this.matcher.match(pattern, file.getRelativeName())) {
            return false;
        }
    }
    return true;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ClassPathFileChangeListener.java   
private boolean isRestartRequired(Set<ChangedFiles> changeSet) {
    if (AgentReloader.isActive()) {
        return false;
    }
    for (ChangedFiles changedFiles : changeSet) {
        for (ChangedFile changedFile : changedFiles) {
            if (this.restartStrategy.isRestartRequired(changedFile)) {
                return true;
            }
        }
    }
    return false;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ClassPathChangeUploaderTests.java   
private ClassPathChangedEvent createClassPathChangedEvent(File sourceFolder)
        throws IOException {
    Set<ChangedFile> files = new LinkedHashSet<ChangedFile>();
    File file1 = createFile(sourceFolder, "File1");
    File file2 = createFile(sourceFolder, "File2");
    File file3 = createFile(sourceFolder, "File3");
    files.add(new ChangedFile(sourceFolder, file1, Type.ADD));
    files.add(new ChangedFile(sourceFolder, file2, Type.MODIFY));
    files.add(new ChangedFile(sourceFolder, file3, Type.DELETE));
    Set<ChangedFiles> changeSet = new LinkedHashSet<ChangedFiles>();
    changeSet.add(new ChangedFiles(sourceFolder, files));
    ClassPathChangedEvent event = new ClassPathChangedEvent(this, changeSet, false);
    return event;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ClassPathFileSystemWatcherTests.java   
@Bean
public ClassPathRestartStrategy restartStrategy() {
    return new ClassPathRestartStrategy() {

        @Override
        public boolean isRestartRequired(ChangedFile file) {
            return false;
        }

    };
}
项目:spring-boot-concourse    文件:ClassPathChangeUploader.java   
private ClassLoaderFiles getClassLoaderFiles(ClassPathChangedEvent event)
        throws IOException {
    ClassLoaderFiles files = new ClassLoaderFiles();
    for (ChangedFiles changedFiles : event.getChangeSet()) {
        String sourceFolder = changedFiles.getSourceFolder().getAbsolutePath();
        for (ChangedFile changedFile : changedFiles) {
            files.addFile(sourceFolder, changedFile.getRelativeName(),
                    asClassLoaderFile(changedFile));
        }
    }
    return files;
}
项目:spring-boot-concourse    文件:ClassPathChangeUploader.java   
private ClassLoaderFile asClassLoaderFile(ChangedFile changedFile)
        throws IOException {
    ClassLoaderFile.Kind kind = TYPE_MAPPINGS.get(changedFile.getType());
    byte[] bytes = (kind == Kind.DELETED ? null
            : FileCopyUtils.copyToByteArray(changedFile.getFile()));
    long lastModified = (kind == Kind.DELETED ? System.currentTimeMillis()
            : changedFile.getFile().lastModified());
    return new ClassLoaderFile(kind, lastModified, bytes);
}
项目:spring-boot-concourse    文件:PatternClassPathRestartStrategy.java   
@Override
public boolean isRestartRequired(ChangedFile file) {
    for (String pattern : this.excludePatterns) {
        if (this.matcher.match(pattern, file.getRelativeName())) {
            return false;
        }
    }
    return true;
}
项目:spring-boot-concourse    文件:ClassPathFileChangeListener.java   
private boolean isRestartRequired(Set<ChangedFiles> changeSet) {
    if (AgentReloader.isActive()) {
        return false;
    }
    for (ChangedFiles changedFiles : changeSet) {
        for (ChangedFile changedFile : changedFiles) {
            if (this.restartStrategy.isRestartRequired(changedFile)) {
                return true;
            }
        }
    }
    return false;
}
项目:spring-boot-concourse    文件:ClassPathChangeUploaderTests.java   
@Test
public void sendsClassLoaderFiles() throws Exception {
    File sourceFolder = this.temp.newFolder();
    Set<ChangedFile> files = new LinkedHashSet<ChangedFile>();
    File file1 = createFile(sourceFolder, "File1");
    File file2 = createFile(sourceFolder, "File2");
    File file3 = createFile(sourceFolder, "File3");
    files.add(new ChangedFile(sourceFolder, file1, Type.ADD));
    files.add(new ChangedFile(sourceFolder, file2, Type.MODIFY));
    files.add(new ChangedFile(sourceFolder, file3, Type.DELETE));
    Set<ChangedFiles> changeSet = new LinkedHashSet<ChangedFiles>();
    changeSet.add(new ChangedFiles(sourceFolder, files));
    ClassPathChangedEvent event = new ClassPathChangedEvent(this, changeSet, false);
    this.requestFactory.willRespond(HttpStatus.OK);
    this.uploader.onApplicationEvent(event);
    MockClientHttpRequest request = this.requestFactory.getExecutedRequests().get(0);
    ClassLoaderFiles classLoaderFiles = deserialize(request.getBodyAsBytes());
    Collection<SourceFolder> sourceFolders = classLoaderFiles.getSourceFolders();
    assertThat(sourceFolders.size()).isEqualTo(1);
    SourceFolder classSourceFolder = sourceFolders.iterator().next();
    assertThat(classSourceFolder.getName()).isEqualTo(sourceFolder.getAbsolutePath());
    Iterator<ClassLoaderFile> classFiles = classSourceFolder.getFiles().iterator();
    assertClassFile(classFiles.next(), "File1", ClassLoaderFile.Kind.ADDED);
    assertClassFile(classFiles.next(), "File2", ClassLoaderFile.Kind.MODIFIED);
    assertClassFile(classFiles.next(), null, ClassLoaderFile.Kind.DELETED);
    assertThat(classFiles.hasNext()).isFalse();
}
项目:spring-boot-concourse    文件:ClassPathFileSystemWatcherTests.java   
@Bean
public ClassPathRestartStrategy restartStrategy() {
    return new ClassPathRestartStrategy() {

        @Override
        public boolean isRestartRequired(ChangedFile file) {
            return false;
        }

    };
}
项目:contestparser    文件:ClassPathChangeUploader.java   
private ClassLoaderFiles getClassLoaderFiles(ClassPathChangedEvent event)
        throws IOException {
    ClassLoaderFiles files = new ClassLoaderFiles();
    for (ChangedFiles changedFiles : event.getChangeSet()) {
        String sourceFolder = changedFiles.getSourceFolder().getAbsolutePath();
        for (ChangedFile changedFile : changedFiles) {
            files.addFile(sourceFolder, changedFile.getRelativeName(),
                    asClassLoaderFile(changedFile));
        }
    }
    return files;
}
项目:contestparser    文件:ClassPathChangeUploader.java   
private ClassLoaderFile asClassLoaderFile(ChangedFile changedFile)
        throws IOException {
    ClassLoaderFile.Kind kind = TYPE_MAPPINGS.get(changedFile.getType());
    byte[] bytes = (kind == Kind.DELETED ? null
            : FileCopyUtils.copyToByteArray(changedFile.getFile()));
    long lastModified = (kind == Kind.DELETED ? System.currentTimeMillis()
            : changedFile.getFile().lastModified());
    return new ClassLoaderFile(kind, lastModified, bytes);
}
项目:contestparser    文件:PatternClassPathRestartStrategy.java   
@Override
public boolean isRestartRequired(ChangedFile file) {
    for (String pattern : this.excludePatterns) {
        if (this.matcher.match(pattern, file.getRelativeName())) {
            return false;
        }
    }
    return true;
}
项目:contestparser    文件:ClassPathFileChangeListener.java   
private boolean isRestartRequired(Set<ChangedFiles> changeSet) {
    if (AgentReloader.isActive()) {
        return false;
    }
    for (ChangedFiles changedFiles : changeSet) {
        for (ChangedFile changedFile : changedFiles) {
            if (this.restartStrategy.isRestartRequired(changedFile)) {
                return true;
            }
        }
    }
    return false;
}
项目:contestparser    文件:ClassPathChangeUploaderTests.java   
@Test
public void sendsClassLoaderFiles() throws Exception {
    File sourceFolder = this.temp.newFolder();
    Set<ChangedFile> files = new LinkedHashSet<ChangedFile>();
    File file1 = createFile(sourceFolder, "File1");
    File file2 = createFile(sourceFolder, "File2");
    File file3 = createFile(sourceFolder, "File3");
    files.add(new ChangedFile(sourceFolder, file1, Type.ADD));
    files.add(new ChangedFile(sourceFolder, file2, Type.MODIFY));
    files.add(new ChangedFile(sourceFolder, file3, Type.DELETE));
    Set<ChangedFiles> changeSet = new LinkedHashSet<ChangedFiles>();
    changeSet.add(new ChangedFiles(sourceFolder, files));
    ClassPathChangedEvent event = new ClassPathChangedEvent(this, changeSet, false);
    this.requestFactory.willRespond(HttpStatus.OK);
    this.uploader.onApplicationEvent(event);
    MockClientHttpRequest request = this.requestFactory.getExecutedRequests().get(0);
    ClassLoaderFiles classLoaderFiles = deserialize(request.getBodyAsBytes());
    Collection<SourceFolder> sourceFolders = classLoaderFiles.getSourceFolders();
    assertThat(sourceFolders.size(), equalTo(1));
    SourceFolder classSourceFolder = sourceFolders.iterator().next();
    assertThat(classSourceFolder.getName(), equalTo(sourceFolder.getAbsolutePath()));
    Iterator<ClassLoaderFile> classFiles = classSourceFolder.getFiles().iterator();
    assertClassFile(classFiles.next(), "File1", ClassLoaderFile.Kind.ADDED);
    assertClassFile(classFiles.next(), "File2", ClassLoaderFile.Kind.MODIFIED);
    assertClassFile(classFiles.next(), null, ClassLoaderFile.Kind.DELETED);
    assertThat(classFiles.hasNext(), equalTo(false));
}
项目:contestparser    文件:ClassPathFileSystemWatcherTests.java   
@Bean
public ClassPathRestartStrategy restartStrategy() {
    return new ClassPathRestartStrategy() {

        @Override
        public boolean isRestartRequired(ChangedFile file) {
            return false;
        }

    };
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:PatternClassPathRestartStrategyTests.java   
private ChangedFile mockFile(String relativeName) {
    return new ChangedFile(new File("."), new File("./" + relativeName), Type.ADD);
}
项目:spring-boot-concourse    文件:PatternClassPathRestartStrategyTests.java   
private ChangedFile mockFile(String relativeName) {
    return new ChangedFile(new File("."), new File("./" + relativeName), Type.ADD);
}
项目:contestparser    文件:PatternClassPathRestartStrategyTests.java   
private ChangedFile mockFile(String relativeName) {
    return new ChangedFile(new File("."), new File("./" + relativeName), Type.ADD);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ClassPathRestartStrategy.java   
/**
 * Return true if a full restart is required.
 * @param file the changed file
 * @return {@code true} if a full restart is required
 */
boolean isRestartRequired(ChangedFile file);
项目:spring-boot-concourse    文件:ClassPathRestartStrategy.java   
/**
 * Return true if a full restart is required.
 * @param file the changed file
 * @return {@code true} if a full restart is required
 */
boolean isRestartRequired(ChangedFile file);
项目:contestparser    文件:ClassPathRestartStrategy.java   
/**
 * Return true if a full restart is required.
 * @param file the changed file
 * @return {@code true} if a full restart is required
 */
boolean isRestartRequired(ChangedFile file);