本文整理汇总了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);
}
}
示例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);
}
}
示例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();
}
}
}
}
示例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);
}
}
}
}
}
示例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);
}
}
示例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);
}
}
示例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();
}
}
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}