当前位置: 首页>>代码示例>>Java>>正文


Java AllowConcurrentEvents类代码示例

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


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

示例1: on

import com.google.common.eventbus.AllowConcurrentEvents; //导入依赖的package包/类
/**
 * 监听链接关闭事件,清理失效的路由
 *
 * @param event
 */
@Subscribe
@AllowConcurrentEvents
void on(ConnectionCloseEvent event) {
    Connection connection = event.connection;
    if (connection == null) return;
    SessionContext context = connection.getSessionContext();
    String userId = context.userId;
    if (userId == null) return;
    String key = CacheKeys.getUserRouteKey(userId);
    String field = Integer.toString(context.getClientType());
    ClientLocation location = cacheManager.hget(key, field, ClientLocation.class);
    if (location == null || location.isOffline()) return;

    String connId = connection.getId();
    //2.检测下,是否是同一个链接, 如果客户端重连,老的路由会被新的链接覆盖
    if (connId.equals(location.getConnId())) {
        cacheManager.hset(key, field, location.offline());
        LOGGER.info("clean disconnected remote route, userId={}, route={}", userId, location);
    } else {
        LOGGER.info("clean disconnected remote route, not clean:userId={}, route={}", userId, location);
    }
}
 
开发者ID:mpusher,项目名称:mpush,代码行数:28,代码来源:RemoteRouterManager.java

示例2: on

import com.google.common.eventbus.AllowConcurrentEvents; //导入依赖的package包/类
/**
 * 监听链接关闭事件,清理失效的路由
 *
 * @param event
 */
@Subscribe
@AllowConcurrentEvents
void on(ConnectionCloseEvent event) {
    Connection connection = event.connection;
    if (connection == null) return;
    SessionContext context = connection.getSessionContext();

    String userId = context.userId;
    if (userId == null) return;

    EventBus.post(new UserOfflineEvent(event.connection, userId));
    int clientType = context.getClientType();
    LocalRouter localRouter = routers.getOrDefault(userId, EMPTY).get(clientType);
    if (localRouter == null) return;

    String connId = connection.getId();
    //2.检测下,是否是同一个链接, 如果客户端重连,老的路由会被新的链接覆盖
    if (connId.equals(localRouter.getRouteValue().getId())) {
        //3.删除路由
        routers.getOrDefault(userId, EMPTY).remove(clientType);
        LOGGER.info("clean disconnected local route, userId={}, route={}", userId, localRouter);
    } else { //如果不相等,则log一下
        LOGGER.info("clean disconnected local route, not clean:userId={}, route={}", userId, localRouter);
    }
}
 
开发者ID:mpusher,项目名称:mpush,代码行数:31,代码来源:LocalRouterManager.java

示例3: on

import com.google.common.eventbus.AllowConcurrentEvents; //导入依赖的package包/类
@Subscribe
@AllowConcurrentEvents
public void on(final AssetEvent event) {
  // only make DB changes on the originating node, as orient will also replicate those for us
  if (event.isLocal() && member(event.getRepositoryName()) && event.getComponentId() == null) {
    final String path = event.getAsset().name();
    final MavenPath mavenPath = mavenFacet.getMavenPathParser().parsePath(path);
    // group deletes path + path.hashes, but it should do only on content change in member
    if (!mavenPath.isHash()) {
      UnitOfWork.begin(getRepository().facet(StorageFacet.class).txSupplier());
      try {
        evictCache(mavenPath);
      }
      catch (IOException e) {
        log.warn("Could not evict merged content from {} cache at {}", getRepository().getName(),
            mavenPath.getPath(), e);
      }
      finally {
        UnitOfWork.end();
      }
    }
  }
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:24,代码来源:MavenGroupFacet.java

示例4: handle

import com.google.common.eventbus.AllowConcurrentEvents; //导入依赖的package包/类
@AllowConcurrentEvents
@Subscribe
public void handle(final CapabilityEvent.BeforeUpdate event) {
  if (event.getReference().context().id().equals(id)) {
    if (propertyNames == null) {
      setSatisfied(false);
    }
    else {
      for (final String propertyName : propertyNames) {
        String oldValue = event.properties().get(propertyName);
        if (oldValue == null) {
          oldValue = "";
        }
        String newValue = event.previousProperties().get(propertyName);
        if (newValue == null) {
          newValue = "";
        }
        if (isSatisfied() && !oldValue.equals(newValue)) {
          setSatisfied(false);
        }
      }
    }
  }
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:25,代码来源:PassivateCapabilityDuringUpdateCondition.java

示例5: on

import com.google.common.eventbus.AllowConcurrentEvents; //导入依赖的package包/类
@Subscribe
@AllowConcurrentEvents
public void on(final RepositoryEvent event) {
  if (isRecording()) {
    Repository repository = event.getRepository();
    AuditData data = new AuditData();
    data.setDomain(DOMAIN);
    data.setType(type(event.getClass()));
    data.setContext(repository.getName());

    Map<String, String> attributes = data.getAttributes();
    attributes.put("name", repository.getName());
    attributes.put("type", repository.getType().getValue());
    attributes.put("format", repository.getFormat().getValue());

    record(data);
  }
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:19,代码来源:RepositoryAuditor.java

示例6: on

import com.google.common.eventbus.AllowConcurrentEvents; //导入依赖的package包/类
@Subscribe
@AllowConcurrentEvents
public void on(final BlobStoreEvent event) {
  if (isRecording()) {
    BlobStore blobStore = event.getBlobStore();
    BlobStoreConfiguration configuration = blobStore.getBlobStoreConfiguration();

    AuditData data = new AuditData();
    data.setDomain(DOMAIN);
    data.setType(type(event.getClass()));
    data.setContext(configuration.getName());

    Map<String, String> attributes = data.getAttributes();
    attributes.put("name", configuration.getName());
    attributes.put("type", configuration.getType());

    record(data);
  }
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:20,代码来源:BlobStoreAuditor.java

示例7: handle

import com.google.common.eventbus.AllowConcurrentEvents; //导入依赖的package包/类
@AllowConcurrentEvents
@Subscribe
public void handle(final CapabilityEvent.AfterUpdate event) {
  if (event.getReference().context().id().equals(capabilityIdentity)) {
    if (!sameRepositoryAs(repositoryBeforeLastUpdate)) {
      try {
        bindLock.writeLock().lock();
        for (final Repository repository : repositoryManager.browse()) {
          handle(new RepositoryCreatedEvent(repository));
        }
      }
      finally {
        bindLock.writeLock().unlock();
      }
    }
  }
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:18,代码来源:RepositoryConditionSupport.java

示例8: on

import com.google.common.eventbus.AllowConcurrentEvents; //导入依赖的package包/类
@Subscribe
@AllowConcurrentEvents
public void on(final ComponentEvent event) {
  if (isRecording() && event.isLocal()) {
    Component component = event.getComponent();

    AuditData data = new AuditData();
    data.setDomain(DOMAIN);
    data.setType(type(event.getClass()));
    data.setContext(component.name());

    Map<String, String> attributes = data.getAttributes();
    attributes.put("repository.name", event.getRepositoryName());
    attributes.put("format", component.format());
    attributes.put("name", component.name());
    attributes.put("group", component.group());
    attributes.put("version", component.version());

    record(data);
  }
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:22,代码来源:ComponentAuditor.java

示例9: on

import com.google.common.eventbus.AllowConcurrentEvents; //导入依赖的package包/类
@Subscribe
@AllowConcurrentEvents
public void on(final AssetEvent event) {
  if (isRecording() && event.isLocal()) {
    Asset asset = event.getAsset();

    AuditData data = new AuditData();
    data.setDomain(DOMAIN);
    data.setType(type(event.getClass()));
    data.setContext(asset.name());

    Map<String, String> attributes = data.getAttributes();
    attributes.put("repository.name", event.getRepositoryName());
    attributes.put("format", asset.format());
    attributes.put("name", asset.name());

    record(data);
  }
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:20,代码来源:AssetAuditor.java

示例10: on

import com.google.common.eventbus.AllowConcurrentEvents; //导入依赖的package包/类
@Subscribe
@AllowConcurrentEvents
public void on(final AnonymousConfigurationChangedEvent event) {
  if (isRecording()) {
    AnonymousConfiguration configuration = event.getConfiguration();

    AuditData data = new AuditData();
    data.setDomain(DOMAIN);
    data.setType(CHANGED_TYPE);
    data.setContext(SYSTEM_CONTEXT);

    Map<String, String> attributes = data.getAttributes();
    attributes.put("enabled", string(configuration.isEnabled()));
    attributes.put("userId", configuration.getUserId());
    attributes.put("realm", configuration.getRealmName());

    record(data);
  }
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:20,代码来源:AnonymousAuditor.java

示例11: on

import com.google.common.eventbus.AllowConcurrentEvents; //导入依赖的package包/类
@Subscribe
@AllowConcurrentEvents
public void on(final UserRoleMappingEvent event) {
  if (isRecording()) {
    AuditData data = new AuditData();
    data.setDomain(DOMAIN);
    data.setType(type(event.getClass()));
    data.setContext(event.getUserId());

    Map<String, String> attributes = data.getAttributes();
    attributes.put("id", event.getUserId());
    attributes.put("source", event.getUserSource());
    attributes.put("roles", string(event.getRoles()));

    record(data);
  }
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:18,代码来源:UserRoleMappingAuditor.java

示例12: on

import com.google.common.eventbus.AllowConcurrentEvents; //导入依赖的package包/类
@Subscribe
@AllowConcurrentEvents
public void on(final RealmConfigurationChangedEvent event) {
  if (isRecording()) {
    RealmConfiguration configuration = event.getConfiguration();

    AuditData data = new AuditData();
    data.setDomain(DOMAIN);
    data.setType(CHANGED_TYPE);
    data.setContext(SYSTEM_CONTEXT);

    Map<String, String> attributes = data.getAttributes();
    attributes.put("realms", string(configuration.getRealmNames()));

    record(data);
  }
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:18,代码来源:RealmAuditor.java

示例13: on

import com.google.common.eventbus.AllowConcurrentEvents; //导入依赖的package包/类
@Subscribe
@AllowConcurrentEvents
public void on(final RoleEvent event) {
  if (isRecording()) {
    Role role = event.getRole();

    AuditData data = new AuditData();
    data.setDomain(DOMAIN);
    data.setType(type(event.getClass()));
    data.setContext(role.getRoleId());

    Map<String, String> attributes = data.getAttributes();
    attributes.put("id", role.getRoleId());
    attributes.put("name", role.getName());
    attributes.put("source", role.getSource());
    attributes.put("roles", string(role.getRoles()));
    attributes.put("privileges", string(role.getPrivileges()));

    record(data);
  }
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:22,代码来源:RoleAuditor.java

示例14: on

import com.google.common.eventbus.AllowConcurrentEvents; //导入依赖的package包/类
@Subscribe
@AllowConcurrentEvents
public void on(final UserEvent event) {
  if (isRecording()) {
    User user = event.getUser();

    AuditData data = new AuditData();
    data.setDomain(DOMAIN);
    data.setType(type(event.getClass()));
    data.setContext(user.getUserId());

    Map<String, String> attributes = data.getAttributes();
    attributes.put("id", user.getUserId());
    attributes.put("name", user.getName());
    attributes.put("email", user.getEmailAddress());
    attributes.put("source", user.getSource());
    attributes.put("status", user.getStatus().name());
    attributes.put("roles", roles(user));

    record(data);
  }
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:23,代码来源:UserAuditor.java

示例15: on

import com.google.common.eventbus.AllowConcurrentEvents; //导入依赖的package包/类
@Subscribe
@AllowConcurrentEvents
public void on(final PrivilegeEvent event) {
  if (isRecording()) {
    Privilege privilege = event.getPrivilege();

    AuditData data = new AuditData();
    data.setDomain(DOMAIN);
    data.setType(type(event.getClass()));
    data.setContext(privilege.getId());

    Map<String, String> attributes = data.getAttributes();
    attributes.put("id", privilege.getId());
    attributes.put("name", privilege.getName());
    attributes.put("type", privilege.getType());

    for (Entry<String,String> entry : privilege.getProperties().entrySet()) {
      attributes.put("property." + entry.getKey(), entry.getValue());
    }

    record(data);
  }
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:24,代码来源:PrivilegeAuditor.java


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