本文整理汇总了Java中org.codehaus.jackson.jaxrs.JacksonJsonProvider类的典型用法代码示例。如果您正苦于以下问题:Java JacksonJsonProvider类的具体用法?Java JacksonJsonProvider怎么用?Java JacksonJsonProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JacksonJsonProvider类属于org.codehaus.jackson.jaxrs包,在下文中一共展示了JacksonJsonProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configClient
import org.codehaus.jackson.jaxrs.JacksonJsonProvider; //导入依赖的package包/类
protected WebTarget configClient() {
JacksonJsonProvider customRepresentationTypeProvider = new CustomRepresentationTypeProvider()
.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
rootTarget = client.target(configuration.getJasperReportsServerUrl());
rootTarget
.register(customRepresentationTypeProvider)
.register(JacksonFeature.class)
.register(MultiPartWriter.class);
if (sessionId != null) {
rootTarget.register(new SessionOutputFilter(sessionId));
}
if (configuration.getLogHttp()) {
rootTarget.register(initLoggingFilter());
}
return rootTarget;
}
示例2: should_return_client_with_configuration
import org.codehaus.jackson.jaxrs.JacksonJsonProvider; //导入依赖的package包/类
@Test
public void should_return_client_with_configuration() throws Exception {
// Given
suppress(method(SessionStorage.class, "init"));
doReturn("http").when(configurationMock).getJasperReportsServerUrl();
SessionStorage sessionStorage = Mockito.spy(new SessionStorage(configurationMock, credentialsMock, null, null));
Whitebox.setInternalState(sessionStorage, "client", clientMock);
Whitebox.setInternalState(sessionStorage, "sessionId", "sessionId");
doReturn(targetMock).when(clientMock).target(anyString());
doReturn(targetMock).when(targetMock).register(JacksonFeature.class);
doReturn(targetMock).when(targetMock).register(MultiPartWriter.class);
doReturn(targetMock).when(targetMock).register(any(JacksonJsonProvider.class));
doReturn(targetMock).when(targetMock).register(any(SessionOutputFilter.class));
doReturn(true).when(configurationMock).getLogHttp();
doReturn(targetMock).when(targetMock).register(any(LoggingFilter.class));
when(sessionStorage.getConfiguredClient()).thenReturn(targetMock);
// When
// When
WebTarget configuredClient = sessionStorage.getConfiguredClient();
// Then
assertEquals(configuredClient, targetMock);
}
示例3: OpenStackProviderFactory
import org.codehaus.jackson.jaxrs.JacksonJsonProvider; //导入依赖的package包/类
public OpenStackProviderFactory() {
super();
addContextResolver(new ContextResolver<ObjectMapper>() {
public ObjectMapper getContext(Class<?> type) {
return type.getAnnotation(JsonRootName.class) == null ? DEFAULT_MAPPER : WRAPPED_MAPPER;
}
});
jsonProvider = new JacksonJsonProvider();
addMessageBodyReader(jsonProvider);
addMessageBodyWriter(jsonProvider);
streamProvider = new InputStreamProvider();
addMessageBodyReader(streamProvider);
addMessageBodyWriter(streamProvider);
}
示例4: AbstractClient
import org.codehaus.jackson.jaxrs.JacksonJsonProvider; //导入依赖的package包/类
/**
* @param apiKey your Asana API key
* @param connectionTimeout the connection timeout in MILLISECONDS
* @param readTimeout the read timeout in MILLISECONDS
*/
public AbstractClient(String apiKey, int connectionTimeout, int readTimeout){
this.apiKey = apiKey;
ClientConfig config = new DefaultClientConfig();
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE, true);
mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JacksonJsonProvider provider = new JacksonJsonProvider(mapper);
config.getSingletons().add(provider);
//config.getClasses().add(JacksonJsonProvider.class);
Client client = Client.create(config);
client.addFilter(new HTTPBasicAuthFilter(apiKey, ""));
client.setConnectTimeout(connectionTimeout);
client.setReadTimeout(readTimeout);
service = client.resource(UriBuilder.fromUri(BASE_URL).build());
}
示例5: addingService
import org.codehaus.jackson.jaxrs.JacksonJsonProvider; //导入依赖的package包/类
@Override
public Object addingService(ServiceReference serviceReference) {
final Object trackedService = context.getService(serviceReference);
if (trackedService instanceof EntityService) {
final EntityServiceRest restApi = new EntityServiceRest();
restApi.setEntityService((EntityService) trackedService);
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
sf.setResourceClasses(restApi.getClass());
sf.setResourceProvider(restApi.getClass(), new SingletonResourceProvider(restApi));
sf.setAddress("/entity");
sf.setProvider(new JacksonJsonProvider());
server = sf.create();
}
return trackedService;
}
示例6: configureServlets
import org.codehaus.jackson.jaxrs.JacksonJsonProvider; //导入依赖的package包/类
@Override
protected void configureServlets() {
bind(BuildInfo.class).toInstance(buildInfo);
bind(ServerConfig.class).toInstance(serverConfig);
// For metrics
bind(InstrumentedResourceMethodDispatchAdapter.class).in(Singleton.class);
install(new SecurityModule(servletContext));
install(new PersistenceModule(serverConfig.getDbConfig(), ""));
install(new MailModule(serverConfig.getMailConfig()));
LOG.debug("Configuring servlets and URLs");
filter("/*").through(PersistFilter.class);
filter("/*").through(GuiceShiroFilter.class);
bind(Provisioner.class).in(Scopes.SINGLETON);
bind(JacksonJsonProvider.class).in(Scopes.SINGLETON);
final Map<String, String> params = Maps.newHashMap();
params.put("com.sun.jersey.config.property.packages", "nl.tudelft.ewi.dea.jaxrs");
params.put(ServletContainer.PROPERTY_WEB_PAGE_CONTENT_REGEX, "/.*\\.(html|js|gif|png|jpg|jpeg|css|ico)");
filter("/*").through(GuiceContainer.class, params);
}
示例7: getInjector
import org.codehaus.jackson.jaxrs.JacksonJsonProvider; //导入依赖的package包/类
@Override
protected Injector getInjector() {
return Guice.createInjector(new ServletModule() {
@Override
protected void configureServlets() {
super.configureServlets();
// Configuring Jersey via Guice:
ResourceConfig resourceConfig = new PackagesResourceConfig("ngdemo/web");
for (Class<?> resource : resourceConfig.getClasses()) {
bind(resource);
}
// hook Jackson into Jersey as the POJO <-> JSON mapper
bind(JacksonJsonProvider.class).in(Scopes.SINGLETON);
serve("/web/*").with(GuiceContainer.class);
filter("/web/*").through(ResponseCorsFilter.class);
}
}, new UserModule());
}
示例8: createServer
import org.codehaus.jackson.jaxrs.JacksonJsonProvider; //导入依赖的package包/类
public void createServer() throws IOException {
System.out.println("Starting grizzly...");
Injector injector = Guice.createInjector(new ServletModule() {
@Override
protected void configureServlets() {
bind(UserService.class).to(UserServiceImpl.class);
bind(UserRepository.class).to(UserMockRepositoryImpl.class);
bind(DummyService.class).to(DummyServiceImpl.class);
bind(DummyRepository.class).to(DummyMockRepositoryImpl.class);
// hook Jackson into Jersey as the POJO <-> JSON mapper
bind(JacksonJsonProvider.class).in(Scopes.SINGLETON);
}
});
ResourceConfig rc = new PackagesResourceConfig("ngdemo.web");
IoCComponentProviderFactory ioc = new GuiceComponentProviderFactory(rc, injector);
server = GrizzlyServerFactory.createHttpServer(BASE_URI + "web/", rc, ioc);
System.out.println(String.format("Jersey app started with WADL available at "
+ "%srest/application.wadl\nTry out %sngdemo\nHit enter to stop it...",
BASE_URI, BASE_URI));
}
示例9: newApiClient
import org.codehaus.jackson.jaxrs.JacksonJsonProvider; //导入依赖的package包/类
/**
* @return a new jersey client using a multithreaded http client
*/
public WebResource newApiClient() {
ClientConfig cc = new DefaultClientConfig();
cc.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, true);
cc.getProperties().put(ClientConfig.PROPERTY_READ_TIMEOUT, timeout);
cc.getProperties().put(ClientConfig.PROPERTY_CONNECT_TIMEOUT, timeout);
cc.getClasses().add(JacksonJsonProvider.class);
// use custom configured object mapper ignoring unknown properties
cc.getClasses().add(ObjectMapperContextResolver.class);
HttpClient http = HttpUtil.newMultithreadedClient(timeout, maxConnections, maxConnections);
ApacheHttpClient4Handler hch = new ApacheHttpClient4Handler(http, null, false);
Client client = new ApacheHttpClient4(hch, cc);
LOG.info("Connecting to GBIF API: {}", url);
return client.resource(url);
}
示例10: getClasses
import org.codehaus.jackson.jaxrs.JacksonJsonProvider; //导入依赖的package包/类
@Override
public Set<Class<?>> getClasses() {
Set<Class<?>> resources = new HashSet<>();
// following code to customize Jersey 1.x JSON provider:
resources.add(JacksonJsonProvider.class);
addRestResourceClasses(resources);
return resources;
}
示例11: AuthenticationRestClient
import org.codehaus.jackson.jaxrs.JacksonJsonProvider; //导入依赖的package包/类
public AuthenticationRestClient(String uri)
{
ClientConfig config = new DefaultClientConfig();
config.getClasses().add(JacksonJsonProvider.class);
client = Client.create(config);
webResource = client.resource(uri);
}
示例12: OrganisationRestClient
import org.codehaus.jackson.jaxrs.JacksonJsonProvider; //导入依赖的package包/类
public OrganisationRestClient(String uri)
{
ClientConfig config = new DefaultClientConfig();
config.getClasses().add(JacksonJsonProvider.class);
client = Client.create(config);
webResource = client.resource(uri).path("organisations");
endpointWebResource = client.resource(uri).path("endpoint");
channelWebResource = client.resource(uri).path("channel");
contactWebResource = client.resource(uri).path("endpointcontact");
}
示例13: PersonRestClient
import org.codehaus.jackson.jaxrs.JacksonJsonProvider; //导入依赖的package包/类
/**
* Creates a new instance.
*
* @param uri the REST service URI prefix
*/
public PersonRestClient(String uri)
{
ClientConfig config = new DefaultClientConfig();
config.getClasses().add(JacksonJsonProvider.class);
client = Client.create(config);
webResource = client.resource(uri).path("persons");
}
示例14: getClasses
import org.codehaus.jackson.jaxrs.JacksonJsonProvider; //导入依赖的package包/类
@Override
public Set<Class<?>> getClasses()
{
Set<Class<?>> resources = new HashSet<>();
// following code to customize Jersey 1.x JSON provider:
resources.add(JacksonJsonProvider.class);
addRestResourceClasses(resources);
return resources;
}
示例15: InformationRestClient
import org.codehaus.jackson.jaxrs.JacksonJsonProvider; //导入依赖的package包/类
/**
* Creates a new instance.
*
* @param uri the REST Service end-point URI. For example:
* http://localhost:8080/usm-information/rest/
*/
public InformationRestClient(String uri)
{
ClientConfig config = new DefaultClientConfig();
config.getClasses().add(JacksonJsonProvider.class);
client = Client.create(config);
webResource = client.resource(uri);
}