Wednesday 16 November 2016

Getting started Jersey.

1. Project build and management configuration is described in the pom.xml located in the project root
directory.
REF : pom elements
2. Project sources are located under src/main/java.
3. Project resources are located under src/main/resources.
4. Project web application files are located under src/main/webapp.

5. To compile and package the application into a WAR, invoke the following maven command in your
console:

ex : mvn clean package

logs :

Packaging webapp
[INFO] Assembling webapp [simple-service-webapp] in [.../simple-service-webapp/target/[INFO] Processing war project
[INFO] Building war: .../simple-service-webapp/target/simple-service-webapp.war

Now you are ready to take the packaged WAR (located under ./target/simple-servicewebapp.
war) and deploy it to a Servlet container of your choice.

Jersey dependency maven :

1) jersey-server, jersey-json, jersey-multipart.

Spring dependency :

spring-core,context,context-support,web,aop.

spring security.

security-web,security-config,security-taglib,security-core,security-acl

spring+jersey

spring,core,web,beans,context,asm,aop.

jackson:

jackson-jaxrs-json-provider


apache commons :

utility for string manipulation

connection pool :

dbcp

Apache-commns :

Apache Commons Codec provides implementations of common encoders and decoders such as Base64, Hex, Phonetic and URLs.

Hibernate :

hibernate-core

spring-transaction:

REF : transaction   why we go for spring transaction

hibernate entity manager
table mapping

spring-orm



6. Root Resource Classes
Root resource classes are POJOs (Plain Old Java Objects) that are annotated with @Path

7. @Produces
annotation is used to specify the MIME media types of representations a resource can produce and send back to the
client.
Using multiple output MIME types
@Produces({"application/xml", "application/json"})


@Consumes
annotation is used to specify the MIME media types of representations that can be consumed by a resource.

@QueryParam
is used to extract query parameters from the Query component of the request URL.

@DefaultValue
annotation, will be assigned to the step method parameter. If the
"step" value cannot be parsed as a 32 bit signed integer then a HTTP 404
ex :
 public Response smooth(
4 @DefaultValue("2") @QueryParam("step") int step

@FormParam

it extracts information from a request representation that is of the MIME media type
"application/x-www-form-urlencoded"

@Context HttpHeaders headers,

@Singleton
annotation says that the resource
will be managed as singleton and not in request scope. The sub-resource locator method returns a class which means that the runtime will managed the resource instance and its life-cycle. If the method would return instance instead, the Singleton annotation would have no effect and the returned instance would be used.


Securiry -- done
Multipart  -- progress -- 8.3
Filters -- 9.0







Stateless Authentication with Spring Security


1) for content and format ref :
http://blog.jdriven.com/2014/10/stateless-spring-security-part-2-stateless-authentication/

2) http://www.codingpedia.org/ama/how-to-secure-jersey-rest-services-with-spring-security-and-basic-authentication/
3) http://www.codingpedia.org/ama/tutorial-rest-api-design-and-implementation-in-java-with-jersey-and-spring/