This is an automated email from the ASF dual-hosted git repository.

liubao pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/incubator-servicecomb-java-chassis.git


The following commit(s) were added to refs/heads/master by this push:
     new dfb7d35  [SCB-477] sdk guava's version need to update to 19.0
dfb7d35 is described below

commit dfb7d3577a789305ce3c053e323d0ec54a825d55
Author: weichao666 <weicha...@huawei.com>
AuthorDate: Thu Apr 12 10:45:07 2018 +0800

    [SCB-477] sdk guava's version need to update to 19.0
---
 .../com/google/common/eventbus/SimpleEventBus.java | 86 ----------------------
 .../foundation/common/event/EventManager.java      |  3 +-
 .../{TestSimpleEventBus.java => TestEventBus.java} | 10 +--
 java-chassis-dependencies/pom.xml                  |  2 +-
 java-chassis-distribution/src/release/LICENSE      |  2 +-
 5 files changed, 5 insertions(+), 98 deletions(-)

diff --git 
a/foundations/foundation-common/src/main/java/com/google/common/eventbus/SimpleEventBus.java
 
b/foundations/foundation-common/src/main/java/com/google/common/eventbus/SimpleEventBus.java
deleted file mode 100644
index 55c3708..0000000
--- 
a/foundations/foundation-common/src/main/java/com/google/common/eventbus/SimpleEventBus.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.google.common.eventbus;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-import org.apache.servicecomb.foundation.common.concurrent.ConcurrentHashMapEx;
-
-import com.google.common.collect.Multimap;
-
-/**
- * <p>EventBus has performance problem, we create a new simpler eventBus
- * 
- * <p>extend from EventBus is not necessary<br>
- * but EventManager has a public EventBus field, we need to make compatible
- * 
- * <p>different between this class and EventBus:<br>
- * 1. not support cycle trigger:<br>
- *   subscribe a, when handle a, trigger event b<br>
- *   subscribe b, when handle b, trigger event a
- */
-public class SimpleEventBus extends com.google.common.eventbus.EventBus {
-  private AnnotatedSubscriberFinder finder = new AnnotatedSubscriberFinder();
-
-  // key is event type
-  // value is CopyOnWriteArrayList
-  private Map<Class<?>, List<EventSubscriber>> subscribersByType = new 
ConcurrentHashMapEx<>();
-
-  @Override
-  public void register(Object listener) {
-    Multimap<Class<?>, EventSubscriber> methodsInListener = 
finder.findAllSubscribers(listener);
-
-    for (Entry<Class<?>, Collection<EventSubscriber>> entry : 
methodsInListener.asMap().entrySet()) {
-      List<EventSubscriber> exists = 
subscribersByType.computeIfAbsent(entry.getKey(), cls -> {
-        return new CopyOnWriteArrayList<>();
-      });
-      exists.addAll(entry.getValue());
-    }
-  }
-
-  @Override
-  public void unregister(Object listener) {
-    Multimap<Class<?>, EventSubscriber> methodsInListener = 
finder.findAllSubscribers(listener);
-
-    for (Entry<Class<?>, Collection<EventSubscriber>> entry : 
methodsInListener.asMap().entrySet()) {
-      List<EventSubscriber> exists = subscribersByType.get(entry.getKey());
-      if (exists == null) {
-        continue;
-      }
-
-      exists.removeAll(entry.getValue());
-    }
-  }
-
-  @Override
-  public void post(Object event) {
-    Set<Class<?>> dispatchTypes = flattenHierarchy(event.getClass());
-    for (Class<?> dispatchType : dispatchTypes) {
-      List<EventSubscriber> subscribers = 
subscribersByType.getOrDefault(dispatchType, Collections.emptyList());
-
-      for (EventSubscriber subscriber : subscribers) {
-        dispatch(event, subscriber);
-      }
-    }
-  }
-}
diff --git 
a/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/event/EventManager.java
 
b/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/event/EventManager.java
index 9672a92..cb72a21 100644
--- 
a/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/event/EventManager.java
+++ 
b/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/event/EventManager.java
@@ -18,14 +18,13 @@
 package org.apache.servicecomb.foundation.common.event;
 
 import com.google.common.eventbus.EventBus;
-import com.google.common.eventbus.SimpleEventBus;
 
 /**
  * EventManager for chassis events
  *
  */
 public class EventManager {
-  public static EventBus eventBus = new SimpleEventBus();
+  public static EventBus eventBus = new EventBus();
 
   public static EventBus getEventBus() {
     return eventBus;
diff --git 
a/foundations/foundation-common/src/test/java/com/google/common/eventbus/TestSimpleEventBus.java
 
b/foundations/foundation-common/src/test/java/com/google/common/eventbus/TestEventBus.java
similarity index 90%
rename from 
foundations/foundation-common/src/test/java/com/google/common/eventbus/TestSimpleEventBus.java
rename to 
foundations/foundation-common/src/test/java/com/google/common/eventbus/TestEventBus.java
index 8aef0cb..8e2231a 100644
--- 
a/foundations/foundation-common/src/test/java/com/google/common/eventbus/TestSimpleEventBus.java
+++ 
b/foundations/foundation-common/src/test/java/com/google/common/eventbus/TestEventBus.java
@@ -23,8 +23,8 @@ import org.hamcrest.Matchers;
 import org.junit.Assert;
 import org.junit.Test;
 
-public class TestSimpleEventBus {
-  private SimpleEventBus eventBus = new SimpleEventBus();
+public class TestEventBus {
+  private EventBus eventBus = new EventBus();
 
   private List<Object> events = new ArrayList<>();
 
@@ -45,14 +45,8 @@ public class TestSimpleEventBus {
   public void unregister() {
     Object obj = new SubscriberForTest();
 
-    // unregister not exist obj, should no problem
-    eventBus.unregister(obj);
-
     eventBus.register(obj);
     eventBus.unregister(obj);
-
-    // unregister again, should no problem
-    eventBus.unregister(obj);
   }
 
   @Test
diff --git a/java-chassis-dependencies/pom.xml 
b/java-chassis-dependencies/pom.xml
index f01ec11..02af808 100644
--- a/java-chassis-dependencies/pom.xml
+++ b/java-chassis-dependencies/pom.xml
@@ -179,7 +179,7 @@
       <dependency>
         <groupId>com.google.guava</groupId>
         <artifactId>guava</artifactId>
-        <version>16.0.1</version>
+        <version>19.0</version>
       </dependency>
 
       <dependency>
diff --git a/java-chassis-distribution/src/release/LICENSE 
b/java-chassis-distribution/src/release/LICENSE
index 3947079..d4933ba 100644
--- a/java-chassis-distribution/src/release/LICENSE
+++ b/java-chassis-distribution/src/release/LICENSE
@@ -345,7 +345,7 @@ ClassMate (http://github.com/cowtowncoder/java-classmate) 
com.fasterxml:classmat
 Commons IO (http://commons.apache.org/io/) commons-io:commons-io:jar:2.4
 Commons Lang (http://commons.apache.org/lang/) 
commons-lang:commons-lang:jar:2.6
 FindBugs-jsr305 (http://findbugs.sourceforge.net/) 
com.google.code.findbugs:jsr305:jar:3.0.1
-Guava: Google Core Libraries for Java 
(http://code.google.com/p/guava-libraries/guava) 
com.google.guava:guava:bundle:16.0.1
+Guava: Google Core Libraries for Java 
(http://code.google.com/p/guava-libraries/guava) 
com.google.guava:guava:bundle:19.0
 Hibernate Validator Engine 
(http://hibernate.org/validator/hibernate-validator) 
org.hibernate:hibernate-validator:jar:5.2.4.Final
 JBoss Logging 3 (http://www.jboss.org) 
org.jboss.logging:jboss-logging:jar:3.3.0.Final
 Jackson dataformat: CBOR 
(http://github.com/FasterXML/jackson-dataformats-binary) 
com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:bundle:2.8.7

-- 
To stop receiving notification emails like this one, please contact
liu...@apache.org.

Reply via email to