summaryrefslogtreecommitdiffstats
path: root/java/vaadin/src
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2017-03-27 02:56:15 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2017-03-27 02:56:15 +0200
commit32b5c0d85df5b29c44693996b72ff4044860bcf5 (patch)
tree18857e0e4cf2c4df20c9efd307daac514caabb04 /java/vaadin/src
parent1fa4cec10b4b29c622a89e7f94f4e5269fd644a1 (diff)
downloadshare-32b5c0d85df5b29c44693996b72ff4044860bcf5.zip
share-32b5c0d85df5b29c44693996b72ff4044860bcf5.tar.gz
java : vaadin : HelloWorld->HelloWorldUI, add echo to jar target, improve run/.../Main
Diffstat (limited to 'java/vaadin/src')
-rw-r--r--java/vaadin/src/main/java/ch/asynk/HelloWorldServlet.java2
-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.java24
3 files changed, 11 insertions, 17 deletions
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();
}
}