Professional Documents
Culture Documents
THIS PROJECT IS JUST TO DEMONSTRATE THE PARAM ANNOTATION...& THUS IT DOES NOT
MAKE ANY CHANGES IN THE EXISTING MESSAGE SERVICE PROECT CLASSES..INSTEAD WE
WILL CREATE A NEW CALSS TO TASTE IT
package com.module;
import javax.ws.rs.Consumes;
import javax.ws.rs.CookieParam;
import javax.ws.rs.GET;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.MatrixParam;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
@Path("/injectDemo")
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.TEXT_PLAIN)
public class InjectDemoResource{
@GET
@Path("/annotations")
public String GetParamUsingAnnotations(@MatrixParam("param")
String MatrixParam , @HeaderParam("customHeader") String header,
@CookieParam("name") String cookie){
return "Gitesh says : MATRIX PARAM => "+MatrixParam +" &
HEADER VALUE => "+header+" & COOKIE VALUE (if set then) =>
"+cookie;
}
//MATRIX PARAM => very similar to QUERY PARAM... but they use
';' instaed of '?'
//eg: /messages;param=value
//HEADER PARAM => when we send the data in the header section
along with the request..then the header pram is used to handle that
data
// these header values can play a big role when it comes to
authorization and security
//like you can send the session ID and all that things using
these fields
//where customHeader is just an example name of the header and
it will read its value and return us