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 | |
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')
-rw-r--r-- | java/vaadin/build.xml | 1 | ||||
-rw-r--r-- | java/vaadin/src/main/java/ch/asynk/HelloWorldServlet.java | 2 | ||||
-rw-r--r-- | java/vaadin/src/main/java/ch/asynk/HelloWorldUI.java (renamed from java/vaadin/src/main/java/ch/asynk/HelloWorld.java) | 2 | ||||
-rw-r--r-- | java/vaadin/src/run/java/ch/asynk/Main.java | 24 |
4 files changed, 12 insertions, 17 deletions
diff --git a/java/vaadin/build.xml b/java/vaadin/build.xml index c36b396..1090e68 100644 --- a/java/vaadin/build.xml +++ b/java/vaadin/build.xml @@ -217,6 +217,7 @@ </fileset> <zipfileset src="dist/deps.jar" excludes="META-INF/*"/> </jar> + <echo message="$ java -DWEBROOT=/tmp -DTEST=1 -jar ${jar.name}"/> </target> <target name="run.jar" description="run jetty from application jar" depends="configure"> diff --git a/java/vaadin/src/main/java/ch/asynk/HelloWorldServlet.java b/java/vaadin/src/main/java/ch/asynk/HelloWorldServlet.java index e4092f2..e4157c4 100644 --- a/java/vaadin/src/main/java/ch/asynk/HelloWorldServlet.java +++ b/java/vaadin/src/main/java/ch/asynk/HelloWorldServlet.java @@ -12,7 +12,7 @@ import com.vaadin.server.SessionDestroyListener; import com.vaadin.server.VaadinServlet; @WebServlet(value = "/*", asyncSupported = true) -@VaadinServletConfiguration(productionMode = false, ui = ch.asynk.HelloWorld.class, closeIdleSessions = true) +@VaadinServletConfiguration(productionMode = false, ui = ch.asynk.HelloWorldUI.class, closeIdleSessions = true) public class HelloWorldServlet extends VaadinServlet implements SessionInitListener, SessionDestroyListener { private static final long serialVersionUID = 511085337415583793L; diff --git a/java/vaadin/src/main/java/ch/asynk/HelloWorld.java b/java/vaadin/src/main/java/ch/asynk/HelloWorldUI.java index c9f807e..f4579be 100644 --- a/java/vaadin/src/main/java/ch/asynk/HelloWorld.java +++ b/java/vaadin/src/main/java/ch/asynk/HelloWorldUI.java @@ -19,7 +19,7 @@ import org.slf4j.LoggerFactory; @PreserveOnRefresh @Title("Hello!!") @Theme("mytheme") -public class HelloWorld extends UI +public class HelloWorldUI extends UI { private static final long serialVersionUID = 511085335415683713L; private static Logger logger = null; 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(); } } |