本文整理汇总了Java中com.google.ipc.invalidation.external.client.types.Invalidation类的典型用法代码示例。如果您正苦于以下问题:Java Invalidation类的具体用法?Java Invalidation怎么用?Java Invalidation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Invalidation类属于com.google.ipc.invalidation.external.client.types包,在下文中一共展示了Invalidation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: tryHandleBackgroundInvalidationsIntent
import com.google.ipc.invalidation.external.client.types.Invalidation; //导入依赖的package包/类
/**
* Tries to handle a background invalidation intent. Returns {@code true} iff the intent is a
* background invalidation intent.
*/
private boolean tryHandleBackgroundInvalidationsIntent(Intent intent) {
byte[] data = intent.getByteArrayExtra(ProtocolIntents.BACKGROUND_INVALIDATION_KEY);
if (data == null) {
return false;
}
try {
InvalidationMessage invalidationMessage = InvalidationMessage.parseFrom(data);
List<Invalidation> invalidations = new ArrayList<Invalidation>();
for (InvalidationP invalidation : invalidationMessage.getInvalidation()) {
invalidations.add(ProtoWrapperConverter.convertFromInvalidationProto(invalidation));
}
backgroundInvalidateForInternalUse(invalidations);
} catch (ValidationException exception) {
logger.info("Failed to parse background invalidation intent payload: %s",
exception.getMessage());
}
return false;
}
示例2: invalidate
import com.google.ipc.invalidation.external.client.types.Invalidation; //导入依赖的package包/类
@Override
public void invalidate(Invalidation invalidation, byte[] ackHandle) {
byte[] payload = invalidation.getPayload();
String payloadStr = (payload == null) ? null : new String(payload);
requestSync(invalidation.getObjectId(), invalidation.getVersion(), payloadStr);
acknowledge(ackHandle);
}
示例3: invalidate
import com.google.ipc.invalidation.external.client.types.Invalidation; //导入依赖的package包/类
@Override
public void invalidate(InvalidationClient client, Invalidation invalidation,
AckHandle ackHandle) {
try {
AckHandleP ackHandleP = AckHandleP.parseFrom(ackHandle.getHandleData());
issueIntent(context, ListenerUpcalls.newInvalidateIntent(
ProtoWrapperConverter.convertToInvalidationProto(invalidation), ackHandleP));
} catch (ValidationException exception) {
// Log and drop invalid call.
logBadAckHandle("invalidate", ackHandle);
}
}
示例4: handleInvalidations
import com.google.ipc.invalidation.external.client.types.Invalidation; //导入依赖的package包/类
/** Handles incoming {@code invalidations}. */
private void handleInvalidations(Collection<InvalidationP> invalidations) {
Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");
for (InvalidationP invalidation : invalidations) {
AckHandle ackHandle = AckHandle.newInstance(AckHandleP.create(invalidation).toByteArray());
if (ackCache.isAcked(invalidation)) {
// If the ack cache indicates that the client has already acked a restarted invalidation
// with an equal or greater version, then the TICL can simply acknowledge it immediately
// rather than delivering it to the listener.
logger.info("Stale invalidation {0}, not delivering", invalidation);
acknowledge(ackHandle);
statistics.recordReceivedMessage(ReceivedMessageType.STALE_INVALIDATION);
} else if (CommonProtos.isAllObjectId(invalidation.getObjectId())) {
logger.info("Issuing invalidate all");
listener.invalidateAll(InvalidationClientCore.this, ackHandle);
} else {
// Regular object. Could be unknown version or not.
Invalidation inv = ProtoWrapperConverter.convertFromInvalidationProto(invalidation);
boolean isSuppressed = invalidation.getIsTrickleRestart();
logger.info("Issuing invalidate (known-version = %s, is-trickle-restart = %s): %s",
invalidation.getIsKnownVersion(), isSuppressed, inv);
// Issue invalidate if the invalidation had a known version AND either no suppression has
// occurred or the client allows suppression.
if (invalidation.getIsKnownVersion() &&
(!isSuppressed || InvalidationClientCore.this.config.getAllowSuppression())) {
listener.invalidate(InvalidationClientCore.this, inv, ackHandle);
} else {
// Otherwise issue invalidateUnknownVersion.
listener.invalidateUnknownVersion(InvalidationClientCore.this, inv.getObjectId(),
ackHandle);
}
}
}
}
示例5: invalidate
import com.google.ipc.invalidation.external.client.types.Invalidation; //导入依赖的package包/类
@Override
public void invalidate(final InvalidationClient client, final Invalidation invalidation,
final AckHandle ackHandle) {
Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");
Preconditions.checkNotNull(ackHandle);
listenerScheduler.schedule(NO_DELAY, new NamedRunnable("CheckingInvalListener.invalidate") {
@Override
public void run() {
statistics.recordListenerEvent(ListenerEventType.INVALIDATE);
delegate.invalidate(client, invalidation, ackHandle);
}
});
}
示例6: convertFromInvalidationProto
import com.google.ipc.invalidation.external.client.types.Invalidation; //导入依赖的package包/类
/**
* Converts an invalidation protocol buffer {@code invalidation} to the
* corresponding external object and returns it
*/
public static Invalidation convertFromInvalidationProto(InvalidationP invalidation) {
Preconditions.checkNotNull(invalidation);
ObjectId objectId = convertFromObjectIdProto(invalidation.getObjectId());
// No bridge arrival time in invalidation.
return Invalidation.newInstance(objectId, invalidation.getVersion(),
invalidation.hasPayload() ? invalidation.getPayload().getByteArray() : null,
invalidation.getIsTrickleRestart());
}
示例7: convertToInvalidationProto
import com.google.ipc.invalidation.external.client.types.Invalidation; //导入依赖的package包/类
/**
* Converts an invalidation {@code invalidation} to the corresponding protocol
* buffer and returns it.
*/
public static InvalidationP convertToInvalidationProto(Invalidation invalidation) {
Preconditions.checkNotNull(invalidation);
ObjectIdP objectId = convertToObjectIdProto(invalidation.getObjectId());
// Invalidations clients do not know about trickle restarts. Every invalidation is allowed
// to suppress earlier invalidations and acks implicitly acknowledge all previous
// invalidations. Therefore the correct semanantics are provided by setting isTrickleRestart to
// true.
return CommonProtos.newInvalidationP(objectId, invalidation.getVersion(),
invalidation.getIsTrickleRestartForInternalUse(), invalidation.getPayload());
}
示例8: invalidate
import com.google.ipc.invalidation.external.client.types.Invalidation; //导入依赖的package包/类
@Override
public void invalidate(Invalidation invalidation, byte[] ackHandle) {
Log.i(TAG, "invalidate: " + invalidation);
// Do real work here based upon the invalidation
MainActivity.State.setVersion(
invalidation.getObjectId(), "invalidate", invalidation.toString());
acknowledge(ackHandle);
}
示例9: convertFromInvalidationProto
import com.google.ipc.invalidation.external.client.types.Invalidation; //导入依赖的package包/类
/**
* Converts an invalidation protocol buffer {@code invalidation} to the
* corresponding external object and returns it
*/
public static Invalidation convertFromInvalidationProto(InvalidationP invalidation) {
Preconditions.checkNotNull(invalidation);
ObjectId objectId = convertFromObjectIdProto(invalidation.getObjectId());
// No bridge arrival time in invalidation.
return Invalidation.newInstance(objectId, invalidation.getVersion(),
invalidation.hasPayload() ? invalidation.getPayload().toByteArray() : null,
invalidation.getIsTrickleRestart());
}
示例10: convertToInvalidationProto
import com.google.ipc.invalidation.external.client.types.Invalidation; //导入依赖的package包/类
/**
* Converts an invalidation {@code invalidation} to the corresponding protocol
* buffer and returns it.
*/
public static InvalidationP convertToInvalidationProto(Invalidation invalidation) {
Preconditions.checkNotNull(invalidation);
ObjectIdP objectId = convertToObjectIdProto(invalidation.getObjectId());
// Invalidations clients do not know about trickle restarts. Every invalidation is allowed
// to suppress earlier invalidations and acks implicitly acknowledge all previous
// invalidations. Therefore the correct semanantics are provided by setting isTrickleRestart to
// true.
return CommonProtos2.newInvalidationP(objectId, invalidation.getVersion(),
TrickleState.fromBoolean(invalidation.getIsTrickleRestartForInternalUse()),
invalidation.getPayload() == null ? null : ByteString.copyFrom(invalidation.getPayload()));
}
示例11: invalidate
import com.google.ipc.invalidation.external.client.types.Invalidation; //导入依赖的package包/类
@Override
public void invalidate(InvalidationClient client, Invalidation invalidation,
AckHandle ackHandle) {
try {
AckHandleP ackHandleP = AckHandleP.parseFrom(ackHandle.getHandleData());
issueIntent(context, ListenerUpcalls.newInvalidateIntent(
ProtoConverter.convertToInvalidationProto(invalidation), ackHandleP));
} catch (InvalidProtocolBufferException exception) {
// Log and drop invalid call.
logBadAckHandle("invalidate", ackHandle);
}
}
示例12: handleInvalidations
import com.google.ipc.invalidation.external.client.types.Invalidation; //导入依赖的package包/类
/** Handles incoming {@code invalidations}. */
private void handleInvalidations(Collection<InvalidationP> invalidations) {
Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");
for (InvalidationP invalidation : invalidations) {
AckHandle ackHandle = AckHandle.newInstance(
CommonProtos2.newAckHandleP(invalidation).toByteArray());
if (CommonProtos2.isAllObjectId(invalidation.getObjectId())) {
logger.info("Issuing invalidate all");
listener.invalidateAll(InvalidationClientCore.this, ackHandle);
} else {
// Regular object. Could be unknown version or not.
Invalidation inv = ProtoConverter.convertFromInvalidationProto(invalidation);
boolean isSuppressed = invalidation.getIsTrickleRestart();
logger.info("Issuing invalidate (known-version = %s, is-trickle-restart = %s): %s",
invalidation.getIsKnownVersion(), isSuppressed, inv);
// Issue invalidate if the invalidation had a known version AND either no suppression has
// occurred or the client allows suppression.
if (invalidation.getIsKnownVersion() &&
(!isSuppressed || InvalidationClientCore.this.config.getAllowSuppression())) {
listener.invalidate(InvalidationClientCore.this, inv, ackHandle);
} else {
// Otherwise issue invalidateUnknownVersion.
listener.invalidateUnknownVersion(InvalidationClientCore.this, inv.getObjectId(),
ackHandle);
}
}
}
}
示例13: invalidate
import com.google.ipc.invalidation.external.client.types.Invalidation; //导入依赖的package包/类
@Override
public void invalidate(
InvalidationClient client, Invalidation invalidation, AckHandle ackHandle) {
Event event = Event.newBuilder(Event.Action.INVALIDATE)
.setClientKey(clientKey).setInvalidation(invalidation).setAckHandle(ackHandle).build();
sendEvent(event);
}
示例14: ParcelableInvalidation
import com.google.ipc.invalidation.external.client.types.Invalidation; //导入依赖的package包/类
/**
* Creates a new invalidation wrapper by reading data from a parcel.
*/
public ParcelableInvalidation(Parcel in) {
// Read parcelable object id from parcel using the application class loader
ParcelableObjectId objectId = in.readParcelable(getClass().getClassLoader());
long version = in.readLong();
boolean isTrickleRestart = in.createBooleanArray()[0];
boolean[] values = in.createBooleanArray();
byte[] payload = null;
if (values[0]) { // hasPayload
payload = in.createByteArray();
}
this.invalidation = Invalidation.newInstance(objectId.objectId, version, payload,
isTrickleRestart);
this.includePayload = payload != null;
}
示例15: invalidate
import com.google.ipc.invalidation.external.client.types.Invalidation; //导入依赖的package包/类
@Override
public void invalidate(
InvalidationClient client, Invalidation invalidation, AckHandle ackHandle) {
InvalidationListener listener = getListener(client);
logger.fine("Received INVALIDATE for %s: %s", getClientKey(client), listener);
if (listener != null) {
listener.invalidate(client, invalidation, ackHandle);
}
}