本文整理匯總了Java中org.glassfish.jersey.jackson.JacksonFeature類的典型用法代碼示例。如果您正苦於以下問題:Java JacksonFeature類的具體用法?Java JacksonFeature怎麽用?Java JacksonFeature使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
JacksonFeature類屬於org.glassfish.jersey.jackson包,在下文中一共展示了JacksonFeature類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: RadioBrowser
import org.glassfish.jersey.jackson.JacksonFeature; //導入依賴的package包/類
/** Custom constructor for mocked unit testing.
* @param apiUrl the base URL of the API.
* @param timeout the timeout in milliseconds for connecting
* and reading.
* @param myUserAgent the user agent string to use.
* */
RadioBrowser(final String apiUrl,
final int timeout,
final String myUserAgent) {
if (timeout <= 0) {
throw new IllegalArgumentException(
"timeout must be > 0, but is "
+ timeout);
}
this.userAgent = Objects.requireNonNull(myUserAgent,
"User agent is null");
Client client = ClientBuilder.newBuilder()
.register(JacksonFeature.class)
.build();
client.property(ClientProperties.CONNECT_TIMEOUT, timeout);
client.property(ClientProperties.READ_TIMEOUT, timeout);
webTarget = client.target(apiUrl);
}
示例2: initApi
import org.glassfish.jersey.jackson.JacksonFeature; //導入依賴的package包/類
private void initApi() {
ServletContextHandler servletHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);
servletHandler.setContextPath("/api");
servletHandler.getSessionHandler().setSessionManager(sessionManager);
servletHandler.addServlet(new ServletHolder(new AsyncSocketServlet()), "/socket");
ResourceConfig resourceConfig = new ResourceConfig();
resourceConfig.registerClasses(JacksonFeature.class, ObjectMapperProvider.class, ResourceErrorHandler.class);
resourceConfig.registerClasses(SecurityRequestFilter.class, CorsResponseFilter.class);
resourceConfig.packages(ServerResource.class.getPackage().getName());
servletHandler.addServlet(new ServletHolder(new ServletContainer(resourceConfig)), "/*");
handlers.addHandler(servletHandler);
}
示例3: startServer
import org.glassfish.jersey.jackson.JacksonFeature; //導入依賴的package包/類
public void startServer() throws TelegramApiException {
SSLContextConfigurator sslContext = new SSLContextConfigurator();
// set up security context
sslContext.setKeyStoreFile(KEYSTORE_SERVER_FILE); // contains server keypair
sslContext.setKeyStorePass(KEYSTORE_SERVER_PWD);
ResourceConfig rc = new ResourceConfig();
rc.register(restApi);
rc.register(JacksonFeature.class);
rc.property(JSONConfiguration.FEATURE_POJO_MAPPING, true);
final HttpServer grizzlyServer = GrizzlyHttpServerFactory.createHttpServer(
getBaseURI(),
rc,
true,
new SSLEngineConfigurator(sslContext).setClientMode(false).setNeedClientAuth(false));
try {
grizzlyServer.start();
} catch (IOException e) {
throw new TelegramApiException("Error starting webhook server", e);
}
}
示例4: start
import org.glassfish.jersey.jackson.JacksonFeature; //導入依賴的package包/類
void start() {
try {
Config config = core.getConfig();
String urlStr = config.getString("networking.rest-url");
ResourceConfig rc = new ResourceConfig();
rc.register(LoggingFilter.class);
rc.register(JacksonFeature.class);
rc.register(CatchAllExceptionMapper.class);
rc.register(SerializationExceptionMapper.class);
rc.register(AdminResourceImpl.class);
rc.register(new KBResourceImpl(core));
rc.register(new QueryResourceImpl(core));
httpServer = GrizzlyHttpServerFactory.createHttpServer(URI.create(urlStr), rc, true);
logger.info(marker, "Stargraph listening on {}", urlStr);
} catch (Exception e) {
throw new StarGraphException(e);
}
}
示例5: WechatMallApplication
import org.glassfish.jersey.jackson.JacksonFeature; //導入依賴的package包/類
public WechatMallApplication() {
String admin = "org.jiumao.wechatMall.admin.resource";
String mall = "org.jiumao.wechatMall.mall.resource";
String api = "org.jiumao.wechatMall.api.resource";
String user = "org.jiumao.wechatMall.user.resource";
packages(admin, mall, api, user);
register(RequestContextFilter.class);
register(JacksonFeature.class);
register(AppkeyServiceFeature.class);
register(AuthServiceFeature.class);
register(LoggingResponseFilter.class);
register(CORSResponseFilter.class);
}
示例6: TestApplication
import org.glassfish.jersey.jackson.JacksonFeature; //導入依賴的package包/類
public TestApplication(boolean querySpec, boolean jsonApiFilter, boolean serializeLinksAsObjects) {
property(CrnkProperties.RESOURCE_SEARCH_PACKAGE, "io.crnk.test.mock");
property(CrnkProperties.SERIALIZE_LINKS_AS_OBJECTS, Boolean.toString(serializeLinksAsObjects));
if (!querySpec) {
feature = new CrnkTestFeature(new ObjectMapper(), new QueryParamsBuilder(new DefaultQueryParamsParser()),
new SampleJsonServiceLocator());
}
else {
feature = new CrnkTestFeature(new ObjectMapper(), new DefaultQuerySpecDeserializer(),
new SampleJsonServiceLocator());
}
feature.addModule(new TestModule());
if (jsonApiFilter) {
register(new JsonApiResponseFilter(feature));
register(new JsonapiExceptionMapperBridge(feature));
register(new JacksonFeature());
}
setupFeature(feature);
register(feature);
}
示例7: getClasses
import org.glassfish.jersey.jackson.JacksonFeature; //導入依賴的package包/類
@Override
public Set<Class<?>> getClasses() {
Set<Class<?>> classes = new HashSet<>();
// Use Jackson for media types
classes.add(JacksonFeature.class);
// Register the service endpoint
classes.add(HelloService.class);
// Register the infrastructure endpoint
classes.add(HealthService.class);
// the Tracing filter
classes.add(TraceContainerFilter.class);
return classes;
}
示例8: getClasses
import org.glassfish.jersey.jackson.JacksonFeature; //導入依賴的package包/類
@Override
public Set<Class<?>> getClasses() {
Set<Class<?>> classes = new HashSet<>();
// Use Jackson for media types
classes.add(JacksonFeature.class);
// Register the service endpoint
classes.add(HelloService.class);
// Register the infrastructure endpoint
classes.add(HealthService.class);
// the Tracing filter is added in web.xml
return classes;
}
示例9: startServer
import org.glassfish.jersey.jackson.JacksonFeature; //導入依賴的package包/類
public void startServer() throws TelegramApiRequestException {
ResourceConfig rc = new ResourceConfig();
rc.register(restApi);
rc.register(JacksonFeature.class);
final HttpServer grizzlyServer;
if (keystoreServerFile != null && keystoreServerPwd != null) {
SSLContextConfigurator sslContext = new SSLContextConfigurator();
// set up security context
sslContext.setKeyStoreFile(keystoreServerFile); // contains server keypair
sslContext.setKeyStorePass(keystoreServerPwd);
grizzlyServer = GrizzlyHttpServerFactory.createHttpServer(getBaseURI(), rc, true,
new SSLEngineConfigurator(sslContext).setClientMode(false).setNeedClientAuth(false));
} else {
grizzlyServer = GrizzlyHttpServerFactory.createHttpServer(getBaseURI(), rc);
}
try {
grizzlyServer.start();
} catch (IOException e) {
throw new TelegramApiRequestException("Error starting webhook server", e);
}
}
示例10: Coreference
import org.glassfish.jersey.jackson.JacksonFeature; //導入依賴的package包/類
public Coreference(Config config) {
log.info("Will use remote coreference resource at: '{}'", config.getString("url"));
final Client webClient = ClientBuilder.newClient();
webClient.register(JacksonFeature.class);
this.textTarget = webClient
.target(config.getString("url"))
.path(config.getString("text-path"));
this.wikiTarget = webClient
.target(config.getString("url"))
.path(config.getString("wiki-path"));
this.wikiLinkTarget = webClient
.target(config.getString("url"))
.path(config.getString("wiki-link-path"));
log.info("Coreference initialized");
}
示例11: generateResourceConfig
import org.glassfish.jersey.jackson.JacksonFeature; //導入依賴的package包/類
static ResourceConfig generateResourceConfig(Config config, Graphene graphene) {
ResourceConfig rc = new ResourceConfig();
// settings
rc.property(ServerProperties.FEATURE_AUTO_DISCOVERY_DISABLE, true);
rc.property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true); // TODO: remove in production
// basic features
rc.register(CORSFilter.class);
rc.register(JacksonFeature.class);
rc.register(ValidationFeature.class);
// custom resources
GrapheneResourceFactory factory = new GrapheneResourceFactory(config, graphene);
rc.register(factory.createResource(AdminResource.class));
rc.register(factory.createResource(CoreferenceResource.class));
rc.register(factory.createResource(RelationExtractionResource.class));
return rc;
}
示例12: getRegistryClient
import org.glassfish.jersey.jackson.JacksonFeature; //導入依賴的package包/類
private RegistryEndpoints getRegistryClient(ImageRef imageRef) {
if (!proxyClients.containsKey(imageRef.getRegistryUrl())) {
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JavaTimeModule());
Client client = ClientBuilder.newClient()
.register(new JacksonJaxbJsonProvider(mapper, new Annotations[] {Annotations.JACKSON}))
.register(JacksonFeature.class);
String auth = config.getAuthFor(imageRef.getRegistryName());
if (auth != null) {
String[] credentials = new String(Base64.getDecoder().decode(auth), StandardCharsets.UTF_8).split(":");
client.register(HttpAuthenticationFeature.basicBuilder().credentials(credentials[0], credentials[1]));
}
WebTarget webTarget = client.target(imageRef.getRegistryUrl());
proxyClients.put(imageRef.getRegistryUrl(), WebResourceFactory.newResource(RegistryEndpoints.class, webTarget));
}
return proxyClients.get(imageRef.getRegistryUrl());
}
示例13: BaseApplicaionConfig
import org.glassfish.jersey.jackson.JacksonFeature; //導入依賴的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);
}
}
示例14: startServer
import org.glassfish.jersey.jackson.JacksonFeature; //導入依賴的package包/類
protected void startServer() {
WifiManager wifiMgr = (WifiManager) getApplicationContext()
.getSystemService(Service.WIFI_SERVICE);
if (wifiMgr.isWifiEnabled()) {
// Deprecated. Does not support ipv6. *shrug* :)
String ipAddress = Formatter.formatIpAddress(wifiMgr.getConnectionInfo()
.getIpAddress());
URI baseUri = UriBuilder.fromUri("http://" + ipAddress)
.port(49152)
.build();
ResourceConfig config = new ResourceConfig(SseFeature.class)
.register(JacksonFeature.class);
config.registerInstances(new SecureFilter(this));
config.registerInstances(new DeskDroidResource(this));
// server = JettyHttpContainerFactory.createServer(baseUri, config);
server = GrizzlyHttpServerFactory.createHttpServer(baseUri, config);
}
}
示例15: JbrickWSApplication
import org.glassfish.jersey.jackson.JacksonFeature; //導入依賴的package包/類
public JbrickWSApplication() {
// Registrazione del package contenente le risorse
packages("it.makeit.jbrick.ws.resources");
packages("it.makeit.profiler.ws.resources");
packages("it.makeit.jbrick.configdb.ws.resources");
packages("it.makeit.jbrick.scheduler.ws.resources");
packages("it.makeit.zefiro.ws.resources");
// Registrazione di jackson-media-provider e configurazione serializzatore
register(JacksonFeature.class);
register(JbrickJacksonConfigurator.class);
// Registrazione del listener delle eccezioni
register(ExceptionListener.class);
// Registrazione exception mapper
register(JbrickExceptionMapper.class);
// Registrazione Multipart Feature per upload file
register(MultiPartFeature.class);
// Registrazione filtri
register(AuthenticationFilter.class);
register(LogFilter.class);
}