diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2017-03-27 02:56:15 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2017-03-27 02:56:15 +0200 |
commit | 32b5c0d85df5b29c44693996b72ff4044860bcf5 (patch) | |
tree | 18857e0e4cf2c4df20c9efd307daac514caabb04 /java/vaadin/src/run | |
parent | 1fa4cec10b4b29c622a89e7f94f4e5269fd644a1 (diff) | |
download | share-32b5c0d85df5b29c44693996b72ff4044860bcf5.zip share-32b5c0d85df5b29c44693996b72ff4044860bcf5.tar.gz |
java : vaadin : HelloWorld->HelloWorldUI, add echo to jar target, improve run/.../Main
Diffstat (limited to 'java/vaadin/src/run')
-rw-r--r-- | java/vaadin/src/run/java/ch/asynk/Main.java | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/java/vaadin/src/run/java/ch/asynk/Main.java b/java/vaadin/src/run/java/ch/asynk/Main.java index e0aeb15..a569c85 100644 --- a/java/vaadin/src/run/java/ch/asynk/Main.java +++ b/java/vaadin/src/run/java/ch/asynk/Main.java @@ -15,14 +15,15 @@ import java.nio.file.Paths; class MyVaadinJettyServer extends Server { - public MyVaadinJettyServer(int port, Class<? extends VaadinServlet> servletClass, Class<? extends UI> uiClass, String webappDirectory) - throws IOException, InstantiationException, IllegalAccessException + public MyVaadinJettyServer(int port, String webappDirectory) throws IOException { super(port); - createIfDoesntExists(webappDirectory); WebAppContext context = new WebAppContext(webappDirectory, "/"); - context.addServlet(buildVaadinServlet(servletClass.newInstance(), uiClass), "/*"); + + context.addServlet(buildVaadinServlet(new VaadinServlet(), null), "/*"); + context.addServlet(buildVaadinServlet(new HelloWorldServlet(), HelloWorldUI.class), "/hello/*"); + setHandler(context); } @@ -30,17 +31,9 @@ class MyVaadinJettyServer extends Server { ServletHolder servletHolder = new ServletHolder(servlet); servletHolder.setInitParameter(VaadinServlet.SERVLET_PARAMETER_UI_PROVIDER, DefaultUIProvider.class.getName()); - servletHolder.setInitParameter("UI", uiClass.getName()); + if (uiClass != null) servletHolder.setInitParameter("UI", uiClass.getName()); return servletHolder; } - - private void createIfDoesntExists(String directory) throws IOException - { - Path path = Paths.get(directory); - if (!Files.exists(path)) { - Files.createDirectory(path); - } - } } public class Main @@ -48,7 +41,8 @@ public class Main public static void main(String[] args) throws Exception { String webRoot = System.getProperty("WEBROOT"); - if (webRoot == null) webRoot = "./src/main/WebContent/"; - new MyVaadinJettyServer(8081, HelloWorldServlet.class, HelloWorld.class, webRoot).start(); + if (webRoot == null) webRoot = "./src/main/WebContent"; + System.out.println("http://127.0.0.1:8666/hello"); + new MyVaadinJettyServer(8666, webRoot).start(); } } |