本文整理汇总了Java中com.google.ipc.invalidation.external.client.android.service.Request.Action类的典型用法代码示例。如果您正苦于以下问题:Java Action类的具体用法?Java Action怎么用?Java Action使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Action类属于com.google.ipc.invalidation.external.client.android.service.Request包,在下文中一共展示了Action类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
import com.google.ipc.invalidation.external.client.android.service.Request.Action; //导入依赖的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();
}
示例2: create
import com.google.ipc.invalidation.external.client.android.service.Request.Action; //导入依赖的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);
}
}
示例3: resume
import com.google.ipc.invalidation.external.client.android.service.Request.Action; //导入依赖的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);
}
}
}
示例4: unregister
import com.google.ipc.invalidation.external.client.android.service.Request.Action; //导入依赖的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);
}
}
示例5: register
import com.google.ipc.invalidation.external.client.android.service.Request.Action; //导入依赖的package包/类
/**
* Registers to receive invalidation notifications for an object.
*
* @param objectId object id.
*/
@Override
public void register(ObjectId objectId) {
Request request =
Request.newBuilder(Action.REGISTER).setClientKey(clientKey).setObjectId(objectId).build();
executeServiceRequest(request);
}
示例6: unregister
import com.google.ipc.invalidation.external.client.android.service.Request.Action; //导入依赖的package包/类
/**
* Unregisters to disable receipt of invalidations on an object.
*
* @param objectId object id.
*/
@Override
public void unregister(ObjectId objectId) {
Request request =
Request.newBuilder(Action.UNREGISTER).setClientKey(clientKey).setObjectId(objectId).build();
executeServiceRequest(request);
}
示例7: acknowledge
import com.google.ipc.invalidation.external.client.android.service.Request.Action; //导入依赖的package包/类
@Override
public void acknowledge(AckHandle ackHandle) {
Request request = Request
.newBuilder(Action.ACKNOWLEDGE)
.setClientKey(clientKey)
.setAckHandle(ackHandle)
.build();
executeServiceRequest(request);
}
示例8: destroy
import com.google.ipc.invalidation.external.client.android.service.Request.Action; //导入依赖的package包/类
@Override
public void destroy() {
Request request = Request
.newBuilder(Action.DESTROY)
.setClientKey(clientKey)
.build();
executeServiceRequest(request);
}
示例9: initResumed
import com.google.ipc.invalidation.external.client.android.service.Request.Action; //导入依赖的package包/类
/**
* Called to resume an existing client instance with the invalidation service. Iff
* {@code sendTiclResumeRequest}, a request is sent to the invalidatation service to ensure
* that the Ticl is loaded.
*/
void initResumed(boolean sendTiclResumeRequest) {
if (sendTiclResumeRequest) {
Request request = Request.newBuilder(Action.RESUME).setClientKey(clientKey).build();
executeServiceRequest(request);
}
addReference();
}
示例10: register
import com.google.ipc.invalidation.external.client.android.service.Request.Action; //导入依赖的package包/类
@Override
protected void register(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.REGISTER, Parameter.ACTION, Parameter.CLIENT, objectParam);
if (!validateClient(request)) {
response.setStatus(Response.Status.INVALID_CLIENT);
return;
}
response.setStatus(Response.Status.SUCCESS);
}
}
示例11: start
import com.google.ipc.invalidation.external.client.android.service.Request.Action; //导入依赖的package包/类
@Override
protected void start(Request request, Response.Builder response) {
synchronized (LOCK) {
validateRequest(
request, Action.START, Parameter.ACTION, Parameter.CLIENT);
if (!validateClient(request)) {
response.setStatus(Response.Status.INVALID_CLIENT);
return;
}
response.setStatus(Response.Status.SUCCESS);
}
}
示例12: stop
import com.google.ipc.invalidation.external.client.android.service.Request.Action; //导入依赖的package包/类
@Override
protected void stop(Request request, Response.Builder response) {
synchronized (LOCK) {
validateRequest(request, Action.STOP, Parameter.ACTION, Parameter.CLIENT);
if (!validateClient(request)) {
response.setStatus(Response.Status.INVALID_CLIENT);
return;
}
response.setStatus(Response.Status.SUCCESS);
}
}
示例13: acknowledge
import com.google.ipc.invalidation.external.client.android.service.Request.Action; //导入依赖的package包/类
@Override
protected void acknowledge(Request request, Response.Builder response) {
synchronized (LOCK) {
validateRequest(request, Action.ACKNOWLEDGE, Parameter.ACTION, Parameter.CLIENT,
Parameter.ACK_TOKEN);
if (!validateClient(request)) {
response.setStatus(Response.Status.INVALID_CLIENT);
return;
}
response.setStatus(Response.Status.SUCCESS);
}
}
示例14: destroy
import com.google.ipc.invalidation.external.client.android.service.Request.Action; //导入依赖的package包/类
@Override
protected void destroy(Request request, Response.Builder response) {
synchronized (LOCK) {
validateRequest(request, Action.DESTROY, Parameter.ACTION, Parameter.CLIENT);
if (!validateClient(request)) {
response.setStatus(Response.Status.INVALID_CLIENT);
return;
}
response.setStatus(Response.Status.SUCCESS);
}
}
示例15: validateRequest
import com.google.ipc.invalidation.external.client.android.service.Request.Action; //导入依赖的package包/类
/**
* Validates that the request contains exactly the set of parameters expected.
*
* @param request request to validate
* @param action expected action
* @param parameters expected parameters
*/
private void validateRequest(Request request, Action action, String... parameters) {
Assert.assertEquals(action, request.getAction());
List<String> expectedParameters = new ArrayList<String>(Arrays.asList(parameters));
Bundle requestBundle = request.getBundle();
for (String parameter : requestBundle.keySet()) {
Assert.assertTrue("Unexpected parameter: " + parameter, expectedParameters.remove(parameter));
// Validate the value
Object value = requestBundle.get(parameter);
Assert.assertNotNull(value);
}
Assert.assertTrue("Missing parameter:" + expectedParameters, expectedParameters.isEmpty());
}