本文整理匯總了Java中com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider類的典型用法代碼示例。如果您正苦於以下問題:Java JacksonJsonProvider類的具體用法?Java JacksonJsonProvider怎麽用?Java JacksonJsonProvider使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
JacksonJsonProvider類屬於com.fasterxml.jackson.jaxrs.json包,在下文中一共展示了JacksonJsonProvider類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: ParaClient
import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; //導入依賴的package包/類
/**
* Default constructor.
* @param accessKey app access key
* @param secretKey app secret key
*/
public ParaClient(String accessKey, String secretKey) {
this.accessKey = accessKey;
this.secretKey = secretKey;
if (StringUtils.length(secretKey) < 6) {
logger.warn("Secret key appears to be invalid. Make sure you call 'signIn()' first.");
}
ClientConfig clientConfig = new ClientConfig();
clientConfig.register(GenericExceptionMapper.class);
clientConfig.register(new JacksonJsonProvider(ParaObjectUtils.getJsonMapper()));
clientConfig.connectorProvider(new HttpUrlConnectorProvider().useSetMethodWorkaround());
SSLContext sslContext = SslConfigurator.newInstance().securityProtocol("TLSv1").createSSLContext();
System.setProperty("https.protocols", "TLSv1");
apiClient = ClientBuilder.newBuilder().
sslContext(sslContext).
withConfig(clientConfig).build();
}
示例2: JerseyApplication
import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; //導入依賴的package包/類
@Inject
public JerseyApplication(ServiceLocator serviceLocator) {
GuiceBridge.getGuiceBridge().initializeGuiceBridge(serviceLocator);
GuiceIntoHK2Bridge guiceBridge = serviceLocator.getService(GuiceIntoHK2Bridge.class);
guiceBridge.bridgeGuiceInjector(AppLoader.injector);
String disableMoxy = PropertiesHelper.getPropertyNameForRuntime(
CommonProperties.MOXY_JSON_FEATURE_DISABLE,
getConfiguration().getRuntimeType());
property(disableMoxy, true);
property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true);
// add the default Jackson exception mappers
register(JsonParseExceptionMapper.class);
register(JsonMappingExceptionMapper.class);
register(JacksonJsonProvider.class, MessageBodyReader.class, MessageBodyWriter.class);
packages(JerseyApplication.class.getPackage().getName());
for (JerseyConfigurator configurator: AppLoader.getExtensions(JerseyConfigurator.class)) {
configurator.configure(this);
}
}
示例3: rebuildHttpClient
import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; //導入依賴的package包/類
/**
* Build the Client used to make HTTP requests with the latest settings,
* i.e. objectMapper and debugging.
* TODO: better to use the Builder Pattern?
*/
public ApiClient rebuildHttpClient() {
// Add the JSON serialization support to Jersey
JacksonJsonProvider jsonProvider = new JacksonJsonProvider(objectMapper);
DefaultClientConfig conf = new DefaultClientConfig();
conf.getSingletons().add(jsonProvider);
Client client = Client.create(conf);
if (debugging) {
client.addFilter(new LoggingFilter());
}
//to solve the issue of GET:metadata/:guid with accepted encodeing is 'gzip'
//in the past, when clients use gzip header, actually it doesn't trigger a gzip encoding... So everything is fine
//After the release, the content is return in gzip, while the sdk doesn't handle it correctly
client.addFilter(new GZIPContentEncodingFilter(false));
this.httpClient = client;
return this;
}
示例4: getSingletons
import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; //導入依賴的package包/類
@Override
public Set<Object> getSingletons() {
Swagger2Feature swagger = new Swagger2Feature();
swagger.setBasePath("/");
swagger.setHost("localhost:9000");
swagger.setTitle("Order Service");
swagger.setDescription("Rider Auto Parts Order Service");
swagger.setVersion("2.0.0");
swagger.setContact("[email protected]");
swagger.setPrettyPrint(true);
Set<Object> answer = new HashSet<>();
answer.add(orderService);
answer.add(new JacksonJsonProvider());
answer.add(swagger);
// to turn on verbose logging
answer.add(new LoggingFeature());
return answer;
}
示例5: BaseApplicaionConfig
import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; //導入依賴的package包/類
public BaseApplicaionConfig() {
//設置默認時區
System.setProperty("user.timezone", "Asia/Shanghai");
register(ValidationContextResolver.class);
property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true);
property(ServerProperties.BV_DISABLE_VALIDATE_ON_EXECUTABLE_OVERRIDE_CHECK, true);
this.packages(packages());
register(ObjectMapperResolver.class);
register(JacksonFeature.class);
register(JacksonJsonProvider.class);
register(new BaseExceptionMapper(createExcetionWrapper()));
register(RequestContextFilter.class);
register(DefaultWebFilter.class);
if (FilterConfig.apiDocEnabled()) {
register(SwaggerSerializers.class);
}
}
示例6: configureMessage
import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; //導入依賴的package包/類
@Test
public void configureMessage() throws IllegalArgumentException, IllegalAccessException {
final ServerProviderFactory instance = ServerProviderFactory.getInstance();
@SuppressWarnings("unchecked")
final List<ProviderInfo<ExceptionMapper<?>>> object = (List<ProviderInfo<ExceptionMapper<?>>>) FieldUtils
.getField(ServerProviderFactory.class, "exceptionMappers", true).get(instance);
final FailSafeExceptionMapper provider = new FailSafeExceptionMapper();
object.add(new ProviderInfo<>(provider, null, true));
final JacksonJsonProvider jacksonJsonProvider = new JacksonJsonProvider();
FieldUtils.getField(FailSafeExceptionMapper.class, "jacksonJsonProvider", true).set(provider, jacksonJsonProvider);
final UserImportEntry entry = Mockito.mock(UserImportEntry.class);
Mockito.when(entry.getId()).thenThrow(new RuntimeException());
final BatchTaskVo<UserImportEntry> importTask = new BatchTaskVo<>();
importTask.setEntries(Collections.singletonList(entry));
task.configure(importTask);
task.jaxrsFactory = instance;
task.run();
Assert.assertEquals(Boolean.TRUE, importTask.getStatus().getStatus());
Assert.assertEquals(1, importTask.getStatus().getDone());
Assert.assertEquals(1, importTask.getStatus().getEntries());
}
示例7: getSingletons
import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; //導入依賴的package包/類
@Override
public Set<Object> getSingletons() {
if (!preloaded) {
preloaded = true;
forgeInitialiser.preloadCommands(commandsResource);
}
return new HashSet<Object>(
Arrays.asList(
rootResource,
commandsResource,
repositoriesResource,
new JacksonJsonProvider(),
new CamelCatalogRest()
/*
new SwaggerFeature(),
new EnableJMXFeature(),
*/
)
);
}
示例8: BaseApplicaionConfig
import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; //導入依賴的package包/類
public BaseApplicaionConfig() {
//設置默認時區
System.setProperty("user.timezone","Asia/Shanghai");
register(ValidationContextResolver.class);
property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true);
property(ServerProperties.BV_DISABLE_VALIDATE_ON_EXECUTABLE_OVERRIDE_CHECK, true);
this.packages(packages());
register(ObjectMapperResolver.class);
register(JacksonFeature.class);
register(JacksonJsonProvider.class);
register(new BaseExceptionMapper(createExcetionWrapper()));
register(RequestContextFilter.class);
register(DefaultWebFilter.class);
//
if(FilterConfig.apiDocEnabled()){
register(SwaggerSerializers.class);
}
}
示例9: jaxRsServer
import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; //導入依賴的package包/類
@Bean
@DependsOn("cxf")
public Server jaxRsServer() {
JAXRSServerFactoryBean serverFactory = RuntimeDelegate.getInstance().createEndpoint(jaxRsApiApplication(), JAXRSServerFactoryBean.class);
//factory.setServiceBean(new DenialCategoryRest());
// get all the class annotated with @JaxrsService
List<Object> beans = configUtil.findBeans( JaxrsService.class );
if (beans.size() > 0) {
// add all the CXF service classes into the CXF stack
serverFactory.setServiceBeans( beans );
serverFactory.setAddress("/"+ serverFactory.getAddress());
serverFactory.setBus(springBus);
serverFactory.setStart(true);
// set JSON as the response serializer
JacksonJsonProvider provider = new JacksonJsonProvider();
serverFactory.setProvider(provider);
}
return serverFactory.create();
}
示例10: setup
import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; //導入依賴的package包/類
@Before
public void setup() {
catalog = new CamelCatalogRest();
port = AvailablePortFinder.getNextAvailable(9000);
// setup Apache CXF REST server
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
sf.setResourceClasses(CamelCatalogRest.class);
sf.setResourceProvider(CamelCatalogRest.class, new SingletonResourceProvider(catalog));
// to use jackson for json
sf.setProvider(JacksonJsonProvider.class);
sf.setAddress("http://localhost:" + port);
// create and start the CXF server (non blocking)
server = sf.create();
server.start();
}
示例11: testCalendarIdParameterEncoding
import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; //導入依賴的package包/類
@Test
public void testCalendarIdParameterEncoding() {
// test data
final Client client = ClientBuilder.newBuilder().register(JacksonJsonProvider.class).build();
final WebTarget eventsTarget = client.target("https://api.cronofy.com/")
.path("v1")
.path("events");
// expectations
final WebTarget noCalendars = eventsTarget.queryParam("calendar_ids[]", null);
final WebTarget emptyCalendars = eventsTarget.queryParam("calendar_ids[]", new String[]{});
final WebTarget twoCalendars1 = eventsTarget.queryParam("calendar_ids[]", new String[]{"a", "b"});
final WebTarget twoCalendars2 = eventsTarget.queryParam("calendar_ids[]", "a", "b");
// test scenario
assertEquals("https://api.cronofy.com/v1/events", noCalendars.getUri().toString());
assertEquals("https://api.cronofy.com/v1/events", emptyCalendars.getUri().toString());
assertEquals("https://api.cronofy.com/v1/events?calendar_ids%5B%5D=a&calendar_ids%5B%5D=b", twoCalendars1.getUri().toString());
assertEquals("https://api.cronofy.com/v1/events?calendar_ids%5B%5D=a&calendar_ids%5B%5D=b", twoCalendars2.getUri().toString());
}
示例12: getWebTarget
import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; //導入依賴的package包/類
private WebTarget getWebTarget() {
if (client == null) {
client = ClientBuilder.newClient();
client.register(JacksonJsonProvider.class);
// register the basic authentication filter if authentication information is provided
if (authenticationToken != null) {
client.register(new ClientRequestFilter() {
@Override
public void filter(ClientRequestContext requestContext) throws IOException {
requestContext.getHeaders().add("Authorization", "Basic " + authenticationToken);
}
});
}
}
WebTarget target = client.target(targetUrl);
return target;
}
示例13: configure
import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; //導入依賴的package包/類
@Override
protected Application configure() {
final ResourceConfig application =
new ResourceConfig(TestWebserviceWithPath.class, TestWebserviceWithPutDelete.class,
TestWebserviceMultipart.class, TestWebserviceExceptionHandling.class,
JacksonJsonProvider.class);
final Injector injector =
Guice.createInjector(new ClientModule(), new ExceptionObjectMapperModule());
// register multi part feature.
application.register(MultiPartFeature.class);
// register the application mapper.
application.register(injector.getInstance(TestExceptionMapper.class));
return application;
}
示例14: configure
import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; //導入依賴的package包/類
@Override
public void configure()
{
ApplicationBindingBuilder builder = bindApplication()
.matches("/api/*")
.addProvider(JacksonJsonProvider.class, JsonProviderProvider.class)
.addProvider(AuthRequestFilter.class)
.addProvider(CustomHeaderFilter.class)
.addProvider(AdminRestrictedFilter.class)
;
bindResources(builder);
bindAuthenticator();
bindExceptionhandlers(builder);
bindSecrets();
bindUiApplication();
}
示例15: getClasses
import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; //導入依賴的package包/類
@Override
public Set<Class<?>> getClasses() {
Set<Class<?>> classes = new HashSet<>();
classes.add(DeciserviceResource.class);
classes.add(NotesResource.class);
classes.add(BrowserNotesResource.class);
classes.add(JacksonJsonProvider.class);
classes.add(StaticContentFilter.class);
classes.add(Templater.class);
classes.add(FreemarkerTemplater.class);
classes.add(SanitizedNotesService.class);
classes.add(ExceptionMappers.class);
classes.add(ExceptionMappers.AppExceptionMapper.class);
classes.add(ExceptionMappers.NotFoundMapper.class);
return classes;
}