本文整理汇总了Java中com.google.ipc.invalidation.external.client.types.ErrorInfo.newInstance方法的典型用法代码示例。如果您正苦于以下问题:Java ErrorInfo.newInstance方法的具体用法?Java ErrorInfo.newInstance怎么用?Java ErrorInfo.newInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.ipc.invalidation.external.client.types.ErrorInfo
的用法示例。
在下文中一共展示了ErrorInfo.newInstance方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleErrorMessage
import com.google.ipc.invalidation.external.client.types.ErrorInfo; //导入方法依赖的package包/类
/** Handles an error message. */
private void handleErrorMessage(ServerMessageHeader header, int code, String description) {
Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");
// If it is an auth failure, we shut down the ticl.
logger.severe("Received error message: %s, %s, %s", header, code, description);
// Translate the code to error reason.
int reason;
switch (code) {
case ErrorMessage.Code.AUTH_FAILURE:
reason = ErrorInfo.ErrorReason.AUTH_FAILURE;
break;
case ErrorMessage.Code.UNKNOWN_FAILURE:
default:
reason = ErrorInfo.ErrorReason.UNKNOWN_FAILURE;
break;
}
// Issue an informError to the application.
ErrorInfo errorInfo = ErrorInfo.newInstance(reason, false, description, null);
listener.informError(this, errorInfo);
// If this is an auth failure, remove registrations and stop the Ticl. Otherwise do nothing.
if (code != ErrorMessage.Code.AUTH_FAILURE) {
return;
}
// If there are any registrations, remove them and issue registration failure.
Collection<ObjectIdP> desiredRegistrations = registrationManager.removeRegisteredObjects();
logger.warning("Issuing failure for %s objects", desiredRegistrations.size());
for (ObjectIdP objectId : desiredRegistrations) {
listener.informRegistrationFailure(this,
ProtoWrapperConverter.convertFromObjectIdProto(objectId), false,
"Auth error: " + description);
}
}
示例2: ParcelableErrorInfo
import com.google.ipc.invalidation.external.client.types.ErrorInfo; //导入方法依赖的package包/类
/**
* Creates a new ErrorInfo wrapper by reading data from a parcel.
*/
public ParcelableErrorInfo(Parcel in) {
int reason = in.readInt();
boolean isTransient = in.createBooleanArray()[0];
String message = in.readString();
this.errorInfo = ErrorInfo.newInstance(reason, isTransient, message, null);
}
示例3: handleIntent
import com.google.ipc.invalidation.external.client.types.ErrorInfo; //导入方法依赖的package包/类
/**
* Handles a listener upcall by decoding the protocol buffer in {@code intent} and dispatching
* to the appropriate method on the {@link #listener}.
*/
public void handleIntent(Intent intent) {
// TODO: use wakelocks
// Unmarshall the arguments from the Intent and make the appropriate call on the listener.
ListenerUpcall upcall = tryParseIntent(intent);
if (upcall == null) {
return;
}
if (upcall.hasReady()) {
listener.ready(client);
} else if (upcall.getNullableInvalidate() != null) {
// Handle all invalidation-related upcalls on a common path, since they require creating
// an AckHandleP.
onInvalidateUpcall(upcall.getNullableInvalidate(), listener);
} else if (upcall.getNullableRegistrationStatus() != null) {
RegistrationStatusUpcall regStatus = upcall.getNullableRegistrationStatus();
listener.informRegistrationStatus(client,
ProtoWrapperConverter.convertFromObjectIdProto(regStatus.getObjectId()),
regStatus.getIsRegistered() ?
RegistrationState.REGISTERED : RegistrationState.UNREGISTERED);
} else if (upcall.getNullableRegistrationFailure() != null) {
RegistrationFailureUpcall failure = upcall.getNullableRegistrationFailure();
listener.informRegistrationFailure(client,
ProtoWrapperConverter.convertFromObjectIdProto(failure.getObjectId()),
failure.getTransient(),
failure.getMessage());
} else if (upcall.getNullableReissueRegistrations() != null) {
ReissueRegistrationsUpcall reissueRegs = upcall.getNullableReissueRegistrations();
listener.reissueRegistrations(client, reissueRegs.getPrefix().getByteArray(),
reissueRegs.getLength());
} else if (upcall.getNullableError() != null) {
ErrorUpcall error = upcall.getNullableError();
ErrorInfo errorInfo = ErrorInfo.newInstance(error.getErrorCode(), error.getIsTransient(),
error.getErrorMessage(), null);
listener.informError(client, errorInfo);
} else {
logger.warning("Dropping listener Intent with unknown call: %s", upcall);
}
}
示例4: informListenerOfPermanentError
import com.google.ipc.invalidation.external.client.types.ErrorInfo; //导入方法依赖的package包/类
/** Informs the listener of a non-retryable {@code error}. */
private void informListenerOfPermanentError(final String error) {
ErrorInfo errorInfo = ErrorInfo.newInstance(0, false, error, null);
Intent errorIntent = ProtocolIntents.ListenerUpcalls.newErrorIntent(errorInfo);
IntentForwardingListener.issueIntent(this, errorIntent);
}
示例5: handleIntent
import com.google.ipc.invalidation.external.client.types.ErrorInfo; //导入方法依赖的package包/类
/**
* Handles a listener upcall by decoding the protocol buffer in {@code intent} and dispatching
* to the appropriate method on the {@link #listener}.
*/
public void handleIntent(Intent intent) {
// TODO: use wakelocks
// Unmarshall the arguments from the Intent and make the appropriate call on the listener.
ListenerUpcall upcall = tryParseIntent(intent);
if (upcall == null) {
return;
}
if (upcall.hasReady()) {
listener.ready(client);
} else if (upcall.hasInvalidate()) {
// Handle all invalidation-related upcalls on a common path, since they require creating
// an AckHandleP.
onInvalidateUpcall(upcall, listener);
} else if (upcall.hasRegistrationStatus()) {
RegistrationStatusUpcall regStatus = upcall.getRegistrationStatus();
listener.informRegistrationStatus(client,
ProtoConverter.convertFromObjectIdProto(regStatus.getObjectId()),
regStatus.getIsRegistered() ?
RegistrationState.REGISTERED : RegistrationState.UNREGISTERED);
} else if (upcall.hasRegistrationFailure()) {
RegistrationFailureUpcall failure = upcall.getRegistrationFailure();
listener.informRegistrationFailure(client,
ProtoConverter.convertFromObjectIdProto(failure.getObjectId()),
failure.getTransient(),
failure.getMessage());
} else if (upcall.hasReissueRegistrations()) {
ReissueRegistrationsUpcall reissueRegs = upcall.getReissueRegistrations();
listener.reissueRegistrations(client, reissueRegs.getPrefix().toByteArray(),
reissueRegs.getLength());
} else if (upcall.hasError()) {
ErrorUpcall error = upcall.getError();
ErrorInfo errorInfo = ErrorInfo.newInstance(error.getErrorCode(), error.getIsTransient(),
error.getErrorMessage(), null);
listener.informError(client, errorInfo);
} else {
logger.warning("Dropping listener Intent with unknown call: %s", upcall);
}
}
示例6: handleErrorMessage
import com.google.ipc.invalidation.external.client.types.ErrorInfo; //导入方法依赖的package包/类
/** Handles an error message. */
private void handleErrorMessage(ServerMessageHeader header,
ErrorMessage.Code code, String description) {
Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");
// If it is an auth failure, we shut down the ticl.
logger.severe("Received error message: %s, %s, %s", header, code, description);
// Translate the code to error reason.
int reason;
switch (code) {
case AUTH_FAILURE:
reason = ErrorInfo.ErrorReason.AUTH_FAILURE;
break;
case UNKNOWN_FAILURE:
reason = ErrorInfo.ErrorReason.UNKNOWN_FAILURE;
break;
default:
reason = ErrorInfo.ErrorReason.UNKNOWN_FAILURE;
break;
}
// Issue an informError to the application.
ErrorInfo errorInfo = ErrorInfo.newInstance(reason, false, description, null);
listener.informError(this, errorInfo);
// If this is an auth failure, remove registrations and stop the Ticl. Otherwise do nothing.
if (code != ErrorMessage.Code.AUTH_FAILURE) {
return;
}
// If there are any registrations, remove them and issue registration failure.
Collection<ProtoWrapper<ObjectIdP>> desiredRegistrations =
registrationManager.removeRegisteredObjects();
logger.warning("Issuing failure for %s objects", desiredRegistrations.size());
for (ProtoWrapper<ObjectIdP> objectIdWrapper : desiredRegistrations) {
ObjectIdP objectId = objectIdWrapper.getProto();
listener.informRegistrationFailure(this,
ProtoConverter.convertFromObjectIdProto(objectId), false, "Auth error: " + description);
}
}