本文整理汇总了Java中com.fasterxml.jackson.jaxrs.base.JsonMappingExceptionMapper类的典型用法代码示例。如果您正苦于以下问题:Java JsonMappingExceptionMapper类的具体用法?Java JsonMappingExceptionMapper怎么用?Java JsonMappingExceptionMapper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JsonMappingExceptionMapper类属于com.fasterxml.jackson.jaxrs.base包,在下文中一共展示了JsonMappingExceptionMapper类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: JerseyApplication
import com.fasterxml.jackson.jaxrs.base.JsonMappingExceptionMapper; //导入依赖的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);
}
}
示例2: backstopperOnlyExceptionMapperFactory_removes_all_exception_mappers_except_Jersey2ApiExceptionHandler
import com.fasterxml.jackson.jaxrs.base.JsonMappingExceptionMapper; //导入依赖的package包/类
@Test
public void backstopperOnlyExceptionMapperFactory_removes_all_exception_mappers_except_Jersey2ApiExceptionHandler()
throws NoSuchFieldException, IllegalAccessException {
// given
AbstractBinder lotsOfExceptionMappersBinder = new AbstractBinder() {
@Override
protected void configure() {
bind(JsonMappingExceptionMapper.class).to(ExceptionMapper.class).in(Singleton.class);
bind(JsonParseExceptionMapper.class).to(ExceptionMapper.class).in(Singleton.class);
bind(generateJerseyApiExceptionHandler(projectApiErrors, utils)).to(ExceptionMapper.class);
}
};
ServiceLocator locator = ServiceLocatorUtilities.bind(lotsOfExceptionMappersBinder);
// when
BackstopperOnlyExceptionMapperFactory overrideExceptionMapper = new BackstopperOnlyExceptionMapperFactory(locator);
// then
Set<Object> emTypesLeft = overrideExceptionMapper.getFieldObj(
ExceptionMapperFactory.class, overrideExceptionMapper, "exceptionMapperTypes"
);
assertThat(emTypesLeft).hasSize(1);
ServiceHandle serviceHandle = overrideExceptionMapper.getFieldObj(emTypesLeft.iterator().next(), "mapper");
assertThat(serviceHandle.getService()).isInstanceOf(Jersey2ApiExceptionHandler.class);
}
示例3: DrillRestServer
import com.fasterxml.jackson.jaxrs.base.JsonMappingExceptionMapper; //导入依赖的package包/类
public DrillRestServer(final WorkManager workManager) {
register(DrillRoot.class);
register(StatusResources.class);
register(StorageResources.class);
register(ProfileResources.class);
register(QueryResources.class);
register(MetricsResources.class);
register(ThreadsResources.class);
register(FreemarkerMvcFeature.class);
register(MultiPartFeature.class);
property(ServerProperties.METAINF_SERVICES_LOOKUP_DISABLE, true);
//disable moxy so it doesn't conflict with jackson.
final String disableMoxy = PropertiesHelper.getPropertyNameForRuntime(CommonProperties.MOXY_JSON_FEATURE_DISABLE, getConfiguration().getRuntimeType());
property(disableMoxy, true);
register(JsonParseExceptionMapper.class);
register(JsonMappingExceptionMapper.class);
register(GenericExceptionMapper.class);
JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
provider.setMapper(workManager.getContext().getConfig().getMapper());
register(provider);
register(new AbstractBinder() {
@Override
protected void configure() {
bind(workManager).to(WorkManager.class);
bind(workManager.getContext().getConfig().getMapper()).to(ObjectMapper.class);
bind(workManager.getContext().getPersistentStoreProvider()).to(PStoreProvider.class);
bind(workManager.getContext().getStorage()).to(StoragePluginRegistry.class);
}
});
}
示例4: configure
import com.fasterxml.jackson.jaxrs.base.JsonMappingExceptionMapper; //导入依赖的package包/类
public boolean configure(FeatureContext context) {
context.property("jersey.config.server.disableMoxyJson", Boolean.valueOf(true));
Configuration config = context.getConfiguration();
context.property(getPropertyNameForRuntime("jersey.config.jsonFeature", config.getRuntimeType()), JSON_FEATURE);
if (!config.isRegistered(JacksonJaxbJsonProvider.class)) {
context.register(JsonParseExceptionMapper.class);
context.register(JsonMappingExceptionMapper.class);
context.register(JacksonJaxbJsonProvider.class, new Class[]{MessageBodyReader.class, MessageBodyWriter.class});
}
return true;
}
示例5: configure
import com.fasterxml.jackson.jaxrs.base.JsonMappingExceptionMapper; //导入依赖的package包/类
@Override
public boolean configure(FeatureContext context) {
final Configuration config = context.getConfiguration();
context.property("jersey.config." + config.getRuntimeType().toString().toLowerCase(Locale.ENGLISH) + ".jsonFeature", "JacksonFeature");
context.register(JsonParseExceptionMapper.class, Priorities.ENTITY_CODER);
context.register(JsonMappingExceptionMapper.class, Priorities.ENTITY_CODER);
context.register(JacksonJsonProviderForJsonMediaType.class, Priorities.ENTITY_CODER);
return true;
}
示例6: init
import com.fasterxml.jackson.jaxrs.base.JsonMappingExceptionMapper; //导入依赖的package包/类
protected void init(ScanResult result) {
// FILTERS
register(JSONPrettyPrintFilter.class);
register(MediaTypeFilter.class);
// RESOURCES
for (Class<?> resource : result.getAnnotatedClasses(APIResource.class)) {
register(resource);
}
// FEATURES
register(DACAuthFilterFeature.class);
register(DACJacksonJaxbJsonFeature.class);
register(DACExceptionMapperFeature.class);
// EXCEPTION MAPPERS
register(JsonParseExceptionMapper.class);
register(JsonMappingExceptionMapper.class);
// PROPERTIES
property(ServerProperties.METAINF_SERVICES_LOOKUP_DISABLE, true);
property(ServerProperties.RESPONSE_SET_STATUS_OVER_SEND_ERROR, "true");
final String disableMoxy = PropertiesHelper.getPropertyNameForRuntime(CommonProperties.MOXY_JSON_FEATURE_DISABLE,
getConfiguration().getRuntimeType());
property(disableMoxy, true);
}
示例7: configure
import com.fasterxml.jackson.jaxrs.base.JsonMappingExceptionMapper; //导入依赖的package包/类
@Override
public boolean configure(FeatureContext context) {
final String disableMoxy = CommonProperties.MOXY_JSON_FEATURE_DISABLE + '.'
+ context.getConfiguration().getRuntimeType().name().toLowerCase();
context.property(disableMoxy, true);
// add the default Jackson exception mappers
context.register(JsonParseExceptionMapper.class);
context.register(JsonMappingExceptionMapper.class);
context.register(JacksonProvider.class, MessageBodyReader.class, MessageBodyWriter.class);
return true;
}
示例8: buildClient
import com.fasterxml.jackson.jaxrs.base.JsonMappingExceptionMapper; //导入依赖的package包/类
private static Client buildClient(ClientConfiguration clientConfiguration) {
ClientConfig clientConfig = new ClientConfig();
clientConfig
.register(JsonMappingExceptionMapper.class)
.register(JsonParseExceptionMapper.class)
.register(JacksonJaxbJsonProvider.class, new Class[]{MessageBodyReader.class, MessageBodyWriter.class})
.register(RequestBodyLogger.class)
.register(HttpAuthenticationFeature.basic(clientConfiguration.getUsername(), clientConfiguration.getPassword()))
;
if (clientConfiguration.isEnableBatchCompression()) {
clientConfig.register(GZipWriterInterceptor.class);
}
if (log.isDebugEnabled()) {
clientConfig.register(new LoggingFilter(legacyLogger, true));
}
configureHttps(clientConfiguration, clientConfig);
clientConfig.connectorProvider(new ApacheConnectorProvider());
Client builtClient = ClientBuilder.newBuilder().withConfig(clientConfig).build();
builtClient.property(ClientProperties.CONNECT_TIMEOUT, clientConfiguration.getConnectTimeoutMillis());
builtClient.property(ClientProperties.READ_TIMEOUT, clientConfiguration.getReadTimeoutMillis());
return builtClient;
}
示例9: init
import com.fasterxml.jackson.jaxrs.base.JsonMappingExceptionMapper; //导入依赖的package包/类
protected void init(ScanResult result) {
// FILTERS //
register(JSONPrettyPrintFilter.class);
register(MediaTypeFilter.class);
// RESOURCES //
for (Class<?> resource : result.getAnnotatedClasses(RestResource.class)) {
register(resource);
}
// FEATURES
property(FreemarkerMvcFeature.TEMPLATE_OBJECT_FACTORY, getFreemarkerConfiguration());
register(FreemarkerMvcFeature.class);
register(MultiPartFeature.class);
register(FirstTimeFeature.class);
register(DACAuthFilterFeature.class);
register(DACExceptionMapperFeature.class);
register(DACJacksonJaxbJsonFeature.class);
register(TestResourcesFeature.class);
// LISTENERS //
register(TimingApplicationEventListener.class);
// EXCEPTION MAPPERS //
register(JsonParseExceptionMapper.class);
register(JsonMappingExceptionMapper.class);
// BODY WRITERS //
register(QlikAppMessageBodyGenerator.class);
register(TableauMessageBodyGenerator.class);
// PROPERTIES //
property(ServerProperties.METAINF_SERVICES_LOOKUP_DISABLE, true);
property(ServerProperties.RESPONSE_SET_STATUS_OVER_SEND_ERROR, "true");
final String disableMoxy = PropertiesHelper.getPropertyNameForRuntime(CommonProperties.MOXY_JSON_FEATURE_DISABLE,
getConfiguration().getRuntimeType());
property(disableMoxy, true);
property(TableauMessageBodyGenerator.CUSTOMIZATION_ENABLED, false);
}
示例10: DrillRestServer
import com.fasterxml.jackson.jaxrs.base.JsonMappingExceptionMapper; //导入依赖的package包/类
public DrillRestServer(final WorkManager workManager, final ServletContext servletContext, final Drillbit drillbit) {
register(DrillRoot.class);
register(StatusResources.class);
register(StorageResources.class);
register(ProfileResources.class);
register(QueryResources.class);
register(MetricsResources.class);
register(ThreadsResources.class);
register(LogsResources.class);
property(FreemarkerMvcFeature.TEMPLATE_OBJECT_FACTORY, getFreemarkerConfiguration(servletContext));
register(FreemarkerMvcFeature.class);
register(MultiPartFeature.class);
property(ServerProperties.METAINF_SERVICES_LOOKUP_DISABLE, true);
final boolean isAuthEnabled =
workManager.getContext().getConfig().getBoolean(ExecConstants.USER_AUTHENTICATION_ENABLED);
if (isAuthEnabled) {
register(LogInLogOutResources.class);
register(AuthDynamicFeature.class);
register(RolesAllowedDynamicFeature.class);
}
//disable moxy so it doesn't conflict with jackson.
final String disableMoxy = PropertiesHelper.getPropertyNameForRuntime(CommonProperties.MOXY_JSON_FEATURE_DISABLE,
getConfiguration().getRuntimeType());
property(disableMoxy, true);
register(JsonParseExceptionMapper.class);
register(JsonMappingExceptionMapper.class);
register(GenericExceptionMapper.class);
JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
provider.setMapper(workManager.getContext().getLpPersistence().getMapper());
register(provider);
// Get an EventExecutor out of the BitServer EventLoopGroup to notify listeners for WebUserConnection. For
// actual connections between Drillbits this EventLoopGroup is used to handle network related events. Though
// there is no actual network connection associated with WebUserConnection but we need a CloseFuture in
// WebSessionResources, so we are using EvenExecutor from network EventLoopGroup pool.
final EventExecutor executor = workManager.getContext().getBitLoopGroup().next();
register(new AbstractBinder() {
@Override
protected void configure() {
bind(drillbit).to(Drillbit.class);
bind(workManager).to(WorkManager.class);
bind(executor).to(EventExecutor.class);
bind(workManager.getContext().getLpPersistence().getMapper()).to(ObjectMapper.class);
bind(workManager.getContext().getStoreProvider()).to(PersistentStoreProvider.class);
bind(workManager.getContext().getStorage()).to(StoragePluginRegistry.class);
bind(new UserAuthEnabled(isAuthEnabled)).to(UserAuthEnabled.class);
if (isAuthEnabled) {
bindFactory(DrillUserPrincipalProvider.class).to(DrillUserPrincipal.class);
bindFactory(AuthWebUserConnectionProvider.class).to(WebUserConnection.class);
} else {
bindFactory(AnonDrillUserPrincipalProvider.class).to(DrillUserPrincipal.class);
bindFactory(AnonWebUserConnectionProvider.class).to(WebUserConnection.class);
}
}
});
}