Skip to content
Snippets Groups Projects
Commit 5311f654 authored by Hallvard Trætteberg's avatar Hallvard Trætteberg
Browse files

Endret eksempel så app-en kjører serveren, hvis baseUri gis inn som

arg[0].
parent 9fd62061
No related branches found
No related tags found
No related merge requests found
Pipeline #50557 passed with stage
in 2 minutes and 17 seconds
......@@ -25,6 +25,10 @@ application {
mainClassName = 'simpleex.ui.FxApp' // application plugin
}
run {
args = ["http://localhost:8080/", "[[63.1, 11.2], [63.2, 11.0]]"]
}
// javafx specific way of specifying dependencies
javafx {
version = '11'
......@@ -61,13 +65,16 @@ dependencies {
implementation project(':core')
// brukergrensesnitt
implementation name: 'fx-map-control-1.0'
// rest-server (siden den foreløpig må startes av app-en)
implementation project(':restserver')
testImplementation 'junit:junit:4.12'
// brukergrensesnitt
// rest-server
testCompile project(':restapi')
testImplementation project(':restserver')
// brukergrensesnitt
testImplementation 'org.testfx:testfx-core:4.0.16-alpha'
testImplementation 'org.testfx:testfx-junit:4.0.16-alpha'
testImplementation 'org.mockito:mockito-core:2.28.2'
......
package simpleex.ui;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import org.glassfish.grizzly.http.server.HttpServer;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import simpleex.core.LatLongs;
import simpleex.restapi.LatLongsService;
import simpleex.restserver.LatLongGrizzlyApp;
public class FxApp extends Application {
private HttpServer restServer = null;
@Override
public void start(final Stage stage) throws Exception {
final FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("FxApp.fxml"));
URI baseUri = null;
final List<String> args = getParameters().getRaw();
if (args.size() >= 1) {
final List<String> serverArgs = new ArrayList<String>();
baseUri = URI.create(args.get(0));
serverArgs.add(baseUri.toString());
if (args.size() >= 2) {
// json of initial data
serverArgs.add(args.get(1));
}
restServer = LatLongGrizzlyApp.startServer(serverArgs.toArray(new String[serverArgs.size()]));
}
final String fxml = (baseUri != null ? "FxAppUsingRest.fxml" : "FxApp.fxml");
final FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource(fxml));
final Parent root = fxmlLoader.load();
final FxAppController controller = fxmlLoader.getController();
controller.setLatLongs(new LatLongs(63.1, 11.2, 63.2, 11.0));
if (baseUri == null) {
// set initial data manually
final FxAppController controller = fxmlLoader.getController();
controller.setLatLongs(new LatLongs(63.1, 11.2, 63.2, 11.0));
} else {
final FxAppUsingRestController controller = fxmlLoader.getController();
controller.setDataAccess(new RestLatLongsDataAccess(baseUri + LatLongsService.LAT_LONG_SERVICE_PATH, controller.getObjectMapper()));
}
final Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
}
@Override
public void stop() throws Exception {
restServer.shutdown();
super.stop();
}
/**
* Launches the app.
* @param args the command line arguments
......
......@@ -25,6 +25,6 @@ FxAppController --> ListView: "locationListView"
public class FxAppUsingRestController extends AbstractFxAppController {
public FxAppUsingRestController() {
setDataAccess(new RestLatLongsDataAccess("http://localhost:8080/dict", getObjectMapper()));
// setDataAccess(new RestLatLongsDataAccess("http://localhost:8080/latLong", getObjectMapper()));
}
}
plugins {
id 'application'
id 'java-library'
}
ext {
......@@ -7,15 +7,18 @@ ext {
jerseyVersion = '2.28'
}
application {
sourceCompatibility = JavaVersion.VERSION_1_10
targetCompatibility = JavaVersion.VERSION_1_10
mainClassName = 'simpleex.restserver.LatLongGrizzlyApp'
}
sourceCompatibility = JavaVersion.VERSION_1_10
targetCompatibility = JavaVersion.VERSION_1_10
//application {
// sourceCompatibility = JavaVersion.VERSION_1_10
// targetCompatibility = JavaVersion.VERSION_1_10
// // mainClassName = 'simpleex.restserver.LatLongGrizzlyApp'
//}
dependencies {
implementation project(':core')
implementation project(':restapi')
compile project(':restapi')
compile "org.slf4j:slf4j-api:$slf4jVersion"
compile "org.slf4j:slf4j-simple:$slf4jVersion"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment