Java 类org.springframework.boot.devtools.classpath.ClassPathChangedEvent 实例源码

项目:spring-boot-concourse    文件:ClassPathChangeUploader.java   
@Override
public void onApplicationEvent(ClassPathChangedEvent event) {
    try {
        ClassLoaderFiles classLoaderFiles = getClassLoaderFiles(event);
        ClientHttpRequest request = this.requestFactory.createRequest(this.uri,
                HttpMethod.POST);
        byte[] bytes = serialize(classLoaderFiles);
        HttpHeaders headers = request.getHeaders();
        headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
        headers.setContentLength(bytes.length);
        FileCopyUtils.copy(bytes, request.getBody());
        logUpload(classLoaderFiles);
        ClientHttpResponse response = request.execute();
        Assert.state(response.getStatusCode() == HttpStatus.OK, "Unexpected "
                + response.getStatusCode() + " response uploading class files");
    }
    catch (IOException ex) {
        throw new IllegalStateException(ex);
    }
}
项目:contestparser    文件:ClassPathChangeUploader.java   
@Override
public void onApplicationEvent(ClassPathChangedEvent event) {
    try {
        ClassLoaderFiles classLoaderFiles = getClassLoaderFiles(event);
        ClientHttpRequest request = this.requestFactory.createRequest(this.uri,
                HttpMethod.POST);
        byte[] bytes = serialize(classLoaderFiles);
        HttpHeaders headers = request.getHeaders();
        headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
        headers.setContentLength(bytes.length);
        FileCopyUtils.copy(bytes, request.getBody());
        logUpload(classLoaderFiles);
        ClientHttpResponse response = request.execute();
        Assert.state(response.getStatusCode() == HttpStatus.OK, "Unexpected "
                + response.getStatusCode() + " response uploading class files");
    }
    catch (IOException ex) {
        throw new IllegalStateException(ex);
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:LocalDevToolsAutoConfiguration.java   
@EventListener
public void onClassPathChanged(ClassPathChangedEvent event) {
    if (event.isRestartRequired()) {
        Restarter.getInstance().restart(
                new FileWatchingFailureHandler(fileSystemWatcherFactory()));
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ClassPathChangeUploader.java   
@Override
public void onApplicationEvent(ClassPathChangedEvent event) {
    try {
        ClassLoaderFiles classLoaderFiles = getClassLoaderFiles(event);
        byte[] bytes = serialize(classLoaderFiles);
        performUpload(classLoaderFiles, bytes);
    }
    catch (IOException ex) {
        throw new IllegalStateException(ex);
    }
}
项目: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    文件:LocalDevToolsAutoConfigurationTests.java   
@Test
public void liveReloadTriggeredOnClassPathChangeWithoutRestart() throws Exception {
    this.context = initializeAndRun(ConfigWithMockLiveReload.class);
    LiveReloadServer server = this.context.getBean(LiveReloadServer.class);
    reset(server);
    ClassPathChangedEvent event = new ClassPathChangedEvent(this.context,
            Collections.<ChangedFiles>emptySet(), false);
    this.context.publishEvent(event);
    verify(server).triggerReload();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:LocalDevToolsAutoConfigurationTests.java   
@Test
public void liveReloadNotTriggeredOnClassPathChangeWithRestart() throws Exception {
    this.context = initializeAndRun(ConfigWithMockLiveReload.class);
    LiveReloadServer server = this.context.getBean(LiveReloadServer.class);
    reset(server);
    ClassPathChangedEvent event = new ClassPathChangedEvent(this.context,
            Collections.<ChangedFiles>emptySet(), true);
    this.context.publishEvent(event);
    verify(server, never()).triggerReload();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:LocalDevToolsAutoConfigurationTests.java   
@Test
public void restartTriggeredOnClassPathChangeWithRestart() throws Exception {
    this.context = initializeAndRun(Config.class);
    ClassPathChangedEvent event = new ClassPathChangedEvent(this.context,
            Collections.<ChangedFiles>emptySet(), true);
    this.context.publishEvent(event);
    verify(this.mockRestarter.getMock()).restart(any(FailureHandler.class));
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:LocalDevToolsAutoConfigurationTests.java   
@Test
public void restartNotTriggeredOnClassPathChangeWithRestart() throws Exception {
    this.context = initializeAndRun(Config.class);
    ClassPathChangedEvent event = new ClassPathChangedEvent(this.context,
            Collections.<ChangedFiles>emptySet(), false);
    this.context.publishEvent(event);
    verify(this.mockRestarter.getMock(), never()).restart();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ClassPathChangeUploaderTests.java   
@Test
public void sendsClassLoaderFiles() throws Exception {
    File sourceFolder = this.temp.newFolder();
    ClassPathChangedEvent event = createClassPathChangedEvent(sourceFolder);
    this.requestFactory.willRespond(HttpStatus.OK);
    this.uploader.onApplicationEvent(event);
    assertThat(this.requestFactory.getExecutedRequests()).hasSize(1);
    MockClientHttpRequest request = this.requestFactory.getExecutedRequests().get(0);
    verifyUploadRequest(sourceFolder, request);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ClassPathChangeUploaderTests.java   
@Test
public void retriesOnConnectException() throws Exception {
    File sourceFolder = this.temp.newFolder();
    ClassPathChangedEvent event = createClassPathChangedEvent(sourceFolder);
    this.requestFactory.willRespond(new ConnectException());
    this.requestFactory.willRespond(HttpStatus.OK);
    this.uploader.onApplicationEvent(event);
    assertThat(this.requestFactory.getExecutedRequests()).hasSize(2);
    verifyUploadRequest(sourceFolder,
            this.requestFactory.getExecutedRequests().get(1));
}
项目: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    文件:RemoteClientConfigurationTests.java   
@Test
public void liveReloadOnClassPathChanged() throws Exception {
    configure();
    Set<ChangedFiles> changeSet = new HashSet<ChangedFiles>();
    ClassPathChangedEvent event = new ClassPathChangedEvent(this, changeSet, false);
    this.context.publishEvent(event);
    LiveReloadConfiguration configuration = this.context
            .getBean(LiveReloadConfiguration.class);
    configuration.getExecutor().shutdown();
    configuration.getExecutor().awaitTermination(2, TimeUnit.SECONDS);
    LiveReloadServer server = this.context.getBean(LiveReloadServer.class);
    verify(server).triggerReload();
}
项目:spring-boot-concourse    文件:LocalDevToolsAutoConfiguration.java   
@EventListener
public void onClassPathChanged(ClassPathChangedEvent event) {
    if (event.isRestartRequired()) {
        Restarter.getInstance().restart(
                new FileWatchingFailureHandler(fileSystemWatcherFactory()));
    }
}
项目: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    文件:LocalDevToolsAutoConfigurationTests.java   
@Test
public void liveReloadTriggeredOnClassPathChangeWithoutRestart() throws Exception {
    this.context = initializeAndRun(ConfigWithMockLiveReload.class);
    LiveReloadServer server = this.context.getBean(LiveReloadServer.class);
    reset(server);
    ClassPathChangedEvent event = new ClassPathChangedEvent(this.context,
            Collections.<ChangedFiles>emptySet(), false);
    this.context.publishEvent(event);
    verify(server).triggerReload();
}
项目:spring-boot-concourse    文件:LocalDevToolsAutoConfigurationTests.java   
@Test
public void liveReloadNotTriggeredOnClassPathChangeWithRestart() throws Exception {
    this.context = initializeAndRun(ConfigWithMockLiveReload.class);
    LiveReloadServer server = this.context.getBean(LiveReloadServer.class);
    reset(server);
    ClassPathChangedEvent event = new ClassPathChangedEvent(this.context,
            Collections.<ChangedFiles>emptySet(), true);
    this.context.publishEvent(event);
    verify(server, never()).triggerReload();
}
项目:spring-boot-concourse    文件:LocalDevToolsAutoConfigurationTests.java   
@Test
public void restartTriggeredOnClassPathChangeWithRestart() throws Exception {
    this.context = initializeAndRun(Config.class);
    ClassPathChangedEvent event = new ClassPathChangedEvent(this.context,
            Collections.<ChangedFiles>emptySet(), true);
    this.context.publishEvent(event);
    verify(this.mockRestarter.getMock()).restart(any(FailureHandler.class));
}
项目:spring-boot-concourse    文件:LocalDevToolsAutoConfigurationTests.java   
@Test
public void restartNotTriggeredOnClassPathChangeWithRestart() throws Exception {
    this.context = initializeAndRun(Config.class);
    ClassPathChangedEvent event = new ClassPathChangedEvent(this.context,
            Collections.<ChangedFiles>emptySet(), false);
    this.context.publishEvent(event);
    verify(this.mockRestarter.getMock(), never()).restart();
}
项目: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    文件:RemoteClientConfigurationTests.java   
@Test
public void liveReloadOnClassPathChanged() throws Exception {
    configure();
    Set<ChangedFiles> changeSet = new HashSet<ChangedFiles>();
    ClassPathChangedEvent event = new ClassPathChangedEvent(this, changeSet, false);
    this.context.publishEvent(event);
    LiveReloadConfiguration configuration = this.context
            .getBean(LiveReloadConfiguration.class);
    configuration.getExecutor().shutdown();
    configuration.getExecutor().awaitTermination(2, TimeUnit.SECONDS);
    LiveReloadServer server = this.context.getBean(LiveReloadServer.class);
    verify(server).triggerReload();
}
项目:contestparser    文件:LocalDevToolsAutoConfiguration.java   
@EventListener
public void onClassPathChanged(ClassPathChangedEvent event) {
    if (event.isRestartRequired()) {
        Restarter.getInstance().restart(
                new FileWatchingFailureHandler(fileSystemWatcherFactory()));
    }
}
项目: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    文件:LocalDevToolsAutoConfigurationTests.java   
@Test
public void liveReloadTriggerdOnClassPathChangeWithoutRestart() throws Exception {
    this.context = initializeAndRun(ConfigWithMockLiveReload.class);
    LiveReloadServer server = this.context.getBean(LiveReloadServer.class);
    reset(server);
    ClassPathChangedEvent event = new ClassPathChangedEvent(this.context,
            Collections.<ChangedFiles>emptySet(), false);
    this.context.publishEvent(event);
    verify(server).triggerReload();
}
项目:contestparser    文件:LocalDevToolsAutoConfigurationTests.java   
@Test
public void liveReloadNotTriggerdOnClassPathChangeWithRestart() throws Exception {
    this.context = initializeAndRun(ConfigWithMockLiveReload.class);
    LiveReloadServer server = this.context.getBean(LiveReloadServer.class);
    reset(server);
    ClassPathChangedEvent event = new ClassPathChangedEvent(this.context,
            Collections.<ChangedFiles>emptySet(), true);
    this.context.publishEvent(event);
    verify(server, never()).triggerReload();
}
项目:contestparser    文件:LocalDevToolsAutoConfigurationTests.java   
@Test
public void restartTriggeredOnClassPathChangeWithRestart() throws Exception {
    this.context = initializeAndRun(Config.class);
    ClassPathChangedEvent event = new ClassPathChangedEvent(this.context,
            Collections.<ChangedFiles>emptySet(), true);
    this.context.publishEvent(event);
    verify(this.mockRestarter.getMock()).restart(any(FailureHandler.class));
}
项目:contestparser    文件:LocalDevToolsAutoConfigurationTests.java   
@Test
public void restartNotTriggeredOnClassPathChangeWithRestart() throws Exception {
    this.context = initializeAndRun(Config.class);
    ClassPathChangedEvent event = new ClassPathChangedEvent(this.context,
            Collections.<ChangedFiles>emptySet(), false);
    this.context.publishEvent(event);
    verify(this.mockRestarter.getMock(), never()).restart();
}
项目: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    文件:RemoteClientConfigurationTests.java   
@Test
public void liveReloadOnClassPathChanged() throws Exception {
    configure();
    Set<ChangedFiles> changeSet = new HashSet<ChangedFiles>();
    ClassPathChangedEvent event = new ClassPathChangedEvent(this, changeSet, false);
    this.context.publishEvent(event);
    LiveReloadConfiguration configuration = this.context
            .getBean(LiveReloadConfiguration.class);
    configuration.getExecutor().shutdown();
    configuration.getExecutor().awaitTermination(2, TimeUnit.SECONDS);
    LiveReloadServer server = this.context.getBean(LiveReloadServer.class);
    verify(server).triggerReload();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:LocalDevToolsAutoConfiguration.java   
@EventListener
public void onClassPathChanged(ClassPathChangedEvent event) {
    if (!event.isRestartRequired()) {
        optionalLiveReloadServer().triggerReload();
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:RemoteClientConfiguration.java   
@EventListener
public void onClassPathChanged(ClassPathChangedEvent event) {
    String url = this.remoteUrl + this.properties.getRemote().getContextPath();
    this.executor.execute(new DelayedLiveReloadTrigger(optionalLiveReloadServer(),
            this.clientHttpRequestFactory, url));
}
项目:spring-boot-concourse    文件:LocalDevToolsAutoConfiguration.java   
@EventListener
public void onClassPathChanged(ClassPathChangedEvent event) {
    if (!event.isRestartRequired()) {
        optionalLiveReloadServer().triggerReload();
    }
}
项目:spring-boot-concourse    文件:RemoteClientConfiguration.java   
@EventListener
public void onClassPathChanged(ClassPathChangedEvent event) {
    String url = this.remoteUrl + this.properties.getRemote().getContextPath();
    this.executor.execute(new DelayedLiveReloadTrigger(optionalLiveReloadServer(),
            this.clientHttpRequestFactory, url));
}
项目:contestparser    文件:LocalDevToolsAutoConfiguration.java   
@EventListener
public void onClassPathChanged(ClassPathChangedEvent event) {
    if (!event.isRestartRequired()) {
        optionalLiveReloadServer().triggerReload();
    }
}
项目:contestparser    文件:RemoteClientConfiguration.java   
@EventListener
public void onClassPathChanged(ClassPathChangedEvent event) {
    String url = this.remoteUrl + this.properties.getRemote().getContextPath();
    this.executor.execute(new DelayedLiveReloadTrigger(optionalLiveReloadServer(),
            this.clientHttpRequestFactory, url));
}