193 Lotus blogs updated hourly. Who will post next? Home | Blogs | Search | About 
 
Latest 7 Posts
High Performance REST Applications (3) – Importing the Starter Project
Mon, Apr 24th 2017 72
High Performance REST Applications (2) – Dev Environment
Sun, Apr 23rd 2017 206
High Performance REST Applications (1) – Intro
Fri, Apr 21st 2017 253
Re: Domino REST performance analysis
Thu, Mar 16th 2017 10
Domino & Java 1.8: Thank you, IBM!
Tue, Mar 14th 2017 13
Domin & REST: Debug your Plugin
Tue, Mar 7th 2017 11
Domino & REST: More about Jackson
Fri, Mar 3rd 2017 15
Top 10
High Performance REST Applications (1) – Intro
Fri, Apr 21st 2017 253
High Performance REST Applications (2) – Dev Environment
Sun, Apr 23rd 2017 206
High Performance REST Applications (3) – Importing the Starter Project
Mon, Apr 24th 2017 72
Domino & REST: More about Jackson
Fri, Mar 3rd 2017 15
Security: Usefull HTTP Response Headers
Wed, Jan 14th 2015 14
Domino & Java 1.8: Thank you, IBM!
Tue, Mar 14th 2017 13
Domin & REST: Debug your Plugin
Tue, Mar 7th 2017 11
Hardening SSH vs. Eclipse RSE
Tue, Jan 13th 2015 10
Re: Domino REST performance analysis
Thu, Mar 16th 2017 10
XPages: Running Google’s Chrome V8 Javascript Engine
Sun, Nov 9th 2014 9


Domino & REST: A basic Servlet
Twitter Google+ Facebook LinkedIn Addthis Email Gmail Flipboard Reddit Tumblr WhatsApp StumbleUpon Yammer Evernote Delicious
Sven Hasselbach    

To have a good starting point when creating RESTful applications on top of Domino, I have created a „Hello World“ example of a JEE Application, based on Apache Wink & Jackson 2.5.0.

The Jackson AnnotaionProcessor is registered into Apache Wink application and is enabled by default, the JAXB processor is also included as the secondary AnnotationProcessor. The benefit of this is that only one global ObjectMapper instance is created and is reused, wich allows a better performance as when you create an own instance of an ObjectMapper for every request.

The servlet is deployed as a Plugin, so you need a working XPages plugin development environment first before you can build it (I won’t get in the details at this time). The code of the servlet can be found in the domino-rest-servlet.plugin project.

First have a look into plugin.xml: This file contains the extension point used by the plugin, which means that this tells the Domino server what is inside and what to do next with the plugin. The extension point is of type „com.ibm.pvc.webcontainer.application“ and allows to run our own JEE application, independently of the XPages runtime. The contextRoot is the URI part on which our application „listens“. The contentLocation is where files are searched when accessed from the browser, and points to the WebContent folder (as you already know, it is the same as in XPages projects when using the package explorer view). Here you can store static files and/or resources if required.

The web.xml file is the servlet configuration and the place where the servlet is registered. With servlet-mappings you can define URI pathes *inside* of the JEE application.

In this example, every request is mapped to the RestServlet servlet when it is send to „http://your.server/dominorestservlet/„. It will be now processed by the class ch.hasselba.dominorestservlet.RestApiApplication, which „knows“ the RestApiServlet because of the @Path annotations.

Our „Hello World“ example is registered for the URI „/helloworld/“ and only for HTTP GET requests. As soon you are opening „http://your.server/dominorestservlet/helloworld/„, an instance of HelloWorld is created and transformed to JSON. The result looks like this:

{"message":"Hello World!"}

During the next blog posts, I will expand this example and explain step by step how a seamless integration in the Domino environment works.

You can find the code here: https://github.com/hasselbach/domino-rest-servlet



---------------------
http://hasselba.ch/blog/?p=2307
Feb 28, 2017
7 hits



Recent Blog Posts
72
High Performance REST Applications (3) – Importing the Starter Project
Mon, Apr 24th 2017 9:03a   Sven Hasselbach
Now you can import the projects required from Git. First, go to „File > Import…“ Import Project Then select „Projects from Git“ Projects from Git and „Clone URI“ to clone an existing repository: Clone existing respository To get the URI, you have to open https://github.com/hasselbach/ and select the repository „ch.hasselba.concurrent„. Click the „Clone or download„-Button and copy the URI from the opening box: Get the repositor
206
High Performance REST Applications (2) – Dev Environment
Sun, Apr 23rd 2017 8:55a   Sven Hasselbach
Before you can start developing a Servlet as an OSGi Plugins, you must set up a development environment first. To do this, download Eclipse IDE (Eclipse IDE for Java EE Developers) and XPages SDK from OpenNTF (The XPages SDK is a helper to create the JRE environment and the Target Platform). For development it is the best to have a (local) development server, because during development you might want to restart and/or modify it, and debugging is a lot easier if have control over the whole server
253
High Performance REST Applications (1) – Intro
Fri, Apr 21st 2017 9:33a   Sven Hasselbach
This is a new serie about developing high performance REST applications on top of Domino. It will contain my presentations from SNoUG and EntwicklerCamp this year and descripe all required steps to develop, build and deploy these servlets on a basic level. The code used in this serie is already available at GitHub: https://github.com/hasselbach/domino-rest-servlet/tree/highperformance https://github.com/hasselbach/ch.hasselba.concurrent (The high performance part is in a branch of my example D
10
Re: Domino REST performance analysis
Thu, Mar 16th 2017 8:51p   Sven Hasselbach
I have created a Quick-n-Dirty performance test for Csaba’s „10K record test“: Loading time 200 ms overall, 60 ms TTFB. Do you want to know how this works? Feel free to come to SNoUG next week or to Rudi’s EntwicklerCamp and join my sessions.
13
Domino & Java 1.8: Thank you, IBM!
Tue, Mar 14th 2017 1:16p   Sven Hasselbach
For years it was a lot of pain when developing for the Domino platform using Java 1.6 only. But now, Java 1.8 is available, and this allows to use the latest versions for a lot of libraries and development tools. After installing FP8 to the Client, Eclipse allowes to use the Domino JRE in a JavaSE-1.8 environment: This gives access to the latest M2Eclipse plugin (1.7.0). The old version problem when running with JRE 1.6… … is solved: Eclipse Updates? No problem, just do it! Latest
11
Domin & REST: Debug your Plugin
Tue, Mar 7th 2017 11:14a   Sven Hasselbach
When developing OSGi Plugins, you should have your own development server running on your local machine. Not only because of the faster deployment of changes (a new version of a plugin must always deployed with a HTTP restart), but because of the Java debugging posibilities: Only one Eclipse instance can connect to the JVM, and every request processed by the server will start the debugger. If multiple users a accessing the server while you are debugging, your Eclipse will try to debug every inco
15
Domino & REST: More about Jackson
Fri, Mar 3rd 2017 10:16a   Sven Hasselbach
When creating a REST API servlet, Jackson provides a huge list of possibilities to manipulate the JSON data, mostly using annotations. Let’s demonstrate some of them with this little class, which has only two properties: public class Demo { private String foo; private String bar; public String getFoo() { return foo; } public void setFoo(String foo) { this.foo = foo; } public String getBar() { return bar; } public void setBar(String bar) { this.bar = ba
7
Domino & REST: Accessing Domino’s Environment / Check Authentication
Thu, Mar 2nd 2017 11:00a   Sven Hasselbach
If we want to access Domino’s Environment, it is the ContextInfo class which gives us all we need. Everything you need to do to use the class is described in an earlier blog post. The class gives mainly access to the following methods: Method Description getDataDirectory() Path to notes data directory getEnvironmentString(String envName) Returns the environment variable getServerDatabase() The actual database as NAPI object, if any getServerVariable(String varName) Variables
9
Domino & REST: Consuming JSON
Wed, Mar 1st 2017 7:25a   Sven Hasselbach
Consuming JSON is as easy as pie: Just create a new method to the RestApiServlet,  add a @POST annotation, and declare the object you want to the parameters of the method:     @POST     @Path("/helloworld/")     @Consumes(MediaType.APPLICATION_JSON)     public Response postHelloWorld(HelloWorld helloWorld) {         return Response.ok(helloWorld, MediaType.APPLICATION_JSON).build();     } In this example we are using the same URI „/helloworld/„; because
7
Domino & REST: A basic Servlet
Tue, Feb 28th 2017 1:49p   Sven Hasselbach
To have a good starting point when creating RESTful applications on top of Domino, I have created a „Hello World“ example of a JEE Application, based on Apache Wink & Jackson 2.5.0. The Jackson AnnotaionProcessor is registered into Apache Wink application and is enabled by default, the JAXB processor is also included as the secondary AnnotationProcessor. The benefit of this is that only one global ObjectMapper instance is created and is reused, wich allows a better performance as




Created and Maintained by Yancy Lent - About - Planet Lotus Blog - Advertising - Mobile Edition