Giter VIP home page Giter VIP logo

couchbase-javaee's Introduction

Couchbase and Java EE

This workspace will show how to query a Couchbase bucket using simple Java EE application deployed on WildFly. Alternative configuration is also provided to deploy on Payara/GlassFish.

Minimum Requirements

  1. Docker for Mac 1.13

Run Application

  1. Start Docker Swarm Mode: docker swarm init

  2. Build application: mvn package. Alternatively, it can be built using Docker:

    docker volume create maven
    docker run -it --rm -v $PWD:/usr/src -v maven:/root/.m2 -w /usr/src maven:3.3-jdk-8 mvn package
  3. Build Docker image: docker image build -t arungupta/wildfly-couchbase-javaee:travel .

  4. Deploy the application: docker stack deploy --compose-file=docker-compose.yml couchbase-javaee

Deploy Application to Payara/GlassFish

mvn install -Ppayara -Dpayara.hostname=localhost -Dpayara.username=admin -Dpayara.password=glassfish

Access Application

Get 10 Airline resources (GET)

curl -v http://localhost:8080/couchbase-javaee/resources/airline
*   Trying ::1...
* Connected to localhost (::1) port 8080 (#0)
> GET /couchbase-javaee/resources/airline HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.43.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Connection: keep-alive
< X-Powered-By: Undertow/1
< Server: WildFly/8
< Content-Type: application/octet-stream
< Content-Length: 1402
< Date: Sat, 16 Jul 2016 05:34:56 GMT
<
* Connection #0 to host localhost left intact
[{"travel-sample":{"id":10,"iata":"Q5","icao":"MLA","name":"40-Mile Air","callsign":"MILE-AIR","type":"airline","country":"United States"}}, {"travel-sample":{"id":10123,"iata":"TQ","icao":"TXW","name":"Texas Wings","callsign":"TXW","type":"airline","country":"United States"}}, {"travel-sample":{"id":10226,"iata":"A1","icao":"A1F","name":"Atifly","callsign":"atifly","type":"airline","country":"United States"}}, {"travel-sample":{"id":10642,"iata":null,"icao":"JRB","name":"Jc royal.britannica","callsign":null,"type":"airline","country":"United Kingdom"}}, {"travel-sample":{"id":10748,"iata":"ZQ","icao":"LOC","name":"Locair","callsign":"LOCAIR","type":"airline","country":"United States"}}, {"travel-sample":{"id":10765,"iata":"K5","icao":"SQH","name":"SeaPort Airlines","callsign":"SASQUATCH","type":"airline","country":"United States"}}, {"travel-sample":{"id":109,"iata":"KO","icao":"AER","name":"Alaska Central Express","callsign":"ACE AIR","type":"airline","country":"United States"}}, {"travel-sample":{"id":112,"iata":"5W","icao":"AEU","name":"Astraeus","callsign":"FLYSTAR","type":"airline","country":"United Kingdom"}}, {"travel-sample":{"id":1191,"iata":"UU","icao":"REU","name":"Air Austral","callsign":"REUNION","type":"airline","country":"France"}}, {"travel-sample":{"id":1203,"iata":"A5","icao":"RLA","name":"Airlinair","callsign":"AIRLINAIR","type":"airline","country":"France"}}]

Get one Airline resource (GET)

curl -v http://localhost:8080/couchbase-javaee/resources/airline/137
curl -v http://localhost:8080/couchbase-javaee/resources/airline/137
*   Trying ::1...
* Connected to localhost (::1) port 8080 (#0)
> GET /couchbase-javaee/resources/airline/137 HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.43.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Connection: keep-alive
< X-Powered-By: Undertow/1
< Server: WildFly/8
< Content-Type: application/octet-stream
< Content-Length: 131
< Date: Sat, 16 Jul 2016 05:35:57 GMT
<
* Connection #0 to host localhost left intact
{"travel-sample":{"id":137,"iata":"AF","icao":"AFR","name":"Air France","callsign":"AIRFRANS","type":"airline","country":"France"}}

Create a new Airline resource (POST)

curl -v -H "Content-Type: application/json" -X POST -d '{"country":"France","iata":"A5","callsign":"AIRLINAIR","name":"Airlinair","icao":"RLA","type":"airline"}' http://localhost:8080/couchbase-javaee/resources/airline
*   Trying ::1...
* Connected to localhost (::1) port 8080 (#0)
> POST /couchbase-javaee/resources/airline HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.43.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 104
>
* upload completely sent off: 104 out of 104 bytes
< HTTP/1.1 200 OK
< Connection: keep-alive
< X-Powered-By: Undertow/1
< Server: WildFly/8
< Content-Type: application/octet-stream
< Content-Length: 117
< Date: Sat, 16 Jul 2016 05:36:42 GMT
<
* Connection #0 to host localhost left intact
{"id":"19810","iata":"A5","icao":"RLA","name":"Airlinair","callsign":"AIRLINAIR","type":"airline","country":"France"}

Update an existing Airline resource (PUT)

curl -v -H "Content-Type: application/json" -X PUT -d '{"country":"France","iata":"A5","callsign":"AIRLINAIR","name":"Airlin Air","icao":"RLA","type":"airline","id": "19810"}' http://localhost:8080/couchbase-javaee/resources/airline/19810
*   Trying ::1...
* Connected to localhost (::1) port 8080 (#0)
> PUT /couchbase-javaee/resources/airline/19810 HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.43.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 119
>
* upload completely sent off: 119 out of 119 bytes
< HTTP/1.1 200 OK
< Connection: keep-alive
< X-Powered-By: Undertow/1
< Server: WildFly/8
< Content-Type: application/octet-stream
< Content-Length: 118
< Date: Sat, 16 Jul 2016 05:37:29 GMT
<
* Connection #0 to host localhost left intact
{"id":"19810","iata":"A5","icao":"RLA","name":"Airlin Air","callsign":"AIRLINAIR","type":"airline","country":"France"}

Delete an existing Airline resource (DELETE)

curl -v -X DELETE http://localhost:8080/couchbase-javaee/resources/airline/19810
*   Trying ::1...
* Connected to localhost (::1) port 8080 (#0)
> DELETE /couchbase-javaee/resources/airline/19810 HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.43.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Connection: keep-alive
< X-Powered-By: Undertow/1
< Server: WildFly/8
< Content-Type: application/octet-stream
< Content-Length: 136
< Date: Sat, 16 Jul 2016 05:38:14 GMT
<
* Connection #0 to host localhost left intact
{"travel-sample":{"id":"19810","iata":"A5","icao":"RLA","name":"Airlin Air","callsign":"AIRLINAIR","type":"airline","country":"France"}}

couchbase-javaee's People

Contributors

arun-gupta avatar chanezon avatar wcomnisky avatar

Watchers

NIlanjan Chakraborty 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.