jersey

is it possible to call one jax-rs method from another?

白昼怎懂夜的黑 提交于 2019-12-22 01:55:11
问题 suppose i have some jax-rs resource class: @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public class ResourceA { @GET public Something get(@Context UriInfo uriInfo) { if (...) { //how to get to ResourceB ? } } } and i want to conditionally redirect the call to some other jax-rs resource: public class ResourceB { @GET @Path("{identifier}") public Other get(@PathParam("identifier")String someArg) { } } how do i do this? note that i dont want this to be visible to

JERSEY RESTful - How to work with multiselect checkboxes?

穿精又带淫゛_ 提交于 2019-12-22 00:40:53
问题 I´m trying to create a method that receive a list of parameters from a multiselection checkbox html component. But, it just doesn´t work. I've test: @POST.. .. myMethod(@FormParam String [] myCheckboxAttribute) .. myMethod(@FormParam List<String> myCheckboxAttribute) None of those works well (the last one (list) come with just the first checkbox checked but the others no). Some idea? 回答1: You have to specify the name of the form parameter in the @FormParam annotation. Here is an example that

Jersey SSE client is not receiving events

你离开我真会死。 提交于 2019-12-21 22:45:27
问题 I have written a rudimentary Java application to consume SSE (server-sent events) streamed from a Node.js server, using the Jersey SSE client. However, I am unable to receive the events. To verify the server component is working as expected, I used the curl as follows: curl -v -H "Accept: text/event-stream" http://localhost:8080/events/ I get the following response: * Trying ::1... * Connected to localhost (::1) port 8080 (#0) > GET /events/ HTTP/1.1 > Host: localhost:8080 > User-Agent: curl

Upgrading jax-rs shared library on weblogic

試著忘記壹切 提交于 2019-12-21 19:54:15
问题 Normally weblogic 12c doesnt support jax-rs 2.0 but by the help of jax-rs shared library which comes with weblogic itself it is possible to upgrade jax-rs version from 1.1 to 2.0. The problem is library implementation is jersey 2.5 which doesnt satisfy my needs. I found a link about upgrading jersey version on weblogic which looks a lil bit complex. Is it enough to replace jersey jars 2.5 with my jersey version 2.13? Do i need to do anything else? 回答1: I have created a simple maven project to

Jersey Consumes XML post

不羁的心 提交于 2019-12-21 17:36:02
问题 I want to make a Post to Jersey Rest service. What is the standard way of doing this? @Post @Consumes(MediaType.Application_xml) public Response method(??){} 回答1: Suppose you have a java bean say an employee bean such as. Add the tags to tell @XmlRootElement (name = "Employee") public class Employee { String employeeName; @XmlElement public String getEmployeeName() { return employeeName; } public void setEmployeeName(String employeeName) { this.employeeName = employeeName; } } @XmlRootElement

Why my Aspect is not detected for Jersey controller (using custom annotation)?

删除回忆录丶 提交于 2019-12-21 12:32:54
问题 I want to create an Aspect over a Jersey controller to measure how long the services take to be executed. I'm fighting against my pointcut since it isn't detected and my aspect never gets launched. I have tried using lots of pointcuts like: execution(@Monitor * *.*(..)) execution(public * *(..)) change the order of @Aspect and @Component Added a pointcut like this: @Pointcut("execution(@Monitor * *.*(..))") public void monitorRequestTargets(){} @Around("monitorRequestTargets()") Tried using

Why are names returned with @ in JSON using Jersey

大憨熊 提交于 2019-12-21 10:10:12
问题 I am using the JAXB that is part of the Jersey JAX-RS. When I request JSON for my output type, all my attribute names start with an asterisk like this, This object; package com.ups.crd.data.objects; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlType; @XmlType public class ResponseDetails { @XmlAttribute public String ReturnCode = ""; @XmlAttribute public String StatusMessage = ""; @XmlAttribute public String TransactionDate =""; } becomes this, {

Java: Enum case insensitive Jersey Query Param Binding

谁都会走 提交于 2019-12-21 09:43:08
问题 I tried to override/implement all the attribute in JSR311 but the Jersey binding seems case sensitive : Be a primitive type Have a constructor that accepts a single String argument Have a static method named valueOf or fromString that accepts a single String argument (see, for example, Integer.valueOf(String)) Be List, Set or SortedSet, where T satisfies 2 or 3 above. The resulting collection is read-only. How can I make Jersey binding for enum case insensitive? EDIT: Here's the code: The

How do I get the URL of a request?

半城伤御伤魂 提交于 2019-12-21 07:22:44
问题 I am using Jeresy Jax-RS to build a web service. Now I need to get the url of the request with the port # if one exist. So if my service runs on http://www.somelocation.com/web/services I want to capture the www.somelocation.com How can I do this ? 回答1: You can add a UriInfo parameter to your operation. From there you can access the URL: @POST @Consumes({"application/xml", "application/json"}) public Response create(@Context UriInfo uriInfo, Customer customer) { ... } 来源: https:/

How do I get the URL of a request?

蓝咒 提交于 2019-12-21 07:22:02
问题 I am using Jeresy Jax-RS to build a web service. Now I need to get the url of the request with the port # if one exist. So if my service runs on http://www.somelocation.com/web/services I want to capture the www.somelocation.com How can I do this ? 回答1: You can add a UriInfo parameter to your operation. From there you can access the URL: @POST @Consumes({"application/xml", "application/json"}) public Response create(@Context UriInfo uriInfo, Customer customer) { ... } 来源: https:/