use of org.glassfish.jersey.media.multipart.MultiPartFeature in project jersey by jersey.
the class MultiPartTest method testMultiPartResource.
@Test
public void testMultiPartResource() throws Exception {
final ResourceConfig resourceConfig = new ResourceConfig(MultiPartResource.class).register(new MultiPartFeature());
final HttpServer server = GrizzlyHttpServerFactory.createHttpServer(baseUri, resourceConfig);
Client c = ClientBuilder.newClient(new ClientConfig().register(MultiPartFeature.class));
final Response response = c.target(baseUri).path("/multipart-simple").request().buildGet().invoke();
MultiPart result = response.readEntity(MultiPart.class);
System.out.println("RESULT = " + result);
checkEntity("This is the only segment", (BodyPartEntity) result.getBodyParts().get(0).getEntity());
server.shutdownNow();
}
use of org.glassfish.jersey.media.multipart.MultiPartFeature in project jersey by jersey.
the class MultiPartJerseyTest method configure.
@Override
protected Application configure() {
enable(TestProperties.LOG_TRAFFIC);
enable(TestProperties.DUMP_ENTITY);
return new ResourceConfig().registerClasses(getResourceClasses()).registerClasses(MultiPartBeanProvider.class).registerInstances(new LoggingFeature(LOGGER, LoggingFeature.Verbosity.PAYLOAD_ANY)).register(new MultiPartFeature());
}
use of org.glassfish.jersey.media.multipart.MultiPartFeature in project Payara by payara.
the class AbstractRestResourceProvider method getResourceConfig.
@Override
public ResourceConfig getResourceConfig(Set<Class<?>> classes, final ServerContext sc, final ServiceLocator habitat, final Set<? extends Binder> additionalBinders) throws EndpointRegistrationException {
final Reloader r = new Reloader();
ResourceConfig rc = new ResourceConfig(classes);
rc.property(ServerProperties.MEDIA_TYPE_MAPPINGS, getMimeMappings());
rc.register(CsrfProtectionFilter.class);
// TODO - JERSEY2
// RestConfig restConf = ResourceUtil.getRestConfig(habitat);
// if (restConf != null) {
// if (restConf.getLogOutput().equalsIgnoreCase("true")) { //enable output logging
// rc.getContainerResponseFilters().add(LoggingFilter.class);
// }
// if (restConf.getLogInput().equalsIgnoreCase("true")) { //enable input logging
// rc.getContainerRequestFilters().add(LoggingFilter.class);
// }
// if (restConf.getWadlGeneration().equalsIgnoreCase("false")) { //disable WADL
// rc.getFeatures().put(ResourceConfig.FEATURE_DISABLE_WADL, Boolean.TRUE);
// }
// }
// else {
// rc.getFeatures().put(ResourceConfig.FEATURE_DISABLE_WADL, Boolean.TRUE);
// }
//
rc.register(r);
rc.register(ReloadResource.class);
rc.register(new MultiPartFeature());
// rc.register(getJsonFeature());
rc.register(new AbstractBinder() {
@Override
protected void configure() {
AbstractActiveDescriptor<Reloader> descriptor = BuilderHelper.createConstantDescriptor(r);
descriptor.addContractType(Reloader.class);
bind(descriptor);
AbstractActiveDescriptor<ServerContext> scDescriptor = BuilderHelper.createConstantDescriptor(sc);
scDescriptor.addContractType(ServerContext.class);
bind(scDescriptor);
LocatorBridge locatorBridge = new LocatorBridge(habitat);
AbstractActiveDescriptor<LocatorBridge> hDescriptor = BuilderHelper.createConstantDescriptor(locatorBridge);
bind(hDescriptor);
RestSessionManager rsm = habitat.getService(RestSessionManager.class);
AbstractActiveDescriptor<RestSessionManager> rmDescriptor = BuilderHelper.createConstantDescriptor(rsm);
bind(rmDescriptor);
}
});
for (Binder b : additionalBinders) {
rc.register(b);
}
rc.property(MessageProperties.LEGACY_WORKERS_ORDERING, true);
return rc;
}
Aggregations