Movatterモバイル変換


[0]ホーム

URL:


Google APIs Client Library for Java

Overview
Setup Instructions
Component Modules
Android
Google App Engine
Batching
Media Download
Media Upload
OAuth 2.0
Timeouts and Errors
Support

Batching

Each HTTP connection that your client makes results in overhead. To reduceoverhead, you can batch multiple API calls together into a single HTTP request.

The main classes of interest areBatchRequest andJsonBatchCallback. The following example shows how to usethese classes with service-specific generated libraries:

JsonBatchCallback<Calendar>callback=newJsonBatchCallback<Calendar>(){publicvoidonSuccess(Calendarcalendar,HttpHeadersresponseHeaders){printCalendar(calendar);addedCalendarsUsingBatch.add(calendar);}publicvoidonFailure(GoogleJsonErrore,HttpHeadersresponseHeaders){System.out.println("Error Message: "+e.getMessage());}};...Calendarclient=Calendar.builder(transport,jsonFactory,credential).setApplicationName("BatchExample/1.0").build();BatchRequestbatch=client.batch();Calendarentry1=newCalendar().setSummary("Calendar for Testing 1");client.calendars().insert(entry1).queue(batch,callback);Calendarentry2=newCalendar().setSummary("Calendar for Testing 2");client.calendars().insert(entry2).queue(batch,callback);batch.execute();

[8]ページ先頭

©2009-2025 Movatter.jp