• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java InvalidationListener类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.google.ipc.invalidation.external.client.InvalidationListener的典型用法代码示例。如果您正苦于以下问题:Java InvalidationListener类的具体用法?Java InvalidationListener怎么用?Java InvalidationListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



InvalidationListener类属于com.google.ipc.invalidation.external.client包,在下文中一共展示了InvalidationListener类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: onInvalidateUpcall

import com.google.ipc.invalidation.external.client.InvalidationListener; //导入依赖的package包/类
/**
 * Handles an invalidation-related listener {@code upcall} by dispatching to the appropriate
 * method on an instance of {@link InvalidationListener}.
 */
private void onInvalidateUpcall(InvalidateUpcall invalidate, InvalidationListener listener) {
  AckHandle ackHandle = AckHandle.newInstance(invalidate.getAckHandle().getByteArray());
  if (invalidate.getNullableInvalidation() != null) {
    listener.invalidate(client,
        ProtoWrapperConverter.convertFromInvalidationProto(invalidate.getNullableInvalidation()),
        ackHandle);
  } else if (invalidate.hasInvalidateAll()) {
    listener.invalidateAll(client, ackHandle);
  } else if (invalidate.getNullableInvalidateUnknown() != null) {
    listener.invalidateUnknownVersion(client,
        ProtoWrapperConverter.convertFromObjectIdProto(invalidate.getNullableInvalidateUnknown()),
        ackHandle);
  } else {
    throw new RuntimeException("Invalid invalidate upcall: " + invalidate);
  }
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:21,代码来源:AndroidInvalidationListenerIntentMapper.java


示例2: InvalidationClientCore

import com.google.ipc.invalidation.external.client.InvalidationListener; //导入依赖的package包/类
/**
 * Constructs a client.
 *
 * @param resources resources to use during execution
 * @param random a random number generator
 * @param clientType client type code
 * @param clientName application identifier for the client
 * @param config configuration for the client
 * @param applicationName name of the application using the library (for debugging/monitoring)
 * @param regManagerState marshalled registration manager state, if any
 * @param protocolHandlerState marshalled protocol handler state, if any
 * @param listener application callback
 */
private InvalidationClientCore(final SystemResources resources, Random random, int clientType,
    final byte[] clientName, ClientConfigP config, String applicationName,
    RunStateP ticlRunState,
    RegistrationManagerStateP regManagerState,
    ProtocolHandlerState protocolHandlerState,
    StatisticsState statisticsState,
    InvalidationListener listener) {
  this.resources = Preconditions.checkNotNull(resources);
  this.random = random;
  this.logger = Preconditions.checkNotNull(resources.getLogger());
  this.internalScheduler = resources.getInternalScheduler();
  this.storage = resources.getStorage();
  this.config = config;
  this.ticlState = (ticlRunState == null) ? new RunState() : new RunState(ticlRunState);
  this.smearer = new Smearer(random, this.config.getSmearPercent());
  this.applicationClientId = ApplicationClientIdP.create(clientType, new Bytes(clientName));
  this.listener = listener;
  this.statistics = (statisticsState != null)
      ? Statistics.deserializeStatistics(resources.getLogger(), statisticsState.getCounter())
      : new Statistics();
  this.registrationManager = new RegistrationManager(logger, statistics, digestFn,
      regManagerState);
  this.protocolHandler = new ProtocolHandler(config.getProtocolHandlerConfig(), resources,
      smearer, statistics, clientType, applicationName, this, protocolHandlerState);
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:39,代码来源:InvalidationClientCore.java


示例3: onInvalidateUpcall

import com.google.ipc.invalidation.external.client.InvalidationListener; //导入依赖的package包/类
/**
 * Handles an invalidation-related listener {@code upcall} by dispatching to the appropriate
 * method on an instance of {@link #listenerClass}.
 */
private void onInvalidateUpcall(ListenerUpcall upcall, InvalidationListener listener) {
  InvalidateUpcall invalidate = upcall.getInvalidate();
  AckHandle ackHandle = AckHandle.newInstance(invalidate.getAckHandle().toByteArray());
  if (invalidate.hasInvalidation()) {
    listener.invalidate(client,
        ProtoConverter.convertFromInvalidationProto(invalidate.getInvalidation()),
        ackHandle);
  } else if (invalidate.hasInvalidateAll()) {
    listener.invalidateAll(client, ackHandle);
  } else if (invalidate.hasInvalidateUnknown()) {
    listener.invalidateUnknownVersion(client,
        ProtoConverter.convertFromObjectIdProto(invalidate.getInvalidateUnknown()), ackHandle);
  } else {
    throw new RuntimeException("Invalid invalidate upcall: " + invalidate);
  }
}
 
开发者ID:morristech,项目名称:android-chromium,代码行数:21,代码来源:AndroidInvalidationListenerIntentMapper.java


示例4: InvalidationClientCore

import com.google.ipc.invalidation.external.client.InvalidationListener; //导入依赖的package包/类
/**
 * Constructs a client with state initialized from {@code marshalledState}.
 *
 * @param resources resources to use during execution
 * @param random a random number generator
 * @param clientType client type code
 * @param clientName application identifier for the client
 * @param config configuration for the client
 * @param applicationName name of the application using the library (for debugging/monitoring)
 * @param listener application callback
 */
public InvalidationClientCore(final SystemResources resources, Random random, int clientType,
    final byte[] clientName, ClientConfigP config, String applicationName,
    InvalidationClientState marshalledState, InvalidationListener listener) {
  this(resources, random, clientType, clientName, config, applicationName,
      marshalledState.getRunState(), marshalledState.getRegistrationManagerState(),
      marshalledState.getProtocolHandlerState(), marshalledState.getStatisticsState(), listener);
  // Unmarshall.
  if (marshalledState.hasClientToken()) {
    clientToken = marshalledState.getClientToken();
  }
  if (marshalledState.hasNonce()) {
    nonce = marshalledState.getNonce();
  }
  this.shouldSendRegistrations = marshalledState.getShouldSendRegistrations();
  this.lastMessageSendTimeMs = marshalledState.getLastMessageSendTimeMs();
  this.isOnline = marshalledState.getIsOnline();
  createSchedulingTasks(marshalledState);

  // We register with the network after unmarshalling our isOnline value. This is because when
  // we register with the network, it may give us a new value for isOnline. If we unmarshalled
  // after registering, then we would clobber the new value with the old marshalled value, which
  // is wrong.
  registerWithNetwork(resources);
  logger.info("Created client: %s", this);
}
 
开发者ID:morristech,项目名称:android-chromium,代码行数:37,代码来源:InvalidationClientCore.java


示例5: createClient

import com.google.ipc.invalidation.external.client.InvalidationListener; //导入依赖的package包/类
/**
 * Creates a new InvalidationClient instance that the proxy will delegate requests to and listen
 * for events from.
 */
// Overridden by tests to inject mock clients or for listener interception

InvalidationClient createClient(SystemResources resources, int clientType, byte[] clientName,
    String applicationName, InvalidationListener listener, ClientConfigP config) {
  // We always use C2DM, so set the channel-supports-offline-delivery bit on our config.
  final ClientConfigP.Builder configBuilder;
  if (config == null) {
    configBuilder = InvalidationClientCore.createConfig();
  } else {
    configBuilder = ClientConfigP.newBuilder(config);
  }
  configBuilder.setChannelSupportsOfflineDelivery(true);
  config = configBuilder.build();
  Random random = new Random(resources.getInternalScheduler().getCurrentTimeMs());
  return new InvalidationClientImpl(resources, random, clientType, clientName, config,
      applicationName, listener);
}
 
开发者ID:morristech,项目名称:android-chromium,代码行数:22,代码来源:AndroidClientProxy.java


示例6: getListenerClass

import com.google.ipc.invalidation.external.client.InvalidationListener; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private Class<? extends InvalidationListener> getListenerClass() {
  try {
    // Find the listener class that the application wants to use to receive upcalls.
    return (Class<? extends InvalidationListener>)
        Class.forName(new AndroidTiclManifest(this).getListenerClass());
  } catch (ClassNotFoundException exception) {
    throw new RuntimeException("Invalid listener class", exception);
  }
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:11,代码来源:AndroidInvalidationListenerStub.java


示例7: handleRegistrationStatus

import com.google.ipc.invalidation.external.client.InvalidationListener; //导入依赖的package包/类
/** Handles incoming registration statuses. */
private void handleRegistrationStatus(List<RegistrationStatus> regStatusList) {
  Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");
  List<Boolean> localProcessingStatuses =
      registrationManager.handleRegistrationStatus(regStatusList);
  Preconditions.checkState(localProcessingStatuses.size() == regStatusList.size(),
      "Not all registration statuses were processed");

  // Inform app about the success or failure of each registration based
  // on what the registration manager has indicated.
  for (int i = 0; i < regStatusList.size(); ++i) {
    RegistrationStatus regStatus = regStatusList.get(i);
    boolean wasSuccess = localProcessingStatuses.get(i);
    logger.fine("Process reg status: %s", regStatus);

    ObjectId objectId = ProtoWrapperConverter.convertFromObjectIdProto(
      regStatus.getRegistration().getObjectId());
    if (wasSuccess) {
      // Server operation was both successful and agreed with what the client wanted.
      int regOpType = regStatus.getRegistration().getOpType();
      InvalidationListener.RegistrationState regState = convertOpTypeToRegState(regOpType);
      listener.informRegistrationStatus(InvalidationClientCore.this, objectId, regState);
    } else {
      // Server operation either failed or disagreed with client's intent (e.g., successful
      // unregister, but the client wanted a registration).
      String description = CommonProtos.isSuccess(regStatus.getStatus())
          ? "Registration discrepancy detected" : regStatus.getStatus().getDescription();
      boolean isPermanent = CommonProtos.isPermanentFailure(regStatus.getStatus());
      listener.informRegistrationFailure(InvalidationClientCore.this, objectId, !isPermanent,
          description);
    }
  }
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:34,代码来源:InvalidationClientCore.java


示例8: convertOpTypeToRegState

import com.google.ipc.invalidation.external.client.InvalidationListener; //导入依赖的package包/类
/**
 * Converts an operation type {@code regOpType} to a
 * {@code InvalidationListener.RegistrationState}.
 */
private static InvalidationListener.RegistrationState convertOpTypeToRegState(int regOpType) {
  InvalidationListener.RegistrationState regState =
      regOpType == RegistrationP.OpType.REGISTER ?
          InvalidationListener.RegistrationState.REGISTERED :
            InvalidationListener.RegistrationState.UNREGISTERED;
  return regState;
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:12,代码来源:InvalidationClientCore.java


示例9: CheckingInvalidationListener

import com.google.ipc.invalidation.external.client.InvalidationListener; //导入依赖的package包/类
CheckingInvalidationListener(InvalidationListener delegate, Scheduler internalScheduler,
    Scheduler listenerScheduler, Logger logger) {
  this.delegate = Preconditions.checkNotNull(delegate, "Delegate cannot be null");
  this.internalScheduler = Preconditions.checkNotNull(internalScheduler,
      "Internal scheduler cannot be null");
  this.listenerScheduler = Preconditions.checkNotNull(listenerScheduler,
      "Listener scheduler cannot be null");
  this.logger = Preconditions.checkNotNull(logger, "Logger cannot be null");
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:10,代码来源:CheckingInvalidationListener.java


示例10: InvalidationClientImpl

import com.google.ipc.invalidation.external.client.InvalidationListener; //导入依赖的package包/类
public InvalidationClientImpl(final SystemResources resources, Random random, int clientType,
    final byte[] clientName, ClientConfigP config, String applicationName,
    InvalidationListener listener) {
  super(
      // We will make Storage a SafeStorage after the constructor call. It's not possible to
      // construct a new resources around the existing components and pass that to super(...)
      // because then subsequent calls on the first resources object (e.g., start) would not
      // affect the new resources object that the Ticl would be using.
      resources,

      // Pass basic parameters through unmodified.
      random, clientType, clientName, config, applicationName,

      // Wrap the listener in a CheckingInvalidationListener to enforce appropriate threading.
      new CheckingInvalidationListener(listener,
          resources.getInternalScheduler(), resources.getListenerScheduler(),
          resources.getLogger())
  ); // End super.

  // Make Storage safe.
  this.storage = new SafeStorage(resources.getStorage());
  this.storage.setSystemResources(resources);

  // CheckingInvalidationListener needs the statistics object created by our super() call, so
  // we can't provide it at construction-time (since it hasn't been created yet).
  ((CheckingInvalidationListener) this.listener).setStatistics(statistics);

}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:29,代码来源:InvalidationClientImpl.java


示例11: handleRegistrationStatus

import com.google.ipc.invalidation.external.client.InvalidationListener; //导入依赖的package包/类
/** Handles incoming registration statuses. */
private void handleRegistrationStatus(List<RegistrationStatus> regStatusList) {
  Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");
  List<Boolean> localProcessingStatuses =
      registrationManager.handleRegistrationStatus(regStatusList);
  Preconditions.checkState(localProcessingStatuses.size() == regStatusList.size(),
      "Not all registration statuses were processed");

  // Inform app about the success or failure of each registration based
  // on what the registration manager has indicated.
  for (int i = 0; i < regStatusList.size(); ++i) {
    RegistrationStatus regStatus = regStatusList.get(i);
    boolean wasSuccess = localProcessingStatuses.get(i);
    logger.fine("Process reg status: %s", regStatus);

    ObjectId objectId = ProtoConverter.convertFromObjectIdProto(
      regStatus.getRegistration().getObjectId());
    if (wasSuccess) {
      // Server operation was both successful and agreed with what the client wanted.
      OpType regOpType = regStatus.getRegistration().getOpType();
      InvalidationListener.RegistrationState regState = convertOpTypeToRegState(regOpType);
      listener.informRegistrationStatus(InvalidationClientCore.this, objectId, regState);
    } else {
      // Server operation either failed or disagreed with client's intent (e.g., successful
      // unregister, but the client wanted a registration).
      String description = CommonProtos2.isSuccess(regStatus.getStatus()) ?
          "Registration discrepancy detected" : regStatus.getStatus().getDescription();
      boolean isPermanent = CommonProtos2.isPermanentFailure(regStatus.getStatus());
      listener.informRegistrationFailure(InvalidationClientCore.this, objectId, !isPermanent,
          description);
    }
  }
}
 
开发者ID:morristech,项目名称:android-chromium,代码行数:34,代码来源:InvalidationClientCore.java


示例12: convertOpTypeToRegState

import com.google.ipc.invalidation.external.client.InvalidationListener; //导入依赖的package包/类
/**
 * Converts an operation type {@code regOpType} to a
 * {@code InvalidationListener.RegistrationState}.
 */
private static InvalidationListener.RegistrationState convertOpTypeToRegState(
    RegistrationP.OpType regOpType) {
  InvalidationListener.RegistrationState regState =
      regOpType == RegistrationP.OpType.REGISTER ?
          InvalidationListener.RegistrationState.REGISTERED :
            InvalidationListener.RegistrationState.UNREGISTERED;
  return regState;
}
 
开发者ID:morristech,项目名称:android-chromium,代码行数:13,代码来源:InvalidationClientCore.java


示例13: ready

import com.google.ipc.invalidation.external.client.InvalidationListener; //导入依赖的package包/类
@Override
public void ready(InvalidationClient client) {
  InvalidationListener listener = getListener(client);
  logger.fine("Received READY for %s: %s", getClientKey(client), listener);
  if (listener != null) {
    listener.ready(client);
  }
}
 
开发者ID:morristech,项目名称:android-chromium,代码行数:9,代码来源:InvalidationTestListener.java


示例14: invalidate

import com.google.ipc.invalidation.external.client.InvalidationListener; //导入依赖的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);
  }
}
 
开发者ID:morristech,项目名称:android-chromium,代码行数:10,代码来源:InvalidationTestListener.java


示例15: invalidateUnknownVersion

import com.google.ipc.invalidation.external.client.InvalidationListener; //导入依赖的package包/类
@Override
public void invalidateUnknownVersion(
    InvalidationClient client, ObjectId objectId, AckHandle ackHandle) {
  InvalidationListener listener = getListener(client);
  logger.fine("Received INVALIDATE_UNKNOWN_VERSION for %s: %s", getClientKey(client), listener);
  if (listener != null) {
    listener.invalidateUnknownVersion(client, objectId, ackHandle);
  }
}
 
开发者ID:morristech,项目名称:android-chromium,代码行数:10,代码来源:InvalidationTestListener.java


示例16: invalidateAll

import com.google.ipc.invalidation.external.client.InvalidationListener; //导入依赖的package包/类
@Override
public void invalidateAll(InvalidationClient client, AckHandle ackHandle) {
  InvalidationListener listener = getListener(client);
  logger.fine("Received INVALIDATE_ALL for %s: %s", getClientKey(client), listener);
  if (listener != null) {
    listener.invalidateAll(client, ackHandle);
  }
}
 
开发者ID:morristech,项目名称:android-chromium,代码行数:9,代码来源:InvalidationTestListener.java


示例17: informRegistrationStatus

import com.google.ipc.invalidation.external.client.InvalidationListener; //导入依赖的package包/类
@Override
public void informRegistrationStatus(
    InvalidationClient client, ObjectId objectId, RegistrationState regState) {
  InvalidationListener listener = getListener(client);
  logger.fine("Received INFORM_REGISTRATION_STATUS for %s: %s", getClientKey(client), listener);
  if (listener != null) {
    listener.informRegistrationStatus(client, objectId, regState);
  }
}
 
开发者ID:morristech,项目名称:android-chromium,代码行数:10,代码来源:InvalidationTestListener.java


示例18: informRegistrationFailure

import com.google.ipc.invalidation.external.client.InvalidationListener; //导入依赖的package包/类
@Override
public void informRegistrationFailure(
    InvalidationClient client, ObjectId objectId, boolean isTransient, String errorMessage) {
  InvalidationListener listener = getListener(client);
  logger.fine("Received INFORM_REGISTRATION_FAILURE for %s: %s", getClientKey(client), listener);
  if (listener != null) {
    listener.informRegistrationFailure(client, objectId, isTransient, errorMessage);
  }
}
 
开发者ID:morristech,项目名称:android-chromium,代码行数:10,代码来源:InvalidationTestListener.java


示例19: reissueRegistrations

import com.google.ipc.invalidation.external.client.InvalidationListener; //导入依赖的package包/类
@Override
public void reissueRegistrations(InvalidationClient client, byte[] prefix, int prefixLength) {
  InvalidationListener listener = getListener(client);
  logger.fine("Received REISSUE_REGISTRATIONS for %s: %s", getClientKey(client), listener);
  if (listener != null) {
    listener.reissueRegistrations(client, prefix, prefixLength);
  }
}
 
开发者ID:morristech,项目名称:android-chromium,代码行数:9,代码来源:InvalidationTestListener.java


示例20: informError

import com.google.ipc.invalidation.external.client.InvalidationListener; //导入依赖的package包/类
@Override
public void informError(InvalidationClient client, ErrorInfo errorInfo) {
  InvalidationListener listener = getListener(client);
  logger.fine("Received INFORM_ERROR for %s: %s", getClientKey(client), listener);
  if (listener != null) {
    listener.informError(client, errorInfo);
  }
}
 
开发者ID:morristech,项目名称:android-chromium,代码行数:9,代码来源:InvalidationTestListener.java



注:本文中的com.google.ipc.invalidation.external.client.InvalidationListener类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Github类代码示例发布时间:2022-05-23
下一篇:
Java X509CertificateCredential类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap