org.rapidpm.vaadin:nano-vaadin-undertow

Dependencies for the Java/Kotlin projects

License

License

Categories

Categories

Vaadin User Interface Web Frameworks Undertow Net Networking
GroupId

GroupId

org.rapidpm.vaadin
ArtifactId

ArtifactId

nano-vaadin-undertow
Last Version

Last Version

01.00.04-RPM
Release Date

Release Date

Type

Type

jar
Description

Description

Dependencies for the Java/Kotlin projects
Project Organization

Project Organization

Vaadin

Download nano-vaadin-undertow

How to add to project

<!-- https://jarcasting.com/artifacts/org.rapidpm.vaadin/nano-vaadin-undertow/ -->
<dependency>
    <groupId>org.rapidpm.vaadin</groupId>
    <artifactId>nano-vaadin-undertow</artifactId>
    <version>01.00.04-RPM</version>
</dependency>
// https://jarcasting.com/artifacts/org.rapidpm.vaadin/nano-vaadin-undertow/
implementation 'org.rapidpm.vaadin:nano-vaadin-undertow:01.00.04-RPM'
// https://jarcasting.com/artifacts/org.rapidpm.vaadin/nano-vaadin-undertow/
implementation ("org.rapidpm.vaadin:nano-vaadin-undertow:01.00.04-RPM")
'org.rapidpm.vaadin:nano-vaadin-undertow:jar:01.00.04-RPM'
<dependency org="org.rapidpm.vaadin" name="nano-vaadin-undertow" rev="01.00.04-RPM">
  <artifact name="nano-vaadin-undertow" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.rapidpm.vaadin', module='nano-vaadin-undertow', version='01.00.04-RPM')
)
libraryDependencies += "org.rapidpm.vaadin" % "nano-vaadin-undertow" % "01.00.04-RPM"
[org.rapidpm.vaadin/nano-vaadin-undertow "01.00.04-RPM"]

Dependencies

compile (12)

Group / Artifact Type Version
io.undertow : undertow-core jar 2.0.28.Final
io.undertow : undertow-servlet jar 2.0.28.Final
io.undertow : undertow-websockets-jsr jar 2.0.28.Final
net.oneandone.reflections8 : reflections8 jar 0.11.7
commons-cli : commons-cli jar 1.4
org.slf4j : slf4j-api jar 1.7.28
org.slf4j : slf4j-simple jar 1.7.28
org.rapidpm : rapidpm-vaadin-flow-commons jar 04.06.00-RPM
org.rapidpm : rapidpm-functional-reactive jar 01.00.04-RPM
org.rapidpm : rapidpm-logger-adapter jar 01.00.06-RPM
net.jcip : jcip-annotations jar 1.0
com.google.code.findbugs : jsr305 jar 3.0.2

provided (5)

Group / Artifact Type Version
com.vaadin : flow-server jar 2.1.2
com.vaadin : flow-push jar 2.1.2
com.vaadin : flow-client jar 2.1.2
com.vaadin : flow-html-components jar 2.1.2
com.vaadin : flow-data jar 2.1.2

test (14)

Group / Artifact Type Version
org.junit.jupiter : junit-jupiter-api jar 5.5.2
org.junit.jupiter : junit-jupiter-params jar 5.5.2
org.junit.platform : junit-platform-launcher jar 1.5.2
org.junit.jupiter : junit-jupiter-engine jar 5.5.2
org.junit.platform : junit-platform-testkit jar 1.5.2
com.google.truth : truth jar 1.0
org.openjdk.jmh : jmh-core jar 1.22
org.openjdk.jmh : jmh-core-benchmarks jar 1.22
org.openjdk.jmh : jmh-generator-annprocess jar 1.22
org.openjdk.jmh : jmh-generator-reflection jar 1.22
com.github.javafaker : javafaker jar 1.0.1
org.jetbrains.kotlin : kotlin-test-junit jar 1.3.61
org.jetbrains.kotlin : kotlin-test-junit5 jar 1.3.61
org.jetbrains.kotlin : kotlin-test jar 1.3.61

Project Modules

There are no modules declared in this project.

Maven Central

Nano Vaadin - Ramp up in a second.

A nano project to start a Vaadin V8 project based on JDK10. Perfect for Micro-UIs packed as fat jar in a docker image. On my Laptop the Server is started in approx 300ms.

maven central

You can use this as dependency as well. For this you should add the following into your pom.xml

<dependency>
  <groupId>org.rapidpm.vaadin</groupId>
  <artifactId>nano-vaadin-v08</artifactId>
  <version>x.y.z</version>
</dependency>

target of this project

The target of this project is a minimal rampup time for a first hello world. Why we need one more HelloWorld? Well, the answer is quite easy. If you have to try something out, or you want to make a small POC to present something, there is no time and budget to create a demo project. You don´t want to copy paste all small things together. Here you will get a Nano-Project that will give you all in a second.

Clone the repo and start editing the class demo.HelloWorld. You will find it in the test source folder.

public class HelloWorld  {

  public static void main(String[] args) {
    //reference the Supplier
    setProperty(COMPONENT_SUPPLIER_TO_USE, HelloWorldSupplier.class.getName());
    //start the Server
    new CoreUIService().startup();
  }


  /**
   * start adding your UI elements here.
   */
  public static class HelloWorldSupplier implements ComponentSupplier {
    @Override
    public Component get() {
      return new Label("Hello World");
    }
  }
}

How does it work?

This project will not use any additional maven plugin or technology. Core Java and the Vaadin Dependencies are all that you need to put a Vaadin app into a Servlet-container.

Here we are using the plain undertow as Servlet-Container.

As mentioned before, there is not additional technology involved. No DI to wire all things together. The way used here is based on good old Properties.

But let´s start from the beginning.

CoreUIService

The class CoreUIService will ramp up the Container. For this you should invoke the method startup(). (see HelloWorld) The app itself will be deployed as ROOT.war. If nothing else is defined, the port 8899 and the IP 0.0.0.0 will be used. But you can define the port and the IP. The corresponding properties are

  • CORE_UI_SERVER_HOST = "core-ui-server-host";
  • CORE_UI_SERVER_PORT = "core-ui-server-port";

If you are using the method startup(Config config) you can set this values manually, without using system-properties. This is usefull in an environment, where multiple Servlet - containers are started on the same host. With this you can implement concurrent tests.

_data/MultipleServletContainers_50p.gif

With this you can use the Container for jUnit - UI tests easily. Every test will get a random port to have concurrent tests. How to do this you can read under http://vaadin.com/testing or check the OpenSource project on github https://github.com/vaadin-developer/vaadin-testbench-ng

Core Servlet && CoreUI

For a Vaadin app you need a VaadinServlet. This is in a generic way implemented for this project. What you will do, is the mapping to your UI class. But for this project even this boiler-plate code is done. The reference will be ui = CoreUI.class

@WebServlet(value = "/*", asyncSupported = true, loadOnStartup = 1)
@VaadinServletConfiguration(productionMode = false, ui = CoreUI.class)
public class CoreServlet extends VaadinServlet {
  //customize Servlet if needed
}

The UI class is responsible to create an instance of the components you want to have. The property that will reference the Supplier is used to load the class and create an instance.

@PreserveOnRefresh
@Push
public class CoreUI extends UI implements HasLogger {
  public static final String COMPONENT_SUPPLIER_TO_USE = "COMPONENT_SUPPLIER_TO_USE";

  @Override
  protected void init(VaadinRequest request) {
    final String className = getProperty(COMPONENT_SUPPLIER_TO_USE);
    logger().info("class to load : " + className);
    ((CheckedSupplier<Class<?>>) () -> forName(className))
        .get()
        .ifFailed(e -> logger().warning(e))
        .flatMap((CheckedFunction<Class<?>, Object>) Class::newInstance)
        .flatMap((CheckedFunction<Object, ComponentSupplier>) ComponentSupplier.class::cast)
        .flatMap((CheckedFunction<ComponentSupplier, Component>) Supplier::get)
        .ifPresentOrElse(this::setContent,
                         failed -> logger().warning(failed)
        );
  }
}

Remember the part in the class HellWorld

setProperty(COMPONENT_SUPPLIER_TO_USE, HelloWorldSupplier.class.getName());

How a developer like you can use this

The steps are quite easy. First of all, clone the repo and try to build it with mvn clean package or use your IDE, if maven is not installed for command line usage on your machine.

If this is running well, start the main Method from the class HelloWorld. Now you can use a browser on http://localhost:8899/

To create your own demos, edit the Supplier.

Happy Coding.

if you have any questions: ping me on Twitter https://twitter.com/SvenRuppert or via mail.

org.rapidpm.vaadin

Vaadin Developer

Jumpstarts and HowTos for Vaadin based projects

Versions

Version
01.00.04-RPM
01.00.03-RPM
01.00.02-RPM
01.00.01-RPM