当前位置: 首页>>代码示例>>Java>>正文


Java JacksonConverter类代码示例

本文整理汇总了Java中retrofit.converter.JacksonConverter的典型用法代码示例。如果您正苦于以下问题:Java JacksonConverter类的具体用法?Java JacksonConverter怎么用?Java JacksonConverter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JacksonConverter类属于retrofit.converter包,在下文中一共展示了JacksonConverter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getRestAdapter

import retrofit.converter.JacksonConverter; //导入依赖的package包/类
private RestAdapter getRestAdapter() {
	return new RestAdapter.Builder()
			.setEndpoint("http://localhost:8080")
			.setRequestInterceptor(new RequestInterceptor() {
				@Override
				public void intercept(RequestFacade request) {
					if (!authenticatedUser.isPresent()) return;
					String credentials = authenticatedUser.get().getEmail() + ":" + authenticatedUser.get().getPassword();
					String base64EncodedCredentials = Base64.encodeAsString(credentials.getBytes());
					request.addHeader("Authorization", "Basic " + base64EncodedCredentials);
				}
			})
			.setClient(new LongTimeoutUrlConnectionClient())
			.setConverter(new JacksonConverter())
			.build();
}
 
开发者ID:AMOS-2015,项目名称:amos-ss15-proj2,代码行数:17,代码来源:ApiFactory.java

示例2: sendEventUpdate

import retrofit.converter.JacksonConverter; //导入依赖的package包/类
@Override
public SenderResult sendEventUpdate(HttpClient client) {
	RestAdapter adapter = new RestAdapter.Builder()
			.setConverter(new JacksonConverter())
			.setEndpoint(client.getDeviceId())
			.build();
	NewDataCallbackService callbackService = adapter.create(NewDataCallbackService.class);

	EventData content = new EventData(client.getId());

	try {
		callbackService.onNewData(content);
		return getSuccessResult();
	} catch (RetrofitError re) {
		return getErrorResult(re);
	}
}
 
开发者ID:jvalue,项目名称:cep-service,代码行数:18,代码来源:HttpSender.java

示例3: fiatService

import retrofit.converter.JacksonConverter; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean(FiatService.class) // Allows for override
public FiatService fiatService(FiatClientConfigurationProperties fiatConfigurationProperties,
                               SpinnakerRequestInterceptor interceptor,
                               OkClient okClient) {
  // New role providers break deserialization if this is not enabled.
  val objectMapper = new ObjectMapper();
  objectMapper.enable(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL);
  objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
  return new RestAdapter.Builder()
      .setEndpoint(Endpoints.newFixedEndpoint(fiatConfigurationProperties.getBaseUrl()))
      .setRequestInterceptor(interceptor)
      .setClient(okClient)
      .setConverter(new JacksonConverter(objectMapper))
      .setLogLevel(retrofitLogLevel)
      .setLog(new Slf4jRetrofitLogger(FiatService.class))
      .build()
      .create(FiatService.class);
}
 
开发者ID:spinnaker,项目名称:fiat,代码行数:20,代码来源:FiatAuthenticationConfig.java

示例4: setUp

import retrofit.converter.JacksonConverter; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    appId = System.getenv("LEANPLUM_APP_ID");
    key = System.getenv("LEANPLUM_KEY");

    objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

    RestAdapter restAdapter = new RestAdapter.Builder()
            .setLogLevel(RestAdapter.LogLevel.FULL)
            .setEndpoint("https://www.leanplum.com")
            .setRequestInterceptor(
                    LeanplumInterceptor.createInterceptorWithUserId(appId, key, true, "[email protected]"))
            .setConverter(new JacksonConverter(objectMapper))
            .build();

    leanplumApi = restAdapter.create(LeanplumApi.class);
}
 
开发者ID:scopely,项目名称:leanplum-java-sdk,代码行数:18,代码来源:ProductionApiClientTest.java

示例5: createService

import retrofit.converter.JacksonConverter; //导入依赖的package包/类
public static <S> S createService(Class<S> serviceClass, String endpoint, final String token) {
    // set endpoint url and use OkHTTP as HTTP client
    RestAdapter.Builder builder = new RestAdapter.Builder()
            .setEndpoint(endpoint)
            .setConverter(new JacksonConverter())
            .setLogLevel(BuildConfig.DEBUG ? RestAdapter.LogLevel.FULL : RestAdapter.LogLevel.BASIC)
            .setClient(new OkClient(new OkHttpClient()));


    builder.setRequestInterceptor(new RequestInterceptor() {
        @Override
        public void intercept(RequestFacade request) {
            request.addHeader(Constants.HEADER_ACCEPT, "application/json");
            if (token != null) {
                request.addHeader(Constants.HEADER_TOKEN, token);
            }
        }
    });
    RestAdapter adapter = builder.build();
    return adapter.create(serviceClass);
}
 
开发者ID:ideable,项目名称:fiware-android-sdk,代码行数:22,代码来源:ServiceGenerator.java

示例6: configure

import retrofit.converter.JacksonConverter; //导入依赖的package包/类
@Override
protected void configure() {
    RestAdapter adapter = new RestAdapter.Builder()
            .setEndpoint("https://maps.googleapis.com/maps/api/place/")
            .setRequestInterceptor(new RequestInterceptor() {
                @Override
                public void intercept(RequestFacade request) {
                    request.addQueryParam("key", googleApiKey);
                    //request.addQueryParam("types", "bus_station|parking|train_station|store|gas_station");
                    request.addQueryParam("types", "accounting|airport|amusement_park|aquarium|art_gallery|atm|bakery|bank|bar|beauty_salon|bicycle_store|book_store|bowling_alley|bus_station|cafe|campground|car_dealer|car_rental|car_repair|car_wash|casino|cemetery|church|city_hall|clothing_store|convenience_store|courthouse|dentist|department_store|doctor|electrician|electronics_store|embassy|establishment|finance|fire_station|florist|food|funeral_home|furniture_store|gas_station|general_contractor|grocery_or_supermarket|gym|hair_care|hardware_store|health|hindu_temple|home_goods_store|hospital|insurance_agency|jewelry_store|laundry|lawyer|library|liquor_store|local_government_office|locksmith|lodging|meal_delivery|meal_takeaway|mosque|movie_rental|movie_theater|moving_company|museum|night_club|painter|park|parking|pet_store|pharmacy|physiotherapist|place_of_worship|plumber|police|post_office|real_estate_agency|restaurant|roofing_contractor|rv_park|school|shoe_store|shopping_mall|spa|stadium|storage|store|subway_station|synagogue|taxi_stand|train_station|travel_agency|university|veterinary_care|zoo");
                }
            })
            .setConverter(new JacksonConverter())
            .build();
    bind(PlacesApi.class).toInstance(adapter.create(PlacesApi.class));
}
 
开发者ID:AMOS-2015,项目名称:amos-ss15-proj2,代码行数:17,代码来源:PlacesModule.java

示例7: provideRestAdapter

import retrofit.converter.JacksonConverter; //导入依赖的package包/类
@Provides
@Singleton
RestAdapter provideRestAdapter(final OdsConfig odsConfig) {
	byte[] credentials = (odsConfig.getAdmin().getUsername() + ":" + odsConfig.getAdmin().getPassword()).getBytes();
	final String authHeader = "Basic " + BaseEncoding.base64().encode(credentials);

	return new RestAdapter.Builder()
			.setConverter(new JacksonConverter(new ObjectMapper()))
			.setEndpoint(odsConfig.getUrl())
			.setRequestInterceptor(new RequestInterceptor() {
				@Override
				public void intercept(RequestFacade request) {
					request.addHeader("Authorization", authHeader);
				}
			})
			.build();
}
 
开发者ID:jvalue,项目名称:cep-service,代码行数:18,代码来源:OdsModule.java

示例8: setup

import retrofit.converter.JacksonConverter; //导入依赖的package包/类
@Before
public void setup() {
	RestAdapter restAdapter = new RestAdapter.Builder()
			.setConverter(new JacksonConverter())
			.setEndpoint("http://localhost:8080/ods/api/v1")
			.setRequestInterceptor(new RequestInterceptor() {
				@Override
				public void intercept(RequestFacade request) {
					request.addHeader("Accept", "application/json");
					request.addHeader("Content-Type", "application/json");
					request.addHeader("Authorization", "Basic YWRtaW5AYWRtaW5sYW5kLmNvbTphZG1pbjEyMw=="); // [email protected] : admin123
				}
			})
			.build();

	dataSourceApi = restAdapter.create(DataSourceApi.class);
	notificationApi = restAdapter.create(NotificationApi.class);
}
 
开发者ID:jvalue,项目名称:open-data-service,代码行数:19,代码来源:AbstractApiTest.java

示例9: onNewDataComplete

import retrofit.converter.JacksonConverter; //导入依赖的package包/类
@Override
public void onNewDataComplete() {
	RestAdapter adapter = new RestAdapter.Builder()
			.setConverter(new JacksonConverter())
			.setEndpoint(client.getCallbackUrl())
			.build();
	NewDataCallbackService callbackService = adapter.create(NewDataCallbackService.class);

	NewData content;
	if (client.getSendData()) content = new NewData(source.getId(), buffer);
	else content = new NewData(source.getId(), null);

	try {
		callbackService.onNewData(content);
		buffer.removeAll();
		setSuccessResult();
	} catch (RetrofitError re) {
		setErrorResult(re);
	}
}
 
开发者ID:jvalue,项目名称:open-data-service,代码行数:21,代码来源:HttpSender.java

示例10: TDServiceImpl

import retrofit.converter.JacksonConverter; //导入依赖的package包/类
private TDServiceImpl() {
    RestAdapter.Builder builder = new RestAdapter.Builder()
            .setLog(this)
            .setLogLevel(BuildConfig.DEBUG ? RestAdapter.LogLevel.FULL : RestAdapter.LogLevel.NONE)
            .setConverter(new JacksonConverter());

    RestAdapter apiAdapter = builder
            .setEndpoint(TDConfig.URL_API_TWITCH_API_BASE)
            .build();
    RestAdapter usherAdapter = builder
            .setEndpoint(TDConfig.URL_API_USHER_BASE)
            .build();
    RestAdapter krakenAdapter = builder
            .setEndpoint(TDConfig.URL_API_TWITCH_KRAKEN_BASE)
            .setRequestInterceptor(new KrakenRequestInterceptor())
            .build();

    twitchAPI = apiAdapter.create(TwitchAPI.class);
    twitchUsher = usherAdapter.create(TwitchUsher.class);
    twitchKraken = krakenAdapter.create(TwitchKraken.class);
}
 
开发者ID:CiTuX,项目名称:TD,代码行数:22,代码来源:TDServiceImpl.java

示例11: get

import retrofit.converter.JacksonConverter; //导入依赖的package包/类
@Override
public RestAdapter get() {
    return new RestAdapter.Builder()
            .setEndpoint(graylogServerURL)
            .setConverter(new JacksonConverter(new ObjectMapper()))
            .setRequestInterceptor(request -> {
                request.addHeader("User-Agent", "LogInsight Collector " + CollectorVersion.CURRENT);
                request.addHeader("X-LogInsight-Collector-Version", CollectorVersion.CURRENT.version());
            })
            .build();
}
 
开发者ID:DevOpsStudio,项目名称:Re-Collector,代码行数:12,代码来源:RestAdapterProvider.java

示例12: createConverter

import retrofit.converter.JacksonConverter; //导入依赖的package包/类
public static Converter createConverter() {

        ObjectMapper objectMapper = new ObjectMapper();
        objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
        objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);

        return new JacksonConverter(objectMapper);
    }
 
开发者ID:Aptoide,项目名称:aptoide-client,代码行数:9,代码来源:OauthErrorHandler.java

示例13: createConverter

import retrofit.converter.JacksonConverter; //导入依赖的package包/类
@Override
protected Converter createConverter() {

    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);

    return new JacksonConverter(objectMapper);
}
 
开发者ID:Aptoide,项目名称:aptoide-client,代码行数:10,代码来源:HttpService.java

示例14: buildClient

import retrofit.converter.JacksonConverter; //导入依赖的package包/类
/**
 * @param apiClass     the Class for which to build a client
 * @param username     the management API username
 * @param password     the management API password
 * @param debugLogging whether debug logging should be enabled
 * @return an API client for the given Class
 */
protected A buildClient(Class<A> apiClass, String endpoint, String username, String password, boolean debugLogging) {
    final RestAdapter.Builder builder = new RestAdapter.Builder() //
            .setConverter(new JacksonConverter(JSON_MAPPER))
            .setEndpoint(endpoint)
            .setRequestInterceptor(request -> {
                request.addHeader(HEADER_AUTHORIZATION, AuthUtil.buildAuthString(username, password));
            });

    if (debugLogging) {
        builder.setLogLevel(RestAdapter.LogLevel.FULL);
    }

    return builder.build().create(apiClass);
}
 
开发者ID:apiman,项目名称:apiman-cli,代码行数:22,代码来源:AbstractManagementApiFactory.java

示例15: gitHubClient

import retrofit.converter.JacksonConverter; //导入依赖的package包/类
@Bean
public GitHubClient gitHubClient() {
  BasicAuthRequestInterceptor interceptor = new BasicAuthRequestInterceptor()
      .setAccessToken(gitHubProperties.getAccessToken());

  return new RestAdapter.Builder()
      .setEndpoint(Endpoints.newFixedEndpoint(gitHubProperties.getBaseUrl()))
      .setRequestInterceptor(interceptor)
      .setClient(okClient)
      .setConverter(new JacksonConverter())
      .setLogLevel(retrofitLogLevel)
      .setLog(new Slf4jRetrofitLogger(GitHubClient.class))
      .build()
      .create(GitHubClient.class);
}
 
开发者ID:spinnaker,项目名称:fiat,代码行数:16,代码来源:GitHubConfig.java


注:本文中的retrofit.converter.JacksonConverter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。