Coder Social home page Coder Social logo

jaxrs-sample's Introduction

JAX-RS Sample application for Wildfly

A very simple JAX-RS sample application that implements a few services. The services are meant purely as a demonstration and are not "real" services.

Deployment

To build, simply run

mvn clean package

This will create a war file that can be deployed into an JEE app server. I've only tested with Wildfly at this point.

The war file can be deployed to Wildfly and possibly other JEE application servers. For Wildlfy, there are many options to deploy listed on the application deployment page that can help deploy.

Sample Service Info

There are a total of three service endpoints:

GET /v1/heartbeat - returns a "text/plain" HTTP body of "OK" if the service is up and running. A heartbeat service like this is commonly used in load balancing environments so that a load balancer can validate that an application is healthy.

POST /v1/product - puts a "product" in the catalog. The product is a simple JSON formatted object:

{"description": "The Product Description"}

This creates a product in the catalog. The response will look like:

{
  "productId": 96361,
  "description": "The Product Description",
  "createDate": "2017-04-10T02:51:12.772Z"
}

Note that the productId is simply a random integer between 10000 and 1000000. The createDate is when the product was added to the catalog. Note that you can also send your own product id in the POST:

{
  "productId": 123456,
  "description": "The Product Description"
}

in which case the id that is given will be used.

If the product id is already in use a 409 (Conflict) HTTP error will be returned with the body

{
  "message": "product id 123456 already exists"
}

GET /v1/product/{productId} gets an existing product with the given product id. The response body looks the same as the call to create a new product. A call with a product id that doesn't exist will return an HTTP 404 error with the body:

{
  "message": "productId not found - 123456"
}

Logging

The two product services are annotated with @Logged which means that the input and output of them will be logged to the loggers. This is a nice way to get the input and output of the web service calls without using any proprietary libraries.

Copyright (c) 2017 by Xigole Systems Licensed under the MIT License - see the file LICENSE for details.

jaxrs-sample's People

Contributors

stdunbar avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.