Jetty Web Server Java POJO Communication

Jetty Web Server Java POJO Communication

In last tutorial you saw how to create Jetty Web server integrated with Google Proto Buffers. In this example you will see how to communicate with Java Old Plain Object means we will be sending request in Java Object and send response back to then client in Java Object. All configuration is same as previous tutorial

Tools needed:

  • Eclipse latest version
  • JDK 1.8
  • Google Protocol Buffers exe which is already include in the project for download
  • Maven 3.2.5
  • Jetty dependent jars (already included in pom.xml)

 

  • Create maven project name: JettyGoogleProtoBuffIntegration below is complete project structure:

Jetty Web Server Java POJO Communication

  • pom.xml:

  • javahonk.properties:

  • server-context.xml:

  • AddressBook.java – Model class to send and receive data:

  • SerializeObject.java: To serialize and deserialize the object

  • JettyService.java: A jetty server class:

  • MessageHandler.java: Main class handles all request and send response:

  • ServerMessageProcessor.java: Default interface for class implementation:

  • PlainObjectProcessor.java: A class where handler send request for processing and its process the request and send response back to the client:

  • JavaHonkMainApp.java: Main class to start the application:

  • To start the applicatoin right click this class and run as java application you will out same as below:

Jetty Web Server Java POJO Communication

  • HTTPPostSendTestData.java: Client class which post data to the server and process response. Right click and run as java application to send and receive response:

  • You will below response data on console:

Jetty Web Server Java POJO Communication

Download source code: JettyJavaPlainObjectCommunication

Leave a Reply

Your email address will not be published. Required fields are marked *