resteasy

Changing Default JSON Time Format with RESTEasy 3.x

五迷三道 提交于 2019-12-21 04:04:35
问题 I am using RESTEasy to implement a REST Service using JSON serialization. Currently, Dates are getting serialized to milliseconds since 1970. To improve compatibility, I would like to get my dates into one of two formats; milliseconds + timezone offset or ISO 8061. It seems that RESTEasy used to use Jettison for JSON serialization, but from what I've been reading they've switch to Jackson ... all of this has made googling for help pretty hit or miss. From what I can tell, I need to implement

RESTEasy - add a resource class dynamically

拟墨画扇 提交于 2019-12-20 04:57:58
问题 With RESTEasy I've implemented a subclass of Application to provide a list of singleton resources. Is there a way to add another singleton dynamically later on? I've not found a way to do it from the API docs. 回答1: I have not tried this myself, but I found a blog post where this is described: http://sarbarian.wordpress.com/2010/03/07/resteasy-and-osgi-perfect-match/ During deployment, RESTEasy puts it's registry in the servlet context. The idea suggstested in the blog, is that you fetch the

How to convert JSON to list of POJOs using RestEasy

淺唱寂寞╮ 提交于 2019-12-20 04:53:47
问题 I have to integrate our j2ee application with a REST webservice. And I wanted to use the RestEasy JAX-RS implementation from JBoss. The webservice returns an array in JSON format. I've this piece of code: Client client = ClientBuilder.newClient(); WebTarget target = client.target("http://myservices.com/schemes/all"); Response response = target.request().get(); Can I map this "response" object to List<Scheme> using RestEasy? Thanks 回答1: Provided that your JSON provider is capable of converting

JAX-RS NoMessageBodyWriterFoundFailure

我的未来我决定 提交于 2019-12-20 04:46:55
问题 the method of my jax-rs application: @GET @Produces (MediaType.APPLICATION_JSON) public List <Document> getDocumentList(@HeaderParam("Range") String headerRange) { int [] range = getRangeFromHeader(headerRange); return facade.listByRange(range); } working properly. But If modifications to the: @GET @Produces(MediaType.APPLICATION_JSON) public Response getDocumentList(@HeaderParam("Range") String headerRange) { int[] range = getRangeFromHeader(headerRange); return Response.ok( facade

Using @RolesAllowed to filter entity properties with RESTEasy and Jackson

瘦欲@ 提交于 2019-12-20 04:34:58
问题 With RESTEasy and Jackson, is it possible to use the @RolesAllowed annotation in my model, in order to avoid certain properties to be serialized in output, depending on the role of the user? I already found a ton of documentation on how to do this with Jersey, but nothing with RESTEasy. I'm blocked on this architecture so switching libraries is not an option, and using the custom ObjectMapper as explained here is not an option either, as the model is big enough to make it too time-consuming

RESTEasy client: reconstructing an object

社会主义新天地 提交于 2019-12-19 21:48:48
问题 I'm playing with RESTEasy to consume REST services, and I'm trying it out with Twitter's search API. So I create this interface: public interface SimpleClient { @GET @Path("search.json") @Produces("application/json") ClientResponse<Set<String>> getSearchResults( @QueryParam("q") String hashtag, @QueryParam("result_type") String resultType ); } and called it with: SimpleClient client = ProxyFactory.create(SimpleClient.class,"http://search.twitter.com/"); ClientResponse<Set<String>> response =

What should we use for ClientResponse and GenericType in latest version (3.0.x) Resteasy?

孤者浪人 提交于 2019-12-19 10:14:07
问题 I am developing Resteasy . I migrated my application's maven dependencies from 2.2.x to 3.0.x and suddenly I saw most of the API's are deprecated. So this migration has affect to my code and test cases as its simply saying deprecated in my whole code. I am taking example of my test cases: Test case with earlier version(in latest version it deprectaed as mentioned in link: ClientRequestFactory RestEasy Deprecated... Any other RestEasy alternative ? ): import org.jboss.resteasy.util.GenericType

Why writer for media type application/json missing

可紊 提交于 2019-12-19 09:11:58
问题 Basically I have a restful service (post) that consumes( application/json ) and produces ( application/json ). The single param for this service is an annotated java object. I am using org.jboss.resteasy.client.ClientRequest to send the request to the service. However, I am getting this exception in the client end and the exception: could not find writer for content-type application/json type. Does this mean that I am missing some library jars or I have to write my own writer for application

Hosting Static Content and JAX-RS Services Under the Same Root Context

心已入冬 提交于 2019-12-19 03:18:07
问题 We have multiple Java web apps packaged as WARs all packaged in an EAR. Our RESTful services are built using JAX-RS and in version specific WARs. We'd like to add static content for each of these version specific WARs, but use the root context (of the WAR) for both the static content and the RESTful service API calls, such that all of the following URLs will work: {hostname}/v1/swagger.yaml <-- Static Content describing the v1 API {hostname}/v1/orders/{uid} <-- JAX-RS RESTful API (v1)

Using JAXB to pass subclass instances as superclass

北城以北 提交于 2019-12-18 20:59:11
问题 What I have is a set of Java classes (close to 25) representing message types. They all inherit from a Message class which I'd like to be abstract. Each message type adds a few additional fields to the set provided by the Message superclass. I'm implementing some RESTful web services using RESTeasy and would like to have methods like this: public Response persist(Message msg) { EntityTransaction tx = em.getTransaction(); tx.begin(); try { em.persist(msg); } catch (Exception e) { e