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


Java JacksonFactory.getDefaultInstance方法代码示例

本文整理汇总了Java中com.google.api.client.json.jackson2.JacksonFactory.getDefaultInstance方法的典型用法代码示例。如果您正苦于以下问题:Java JacksonFactory.getDefaultInstance方法的具体用法?Java JacksonFactory.getDefaultInstance怎么用?Java JacksonFactory.getDefaultInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.api.client.json.jackson2.JacksonFactory的用法示例。


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

示例1: GoogleConnector

import com.google.api.client.json.jackson2.JacksonFactory; //导入方法依赖的package包/类
/**
 * Instances the google connector configuring all required resources.
 */
private GoogleConnector() throws IOException, GeneralSecurityException {
    super();
    // 1. JSON library
    jsonFactory = JacksonFactory.getDefaultInstance();

    // 2. Configure HTTP transport
    httpTransport = GoogleNetHttpTransport.newTrustedTransport();

    // 3. Load the credentials
    secrets = GoogleClientSecrets.load(jsonFactory, new InputStreamReader(GoogleConnector.class.getResourceAsStream("client-secrets.json")));

    // 4. Configure the authentication flow
    dataStoreFactory = new FileDataStoreFactory(CREDENTIALS_DIRECTORY);

    // 5. Create flow
    imp_buildAuthorizationFlow();
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:21,代码来源:GoogleConnector.java

示例2: getProjectsApiStub

import com.google.api.client.json.jackson2.JacksonFactory; //导入方法依赖的package包/类
/**
 * Return the Projects api object used for accessing the Cloud Resource Manager Projects API.
 * @return Projects api object used for accessing the Cloud Resource Manager Projects API
 * @throws GeneralSecurityException Thrown if there's a permissions error.
 * @throws IOException Thrown if there's an IO error initializing the API object.
 */
public static synchronized Projects getProjectsApiStub()
    throws GeneralSecurityException, IOException {
  if (projectApiStub != null) {
    return projectApiStub;
  }
  HttpTransport transport;
  GoogleCredential credential;
  JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
  transport = GoogleNetHttpTransport.newTrustedTransport();
  credential = GoogleCredential.getApplicationDefault(transport, jsonFactory);
  if (credential.createScopedRequired()) {
    Collection<String> scopes = CloudResourceManagerScopes.all();
    credential = credential.createScoped(scopes);
  }
  projectApiStub = new CloudResourceManager
      .Builder(transport, jsonFactory, credential)
      .build()
      .projects();
  return projectApiStub;
}
 
开发者ID:GoogleCloudPlatform,项目名称:policyscanner,代码行数:27,代码来源:GCPProject.java

示例3: getServiceAccountsApiStub

import com.google.api.client.json.jackson2.JacksonFactory; //导入方法依赖的package包/类
/**
 * Get the API stub for accessing the IAM Service Accounts API.
 * @return ServiceAccounts api stub for accessing the IAM Service Accounts API.
 * @throws IOException Thrown if there's an IO error initializing the api connection.
 * @throws GeneralSecurityException Thrown if there's a security error
 * initializing the connection.
 */
public static ServiceAccounts getServiceAccountsApiStub() throws IOException, GeneralSecurityException {
  if (serviceAccountsApiStub == null) {
    HttpTransport transport;
    GoogleCredential credential;
    JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
    transport = GoogleNetHttpTransport.newTrustedTransport();
    credential = GoogleCredential.getApplicationDefault(transport, jsonFactory);
    if (credential.createScopedRequired()) {
      Collection<String> scopes = IamScopes.all();
      credential = credential.createScoped(scopes);
    }
    serviceAccountsApiStub = new Iam.Builder(transport, jsonFactory, credential)
        .build()
        .projects()
        .serviceAccounts();
  }
  return serviceAccountsApiStub;
}
 
开发者ID:GoogleCloudPlatform,项目名称:policyscanner,代码行数:26,代码来源:GCPServiceAccount.java

示例4: createAdminApiClient

import com.google.api.client.json.jackson2.JacksonFactory; //导入方法依赖的package包/类
private static SQLAdmin createAdminApiClient(Credential credential) {
  HttpTransport httpTransport;
  try {
    httpTransport = GoogleNetHttpTransport.newTrustedTransport();
  } catch (GeneralSecurityException | IOException e) {
    throw new RuntimeException("Unable to initialize HTTP transport", e);
  }

  String rootUrl = System.getProperty(API_ROOT_URL_PROPERTY);
  String servicePath = System.getProperty(API_SERVICE_PATH_PROPERTY);

  JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
  SQLAdmin.Builder adminApiBuilder =
      new Builder(httpTransport, jsonFactory, credential)
          .setApplicationName("Cloud SQL Java Socket Factory");
  if (rootUrl != null) {
    logTestPropertyWarning(API_ROOT_URL_PROPERTY);
    adminApiBuilder.setRootUrl(rootUrl);
  }
  if (servicePath != null) {
    logTestPropertyWarning(API_SERVICE_PATH_PROPERTY);
    adminApiBuilder.setServicePath(servicePath);
  }
  return adminApiBuilder.build();
}
 
开发者ID:GoogleCloudPlatform,项目名称:cloud-sql-jdbc-socket-factory,代码行数:26,代码来源:SslSocketFactory.java

示例5: googleStorage

import com.google.api.client.json.jackson2.JacksonFactory; //导入方法依赖的package包/类
@Bean
public Storage googleStorage() {
  JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
  String applicationName = "Spinnaker/Halyard";
  HttpRequestInitializer requestInitializer;
  try {
    requestInitializer = GoogleCredentials.setHttpTimeout(GoogleCredential.getApplicationDefault());
    log.info("Loaded application default credential for reading BOMs & profiles.");
  } catch (Exception e) {
    requestInitializer = GoogleCredentials.retryRequestInitializer();
    log.debug("No application default credential could be loaded for reading BOMs & profiles. Continuing unauthenticated: {}", e.getMessage());
  }

  return new Storage.Builder(GoogleCredentials.buildHttpTransport(), jsonFactory, requestInitializer)
      .setApplicationName(applicationName)
      .build();
}
 
开发者ID:spinnaker,项目名称:halyard,代码行数:18,代码来源:GoogleProfileReader.java

示例6: deleteDevice

import com.google.api.client.json.jackson2.JacksonFactory; //导入方法依赖的package包/类
/** Delete the given device from the registry. */
public static void deleteDevice(String deviceId, String projectId, String cloudRegion,
                                String registryName)
    throws GeneralSecurityException, IOException {
  GoogleCredential credential =
      GoogleCredential.getApplicationDefault().createScoped(CloudIotScopes.all());
  JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
  HttpRequestInitializer init = new RetryHttpInitializerWrapper(credential);
  final CloudIot service = new CloudIot.Builder(
          GoogleNetHttpTransport.newTrustedTransport(),jsonFactory, init)
          .setApplicationName(APP_NAME).build();

  final String devicePath = String.format("projects/%s/locations/%s/registries/%s/devices/%s",
      projectId, cloudRegion, registryName, deviceId);

  System.out.println("Deleting device " + devicePath);
  service.projects().locations().registries().devices().delete(devicePath).execute();
}
 
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:19,代码来源:DeviceRegistryExample.java

示例7: getAuthorizationCodeFlow

import com.google.api.client.json.jackson2.JacksonFactory; //导入方法依赖的package包/类
/**
 * Returns a authorization code flow for OAuth requests.
 * @param forTokenRequest <code>true</code> for token requests, or
 * <code>false</code> for authorization requests
 * @return {@link AuthorizationCodeFlow} object
 * @throws NullPointerException if this object has no client credentials
 */
protected AuthorizationCodeFlow getAuthorizationCodeFlow(
        boolean forTokenRequest) {
    if (!isConfiguredForOAuth()) {
        throw new NullPointerException("No OAuth client credentials");
    }

    HttpExecuteInterceptor clientAuthenticator;
    if (forTokenRequest) {
        clientAuthenticator = getBasicAuthentication();
    } else {
        clientAuthenticator = getClientParameters();
    }
    return new AuthorizationCodeFlow(
            BearerToken.authorizationHeaderAccessMethod(),
            getHttpTransport(), JacksonFactory.getDefaultInstance(),
            new GenericUrl(TOKEN_ENDPOINT_URI), clientAuthenticator,
            getClientId(), AUTHORIZATION_ENDPOINT_URI);
}
 
开发者ID:kazssym,项目名称:bitbucket-api-client-java,代码行数:26,代码来源:OAuthClient.java

示例8: setUp

import com.google.api.client.json.jackson2.JacksonFactory; //导入方法依赖的package包/类
@Before public void setUp() throws Exception {
  // Mock out the vision service for unit tests.
  JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
  HttpTransport transport = new MockHttpTransport() {
    @Override
    public LowLevelHttpRequest buildRequest(String method, String url) throws IOException {
      return new MockLowLevelHttpRequest() {
        @Override
        public LowLevelHttpResponse execute() throws IOException {
          MockLowLevelHttpResponse response = new MockLowLevelHttpResponse();
          response.setStatusCode(200);
          response.setContentType(Json.MEDIA_TYPE);
          response.setContent("{\"responses\": [{\"textAnnotations\": []}]}");
          return response;
        }
      };
    }
  };
  Vision vision = new Vision(transport, jsonFactory, null);

  appUnderTest = new TextApp(vision, null /* index */);
}
 
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:23,代码来源:TextAppTest.java

示例9: getRegistry

import com.google.api.client.json.jackson2.JacksonFactory; //导入方法依赖的package包/类
/** Retrieves registry metadata from a project. **/
public static DeviceRegistry getRegistry(
    String projectId, String cloudRegion, String registryName)
    throws GeneralSecurityException, IOException {
  GoogleCredential credential =
      GoogleCredential.getApplicationDefault().createScoped(CloudIotScopes.all());
  JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
  HttpRequestInitializer init = new RetryHttpInitializerWrapper(credential);
  final CloudIot service = new CloudIot.Builder(
      GoogleNetHttpTransport.newTrustedTransport(),jsonFactory, init)
      .setApplicationName(APP_NAME).build();

  final String registryPath = String.format("projects/%s/locations/%s/registries/%s",
      projectId, cloudRegion, registryName);

  return service.projects().locations().registries().get(registryPath).execute();
}
 
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:18,代码来源:DeviceRegistryExample.java

示例10: createStandardBuilder

import com.google.api.client.json.jackson2.JacksonFactory; //导入方法依赖的package包/类
protected static ShoppingContent.Builder createStandardBuilder(
    CommandLine parsedArgs, ContentConfig config) throws IOException {
  JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
  HttpTransport httpTransport = null;
  try {
    httpTransport = GoogleNetHttpTransport.newTrustedTransport();
  } catch (GeneralSecurityException e) {
    e.printStackTrace();
    System.exit(1);
  }
  Authenticator authenticator =
      new Authenticator(httpTransport, jsonFactory, ShoppingContentScopes.all(), config);
  Credential credential = authenticator.authenticate();

  return new ShoppingContent.Builder(
          httpTransport, jsonFactory, BaseOption.installLogging(credential, parsedArgs))
      .setApplicationName("Content API for Shopping Samples");
}
 
开发者ID:googleads,项目名称:googleads-shopping-samples,代码行数:19,代码来源:ContentWorkflowSample.java

示例11: buildStorageWithCredentials

import com.google.api.client.json.jackson2.JacksonFactory; //导入方法依赖的package包/类
public static Storage buildStorageWithCredentials(Path credentialFilePath) {
  try {
    HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();
    JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
    Credential credential =
        GoogleCredential.fromStream(
                Files.newInputStream(credentialFilePath), httpTransport, jsonFactory)
            .createScoped(
                ImmutableSet.of("https://www.googleapis.com/auth/devstorage.read_write"));
    return new Storage.Builder(httpTransport, jsonFactory, credential)
        .setApplicationName("Gletscher/1.0")
        .build();
  } catch (GeneralSecurityException | IOException e) {
    throw new IllegalStateException(e);
  }
}
 
开发者ID:pmoor,项目名称:gletscher,代码行数:17,代码来源:GoogleCloudFileStorage.java

示例12: ReportsFeature

import com.google.api.client.json.jackson2.JacksonFactory; //导入方法依赖的package包/类
public ReportsFeature(EventDispatcher<BuildServerListener> dispatcher, @NotNull ReportsDescriptor descriptor, @NotNull ReportsConstants constants) {
    this.editParametersUrl = descriptor.getFeaturePath();
    this.constants = constants;
    this.jsonFactory = JacksonFactory.getDefaultInstance();

    try {
        this.httpTransport = GoogleNetHttpTransport.newTrustedTransport();
    } catch (GeneralSecurityException | IOException e) {
        throw new RuntimeException(e);
    }

    if (dispatcher != null) {
        dispatcher.addListener(new BuildServerAdapter() {
            @Override
            public void buildFinished(SRunningBuild build) {
                handleBuildFinished(build);
            }
        });
    }
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:21,代码来源:ReportsFeature.java

示例13: getCalendarEventCount

import com.google.api.client.json.jackson2.JacksonFactory; //导入方法依赖的package包/类
private Integer getCalendarEventCount() throws GeneralSecurityException, IOException {
    NetHttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();
    JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();

    TokenResponse tokenResponse = new TokenResponse();
    tokenResponse.setRefreshToken(REFRESH_TOKEN);
    Credential credential = createCredentialWithRefreshToken(httpTransport, jsonFactory, tokenResponse);

    Calendar calendar = new com.google.api.services.calendar.Calendar.Builder(
            httpTransport, jsonFactory, credential).setApplicationName(APPLICATION_NAME).build();

    Calendar.Events.List events = calendar.events().list(CALENDAR_ID);

    return events.execute().getItems().size();
}
 
开发者ID:synyx,项目名称:urlaubsverwaltung,代码行数:16,代码来源:GoogleCalendarSyncProviderServiceTest.java

示例14: isClusterCollected

import com.google.api.client.json.jackson2.JacksonFactory; //导入方法依赖的package包/类
private boolean isClusterCollected(SpydraArgument arguments)
    throws IOException, GeneralSecurityException {
  GoogleCredential credential = GoogleCredential.fromStream(
      new ByteArrayInputStream(gcpUtils.credentialJsonFromEnv().getBytes()));
  if (credential.createScopedRequired()) {
    credential =
        credential.createScoped(
            Collections.singletonList("https://www.googleapis.com/auth/cloud-platform"));
  }

  HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();
  JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
  Dataproc dataprocService =
      new Dataproc.Builder(httpTransport, jsonFactory, credential)
          .setApplicationName("Google Cloud Platform Sample")
          .build();

  Dataproc.Projects.Regions.Clusters.List request =
      dataprocService.projects().regions().clusters().list(
          arguments.getCluster().getOptions().get(SpydraArgument.OPTION_PROJECT),
          arguments.getRegion());
  ListClustersResponse response;
  do {
    response = request.execute();
    if (response.getClusters() == null) continue;

    String clusterName = arguments.getCluster().getName();
    for (Cluster cluster : response.getClusters()) {
      if (cluster.getClusterName().equals(clusterName)) {
        String status = cluster.getStatus().getState();
        LOGGER.info("Cluster state is" + status);
        return status.equals("DELETING");
      }
    }

    request.setPageToken(response.getNextPageToken());
  } while (response.getNextPageToken() != null);
  return true;
}
 
开发者ID:spotify,项目名称:spydra,代码行数:40,代码来源:LifecycleIT.java

示例15: createClient

import com.google.api.client.json.jackson2.JacksonFactory; //导入方法依赖的package包/类
@Override
public Storage createClient(String serviceAccount, String application, TimeValue connectTimeout, TimeValue readTimeout)
        throws Exception {
    try {
        GoogleCredential credentials = (DEFAULT.equalsIgnoreCase(serviceAccount)) ? loadDefault() : loadCredentials(serviceAccount);
        NetHttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();

        Storage.Builder storage = new Storage.Builder(httpTransport, JacksonFactory.getDefaultInstance(),
                new DefaultHttpRequestInitializer(credentials, connectTimeout, readTimeout));
        storage.setApplicationName(application);

        logger.debug("initializing client with service account [{}/{}]",
                credentials.getServiceAccountId(), credentials.getServiceAccountUser());
        return storage.build();
    } catch (IOException e) {
        throw new ElasticsearchException("Error when loading Google Cloud Storage credentials file", e);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:GoogleCloudStorageService.java


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