diff --git a/pom.xml b/pom.xml index 8053350..9d242b2 100644 --- a/pom.xml +++ b/pom.xml @@ -4,170 +4,47 @@ exchange-server 0.1 - 1.8 - 1.8 + 11 + 11 UTF-8 - 5.6.0 - 3.0.0-M3 - 3.1.2 - 8.39 - 3.0.0-M5 - 0.8.4 - 3.0.0 - - 0% - 0% - 20 - 5 - org.junit.jupiter - junit-jupiter-api - ${junit.version} - test + org.openjfx + javafx-controls + 17 - org.junit.jupiter - junit-jupiter-engine - ${junit.version} - test + org.openjfx + javafx-fxml + 17 - - org.apache.maven.plugins - maven-enforcer-plugin - ${maven-enforcer-plugin.version} - - - - enforce - + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.0 - - - 3.6.3 - - - true + 11 - - - - - org.apache.maven.plugins - maven-checkstyle-plugin - ${maven-checkstyle-plugin.version} - - - com.puppycrawl.tools - checkstyle - ${checkstyle.version} - - - com.github.ngeor - checkstyle-rules - 4.8.0 - - - - com/github/ngeor/checkstyle.xml - true - ${skipTests} - - - - checkstyle - validate - - check - - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - org.jacoco - jacoco-maven-plugin - ${jacoco-maven-plugin.version} - - - pre-unit-test - - prepare-agent - - - - post-unit-test - test - - report - - - - check-unit-test - test - - check - - - ${project.build.directory}/jacoco.exec - - - BUNDLE - - - INSTRUCTION - COVEREDRATIO - ${jacoco.unit-tests.limit.instruction-ratio} - - - BRANCH - COVEREDRATIO - ${jacoco.unit-tests.limit.branch-ratio} - - - - - CLASS - - - COMPLEXITY - TOTALCOUNT - ${jacoco.unit-tests.limit.class-complexity} - - - - - METHOD - - - COMPLEXITY - TOTALCOUNT - ${jacoco.unit-tests.limit.method-complexity} - - - - - - - - + + + org.openjfx + javafx-maven-plugin + 0.0.6 + + + + + default-cli + + ru.molokoin.App + + + + - - - - org.apache.maven.plugins - maven-javadoc-plugin - ${maven-javadoc-plugin.version} - - - diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java new file mode 100644 index 0000000..67791b1 --- /dev/null +++ b/src/main/java/module-info.java @@ -0,0 +1,5 @@ +module ru.molokoin { + requires javafx.controls; + requires javafx.fxml; + exports ru.molokoin; +} diff --git a/src/main/java/ru/molokoin/App.java b/src/main/java/ru/molokoin/App.java new file mode 100644 index 0000000..d89a224 --- /dev/null +++ b/src/main/java/ru/molokoin/App.java @@ -0,0 +1,37 @@ +package ru.molokoin; + +import java.net.URL; + +import javafx.application.Application; +import javafx.fxml.FXMLLoader; +//import javafx.fxml.*; +import javafx.scene.Parent; +import javafx.scene.Scene; +import javafx.stage.Stage; + + +/** + * JavaFX App + */ +public class App extends Application { + + @Override + public void start(Stage stage){ + try { + String link = "/face/mainframe.fxml"; + Parent root = FXMLLoader.load(getClass().getResource(link)); + stage.setTitle("exchange-server-settings"); + stage.setScene(new Scene(root)); + stage.show(); + } catch (Exception e) { + System.out.println("Не удалось запустить сцену. Ошибка: " + e); + } + + + } + + public static void main(String[] args) { + launch(); + } + +} \ No newline at end of file diff --git a/src/main/java/ru/molokoin/ExchangeServer.java b/src/main/java/ru/molokoin/ExchangeServer.java index 7c48459..1a8c505 100644 --- a/src/main/java/ru/molokoin/ExchangeServer.java +++ b/src/main/java/ru/molokoin/ExchangeServer.java @@ -14,8 +14,26 @@ public class ExchangeServer{ private static int port = 8081; private static String link = "localhost"; private static int num = 0; + ServerSocket serverSocket; + Socket socket; - public static void main(String[] args) { + + //подготовка компонентов + public void init(){ + + } + + //остановка серера + public void stop(){ + try { + serverSocket.close(); + //socket.close(); + } catch (Exception e) { + System.out.println("Остановить сервер не удалось. Ошибка: " + e); + } + } + //запуск сервера + public void start(){ try (ServerSocket serverSocket = new ServerSocket(port)) { System.out.println("Server started at port: " + port + " ..."); @@ -44,16 +62,19 @@ public class ExchangeServer{ if(firstLine.startsWith("GET")){ querry = "GET"; } + if(firstLine.startsWith("POST")){ + querry = "POST"; + } System.out.println("firstLine: " + firstLine); System.out.println("querry: " + querry); } - System.out.println(line); + //System.out.println(line); } // отправляем ответ System.out.println("отправка ответа от сервера:"); String path = new File("").getAbsolutePath(); - String fileName = "upload.html"; + String fileName = "upload.http"; path = path + "/src/main/webapp/"; File file = new File(path + fileName); //String text = ""; @@ -81,4 +102,9 @@ public class ExchangeServer{ ex.printStackTrace(); } } + + public static void main(String[] args) { + new ExchangeServer().start(); + } + } diff --git a/src/main/java/ru/molokoin/MainFrameController.java b/src/main/java/ru/molokoin/MainFrameController.java new file mode 100644 index 0000000..da2adca --- /dev/null +++ b/src/main/java/ru/molokoin/MainFrameController.java @@ -0,0 +1,37 @@ +package ru.molokoin; + +import java.net.URL; +import java.util.ResourceBundle; + +import javafx.event.Event; +import javafx.fxml.FXML; +import javafx.fxml.Initializable; +import javafx.scene.control.Button; +import javafx.scene.input.MouseEvent; + +public class MainFrameController implements Initializable{ + @FXML + public Button btn; + public ExchangeServer server; + + @Override + public void initialize(URL location, ResourceBundle resources) { + // TODO Auto-generated method stub + System.out.println("Инициализация компонентов интерфейса ..."); + server = new ExchangeServer(); + } + + @FXML + public void buttonClicked(Event e){ + System.out.println("Button clicked"); + if (btn.getText().equals("START")){ + btn.setText("STOP"); + server.start(); + + }else { + btn.setText("START"); + server.stop(); + } + + } +} diff --git a/src/main/java/ru/molokoin/SystemInfo.java b/src/main/java/ru/molokoin/SystemInfo.java new file mode 100644 index 0000000..9def5ed --- /dev/null +++ b/src/main/java/ru/molokoin/SystemInfo.java @@ -0,0 +1,13 @@ +package ru.molokoin; + +public class SystemInfo { + + public static String javaVersion() { + return System.getProperty("java.version"); + } + + public static String javafxVersion() { + return System.getProperty("javafx.version"); + } + +} \ No newline at end of file diff --git a/src/main/resources/face/mainframe.fxml b/src/main/resources/face/mainframe.fxml new file mode 100644 index 0000000..3ac0079 --- /dev/null +++ b/src/main/resources/face/mainframe.fxml @@ -0,0 +1,10 @@ + + + + + + + +