resteasy

Make a collection generic in javax.xml.bind

若如初见. 提交于 2019-12-06 06:11:35
问题 In a REST server that I've written, I have several collection classes that wrap single items to be returned from my services: @XmlAccessorType(XmlAccessType.NONE) @XmlRootElement(name = "person_collection") public final class PersonCollection { @XmlElement(name = "person") protected final List<Person> collection = new ArrayList<Person>(); public List<Person> getCollection() { return collection; } } I would like to refactor these to use generics so the the boilerplate code can be implemented

How do I implement client side http caching like a browser?

天大地大妈咪最大 提交于 2019-12-06 04:32:24
问题 I use a RESTFul service as a backend to my frontend. The service sets expires/etag/lastmodified headers on it's responses. What I'm looking for is a client-side(favorably java) library which can fetch data from the service and cache it in a pluggable caching backend like ehcache. What I also want to be able to do is automatically prime the cache using background worker threads as soon as an entry is invalidated. Also, it should be smart to do conditional GETs. I've come across http://hc

Tomcat 7, Weld, RESTEasy not Scanning JARs

时间秒杀一切 提交于 2019-12-06 01:35:18
I have Tomcat 7.0.47 and I'm hosting a REST Easy JAXRS service. The service uses two external JARs, one that has a base repository interface and default implementation and one that creates a concrete repository derived from the base (i.e. these two JARs have a dependency). The service works, i.e. I can send a request and get back data from the database. Now what I'm trying to do is get the repository injected into the REST service, to do this I've changed the REST code to look like @Path("/country") public class CountryService { @Inject ICountriesRepository repository; @GET @Produces({

RESTEasy Mock vs. Exception Mapper vs. Context

做~自己de王妃 提交于 2019-12-06 01:31:20
问题 RESTEasy mock framework works fine without exception mapper--request is received and entity is returned with expected contents. After registering exception mapper and forcing an exception, call fails when innards of RESTEasy call ResteasyProviderFactory.getContextData(type), which returns null, resulting in unexpected error message: "Unable to find contextual data of type: javax.servlet.http.HttpServletRequest". Couldn't find any examples anywhere online of RESTEasy mock plus an exception

RESTEasy + Jackson: how to exclude fields in the response?

杀马特。学长 韩版系。学妹 提交于 2019-12-05 23:48:03
问题 I'm migrating my Java web application from servlet-based to JAX-RS. Since I'm using Jboss I'll also use (by default) RESTEasy. In my servlets I use Jackson to serialize/deserialize JSON; Jackson allows me to filter programatically the inclusion/exclusion of fields, for example: ObjectMapper mapper = new ObjectMapper().setVisibility(JsonMethod.FIELD, Visibility.ANY); String[] ignorableFieldNames = { "id", "name" }; FilterProvider filters = new SimpleFilterProvider(). addFilter("f123"

How to make Resteasy 2.3.6 use Jackson 2.+

删除回忆录丶 提交于 2019-12-05 23:23:57
IS there a way to make RestEasy use Jackson 2+ ? It seems that RestEasy Jackson provider uses Jackson 1.9.9 and it's still a case for ResetEasy 3. It occured to be quite simple. There are Jackson JAXRS providers in Jackson 2 already. jackson-jaxrs-xml-provider jackson-jaxrs-json-provider jackson-jaxrs-smile-provider So on the pom.xml <dependency> <groupId>com.fasterxml.jackson.jaxrs</groupId> <artifactId>jackson-jaxrs-json-provider</artifactId> <version>2.2.2</version> </dependency> It's also good to exclude resteasy-jettison-provider to make sure you have no conflicts fo JSON handling.

Integrating spring-boot with RESTEasy

限于喜欢 提交于 2019-12-05 21:15:28
I am trying to prototype a Spring Boot application. I'm coming from a Guice JAX-RS application, so I prefer the standard JAX-RS annotations to Spring MVC. I've gotten Jetty up and serving: @Configuration @Import({ResteasyBootstrap.class, SpringBeanProcessorServletAware.class, HttpServletDispatcher.class}) public class EmbeddedJetty { @Bean @Singleton public EmbeddedServletContainerFactory servletContainer() { JettyEmbeddedServletContainerFactory factory = new JettyEmbeddedServletContainerFactory(); factory.setPort(9000); factory.setSessionTimeout(10, TimeUnit.MINUTES); return factory; } }

How to use RESTEasy PreProcessInterceptor only in specific methods?

六月ゝ 毕业季﹏ 提交于 2019-12-05 21:02:23
问题 I'm writing a REST API, making use of RestEasy 2.3.4.Final. I know that a Interceptor will intercept all of my requests, and that a PreProcessInterceptor will be the first (before everything) to be called. I would like to know how can I make this Interceptor to be called just when specific methods are called. I tried to use both PreProcessInterceptor and AcceptedByMethod, but I was not able to read the parameters I need. For example, I need to run my Interceptor only when this method is

How to generate wadl file for resteasy in jboss

旧巷老猫 提交于 2019-12-05 20:51:07
I want to generate a wadl file for my project which is using resteasy + Jboss 6.4 + Maven. There are many examples given for jersey but not for resteasy does anyone used it for resteasy Resteasy since 3.0.14.Final do support WADL generation. You need to add resteasy-wadl to your dependency manager (e.g. maven): <dependency> <groupId>org.jboss.resteasy</groupId> <artifactId>resteasy-wadl</artifactId> <version>3.0.19.Final</version> </dependency> then declare a new servlet endpoint in your web.xml for providing generated wadl file: <servlet> <servlet-name>WADL</servlet-name> <servlet-class>org

Using RESTeasy on Tomcat

守給你的承諾、 提交于 2019-12-05 20:08:50
I am new to restful web services.One of my client given me some methods with resteasy implementation those methods i have use in my project.I am using apache tomcat server in my project.can these methods will run on apache tomcat server or not??? Yes it's possible. You need to add the RESTeasy implementation jars/dependencies. For Maven (resteasy.version == 3.0.9.Final) <!-- Basic support --> <dependency> <groupId>org.jboss.resteasy</groupId> <artifactId>resteasy-jaxrs</artifactId> <version>${resteasy.version}</version> </dependency> <!-- Servlet pluggability support --> <dependency> <groupId