Share

Search Java Code Snippets


  Help us in improving the repository. Add new snippets through 'Submit Code Snippet ' link.





#Java - Code Snippets for '#Javax.ws.rs.core.MediaType' - 2 code snippet(s) found

 Sample 1. Rest Web Service ( Post ) using Jersey, XML

@Path("/employeeInfo")
public class RestWebServiceJersey {
@POST
@Consumes(MediaType.APPLICATION_XML)
@Produces(MediaType.APPLICATION_XML)
public String submitEmployeeInfo(Employee employee) {
StatusDto status = insertIntoDb(employee);
return status;
}
}

   Like      Feedback     rest  @post  @consumes  @produces  xml  rest web service  jersey  javax.ws.rs.Path  javax.ws.rs.Post  javax.ws.rs.Produces  javax.ws.rs.Consumes  javax.ws.rs.core.MediaType


 Sample 2. Implementation of com.sun.jersey.api.core.DefaultResourceConfig

public class MyConfig extends DefaultResourceConfig {

private final Set<Class<?>> classes =
ImmutableSet.<Class<?>>of(SampleResource1.class, SampleResource2.class);

private final Set<Object> singletons =
ImmutableSet.<Object>of(
new JacksonJaxbJsonProvider().configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, true), new KryoProvider<Object>()
);

private final Map<String, MediaType> mediaTypeMapppings = ImmutableMap.of("json", MediaType.APPLICATION_JSON_TYPE);

public MyConfig() {
super();
}

@Override
public Set<Class<?>> getClasses() {
return classes;
}

@Override
public Set<Object> getSingletons() {
return singletons;
}

@Override
public Map<String, MediaType> getMediaTypeMappings() {
return mediaTypeMapppings;
}
}

   Like      Feedback     Implementation of DefaultResourceConfig   jersey



Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner



comments powered by Disqus