Siddharth Trikha
Siddharth Trikha

Reputation: 2506

@Path in rest-easy with variable?

I am using rest-easy and I want my @Path annotation to obtain it's value from a variable (mayabe a system parameter).

Eg:

@Path(someVar)
    @GET
    @Produces(MediaType.TEXT_XML)
    public String retrieve() {
}

I tried reading and got to know that Path must be a constant value.

Is something like above possible in rest easy ??

Upvotes: 0

Views: 1023

Answers (2)

Naveen Ramawat
Naveen Ramawat

Reputation: 1445

You can pass variable value in URL, something like below example so your URL will be /book/some_isbn_code and the getBook method will receive isbn value in id field.

@Path("/book/{isbn}")
public String getBook(@PathParam("isbn") String id) {

Upvotes: 0

user5500105
user5500105

Reputation: 297

Annotations are processed on compile time. You cannot use a variable as an annotation parameter.

Upvotes: 1

Related Questions