本文整理汇总了Java中com.google.ipc.invalidation.external.client.android.service.Request类的典型用法代码示例。如果您正苦于以下问题:Java Request类的具体用法?Java Request怎么用?Java Request使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Request类属于com.google.ipc.invalidation.external.client.android.service包,在下文中一共展示了Request类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onStartCommand
import com.google.ipc.invalidation.external.client.android.service.Request; //导入依赖的package包/类
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
// Process GCM related messages from the ReceiverService. We do not check isCreated here because
// this is part of the stop/start lifecycle, not bind/unbind.
synchronized (lock) {
logger.fine("Received action = %s", intent.getAction());
if (MESSAGE_ACTION.equals(intent.getAction())) {
handleMessage(intent);
} else if (REGISTRATION_ACTION.equals(intent.getAction())) {
handleRegistration(intent);
} else if (ERROR_ACTION.equals(intent.getAction())) {
handleError(intent);
}
final int retval = super.onStartCommand(intent, flags, startId);
// Unless we are explicitly being asked to start, stop ourselves. Request.SERVICE_INTENT
// is the intent used by InvalidationBinder to bind the service, and
// AndroidInvalidationClientImpl uses the intent returned by InvalidationBinder.getIntent
// as the argument to its startService call.
if (!Request.SERVICE_INTENT.getAction().equals(intent.getAction())) {
stopServiceIfNoClientsRemain(intent.getAction());
}
return retval;
}
}
示例2: initialize
import com.google.ipc.invalidation.external.client.android.service.Request; //导入依赖的package包/类
/**
* Called to initialize a newly created client instance with the invalidation service.
*/
void initialize() {
// Create an intent that can be used to fire listener events back to the
// provided listener service. Use setComponent and not setPackage/setClass so the
// intent is guaranteed to be valid even if the service is not in the same application
Intent eventIntent = new Intent(Event.LISTENER_INTENT);
ComponentName component = new ComponentName(context.getPackageName(), listenerClass.getName());
eventIntent.setComponent(component);
Request request = Request
.newBuilder(Action.CREATE)
.setClientKey(clientKey)
.setClientType(clientType)
.setAccount(account)
.setAuthType(authType)
.setIntent(eventIntent)
.build();
executeServiceRequest(request);
addReference();
}
示例3: executeServiceRequest
import com.google.ipc.invalidation.external.client.android.service.Request; //导入依赖的package包/类
/**
* Executes a request against the invalidation service and does common error processing against
* the resulting response. If unable to connect to the service or an error status is received from
* it, a warning will be logged and the request will be dropped.
*
* @param request the request to execute.
*/
private void executeServiceRequest(final Request request) {
serviceBinder.runWhenBound(new BoundWork<InvalidationService>() {
@Override
public void run(InvalidationService service) {
Bundle outBundle = new Bundle();
try {
service.handleRequest(request.getBundle(), outBundle);
} catch (RemoteException exception) {
logger.warning("Remote exeption executing request %s: %s", request,
exception.getMessage());
}
Response response = new Response(outBundle);
response.warnOnFailure();
}
});
}
示例4: create
import com.google.ipc.invalidation.external.client.android.service.Request; //导入依赖的package包/类
@Override
protected void create(Request request, Response.Builder response) {
synchronized (LOCK) {
validateRequest(request, Action.CREATE, Parameter.ACTION, Parameter.CLIENT,
Parameter.CLIENT_TYPE, Parameter.ACCOUNT, Parameter.AUTH_TYPE, Parameter.INTENT);
logger.info("Creating client %s:%s", request.getClientKey(), clientMap.keySet());
if (!TypedUtil.containsKey(clientMap, request.getClientKey())) {
// If no client exists with this key, create one.
clientMap.put(
request.getClientKey(), new ClientState(request.getAccount(), request.getAuthType(),
request.getIntent()));
} else {
// Otherwise, verify that the existing client has the same account / auth type / intent.
ClientState existingState = TypedUtil.mapGet(clientMap, request.getClientKey());
Preconditions.checkState(request.getAccount().equals(existingState.account));
Preconditions.checkState(request.getAuthType().equals(existingState.authType));
}
response.setStatus(Response.Status.SUCCESS);
}
}
示例5: resume
import com.google.ipc.invalidation.external.client.android.service.Request; //导入依赖的package包/类
@Override
protected void resume(Request request, Response.Builder response) {
synchronized (LOCK) {
validateRequest(
request, Action.RESUME, Parameter.ACTION, Parameter.CLIENT);
ClientState state = clientMap.get(request.getClientKey());
if (state != null) {
logger.info("Resuming client %s:%s", request.getClientKey(), clientMap.keySet());
response.setStatus(Response.Status.SUCCESS);
response.setAccount(state.account);
response.setAuthType(state.authType);
} else {
logger.warning("Cannot resume client %s:%s", request.getClientKey(), clientMap.keySet());
response.setStatus(Response.Status.INVALID_CLIENT);
}
}
}
示例6: unregister
import com.google.ipc.invalidation.external.client.android.service.Request; //导入依赖的package包/类
@Override
protected void unregister(Request request, Response.Builder response) {
synchronized (LOCK) {
// Ensure that one (and only one) of the variant object id forms is used
String objectParam =
request.getBundle().containsKey(Parameter.OBJECT_ID) ?
Parameter.OBJECT_ID :
Parameter.OBJECT_ID_LIST;
validateRequest(request, Action.UNREGISTER, Parameter.ACTION,
Parameter.CLIENT, objectParam);
if (!validateClient(request)) {
response.setStatus(Response.Status.INVALID_CLIENT);
return;
}
response.setStatus(Response.Status.SUCCESS);
}
}
示例7: create
import com.google.ipc.invalidation.external.client.android.service.Request; //导入依赖的package包/类
@Override
protected void create(Request request, Response.Builder response) {
String clientKey = request.getClientKey();
int clientType = request.getClientType();
Account account = request.getAccount();
String authType = request.getAuthType();
Intent eventIntent = request.getIntent();
clientManager.create(clientKey, clientType, account, authType, eventIntent);
response.setStatus(Status.SUCCESS);
}
示例8: resume
import com.google.ipc.invalidation.external.client.android.service.Request; //导入依赖的package包/类
@Override
protected void resume(Request request, Response.Builder response) {
String clientKey = request.getClientKey();
AndroidClientProxy client = clientManager.get(clientKey);
if (setResponseStatus(client, request, response)) {
response.setAccount(client.getAccount());
response.setAuthType(client.getAuthType());
}
}
示例9: start
import com.google.ipc.invalidation.external.client.android.service.Request; //导入依赖的package包/类
@Override
protected void start(Request request, Response.Builder response) {
String clientKey = request.getClientKey();
AndroidInvalidationClient client = clientManager.get(clientKey);
if (setResponseStatus(client, request, response)) {
client.start();
}
}
示例10: stop
import com.google.ipc.invalidation.external.client.android.service.Request; //导入依赖的package包/类
@Override
protected void stop(Request request, Response.Builder response) {
String clientKey = request.getClientKey();
AndroidInvalidationClient client = clientManager.get(clientKey);
if (setResponseStatus(client, request, response)) {
client.stop();
}
}
示例11: register
import com.google.ipc.invalidation.external.client.android.service.Request; //导入依赖的package包/类
@Override
protected void register(Request request, Response.Builder response) {
String clientKey = request.getClientKey();
AndroidInvalidationClient client = clientManager.get(clientKey);
if (setResponseStatus(client, request, response)) {
ObjectId objectId = request.getObjectId();
client.register(objectId);
}
}
示例12: unregister
import com.google.ipc.invalidation.external.client.android.service.Request; //导入依赖的package包/类
@Override
protected void unregister(Request request, Response.Builder response) {
String clientKey = request.getClientKey();
AndroidInvalidationClient client = clientManager.get(clientKey);
if (setResponseStatus(client, request, response)) {
ObjectId objectId = request.getObjectId();
client.unregister(objectId);
}
}
示例13: acknowledge
import com.google.ipc.invalidation.external.client.android.service.Request; //导入依赖的package包/类
@Override
protected void acknowledge(Request request, Response.Builder response) {
String clientKey = request.getClientKey();
AckHandle ackHandle = request.getAckHandle();
AndroidInvalidationClient client = clientManager.get(clientKey);
if (setResponseStatus(client, request, response)) {
client.acknowledge(ackHandle);
}
}
示例14: destroy
import com.google.ipc.invalidation.external.client.android.service.Request; //导入依赖的package包/类
@Override
protected void destroy(Request request, Response.Builder response) {
String clientKey = request.getClientKey();
AndroidInvalidationClient client = clientManager.get(clientKey);
if (setResponseStatus(client, request, response)) {
client.destroy();
}
}
示例15: setResponseStatus
import com.google.ipc.invalidation.external.client.android.service.Request; //导入依赖的package包/类
/**
* If {@code client} is {@code null}, sets the {@code response} status to an error. Otherwise,
* sets the status to {@code success}.
* @return whether {@code client} was non-{@code null}. *
*/
private boolean setResponseStatus(AndroidInvalidationClient client, Request request,
Response.Builder response) {
if (client == null) {
response.setError("Client does not exist: " + request);
response.setStatus(Status.INVALID_CLIENT);
return false;
} else {
response.setStatus(Status.SUCCESS);
return true;
}
}