Skip to content

Commit

Permalink
fix: test failure
Browse files Browse the repository at this point in the history
  • Loading branch information
D-D-H committed Oct 16, 2023
1 parent ef48b5c commit 4aaeed5
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 54 deletions.
54 changes: 0 additions & 54 deletions server/src/main/java/org/eclipse/jifa/server/Launcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,12 @@
********************************************************************************/
package org.eclipse.jifa.server;

import lombok.extern.slf4j.Slf4j;
import org.eclipse.jifa.server.enums.FileType;
import org.eclipse.jifa.server.enums.Role;
import org.eclipse.jifa.server.service.AnalysisApiService;
import org.eclipse.jifa.server.service.FileService;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import java.io.IOException;
import java.nio.file.Path;

@SpringBootApplication
@EnableConfigurationProperties({Configuration.class})
@EnableTransactionManagement
Expand All @@ -38,47 +27,4 @@ public class Launcher {
public static void main(String[] args) {
SpringApplication.run(Launcher.class, args);
}

@Component
@Slf4j
static class ReadyListener extends ConfigurationAccessor {

private final AnalysisApiService analysisApiService;

private final FileService fileService;

ReadyListener(AnalysisApiService analysisApiService, FileService fileService) {
this.analysisApiService = analysisApiService;
this.fileService = fileService;
}

@EventListener(ApplicationReadyEvent.class)
public void fireReadyEvent() {
//noinspection HttpUrlsUsage
log.info("Jifa Server: http://{}:{}", "localhost", config.getPort());

if (config.getRole() == Role.STANDALONE_WORKER) {
Path[] paths = config.getInputFiles();
if (paths != null) {
for (Path path : paths) {
try {
FileType type = analysisApiService.deduceFileType(path);
if (type != null) {
String uniqueName = fileService.handleLocalFileRequest(type, path);
//noinspection HttpUrlsUsage
log.info("{}: http://{}:{}/{}/{}",
path.getFileName(),
"localhost",
config.getPort(),
type.getAnalysisUrlPath(),
uniqueName);
}
} catch (IOException e) {
log.error("Failed to handle input file '{}': {}", path, e.getMessage());
}
}
}
}
}
}
}
68 changes: 68 additions & 0 deletions server/src/main/java/org/eclipse/jifa/server/ReadyListener.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/********************************************************************************
* Copyright (c) 2023 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
********************************************************************************/
package org.eclipse.jifa.server;

import lombok.extern.slf4j.Slf4j;
import org.eclipse.jifa.server.enums.FileType;
import org.eclipse.jifa.server.enums.Role;
import org.eclipse.jifa.server.service.AnalysisApiService;
import org.eclipse.jifa.server.service.FileService;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.nio.file.Path;

@Component
@Slf4j
class ReadyListener extends ConfigurationAccessor {

private final AnalysisApiService analysisApiService;

private final FileService fileService;

ReadyListener(AnalysisApiService analysisApiService, FileService fileService) {
this.analysisApiService = analysisApiService;
this.fileService = fileService;
}

@EventListener(ApplicationReadyEvent.class)
public void fireReadyEvent() {
//noinspection HttpUrlsUsage
log.info("Jifa Server: http://{}:{}", "localhost", config.getPort());

if (config.getRole() == Role.STANDALONE_WORKER) {
Path[] paths = config.getInputFiles();
if (paths != null) {
for (Path path : paths) {
try {
FileType type = analysisApiService.deduceFileType(path);
if (type != null) {
String uniqueName = fileService.handleLocalFileRequest(type, path);
//noinspection HttpUrlsUsage
log.info("{}: http://{}:{}/{}/{}",
path.getFileName(),
"localhost",
config.getPort(),
type.getAnalysisUrlPath(),
uniqueName);
}
} catch (IOException e) {
log.error("Failed to handle input file '{}': {}", path, e.getMessage());
}
}
}
}
}
}

0 comments on commit 4aaeed5

Please sign in to comment.