From 0807761cf3a81ae16c321ad7240e988bf9439693 Mon Sep 17 00:00:00 2001 From: xiuyuhang <442367943@qq.com> Date: Wed, 10 Jan 2018 16:26:29 +0800 Subject: [PATCH 01/21] =?UTF-8?q?SerializerFactory=20=E8=8E=B7=E5=8F=96Ser?= =?UTF-8?q?ializer=E6=97=B6=EF=BC=8C=E9=94=81=E4=BD=8F=E6=95=B4=E4=B8=AAha?= =?UTF-8?q?shmap=EF=BC=8C=E5=AF=BC=E8=87=B4=E6=95=B4=E4=B8=AA=E8=BF=87?= =?UTF-8?q?=E7=A8=8B=E8=A2=ABblock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../caucho/hessian/io/SerializerFactory.java | 76 ++++++++----------- 1 file changed, 31 insertions(+), 45 deletions(-) diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/SerializerFactory.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/SerializerFactory.java index 972143ae90e..72ebcc340ac 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/SerializerFactory.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/SerializerFactory.java @@ -79,6 +79,7 @@ import java.util.Iterator; import java.util.Locale; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -226,9 +227,9 @@ public class SerializerFactory extends AbstractSerializerFactory { private ClassLoader _loader; private Deserializer _hashMapDeserializer; private Deserializer _arrayListDeserializer; - private HashMap _cachedSerializerMap; - private HashMap _cachedDeserializerMap; - private HashMap _cachedTypeDeserializerMap; + private ConcurrentHashMap _cachedSerializerMap; + private ConcurrentHashMap _cachedDeserializerMap; + private ConcurrentHashMap _cachedTypeDeserializerMap; private boolean _isAllowNonSerializable; public SerializerFactory() { @@ -293,21 +294,21 @@ public void setAllowNonSerializable(boolean allow) { * @param cl the class of the object that needs to be serialized. * @return a serializer object for the serialization. */ + @Override public Serializer getSerializer(Class cl) throws HessianProtocolException { Serializer serializer; serializer = (Serializer) _staticSerializerMap.get(cl); - if (serializer != null) + if (serializer != null) { return serializer; + } if (_cachedSerializerMap != null) { - synchronized (_cachedSerializerMap) { - serializer = (Serializer) _cachedSerializerMap.get(cl); - } - - if (serializer != null) + serializer = (Serializer) _cachedSerializerMap.get(cl); + if (serializer != null) { return serializer; + } } for (int i = 0; @@ -346,40 +347,34 @@ else if (Map.class.isAssignableFrom(cl)) { } serializer = _collectionSerializer; - } else if (cl.isArray()) + } else if (cl.isArray()) { serializer = new ArraySerializer(); - - else if (Throwable.class.isAssignableFrom(cl)) + } else if (Throwable.class.isAssignableFrom(cl)) { serializer = new ThrowableSerializer(cl, getClassLoader()); - - else if (InputStream.class.isAssignableFrom(cl)) + } else if (InputStream.class.isAssignableFrom(cl)) { serializer = new InputStreamSerializer(); - - else if (Iterator.class.isAssignableFrom(cl)) + } else if (Iterator.class.isAssignableFrom(cl)) { serializer = IteratorSerializer.create(); - - else if (Enumeration.class.isAssignableFrom(cl)) + } else if (Enumeration.class.isAssignableFrom(cl)) { serializer = EnumerationSerializer.create(); - - else if (Calendar.class.isAssignableFrom(cl)) + } else if (Calendar.class.isAssignableFrom(cl)) { serializer = CalendarSerializer.create(); - - else if (Locale.class.isAssignableFrom(cl)) + } else if (Locale.class.isAssignableFrom(cl)) { serializer = LocaleSerializer.create(); - - else if (Enum.class.isAssignableFrom(cl)) + } else if (Enum.class.isAssignableFrom(cl)) { serializer = new EnumSerializer(cl); + } - if (serializer == null) + if (serializer == null) { serializer = getDefaultSerializer(cl); + } - if (_cachedSerializerMap == null) - _cachedSerializerMap = new HashMap(8); - - synchronized (_cachedSerializerMap) { - _cachedSerializerMap.put(cl, serializer); + if (_cachedSerializerMap == null) { + _cachedSerializerMap = new ConcurrentHashMap(8); } + _cachedSerializerMap.put(cl, serializer); + return serializer; } @@ -418,10 +413,7 @@ public Deserializer getDeserializer(Class cl) return deserializer; if (_cachedDeserializerMap != null) { - synchronized (_cachedDeserializerMap) { - deserializer = (Deserializer) _cachedDeserializerMap.get(cl); - } - + deserializer = (Deserializer) _cachedDeserializerMap.get(cl); if (deserializer != null) return deserializer; } @@ -462,11 +454,9 @@ else if (Class.class.equals(cl)) deserializer = getDefaultDeserializer(cl); if (_cachedDeserializerMap == null) - _cachedDeserializerMap = new HashMap(8); + _cachedDeserializerMap = new ConcurrentHashMap(8); - synchronized (_cachedDeserializerMap) { - _cachedDeserializerMap.put(cl, deserializer); - } + _cachedDeserializerMap.put(cl, deserializer); return deserializer; } @@ -624,9 +614,7 @@ public Deserializer getDeserializer(String type) Deserializer deserializer; if (_cachedTypeDeserializerMap != null) { - synchronized (_cachedTypeDeserializerMap) { - deserializer = (Deserializer) _cachedTypeDeserializerMap.get(type); - } + deserializer = (Deserializer) _cachedTypeDeserializerMap.get(type); if (deserializer != null) return deserializer; @@ -657,11 +645,9 @@ public Deserializer getDeserializer(String type) if (deserializer != null) { if (_cachedTypeDeserializerMap == null) - _cachedTypeDeserializerMap = new HashMap(8); + _cachedTypeDeserializerMap = new ConcurrentHashMap(8); - synchronized (_cachedTypeDeserializerMap) { - _cachedTypeDeserializerMap.put(type, deserializer); - } + _cachedTypeDeserializerMap.put(type, deserializer); } return deserializer; From 65438b4748cc0da3c40e309f9fa59da6012bef64 Mon Sep 17 00:00:00 2001 From: xiuyuhang <442367943@qq.com> Date: Wed, 10 Jan 2018 19:49:14 +0800 Subject: [PATCH 02/21] =?UTF-8?q?=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E3=80=82=E4=BF=9D=E8=AF=81=E4=B8=80=E4=B8=AAclass=E5=8F=AA?= =?UTF-8?q?=E6=9C=89=E4=B8=80=E4=B8=AAserializer=E5=92=8Cdeserializer?= =?UTF-8?q?=E3=80=82=E5=8D=95=E7=BA=BF=E7=A8=8B=E5=92=8C=E5=A4=9A=E7=BA=BF?= =?UTF-8?q?=E7=A8=8B=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hessian/io/SerializerFactoryTest.java | 86 +++++++++++++++++++ .../com/caucho/hessian/io/TestClass.java | 6 ++ 2 files changed, 92 insertions(+) create mode 100644 hessian-lite/src/test/java/com/alibaba/com/caucho/hessian/io/SerializerFactoryTest.java create mode 100644 hessian-lite/src/test/java/com/alibaba/com/caucho/hessian/io/TestClass.java diff --git a/hessian-lite/src/test/java/com/alibaba/com/caucho/hessian/io/SerializerFactoryTest.java b/hessian-lite/src/test/java/com/alibaba/com/caucho/hessian/io/SerializerFactoryTest.java new file mode 100644 index 00000000000..6fda8a0010c --- /dev/null +++ b/hessian-lite/src/test/java/com/alibaba/com/caucho/hessian/io/SerializerFactoryTest.java @@ -0,0 +1,86 @@ +package com.alibaba.com.caucho.hessian.io; + +import org.junit.Assert; +import org.junit.Test; + +import java.util.concurrent.CountDownLatch; + +public class SerializerFactoryTest { + + private static final int THREADS = 10; + + @Test + public void getSerializer() throws Exception { + final SerializerFactory serializerFactory = new SerializerFactory(); + final Class klass = TestClass.class; + + Serializer s1 = serializerFactory.getSerializer(klass); + Serializer s2 = serializerFactory.getSerializer(klass); + + Assert.assertTrue("several Serializer!", s1 == s2); + } + + @Test + public void getSerializerDuplicateThread() throws Exception { + final SerializerFactory serializerFactory = new SerializerFactory(); + final Class klass = TestClass.class; + final CountDownLatch countDownLatch = new CountDownLatch(THREADS); + + //init into cached map + final Serializer s = serializerFactory.getSerializer(klass); + + //get from duplicate thread + for (int i = 0; i < THREADS; i++) { + new Thread(new Runnable() { + @Override + public void run() { + try { + Assert.assertTrue("serveral Serializer!", s == serializerFactory.getSerializer(klass)); + } catch (HessianProtocolException e) { + e.printStackTrace(); + } + countDownLatch.countDown(); + } + }).start(); + } + countDownLatch.await(); + } + + @Test + public void getDeserializer() throws Exception { + final SerializerFactory serializerFactory = new SerializerFactory(); + final Class klass = TestClass.class; + + Deserializer d1 = serializerFactory.getDeserializer(klass); + Deserializer d2 = serializerFactory.getDeserializer(klass); + + Assert.assertTrue("several Deserializer!", d1 == d2); + } + + @Test + public void getDeserializerDuplicateThread() throws Exception { + final SerializerFactory serializerFactory = new SerializerFactory(); + final Class klass = TestClass.class; + final CountDownLatch countDownLatch = new CountDownLatch(THREADS); + + //init into cached map + final Deserializer s = serializerFactory.getDeserializer(klass); + + //get from duplicate thread + for (int i = 0; i < THREADS; i++) { + new Thread(new Runnable() { + @Override + public void run() { + try { + Assert.assertTrue("serveral Deserializer!", s == serializerFactory.getDeserializer(klass)); + } catch (HessianProtocolException e) { + e.printStackTrace(); + } + countDownLatch.countDown(); + } + }).start(); + } + countDownLatch.await(); + } + +} \ No newline at end of file diff --git a/hessian-lite/src/test/java/com/alibaba/com/caucho/hessian/io/TestClass.java b/hessian-lite/src/test/java/com/alibaba/com/caucho/hessian/io/TestClass.java new file mode 100644 index 00000000000..cba9b8fea4a --- /dev/null +++ b/hessian-lite/src/test/java/com/alibaba/com/caucho/hessian/io/TestClass.java @@ -0,0 +1,6 @@ +package com.alibaba.com.caucho.hessian.io; + +import java.io.Serializable; + +public class TestClass implements Serializable { +} From 7291963cd359073b04034d78603d0630853ce312 Mon Sep 17 00:00:00 2001 From: xiuyuhang <442367943@qq.com> Date: Wed, 10 Jan 2018 19:50:02 +0800 Subject: [PATCH 03/21] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BA=BF=E7=A8=8B?= =?UTF-8?q?=E6=95=B0=2050=20=E6=A8=A1=E6=8B=9F=E5=A4=9A=E4=B8=AA=E7=BA=BF?= =?UTF-8?q?=E7=A8=8B=E6=9D=A5=E8=8E=B7=E5=8F=96serializer=E5=92=8Cdeserial?= =?UTF-8?q?izer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../alibaba/com/caucho/hessian/io/SerializerFactoryTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hessian-lite/src/test/java/com/alibaba/com/caucho/hessian/io/SerializerFactoryTest.java b/hessian-lite/src/test/java/com/alibaba/com/caucho/hessian/io/SerializerFactoryTest.java index 6fda8a0010c..b9c21e301c6 100644 --- a/hessian-lite/src/test/java/com/alibaba/com/caucho/hessian/io/SerializerFactoryTest.java +++ b/hessian-lite/src/test/java/com/alibaba/com/caucho/hessian/io/SerializerFactoryTest.java @@ -7,7 +7,7 @@ public class SerializerFactoryTest { - private static final int THREADS = 10; + private static final int THREADS = 50; @Test public void getSerializer() throws Exception { From ed2ff0f1fface99c1347e7bcaf627bdc8275d191 Mon Sep 17 00:00:00 2001 From: xiuyuhang <442367943@qq.com> Date: Thu, 11 Jan 2018 14:22:55 +0800 Subject: [PATCH 04/21] =?UTF-8?q?=E5=BD=93cores=E7=BA=BF=E7=A8=8B=E6=95=B0?= =?UTF-8?q?=E5=85=A8=E9=83=BD=E4=BD=BF=E7=94=A8=E7=9A=84=E6=83=85=E5=86=B5?= =?UTF-8?q?=E4=B8=8B=EF=BC=8C=E9=BB=98=E8=AE=A4=E7=BA=BF=E7=A8=8B=E6=B1=A0?= =?UTF-8?q?=E4=BC=9A=E6=8A=8A=E4=BB=BB=E5=8A=A1=E6=94=BE=E5=85=A5=E5=88=B0?= =?UTF-8?q?=E9=98=9F=E5=88=97=E4=B8=AD=E3=80=82=E9=98=9F=E5=88=97=E6=BB=A1?= =?UTF-8?q?=E5=88=99=E5=86=8D=E5=88=9B=E5=BB=BA=E7=BA=BF=E7=A8=8B=EF=BC=88?= =?UTF-8?q?=E6=80=BB=E6=95=B0=E4=B8=8D=E4=BC=9A=E8=B6=85=E8=BF=87Max?= =?UTF-8?q?=E7=BA=BF=E7=A8=8B=E6=95=B0=EF=BC=89=20=E5=A2=9E=E5=BC=BA?= =?UTF-8?q?=E7=BA=BF=E7=A8=8B=E6=B1=A0=EF=BC=9A=E5=9C=A8=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E9=87=8F=E9=98=B6=E6=AE=B5=E6=80=A7=E5=87=BA=E7=8E=B0=E9=AB=98?= =?UTF-8?q?=E5=B3=B0=E6=97=B6=E4=BD=BF=E7=94=A8=20=E7=89=B9=E6=80=A7?= =?UTF-8?q?=EF=BC=9Acores=E7=BA=BF=E7=A8=8B=E5=85=A8=E9=83=A8=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E7=9A=84=E6=83=85=E5=86=B5=E4=B8=8B=EF=BC=8C=E4=BC=98?= =?UTF-8?q?=E5=85=88=E5=88=9B=E5=BB=BA=E7=BA=BF=E7=A8=8B=EF=BC=88=E6=80=BB?= =?UTF-8?q?=E6=95=B0=E4=B8=8D=E4=BC=9A=E8=B6=85=E8=BF=87max=EF=BC=89?= =?UTF-8?q?=EF=BC=8C=E5=BD=93max=E4=B8=AA=E7=BA=BF=E7=A8=8B=E5=85=A8?= =?UTF-8?q?=E9=83=BD=E5=9C=A8=E5=BF=99=E7=9A=84=E6=83=85=E5=86=B5=E4=B8=8B?= =?UTF-8?q?=EF=BC=8C=E6=89=8D=E5=B0=86=E4=BB=BB=E5=8A=A1=E6=94=BE=E5=85=A5?= =?UTF-8?q?=E9=98=9F=E5=88=97=E3=80=82=E8=AF=B7=E6=B1=82=E9=87=8F=E4=B8=8B?= =?UTF-8?q?=E9=99=8D=E6=97=B6=EF=BC=8C=E7=BA=BF=E7=A8=8B=E6=B1=A0=E4=BC=9A?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E7=BB=B4=E6=8C=81cores=E4=B8=AA=E7=BA=BF?= =?UTF-8?q?=E7=A8=8B=EF=BC=8C=E5=A4=9A=E4=BD=99=E7=9A=84=E7=BA=BF=E7=A8=8B?= =?UTF-8?q?=E9=80=80=E5=87=BA=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../support/enhanced/EnhancedTaskQueue.java | 73 +++++++++++++++++++ .../support/enhanced/EnhancedThreadPool.java | 32 ++++++++ .../enhanced/EnhancedThreadPoolExecutor.java | 45 ++++++++++++ ...alibaba.dubbo.common.threadpool.ThreadPool | 1 + .../enhanced/EnhancedThreadPoolTest.java | 68 +++++++++++++++++ 5 files changed, 219 insertions(+) create mode 100644 dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/enhanced/EnhancedTaskQueue.java create mode 100644 dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/enhanced/EnhancedThreadPool.java create mode 100644 dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/enhanced/EnhancedThreadPoolExecutor.java create mode 100644 dubbo-common/src/test/java/com/alibaba/dubbo/common/threadpool/support/enhanced/EnhancedThreadPoolTest.java diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/enhanced/EnhancedTaskQueue.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/enhanced/EnhancedTaskQueue.java new file mode 100644 index 00000000000..437e988fc3f --- /dev/null +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/enhanced/EnhancedTaskQueue.java @@ -0,0 +1,73 @@ +package com.alibaba.dubbo.common.threadpool.support.enhanced; + +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.RejectedExecutionException; + +/** + * enhanced task queue + */ +public class EnhancedTaskQueue extends LinkedBlockingQueue { + + private static final long serialVersionUID = -2635853580887179627L; + + private EnhancedThreadPoolExecutor executor; + + public EnhancedTaskQueue(int capacity) { + super(capacity); + } + + public void setExecutor(EnhancedThreadPoolExecutor exec) { + executor = exec; + } + + @Override + public boolean offer(Runnable runnable) { + if (executor == null) { + throw new RejectedExecutionException("enhanced queue does not have executor !"); + } + int currentPoolThreadSize = executor.getPoolSize(); + //have free worker. put task into queue to let the worker deal with task. + if (executor.getSubmittedTaskCount() < currentPoolThreadSize) { + return super.offer(runnable); + } + + // return false to let executor create new worker. + if (currentPoolThreadSize < executor.getMaximumPoolSize()) { + return false; + } + + //currentPoolThreadSize >= max + return super.offer(runnable); + +// int currentPoolThreadSize = executor.getPoolSize(); +// //如果线程池里的线程数量已经到达最大,将任务添加到队列中 +// if (currentPoolThreadSize == executor.getMaximumPoolSize()) { +// return super.offer(runnable); +// } +// //说明有空闲的线程,这个时候无需创建core线程之外的线程,而是把任务直接丢到队列里即可 +// if (executor.getSubmittedTaskCount() < currentPoolThreadSize) { +// return super.offer(runnable); +// } +// +// //如果线程池里的线程数量还没有到达最大,直接创建线程,而不是把任务丢到队列里面 +// if (currentPoolThreadSize < executor.getMaximumPoolSize()) { +// return false; +// } +// +// return super.offer(runnable); + } + + /** + * retry offer task + * + * @param o task + * @return offer success or not + * @throws RejectedExecutionException if executor is terminated. + */ + public boolean retryOffer(Runnable o) { + if (executor.isShutdown()) { + throw new RejectedExecutionException("Executor is shutdown !"); + } + return super.offer(o); + } +} \ No newline at end of file diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/enhanced/EnhancedThreadPool.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/enhanced/EnhancedThreadPool.java new file mode 100644 index 00000000000..e9285797113 --- /dev/null +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/enhanced/EnhancedThreadPool.java @@ -0,0 +1,32 @@ +package com.alibaba.dubbo.common.threadpool.support.enhanced; + +import com.alibaba.dubbo.common.Constants; +import com.alibaba.dubbo.common.URL; +import com.alibaba.dubbo.common.threadpool.ThreadPool; +import com.alibaba.dubbo.common.threadpool.support.AbortPolicyWithReport; +import com.alibaba.dubbo.common.utils.NamedThreadFactory; + +import java.util.concurrent.*; + +/** + * enhanced thread pool. + * When the core threads are all in busy , create new thread instead of putting task into blocking queue . + */ +public class EnhancedThreadPool implements ThreadPool { + + @Override + public Executor getExecutor(URL url) { + String name = url.getParameter(Constants.THREAD_NAME_KEY, Constants.DEFAULT_THREAD_NAME); + int cores = url.getParameter(Constants.CORE_THREADS_KEY, Constants.DEFAULT_CORE_THREADS); + int threads = url.getParameter(Constants.THREADS_KEY, Integer.MAX_VALUE); + int queues = url.getParameter(Constants.QUEUES_KEY, Constants.DEFAULT_QUEUES); + int alive = url.getParameter(Constants.ALIVE_KEY, Constants.DEFAULT_ALIVE); + + //init queue and enhanced executor + EnhancedTaskQueue enhancedTaskQueue = new EnhancedTaskQueue(queues <= 0 ? 1 : queues); + EnhancedThreadPoolExecutor executor = new EnhancedThreadPoolExecutor(cores, threads, alive, TimeUnit.MILLISECONDS, enhancedTaskQueue, + new NamedThreadFactory(name, true), new AbortPolicyWithReport(name, url)); + enhancedTaskQueue.setExecutor(executor); + return executor; + } +} diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/enhanced/EnhancedThreadPoolExecutor.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/enhanced/EnhancedThreadPoolExecutor.java new file mode 100644 index 00000000000..f19f162e7ec --- /dev/null +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/enhanced/EnhancedThreadPoolExecutor.java @@ -0,0 +1,45 @@ +package com.alibaba.dubbo.common.threadpool.support.enhanced; + +import java.util.concurrent.*; +import java.util.concurrent.atomic.AtomicInteger; + +/** + * Enhanced thread pool + */ +public class EnhancedThreadPoolExecutor extends ThreadPoolExecutor { + + //task count + private final AtomicInteger submittedTaskCount = new AtomicInteger(0); + + public EnhancedThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, EnhancedTaskQueue workQueue, ThreadFactory threadFactory, RejectedExecutionHandler handler) { + super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, threadFactory, handler); + } + + /** + * @return current tasks which are executed + */ + public int getSubmittedTaskCount() { + return submittedTaskCount.get(); + } + + @Override + protected void afterExecute(Runnable r, Throwable t) { + submittedTaskCount.decrementAndGet(); + } + + @Override + public void execute(Runnable command) { + //do not increment in method beforeExecute! + submittedTaskCount.incrementAndGet(); + try { + super.execute(command); + } catch (RejectedExecutionException rx) { + //retry to offer the task into queue . + final EnhancedTaskQueue queue = (EnhancedTaskQueue) super.getQueue(); + if (!queue.retryOffer(command)) { + submittedTaskCount.decrementAndGet(); + throw new RejectedExecutionException(); + } + } + } +} \ No newline at end of file diff --git a/dubbo-common/src/main/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.threadpool.ThreadPool b/dubbo-common/src/main/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.threadpool.ThreadPool index eeb2e102440..ac4f0657e28 100644 --- a/dubbo-common/src/main/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.threadpool.ThreadPool +++ b/dubbo-common/src/main/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.threadpool.ThreadPool @@ -1,3 +1,4 @@ fixed=com.alibaba.dubbo.common.threadpool.support.fixed.FixedThreadPool cached=com.alibaba.dubbo.common.threadpool.support.cached.CachedThreadPool limited=com.alibaba.dubbo.common.threadpool.support.limited.LimitedThreadPool +enhanced=com.alibaba.dubbo.common.threadpool.support.enhanced.EnhancedThreadPool diff --git a/dubbo-common/src/test/java/com/alibaba/dubbo/common/threadpool/support/enhanced/EnhancedThreadPoolTest.java b/dubbo-common/src/test/java/com/alibaba/dubbo/common/threadpool/support/enhanced/EnhancedThreadPoolTest.java new file mode 100644 index 00000000000..8a6a37c66cd --- /dev/null +++ b/dubbo-common/src/test/java/com/alibaba/dubbo/common/threadpool/support/enhanced/EnhancedThreadPoolTest.java @@ -0,0 +1,68 @@ +package com.alibaba.dubbo.common.threadpool.support.enhanced; + +import com.alibaba.dubbo.common.URL; +import com.alibaba.dubbo.common.threadpool.support.AbortPolicyWithReport; +import com.alibaba.dubbo.common.utils.NamedThreadFactory; +import org.junit.Assert; +import org.junit.Test; + +import java.util.concurrent.TimeUnit; + +public class EnhancedThreadPoolTest { + + /** + * it print like this: + * thread number in current pool:1, task number in task queue:0 executor size: 1 + * thread number in current pool:2, task number in task queue:0 executor size: 2 + * thread number in current pool:3, task number in task queue:0 executor size: 3 + * thread number in current pool:4, task number in task queue:0 executor size: 4 + * thread number in current pool:5, task number in task queue:0 executor size: 5 + * thread number in current pool:6, task number in task queue:0 executor size: 6 + * thread number in current pool:7, task number in task queue:0 executor size: 7 + * thread number in current pool:8, task number in task queue:0 executor size: 8 + * thread number in current pool:9, task number in task queue:0 executor size: 9 + * thread number in current pool:10, task number in task queue:0 executor size: 10 + * thread number in current pool:10, task number in task queue:4 executor size: 10 + * thread number in current pool:10, task number in task queue:3 executor size: 10 + * thread number in current pool:10, task number in task queue:2 executor size: 10 + * thread number in current pool:10, task number in task queue:1 executor size: 10 + * thread number in current pool:10, task number in task queue:0 executor size: 10 + * + * we can see , when the core threads are in busy , the thread pool create thread (but thread nums always less than max) instead of put task into queue. + */ + @Test + public void testEnhancedThreadPool() throws Exception { + String name = "enhanced-tf"; + int queues = 5; + int cores = 5; + int threads = 10; + //alive 1 second + long alive = 1000; + URL url = new URL("dubbo", "localhost", 8080); + + //init queue and enhanced executor + EnhancedTaskQueue enhancedTaskQueue = new EnhancedTaskQueue(queues); + final EnhancedThreadPoolExecutor executor = new EnhancedThreadPoolExecutor(cores, threads, alive, TimeUnit.MILLISECONDS, enhancedTaskQueue, + new NamedThreadFactory(name, true), new AbortPolicyWithReport(name, url)); + enhancedTaskQueue.setExecutor(executor); + + for (int i = 0; i < 15; i++) { + Thread.sleep(50); + executor.execute(new Runnable() { + @Override + public void run() { + System.out.println("thread number in current pool:" + executor.getPoolSize() + ", task number in task queue:" + executor.getQueue().size() + " executor size: " + executor.getPoolSize()); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + }); + } + Thread.sleep(5000); + //cores theads are all alive + Assert.assertTrue("more than cores threads alive!", executor.getPoolSize() == cores); + } + +} \ No newline at end of file From f97db8042a16637ad5db6d60ff46d00f23fd79b8 Mon Sep 17 00:00:00 2001 From: xiuyuhang <442367943@qq.com> Date: Thu, 11 Jan 2018 14:32:57 +0800 Subject: [PATCH 05/21] =?UTF-8?q?=E5=BD=93cores=E7=BA=BF=E7=A8=8B=E6=95=B0?= =?UTF-8?q?=E5=85=A8=E9=83=BD=E4=BD=BF=E7=94=A8=E7=9A=84=E6=83=85=E5=86=B5?= =?UTF-8?q?=E4=B8=8B=EF=BC=8C=E9=BB=98=E8=AE=A4=E7=BA=BF=E7=A8=8B=E6=B1=A0?= =?UTF-8?q?=E4=BC=9A=E6=8A=8A=E4=BB=BB=E5=8A=A1=E6=94=BE=E5=85=A5=E5=88=B0?= =?UTF-8?q?=E9=98=9F=E5=88=97=E4=B8=AD=E3=80=82=E9=98=9F=E5=88=97=E6=BB=A1?= =?UTF-8?q?=E5=88=99=E5=86=8D=E5=88=9B=E5=BB=BA=E7=BA=BF=E7=A8=8B=EF=BC=88?= =?UTF-8?q?=E6=80=BB=E6=95=B0=E4=B8=8D=E4=BC=9A=E8=B6=85=E8=BF=87Max?= =?UTF-8?q?=E7=BA=BF=E7=A8=8B=E6=95=B0=EF=BC=89=20=E5=A2=9E=E5=BC=BA?= =?UTF-8?q?=E7=BA=BF=E7=A8=8B=E6=B1=A0=EF=BC=9A=E5=9C=A8=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E9=87=8F=E9=98=B6=E6=AE=B5=E6=80=A7=E5=87=BA=E7=8E=B0=E9=AB=98?= =?UTF-8?q?=E5=B3=B0=E6=97=B6=E4=BD=BF=E7=94=A8=20=E7=89=B9=E6=80=A7?= =?UTF-8?q?=EF=BC=9Acores=E7=BA=BF=E7=A8=8B=E5=85=A8=E9=83=A8=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E7=9A=84=E6=83=85=E5=86=B5=E4=B8=8B=EF=BC=8C=E4=BC=98?= =?UTF-8?q?=E5=85=88=E5=88=9B=E5=BB=BA=E7=BA=BF=E7=A8=8B=EF=BC=88=E6=80=BB?= =?UTF-8?q?=E6=95=B0=E4=B8=8D=E4=BC=9A=E8=B6=85=E8=BF=87max=EF=BC=89?= =?UTF-8?q?=EF=BC=8C=E5=BD=93max=E4=B8=AA=E7=BA=BF=E7=A8=8B=E5=85=A8?= =?UTF-8?q?=E9=83=BD=E5=9C=A8=E5=BF=99=E7=9A=84=E6=83=85=E5=86=B5=E4=B8=8B?= =?UTF-8?q?=EF=BC=8C=E6=89=8D=E5=B0=86=E4=BB=BB=E5=8A=A1=E6=94=BE=E5=85=A5?= =?UTF-8?q?=E9=98=9F=E5=88=97=E3=80=82=E8=AF=B7=E6=B1=82=E9=87=8F=E4=B8=8B?= =?UTF-8?q?=E9=99=8D=E6=97=B6=EF=BC=8C=E7=BA=BF=E7=A8=8B=E6=B1=A0=E4=BC=9A?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E7=BB=B4=E6=8C=81cores=E4=B8=AA=E7=BA=BF?= =?UTF-8?q?=E7=A8=8B=EF=BC=8C=E5=A4=9A=E4=BD=99=E7=9A=84=E7=BA=BF=E7=A8=8B?= =?UTF-8?q?=E9=80=80=E5=87=BA=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../support/enhanced/EnhancedTaskQueue.java | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/enhanced/EnhancedTaskQueue.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/enhanced/EnhancedTaskQueue.java index 437e988fc3f..65cedaf2f2c 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/enhanced/EnhancedTaskQueue.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/enhanced/EnhancedTaskQueue.java @@ -38,23 +38,6 @@ public boolean offer(Runnable runnable) { //currentPoolThreadSize >= max return super.offer(runnable); - -// int currentPoolThreadSize = executor.getPoolSize(); -// //如果线程池里的线程数量已经到达最大,将任务添加到队列中 -// if (currentPoolThreadSize == executor.getMaximumPoolSize()) { -// return super.offer(runnable); -// } -// //说明有空闲的线程,这个时候无需创建core线程之外的线程,而是把任务直接丢到队列里即可 -// if (executor.getSubmittedTaskCount() < currentPoolThreadSize) { -// return super.offer(runnable); -// } -// -// //如果线程池里的线程数量还没有到达最大,直接创建线程,而不是把任务丢到队列里面 -// if (currentPoolThreadSize < executor.getMaximumPoolSize()) { -// return false; -// } -// -// return super.offer(runnable); } /** From 49aecfb6910a4a5b1f91917c212d3665ef062721 Mon Sep 17 00:00:00 2001 From: xiuyuhang <442367943@qq.com> Date: Wed, 17 Jan 2018 09:52:22 +0800 Subject: [PATCH 06/21] =?UTF-8?q?=E8=A1=A5=E5=85=A8=E5=8D=95=E5=85=83?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=EF=BC=8C=E6=B5=8B=E8=AF=95=E6=89=A9=E5=B1=95?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E7=94=9F=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../support/enhanced/EnhancedThreadPoolTest.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/dubbo-common/src/test/java/com/alibaba/dubbo/common/threadpool/support/enhanced/EnhancedThreadPoolTest.java b/dubbo-common/src/test/java/com/alibaba/dubbo/common/threadpool/support/enhanced/EnhancedThreadPoolTest.java index 8a6a37c66cd..b51ffe5cc3d 100644 --- a/dubbo-common/src/test/java/com/alibaba/dubbo/common/threadpool/support/enhanced/EnhancedThreadPoolTest.java +++ b/dubbo-common/src/test/java/com/alibaba/dubbo/common/threadpool/support/enhanced/EnhancedThreadPoolTest.java @@ -1,15 +1,20 @@ package com.alibaba.dubbo.common.threadpool.support.enhanced; import com.alibaba.dubbo.common.URL; +import com.alibaba.dubbo.common.extension.ExtensionLoader; +import com.alibaba.dubbo.common.threadpool.ThreadPool; import com.alibaba.dubbo.common.threadpool.support.AbortPolicyWithReport; import com.alibaba.dubbo.common.utils.NamedThreadFactory; import org.junit.Assert; import org.junit.Test; +import java.util.concurrent.ExecutorService; import java.util.concurrent.TimeUnit; public class EnhancedThreadPoolTest { + private static final URL URL = new URL("dubbo", "localhost", 8080); + /** * it print like this: * thread number in current pool:1, task number in task queue:0 executor size: 1 @@ -27,7 +32,7 @@ public class EnhancedThreadPoolTest { * thread number in current pool:10, task number in task queue:2 executor size: 10 * thread number in current pool:10, task number in task queue:1 executor size: 10 * thread number in current pool:10, task number in task queue:0 executor size: 10 - * + *

* we can see , when the core threads are in busy , the thread pool create thread (but thread nums always less than max) instead of put task into queue. */ @Test @@ -38,12 +43,11 @@ public void testEnhancedThreadPool() throws Exception { int threads = 10; //alive 1 second long alive = 1000; - URL url = new URL("dubbo", "localhost", 8080); //init queue and enhanced executor EnhancedTaskQueue enhancedTaskQueue = new EnhancedTaskQueue(queues); final EnhancedThreadPoolExecutor executor = new EnhancedThreadPoolExecutor(cores, threads, alive, TimeUnit.MILLISECONDS, enhancedTaskQueue, - new NamedThreadFactory(name, true), new AbortPolicyWithReport(name, url)); + new NamedThreadFactory(name, true), new AbortPolicyWithReport(name, URL)); enhancedTaskQueue.setExecutor(executor); for (int i = 0; i < 15; i++) { @@ -65,4 +69,10 @@ public void run() { Assert.assertTrue("more than cores threads alive!", executor.getPoolSize() == cores); } + @Test + public void testSPI() { + ExecutorService executorService = (ExecutorService) ExtensionLoader.getExtensionLoader(ThreadPool.class).getExtension("enhanced").getExecutor(URL); + Assert.assertTrue("test spi fail!", executorService.getClass().getSimpleName().equals("EnhancedThreadPoolExecutor")); + } + } \ No newline at end of file From 60c2993aa83bc0ab26337c2146f7d37cd00d7fd2 Mon Sep 17 00:00:00 2001 From: xiuyuhang <442367943@qq.com> Date: Wed, 7 Feb 2018 10:16:08 +0800 Subject: [PATCH 07/21] =?UTF-8?q?=E9=94=99=E8=AF=AF=E5=91=BD=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../alibaba/dubbo/registry/integration/RegistryProtocol.java | 2 +- .../dubbo/registry/support/ProviderConsumerRegTable.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/integration/RegistryProtocol.java b/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/integration/RegistryProtocol.java index 14a516137f8..cd272bd869e 100644 --- a/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/integration/RegistryProtocol.java +++ b/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/integration/RegistryProtocol.java @@ -305,7 +305,7 @@ private Invoker doRefer(Cluster cluster, Registry registry, Class type + "," + Constants.ROUTERS_CATEGORY)); Invoker invoker = cluster.join(directory); - ProviderConsumerRegTable.registerConsuemr(invoker, url, subscribeUrl, directory); + ProviderConsumerRegTable.registerConsumer(invoker, url, subscribeUrl, directory); return invoker; } diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/support/ProviderConsumerRegTable.java b/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/support/ProviderConsumerRegTable.java index cd408ca4051..8e5d3336430 100644 --- a/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/support/ProviderConsumerRegTable.java +++ b/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/support/ProviderConsumerRegTable.java @@ -73,7 +73,7 @@ public static ProviderInvokerWrapper getProviderWrapper(Invoker invoker) { return null; } - public static void registerConsuemr(Invoker invoker, URL registryUrl, URL consumerUrl, RegistryDirectory registryDirectory) { + public static void registerConsumer(Invoker invoker, URL registryUrl, URL consumerUrl, RegistryDirectory registryDirectory) { ConsumerInvokerWrapper wrapperInvoker = new ConsumerInvokerWrapper(invoker, registryUrl, consumerUrl, registryDirectory); String serviceUniqueName = consumerUrl.getServiceKey(); Set invokers = consumerInvokers.get(serviceUniqueName); From 4be8d617285bd3e579450a75bff15c4b87bde254 Mon Sep 17 00:00:00 2001 From: xiuyuhang <442367943@qq.com> Date: Tue, 27 Feb 2018 09:59:40 +0800 Subject: [PATCH 08/21] =?UTF-8?q?=E5=A2=9E=E5=8A=A0@Override=E6=B3=A8?= =?UTF-8?q?=E8=A7=A3=20long=20=E5=88=9D=E5=A7=8B=E5=8C=96=E8=B5=8B?= =?UTF-8?q?=E5=80=BC=E6=97=B6=EF=BC=8C=E5=B0=8F=E5=86=99l=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E5=A4=A7=E5=86=99L=E9=98=B2=E6=AD=A2=E8=AF=AF?= =?UTF-8?q?=E8=AF=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../configurator/AbstractConfigurator.java | 3 + .../absent/AbsentConfigurator.java | 1 + .../absent/AbsentConfiguratorFactory.java | 1 + .../override/OverrideConfigurator.java | 1 + .../override/OverrideConfiguratorFactory.java | 1 + .../cluster/directory/AbstractDirectory.java | 3 + .../cluster/directory/StaticDirectory.java | 3 + .../loadbalance/AbstractLoadBalance.java | 1 + .../loadbalance/LeastActiveLoadBalance.java | 1 + .../loadbalance/RandomLoadBalance.java | 1 + .../loadbalance/RoundRobinLoadBalance.java | 1 + .../dubbo/rpc/cluster/merger/ArrayMerger.java | 1 + .../cluster/merger/BooleanArrayMerger.java | 1 + .../rpc/cluster/merger/ByteArrayMerger.java | 1 + .../rpc/cluster/merger/CharArrayMerger.java | 1 + .../rpc/cluster/merger/DoubleArrayMerger.java | 1 + .../rpc/cluster/merger/FloatArrayMerger.java | 1 + .../rpc/cluster/merger/IntArrayMerger.java | 1 + .../dubbo/rpc/cluster/merger/ListMerger.java | 1 + .../rpc/cluster/merger/LongArrayMerger.java | 1 + .../dubbo/rpc/cluster/merger/MapMerger.java | 1 + .../dubbo/rpc/cluster/merger/SetMerger.java | 1 + .../rpc/cluster/merger/ShortArrayMerger.java | 1 + .../cluster/router/MockInvokersSelector.java | 3 + .../router/condition/ConditionRouter.java | 3 + .../condition/ConditionRouterFactory.java | 1 + .../router/file/FileRouterFactory.java | 1 + .../cluster/router/script/ScriptRouter.java | 3 + .../router/script/ScriptRouterFactory.java | 1 + .../support/AbstractClusterInvoker.java | 5 ++ .../rpc/cluster/support/AvailableCluster.java | 2 + .../support/AvailableClusterInvoker.java | 1 + .../rpc/cluster/support/BroadcastCluster.java | 1 + .../support/BroadcastClusterInvoker.java | 1 + .../rpc/cluster/support/FailbackCluster.java | 1 + .../support/FailbackClusterInvoker.java | 2 + .../rpc/cluster/support/FailfastCluster.java | 1 + .../support/FailfastClusterInvoker.java | 1 + .../rpc/cluster/support/FailoverCluster.java | 1 + .../support/FailoverClusterInvoker.java | 1 + .../rpc/cluster/support/FailsafeCluster.java | 1 + .../support/FailsafeClusterInvoker.java | 1 + .../rpc/cluster/support/ForkingCluster.java | 1 + .../support/ForkingClusterInvoker.java | 2 + .../rpc/cluster/support/MergeableCluster.java | 1 + .../support/MergeableClusterInvoker.java | 6 ++ .../support/wrapper/MockClusterInvoker.java | 5 ++ .../support/wrapper/MockClusterWrapper.java | 1 + .../com/alibaba/dubbo/common/Parameters.java | 2 + .../java/com/alibaba/dubbo/common/URL.java | 1 + .../common/beanutil/JavaBeanDescriptor.java | 1 + .../alibaba/dubbo/common/bytecode/Proxy.java | 2 + .../dubbo/common/bytecode/Wrapper.java | 8 +++ .../compiler/support/AbstractCompiler.java | 1 + .../compiler/support/AdaptiveCompiler.java | 1 + .../common/compiler/support/JdkCompiler.java | 1 + .../factory/AdaptiveExtensionFactory.java | 1 + .../factory/SpiExtensionFactory.java | 1 + .../extension/support/ActivateComparator.java | 1 + .../alibaba/dubbo/common/io/StreamUtils.java | 8 +++ .../common/io/UnsafeByteArrayInputStream.java | 8 +++ .../io/UnsafeByteArrayOutputStream.java | 4 ++ .../dubbo/common/io/UnsafeStringReader.java | 4 ++ .../common/json/GenericJSONConverter.java | 36 +++++++++++ .../alibaba/dubbo/common/json/J2oVisitor.java | 10 +++ .../alibaba/dubbo/common/json/JSONArray.java | 1 + .../alibaba/dubbo/common/json/JSONObject.java | 1 + .../dubbo/common/logger/jcl/JclLogger.java | 20 ++++++ .../common/logger/jcl/JclLoggerAdapter.java | 6 ++ .../dubbo/common/logger/jdk/JdkLogger.java | 20 ++++++ .../common/logger/jdk/JdkLoggerAdapter.java | 6 ++ .../common/logger/log4j/Log4jLogger.java | 20 ++++++ .../logger/log4j/Log4jLoggerAdapter.java | 6 ++ .../common/logger/slf4j/Slf4jLogger.java | 20 ++++++ .../logger/slf4j/Slf4jLoggerAdapter.java | 6 ++ .../common/logger/support/FailsafeLogger.java | 20 ++++++ .../serialize/support/dubbo/Builder.java | 8 +++ .../support/dubbo/DubboSerialization.java | 4 ++ .../support/dubbo/GenericDataInput.java | 15 ++++- .../support/dubbo/GenericDataOutput.java | 11 ++++ .../support/dubbo/GenericObjectInput.java | 3 + .../support/dubbo/GenericObjectOutput.java | 1 + .../serialize/support/fst/FstObjectInput.java | 12 ++++ .../support/fst/FstObjectOutput.java | 12 ++++ .../support/fst/FstSerialization.java | 4 ++ .../support/hessian/Hessian2ObjectInput.java | 12 ++++ .../support/hessian/Hessian2ObjectOutput.java | 12 ++++ .../hessian/Hessian2Serialization.java | 4 ++ .../java/CompactedJavaSerialization.java | 4 ++ .../support/java/JavaObjectInput.java | 5 ++ .../support/java/JavaObjectOutput.java | 3 + .../support/java/JavaSerialization.java | 4 ++ .../support/json/FastJsonObjectInput.java | 12 ++++ .../support/json/FastJsonObjectOutput.java | 12 ++++ .../support/json/FastJsonSerialization.java | 4 ++ .../support/json/JsonObjectInput.java | 12 ++++ .../support/json/JsonObjectOutput.java | 12 ++++ .../support/json/JsonSerialization.java | 4 ++ .../support/kryo/KryoObjectInput.java | 13 ++++ .../support/kryo/KryoObjectOutput.java | 13 ++++ .../support/kryo/KryoSerialization.java | 4 ++ .../kryo/utils/AbstractKryoFactory.java | 1 + .../kryo/utils/PrototypeKryoFactory.java | 1 + .../kryo/utils/ThreadLocalKryoFactory.java | 1 + .../nativejava/NativeJavaObjectInput.java | 12 ++++ .../nativejava/NativeJavaObjectOutput.java | 12 ++++ .../nativejava/NativeJavaSerialization.java | 4 ++ .../status/support/LoadStatusChecker.java | 1 + .../status/support/MemoryStatusChecker.java | 1 + .../common/store/support/SimpleDataStore.java | 4 ++ .../support/cached/CachedThreadPool.java | 1 + .../support/fixed/FixedThreadPool.java | 1 + .../support/limited/LimitedThreadPool.java | 1 + .../common/utils/AtomicPositiveInteger.java | 7 +++ .../dubbo/common/utils/CollectionUtils.java | 1 + .../dubbo/common/utils/ConcurrentHashSet.java | 7 +++ .../dubbo/common/utils/DubboAppender.java | 1 + .../dubbo/common/utils/ExecutorUtil.java | 1 + .../common/utils/NamedThreadFactory.java | 1 + .../alibaba/dubbo/common/utils/PojoUtils.java | 1 + .../alibaba/dubbo/config/AbstractConfig.java | 1 + .../dubbo/config/AbstractReferenceConfig.java | 2 + .../dubbo/config/AbstractServiceConfig.java | 2 + .../alibaba/dubbo/config/ServiceConfig.java | 1 + .../DelegateProviderMetaDataInvoker.java | 5 ++ .../config/utils/ReferenceConfigCache.java | 1 + .../dubbo/config/spring/AnnotationBean.java | 5 ++ .../dubbo/config/spring/ReferenceBean.java | 5 ++ .../dubbo/config/spring/ServiceBean.java | 6 ++ .../DubboClassPathBeanDefinitionScanner.java | 2 + .../extension/SpringExtensionFactory.java | 1 + .../AnnotationBeanDefinitionParser.java | 3 + .../schema/DubboBeanDefinitionParser.java | 1 + .../spring/schema/DubboNamespaceHandler.java | 1 + .../status/DataSourceStatusChecker.java | 1 + .../spring/status/SpringStatusChecker.java | 1 + .../com/alibaba/dubbo/container/Main.java | 1 + .../dubbo/container/log4j/Log4jContainer.java | 2 + .../container/logback/LogbackContainer.java | 2 + .../container/spring/SpringContainer.java | 2 + .../dubbo/demo/provider/DemoServiceImpl.java | 1 + .../dubbo/cache/filter/CacheFilter.java | 1 + .../cache/support/AbstractCacheFactory.java | 1 + .../dubbo/cache/support/jcache/JCache.java | 2 + .../cache/support/jcache/JCacheFactory.java | 1 + .../dubbo/cache/support/lru/LruCache.java | 2 + .../cache/support/lru/LruCacheFactory.java | 1 + .../support/threadlocal/ThreadLocalCache.java | 2 + .../threadlocal/ThreadLocalCacheFactory.java | 1 + .../validation/filter/ValidationFilter.java | 1 + .../support/AbstractValidation.java | 1 + .../support/jvalidation/JValidator.java | 1 + .../support/AbstractMonitorFactory.java | 1 + .../dubbo/monitor/support/MonitorFilter.java | 1 + .../dubbo/monitor/dubbo/DubboMonitor.java | 6 ++ .../integration/RegistryDirectory.java | 7 +++ .../integration/RegistryProtocol.java | 9 +++ .../status/RegistryStatusChecker.java | 1 + .../registry/support/AbstractRegistry.java | 10 +++ .../support/AbstractRegistryFactory.java | 1 + .../support/ConsumerInvokerWrapper.java | 5 ++ .../registry/support/FailbackRegistry.java | 1 + .../support/ProviderInvokerWrapper.java | 5 ++ .../dubbo/registry/dubbo/DubboRegistry.java | 8 +++ .../registry/dubbo/DubboRegistryFactory.java | 1 + .../registry/multicast/MulticastRegistry.java | 13 ++++ .../multicast/MulticastRegistryFactory.java | 1 + .../dubbo/registry/redis/RedisRegistry.java | 2 + .../registry/zookeeper/ZookeeperRegistry.java | 10 +++ .../zookeeper/ZookeeperRegistryFactory.java | 1 + .../buffer/AbstractChannelBuffer.java | 43 +++++++++++++ .../buffer/ByteBufferBackedChannelBuffer.java | 18 ++++++ .../dubbo/remoting/buffer/ChannelBuffer.java | 1 + .../buffer/DirectChannelBufferFactory.java | 3 + .../remoting/buffer/DynamicChannelBuffer.java | 18 ++++++ .../remoting/buffer/HeapChannelBuffer.java | 18 ++++++ .../buffer/HeapChannelBufferFactory.java | 3 + .../remoting/exchange/ExchangeChannel.java | 1 + .../exchange/codec/ExchangeCodec.java | 3 + .../exchange/support/DefaultFuture.java | 5 ++ .../support/ExchangeHandlerAdapter.java | 1 + .../support/ExchangeHandlerDispatcher.java | 7 +++ .../support/ExchangeServerDelegate.java | 15 +++++ .../exchange/support/MultiMessage.java | 1 + .../exchange/support/ReplierDispatcher.java | 1 + .../exchange/support/SimpleFuture.java | 4 ++ .../support/header/HeaderExchangeChannel.java | 17 ++++++ .../support/header/HeaderExchangeClient.java | 21 +++++++ .../support/header/HeaderExchangeHandler.java | 6 ++ .../support/header/HeaderExchangeServer.java | 16 +++++ .../support/header/HeaderExchanger.java | 2 + .../support/header/HeartBeatTask.java | 1 + .../support/header/HeartbeatHandler.java | 4 ++ .../remoting/telnet/codec/TelnetCodec.java | 2 + .../telnet/support/TelnetHandlerAdapter.java | 1 + .../support/command/ClearTelnetHandler.java | 1 + .../support/command/ExitTelnetHandler.java | 1 + .../support/command/HelpTelnetHandler.java | 1 + .../support/command/LogTelnetHandler.java | 1 + .../support/command/StatusTelnetHandler.java | 1 + .../remoting/transport/AbstractChannel.java | 1 + .../AbstractChannelHandlerDelegate.java | 6 ++ .../remoting/transport/AbstractClient.java | 12 ++++ .../remoting/transport/AbstractEndpoint.java | 1 + .../remoting/transport/AbstractPeer.java | 12 ++++ .../remoting/transport/AbstractServer.java | 5 ++ .../remoting/transport/ChannelDelegate.java | 14 +++++ .../transport/ChannelHandlerAdapter.java | 5 ++ .../transport/ChannelHandlerDispatcher.java | 5 ++ .../remoting/transport/ClientDelegate.java | 17 ++++++ .../remoting/transport/DecodeHandler.java | 1 + .../remoting/transport/ServerDelegate.java | 13 ++++ .../transport/codec/CodecAdapter.java | 2 + .../transport/codec/TransportCodec.java | 2 + .../dispatcher/ChannelEventRunnable.java | 1 + .../dispatcher/WrappedChannelHandler.java | 6 ++ .../dispatcher/all/AllChannelHandler.java | 4 ++ .../dispatcher/all/AllDispatcher.java | 1 + .../ConnectionOrderedChannelHandler.java | 4 ++ .../ConnectionOrderedDispatcher.java | 1 + .../dispatcher/direct/DirectDispatcher.java | 1 + .../execution/ExecutionChannelHandler.java | 4 ++ .../execution/ExecutionDispatcher.java | 1 + .../message/MessageOnlyChannelHandler.java | 1 + .../message/MessageOnlyDispatcher.java | 1 + .../transport/grizzly/GrizzlyChannel.java | 9 +++ .../transport/grizzly/GrizzlyServer.java | 3 + .../transport/grizzly/GrizzlyTransporter.java | 2 + .../remoting/http/jetty/JettyHttpBinder.java | 1 + .../remoting/http/jetty/JettyHttpServer.java | 1 + .../http/servlet/BootstrapListener.java | 2 + .../http/servlet/DispatcherServlet.java | 1 + .../http/servlet/ServletHttpBinder.java | 1 + .../http/support/AbstractHttpServer.java | 8 +++ .../http/tomcat/TomcatHttpBinder.java | 1 + .../http/tomcat/TomcatHttpServer.java | 1 + .../remoting/transport/mina/MinaChannel.java | 9 +++ .../remoting/transport/mina/MinaClient.java | 1 + .../transport/mina/MinaCodecAdapter.java | 7 +++ .../remoting/transport/mina/MinaServer.java | 3 + .../transport/mina/MinaTransporter.java | 2 + .../netty/NettyBackedChannelBuffer.java | 61 +++++++++++++++++++ .../NettyBackedChannelBufferFactory.java | 3 + .../transport/netty/NettyChannel.java | 9 +++ .../remoting/transport/netty/NettyClient.java | 2 + .../remoting/transport/netty/NettyHelper.java | 12 ++++ .../remoting/transport/netty/NettyServer.java | 4 ++ .../transport/netty/NettyTransporter.java | 2 + .../netty4/NettyBackedChannelBuffer.java | 61 +++++++++++++++++++ .../transport/netty4/NettyChannel.java | 9 +++ .../transport/netty4/NettyClient.java | 2 + .../transport/netty4/NettyCodecAdapter.java | 2 + .../transport/netty4/NettyServer.java | 3 + .../transport/netty4/NettyTransporter.java | 2 + .../transport/netty4/logging/NettyHelper.java | 30 +++++++++ .../support/AbstractExchangeGroup.java | 5 ++ .../exchange/support/ExchangeServerPeer.java | 1 + .../exchange/support/FileExchangeGroup.java | 2 + .../support/FileExchangeNetworker.java | 1 + .../support/MulticastExchangeGroup.java | 1 + .../support/MulticastExchangeNetworker.java | 1 + .../remoting/p2p/support/AbstractGroup.java | 4 ++ .../dubbo/remoting/p2p/support/FileGroup.java | 3 + .../remoting/p2p/support/FileNetworker.java | 1 + .../remoting/p2p/support/MulticastGroup.java | 1 + .../p2p/support/MulticastNetworker.java | 1 + .../remoting/p2p/support/ServerPeer.java | 1 + .../curator/CuratorZookeeperClient.java | 12 ++++ .../curator/CuratorZookeeperTransporter.java | 1 + .../support/AbstractZookeeperClient.java | 7 +++ .../zkclient/ZkclientZookeeperClient.java | 13 ++++ .../ZkclientZookeeperTransporter.java | 1 + .../com/alibaba/dubbo/rpc/RpcContext.java | 6 ++ .../com/alibaba/dubbo/rpc/RpcInvocation.java | 7 +++ .../java/com/alibaba/dubbo/rpc/RpcResult.java | 8 +++ .../dubbo/rpc/filter/AccessLogFilter.java | 2 + .../dubbo/rpc/filter/ActiveLimitFilter.java | 1 + .../dubbo/rpc/filter/ClassLoaderFilter.java | 1 + .../dubbo/rpc/filter/CompatibleFilter.java | 1 + .../rpc/filter/ConsumerContextFilter.java | 1 + .../dubbo/rpc/filter/ContextFilter.java | 1 + .../dubbo/rpc/filter/DeprecatedFilter.java | 1 + .../alibaba/dubbo/rpc/filter/EchoFilter.java | 1 + .../dubbo/rpc/filter/ExceptionFilter.java | 1 + .../dubbo/rpc/filter/ExecuteLimitFilter.java | 1 + .../dubbo/rpc/filter/GenericFilter.java | 1 + .../dubbo/rpc/filter/GenericImplFilter.java | 1 + .../dubbo/rpc/filter/TimeoutFilter.java | 1 + .../alibaba/dubbo/rpc/filter/TokenFilter.java | 1 + .../dubbo/rpc/filter/TpsLimitFilter.java | 1 + .../rpc/filter/tps/DefaultTPSLimiter.java | 1 + .../dubbo/rpc/filter/tps/StatItem.java | 1 + .../listener/DeprecatedInvokerListener.java | 1 + .../rpc/listener/ExporterListenerAdapter.java | 2 + .../rpc/listener/InvokerListenerAdapter.java | 2 + .../rpc/listener/ListenerExporterWrapper.java | 2 + .../rpc/listener/ListenerInvokerWrapper.java | 5 ++ .../dubbo/rpc/protocol/AbstractExporter.java | 3 + .../dubbo/rpc/protocol/AbstractInvoker.java | 6 ++ .../dubbo/rpc/protocol/AbstractProtocol.java | 1 + .../rpc/protocol/AbstractProxyProtocol.java | 3 + .../dubbo/rpc/protocol/InvokerWrapper.java | 5 ++ .../rpc/protocol/ProtocolFilterWrapper.java | 9 +++ .../rpc/protocol/ProtocolListenerWrapper.java | 4 ++ .../dubbo/rpc/proxy/AbstractProxyFactory.java | 1 + .../dubbo/rpc/proxy/AbstractProxyInvoker.java | 5 ++ .../rpc/proxy/InvokerInvocationHandler.java | 1 + .../javassist/JavassistProxyFactory.java | 2 + .../dubbo/rpc/proxy/jdk/JdkProxyFactory.java | 2 + .../wrapper/StubProxyFactoryWrapper.java | 2 + .../dubbo/rpc/support/DelegateExporter.java | 2 + .../dubbo/rpc/support/DelegateInvoker.java | 5 ++ .../dubbo/rpc/support/MockInvoker.java | 5 ++ .../dubbo/rpc/support/MockProtocol.java | 3 + .../protocol/dubbo/ChannelWrappedInvoker.java | 16 +++++ .../dubbo/DecodeableRpcInvocation.java | 3 + .../protocol/dubbo/DecodeableRpcResult.java | 3 + .../dubbo/rpc/protocol/dubbo/DubboCodec.java | 1 + .../rpc/protocol/dubbo/DubboCountCodec.java | 2 + .../rpc/protocol/dubbo/DubboInvoker.java | 1 + .../rpc/protocol/dubbo/DubboProtocol.java | 5 ++ .../rpc/protocol/dubbo/FutureAdapter.java | 5 ++ .../dubbo/LazyConnectExchangeClient.java | 20 ++++++ .../dubbo/ReferenceCountExchangeClient.java | 21 +++++++ .../protocol/dubbo/filter/FutureFilter.java | 3 + .../protocol/dubbo/filter/TraceFilter.java | 1 + .../dubbo/status/ServerStatusChecker.java | 1 + .../dubbo/status/ThreadPoolStatusChecker.java | 1 + .../dubbo/telnet/ChangeTelnetHandler.java | 1 + .../dubbo/telnet/CountTelnetHandler.java | 2 + .../dubbo/telnet/CurrentTelnetHandler.java | 1 + .../dubbo/telnet/InvokeTelnetHandler.java | 1 + .../dubbo/telnet/ListTelnetHandler.java | 1 + .../dubbo/telnet/LogTelnetHandler.java | 1 + .../dubbo/telnet/PortTelnetHandler.java | 1 + .../dubbo/telnet/TraceTelnetHandler.java | 1 + .../rpc/protocol/hessian/HessianProtocol.java | 7 +++ .../hessian/HttpClientConnection.java | 9 +++ .../hessian/HttpClientConnectionFactory.java | 2 + .../dubbo/rpc/protocol/http/HttpProtocol.java | 7 +++ .../rpc/protocol/injvm/InjvmExporter.java | 1 + .../rpc/protocol/injvm/InjvmInvoker.java | 1 + .../rpc/protocol/injvm/InjvmProtocol.java | 3 + .../protocol/memcached/MemcachedProtocol.java | 5 ++ .../rpc/protocol/redis/RedisProtocol.java | 5 ++ .../rpc/protocol/rest/BaseRestServer.java | 3 + .../rpc/protocol/rest/DubboHttpServer.java | 10 +++ .../protocol/rest/DubboResourceFactory.java | 5 ++ .../dubbo/rpc/protocol/rest/NettyServer.java | 3 + .../dubbo/rpc/protocol/rest/RestProtocol.java | 8 +++ .../rpc/protocol/rest/RpcContextFilter.java | 2 + .../rpc/protocol/rest/RpcExceptionMapper.java | 1 + .../protocol/rest/support/LoggingFilter.java | 6 ++ .../dubbo/rpc/protocol/rmi/RmiProtocol.java | 6 ++ .../thrift/DubboClassNameGenerator.java | 2 + .../thrift/ThriftClassNameGenerator.java | 2 + .../rpc/protocol/thrift/ThriftCodec.java | 2 + .../rpc/protocol/thrift/ThriftInvoker.java | 1 + .../protocol/thrift/ThriftNativeCodec.java | 2 + .../rpc/protocol/thrift/ThriftProtocol.java | 4 ++ .../thrift/ext/MultiServiceProcessor.java | 1 + .../io/RandomAccessByteArrayOutputStream.java | 4 ++ .../webservice/WebServiceProtocol.java | 6 ++ .../benchmark/AbstractBenchmarkServer.java | 1 + .../rpc/benchmark/AbstractClientRunnable.java | 2 + .../dubbo/rpc/benchmark/DemoServiceImpl.java | 1 + .../rpc/benchmark/ExchangeClientFactory.java | 1 + ...impleProcessorBenchmarkClientRunnable.java | 2 + .../impl/AnnotationServiceImpl.java | 1 + .../dubbo/examples/async/AsyncConsumer.java | 2 + .../examples/async/impl/AsyncServiceImpl.java | 1 + .../examples/cache/impl/CacheServiceImpl.java | 1 + .../examples/callback/CallbackConsumer.java | 1 + .../callback/impl/CallbackServiceImpl.java | 2 + .../generic/impl/UserServiceImpl.java | 1 + .../examples/heartbeat/HeartbeatClient.java | 1 + .../examples/heartbeat/HeartbeatServer.java | 1 + .../heartbeat/impl/HelloServiceImpl.java | 1 + .../examples/merge/impl/MergeServiceImpl.java | 1 + .../merge/impl/MergeServiceImpl2.java | 1 + .../merge/impl/MergeServiceImpl3.java | 1 + .../rest/api/extension/ClientTraceFilter.java | 2 + .../api/extension/CustomExceptionMapper.java | 1 + .../api/extension/DynamicTraceBinding.java | 1 + .../extension/DynamicTraceInterceptor.java | 2 + .../rest/api/extension/LogFilter.java | 1 + .../rest/api/extension/TraceFilter.java | 2 + .../rest/api/extension/TraceInterceptor.java | 2 + .../examples/rest/impl/UserServiceImpl.java | 2 + .../AnnotationDrivenUserRestServiceImpl.java | 2 + .../facade/AnotherUserRestServiceImpl.java | 2 + .../rest/impl/facade/UserRestServiceImpl.java | 2 + .../impl/ValidationServiceImpl.java | 3 + .../version/impl/VersionServiceImpl.java | 1 + .../version/impl/VersionServiceImpl2.java | 1 + .../hessian/io/AbstractDeserializer.java | 6 ++ .../hessian/io/AbstractHessianResolver.java | 1 + .../hessian/io/AbstractListDeserializer.java | 1 + .../hessian/io/AbstractMapDeserializer.java | 2 + .../caucho/hessian/io/AbstractSerializer.java | 1 + .../caucho/hessian/io/ArrayDeserializer.java | 4 ++ .../caucho/hessian/io/ArraySerializer.java | 1 + .../caucho/hessian/io/BasicDeserializer.java | 4 ++ .../caucho/hessian/io/BasicSerializer.java | 1 + .../caucho/hessian/io/BeanDeserializer.java | 2 + .../com/caucho/hessian/io/BeanSerializer.java | 2 + .../hessian/io/BeanSerializerFactory.java | 2 + .../caucho/hessian/io/CalendarSerializer.java | 1 + .../caucho/hessian/io/ClassDeserializer.java | 3 + .../caucho/hessian/io/ClassSerializer.java | 1 + .../hessian/io/CollectionDeserializer.java | 3 + .../hessian/io/CollectionSerializer.java | 1 + .../com/caucho/hessian/io/Deflation.java | 9 +++ .../caucho/hessian/io/EnumDeserializer.java | 3 + .../com/caucho/hessian/io/EnumSerializer.java | 1 + .../hessian/io/EnumerationDeserializer.java | 1 + .../hessian/io/EnumerationSerializer.java | 1 + .../hessian/io/ExtSerializerFactory.java | 2 + .../com/caucho/hessian/io/Hessian2Input.java | 38 ++++++++++++ .../com/caucho/hessian/io/Hessian2Output.java | 34 +++++++++++ .../hessian/io/Hessian2StreamingInput.java | 2 + .../hessian/io/HessianDebugInputStream.java | 5 ++ .../hessian/io/HessianDebugOutputStream.java | 6 ++ .../caucho/hessian/io/HessianDebugState.java | 29 +++++++++ .../com/caucho/hessian/io/HessianInput.java | 42 +++++++++++++ .../com/caucho/hessian/io/HessianOutput.java | 35 +++++++++++ .../hessian/io/HessianProtocolException.java | 1 + .../com/caucho/hessian/io/HessianRemote.java | 3 + .../caucho/hessian/io/IOExceptionWrapper.java | 1 + .../hessian/io/InputStreamDeserializer.java | 1 + .../hessian/io/InputStreamSerializer.java | 1 + .../caucho/hessian/io/IteratorSerializer.java | 1 + .../caucho/hessian/io/JavaDeserializer.java | 17 ++++++ .../com/caucho/hessian/io/JavaSerializer.java | 7 +++ .../caucho/hessian/io/LocaleSerializer.java | 1 + .../caucho/hessian/io/MapDeserializer.java | 2 + .../com/caucho/hessian/io/MapSerializer.java | 1 + .../caucho/hessian/io/ObjectDeserializer.java | 5 ++ .../caucho/hessian/io/RemoteSerializer.java | 1 + .../caucho/hessian/io/SerializerFactory.java | 1 + .../hessian/io/SqlDateDeserializer.java | 3 + .../caucho/hessian/io/SqlDateSerializer.java | 1 + .../hessian/io/StringValueDeserializer.java | 3 + .../hessian/io/StringValueSerializer.java | 1 + .../hessian/io/ThrowableSerializer.java | 1 + .../caucho/hessian/io/ValueDeserializer.java | 2 + .../hessian/security/X509Encryption.java | 9 +++ .../hessian/security/X509Signature.java | 9 +++ .../caucho/hessian/util/IdentityIntMap.java | 1 + .../com/caucho/hessian/util/IntMap.java | 1 + 450 files changed, 2013 insertions(+), 3 deletions(-) diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/configurator/AbstractConfigurator.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/configurator/AbstractConfigurator.java index 50653fed32b..32c6c9ec306 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/configurator/AbstractConfigurator.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/configurator/AbstractConfigurator.java @@ -44,10 +44,12 @@ public static void main(String[] args) { System.out.println(URL.encode("timeout=100")); } + @Override public URL getUrl() { return configuratorUrl; } + @Override public URL configure(URL url) { if (configuratorUrl == null || configuratorUrl.getHost() == null || url == null || url.getHost() == null) { @@ -107,6 +109,7 @@ private URL configureIfMatch(String host, URL url) { * @param o * @return */ + @Override public int compareTo(Configurator o) { if (o == null) { return -1; diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/configurator/absent/AbsentConfigurator.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/configurator/absent/AbsentConfigurator.java index 1a62a969afd..d796df48594 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/configurator/absent/AbsentConfigurator.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/configurator/absent/AbsentConfigurator.java @@ -29,6 +29,7 @@ public AbsentConfigurator(URL url) { super(url); } + @Override public URL doConfigure(URL currentUrl, URL configUrl) { return currentUrl.addParametersIfAbsent(configUrl.getParameters()); } diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/configurator/absent/AbsentConfiguratorFactory.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/configurator/absent/AbsentConfiguratorFactory.java index fe3fa6e8406..fbe8e981cfe 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/configurator/absent/AbsentConfiguratorFactory.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/configurator/absent/AbsentConfiguratorFactory.java @@ -26,6 +26,7 @@ */ public class AbsentConfiguratorFactory implements ConfiguratorFactory { + @Override public Configurator getConfigurator(URL url) { return new AbsentConfigurator(url); } diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/configurator/override/OverrideConfigurator.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/configurator/override/OverrideConfigurator.java index 5286bfaa0ce..f8c7ee8d985 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/configurator/override/OverrideConfigurator.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/configurator/override/OverrideConfigurator.java @@ -29,6 +29,7 @@ public OverrideConfigurator(URL url) { super(url); } + @Override public URL doConfigure(URL currentUrl, URL configUrl) { return currentUrl.addParameters(configUrl.getParameters()); } diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/configurator/override/OverrideConfiguratorFactory.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/configurator/override/OverrideConfiguratorFactory.java index 75b3e056f72..fc648a727b9 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/configurator/override/OverrideConfiguratorFactory.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/configurator/override/OverrideConfiguratorFactory.java @@ -26,6 +26,7 @@ */ public class OverrideConfiguratorFactory implements ConfiguratorFactory { + @Override public Configurator getConfigurator(URL url) { return new OverrideConfigurator(url); } diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/directory/AbstractDirectory.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/directory/AbstractDirectory.java index db787747f54..b2563f33e57 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/directory/AbstractDirectory.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/directory/AbstractDirectory.java @@ -66,6 +66,7 @@ public AbstractDirectory(URL url, URL consumerUrl, List routers) { setRouters(routers); } + @Override public List> list(Invocation invocation) throws RpcException { if (destroyed) { throw new RpcException("Directory already destroyed .url: " + getUrl()); @@ -86,6 +87,7 @@ public List> list(Invocation invocation) throws RpcException { return invokers; } + @Override public URL getUrl() { return url; } @@ -121,6 +123,7 @@ public boolean isDestroyed() { return destroyed; } + @Override public void destroy() { destroyed = true; } diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/directory/StaticDirectory.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/directory/StaticDirectory.java index a8563b643c8..b80d10c8cf0 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/directory/StaticDirectory.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/directory/StaticDirectory.java @@ -51,10 +51,12 @@ public StaticDirectory(URL url, List> invokers, List routers) this.invokers = invokers; } + @Override public Class getInterface() { return invokers.get(0).getInterface(); } + @Override public boolean isAvailable() { if (isDestroyed()) { return false; @@ -67,6 +69,7 @@ public boolean isAvailable() { return false; } + @Override public void destroy() { if (isDestroyed()) { return; diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/loadbalance/AbstractLoadBalance.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/loadbalance/AbstractLoadBalance.java index 74db7bcd189..96e32092d56 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/loadbalance/AbstractLoadBalance.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/loadbalance/AbstractLoadBalance.java @@ -35,6 +35,7 @@ static int calculateWarmupWeight(int uptime, int warmup, int weight) { return ww < 1 ? 1 : (ww > weight ? weight : ww); } + @Override public Invoker select(List> invokers, URL url, Invocation invocation) { if (invokers == null || invokers.isEmpty()) return null; diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/loadbalance/LeastActiveLoadBalance.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/loadbalance/LeastActiveLoadBalance.java index 0da2254ca62..471265c6b32 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/loadbalance/LeastActiveLoadBalance.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/loadbalance/LeastActiveLoadBalance.java @@ -35,6 +35,7 @@ public class LeastActiveLoadBalance extends AbstractLoadBalance { private final Random random = new Random(); + @Override protected Invoker doSelect(List> invokers, URL url, Invocation invocation) { int length = invokers.size(); // Number of invokers int leastActive = -1; // The least active value of all invokers diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/loadbalance/RandomLoadBalance.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/loadbalance/RandomLoadBalance.java index 933428ba032..ca349286d86 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/loadbalance/RandomLoadBalance.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/loadbalance/RandomLoadBalance.java @@ -33,6 +33,7 @@ public class RandomLoadBalance extends AbstractLoadBalance { private final Random random = new Random(); + @Override protected Invoker doSelect(List> invokers, URL url, Invocation invocation) { int length = invokers.size(); // Number of invokers int totalWeight = 0; // The sum of weights diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/loadbalance/RoundRobinLoadBalance.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/loadbalance/RoundRobinLoadBalance.java index 1eccbf47c4f..77de958a509 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/loadbalance/RoundRobinLoadBalance.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/loadbalance/RoundRobinLoadBalance.java @@ -37,6 +37,7 @@ public class RoundRobinLoadBalance extends AbstractLoadBalance { private final ConcurrentMap sequences = new ConcurrentHashMap(); + @Override protected Invoker doSelect(List> invokers, URL url, Invocation invocation) { String key = invokers.get(0).getUrl().getServiceKey() + "." + invocation.getMethodName(); int length = invokers.size(); // Number of invokers diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/merger/ArrayMerger.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/merger/ArrayMerger.java index 873138974f1..698a31556d2 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/merger/ArrayMerger.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/merger/ArrayMerger.java @@ -24,6 +24,7 @@ public class ArrayMerger implements Merger { public static final ArrayMerger INSTANCE = new ArrayMerger(); + @Override public Object[] merge(Object[]... others) { if (others.length == 0) { return null; diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/merger/BooleanArrayMerger.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/merger/BooleanArrayMerger.java index 105717b516b..1b4c4b1ca44 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/merger/BooleanArrayMerger.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/merger/BooleanArrayMerger.java @@ -21,6 +21,7 @@ public class BooleanArrayMerger implements Merger { + @Override public boolean[] merge(boolean[]... items) { int totalLen = 0; for (boolean[] array : items) { diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/merger/ByteArrayMerger.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/merger/ByteArrayMerger.java index 2be2984ac18..7951b8d0356 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/merger/ByteArrayMerger.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/merger/ByteArrayMerger.java @@ -21,6 +21,7 @@ public class ByteArrayMerger implements Merger { + @Override public byte[] merge(byte[]... items) { int total = 0; for (byte[] array : items) { diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/merger/CharArrayMerger.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/merger/CharArrayMerger.java index 565c6c176a0..b72c64aef1d 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/merger/CharArrayMerger.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/merger/CharArrayMerger.java @@ -21,6 +21,7 @@ public class CharArrayMerger implements Merger { + @Override public char[] merge(char[]... items) { int total = 0; for (char[] array : items) { diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/merger/DoubleArrayMerger.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/merger/DoubleArrayMerger.java index 4bf5c689146..b2494900343 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/merger/DoubleArrayMerger.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/merger/DoubleArrayMerger.java @@ -21,6 +21,7 @@ public class DoubleArrayMerger implements Merger { + @Override public double[] merge(double[]... items) { int total = 0; for (double[] array : items) { diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/merger/FloatArrayMerger.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/merger/FloatArrayMerger.java index 03dcf83615c..5bf14cbc95a 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/merger/FloatArrayMerger.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/merger/FloatArrayMerger.java @@ -21,6 +21,7 @@ public class FloatArrayMerger implements Merger { + @Override public float[] merge(float[]... items) { int total = 0; for (float[] array : items) { diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/merger/IntArrayMerger.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/merger/IntArrayMerger.java index 39fe0f57432..dc237672779 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/merger/IntArrayMerger.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/merger/IntArrayMerger.java @@ -21,6 +21,7 @@ public class IntArrayMerger implements Merger { + @Override public int[] merge(int[]... items) { int totalLen = 0; for (int[] item : items) { diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/merger/ListMerger.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/merger/ListMerger.java index abde290d49f..bc61dae4455 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/merger/ListMerger.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/merger/ListMerger.java @@ -24,6 +24,7 @@ public class ListMerger implements Merger> { + @Override public List merge(List... items) { List result = new ArrayList(); for (List item : items) { diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/merger/LongArrayMerger.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/merger/LongArrayMerger.java index 35ce7ed5ac0..a5ad1075816 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/merger/LongArrayMerger.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/merger/LongArrayMerger.java @@ -21,6 +21,7 @@ public class LongArrayMerger implements Merger { + @Override public long[] merge(long[]... items) { int total = 0; for (long[] array : items) { diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/merger/MapMerger.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/merger/MapMerger.java index 5c9121cc50a..b8affc99f70 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/merger/MapMerger.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/merger/MapMerger.java @@ -23,6 +23,7 @@ public class MapMerger implements Merger> { + @Override public Map merge(Map... items) { if (items.length == 0) { return null; diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/merger/SetMerger.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/merger/SetMerger.java index 836517396e7..ec72bb803e7 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/merger/SetMerger.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/merger/SetMerger.java @@ -23,6 +23,7 @@ public class SetMerger implements Merger> { + @Override public Set merge(Set... items) { Set result = new HashSet(); diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/merger/ShortArrayMerger.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/merger/ShortArrayMerger.java index 7834364f5a3..77342fc83c6 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/merger/ShortArrayMerger.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/merger/ShortArrayMerger.java @@ -21,6 +21,7 @@ public class ShortArrayMerger implements Merger { + @Override public short[] merge(short[]... items) { int total = 0; for (short[] array : items) { diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/router/MockInvokersSelector.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/router/MockInvokersSelector.java index 9239ce635ee..d406f78da4f 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/router/MockInvokersSelector.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/router/MockInvokersSelector.java @@ -33,6 +33,7 @@ */ public class MockInvokersSelector implements Router { + @Override public List> route(final List> invokers, URL url, final Invocation invocation) throws RpcException { if (invocation.getAttachments() == null) { @@ -86,10 +87,12 @@ private boolean hasMockProviders(final List> invokers) { return hasMockProvider; } + @Override public URL getUrl() { return null; } + @Override public int compareTo(Router o) { return 1; } diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/router/condition/ConditionRouter.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/router/condition/ConditionRouter.java index 927849f4ebb..6855d7e8ce2 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/router/condition/ConditionRouter.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/router/condition/ConditionRouter.java @@ -142,6 +142,7 @@ else if (",".equals(separator)) { // Should be seperateed by ',' return condition; } + @Override public List> route(List> invokers, URL url, Invocation invocation) throws RpcException { if (invokers == null || invokers.isEmpty()) { @@ -173,10 +174,12 @@ public List> route(List> invokers, URL url, Invocation return invokers; } + @Override public URL getUrl() { return url; } + @Override public int compareTo(Router o) { if (o == null || o.getClass() != ConditionRouter.class) { return 1; diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/router/condition/ConditionRouterFactory.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/router/condition/ConditionRouterFactory.java index b34a0e19638..35ffbec1feb 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/router/condition/ConditionRouterFactory.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/router/condition/ConditionRouterFactory.java @@ -28,6 +28,7 @@ public class ConditionRouterFactory implements RouterFactory { public static final String NAME = "condition"; + @Override public Router getRouter(URL url) { return new ConditionRouter(url); } diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/router/file/FileRouterFactory.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/router/file/FileRouterFactory.java index d78ca0bf190..4d338903138 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/router/file/FileRouterFactory.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/router/file/FileRouterFactory.java @@ -37,6 +37,7 @@ public void setRouterFactory(RouterFactory routerFactory) { this.routerFactory = routerFactory; } + @Override public Router getRouter(URL url) { try { // Transform File URL into Script Route URL, and Load diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/router/script/ScriptRouter.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/router/script/ScriptRouter.java index 7359e6ce6f2..aa01dac5c69 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/router/script/ScriptRouter.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/router/script/ScriptRouter.java @@ -79,10 +79,12 @@ public ScriptRouter(URL url) { this.rule = rule; } + @Override public URL getUrl() { return url; } + @Override @SuppressWarnings("unchecked") public List> route(List> invokers, URL url, Invocation invocation) throws RpcException { try { @@ -112,6 +114,7 @@ public List> route(List> invokers, URL url, Invocation } } + @Override public int compareTo(Router o) { if (o == null || o.getClass() != ScriptRouter.class) { return 1; diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/router/script/ScriptRouterFactory.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/router/script/ScriptRouterFactory.java index 18a6c97205e..e8fba4fa427 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/router/script/ScriptRouterFactory.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/router/script/ScriptRouterFactory.java @@ -37,6 +37,7 @@ public class ScriptRouterFactory implements RouterFactory { public static final String NAME = "script"; + @Override public Router getRouter(URL url) { return new ScriptRouter(url); } diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/AbstractClusterInvoker.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/AbstractClusterInvoker.java index f2cd281ef86..68ed406f9cd 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/AbstractClusterInvoker.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/AbstractClusterInvoker.java @@ -64,14 +64,17 @@ public AbstractClusterInvoker(Directory directory, URL url) { this.availablecheck = url.getParameter(Constants.CLUSTER_AVAILABLE_CHECK_KEY, Constants.DEFAULT_CLUSTER_AVAILABLE_CHECK); } + @Override public Class getInterface() { return directory.getInterface(); } + @Override public URL getUrl() { return directory.getUrl(); } + @Override public boolean isAvailable() { Invoker invoker = stickyInvoker; if (invoker != null) { @@ -80,6 +83,7 @@ public boolean isAvailable() { return directory.isAvailable(); } + @Override public void destroy() { if (destroyed.compareAndSet(false, true)) { directory.destroy(); @@ -221,6 +225,7 @@ private Invoker reselect(LoadBalance loadbalance, Invocation invocation, return null; } + @Override public Result invoke(final Invocation invocation) throws RpcException { checkWhetherDestroyed(); LoadBalance loadbalance = null; diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/AvailableCluster.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/AvailableCluster.java index 7c6c5f44b72..8e9c8712279 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/AvailableCluster.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/AvailableCluster.java @@ -34,9 +34,11 @@ public class AvailableCluster implements Cluster { public static final String NAME = "available"; + @Override public Invoker join(Directory directory) throws RpcException { return new AbstractClusterInvoker(directory) { + @Override public Result doInvoke(Invocation invocation, List> invokers, LoadBalance loadbalance) throws RpcException { for (Invoker invoker : invokers) { if (invoker.isAvailable()) { diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/AvailableClusterInvoker.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/AvailableClusterInvoker.java index d67958fe691..82a98f2b311 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/AvailableClusterInvoker.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/AvailableClusterInvoker.java @@ -35,6 +35,7 @@ public AvailableClusterInvoker(Directory directory) { super(directory); } + @Override public Result doInvoke(Invocation invocation, List> invokers, LoadBalance loadbalance) throws RpcException { for (Invoker invoker : invokers) { if (invoker.isAvailable()) { diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/BroadcastCluster.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/BroadcastCluster.java index 1e10f53cbf9..584299f336e 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/BroadcastCluster.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/BroadcastCluster.java @@ -27,6 +27,7 @@ */ public class BroadcastCluster implements Cluster { + @Override public Invoker join(Directory directory) throws RpcException { return new BroadcastClusterInvoker(directory); } diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/BroadcastClusterInvoker.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/BroadcastClusterInvoker.java index da79ace74b7..0f695c61940 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/BroadcastClusterInvoker.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/BroadcastClusterInvoker.java @@ -40,6 +40,7 @@ public BroadcastClusterInvoker(Directory directory) { super(directory); } + @Override @SuppressWarnings({"unchecked", "rawtypes"}) public Result doInvoke(final Invocation invocation, List> invokers, LoadBalance loadbalance) throws RpcException { checkInvokers(invokers, invocation); diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/FailbackCluster.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/FailbackCluster.java index 13d0dc91e2a..b4f56a6de35 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/FailbackCluster.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/FailbackCluster.java @@ -29,6 +29,7 @@ public class FailbackCluster implements Cluster { public final static String NAME = "failback"; + @Override public Invoker join(Directory directory) throws RpcException { return new FailbackClusterInvoker(directory); } diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/FailbackClusterInvoker.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/FailbackClusterInvoker.java index acdd62db1b3..57c2fa2b32e 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/FailbackClusterInvoker.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/FailbackClusterInvoker.java @@ -64,6 +64,7 @@ private void addFailed(Invocation invocation, AbstractClusterInvoker router) if (retryFuture == null) { retryFuture = scheduledExecutorService.scheduleWithFixedDelay(new Runnable() { + @Override public void run() { // collect retry statistics try { @@ -96,6 +97,7 @@ void retryFailed() { } } + @Override protected Result doInvoke(Invocation invocation, List> invokers, LoadBalance loadbalance) throws RpcException { try { checkInvokers(invokers, invocation); diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/FailfastCluster.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/FailfastCluster.java index f47c6022bc5..d01794240a3 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/FailfastCluster.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/FailfastCluster.java @@ -29,6 +29,7 @@ public class FailfastCluster implements Cluster { public final static String NAME = "failfast"; + @Override public Invoker join(Directory directory) throws RpcException { return new FailfastClusterInvoker(directory); } diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/FailfastClusterInvoker.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/FailfastClusterInvoker.java index d1307be567a..29a3069dbe2 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/FailfastClusterInvoker.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/FailfastClusterInvoker.java @@ -40,6 +40,7 @@ public FailfastClusterInvoker(Directory directory) { super(directory); } + @Override public Result doInvoke(Invocation invocation, List> invokers, LoadBalance loadbalance) throws RpcException { checkInvokers(invokers, invocation); Invoker invoker = select(loadbalance, invocation, invokers, null); diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/FailoverCluster.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/FailoverCluster.java index 64d731f0201..de97e122cf4 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/FailoverCluster.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/FailoverCluster.java @@ -29,6 +29,7 @@ public class FailoverCluster implements Cluster { public final static String NAME = "failover"; + @Override public Invoker join(Directory directory) throws RpcException { return new FailoverClusterInvoker(directory); } diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/FailoverClusterInvoker.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/FailoverClusterInvoker.java index 90a9a379fa7..7c23b986d9e 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/FailoverClusterInvoker.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/FailoverClusterInvoker.java @@ -49,6 +49,7 @@ public FailoverClusterInvoker(Directory directory) { super(directory); } + @Override @SuppressWarnings({"unchecked", "rawtypes"}) public Result doInvoke(Invocation invocation, final List> invokers, LoadBalance loadbalance) throws RpcException { List> copyinvokers = invokers; diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/FailsafeCluster.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/FailsafeCluster.java index a085eb85cda..4fda19fb881 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/FailsafeCluster.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/FailsafeCluster.java @@ -29,6 +29,7 @@ public class FailsafeCluster implements Cluster { public final static String NAME = "failsafe"; + @Override public Invoker join(Directory directory) throws RpcException { return new FailsafeClusterInvoker(directory); } diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/FailsafeClusterInvoker.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/FailsafeClusterInvoker.java index bfdc80d018b..a68ef6ede44 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/FailsafeClusterInvoker.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/FailsafeClusterInvoker.java @@ -42,6 +42,7 @@ public FailsafeClusterInvoker(Directory directory) { super(directory); } + @Override public Result doInvoke(Invocation invocation, List> invokers, LoadBalance loadbalance) throws RpcException { try { checkInvokers(invokers, invocation); diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/ForkingCluster.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/ForkingCluster.java index e0da2966eae..b9fe31d3456 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/ForkingCluster.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/ForkingCluster.java @@ -29,6 +29,7 @@ public class ForkingCluster implements Cluster { public final static String NAME = "forking"; + @Override public Invoker join(Directory directory) throws RpcException { return new ForkingClusterInvoker(directory); } diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/ForkingClusterInvoker.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/ForkingClusterInvoker.java index 307d82a73ca..78ef37b74d6 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/ForkingClusterInvoker.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/ForkingClusterInvoker.java @@ -49,6 +49,7 @@ public ForkingClusterInvoker(Directory directory) { super(directory); } + @Override @SuppressWarnings({"unchecked", "rawtypes"}) public Result doInvoke(final Invocation invocation, List> invokers, LoadBalance loadbalance) throws RpcException { checkInvokers(invokers, invocation); @@ -72,6 +73,7 @@ public Result doInvoke(final Invocation invocation, List> invokers, L final BlockingQueue ref = new LinkedBlockingQueue(); for (final Invoker invoker : selected) { executor.execute(new Runnable() { + @Override public void run() { try { Result result = invoker.invoke(invocation); diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/MergeableCluster.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/MergeableCluster.java index 7f9f05ae04a..ec942b737d6 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/MergeableCluster.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/MergeableCluster.java @@ -25,6 +25,7 @@ public class MergeableCluster implements Cluster { public static final String NAME = "mergeable"; + @Override public Invoker join(Directory directory) throws RpcException { return new MergeableClusterInvoker(directory); } diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/MergeableClusterInvoker.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/MergeableClusterInvoker.java index 62372108f8d..efe033166e3 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/MergeableClusterInvoker.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/MergeableClusterInvoker.java @@ -57,6 +57,7 @@ public MergeableClusterInvoker(Directory directory) { this.directory = directory; } + @Override @SuppressWarnings("rawtypes") public Result invoke(final Invocation invocation) throws RpcException { List> invokers = directory.list(invocation); @@ -82,6 +83,7 @@ public Result invoke(final Invocation invocation) throws RpcException { Map> results = new HashMap>(); for (final Invoker invoker : invokers) { Future future = executor.submit(new Callable() { + @Override public Result call() throws Exception { return invoker.invoke(new RpcInvocation(invocation, invoker)); } @@ -184,18 +186,22 @@ public Result call() throws Exception { return new RpcResult(result); } + @Override public Class getInterface() { return directory.getInterface(); } + @Override public URL getUrl() { return directory.getUrl(); } + @Override public boolean isAvailable() { return directory.isAvailable(); } + @Override public void destroy() { directory.destroy(); } diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/wrapper/MockClusterInvoker.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/wrapper/MockClusterInvoker.java index 0a038c74335..b440d45050c 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/wrapper/MockClusterInvoker.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/wrapper/MockClusterInvoker.java @@ -45,22 +45,27 @@ public MockClusterInvoker(Directory directory, Invoker invoker) { this.invoker = invoker; } + @Override public URL getUrl() { return directory.getUrl(); } + @Override public boolean isAvailable() { return directory.isAvailable(); } + @Override public void destroy() { this.invoker.destroy(); } + @Override public Class getInterface() { return directory.getInterface(); } + @Override public Result invoke(Invocation invocation) throws RpcException { Result result = null; diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/wrapper/MockClusterWrapper.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/wrapper/MockClusterWrapper.java index b2b3488579e..9692cbb524d 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/wrapper/MockClusterWrapper.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/support/wrapper/MockClusterWrapper.java @@ -33,6 +33,7 @@ public MockClusterWrapper(Cluster cluster) { this.cluster = cluster; } + @Override public Invoker join(Directory directory) throws RpcException { return new MockClusterInvoker(directory, this.cluster.join(directory)); diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/Parameters.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/Parameters.java index ec231304de8..0d21c43fc7b 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/Parameters.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/Parameters.java @@ -247,10 +247,12 @@ public boolean hasMethodParamter(String method, String key) { return value != null && value.length() > 0; } + @Override public boolean equals(Object o) { return parameters.equals(o); } + @Override public int hashCode() { return parameters.hashCode(); } diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/URL.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/URL.java index eb5c144b0d3..c2b50a979d3 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/URL.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/URL.java @@ -1080,6 +1080,7 @@ public Map toMap() { return map; } + @Override public String toString() { if (string != null) { return string; diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/beanutil/JavaBeanDescriptor.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/beanutil/JavaBeanDescriptor.java index ab6060663dc..167905a1fa6 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/beanutil/JavaBeanDescriptor.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/beanutil/JavaBeanDescriptor.java @@ -184,6 +184,7 @@ public boolean containsProperty(Object propertyName) { return properties.containsKey(propertyName); } + @Override public Iterator> iterator() { return properties.entrySet().iterator(); } diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/bytecode/Proxy.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/bytecode/Proxy.java index f6761f715f0..25b0d23a3ab 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/bytecode/Proxy.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/bytecode/Proxy.java @@ -39,11 +39,13 @@ public abstract class Proxy { public static final InvocationHandler RETURN_NULL_INVOKER = new InvocationHandler() { + @Override public Object invoke(Object proxy, Method method, Object[] args) { return null; } }; public static final InvocationHandler THROW_UNSUPPORTED_INVOKER = new InvocationHandler() { + @Override public Object invoke(Object proxy, Method method, Object[] args) { throw new UnsupportedOperationException("Method [" + ReflectUtils.getName(method) + "] unimplemented."); } diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/bytecode/Wrapper.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/bytecode/Wrapper.java index 25ddddb4128..59af578d1cf 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/bytecode/Wrapper.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/bytecode/Wrapper.java @@ -40,34 +40,42 @@ public abstract class Wrapper { private static final String[] EMPTY_STRING_ARRAY = new String[0]; private static final String[] OBJECT_METHODS = new String[]{"getClass", "hashCode", "toString", "equals"}; private static final Wrapper OBJECT_WRAPPER = new Wrapper() { + @Override public String[] getMethodNames() { return OBJECT_METHODS; } + @Override public String[] getDeclaredMethodNames() { return OBJECT_METHODS; } + @Override public String[] getPropertyNames() { return EMPTY_STRING_ARRAY; } + @Override public Class getPropertyType(String pn) { return null; } + @Override public Object getPropertyValue(Object instance, String pn) throws NoSuchPropertyException { throw new NoSuchPropertyException("Property [" + pn + "] not found."); } + @Override public void setPropertyValue(Object instance, String pn, Object pv) throws NoSuchPropertyException { throw new NoSuchPropertyException("Property [" + pn + "] not found."); } + @Override public boolean hasProperty(String name) { return false; } + @Override public Object invokeMethod(Object instance, String mn, Class[] types, Object[] args) throws NoSuchMethodException { if ("getClass".equals(mn)) return instance.getClass(); if ("hashCode".equals(mn)) return instance.hashCode(); diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/compiler/support/AbstractCompiler.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/compiler/support/AbstractCompiler.java index b007244624c..2e94b90c62b 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/compiler/support/AbstractCompiler.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/compiler/support/AbstractCompiler.java @@ -31,6 +31,7 @@ public abstract class AbstractCompiler implements Compiler { private static final Pattern CLASS_PATTERN = Pattern.compile("class\\s+([$_a-zA-Z][$_a-zA-Z0-9]*)\\s+"); + @Override public Class compile(String code, ClassLoader classLoader) { code = code.trim(); Matcher matcher = PACKAGE_PATTERN.matcher(code); diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/compiler/support/AdaptiveCompiler.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/compiler/support/AdaptiveCompiler.java index a088256789b..c8dcfb2e5e4 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/compiler/support/AdaptiveCompiler.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/compiler/support/AdaptiveCompiler.java @@ -33,6 +33,7 @@ public static void setDefaultCompiler(String compiler) { DEFAULT_COMPILER = compiler; } + @Override public Class compile(String code, ClassLoader classLoader) { Compiler compiler; ExtensionLoader loader = ExtensionLoader.getExtensionLoader(Compiler.class); diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/compiler/support/JdkCompiler.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/compiler/support/JdkCompiler.java index 461172d7807..9a370a6beee 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/compiler/support/JdkCompiler.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/compiler/support/JdkCompiler.java @@ -87,6 +87,7 @@ public JdkCompiler() { } } classLoader = AccessController.doPrivileged(new PrivilegedAction() { + @Override public ClassLoaderImpl run() { return new ClassLoaderImpl(loader); } diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/extension/factory/AdaptiveExtensionFactory.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/extension/factory/AdaptiveExtensionFactory.java index c9235bdddd9..55bbf5b2e06 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/extension/factory/AdaptiveExtensionFactory.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/extension/factory/AdaptiveExtensionFactory.java @@ -41,6 +41,7 @@ public AdaptiveExtensionFactory() { factories = Collections.unmodifiableList(list); } + @Override public T getExtension(Class type, String name) { for (ExtensionFactory factory : factories) { T extension = factory.getExtension(type, name); diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/extension/factory/SpiExtensionFactory.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/extension/factory/SpiExtensionFactory.java index 0fc857ed50e..f8d7ba5f02e 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/extension/factory/SpiExtensionFactory.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/extension/factory/SpiExtensionFactory.java @@ -25,6 +25,7 @@ */ public class SpiExtensionFactory implements ExtensionFactory { + @Override public T getExtension(Class type, String name) { if (type.isInterface() && type.isAnnotationPresent(SPI.class)) { ExtensionLoader loader = ExtensionLoader.getExtensionLoader(type); diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/extension/support/ActivateComparator.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/extension/support/ActivateComparator.java index 809e883d894..7cf7a1b3716 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/extension/support/ActivateComparator.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/extension/support/ActivateComparator.java @@ -29,6 +29,7 @@ public class ActivateComparator implements Comparator { public static final Comparator COMPARATOR = new ActivateComparator(); + @Override public int compare(Object o1, Object o2) { if (o1 == null && o2 == null) { return 0; diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/io/StreamUtils.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/io/StreamUtils.java index 0b8536e86e0..98c8ab05822 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/io/StreamUtils.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/io/StreamUtils.java @@ -30,6 +30,7 @@ public static InputStream limitedInputStream(final InputStream is, final int lim return new InputStream() { private int mPosition = 0, mMark = 0, mLimit = Math.min(limit, is.available()); + @Override public int read() throws IOException { if (mPosition < mLimit) { mPosition++; @@ -38,6 +39,7 @@ public int read() throws IOException { return -1; } + @Override public int read(byte b[], int off, int len) throws IOException { if (b == null) throw new NullPointerException(); @@ -59,6 +61,7 @@ public int read(byte b[], int off, int len) throws IOException { return len; } + @Override public long skip(long len) throws IOException { if (mPosition + len > mLimit) len = mLimit - mPosition; @@ -71,24 +74,29 @@ public long skip(long len) throws IOException { return len; } + @Override public int available() { return mLimit - mPosition; } + @Override public boolean markSupported() { return is.markSupported(); } + @Override public void mark(int readlimit) { is.mark(readlimit); mMark = mPosition; } + @Override public void reset() throws IOException { is.reset(); mPosition = mMark; } + @Override public void close() throws IOException { } }; diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/io/UnsafeByteArrayInputStream.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/io/UnsafeByteArrayInputStream.java index 556c76f2032..507ec8c8fa0 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/io/UnsafeByteArrayInputStream.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/io/UnsafeByteArrayInputStream.java @@ -41,10 +41,12 @@ public UnsafeByteArrayInputStream(byte buf[], int offset, int length) { mLimit = Math.min(offset + length, buf.length); } + @Override public int read() { return (mPosition < mLimit) ? (mData[mPosition++] & 0xff) : -1; } + @Override public int read(byte b[], int off, int len) { if (b == null) throw new NullPointerException(); @@ -61,6 +63,7 @@ public int read(byte b[], int off, int len) { return len; } + @Override public long skip(long len) { if (mPosition + len > mLimit) len = mLimit - mPosition; @@ -70,22 +73,27 @@ public long skip(long len) { return len; } + @Override public int available() { return mLimit - mPosition; } + @Override public boolean markSupported() { return true; } + @Override public void mark(int readAheadLimit) { mMark = mPosition; } + @Override public void reset() { mPosition = mMark; } + @Override public void close() throws IOException { } diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/io/UnsafeByteArrayOutputStream.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/io/UnsafeByteArrayOutputStream.java index 1c1d0a697a0..8dfef388e9b 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/io/UnsafeByteArrayOutputStream.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/io/UnsafeByteArrayOutputStream.java @@ -39,6 +39,7 @@ public UnsafeByteArrayOutputStream(int size) { mBuffer = new byte[size]; } + @Override public void write(int b) { int newcount = mCount + 1; if (newcount > mBuffer.length) @@ -47,6 +48,7 @@ public void write(int b) { mCount = newcount; } + @Override public void write(byte b[], int off, int len) { if ((off < 0) || (off > b.length) || (len < 0) || ((off + len) > b.length) || ((off + len) < 0)) throw new IndexOutOfBoundsException(); @@ -79,6 +81,7 @@ public void writeTo(OutputStream out) throws IOException { out.write(mBuffer, 0, mCount); } + @Override public String toString() { return new String(mBuffer, 0, mCount); } @@ -87,6 +90,7 @@ public String toString(String charset) throws UnsupportedEncodingException { return new String(mBuffer, 0, mCount, charset); } + @Override public void close() throws IOException { } } \ No newline at end of file diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/io/UnsafeStringReader.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/io/UnsafeStringReader.java index ac78050e1b6..5122fe7eb0a 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/io/UnsafeStringReader.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/io/UnsafeStringReader.java @@ -61,6 +61,7 @@ public int read(char[] cs, int off, int len) throws IOException { return n; } + @Override public long skip(long ns) throws IOException { ensureOpen(); if (mPosition >= mLimit) @@ -72,6 +73,7 @@ public long skip(long ns) throws IOException { return n; } + @Override public boolean ready() throws IOException { ensureOpen(); return true; @@ -82,6 +84,7 @@ public boolean markSupported() { return true; } + @Override public void mark(int readAheadLimit) throws IOException { if (readAheadLimit < 0) throw new IllegalArgumentException("Read-ahead limit < 0"); @@ -90,6 +93,7 @@ public void mark(int readAheadLimit) throws IOException { mMark = mPosition; } + @Override public void reset() throws IOException { ensureOpen(); mPosition = mMark; diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/GenericJSONConverter.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/GenericJSONConverter.java index 362464a9965..ecf63d307e7 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/GenericJSONConverter.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/GenericJSONConverter.java @@ -41,6 +41,7 @@ public class GenericJSONConverter implements JSONConverter { static { // init encoder map. Encoder e = new Encoder() { + @Override public void encode(Object obj, JSONWriter jb) throws IOException { jb.valueBoolean((Boolean) obj); } @@ -49,6 +50,7 @@ public void encode(Object obj, JSONWriter jb) throws IOException { GlobalEncoderMap.put(Boolean.class, e); e = new Encoder() { + @Override public void encode(Object obj, JSONWriter jb) throws IOException { jb.valueInt(((Number) obj).intValue()); } @@ -62,6 +64,7 @@ public void encode(Object obj, JSONWriter jb) throws IOException { GlobalEncoderMap.put(AtomicInteger.class, e); e = new Encoder() { + @Override public void encode(Object obj, JSONWriter jb) throws IOException { jb.valueString(Character.toString((Character) obj)); } @@ -70,6 +73,7 @@ public void encode(Object obj, JSONWriter jb) throws IOException { GlobalEncoderMap.put(Character.class, e); e = new Encoder() { + @Override public void encode(Object obj, JSONWriter jb) throws IOException { jb.valueLong(((Number) obj).longValue()); } @@ -80,6 +84,7 @@ public void encode(Object obj, JSONWriter jb) throws IOException { GlobalEncoderMap.put(BigInteger.class, e); e = new Encoder() { + @Override public void encode(Object obj, JSONWriter jb) throws IOException { jb.valueFloat(((Number) obj).floatValue()); } @@ -88,6 +93,7 @@ public void encode(Object obj, JSONWriter jb) throws IOException { GlobalEncoderMap.put(Float.class, e); e = new Encoder() { + @Override public void encode(Object obj, JSONWriter jb) throws IOException { jb.valueDouble(((Number) obj).doubleValue()); } @@ -97,6 +103,7 @@ public void encode(Object obj, JSONWriter jb) throws IOException { GlobalEncoderMap.put(BigDecimal.class, e); e = new Encoder() { + @Override public void encode(Object obj, JSONWriter jb) throws IOException { jb.valueString(obj.toString()); } @@ -106,6 +113,7 @@ public void encode(Object obj, JSONWriter jb) throws IOException { GlobalEncoderMap.put(StringBuffer.class, e); e = new Encoder() { + @Override public void encode(Object obj, JSONWriter jb) throws IOException { jb.valueString(Bytes.bytes2base64((byte[]) obj)); } @@ -113,6 +121,7 @@ public void encode(Object obj, JSONWriter jb) throws IOException { GlobalEncoderMap.put(byte[].class, e); e = new Encoder() { + @Override public void encode(Object obj, JSONWriter jb) throws IOException { jb.valueString(new SimpleDateFormat(DATE_FORMAT).format((Date) obj)); } @@ -121,6 +130,7 @@ public void encode(Object obj, JSONWriter jb) throws IOException { // init decoder map. Decoder d = new Decoder() { + @Override public Object decode(Object jv) { return jv.toString(); } @@ -128,6 +138,7 @@ public Object decode(Object jv) { GlobalDecoderMap.put(String.class, d); d = new Decoder() { + @Override public Object decode(Object jv) { if (jv instanceof Boolean) return ((Boolean) jv).booleanValue(); return false; @@ -136,6 +147,7 @@ public Object decode(Object jv) { GlobalDecoderMap.put(boolean.class, d); d = new Decoder() { + @Override public Object decode(Object jv) { if (jv instanceof Boolean) return (Boolean) jv; return (Boolean) null; @@ -144,6 +156,7 @@ public Object decode(Object jv) { GlobalDecoderMap.put(Boolean.class, d); d = new Decoder() { + @Override public Object decode(Object jv) { if (jv instanceof String && ((String) jv).length() > 0) return ((String) jv).charAt(0); return (char) 0; @@ -152,6 +165,7 @@ public Object decode(Object jv) { GlobalDecoderMap.put(char.class, d); d = new Decoder() { + @Override public Object decode(Object jv) { if (jv instanceof String && ((String) jv).length() > 0) return ((String) jv).charAt(0); return (Character) null; @@ -160,6 +174,7 @@ public Object decode(Object jv) { GlobalDecoderMap.put(Character.class, d); d = new Decoder() { + @Override public Object decode(Object jv) { if (jv instanceof Number) return ((Number) jv).intValue(); return 0; @@ -168,6 +183,7 @@ public Object decode(Object jv) { GlobalDecoderMap.put(int.class, d); d = new Decoder() { + @Override public Object decode(Object jv) { if (jv instanceof Number) return Integer.valueOf(((Number) jv).intValue()); return (Integer) null; @@ -176,6 +192,7 @@ public Object decode(Object jv) { GlobalDecoderMap.put(Integer.class, d); d = new Decoder() { + @Override public Object decode(Object jv) { if (jv instanceof Number) return ((Number) jv).shortValue(); return (short) 0; @@ -184,6 +201,7 @@ public Object decode(Object jv) { GlobalDecoderMap.put(short.class, d); d = new Decoder() { + @Override public Object decode(Object jv) { if (jv instanceof Number) return Short.valueOf(((Number) jv).shortValue()); return (Short) null; @@ -192,6 +210,7 @@ public Object decode(Object jv) { GlobalDecoderMap.put(Short.class, d); d = new Decoder() { + @Override public Object decode(Object jv) { if (jv instanceof Number) return ((Number) jv).longValue(); return (long) 0; @@ -200,6 +219,7 @@ public Object decode(Object jv) { GlobalDecoderMap.put(long.class, d); d = new Decoder() { + @Override public Object decode(Object jv) { if (jv instanceof Number) return Long.valueOf(((Number) jv).longValue()); return (Long) null; @@ -208,6 +228,7 @@ public Object decode(Object jv) { GlobalDecoderMap.put(Long.class, d); d = new Decoder() { + @Override public Object decode(Object jv) { if (jv instanceof Number) return ((Number) jv).floatValue(); return (float) 0; @@ -216,6 +237,7 @@ public Object decode(Object jv) { GlobalDecoderMap.put(float.class, d); d = new Decoder() { + @Override public Object decode(Object jv) { if (jv instanceof Number) return new Float(((Number) jv).floatValue()); return (Float) null; @@ -224,6 +246,7 @@ public Object decode(Object jv) { GlobalDecoderMap.put(Float.class, d); d = new Decoder() { + @Override public Object decode(Object jv) { if (jv instanceof Number) return ((Number) jv).doubleValue(); return (double) 0; @@ -232,6 +255,7 @@ public Object decode(Object jv) { GlobalDecoderMap.put(double.class, d); d = new Decoder() { + @Override public Object decode(Object jv) { if (jv instanceof Number) return new Double(((Number) jv).doubleValue()); return (Double) null; @@ -240,6 +264,7 @@ public Object decode(Object jv) { GlobalDecoderMap.put(Double.class, d); d = new Decoder() { + @Override public Object decode(Object jv) { if (jv instanceof Number) return ((Number) jv).byteValue(); return (byte) 0; @@ -248,6 +273,7 @@ public Object decode(Object jv) { GlobalDecoderMap.put(byte.class, d); d = new Decoder() { + @Override public Object decode(Object jv) { if (jv instanceof Number) return Byte.valueOf(((Number) jv).byteValue()); return (Byte) null; @@ -256,6 +282,7 @@ public Object decode(Object jv) { GlobalDecoderMap.put(Byte.class, d); d = new Decoder() { + @Override public Object decode(Object jv) throws IOException { if (jv instanceof String) return Bytes.base642bytes((String) jv); return (byte[]) null; @@ -264,6 +291,7 @@ public Object decode(Object jv) throws IOException { GlobalDecoderMap.put(byte[].class, d); d = new Decoder() { + @Override public Object decode(Object jv) throws IOException { return new StringBuilder(jv.toString()); } @@ -271,6 +299,7 @@ public Object decode(Object jv) throws IOException { GlobalDecoderMap.put(StringBuilder.class, d); d = new Decoder() { + @Override public Object decode(Object jv) throws IOException { return new StringBuffer(jv.toString()); } @@ -278,6 +307,7 @@ public Object decode(Object jv) throws IOException { GlobalDecoderMap.put(StringBuffer.class, d); d = new Decoder() { + @Override public Object decode(Object jv) throws IOException { if (jv instanceof Number) return BigInteger.valueOf(((Number) jv).longValue()); return (BigInteger) null; @@ -286,6 +316,7 @@ public Object decode(Object jv) throws IOException { GlobalDecoderMap.put(BigInteger.class, d); d = new Decoder() { + @Override public Object decode(Object jv) throws IOException { if (jv instanceof Number) return BigDecimal.valueOf(((Number) jv).doubleValue()); return (BigDecimal) null; @@ -294,6 +325,7 @@ public Object decode(Object jv) throws IOException { GlobalDecoderMap.put(BigDecimal.class, d); d = new Decoder() { + @Override public Object decode(Object jv) throws IOException { if (jv instanceof Number) return new AtomicInteger(((Number) jv).intValue()); return (AtomicInteger) null; @@ -302,6 +334,7 @@ public Object decode(Object jv) throws IOException { GlobalDecoderMap.put(AtomicInteger.class, d); d = new Decoder() { + @Override public Object decode(Object jv) throws IOException { if (jv instanceof Number) return new AtomicLong(((Number) jv).longValue()); return (AtomicLong) null; @@ -310,6 +343,7 @@ public Object decode(Object jv) throws IOException { GlobalDecoderMap.put(AtomicLong.class, d); d = new Decoder() { + @Override public Object decode(Object jv) throws IOException { if (jv instanceof String) { try { @@ -326,6 +360,7 @@ public Object decode(Object jv) throws IOException { GlobalDecoderMap.put(Date.class, d); } + @Override @SuppressWarnings("unchecked") public void writeValue(Object obj, JSONWriter jb, boolean writeClass) throws IOException { if (obj == null) { @@ -403,6 +438,7 @@ public void writeValue(Object obj, JSONWriter jb, boolean writeClass) throws IOE } } + @Override @SuppressWarnings({"unchecked", "rawtypes"}) public Object readValue(Class c, Object jv) throws IOException { if (jv == null) { diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/J2oVisitor.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/J2oVisitor.java index f0b3d10a336..7fa57f51615 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/J2oVisitor.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/J2oVisitor.java @@ -196,9 +196,11 @@ private static String name(Class[] types) { return sb.toString(); } + @Override public void begin() { } + @Override public Object end(Object obj, boolean isValue) throws ParseException { mStack.clear(); try { @@ -208,6 +210,7 @@ public Object end(Object obj, boolean isValue) throws ParseException { } } + @Override public void objectBegin() throws ParseException { mStack.push(mValue); mStack.push(mType); @@ -238,6 +241,7 @@ public void objectBegin() throws ParseException { } } + @Override public Object objectEnd(int count) { Object ret = mValue; mWrapper = (Wrapper) mStack.pop(); @@ -246,11 +250,13 @@ public Object objectEnd(int count) { return ret; } + @Override public void objectItem(String name) { mStack.push(name); // push name. mType = (mWrapper == null ? Object.class : mWrapper.getPropertyType(name)); } + @Override @SuppressWarnings("unchecked") public void objectItemValue(Object obj, boolean isValue) throws ParseException { String name = (String) mStack.pop(); // pop name. @@ -284,6 +290,7 @@ public void objectItemValue(Object obj, boolean isValue) throws ParseException { } } + @Override public void arrayBegin() throws ParseException { mStack.push(mType); @@ -295,6 +302,7 @@ else if (mType == Object.class || Collection.class.isAssignableFrom(mType)) throw new ParseException("Convert error, can not load json array data into class [" + mType.getName() + "]."); } + @Override @SuppressWarnings("unchecked") public Object arrayEnd(int count) throws ParseException { Object ret; @@ -331,6 +339,7 @@ public Object arrayEnd(int count) throws ParseException { return ret; } + @Override public void arrayItem(int index) throws ParseException { if (mTypes != null && mStack.size() == index + 1) { if (index < mTypes.length) @@ -340,6 +349,7 @@ public void arrayItem(int index) throws ParseException { } } + @Override public void arrayItemValue(int index, Object obj, boolean isValue) throws ParseException { if (isValue && obj != null) { try { diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONArray.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONArray.java index 6003664a76c..10ac398abca 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONArray.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONArray.java @@ -168,6 +168,7 @@ public void addAll(Collection c) { * @param jc json converter * @param jb json builder. */ + @Override public void writeJSON(JSONConverter jc, JSONWriter jb, boolean writeClass) throws IOException { jb.arrayBegin(); for (Object item : mArray) { diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONObject.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONObject.java index bfa32b38730..79469ff5da8 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONObject.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONObject.java @@ -187,6 +187,7 @@ public void putAll(Map map) { * @param jc json converter. * @param jb json builder. */ + @Override public void writeJSON(JSONConverter jc, JSONWriter jb, boolean writeClass) throws IOException { String key; Object value; diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/logger/jcl/JclLogger.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/logger/jcl/JclLogger.java index 8d8625aadae..428fd3d405b 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/logger/jcl/JclLogger.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/logger/jcl/JclLogger.java @@ -35,82 +35,102 @@ public JclLogger(Log logger) { this.logger = logger; } + @Override public void trace(String msg) { logger.trace(msg); } + @Override public void trace(Throwable e) { logger.trace(e); } + @Override public void trace(String msg, Throwable e) { logger.trace(msg, e); } + @Override public void debug(String msg) { logger.debug(msg); } + @Override public void debug(Throwable e) { logger.debug(e); } + @Override public void debug(String msg, Throwable e) { logger.debug(msg, e); } + @Override public void info(String msg) { logger.info(msg); } + @Override public void info(Throwable e) { logger.info(e); } + @Override public void info(String msg, Throwable e) { logger.info(msg, e); } + @Override public void warn(String msg) { logger.warn(msg); } + @Override public void warn(Throwable e) { logger.warn(e); } + @Override public void warn(String msg, Throwable e) { logger.warn(msg, e); } + @Override public void error(String msg) { logger.error(msg); } + @Override public void error(Throwable e) { logger.error(e); } + @Override public void error(String msg, Throwable e) { logger.error(msg, e); } + @Override public boolean isTraceEnabled() { return logger.isTraceEnabled(); } + @Override public boolean isDebugEnabled() { return logger.isDebugEnabled(); } + @Override public boolean isInfoEnabled() { return logger.isInfoEnabled(); } + @Override public boolean isWarnEnabled() { return logger.isWarnEnabled(); } + @Override public boolean isErrorEnabled() { return logger.isErrorEnabled(); } diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/logger/jcl/JclLoggerAdapter.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/logger/jcl/JclLoggerAdapter.java index 5c0738081b7..52a062ee756 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/logger/jcl/JclLoggerAdapter.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/logger/jcl/JclLoggerAdapter.java @@ -28,26 +28,32 @@ public class JclLoggerAdapter implements LoggerAdapter { private Level level; private File file; + @Override public Logger getLogger(String key) { return new JclLogger(LogFactory.getLog(key)); } + @Override public Logger getLogger(Class key) { return new JclLogger(LogFactory.getLog(key)); } + @Override public Level getLevel() { return level; } + @Override public void setLevel(Level level) { this.level = level; } + @Override public File getFile() { return file; } + @Override public void setFile(File file) { this.file = file; } diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/logger/jdk/JdkLogger.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/logger/jdk/JdkLogger.java index 71c8f2777b4..aa7c9223d82 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/logger/jdk/JdkLogger.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/logger/jdk/JdkLogger.java @@ -28,82 +28,102 @@ public JdkLogger(java.util.logging.Logger logger) { this.logger = logger; } + @Override public void trace(String msg) { logger.log(Level.FINER, msg); } + @Override public void trace(Throwable e) { logger.log(Level.FINER, e.getMessage(), e); } + @Override public void trace(String msg, Throwable e) { logger.log(Level.FINER, msg, e); } + @Override public void debug(String msg) { logger.log(Level.FINE, msg); } + @Override public void debug(Throwable e) { logger.log(Level.FINE, e.getMessage(), e); } + @Override public void debug(String msg, Throwable e) { logger.log(Level.FINE, msg, e); } + @Override public void info(String msg) { logger.log(Level.INFO, msg); } + @Override public void info(String msg, Throwable e) { logger.log(Level.INFO, msg, e); } + @Override public void warn(String msg) { logger.log(Level.WARNING, msg); } + @Override public void warn(String msg, Throwable e) { logger.log(Level.WARNING, msg, e); } + @Override public void error(String msg) { logger.log(Level.SEVERE, msg); } + @Override public void error(String msg, Throwable e) { logger.log(Level.SEVERE, msg, e); } + @Override public void error(Throwable e) { logger.log(Level.SEVERE, e.getMessage(), e); } + @Override public void info(Throwable e) { logger.log(Level.INFO, e.getMessage(), e); } + @Override public void warn(Throwable e) { logger.log(Level.WARNING, e.getMessage(), e); } + @Override public boolean isTraceEnabled() { return logger.isLoggable(Level.FINER); } + @Override public boolean isDebugEnabled() { return logger.isLoggable(Level.FINE); } + @Override public boolean isInfoEnabled() { return logger.isLoggable(Level.INFO); } + @Override public boolean isWarnEnabled() { return logger.isLoggable(Level.WARNING); } + @Override public boolean isErrorEnabled() { return logger.isLoggable(Level.SEVERE); } diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/logger/jdk/JdkLoggerAdapter.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/logger/jdk/JdkLoggerAdapter.java index 9c4cb552bc2..fe686727ecc 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/logger/jdk/JdkLoggerAdapter.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/logger/jdk/JdkLoggerAdapter.java @@ -94,26 +94,32 @@ private static Level fromJdkLevel(java.util.logging.Level level) { return Level.OFF; } + @Override public Logger getLogger(Class key) { return new JdkLogger(java.util.logging.Logger.getLogger(key == null ? "" : key.getName())); } + @Override public Logger getLogger(String key) { return new JdkLogger(java.util.logging.Logger.getLogger(key)); } + @Override public Level getLevel() { return fromJdkLevel(java.util.logging.Logger.getLogger(GLOBAL_LOGGER_NAME).getLevel()); } + @Override public void setLevel(Level level) { java.util.logging.Logger.getLogger(GLOBAL_LOGGER_NAME).setLevel(toJdkLevel(level)); } + @Override public File getFile() { return file; } + @Override public void setFile(File file) { } diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/logger/log4j/Log4jLogger.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/logger/log4j/Log4jLogger.java index e92fb1a108c..1e6480eb39b 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/logger/log4j/Log4jLogger.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/logger/log4j/Log4jLogger.java @@ -31,82 +31,102 @@ public Log4jLogger(org.apache.log4j.Logger logger) { this.logger = logger; } + @Override public void trace(String msg) { logger.log(FQCN, Level.TRACE, msg, null); } + @Override public void trace(Throwable e) { logger.log(FQCN, Level.TRACE, e == null ? null : e.getMessage(), e); } + @Override public void trace(String msg, Throwable e) { logger.log(FQCN, Level.TRACE, msg, e); } + @Override public void debug(String msg) { logger.log(FQCN, Level.DEBUG, msg, null); } + @Override public void debug(Throwable e) { logger.log(FQCN, Level.DEBUG, e == null ? null : e.getMessage(), e); } + @Override public void debug(String msg, Throwable e) { logger.log(FQCN, Level.DEBUG, msg, e); } + @Override public void info(String msg) { logger.log(FQCN, Level.INFO, msg, null); } + @Override public void info(Throwable e) { logger.log(FQCN, Level.INFO, e == null ? null : e.getMessage(), e); } + @Override public void info(String msg, Throwable e) { logger.log(FQCN, Level.INFO, msg, e); } + @Override public void warn(String msg) { logger.log(FQCN, Level.WARN, msg, null); } + @Override public void warn(Throwable e) { logger.log(FQCN, Level.WARN, e == null ? null : e.getMessage(), e); } + @Override public void warn(String msg, Throwable e) { logger.log(FQCN, Level.WARN, msg, e); } + @Override public void error(String msg) { logger.log(FQCN, Level.ERROR, msg, null); } + @Override public void error(Throwable e) { logger.log(FQCN, Level.ERROR, e == null ? null : e.getMessage(), e); } + @Override public void error(String msg, Throwable e) { logger.log(FQCN, Level.ERROR, msg, e); } + @Override public boolean isTraceEnabled() { return logger.isTraceEnabled(); } + @Override public boolean isDebugEnabled() { return logger.isDebugEnabled(); } + @Override public boolean isInfoEnabled() { return logger.isInfoEnabled(); } + @Override public boolean isWarnEnabled() { return logger.isEnabledFor(Level.WARN); } + @Override public boolean isErrorEnabled() { return logger.isEnabledFor(Level.ERROR); } diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/logger/log4j/Log4jLoggerAdapter.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/logger/log4j/Log4jLoggerAdapter.java index f051a093cf3..f5967b9c95a 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/logger/log4j/Log4jLoggerAdapter.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/logger/log4j/Log4jLoggerAdapter.java @@ -87,26 +87,32 @@ private static Level fromLog4jLevel(org.apache.log4j.Level level) { return Level.OFF; } + @Override public Logger getLogger(Class key) { return new Log4jLogger(LogManager.getLogger(key)); } + @Override public Logger getLogger(String key) { return new Log4jLogger(LogManager.getLogger(key)); } + @Override public Level getLevel() { return fromLog4jLevel(LogManager.getRootLogger().getLevel()); } + @Override public void setLevel(Level level) { LogManager.getRootLogger().setLevel(toLog4jLevel(level)); } + @Override public File getFile() { return file; } + @Override public void setFile(File file) { } diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/logger/slf4j/Slf4jLogger.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/logger/slf4j/Slf4jLogger.java index 563deea4fe7..8eae7002bdb 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/logger/slf4j/Slf4jLogger.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/logger/slf4j/Slf4jLogger.java @@ -42,6 +42,7 @@ public Slf4jLogger(org.slf4j.Logger logger) { this.logger = logger; } + @Override public void trace(String msg) { if (locationAwareLogger != null) { locationAwareLogger.log(null, FQCN, LocationAwareLogger.TRACE_INT, msg, null, null); @@ -50,6 +51,7 @@ public void trace(String msg) { logger.trace(msg); } + @Override public void trace(Throwable e) { if (locationAwareLogger != null) { locationAwareLogger.log(null, FQCN, LocationAwareLogger.TRACE_INT, e.getMessage(), null, e); @@ -58,6 +60,7 @@ public void trace(Throwable e) { logger.trace(e.getMessage(), e); } + @Override public void trace(String msg, Throwable e) { if (locationAwareLogger != null) { locationAwareLogger.log(null, FQCN, LocationAwareLogger.TRACE_INT, msg, null, e); @@ -66,6 +69,7 @@ public void trace(String msg, Throwable e) { logger.trace(msg, e); } + @Override public void debug(String msg) { if (locationAwareLogger != null) { locationAwareLogger.log(null, FQCN, LocationAwareLogger.DEBUG_INT, msg, null, null); @@ -74,6 +78,7 @@ public void debug(String msg) { logger.debug(msg); } + @Override public void debug(Throwable e) { if (locationAwareLogger != null) { locationAwareLogger.log(null, FQCN, LocationAwareLogger.DEBUG_INT, e.getMessage(), null, e); @@ -82,6 +87,7 @@ public void debug(Throwable e) { logger.debug(e.getMessage(), e); } + @Override public void debug(String msg, Throwable e) { if (locationAwareLogger != null) { locationAwareLogger.log(null, FQCN, LocationAwareLogger.DEBUG_INT, msg, null, e); @@ -90,6 +96,7 @@ public void debug(String msg, Throwable e) { logger.debug(msg, e); } + @Override public void info(String msg) { if (locationAwareLogger != null) { locationAwareLogger.log(null, FQCN, LocationAwareLogger.INFO_INT, msg, null, null); @@ -98,6 +105,7 @@ public void info(String msg) { logger.info(msg); } + @Override public void info(Throwable e) { if (locationAwareLogger != null) { locationAwareLogger.log(null, FQCN, LocationAwareLogger.INFO_INT, e.getMessage(), null, e); @@ -106,6 +114,7 @@ public void info(Throwable e) { logger.info(e.getMessage(), e); } + @Override public void info(String msg, Throwable e) { if (locationAwareLogger != null) { locationAwareLogger.log(null, FQCN, LocationAwareLogger.INFO_INT, msg, null, e); @@ -114,6 +123,7 @@ public void info(String msg, Throwable e) { logger.info(msg, e); } + @Override public void warn(String msg) { if (locationAwareLogger != null) { locationAwareLogger.log(null, FQCN, LocationAwareLogger.WARN_INT, msg, null, null); @@ -122,6 +132,7 @@ public void warn(String msg) { logger.warn(msg); } + @Override public void warn(Throwable e) { if (locationAwareLogger != null) { locationAwareLogger.log(null, FQCN, LocationAwareLogger.WARN_INT, e.getMessage(), null, e); @@ -130,6 +141,7 @@ public void warn(Throwable e) { logger.warn(e.getMessage(), e); } + @Override public void warn(String msg, Throwable e) { if (locationAwareLogger != null) { locationAwareLogger.log(null, FQCN, LocationAwareLogger.WARN_INT, msg, null, e); @@ -138,6 +150,7 @@ public void warn(String msg, Throwable e) { logger.warn(msg, e); } + @Override public void error(String msg) { if (locationAwareLogger != null) { locationAwareLogger.log(null, FQCN, LocationAwareLogger.ERROR_INT, msg, null, null); @@ -146,6 +159,7 @@ public void error(String msg) { logger.error(msg); } + @Override public void error(Throwable e) { if (locationAwareLogger != null) { locationAwareLogger.log(null, FQCN, LocationAwareLogger.ERROR_INT, e.getMessage(), null, e); @@ -154,6 +168,7 @@ public void error(Throwable e) { logger.error(e.getMessage(), e); } + @Override public void error(String msg, Throwable e) { if (locationAwareLogger != null) { locationAwareLogger.log(null, FQCN, LocationAwareLogger.ERROR_INT, msg, null, e); @@ -162,22 +177,27 @@ public void error(String msg, Throwable e) { logger.error(msg, e); } + @Override public boolean isTraceEnabled() { return logger.isTraceEnabled(); } + @Override public boolean isDebugEnabled() { return logger.isDebugEnabled(); } + @Override public boolean isInfoEnabled() { return logger.isInfoEnabled(); } + @Override public boolean isWarnEnabled() { return logger.isWarnEnabled(); } + @Override public boolean isErrorEnabled() { return logger.isErrorEnabled(); } diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/logger/slf4j/Slf4jLoggerAdapter.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/logger/slf4j/Slf4jLoggerAdapter.java index a9eb18af70e..788920399f0 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/logger/slf4j/Slf4jLoggerAdapter.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/logger/slf4j/Slf4jLoggerAdapter.java @@ -27,26 +27,32 @@ public class Slf4jLoggerAdapter implements LoggerAdapter { private Level level; private File file; + @Override public Logger getLogger(String key) { return new Slf4jLogger(org.slf4j.LoggerFactory.getLogger(key)); } + @Override public Logger getLogger(Class key) { return new Slf4jLogger(org.slf4j.LoggerFactory.getLogger(key)); } + @Override public Level getLevel() { return level; } + @Override public void setLevel(Level level) { this.level = level; } + @Override public File getFile() { return file; } + @Override public void setFile(File file) { this.file = file; } diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/logger/support/FailsafeLogger.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/logger/support/FailsafeLogger.java index 858a4e085f2..668434a0b19 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/logger/support/FailsafeLogger.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/logger/support/FailsafeLogger.java @@ -40,6 +40,7 @@ private String appendContextMessage(String msg) { return " [DUBBO] " + msg + ", dubbo version: " + Version.getVersion() + ", current host: " + NetUtils.getLogHost(); } + @Override public void trace(String msg, Throwable e) { try { logger.trace(appendContextMessage(msg), e); @@ -47,6 +48,7 @@ public void trace(String msg, Throwable e) { } } + @Override public void trace(Throwable e) { try { logger.trace(e); @@ -54,6 +56,7 @@ public void trace(Throwable e) { } } + @Override public void trace(String msg) { try { logger.trace(appendContextMessage(msg)); @@ -61,6 +64,7 @@ public void trace(String msg) { } } + @Override public void debug(String msg, Throwable e) { try { logger.debug(appendContextMessage(msg), e); @@ -68,6 +72,7 @@ public void debug(String msg, Throwable e) { } } + @Override public void debug(Throwable e) { try { logger.debug(e); @@ -75,6 +80,7 @@ public void debug(Throwable e) { } } + @Override public void debug(String msg) { try { logger.debug(appendContextMessage(msg)); @@ -82,6 +88,7 @@ public void debug(String msg) { } } + @Override public void info(String msg, Throwable e) { try { logger.info(appendContextMessage(msg), e); @@ -89,6 +96,7 @@ public void info(String msg, Throwable e) { } } + @Override public void info(String msg) { try { logger.info(appendContextMessage(msg)); @@ -96,6 +104,7 @@ public void info(String msg) { } } + @Override public void warn(String msg, Throwable e) { try { logger.warn(appendContextMessage(msg), e); @@ -103,6 +112,7 @@ public void warn(String msg, Throwable e) { } } + @Override public void warn(String msg) { try { logger.warn(appendContextMessage(msg)); @@ -110,6 +120,7 @@ public void warn(String msg) { } } + @Override public void error(String msg, Throwable e) { try { logger.error(appendContextMessage(msg), e); @@ -117,6 +128,7 @@ public void error(String msg, Throwable e) { } } + @Override public void error(String msg) { try { logger.error(appendContextMessage(msg)); @@ -124,6 +136,7 @@ public void error(String msg) { } } + @Override public void error(Throwable e) { try { logger.error(e); @@ -131,6 +144,7 @@ public void error(Throwable e) { } } + @Override public void info(Throwable e) { try { logger.info(e); @@ -138,6 +152,7 @@ public void info(Throwable e) { } } + @Override public void warn(Throwable e) { try { logger.warn(e); @@ -145,6 +160,7 @@ public void warn(Throwable e) { } } + @Override public boolean isTraceEnabled() { try { return logger.isTraceEnabled(); @@ -153,6 +169,7 @@ public boolean isTraceEnabled() { } } + @Override public boolean isDebugEnabled() { try { return logger.isDebugEnabled(); @@ -161,6 +178,7 @@ public boolean isDebugEnabled() { } } + @Override public boolean isInfoEnabled() { try { return logger.isInfoEnabled(); @@ -169,6 +187,7 @@ public boolean isInfoEnabled() { } } + @Override public boolean isWarnEnabled() { try { return logger.isWarnEnabled(); @@ -177,6 +196,7 @@ public boolean isWarnEnabled() { } } + @Override public boolean isErrorEnabled() { try { return logger.isErrorEnabled(); diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/dubbo/Builder.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/dubbo/Builder.java index f8b6fa8f594..b6838ae494d 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/dubbo/Builder.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/dubbo/Builder.java @@ -110,18 +110,21 @@ public Serializable parseFrom(GenericObjectInput in) throws IOException { private static final int MAX_FIELD_CONFIG_FILE_SIZE = 16 * 1024; private static final Comparator FNC = new Comparator() { + @Override public int compare(String n1, String n2) { return compareFieldName(n1, n2); } }; private static final Comparator FC = new Comparator() { + @Override public int compare(Field f1, Field f2) { return compareFieldName(f1.getName(), f2.getName()); } }; private static final Comparator CC = new Comparator() { + @Override public int compare(Constructor o1, Constructor o2) { return o1.getParameterTypes().length - o2.getParameterTypes().length; } @@ -133,12 +136,14 @@ public int compare(Constructor o1, Constructor o2) { private static final Map mDescMap = new ConcurrentHashMap(); public static ClassDescriptorMapper DEFAULT_CLASS_DESCRIPTOR_MAPPER = new ClassDescriptorMapper() { + @Override public String getDescriptor(int index) { if (index < 0 || index >= mDescList.size()) return null; return mDescList.get(index); } + @Override public int getDescriptorIndex(String desc) { Integer ret = mDescMap.get(desc); return ret == null ? -1 : ret.intValue(); @@ -1367,8 +1372,10 @@ static class PropertyMetadata { } public static abstract class AbstractObjectBuilder extends Builder { + @Override abstract public Class getType(); + @Override public void writeTo(T obj, GenericObjectOutput out) throws IOException { if (obj == null) { out.write0(OBJECT_NULL); @@ -1385,6 +1392,7 @@ public void writeTo(T obj, GenericObjectOutput out) throws IOException { } } + @Override public T parseFrom(GenericObjectInput in) throws IOException { byte b = in.read0(); switch (b) { diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/dubbo/DubboSerialization.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/dubbo/DubboSerialization.java index 3a475285b28..d5dcfc71d76 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/dubbo/DubboSerialization.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/dubbo/DubboSerialization.java @@ -27,18 +27,22 @@ public class DubboSerialization implements Serialization { + @Override public byte getContentTypeId() { return 1; } + @Override public String getContentType() { return "x-application/dubbo"; } + @Override public ObjectOutput serialize(URL url, OutputStream out) throws IOException { return new GenericObjectOutput(out); } + @Override public ObjectInput deserialize(URL url, InputStream is) throws IOException { return new GenericObjectInput(is); } diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/dubbo/GenericDataInput.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/dubbo/GenericDataInput.java index c899727a7ab..13beb3c7296 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/dubbo/GenericDataInput.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/dubbo/GenericDataInput.java @@ -50,6 +50,7 @@ public GenericDataInput(InputStream is, int buffSize) { mBuffer = new byte[buffSize]; } + @Override public boolean readBool() throws IOException { byte b = read0(); @@ -63,6 +64,7 @@ public boolean readBool() throws IOException { } } + @Override public byte readByte() throws IOException { byte b = read0(); @@ -138,26 +140,32 @@ public byte readByte() throws IOException { } } + @Override public short readShort() throws IOException { return (short) readVarint32(); } + @Override public int readInt() throws IOException { return readVarint32(); } + @Override public long readLong() throws IOException { return readVarint64(); } + @Override public float readFloat() throws IOException { return Float.intBitsToFloat(readVarint32()); } + @Override public double readDouble() throws IOException { return Double.longBitsToDouble(readVarint64()); } + @Override public String readUTF() throws IOException { byte b = read0(); @@ -189,6 +197,7 @@ public String readUTF() throws IOException { } } + @Override public byte[] readBytes() throws IOException { byte b = read0(); @@ -415,7 +424,7 @@ private long readVarint64() throws IOException { (((long) b4 & 0xff) << 24) | (((long) b5 & 0xff) << 32); if (b5 < 0) - return ret | 0xffffff0000000000l; + return ret | 0xffffff0000000000L; return ret; } case VARINT48: { @@ -427,7 +436,7 @@ private long readVarint64() throws IOException { (((long) b5 & 0xff) << 32) | (((long) b6 & 0xff) << 40); if (b6 < 0) - return ret | 0xffff000000000000l; + return ret | 0xffff000000000000L; return ret; } case VARINT56: { @@ -440,7 +449,7 @@ private long readVarint64() throws IOException { (((long) b6 & 0xff) << 40) | (((long) b7 & 0xff) << 48); if (b7 < 0) - return ret | 0xff00000000000000l; + return ret | 0xff00000000000000L; return ret; } case VARINT64: { diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/dubbo/GenericDataOutput.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/dubbo/GenericDataOutput.java index 3119e9ccf71..f14384009ae 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/dubbo/GenericDataOutput.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/dubbo/GenericDataOutput.java @@ -49,10 +49,12 @@ public GenericDataOutput(OutputStream out, int buffSize) { mBuffer = new byte[buffSize]; } + @Override public void writeBool(boolean v) throws IOException { write0(v ? VARINT_1 : VARINT_0); } + @Override public void writeByte(byte v) throws IOException { switch (v) { case 0: @@ -157,26 +159,32 @@ public void writeByte(byte v) throws IOException { } } + @Override public void writeShort(short v) throws IOException { writeVarint32(v); } + @Override public void writeInt(int v) throws IOException { writeVarint32(v); } + @Override public void writeLong(long v) throws IOException { writeVarint64(v); } + @Override public void writeFloat(float v) throws IOException { writeVarint32(Float.floatToRawIntBits(v)); } + @Override public void writeDouble(double v) throws IOException { writeVarint64(Double.doubleToRawLongBits(v)); } + @Override public void writeUTF(String v) throws IOException { if (v == null) { write0(OBJECT_NULL); @@ -227,6 +235,7 @@ public void writeUTF(String v) throws IOException { } } + @Override public void writeBytes(byte[] b) throws IOException { if (b == null) write0(OBJECT_NULL); @@ -234,6 +243,7 @@ public void writeBytes(byte[] b) throws IOException { writeBytes(b, 0, b.length); } + @Override public void writeBytes(byte[] b, int off, int len) throws IOException { if (len == 0) { write0(OBJECT_DUMMY); @@ -244,6 +254,7 @@ public void writeBytes(byte[] b, int off, int len) throws IOException { } } + @Override public void flushBuffer() throws IOException { if (mPosition > 0) { mOutput.write(mBuffer, 0, mPosition); diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/dubbo/GenericObjectInput.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/dubbo/GenericObjectInput.java index 3f56218c741..c423ae479fa 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/dubbo/GenericObjectInput.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/dubbo/GenericObjectInput.java @@ -54,6 +54,7 @@ public GenericObjectInput(InputStream is, int buffSize, ClassDescriptorMapper ma mMapper = mapper; } + @Override public Object readObject() throws IOException { String desc; byte b = read0(); @@ -85,11 +86,13 @@ public Object readObject() throws IOException { } } + @Override @SuppressWarnings("unchecked") public T readObject(Class cls) throws IOException, ClassNotFoundException { return (T) readObject(); } + @Override @SuppressWarnings("unchecked") public T readObject(Class cls, Type type) throws IOException, ClassNotFoundException { return (T) readObject(); diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/dubbo/GenericObjectOutput.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/dubbo/GenericObjectOutput.java index 71e9eb9a92b..d699aff7eb2 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/dubbo/GenericObjectOutput.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/dubbo/GenericObjectOutput.java @@ -56,6 +56,7 @@ public GenericObjectOutput(OutputStream out, int buffSize, ClassDescriptorMapper this.isAllowNonSerializable = isAllowNonSerializable; } + @Override @SuppressWarnings({"unchecked", "rawtypes"}) public void writeObject(Object obj) throws IOException { if (obj == null) { diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/fst/FstObjectInput.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/fst/FstObjectInput.java index 975c9bda5e6..0c6084aea17 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/fst/FstObjectInput.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/fst/FstObjectInput.java @@ -33,34 +33,42 @@ public FstObjectInput(InputStream inputStream) { input = FstFactory.getDefaultFactory().getObjectInput(inputStream); } + @Override public boolean readBool() throws IOException { return input.readBoolean(); } + @Override public byte readByte() throws IOException { return input.readByte(); } + @Override public short readShort() throws IOException { return input.readShort(); } + @Override public int readInt() throws IOException { return input.readInt(); } + @Override public long readLong() throws IOException { return input.readLong(); } + @Override public float readFloat() throws IOException { return input.readFloat(); } + @Override public double readDouble() throws IOException { return input.readDouble(); } + @Override public byte[] readBytes() throws IOException { int len = input.readInt(); if (len < 0) { @@ -74,20 +82,24 @@ public byte[] readBytes() throws IOException { } } + @Override public String readUTF() throws IOException { return input.readUTF(); } + @Override public Object readObject() throws IOException, ClassNotFoundException { return input.readObject(); } + @Override @SuppressWarnings("unchecked") public T readObject(Class clazz) throws IOException, ClassNotFoundException { return (T) readObject(); } + @Override @SuppressWarnings("unchecked") public T readObject(Class clazz, Type type) throws IOException, ClassNotFoundException { return (T) readObject(); diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/fst/FstObjectOutput.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/fst/FstObjectOutput.java index e546ff1b151..8b35ef3c80f 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/fst/FstObjectOutput.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/fst/FstObjectOutput.java @@ -32,34 +32,42 @@ public FstObjectOutput(OutputStream outputStream) { output = FstFactory.getDefaultFactory().getObjectOutput(outputStream); } + @Override public void writeBool(boolean v) throws IOException { output.writeBoolean(v); } + @Override public void writeByte(byte v) throws IOException { output.writeByte(v); } + @Override public void writeShort(short v) throws IOException { output.writeShort(v); } + @Override public void writeInt(int v) throws IOException { output.writeInt(v); } + @Override public void writeLong(long v) throws IOException { output.writeLong(v); } + @Override public void writeFloat(float v) throws IOException { output.writeFloat(v); } + @Override public void writeDouble(double v) throws IOException { output.writeDouble(v); } + @Override public void writeBytes(byte[] v) throws IOException { if (v == null) { output.writeInt(-1); @@ -68,6 +76,7 @@ public void writeBytes(byte[] v) throws IOException { } } + @Override public void writeBytes(byte[] v, int off, int len) throws IOException { if (v == null) { output.writeInt(-1); @@ -78,14 +87,17 @@ public void writeBytes(byte[] v, int off, int len) throws IOException { } + @Override public void writeUTF(String v) throws IOException { output.writeUTF(v); } + @Override public void writeObject(Object v) throws IOException { output.writeObject(v); } + @Override public void flushBuffer() throws IOException { output.flush(); } diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/fst/FstSerialization.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/fst/FstSerialization.java index cd5e50e4177..29a6da8d27c 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/fst/FstSerialization.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/fst/FstSerialization.java @@ -27,18 +27,22 @@ public class FstSerialization implements Serialization { + @Override public byte getContentTypeId() { return 9; } + @Override public String getContentType() { return "x-application/fst"; } + @Override public ObjectOutput serialize(URL url, OutputStream out) throws IOException { return new FstObjectOutput(out); } + @Override public ObjectInput deserialize(URL url, InputStream is) throws IOException { return new FstObjectInput(is); } diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/hessian/Hessian2ObjectInput.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/hessian/Hessian2ObjectInput.java index 6de66982c27..57b878bcf57 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/hessian/Hessian2ObjectInput.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/hessian/Hessian2ObjectInput.java @@ -34,52 +34,64 @@ public Hessian2ObjectInput(InputStream is) { mH2i.setSerializerFactory(Hessian2SerializerFactory.SERIALIZER_FACTORY); } + @Override public boolean readBool() throws IOException { return mH2i.readBoolean(); } + @Override public byte readByte() throws IOException { return (byte) mH2i.readInt(); } + @Override public short readShort() throws IOException { return (short) mH2i.readInt(); } + @Override public int readInt() throws IOException { return mH2i.readInt(); } + @Override public long readLong() throws IOException { return mH2i.readLong(); } + @Override public float readFloat() throws IOException { return (float) mH2i.readDouble(); } + @Override public double readDouble() throws IOException { return mH2i.readDouble(); } + @Override public byte[] readBytes() throws IOException { return mH2i.readBytes(); } + @Override public String readUTF() throws IOException { return mH2i.readString(); } + @Override public Object readObject() throws IOException { return mH2i.readObject(); } + @Override @SuppressWarnings("unchecked") public T readObject(Class cls) throws IOException, ClassNotFoundException { return (T) mH2i.readObject(cls); } + @Override public T readObject(Class cls, Type type) throws IOException, ClassNotFoundException { return readObject(cls); } diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/hessian/Hessian2ObjectOutput.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/hessian/Hessian2ObjectOutput.java index 6a2fa67bf76..7103bd6fcb7 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/hessian/Hessian2ObjectOutput.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/hessian/Hessian2ObjectOutput.java @@ -33,50 +33,62 @@ public Hessian2ObjectOutput(OutputStream os) { mH2o.setSerializerFactory(Hessian2SerializerFactory.SERIALIZER_FACTORY); } + @Override public void writeBool(boolean v) throws IOException { mH2o.writeBoolean(v); } + @Override public void writeByte(byte v) throws IOException { mH2o.writeInt(v); } + @Override public void writeShort(short v) throws IOException { mH2o.writeInt(v); } + @Override public void writeInt(int v) throws IOException { mH2o.writeInt(v); } + @Override public void writeLong(long v) throws IOException { mH2o.writeLong(v); } + @Override public void writeFloat(float v) throws IOException { mH2o.writeDouble(v); } + @Override public void writeDouble(double v) throws IOException { mH2o.writeDouble(v); } + @Override public void writeBytes(byte[] b) throws IOException { mH2o.writeBytes(b); } + @Override public void writeBytes(byte[] b, int off, int len) throws IOException { mH2o.writeBytes(b, off, len); } + @Override public void writeUTF(String v) throws IOException { mH2o.writeString(v); } + @Override public void writeObject(Object obj) throws IOException { mH2o.writeObject(obj); } + @Override public void flushBuffer() throws IOException { mH2o.flushBuffer(); } diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/hessian/Hessian2Serialization.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/hessian/Hessian2Serialization.java index eb78df05020..b0810fc8fd4 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/hessian/Hessian2Serialization.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/hessian/Hessian2Serialization.java @@ -29,18 +29,22 @@ public class Hessian2Serialization implements Serialization { public static final byte ID = 2; + @Override public byte getContentTypeId() { return ID; } + @Override public String getContentType() { return "x-application/hessian2"; } + @Override public ObjectOutput serialize(URL url, OutputStream out) throws IOException { return new Hessian2ObjectOutput(out); } + @Override public ObjectInput deserialize(URL url, InputStream is) throws IOException { return new Hessian2ObjectInput(is); } diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/java/CompactedJavaSerialization.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/java/CompactedJavaSerialization.java index 04da07a871e..1675a704e3e 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/java/CompactedJavaSerialization.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/java/CompactedJavaSerialization.java @@ -27,18 +27,22 @@ public class CompactedJavaSerialization implements Serialization { + @Override public byte getContentTypeId() { return 4; } + @Override public String getContentType() { return "x-application/compactedjava"; } + @Override public ObjectOutput serialize(URL url, OutputStream out) throws IOException { return new JavaObjectOutput(out, true); } + @Override public ObjectInput deserialize(URL url, InputStream is) throws IOException { return new JavaObjectInput(is, true); } diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/java/JavaObjectInput.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/java/JavaObjectInput.java index 8cfcf4b657c..47bd8f853ad 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/java/JavaObjectInput.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/java/JavaObjectInput.java @@ -37,6 +37,7 @@ public JavaObjectInput(InputStream is, boolean compacted) throws IOException { super(compacted ? new CompactedObjectInputStream(is) : new ObjectInputStream(is)); } + @Override public byte[] readBytes() throws IOException { int len = getObjectInputStream().readInt(); if (len < 0) @@ -51,6 +52,7 @@ public byte[] readBytes() throws IOException { return b; } + @Override public String readUTF() throws IOException { int len = getObjectInputStream().readInt(); if (len < 0) @@ -59,6 +61,7 @@ public String readUTF() throws IOException { return getObjectInputStream().readUTF(); } + @Override public Object readObject() throws IOException, ClassNotFoundException { byte b = getObjectInputStream().readByte(); if (b == 0) @@ -67,12 +70,14 @@ public Object readObject() throws IOException, ClassNotFoundException { return getObjectInputStream().readObject(); } + @Override @SuppressWarnings("unchecked") public T readObject(Class cls) throws IOException, ClassNotFoundException { return (T) readObject(); } + @Override @SuppressWarnings("unchecked") public T readObject(Class cls, Type type) throws IOException, ClassNotFoundException { return (T) readObject(); diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/java/JavaObjectOutput.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/java/JavaObjectOutput.java index daadbe5dd62..711e1ac3fe4 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/java/JavaObjectOutput.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/java/JavaObjectOutput.java @@ -34,6 +34,7 @@ public JavaObjectOutput(OutputStream os, boolean compact) throws IOException { super(compact ? new CompactedObjectOutputStream(os) : new ObjectOutputStream(os)); } + @Override public void writeUTF(String v) throws IOException { if (v == null) { getObjectOutputStream().writeInt(-1); @@ -43,6 +44,7 @@ public void writeUTF(String v) throws IOException { } } + @Override public void writeObject(Object obj) throws IOException { if (obj == null) { getObjectOutputStream().writeByte(0); @@ -52,6 +54,7 @@ public void writeObject(Object obj) throws IOException { } } + @Override public void flushBuffer() throws IOException { getObjectOutputStream().flush(); } diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/java/JavaSerialization.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/java/JavaSerialization.java index c4206b52156..35a6b20f6c7 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/java/JavaSerialization.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/java/JavaSerialization.java @@ -27,18 +27,22 @@ public class JavaSerialization implements Serialization { + @Override public byte getContentTypeId() { return 3; } + @Override public String getContentType() { return "x-application/java"; } + @Override public ObjectOutput serialize(URL url, OutputStream out) throws IOException { return new JavaObjectOutput(out); } + @Override public ObjectInput deserialize(URL url, InputStream is) throws IOException { return new JavaObjectInput(is); } diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/json/FastJsonObjectInput.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/json/FastJsonObjectInput.java index 9861698c823..610be5f0a3f 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/json/FastJsonObjectInput.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/json/FastJsonObjectInput.java @@ -43,6 +43,7 @@ public FastJsonObjectInput(Reader reader) { this.reader = new BufferedReader(reader); } + @Override public boolean readBool() throws IOException { try { return readObject(boolean.class); @@ -51,6 +52,7 @@ public boolean readBool() throws IOException { } } + @Override public byte readByte() throws IOException { try { return readObject(byte.class); @@ -59,6 +61,7 @@ public byte readByte() throws IOException { } } + @Override public short readShort() throws IOException { try { return readObject(short.class); @@ -67,6 +70,7 @@ public short readShort() throws IOException { } } + @Override public int readInt() throws IOException { try { return readObject(int.class); @@ -75,6 +79,7 @@ public int readInt() throws IOException { } } + @Override public long readLong() throws IOException { try { return readObject(long.class); @@ -83,6 +88,7 @@ public long readLong() throws IOException { } } + @Override public float readFloat() throws IOException { try { return readObject(float.class); @@ -91,6 +97,7 @@ public float readFloat() throws IOException { } } + @Override public double readDouble() throws IOException { try { return readObject(double.class); @@ -99,6 +106,7 @@ public double readDouble() throws IOException { } } + @Override public String readUTF() throws IOException { try { return readObject(String.class); @@ -107,20 +115,24 @@ public String readUTF() throws IOException { } } + @Override public byte[] readBytes() throws IOException { return readLine().getBytes(); } + @Override public Object readObject() throws IOException, ClassNotFoundException { String json = readLine(); return JSON.parse(json); } + @Override public T readObject(Class cls) throws IOException, ClassNotFoundException { String json = readLine(); return JSON.parseObject(json, cls); } + @Override @SuppressWarnings("unchecked") public T readObject(Class cls, Type type) throws IOException, ClassNotFoundException { Object value = readObject(cls); diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/json/FastJsonObjectOutput.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/json/FastJsonObjectOutput.java index 4048e8a10a8..42e5864148e 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/json/FastJsonObjectOutput.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/json/FastJsonObjectOutput.java @@ -42,46 +42,57 @@ public FastJsonObjectOutput(Writer writer) { this.writer = new PrintWriter(writer); } + @Override public void writeBool(boolean v) throws IOException { writeObject(v); } + @Override public void writeByte(byte v) throws IOException { writeObject(v); } + @Override public void writeShort(short v) throws IOException { writeObject(v); } + @Override public void writeInt(int v) throws IOException { writeObject(v); } + @Override public void writeLong(long v) throws IOException { writeObject(v); } + @Override public void writeFloat(float v) throws IOException { writeObject(v); } + @Override public void writeDouble(double v) throws IOException { writeObject(v); } + @Override public void writeUTF(String v) throws IOException { writeObject(v); } + @Override public void writeBytes(byte[] b) throws IOException { writer.println(new String(b)); } + @Override public void writeBytes(byte[] b, int off, int len) throws IOException { writer.println(new String(b, off, len)); } + @Override public void writeObject(Object obj) throws IOException { SerializeWriter out = new SerializeWriter(); JSONSerializer serializer = new JSONSerializer(out); @@ -93,6 +104,7 @@ public void writeObject(Object obj) throws IOException { writer.flush(); } + @Override public void flushBuffer() throws IOException { writer.flush(); } diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/json/FastJsonSerialization.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/json/FastJsonSerialization.java index 7100ccf0946..48371b420c8 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/json/FastJsonSerialization.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/json/FastJsonSerialization.java @@ -30,18 +30,22 @@ */ public class FastJsonSerialization implements Serialization { + @Override public byte getContentTypeId() { return 6; } + @Override public String getContentType() { return "text/json"; } + @Override public ObjectOutput serialize(URL url, OutputStream output) throws IOException { return new FastJsonObjectOutput(output); } + @Override public ObjectInput deserialize(URL url, InputStream input) throws IOException { return new FastJsonObjectInput(input); } diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/json/JsonObjectInput.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/json/JsonObjectInput.java index 3a4a718cb7b..cbe01069ab3 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/json/JsonObjectInput.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/json/JsonObjectInput.java @@ -46,6 +46,7 @@ public JsonObjectInput(Reader reader) { this.reader = new BufferedReader(reader); } + @Override public boolean readBool() throws IOException { try { return readObject(boolean.class); @@ -54,6 +55,7 @@ public boolean readBool() throws IOException { } } + @Override public byte readByte() throws IOException { try { return readObject(byte.class); @@ -62,6 +64,7 @@ public byte readByte() throws IOException { } } + @Override public short readShort() throws IOException { try { return readObject(short.class); @@ -70,6 +73,7 @@ public short readShort() throws IOException { } } + @Override public int readInt() throws IOException { try { return readObject(int.class); @@ -78,6 +82,7 @@ public int readInt() throws IOException { } } + @Override public long readLong() throws IOException { try { return readObject(long.class); @@ -86,6 +91,7 @@ public long readLong() throws IOException { } } + @Override public float readFloat() throws IOException { try { return readObject(float.class); @@ -94,6 +100,7 @@ public float readFloat() throws IOException { } } + @Override public double readDouble() throws IOException { try { return readObject(double.class); @@ -102,6 +109,7 @@ public double readDouble() throws IOException { } } + @Override public String readUTF() throws IOException { try { return readObject(String.class); @@ -110,10 +118,12 @@ public String readUTF() throws IOException { } } + @Override public byte[] readBytes() throws IOException { return readLine().getBytes(); } + @Override public Object readObject() throws IOException, ClassNotFoundException { try { String json = readLine(); @@ -131,6 +141,7 @@ public Object readObject() throws IOException, ClassNotFoundException { } } + @Override @SuppressWarnings("unchecked") public T readObject(Class cls) throws IOException, ClassNotFoundException { Object value = readObject(); @@ -142,6 +153,7 @@ public T readObject(Class cls) throws IOException, ClassNotFoundException }*/ } + @Override @SuppressWarnings("unchecked") public T readObject(Class cls, Type type) throws IOException, ClassNotFoundException { Object value = readObject(); diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/json/JsonObjectOutput.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/json/JsonObjectOutput.java index 491f173d5a6..58534c1fa52 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/json/JsonObjectOutput.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/json/JsonObjectOutput.java @@ -52,52 +52,64 @@ public JsonObjectOutput(Writer writer, boolean writeClass) { this.writeClass = writeClass; } + @Override public void writeBool(boolean v) throws IOException { writeObject(v); } + @Override public void writeByte(byte v) throws IOException { writeObject(v); } + @Override public void writeShort(short v) throws IOException { writeObject(v); } + @Override public void writeInt(int v) throws IOException { writeObject(v); } + @Override public void writeLong(long v) throws IOException { writeObject(v); } + @Override public void writeFloat(float v) throws IOException { writeObject(v); } + @Override public void writeDouble(double v) throws IOException { writeObject(v); } + @Override public void writeUTF(String v) throws IOException { writeObject(v); } + @Override public void writeBytes(byte[] b) throws IOException { writer.println(new String(b)); } + @Override public void writeBytes(byte[] b, int off, int len) throws IOException { writer.println(new String(b, off, len)); } + @Override public void writeObject(Object obj) throws IOException { JSON.json(obj, writer, writeClass); writer.println(); writer.flush(); } + @Override public void flushBuffer() throws IOException { writer.flush(); } diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/json/JsonSerialization.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/json/JsonSerialization.java index 488786961b1..ee9ebfd01dc 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/json/JsonSerialization.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/json/JsonSerialization.java @@ -31,18 +31,22 @@ @Deprecated public class JsonSerialization implements Serialization { + @Override public byte getContentTypeId() { return 5; } + @Override public String getContentType() { return "text/json"; } + @Override public ObjectOutput serialize(URL url, OutputStream output) throws IOException { return new JsonObjectOutput(output, url.getParameter("with.class", true)); } + @Override public ObjectInput deserialize(URL url, InputStream input) throws IOException { return new JsonObjectInput(input); } diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/kryo/KryoObjectInput.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/kryo/KryoObjectInput.java index b2d373a1b74..32a9daf3bad 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/kryo/KryoObjectInput.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/kryo/KryoObjectInput.java @@ -38,6 +38,7 @@ public KryoObjectInput(InputStream inputStream) { this.kryo = KryoUtils.get(); } + @Override public boolean readBool() throws IOException { try { return input.readBoolean(); @@ -46,6 +47,7 @@ public boolean readBool() throws IOException { } } + @Override public byte readByte() throws IOException { try { return input.readByte(); @@ -54,6 +56,7 @@ public byte readByte() throws IOException { } } + @Override public short readShort() throws IOException { try { return input.readShort(); @@ -62,6 +65,7 @@ public short readShort() throws IOException { } } + @Override public int readInt() throws IOException { try { return input.readInt(); @@ -70,6 +74,7 @@ public int readInt() throws IOException { } } + @Override public long readLong() throws IOException { try { return input.readLong(); @@ -78,6 +83,7 @@ public long readLong() throws IOException { } } + @Override public float readFloat() throws IOException { try { return input.readFloat(); @@ -86,6 +92,7 @@ public float readFloat() throws IOException { } } + @Override public double readDouble() throws IOException { try { return input.readDouble(); @@ -94,6 +101,7 @@ public double readDouble() throws IOException { } } + @Override public byte[] readBytes() throws IOException { try { int len = input.readInt(); @@ -109,6 +117,7 @@ public byte[] readBytes() throws IOException { } } + @Override public String readUTF() throws IOException { try { return input.readString(); @@ -117,6 +126,7 @@ public String readUTF() throws IOException { } } + @Override public Object readObject() throws IOException, ClassNotFoundException { // TODO optimization try { @@ -127,18 +137,21 @@ public Object readObject() throws IOException, ClassNotFoundException { } + @Override @SuppressWarnings("unchecked") public T readObject(Class clazz) throws IOException, ClassNotFoundException { // TODO optimization return (T) readObject(); } + @Override @SuppressWarnings("unchecked") public T readObject(Class clazz, Type type) throws IOException, ClassNotFoundException { // TODO optimization return readObject(clazz); } + @Override public void cleanup() { KryoUtils.release(kryo); kryo = null; diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/kryo/KryoObjectOutput.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/kryo/KryoObjectOutput.java index 652fc3028e0..412337817ed 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/kryo/KryoObjectOutput.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/kryo/KryoObjectOutput.java @@ -36,34 +36,42 @@ public KryoObjectOutput(OutputStream outputStream) { this.kryo = KryoUtils.get(); } + @Override public void writeBool(boolean v) throws IOException { output.writeBoolean(v); } + @Override public void writeByte(byte v) throws IOException { output.writeByte(v); } + @Override public void writeShort(short v) throws IOException { output.writeShort(v); } + @Override public void writeInt(int v) throws IOException { output.writeInt(v); } + @Override public void writeLong(long v) throws IOException { output.writeLong(v); } + @Override public void writeFloat(float v) throws IOException { output.writeFloat(v); } + @Override public void writeDouble(double v) throws IOException { output.writeDouble(v); } + @Override public void writeBytes(byte[] v) throws IOException { if (v == null) { output.writeInt(-1); @@ -72,6 +80,7 @@ public void writeBytes(byte[] v) throws IOException { } } + @Override public void writeBytes(byte[] v, int off, int len) throws IOException { if (v == null) { output.writeInt(-1); @@ -82,19 +91,23 @@ public void writeBytes(byte[] v, int off, int len) throws IOException { } + @Override public void writeUTF(String v) throws IOException { output.writeString(v); } + @Override public void writeObject(Object v) throws IOException { // TODO carries class info every time. kryo.writeClassAndObject(output, v); } + @Override public void flushBuffer() throws IOException { output.flush(); } + @Override public void cleanup() { KryoUtils.release(kryo); kryo = null; diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/kryo/KryoSerialization.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/kryo/KryoSerialization.java index f43e7ca7f83..fefce0508a7 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/kryo/KryoSerialization.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/kryo/KryoSerialization.java @@ -31,18 +31,22 @@ */ public class KryoSerialization implements Serialization { + @Override public byte getContentTypeId() { return 8; } + @Override public String getContentType() { return "x-application/kryo"; } + @Override public ObjectOutput serialize(URL url, OutputStream out) throws IOException { return new KryoObjectOutput(out); } + @Override public ObjectInput deserialize(URL url, InputStream is) throws IOException { return new KryoObjectInput(is); } diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/kryo/utils/AbstractKryoFactory.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/kryo/utils/AbstractKryoFactory.java index b664a9209d3..665972bf089 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/kryo/utils/AbstractKryoFactory.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/kryo/utils/AbstractKryoFactory.java @@ -80,6 +80,7 @@ public void registerClass(Class clazz) { registrations.add(clazz); } + @Override public Kryo create() { if (!kryoCreated) { kryoCreated = true; diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/kryo/utils/PrototypeKryoFactory.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/kryo/utils/PrototypeKryoFactory.java index 12a0313536e..bfef65f427a 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/kryo/utils/PrototypeKryoFactory.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/kryo/utils/PrototypeKryoFactory.java @@ -25,6 +25,7 @@ public void returnKryo(Kryo kryo) { // do nothing } + @Override public Kryo getKryo() { return create(); } diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/kryo/utils/ThreadLocalKryoFactory.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/kryo/utils/ThreadLocalKryoFactory.java index f6668786daf..5e032c063c5 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/kryo/utils/ThreadLocalKryoFactory.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/kryo/utils/ThreadLocalKryoFactory.java @@ -32,6 +32,7 @@ public void returnKryo(Kryo kryo) { // do nothing } + @Override public Kryo getKryo() { return holder.get(); } diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/nativejava/NativeJavaObjectInput.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/nativejava/NativeJavaObjectInput.java index 28354576ce8..63ce19fe341 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/nativejava/NativeJavaObjectInput.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/nativejava/NativeJavaObjectInput.java @@ -42,52 +42,64 @@ protected ObjectInputStream getObjectInputStream() { return inputStream; } + @Override public Object readObject() throws IOException, ClassNotFoundException { return inputStream.readObject(); } + @Override @SuppressWarnings("unchecked") public T readObject(Class cls) throws IOException, ClassNotFoundException { return (T) readObject(); } + @Override @SuppressWarnings("unchecked") public T readObject(Class cls, Type type) throws IOException, ClassNotFoundException { return (T) readObject(); } + @Override public boolean readBool() throws IOException { return inputStream.readBoolean(); } + @Override public byte readByte() throws IOException { return inputStream.readByte(); } + @Override public short readShort() throws IOException { return inputStream.readShort(); } + @Override public int readInt() throws IOException { return inputStream.readInt(); } + @Override public long readLong() throws IOException { return inputStream.readLong(); } + @Override public float readFloat() throws IOException { return inputStream.readFloat(); } + @Override public double readDouble() throws IOException { return inputStream.readDouble(); } + @Override public String readUTF() throws IOException { return inputStream.readUTF(); } + @Override public byte[] readBytes() throws IOException { int len = inputStream.readInt(); if (len < 0) { diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/nativejava/NativeJavaObjectOutput.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/nativejava/NativeJavaObjectOutput.java index d686d1df2cb..ca58a7a6558 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/nativejava/NativeJavaObjectOutput.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/nativejava/NativeJavaObjectOutput.java @@ -41,42 +41,52 @@ protected ObjectOutputStream getObjectOutputStream() { return outputStream; } + @Override public void writeObject(Object obj) throws IOException { outputStream.writeObject(obj); } + @Override public void writeBool(boolean v) throws IOException { outputStream.writeBoolean(v); } + @Override public void writeByte(byte v) throws IOException { outputStream.writeByte(v); } + @Override public void writeShort(short v) throws IOException { outputStream.writeShort(v); } + @Override public void writeInt(int v) throws IOException { outputStream.writeInt(v); } + @Override public void writeLong(long v) throws IOException { outputStream.writeLong(v); } + @Override public void writeFloat(float v) throws IOException { outputStream.writeFloat(v); } + @Override public void writeDouble(double v) throws IOException { outputStream.writeDouble(v); } + @Override public void writeUTF(String v) throws IOException { outputStream.writeUTF(v); } + @Override public void writeBytes(byte[] v) throws IOException { if (v == null) { outputStream.writeInt(-1); @@ -85,6 +95,7 @@ public void writeBytes(byte[] v) throws IOException { } } + @Override public void writeBytes(byte[] v, int off, int len) throws IOException { if (v == null) { outputStream.writeInt(-1); @@ -94,6 +105,7 @@ public void writeBytes(byte[] v, int off, int len) throws IOException { } } + @Override public void flushBuffer() throws IOException { outputStream.flush(); } diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/nativejava/NativeJavaSerialization.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/nativejava/NativeJavaSerialization.java index ec337cb4a7c..4fbd3c7faa3 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/nativejava/NativeJavaSerialization.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/nativejava/NativeJavaSerialization.java @@ -30,18 +30,22 @@ public class NativeJavaSerialization implements Serialization { public static final String NAME = "nativejava"; + @Override public byte getContentTypeId() { return 7; } + @Override public String getContentType() { return "x-application/nativejava"; } + @Override public ObjectOutput serialize(URL url, OutputStream output) throws IOException { return new NativeJavaObjectOutput(output); } + @Override public ObjectInput deserialize(URL url, InputStream input) throws IOException { return new NativeJavaObjectInput(input); } diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/status/support/LoadStatusChecker.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/status/support/LoadStatusChecker.java index b2ce5640b3a..5a409a9ab9a 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/status/support/LoadStatusChecker.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/status/support/LoadStatusChecker.java @@ -30,6 +30,7 @@ @Activate public class LoadStatusChecker implements StatusChecker { + @Override public Status check() { OperatingSystemMXBean operatingSystemMXBean = ManagementFactory.getOperatingSystemMXBean(); double load; diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/status/support/MemoryStatusChecker.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/status/support/MemoryStatusChecker.java index c8ea8f37ac5..530e780f451 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/status/support/MemoryStatusChecker.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/status/support/MemoryStatusChecker.java @@ -26,6 +26,7 @@ @Activate public class MemoryStatusChecker implements StatusChecker { + @Override public Status check() { Runtime runtime = Runtime.getRuntime(); long freeMemory = runtime.freeMemory(); diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/store/support/SimpleDataStore.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/store/support/SimpleDataStore.java index 69c38d1ad6e..d070875acf9 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/store/support/SimpleDataStore.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/store/support/SimpleDataStore.java @@ -30,6 +30,7 @@ public class SimpleDataStore implements DataStore { private ConcurrentMap> data = new ConcurrentHashMap>(); + @Override public Map get(String componentName) { ConcurrentMap value = data.get(componentName); if (value == null) return new HashMap(); @@ -37,6 +38,7 @@ public Map get(String componentName) { return new HashMap(value); } + @Override public Object get(String componentName, String key) { if (!data.containsKey(componentName)) { return null; @@ -44,6 +46,7 @@ public Object get(String componentName, String key) { return data.get(componentName).get(key); } + @Override public void put(String componentName, String key, Object value) { Map componentData = data.get(componentName); if (null == componentData) { @@ -53,6 +56,7 @@ public void put(String componentName, String key, Object value) { componentData.put(key, value); } + @Override public void remove(String componentName, String key) { if (!data.containsKey(componentName)) { return; diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/cached/CachedThreadPool.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/cached/CachedThreadPool.java index f63bda0c59f..41d4418c878 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/cached/CachedThreadPool.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/cached/CachedThreadPool.java @@ -36,6 +36,7 @@ */ public class CachedThreadPool implements ThreadPool { + @Override public Executor getExecutor(URL url) { String name = url.getParameter(Constants.THREAD_NAME_KEY, Constants.DEFAULT_THREAD_NAME); int cores = url.getParameter(Constants.CORE_THREADS_KEY, Constants.DEFAULT_CORE_THREADS); diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/fixed/FixedThreadPool.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/fixed/FixedThreadPool.java index c8fe922dfa3..25bfd12db6f 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/fixed/FixedThreadPool.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/fixed/FixedThreadPool.java @@ -35,6 +35,7 @@ */ public class FixedThreadPool implements ThreadPool { + @Override public Executor getExecutor(URL url) { String name = url.getParameter(Constants.THREAD_NAME_KEY, Constants.DEFAULT_THREAD_NAME); int threads = url.getParameter(Constants.THREADS_KEY, Constants.DEFAULT_THREADS); diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/limited/LimitedThreadPool.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/limited/LimitedThreadPool.java index d1d9156b95a..aa5a71f3da0 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/limited/LimitedThreadPool.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/limited/LimitedThreadPool.java @@ -35,6 +35,7 @@ */ public class LimitedThreadPool implements ThreadPool { + @Override public Executor getExecutor(URL url) { String name = url.getParameter(Constants.THREAD_NAME_KEY, Constants.DEFAULT_THREAD_NAME); int cores = url.getParameter(Constants.CORE_THREADS_KEY, Constants.DEFAULT_CORE_THREADS); diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/AtomicPositiveInteger.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/AtomicPositiveInteger.java index f9bc27a02d9..334dcf6901d 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/AtomicPositiveInteger.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/AtomicPositiveInteger.java @@ -133,30 +133,37 @@ public final boolean weakCompareAndSet(int expect, int update) { return i.weakCompareAndSet(expect, update); } + @Override public byte byteValue() { return i.byteValue(); } + @Override public short shortValue() { return i.shortValue(); } + @Override public int intValue() { return i.intValue(); } + @Override public long longValue() { return i.longValue(); } + @Override public float floatValue() { return i.floatValue(); } + @Override public double doubleValue() { return i.doubleValue(); } + @Override public String toString() { return i.toString(); } diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/CollectionUtils.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/CollectionUtils.java index 300235f1603..be6ef8d788c 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/CollectionUtils.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/CollectionUtils.java @@ -27,6 +27,7 @@ public class CollectionUtils { private static final Comparator SIMPLE_NAME_COMPARATOR = new Comparator() { + @Override public int compare(String s1, String s2) { if (s1 == null && s2 == null) { return 0; diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/ConcurrentHashSet.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/ConcurrentHashSet.java index 2295d65adbd..a1b7a9a1526 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/ConcurrentHashSet.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/ConcurrentHashSet.java @@ -46,6 +46,7 @@ public ConcurrentHashSet(int initialCapacity) { * @return an Iterator over the elements in this set * @see ConcurrentModificationException */ + @Override public Iterator iterator() { return map.keySet().iterator(); } @@ -55,6 +56,7 @@ public Iterator iterator() { * * @return the number of elements in this set (its cardinality) */ + @Override public int size() { return map.size(); } @@ -64,6 +66,7 @@ public int size() { * * @return true if this set contains no elements */ + @Override public boolean isEmpty() { return map.isEmpty(); } @@ -77,6 +80,7 @@ public boolean isEmpty() { * @param o element whose presence in this set is to be tested * @return true if this set contains the specified element */ + @Override public boolean contains(Object o) { return map.containsKey(o); } @@ -93,6 +97,7 @@ public boolean contains(Object o) { * @return true if this set did not already contain the specified * element */ + @Override public boolean add(E e) { return map.put(e, PRESENT) == null; } @@ -108,6 +113,7 @@ public boolean add(E e) { * @param o object to be removed from this set, if present * @return true if the set contained the specified element */ + @Override public boolean remove(Object o) { return map.remove(o) == PRESENT; } @@ -116,6 +122,7 @@ public boolean remove(Object o) { * Removes all of the elements from this set. The set will be empty after * this call returns. */ + @Override public void clear() { map.clear(); } diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/DubboAppender.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/DubboAppender.java index 1d740f18331..96e894931d6 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/DubboAppender.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/DubboAppender.java @@ -40,6 +40,7 @@ public static void clear() { logList.clear(); } + @Override public void append(LoggingEvent event) { super.append(event); if (available) { diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/ExecutorUtil.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/ExecutorUtil.java index eea74838190..338c40664ca 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/ExecutorUtil.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/ExecutorUtil.java @@ -93,6 +93,7 @@ public static void shutdownNow(Executor executor, final int timeout) { private static void newThreadToCloseExecutor(final ExecutorService es) { if (!isShutdown(es)) { shutdownExecutor.execute(new Runnable() { + @Override public void run() { try { for (int i = 0; i < 1000; i++) { diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/NamedThreadFactory.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/NamedThreadFactory.java index 1443a39e269..27c1dce20c0 100755 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/NamedThreadFactory.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/NamedThreadFactory.java @@ -48,6 +48,7 @@ public NamedThreadFactory(String prefix, boolean daemon) { mGroup = (s == null) ? Thread.currentThread().getThreadGroup() : s.getThreadGroup(); } + @Override public Thread newThread(Runnable runnable) { String name = mPrefix + mThreadNum.getAndIncrement(); Thread ret = new Thread(mGroup, runnable, name, 0); diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/PojoUtils.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/PojoUtils.java index 30290c76646..653652a47b4 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/PojoUtils.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/PojoUtils.java @@ -204,6 +204,7 @@ public PojoInvocationHandler(Map map) { this.map = map; } + @Override @SuppressWarnings("unchecked") public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (method.getDeclaringClass() == Object.class) { diff --git a/dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/AbstractConfig.java b/dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/AbstractConfig.java index caa14a53aff..bac80edf7a2 100644 --- a/dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/AbstractConfig.java +++ b/dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/AbstractConfig.java @@ -75,6 +75,7 @@ public abstract class AbstractConfig implements Serializable { static { Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { + @Override public void run() { if (logger.isInfoEnabled()) { logger.info("Run shutdown hook now."); diff --git a/dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/AbstractReferenceConfig.java b/dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/AbstractReferenceConfig.java index c3f02642a15..6f483383360 100644 --- a/dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/AbstractReferenceConfig.java +++ b/dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/AbstractReferenceConfig.java @@ -114,11 +114,13 @@ public void setInjvm(Boolean injvm) { this.injvm = injvm; } + @Override @Parameter(key = Constants.REFERENCE_FILTER_KEY, append = true) public String getFilter() { return super.getFilter(); } + @Override @Parameter(key = Constants.INVOKER_LISTENER_KEY, append = true) public String getListener() { return super.getListener(); diff --git a/dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/AbstractServiceConfig.java b/dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/AbstractServiceConfig.java index 00aed9434a3..f1f428a0768 100644 --- a/dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/AbstractServiceConfig.java +++ b/dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/AbstractServiceConfig.java @@ -198,11 +198,13 @@ public void setExecutes(Integer executes) { this.executes = executes; } + @Override @Parameter(key = Constants.SERVICE_FILTER_KEY, append = true) public String getFilter() { return super.getFilter(); } + @Override @Parameter(key = Constants.EXPORTER_LISTENER_KEY, append = true) public String getListener() { return super.getListener(); diff --git a/dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/ServiceConfig.java b/dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/ServiceConfig.java index dfb633790a9..1d819f319c7 100644 --- a/dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/ServiceConfig.java +++ b/dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/ServiceConfig.java @@ -207,6 +207,7 @@ public synchronized void export() { if (delay != null && delay > 0) { delayExportExecutor.schedule(new Runnable() { + @Override public void run() { doExport(); } diff --git a/dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/invoker/DelegateProviderMetaDataInvoker.java b/dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/invoker/DelegateProviderMetaDataInvoker.java index 14bfa502158..0157f4c74e0 100644 --- a/dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/invoker/DelegateProviderMetaDataInvoker.java +++ b/dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/invoker/DelegateProviderMetaDataInvoker.java @@ -32,22 +32,27 @@ public DelegateProviderMetaDataInvoker(Invoker invoker,ServiceConfig metadata this.metadata = metadata; } + @Override public Class getInterface() { return invoker.getInterface(); } + @Override public URL getUrl() { return invoker.getUrl(); } + @Override public boolean isAvailable() { return invoker.isAvailable(); } + @Override public Result invoke(Invocation invocation) throws RpcException { return invoker.invoke(invocation); } + @Override public void destroy() { invoker.destroy(); } diff --git a/dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/utils/ReferenceConfigCache.java b/dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/utils/ReferenceConfigCache.java index 9e5f759c768..ece1ddc3672 100644 --- a/dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/utils/ReferenceConfigCache.java +++ b/dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/utils/ReferenceConfigCache.java @@ -40,6 +40,7 @@ public class ReferenceConfigCache { * key example: group1/com.alibaba.foo.FooService:1.0.0. */ public static final KeyGenerator DEFAULT_KEY_GENERATOR = new KeyGenerator() { + @Override public String generateKey(ReferenceConfig referenceConfig) { String iName = referenceConfig.getInterface(); if (StringUtils.isBlank(iName)) { diff --git a/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/AnnotationBean.java b/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/AnnotationBean.java index 93168d0893e..096fdfb0eff 100644 --- a/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/AnnotationBean.java +++ b/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/AnnotationBean.java @@ -69,10 +69,12 @@ public void setPackage(String annotationPackage) { : Constants.COMMA_SPLIT_PATTERN.split(annotationPackage); } + @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { this.applicationContext = applicationContext; } + @Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { if (annotationPackage == null || annotationPackage.length() == 0) { @@ -98,6 +100,7 @@ public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) } } + @Override public void destroy() throws Exception { for (ServiceConfig serviceConfig : serviceConfigs) { try { @@ -115,6 +118,7 @@ public void destroy() throws Exception { } } + @Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { if (!isMatchPackage(bean)) { @@ -183,6 +187,7 @@ public Object postProcessAfterInitialization(Object bean, String beanName) return bean; } + @Override public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { if (!isMatchPackage(bean)) { diff --git a/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/ReferenceBean.java b/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/ReferenceBean.java index f3aa9b02493..6768fee69d9 100644 --- a/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/ReferenceBean.java +++ b/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/ReferenceBean.java @@ -56,24 +56,29 @@ public ReferenceBean(Reference reference) { super(reference); } + @Override public void setApplicationContext(ApplicationContext applicationContext) { this.applicationContext = applicationContext; SpringExtensionFactory.addApplicationContext(applicationContext); } + @Override public Object getObject() throws Exception { return get(); } + @Override public Class getObjectType() { return getInterfaceClass(); } + @Override @Parameter(excluded = true) public boolean isSingleton() { return true; } + @Override @SuppressWarnings({"unchecked"}) public void afterPropertiesSet() throws Exception { if (getConsumer() == null) { diff --git a/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/ServiceBean.java b/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/ServiceBean.java index 2e614efdb69..ec819de1cdc 100644 --- a/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/ServiceBean.java +++ b/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/ServiceBean.java @@ -75,6 +75,7 @@ public static ApplicationContext getSpringContext() { return SPRING_CONTEXT; } + @Override public void setApplicationContext(ApplicationContext applicationContext) { this.applicationContext = applicationContext; SpringExtensionFactory.addApplicationContext(applicationContext); @@ -100,6 +101,7 @@ public void setApplicationContext(ApplicationContext applicationContext) { } } + @Override public void setBeanName(String name) { this.beanName = name; } @@ -113,6 +115,7 @@ public Service getService() { return service; } + @Override public void onApplicationEvent(ContextRefreshedEvent event) { if (isDelay() && !isExported() && !isUnexported()) { if (logger.isInfoEnabled()) { @@ -131,6 +134,7 @@ private boolean isDelay() { return supportedApplicationListener && (delay == null || delay == -1); } + @Override @SuppressWarnings({"unchecked", "deprecation"}) public void afterPropertiesSet() throws Exception { if (getProvider() == null) { @@ -262,6 +266,7 @@ && getInterface() != null && getInterface().length() > 0 } } + @Override public void destroy() throws Exception { // This will only be called for singleton scope bean, and expected to be called by spring shutdown hook when BeanFactory/ApplicationContext destroys. // We will guarantee dubbo related resources being released with dubbo shutdown hook. @@ -269,6 +274,7 @@ public void destroy() throws Exception { } // merged from dubbox + @Override protected Class getServiceClass(T ref) { if (AopUtils.isAopProxy(ref)) { return AopUtils.getTargetClass(ref); diff --git a/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/context/annotation/DubboClassPathBeanDefinitionScanner.java b/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/context/annotation/DubboClassPathBeanDefinitionScanner.java index e6aaee315fa..4f0928ed721 100644 --- a/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/context/annotation/DubboClassPathBeanDefinitionScanner.java +++ b/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/context/annotation/DubboClassPathBeanDefinitionScanner.java @@ -57,10 +57,12 @@ public DubboClassPathBeanDefinitionScanner(BeanDefinitionRegistry registry, Envi } + @Override public Set doScan(String... basePackages) { return super.doScan(basePackages); } + @Override public boolean checkCandidate(String beanName, BeanDefinition beanDefinition) throws IllegalStateException { return super.checkCandidate(beanName, beanDefinition); } diff --git a/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/extension/SpringExtensionFactory.java b/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/extension/SpringExtensionFactory.java index 3d13de46512..a4c05c3abc8 100644 --- a/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/extension/SpringExtensionFactory.java +++ b/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/extension/SpringExtensionFactory.java @@ -37,6 +37,7 @@ public static void removeApplicationContext(ApplicationContext context) { contexts.remove(context); } + @Override @SuppressWarnings("unchecked") public T getExtension(Class type, String name) { for (ApplicationContext context : contexts) { diff --git a/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/schema/AnnotationBeanDefinitionParser.java b/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/schema/AnnotationBeanDefinitionParser.java index 8a7123693f2..028eca97e51 100644 --- a/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/schema/AnnotationBeanDefinitionParser.java +++ b/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/schema/AnnotationBeanDefinitionParser.java @@ -36,6 +36,7 @@ public class AnnotationBeanDefinitionParser extends AbstractSingleBeanDefinition * @param parserContext * @param builder */ + @Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { String packageToScan = element.getAttribute("package"); @@ -51,6 +52,7 @@ protected void doParse(Element element, ParserContext parserContext, BeanDefinit } + @Override protected boolean shouldGenerateIdAsFallback() { return true; } @@ -68,6 +70,7 @@ private void registerReferenceAnnotationBeanPostProcessor(BeanDefinitionRegistry } + @Override protected Class getBeanClass(Element element) { return ServiceAnnotationBeanPostProcessor.class; } diff --git a/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/schema/DubboBeanDefinitionParser.java b/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/schema/DubboBeanDefinitionParser.java index 5502d05d64b..12a020dc5e1 100644 --- a/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/schema/DubboBeanDefinitionParser.java +++ b/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/schema/DubboBeanDefinitionParser.java @@ -406,6 +406,7 @@ private static void parseArguments(String id, NodeList nodeList, RootBeanDefinit } } + @Override public BeanDefinition parse(Element element, ParserContext parserContext) { return parse(element, parserContext, beanClass, required); } diff --git a/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/schema/DubboNamespaceHandler.java b/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/schema/DubboNamespaceHandler.java index da44826514a..61b89fd17f5 100644 --- a/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/schema/DubboNamespaceHandler.java +++ b/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/schema/DubboNamespaceHandler.java @@ -33,6 +33,7 @@ public class DubboNamespaceHandler extends NamespaceHandlerSupport { Version.checkDuplicate(DubboNamespaceHandler.class); } + @Override public void init() { registerBeanDefinitionParser("application", new DubboBeanDefinitionParser(ApplicationConfig.class, true)); registerBeanDefinitionParser("module", new DubboBeanDefinitionParser(ModuleConfig.class, true)); diff --git a/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/status/DataSourceStatusChecker.java b/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/status/DataSourceStatusChecker.java index 198122a641f..1c749fa6719 100644 --- a/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/status/DataSourceStatusChecker.java +++ b/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/status/DataSourceStatusChecker.java @@ -38,6 +38,7 @@ public class DataSourceStatusChecker implements StatusChecker { private static final Logger logger = LoggerFactory.getLogger(DataSourceStatusChecker.class); + @Override @SuppressWarnings("unchecked") public Status check() { ApplicationContext context = ServiceBean.getSpringContext(); diff --git a/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/status/SpringStatusChecker.java b/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/status/SpringStatusChecker.java index 0303ed04b26..9d4ed7bb087 100644 --- a/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/status/SpringStatusChecker.java +++ b/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/status/SpringStatusChecker.java @@ -35,6 +35,7 @@ public class SpringStatusChecker implements StatusChecker { private static final Logger logger = LoggerFactory.getLogger(SpringStatusChecker.class); + @Override public Status check() { ApplicationContext context = ServiceBean.getSpringContext(); if (context == null) { diff --git a/dubbo-container/dubbo-container-api/src/main/java/com/alibaba/dubbo/container/Main.java b/dubbo-container/dubbo-container-api/src/main/java/com/alibaba/dubbo/container/Main.java index 27d1f3dac6b..837e024fbfd 100644 --- a/dubbo-container/dubbo-container-api/src/main/java/com/alibaba/dubbo/container/Main.java +++ b/dubbo-container/dubbo-container-api/src/main/java/com/alibaba/dubbo/container/Main.java @@ -62,6 +62,7 @@ public static void main(String[] args) { if ("true".equals(System.getProperty(SHUTDOWN_HOOK_KEY))) { Runtime.getRuntime().addShutdownHook(new Thread() { + @Override public void run() { for (Container container : containers) { try { diff --git a/dubbo-container/dubbo-container-log4j/src/main/java/com/alibaba/dubbo/container/log4j/Log4jContainer.java b/dubbo-container/dubbo-container-log4j/src/main/java/com/alibaba/dubbo/container/log4j/Log4jContainer.java index b4b21c0f192..843e215a0f1 100644 --- a/dubbo-container/dubbo-container-log4j/src/main/java/com/alibaba/dubbo/container/log4j/Log4jContainer.java +++ b/dubbo-container/dubbo-container-log4j/src/main/java/com/alibaba/dubbo/container/log4j/Log4jContainer.java @@ -40,6 +40,7 @@ public class Log4jContainer implements Container { public static final String DEFAULT_LOG4J_LEVEL = "ERROR"; + @Override @SuppressWarnings("unchecked") public void start() { String file = ConfigUtils.getProperty(LOG4J_FILE); @@ -92,6 +93,7 @@ public void start() { } } + @Override public void stop() { } diff --git a/dubbo-container/dubbo-container-logback/src/main/java/com/alibaba/dubbo/container/logback/LogbackContainer.java b/dubbo-container/dubbo-container-logback/src/main/java/com/alibaba/dubbo/container/logback/LogbackContainer.java index 46b7eef7a12..e174a3242cf 100644 --- a/dubbo-container/dubbo-container-logback/src/main/java/com/alibaba/dubbo/container/logback/LogbackContainer.java +++ b/dubbo-container/dubbo-container-logback/src/main/java/com/alibaba/dubbo/container/logback/LogbackContainer.java @@ -42,6 +42,7 @@ public class LogbackContainer implements Container { public static final String DEFAULT_LOGBACK_LEVEL = "ERROR"; + @Override public void start() { String file = ConfigUtils.getProperty(LOGBACK_FILE); if (file != null && file.length() > 0) { @@ -56,6 +57,7 @@ public void start() { } } + @Override public void stop() { } diff --git a/dubbo-container/dubbo-container-spring/src/main/java/com/alibaba/dubbo/container/spring/SpringContainer.java b/dubbo-container/dubbo-container-spring/src/main/java/com/alibaba/dubbo/container/spring/SpringContainer.java index ca00ce2c16f..fc70f83583a 100644 --- a/dubbo-container/dubbo-container-spring/src/main/java/com/alibaba/dubbo/container/spring/SpringContainer.java +++ b/dubbo-container/dubbo-container-spring/src/main/java/com/alibaba/dubbo/container/spring/SpringContainer.java @@ -37,6 +37,7 @@ public static ClassPathXmlApplicationContext getContext() { return context; } + @Override public void start() { String configPath = ConfigUtils.getProperty(SPRING_CONFIG); if (configPath == null || configPath.length() == 0) { @@ -46,6 +47,7 @@ public void start() { context.start(); } + @Override public void stop() { try { if (context != null) { diff --git a/dubbo-demo/dubbo-demo-provider/src/main/java/com/alibaba/dubbo/demo/provider/DemoServiceImpl.java b/dubbo-demo/dubbo-demo-provider/src/main/java/com/alibaba/dubbo/demo/provider/DemoServiceImpl.java index c20dfa61d73..bacb4afb94e 100644 --- a/dubbo-demo/dubbo-demo-provider/src/main/java/com/alibaba/dubbo/demo/provider/DemoServiceImpl.java +++ b/dubbo-demo/dubbo-demo-provider/src/main/java/com/alibaba/dubbo/demo/provider/DemoServiceImpl.java @@ -24,6 +24,7 @@ public class DemoServiceImpl implements DemoService { + @Override public String sayHello(String name) { System.out.println("[" + new SimpleDateFormat("HH:mm:ss").format(new Date()) + "] Hello " + name + ", request from consumer: " + RpcContext.getContext().getRemoteAddress()); return "Hello " + name + ", response form provider: " + RpcContext.getContext().getLocalAddress(); diff --git a/dubbo-filter/dubbo-filter-cache/src/main/java/com/alibaba/dubbo/cache/filter/CacheFilter.java b/dubbo-filter/dubbo-filter-cache/src/main/java/com/alibaba/dubbo/cache/filter/CacheFilter.java index 8b434739794..82b0362dcc2 100644 --- a/dubbo-filter/dubbo-filter-cache/src/main/java/com/alibaba/dubbo/cache/filter/CacheFilter.java +++ b/dubbo-filter/dubbo-filter-cache/src/main/java/com/alibaba/dubbo/cache/filter/CacheFilter.java @@ -41,6 +41,7 @@ public void setCacheFactory(CacheFactory cacheFactory) { this.cacheFactory = cacheFactory; } + @Override public Result invoke(Invoker invoker, Invocation invocation) throws RpcException { if (cacheFactory != null && ConfigUtils.isNotEmpty(invoker.getUrl().getMethodParameter(invocation.getMethodName(), Constants.CACHE_KEY))) { Cache cache = cacheFactory.getCache(invoker.getUrl().addParameter(Constants.METHOD_KEY, invocation.getMethodName())); diff --git a/dubbo-filter/dubbo-filter-cache/src/main/java/com/alibaba/dubbo/cache/support/AbstractCacheFactory.java b/dubbo-filter/dubbo-filter-cache/src/main/java/com/alibaba/dubbo/cache/support/AbstractCacheFactory.java index 06713da5637..5a3f47fc3f5 100644 --- a/dubbo-filter/dubbo-filter-cache/src/main/java/com/alibaba/dubbo/cache/support/AbstractCacheFactory.java +++ b/dubbo-filter/dubbo-filter-cache/src/main/java/com/alibaba/dubbo/cache/support/AbstractCacheFactory.java @@ -30,6 +30,7 @@ public abstract class AbstractCacheFactory implements CacheFactory { private final ConcurrentMap caches = new ConcurrentHashMap(); + @Override public Cache getCache(URL url) { String key = url.toFullString(); Cache cache = caches.get(key); diff --git a/dubbo-filter/dubbo-filter-cache/src/main/java/com/alibaba/dubbo/cache/support/jcache/JCache.java b/dubbo-filter/dubbo-filter-cache/src/main/java/com/alibaba/dubbo/cache/support/jcache/JCache.java index 8ad802b0387..314c6500fa1 100644 --- a/dubbo-filter/dubbo-filter-cache/src/main/java/com/alibaba/dubbo/cache/support/jcache/JCache.java +++ b/dubbo-filter/dubbo-filter-cache/src/main/java/com/alibaba/dubbo/cache/support/jcache/JCache.java @@ -65,10 +65,12 @@ public JCache(URL url) { this.store = cache; } + @Override public void put(Object key, Object value) { store.put(key, value); } + @Override public Object get(Object key) { return store.get(key); } diff --git a/dubbo-filter/dubbo-filter-cache/src/main/java/com/alibaba/dubbo/cache/support/jcache/JCacheFactory.java b/dubbo-filter/dubbo-filter-cache/src/main/java/com/alibaba/dubbo/cache/support/jcache/JCacheFactory.java index 5ccc6acd905..737d192f546 100644 --- a/dubbo-filter/dubbo-filter-cache/src/main/java/com/alibaba/dubbo/cache/support/jcache/JCacheFactory.java +++ b/dubbo-filter/dubbo-filter-cache/src/main/java/com/alibaba/dubbo/cache/support/jcache/JCacheFactory.java @@ -25,6 +25,7 @@ */ public class JCacheFactory extends AbstractCacheFactory { + @Override protected Cache createCache(URL url) { return new JCache(url); } diff --git a/dubbo-filter/dubbo-filter-cache/src/main/java/com/alibaba/dubbo/cache/support/lru/LruCache.java b/dubbo-filter/dubbo-filter-cache/src/main/java/com/alibaba/dubbo/cache/support/lru/LruCache.java index a56aa0cc89e..4fe5248fb68 100644 --- a/dubbo-filter/dubbo-filter-cache/src/main/java/com/alibaba/dubbo/cache/support/lru/LruCache.java +++ b/dubbo-filter/dubbo-filter-cache/src/main/java/com/alibaba/dubbo/cache/support/lru/LruCache.java @@ -34,10 +34,12 @@ public LruCache(URL url) { this.store = new LRUCache(max); } + @Override public void put(Object key, Object value) { store.put(key, value); } + @Override public Object get(Object key) { return store.get(key); } diff --git a/dubbo-filter/dubbo-filter-cache/src/main/java/com/alibaba/dubbo/cache/support/lru/LruCacheFactory.java b/dubbo-filter/dubbo-filter-cache/src/main/java/com/alibaba/dubbo/cache/support/lru/LruCacheFactory.java index 376423b6cb1..2c7b28d3196 100644 --- a/dubbo-filter/dubbo-filter-cache/src/main/java/com/alibaba/dubbo/cache/support/lru/LruCacheFactory.java +++ b/dubbo-filter/dubbo-filter-cache/src/main/java/com/alibaba/dubbo/cache/support/lru/LruCacheFactory.java @@ -25,6 +25,7 @@ */ public class LruCacheFactory extends AbstractCacheFactory { + @Override protected Cache createCache(URL url) { return new LruCache(url); } diff --git a/dubbo-filter/dubbo-filter-cache/src/main/java/com/alibaba/dubbo/cache/support/threadlocal/ThreadLocalCache.java b/dubbo-filter/dubbo-filter-cache/src/main/java/com/alibaba/dubbo/cache/support/threadlocal/ThreadLocalCache.java index bffdd1782d7..bf8fbab1eb6 100644 --- a/dubbo-filter/dubbo-filter-cache/src/main/java/com/alibaba/dubbo/cache/support/threadlocal/ThreadLocalCache.java +++ b/dubbo-filter/dubbo-filter-cache/src/main/java/com/alibaba/dubbo/cache/support/threadlocal/ThreadLocalCache.java @@ -38,10 +38,12 @@ protected Map initialValue() { }; } + @Override public void put(Object key, Object value) { store.get().put(key, value); } + @Override public Object get(Object key) { return store.get().get(key); } diff --git a/dubbo-filter/dubbo-filter-cache/src/main/java/com/alibaba/dubbo/cache/support/threadlocal/ThreadLocalCacheFactory.java b/dubbo-filter/dubbo-filter-cache/src/main/java/com/alibaba/dubbo/cache/support/threadlocal/ThreadLocalCacheFactory.java index 24606664e64..693d33eb091 100644 --- a/dubbo-filter/dubbo-filter-cache/src/main/java/com/alibaba/dubbo/cache/support/threadlocal/ThreadLocalCacheFactory.java +++ b/dubbo-filter/dubbo-filter-cache/src/main/java/com/alibaba/dubbo/cache/support/threadlocal/ThreadLocalCacheFactory.java @@ -25,6 +25,7 @@ */ public class ThreadLocalCacheFactory extends AbstractCacheFactory { + @Override protected Cache createCache(URL url) { return new ThreadLocalCache(url); } diff --git a/dubbo-filter/dubbo-filter-validation/src/main/java/com/alibaba/dubbo/validation/filter/ValidationFilter.java b/dubbo-filter/dubbo-filter-validation/src/main/java/com/alibaba/dubbo/validation/filter/ValidationFilter.java index d26d01888db..1fe717cf404 100644 --- a/dubbo-filter/dubbo-filter-validation/src/main/java/com/alibaba/dubbo/validation/filter/ValidationFilter.java +++ b/dubbo-filter/dubbo-filter-validation/src/main/java/com/alibaba/dubbo/validation/filter/ValidationFilter.java @@ -40,6 +40,7 @@ public void setValidation(Validation validation) { this.validation = validation; } + @Override public Result invoke(Invoker invoker, Invocation invocation) throws RpcException { if (validation != null && !invocation.getMethodName().startsWith("$") && ConfigUtils.isNotEmpty(invoker.getUrl().getMethodParameter(invocation.getMethodName(), Constants.VALIDATION_KEY))) { diff --git a/dubbo-filter/dubbo-filter-validation/src/main/java/com/alibaba/dubbo/validation/support/AbstractValidation.java b/dubbo-filter/dubbo-filter-validation/src/main/java/com/alibaba/dubbo/validation/support/AbstractValidation.java index f299eb9f0df..4ffad494bd3 100644 --- a/dubbo-filter/dubbo-filter-validation/src/main/java/com/alibaba/dubbo/validation/support/AbstractValidation.java +++ b/dubbo-filter/dubbo-filter-validation/src/main/java/com/alibaba/dubbo/validation/support/AbstractValidation.java @@ -30,6 +30,7 @@ public abstract class AbstractValidation implements Validation { private final ConcurrentMap validators = new ConcurrentHashMap(); + @Override public Validator getValidator(URL url) { String key = url.toFullString(); Validator validator = validators.get(key); diff --git a/dubbo-filter/dubbo-filter-validation/src/main/java/com/alibaba/dubbo/validation/support/jvalidation/JValidator.java b/dubbo-filter/dubbo-filter-validation/src/main/java/com/alibaba/dubbo/validation/support/jvalidation/JValidator.java index 9010d372604..0d188a2bf32 100644 --- a/dubbo-filter/dubbo-filter-validation/src/main/java/com/alibaba/dubbo/validation/support/jvalidation/JValidator.java +++ b/dubbo-filter/dubbo-filter-validation/src/main/java/com/alibaba/dubbo/validation/support/jvalidation/JValidator.java @@ -233,6 +233,7 @@ else if (memberValue instanceof ArrayMemberValue) { return memberValue; } + @Override public void validate(String methodName, Class[] parameterTypes, Object[] arguments) throws Exception { List> groups = new ArrayList>(); String methodClassName = clazz.getName() + "$" + toUpperMethoName(methodName); diff --git a/dubbo-monitor/dubbo-monitor-api/src/main/java/com/alibaba/dubbo/monitor/support/AbstractMonitorFactory.java b/dubbo-monitor/dubbo-monitor-api/src/main/java/com/alibaba/dubbo/monitor/support/AbstractMonitorFactory.java index 9839e2d75f4..0a60951eae2 100644 --- a/dubbo-monitor/dubbo-monitor-api/src/main/java/com/alibaba/dubbo/monitor/support/AbstractMonitorFactory.java +++ b/dubbo-monitor/dubbo-monitor-api/src/main/java/com/alibaba/dubbo/monitor/support/AbstractMonitorFactory.java @@ -60,6 +60,7 @@ public static Collection getMonitors() { return Collections.unmodifiableCollection(MONITORS.values()); } + @Override public Monitor getMonitor(URL url) { url = url.setPath(MonitorService.class.getName()).addParameter(Constants.INTERFACE_KEY, MonitorService.class.getName()); String key = url.toServiceStringWithoutResolving(); diff --git a/dubbo-monitor/dubbo-monitor-api/src/main/java/com/alibaba/dubbo/monitor/support/MonitorFilter.java b/dubbo-monitor/dubbo-monitor-api/src/main/java/com/alibaba/dubbo/monitor/support/MonitorFilter.java index ebeb4ee8aab..6714c6d9209 100644 --- a/dubbo-monitor/dubbo-monitor-api/src/main/java/com/alibaba/dubbo/monitor/support/MonitorFilter.java +++ b/dubbo-monitor/dubbo-monitor-api/src/main/java/com/alibaba/dubbo/monitor/support/MonitorFilter.java @@ -54,6 +54,7 @@ public void setMonitorFactory(MonitorFactory monitorFactory) { } // intercepting invocation + @Override public Result invoke(Invoker invoker, Invocation invocation) throws RpcException { if (invoker.getUrl().hasParameter(Constants.MONITOR_KEY)) { RpcContext context = RpcContext.getContext(); // provider must fetch context before invoke() gets called diff --git a/dubbo-monitor/dubbo-monitor-default/src/main/java/com/alibaba/dubbo/monitor/dubbo/DubboMonitor.java b/dubbo-monitor/dubbo-monitor-default/src/main/java/com/alibaba/dubbo/monitor/dubbo/DubboMonitor.java index 7393afed1a4..b2e5178c10b 100644 --- a/dubbo-monitor/dubbo-monitor-default/src/main/java/com/alibaba/dubbo/monitor/dubbo/DubboMonitor.java +++ b/dubbo-monitor/dubbo-monitor-default/src/main/java/com/alibaba/dubbo/monitor/dubbo/DubboMonitor.java @@ -61,6 +61,7 @@ public DubboMonitor(Invoker monitorInvoker, MonitorService monit this.monitorInterval = monitorInvoker.getUrl().getPositiveParameter("interval", 60000); // collect timer for collecting statistics data sendFuture = scheduledExecutorService.scheduleWithFixedDelay(new Runnable() { + @Override public void run() { // collect data try { @@ -133,6 +134,7 @@ public void send() { } } + @Override public void collect(URL url) { // data to collect from url int success = url.getParameter(MonitorService.SUCCESS, 0); @@ -179,18 +181,22 @@ public void collect(URL url) { } while (!reference.compareAndSet(current, update)); } + @Override public List lookup(URL query) { return monitorService.lookup(query); } + @Override public URL getUrl() { return monitorInvoker.getUrl(); } + @Override public boolean isAvailable() { return monitorInvoker.isAvailable(); } + @Override public void destroy() { try { sendFuture.cancel(true); diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/integration/RegistryDirectory.java b/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/integration/RegistryDirectory.java index ee37c85c95d..e832daec501 100644 --- a/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/integration/RegistryDirectory.java +++ b/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/integration/RegistryDirectory.java @@ -159,6 +159,7 @@ public void subscribe(URL url) { registry.subscribe(url, this); } + @Override public void destroy() { if (isDestroyed()) { return; @@ -179,6 +180,7 @@ public void destroy() { } } + @Override public synchronized void notify(List urls) { List invokerUrls = new ArrayList(); List routerUrls = new ArrayList(); @@ -566,6 +568,7 @@ private void destroyUnusedInvokers(Map> oldUrlInvokerMap, Map } } + @Override public List> doList(Invocation invocation) { if (forbidden) { // 1. No service provider 2. Service providers are disabled @@ -598,14 +601,17 @@ public List> doList(Invocation invocation) { return invokers == null ? new ArrayList>(0) : invokers; } + @Override public Class getInterface() { return serviceType; } + @Override public URL getUrl() { return this.overrideDirectoryUrl; } + @Override public boolean isAvailable() { if (isDestroyed()) { return false; @@ -646,6 +652,7 @@ public static InvokerComparator getComparator() { return comparator; } + @Override public int compare(Invoker o1, Invoker o2) { return o1.getUrl().toString().compareTo(o2.getUrl().toString()); } diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/integration/RegistryProtocol.java b/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/integration/RegistryProtocol.java index cd272bd869e..e9fb6b01222 100644 --- a/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/integration/RegistryProtocol.java +++ b/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/integration/RegistryProtocol.java @@ -111,6 +111,7 @@ public void setProxyFactory(ProxyFactory proxyFactory) { this.proxyFactory = proxyFactory; } + @Override public int getDefaultPort() { return 9090; } @@ -124,6 +125,7 @@ public void register(URL registryUrl, URL registedProviderUrl) { registry.register(registedProviderUrl); } + @Override public Exporter export(final Invoker originInvoker) throws RpcException { //export invoker final ExporterChangeableWrapper exporter = doLocalExport(originInvoker); @@ -263,6 +265,7 @@ private String getCacheKey(final Invoker originInvoker) { return key; } + @Override @SuppressWarnings("unchecked") public Invoker refer(Class type, URL url) throws RpcException { url = url.setProtocol(url.getParameter(Constants.REGISTRY_KEY, Constants.DEFAULT_REGISTRY)).removeParameter(Constants.REGISTRY_KEY); @@ -309,6 +312,7 @@ private Invoker doRefer(Cluster cluster, Registry registry, Class type return invoker; } + @Override public void destroy() { List> exporters = new ArrayList>(bounds.values()); for (Exporter exporter : exporters) { @@ -357,6 +361,7 @@ public OverrideListener(URL subscribeUrl, Invoker originalInvoker) { /** * @param urls The list of registered information , is always not empty, The meaning is the same as the return value of {@link com.alibaba.dubbo.registry.RegistryService#lookup(URL)}. */ + @Override public synchronized void notify(List urls) { logger.debug("original override urls: " + urls); List matchedUrls = getMatchedUrls(urls, subscribeUrl); @@ -438,6 +443,7 @@ public Invoker getOriginInvoker() { return originInvoker; } + @Override public Invoker getInvoker() { return exporter.getInvoker(); } @@ -446,6 +452,7 @@ public void setExporter(Exporter exporter) { this.exporter = exporter; } + @Override public void unexport() { String key = getCacheKey(this.originInvoker); bounds.remove(key); @@ -469,10 +476,12 @@ public DestroyableExporter(Exporter exporter, Invoker originInvoker, URL s this.registerUrl = registerUrl; } + @Override public Invoker getInvoker() { return exporter.getInvoker(); } + @Override public void unexport() { Registry registry = RegistryProtocol.INSTANCE.getRegistry(originInvoker); try { diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/status/RegistryStatusChecker.java b/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/status/RegistryStatusChecker.java index 998d6cfabd1..309d9d94b85 100644 --- a/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/status/RegistryStatusChecker.java +++ b/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/status/RegistryStatusChecker.java @@ -31,6 +31,7 @@ @Activate public class RegistryStatusChecker implements StatusChecker { + @Override public Status check() { Collection regsitries = AbstractRegistryFactory.getRegistries(); if (regsitries == null || regsitries.isEmpty()) { diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/support/AbstractRegistry.java b/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/support/AbstractRegistry.java index 7b9acfbfbc6..954cf028970 100644 --- a/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/support/AbstractRegistry.java +++ b/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/support/AbstractRegistry.java @@ -103,6 +103,7 @@ protected static List filterEmpty(URL url, List urls) { return urls; } + @Override public URL getUrl() { return registryUrl; } @@ -230,6 +231,7 @@ public List getCacheUrls(URL url) { return null; } + @Override public List lookup(URL url) { List result = new ArrayList(); Map> notifiedUrls = getNotified().get(url); @@ -244,6 +246,7 @@ public List lookup(URL url) { } else { final AtomicReference> reference = new AtomicReference>(); NotifyListener listener = new NotifyListener() { + @Override public void notify(List urls) { reference.set(urls); } @@ -261,6 +264,7 @@ public void notify(List urls) { return result; } + @Override public void register(URL url) { if (url == null) { throw new IllegalArgumentException("register url == null"); @@ -271,6 +275,7 @@ public void register(URL url) { registered.add(url); } + @Override public void unregister(URL url) { if (url == null) { throw new IllegalArgumentException("unregister url == null"); @@ -281,6 +286,7 @@ public void unregister(URL url) { registered.remove(url); } + @Override public void subscribe(URL url, NotifyListener listener) { if (url == null) { throw new IllegalArgumentException("subscribe url == null"); @@ -299,6 +305,7 @@ public void subscribe(URL url, NotifyListener listener) { listeners.add(listener); } + @Override public void unsubscribe(URL url, NotifyListener listener) { if (url == null) { throw new IllegalArgumentException("unsubscribe url == null"); @@ -438,6 +445,7 @@ private void saveProperties(URL url) { } } + @Override public void destroy() { if (logger.isInfoEnabled()) { logger.info("Destroy registry:" + getUrl()); @@ -475,6 +483,7 @@ public void destroy() { } } + @Override public String toString() { return getUrl().toString(); } @@ -486,6 +495,7 @@ private SaveProperties(long version) { this.version = version; } + @Override public void run() { doSaveProperties(version); } diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/support/AbstractRegistryFactory.java b/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/support/AbstractRegistryFactory.java index 1fa4429a2d6..170ebcd4759 100644 --- a/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/support/AbstractRegistryFactory.java +++ b/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/support/AbstractRegistryFactory.java @@ -80,6 +80,7 @@ public static void destroyAll() { } } + @Override public Registry getRegistry(URL url) { url = url.setPath(RegistryService.class.getName()) .addParameter(Constants.INTERFACE_KEY, RegistryService.class.getName()) diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/support/ConsumerInvokerWrapper.java b/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/support/ConsumerInvokerWrapper.java index e0cb8e1079d..879ea28f96f 100644 --- a/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/support/ConsumerInvokerWrapper.java +++ b/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/support/ConsumerInvokerWrapper.java @@ -41,22 +41,27 @@ public ConsumerInvokerWrapper(Invoker invoker, URL registryUrl, URL consumerU this.registryDirectory = registryDirectory; } + @Override public Class getInterface() { return invoker.getInterface(); } + @Override public URL getUrl() { return invoker.getUrl(); } + @Override public boolean isAvailable() { return invoker.isAvailable(); } + @Override public Result invoke(Invocation invocation) throws RpcException { return invoker.invoke(invocation); } + @Override public void destroy() { invoker.destroy(); } diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/support/FailbackRegistry.java b/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/support/FailbackRegistry.java index 86afffd68d5..b907327d863 100644 --- a/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/support/FailbackRegistry.java +++ b/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/support/FailbackRegistry.java @@ -61,6 +61,7 @@ public FailbackRegistry(URL url) { super(url); int retryPeriod = url.getParameter(Constants.REGISTRY_RETRY_PERIOD_KEY, Constants.DEFAULT_REGISTRY_RETRY_PERIOD); this.retryFuture = retryExecutor.scheduleWithFixedDelay(new Runnable() { + @Override public void run() { // Check and connect to the registry try { diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/support/ProviderInvokerWrapper.java b/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/support/ProviderInvokerWrapper.java index b60fdf5d65e..10d59576952 100644 --- a/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/support/ProviderInvokerWrapper.java +++ b/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/support/ProviderInvokerWrapper.java @@ -39,22 +39,27 @@ public ProviderInvokerWrapper(Invoker invoker,URL registryUrl,URL providerUrl this.providerUrl = providerUrl; } + @Override public Class getInterface() { return invoker.getInterface(); } + @Override public URL getUrl() { return invoker.getUrl(); } + @Override public boolean isAvailable() { return invoker.isAvailable(); } + @Override public Result invoke(Invocation invocation) throws RpcException { return invoker.invoke(invocation); } + @Override public void destroy() { invoker.destroy(); } diff --git a/dubbo-registry/dubbo-registry-default/src/main/java/com/alibaba/dubbo/registry/dubbo/DubboRegistry.java b/dubbo-registry/dubbo-registry-default/src/main/java/com/alibaba/dubbo/registry/dubbo/DubboRegistry.java index 6a5218785dc..a1b29ed24e1 100644 --- a/dubbo-registry/dubbo-registry-default/src/main/java/com/alibaba/dubbo/registry/dubbo/DubboRegistry.java +++ b/dubbo-registry/dubbo-registry-default/src/main/java/com/alibaba/dubbo/registry/dubbo/DubboRegistry.java @@ -66,6 +66,7 @@ public DubboRegistry(Invoker registryInvoker, RegistryService r // Start reconnection timer int reconnectPeriod = registryInvoker.getUrl().getParameter(Constants.REGISTRY_RECONNECT_PERIOD_KEY, RECONNECT_PERIOD_DEFAULT); reconnectFuture = scheduledExecutorService.scheduleWithFixedDelay(new Runnable() { + @Override public void run() { // Check and connect to the registry try { @@ -107,12 +108,14 @@ protected final void connect() { } } + @Override public boolean isAvailable() { if (registryInvoker == null) return false; return registryInvoker.isAvailable(); } + @Override public void destroy() { super.destroy(); try { @@ -126,22 +129,27 @@ public void destroy() { registryInvoker.destroy(); } + @Override protected void doRegister(URL url) { registryService.register(url); } + @Override protected void doUnregister(URL url) { registryService.unregister(url); } + @Override protected void doSubscribe(URL url, NotifyListener listener) { registryService.subscribe(url, listener); } + @Override protected void doUnsubscribe(URL url, NotifyListener listener) { registryService.unsubscribe(url, listener); } + @Override public List lookup(URL url) { return registryService.lookup(url); } diff --git a/dubbo-registry/dubbo-registry-default/src/main/java/com/alibaba/dubbo/registry/dubbo/DubboRegistryFactory.java b/dubbo-registry/dubbo-registry-default/src/main/java/com/alibaba/dubbo/registry/dubbo/DubboRegistryFactory.java index c5be79c9af1..bcb6526c2e6 100644 --- a/dubbo-registry/dubbo-registry-default/src/main/java/com/alibaba/dubbo/registry/dubbo/DubboRegistryFactory.java +++ b/dubbo-registry/dubbo-registry-default/src/main/java/com/alibaba/dubbo/registry/dubbo/DubboRegistryFactory.java @@ -75,6 +75,7 @@ public void setCluster(Cluster cluster) { this.cluster = cluster; } + @Override public Registry createRegistry(URL url) { url = getRegistryURL(url); List urls = new ArrayList(); diff --git a/dubbo-registry/dubbo-registry-multicast/src/main/java/com/alibaba/dubbo/registry/multicast/MulticastRegistry.java b/dubbo-registry/dubbo-registry-multicast/src/main/java/com/alibaba/dubbo/registry/multicast/MulticastRegistry.java index e90edef2c09..cd041410719 100644 --- a/dubbo-registry/dubbo-registry-multicast/src/main/java/com/alibaba/dubbo/registry/multicast/MulticastRegistry.java +++ b/dubbo-registry/dubbo-registry-multicast/src/main/java/com/alibaba/dubbo/registry/multicast/MulticastRegistry.java @@ -88,6 +88,7 @@ public MulticastRegistry(URL url) { mutilcastSocket.setLoopbackMode(false); mutilcastSocket.joinGroup(mutilcastAddress); Thread thread = new Thread(new Runnable() { + @Override public void run() { byte[] buf = new byte[2048]; DatagramPacket recv = new DatagramPacket(buf, buf.length); @@ -117,6 +118,7 @@ public void run() { this.cleanPeriod = url.getParameter(Constants.SESSION_TIMEOUT_KEY, Constants.DEFAULT_SESSION_TIMEOUT); if (url.getParameter("clean", true)) { this.cleanFuture = cleanExecutor.scheduleWithFixedDelay(new Runnable() { + @Override public void run() { try { clean(); // Remove the expired @@ -254,14 +256,17 @@ private void unicast(String msg, String host) { } } + @Override protected void doRegister(URL url) { broadcast(Constants.REGISTER + " " + url.toFullString()); } + @Override protected void doUnregister(URL url) { broadcast(Constants.UNREGISTER + " " + url.toFullString()); } + @Override protected void doSubscribe(URL url, NotifyListener listener) { if (Constants.ANY_VALUE.equals(url.getServiceInterface())) { admin = true; @@ -275,6 +280,7 @@ protected void doSubscribe(URL url, NotifyListener listener) { } } + @Override protected void doUnsubscribe(URL url, NotifyListener listener) { if (!Constants.ANY_VALUE.equals(url.getServiceInterface()) && url.getParameter(Constants.REGISTER_KEY, true)) { @@ -283,6 +289,7 @@ protected void doUnsubscribe(URL url, NotifyListener listener) { broadcast(Constants.UNSUBSCRIBE + " " + url.toFullString()); } + @Override public boolean isAvailable() { try { return mutilcastSocket != null; @@ -291,6 +298,7 @@ public boolean isAvailable() { } } + @Override public void destroy() { super.destroy(); try { @@ -367,26 +375,31 @@ private List toList(Set urls) { return list; } + @Override public void register(URL url) { super.register(url); registered(url); } + @Override public void unregister(URL url) { super.unregister(url); unregistered(url); } + @Override public void subscribe(URL url, NotifyListener listener) { super.subscribe(url, listener); subscribed(url, listener); } + @Override public void unsubscribe(URL url, NotifyListener listener) { super.unsubscribe(url, listener); received.remove(url); } + @Override public List lookup(URL url) { List urls = new ArrayList(); Map> notifiedUrls = getNotified().get(url); diff --git a/dubbo-registry/dubbo-registry-multicast/src/main/java/com/alibaba/dubbo/registry/multicast/MulticastRegistryFactory.java b/dubbo-registry/dubbo-registry-multicast/src/main/java/com/alibaba/dubbo/registry/multicast/MulticastRegistryFactory.java index 5b81456285a..015e8a778db 100644 --- a/dubbo-registry/dubbo-registry-multicast/src/main/java/com/alibaba/dubbo/registry/multicast/MulticastRegistryFactory.java +++ b/dubbo-registry/dubbo-registry-multicast/src/main/java/com/alibaba/dubbo/registry/multicast/MulticastRegistryFactory.java @@ -26,6 +26,7 @@ */ public class MulticastRegistryFactory extends AbstractRegistryFactory { + @Override public Registry createRegistry(URL url) { return new MulticastRegistry(url); } diff --git a/dubbo-registry/dubbo-registry-redis/src/main/java/com/alibaba/dubbo/registry/redis/RedisRegistry.java b/dubbo-registry/dubbo-registry-redis/src/main/java/com/alibaba/dubbo/registry/redis/RedisRegistry.java index 4cc87dd6b6b..ea4b22cba05 100644 --- a/dubbo-registry/dubbo-registry-redis/src/main/java/com/alibaba/dubbo/registry/redis/RedisRegistry.java +++ b/dubbo-registry/dubbo-registry-redis/src/main/java/com/alibaba/dubbo/registry/redis/RedisRegistry.java @@ -152,6 +152,7 @@ public RedisRegistry(URL url) { this.expirePeriod = url.getParameter(Constants.SESSION_TIMEOUT_KEY, Constants.DEFAULT_SESSION_TIMEOUT); this.expireFuture = expireExecutor.scheduleWithFixedDelay(new Runnable() { + @Override public void run() { try { deferExpired(); // Extend the expiration time @@ -221,6 +222,7 @@ private void clean(Jedis jedis) { } } + @Override public boolean isAvailable() { for (JedisPool jedisPool : jedisPools.values()) { try { diff --git a/dubbo-registry/dubbo-registry-zookeeper/src/main/java/com/alibaba/dubbo/registry/zookeeper/ZookeeperRegistry.java b/dubbo-registry/dubbo-registry-zookeeper/src/main/java/com/alibaba/dubbo/registry/zookeeper/ZookeeperRegistry.java index dcce7e4d498..67aaeba04b8 100644 --- a/dubbo-registry/dubbo-registry-zookeeper/src/main/java/com/alibaba/dubbo/registry/zookeeper/ZookeeperRegistry.java +++ b/dubbo-registry/dubbo-registry-zookeeper/src/main/java/com/alibaba/dubbo/registry/zookeeper/ZookeeperRegistry.java @@ -68,6 +68,7 @@ public ZookeeperRegistry(URL url, ZookeeperTransporter zookeeperTransporter) { this.root = group; zkClient = zookeeperTransporter.connect(url); zkClient.addStateListener(new StateListener() { + @Override public void stateChanged(int state) { if (state == RECONNECTED) { try { @@ -92,10 +93,12 @@ static String appendDefaultPort(String address) { return address; } + @Override public boolean isAvailable() { return zkClient.isConnected(); } + @Override public void destroy() { super.destroy(); try { @@ -105,6 +108,7 @@ public void destroy() { } } + @Override protected void doRegister(URL url) { try { zkClient.create(toUrlPath(url), url.getParameter(Constants.DYNAMIC_KEY, true)); @@ -113,6 +117,7 @@ protected void doRegister(URL url) { } } + @Override protected void doUnregister(URL url) { try { zkClient.delete(toUrlPath(url)); @@ -121,6 +126,7 @@ protected void doUnregister(URL url) { } } + @Override protected void doSubscribe(final URL url, final NotifyListener listener) { try { if (Constants.ANY_VALUE.equals(url.getServiceInterface())) { @@ -133,6 +139,7 @@ protected void doSubscribe(final URL url, final NotifyListener listener) { ChildListener zkListener = listeners.get(listener); if (zkListener == null) { listeners.putIfAbsent(listener, new ChildListener() { + @Override public void childChanged(String parentPath, List currentChilds) { for (String child : currentChilds) { child = URL.decode(child); @@ -167,6 +174,7 @@ public void childChanged(String parentPath, List currentChilds) { ChildListener zkListener = listeners.get(listener); if (zkListener == null) { listeners.putIfAbsent(listener, new ChildListener() { + @Override public void childChanged(String parentPath, List currentChilds) { ZookeeperRegistry.this.notify(url, listener, toUrlsWithEmpty(url, parentPath, currentChilds)); } @@ -186,6 +194,7 @@ public void childChanged(String parentPath, List currentChilds) { } } + @Override protected void doUnsubscribe(URL url, NotifyListener listener) { ConcurrentMap listeners = zkListeners.get(url); if (listeners != null) { @@ -196,6 +205,7 @@ protected void doUnsubscribe(URL url, NotifyListener listener) { } } + @Override public List lookup(URL url) { if (url == null) { throw new IllegalArgumentException("lookup url == null"); diff --git a/dubbo-registry/dubbo-registry-zookeeper/src/main/java/com/alibaba/dubbo/registry/zookeeper/ZookeeperRegistryFactory.java b/dubbo-registry/dubbo-registry-zookeeper/src/main/java/com/alibaba/dubbo/registry/zookeeper/ZookeeperRegistryFactory.java index d0bba0a132e..95c225da3ec 100644 --- a/dubbo-registry/dubbo-registry-zookeeper/src/main/java/com/alibaba/dubbo/registry/zookeeper/ZookeeperRegistryFactory.java +++ b/dubbo-registry/dubbo-registry-zookeeper/src/main/java/com/alibaba/dubbo/registry/zookeeper/ZookeeperRegistryFactory.java @@ -33,6 +33,7 @@ public void setZookeeperTransporter(ZookeeperTransporter zookeeperTransporter) { this.zookeeperTransporter = zookeeperTransporter; } + @Override public Registry createRegistry(URL url) { return new ZookeeperRegistry(url, zookeeperTransporter); } diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/buffer/AbstractChannelBuffer.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/buffer/AbstractChannelBuffer.java index 6347c0d085a..b924de2e9ce 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/buffer/AbstractChannelBuffer.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/buffer/AbstractChannelBuffer.java @@ -32,10 +32,12 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer { private int markedWriterIndex; + @Override public int readerIndex() { return readerIndex; } + @Override public void readerIndex(int readerIndex) { if (readerIndex < 0 || readerIndex > writerIndex) { throw new IndexOutOfBoundsException(); @@ -43,10 +45,12 @@ public void readerIndex(int readerIndex) { this.readerIndex = readerIndex; } + @Override public int writerIndex() { return writerIndex; } + @Override public void writerIndex(int writerIndex) { if (writerIndex < readerIndex || writerIndex > capacity()) { throw new IndexOutOfBoundsException(); @@ -54,6 +58,7 @@ public void writerIndex(int writerIndex) { this.writerIndex = writerIndex; } + @Override public void setIndex(int readerIndex, int writerIndex) { if (readerIndex < 0 || readerIndex > writerIndex || writerIndex > capacity()) { throw new IndexOutOfBoundsException(); @@ -62,42 +67,52 @@ public void setIndex(int readerIndex, int writerIndex) { this.writerIndex = writerIndex; } + @Override public void clear() { readerIndex = writerIndex = 0; } + @Override public boolean readable() { return readableBytes() > 0; } + @Override public boolean writable() { return writableBytes() > 0; } + @Override public int readableBytes() { return writerIndex - readerIndex; } + @Override public int writableBytes() { return capacity() - writerIndex; } + @Override public void markReaderIndex() { markedReaderIndex = readerIndex; } + @Override public void resetReaderIndex() { readerIndex(markedReaderIndex); } + @Override public void markWriterIndex() { markedWriterIndex = writerIndex; } + @Override public void resetWriterIndex() { writerIndex = markedWriterIndex; } + @Override public void discardReadBytes() { if (readerIndex == 0) { return; @@ -109,20 +124,24 @@ public void discardReadBytes() { readerIndex = 0; } + @Override public void ensureWritableBytes(int writableBytes) { if (writableBytes > writableBytes()) { throw new IndexOutOfBoundsException(); } } + @Override public void getBytes(int index, byte[] dst) { getBytes(index, dst, 0, dst.length); } + @Override public void getBytes(int index, ChannelBuffer dst) { getBytes(index, dst, dst.writableBytes()); } + @Override public void getBytes(int index, ChannelBuffer dst, int length) { if (length > dst.writableBytes()) { throw new IndexOutOfBoundsException(); @@ -131,14 +150,17 @@ public void getBytes(int index, ChannelBuffer dst, int length) { dst.writerIndex(dst.writerIndex() + length); } + @Override public void setBytes(int index, byte[] src) { setBytes(index, src, 0, src.length); } + @Override public void setBytes(int index, ChannelBuffer src) { setBytes(index, src, src.readableBytes()); } + @Override public void setBytes(int index, ChannelBuffer src, int length) { if (length > src.readableBytes()) { throw new IndexOutOfBoundsException(); @@ -147,6 +169,7 @@ public void setBytes(int index, ChannelBuffer src, int length) { src.readerIndex(src.readerIndex() + length); } + @Override public byte readByte() { if (readerIndex == writerIndex) { throw new IndexOutOfBoundsException(); @@ -154,6 +177,7 @@ public byte readByte() { return getByte(readerIndex++); } + @Override public ChannelBuffer readBytes(int length) { checkReadableBytes(length); if (length == 0) { @@ -165,20 +189,24 @@ public ChannelBuffer readBytes(int length) { return buf; } + @Override public void readBytes(byte[] dst, int dstIndex, int length) { checkReadableBytes(length); getBytes(readerIndex, dst, dstIndex, length); readerIndex += length; } + @Override public void readBytes(byte[] dst) { readBytes(dst, 0, dst.length); } + @Override public void readBytes(ChannelBuffer dst) { readBytes(dst, dst.writableBytes()); } + @Override public void readBytes(ChannelBuffer dst, int length) { if (length > dst.writableBytes()) { throw new IndexOutOfBoundsException(); @@ -187,12 +215,14 @@ public void readBytes(ChannelBuffer dst, int length) { dst.writerIndex(dst.writerIndex() + length); } + @Override public void readBytes(ChannelBuffer dst, int dstIndex, int length) { checkReadableBytes(length); getBytes(readerIndex, dst, dstIndex, length); readerIndex += length; } + @Override public void readBytes(ByteBuffer dst) { int length = dst.remaining(); checkReadableBytes(length); @@ -200,12 +230,14 @@ public void readBytes(ByteBuffer dst) { readerIndex += length; } + @Override public void readBytes(OutputStream out, int length) throws IOException { checkReadableBytes(length); getBytes(readerIndex, out, length); readerIndex += length; } + @Override public void skipBytes(int length) { int newReaderIndex = readerIndex + length; if (newReaderIndex > writerIndex) { @@ -214,23 +246,28 @@ public void skipBytes(int length) { readerIndex = newReaderIndex; } + @Override public void writeByte(int value) { setByte(writerIndex++, value); } + @Override public void writeBytes(byte[] src, int srcIndex, int length) { setBytes(writerIndex, src, srcIndex, length); writerIndex += length; } + @Override public void writeBytes(byte[] src) { writeBytes(src, 0, src.length); } + @Override public void writeBytes(ChannelBuffer src) { writeBytes(src, src.readableBytes()); } + @Override public void writeBytes(ChannelBuffer src, int length) { if (length > src.readableBytes()) { throw new IndexOutOfBoundsException(); @@ -239,17 +276,20 @@ public void writeBytes(ChannelBuffer src, int length) { src.readerIndex(src.readerIndex() + length); } + @Override public void writeBytes(ChannelBuffer src, int srcIndex, int length) { setBytes(writerIndex, src, srcIndex, length); writerIndex += length; } + @Override public void writeBytes(ByteBuffer src) { int length = src.remaining(); setBytes(writerIndex, src); writerIndex += length; } + @Override public int writeBytes(InputStream in, int length) throws IOException { int writtenBytes = setBytes(writerIndex, in, length); if (writtenBytes > 0) { @@ -258,10 +298,12 @@ public int writeBytes(InputStream in, int length) throws IOException { return writtenBytes; } + @Override public ChannelBuffer copy() { return copy(readerIndex, readableBytes()); } + @Override public ByteBuffer toByteBuffer() { return toByteBuffer(readerIndex, readableBytes()); } @@ -272,6 +314,7 @@ public boolean equals(Object o) { && ChannelBuffers.equals(this, (ChannelBuffer) o); } + @Override public int compareTo(ChannelBuffer that) { return ChannelBuffers.compare(this, that); } diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/buffer/ByteBufferBackedChannelBuffer.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/buffer/ByteBufferBackedChannelBuffer.java index 4d5e2eb2af6..54447f9c0d9 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/buffer/ByteBufferBackedChannelBuffer.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/buffer/ByteBufferBackedChannelBuffer.java @@ -44,6 +44,7 @@ public ByteBufferBackedChannelBuffer(ByteBufferBackedChannelBuffer buffer) { setIndex(buffer.readerIndex(), buffer.writerIndex()); } + @Override public ChannelBufferFactory factory() { if (buffer.isDirect()) { return DirectChannelBufferFactory.getInstance(); @@ -53,11 +54,13 @@ public ChannelBufferFactory factory() { } + @Override public int capacity() { return capacity; } + @Override public ChannelBuffer copy(int index, int length) { ByteBuffer src; try { @@ -75,11 +78,13 @@ public ChannelBuffer copy(int index, int length) { } + @Override public byte getByte(int index) { return buffer.get(index); } + @Override public void getBytes(int index, byte[] dst, int dstIndex, int length) { ByteBuffer data = buffer.duplicate(); try { @@ -91,6 +96,7 @@ public void getBytes(int index, byte[] dst, int dstIndex, int length) { } + @Override public void getBytes(int index, ByteBuffer dst) { ByteBuffer data = buffer.duplicate(); int bytesToCopy = Math.min(capacity() - index, dst.remaining()); @@ -103,6 +109,7 @@ public void getBytes(int index, ByteBuffer dst) { } + @Override public void getBytes(int index, ChannelBuffer dst, int dstIndex, int length) { if (dst instanceof ByteBufferBackedChannelBuffer) { ByteBufferBackedChannelBuffer bbdst = (ByteBufferBackedChannelBuffer) dst; @@ -118,6 +125,7 @@ public void getBytes(int index, ChannelBuffer dst, int dstIndex, int length) { } + @Override public void getBytes(int index, OutputStream out, int length) throws IOException { if (length == 0) { return; @@ -136,16 +144,19 @@ public void getBytes(int index, OutputStream out, int length) throws IOException } + @Override public boolean isDirect() { return buffer.isDirect(); } + @Override public void setByte(int index, int value) { buffer.put(index, (byte) value); } + @Override public void setBytes(int index, byte[] src, int srcIndex, int length) { ByteBuffer data = buffer.duplicate(); data.limit(index + length).position(index); @@ -153,6 +164,7 @@ public void setBytes(int index, byte[] src, int srcIndex, int length) { } + @Override public void setBytes(int index, ByteBuffer src) { ByteBuffer data = buffer.duplicate(); data.limit(index + src.remaining()).position(index); @@ -160,6 +172,7 @@ public void setBytes(int index, ByteBuffer src) { } + @Override public void setBytes(int index, ChannelBuffer src, int srcIndex, int length) { if (src instanceof ByteBufferBackedChannelBuffer) { ByteBufferBackedChannelBuffer bbsrc = (ByteBufferBackedChannelBuffer) src; @@ -175,6 +188,7 @@ public void setBytes(int index, ChannelBuffer src, int srcIndex, int length) { } + @Override public ByteBuffer toByteBuffer(int index, int length) { if (index == 0 && length == capacity()) { return buffer.duplicate(); @@ -185,6 +199,7 @@ public ByteBuffer toByteBuffer(int index, int length) { } + @Override public int setBytes(int index, InputStream in, int length) throws IOException { int readBytes = 0; @@ -225,16 +240,19 @@ public int setBytes(int index, InputStream in, int length) throws IOException { } + @Override public byte[] array() { return buffer.array(); } + @Override public boolean hasArray() { return buffer.hasArray(); } + @Override public int arrayOffset() { return buffer.arrayOffset(); } diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/buffer/ChannelBuffer.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/buffer/ChannelBuffer.java index da669cfa20c..4771d16a884 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/buffer/ChannelBuffer.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/buffer/ChannelBuffer.java @@ -274,6 +274,7 @@ public interface ChannelBuffer extends Comparable { * method also returns {@code false} for {@code null} and an object which is * not an instance of {@link ChannelBuffer} type. */ + @Override public boolean equals(Object o); /** diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/buffer/DirectChannelBufferFactory.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/buffer/DirectChannelBufferFactory.java index 18a646ecb34..ec6707018e6 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/buffer/DirectChannelBufferFactory.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/buffer/DirectChannelBufferFactory.java @@ -31,6 +31,7 @@ public static ChannelBufferFactory getInstance() { return INSTANCE; } + @Override public ChannelBuffer getBuffer(int capacity) { if (capacity < 0) { throw new IllegalArgumentException("capacity: " + capacity); @@ -41,6 +42,7 @@ public ChannelBuffer getBuffer(int capacity) { return ChannelBuffers.directBuffer(capacity); } + @Override public ChannelBuffer getBuffer(byte[] array, int offset, int length) { if (array == null) { throw new NullPointerException("array"); @@ -60,6 +62,7 @@ public ChannelBuffer getBuffer(byte[] array, int offset, int length) { return buf; } + @Override public ChannelBuffer getBuffer(ByteBuffer nioBuffer) { if (!nioBuffer.isReadOnly() && nioBuffer.isDirect()) { return ChannelBuffers.wrappedBuffer(nioBuffer); diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/buffer/DynamicChannelBuffer.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/buffer/DynamicChannelBuffer.java index 7f9c563b7e1..2cb4851c982 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/buffer/DynamicChannelBuffer.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/buffer/DynamicChannelBuffer.java @@ -66,11 +66,13 @@ public void ensureWritableBytes(int minWritableBytes) { } + @Override public int capacity() { return buffer.capacity(); } + @Override public ChannelBuffer copy(int index, int length) { DynamicChannelBuffer copiedBuffer = new DynamicChannelBuffer(Math.max(length, 64), factory()); copiedBuffer.buffer = buffer.copy(index, length); @@ -79,66 +81,79 @@ public ChannelBuffer copy(int index, int length) { } + @Override public ChannelBufferFactory factory() { return factory; } + @Override public byte getByte(int index) { return buffer.getByte(index); } + @Override public void getBytes(int index, byte[] dst, int dstIndex, int length) { buffer.getBytes(index, dst, dstIndex, length); } + @Override public void getBytes(int index, ByteBuffer dst) { buffer.getBytes(index, dst); } + @Override public void getBytes(int index, ChannelBuffer dst, int dstIndex, int length) { buffer.getBytes(index, dst, dstIndex, length); } + @Override public void getBytes(int index, OutputStream dst, int length) throws IOException { buffer.getBytes(index, dst, length); } + @Override public boolean isDirect() { return buffer.isDirect(); } + @Override public void setByte(int index, int value) { buffer.setByte(index, value); } + @Override public void setBytes(int index, byte[] src, int srcIndex, int length) { buffer.setBytes(index, src, srcIndex, length); } + @Override public void setBytes(int index, ByteBuffer src) { buffer.setBytes(index, src); } + @Override public void setBytes(int index, ChannelBuffer src, int srcIndex, int length) { buffer.setBytes(index, src, srcIndex, length); } + @Override public int setBytes(int index, InputStream src, int length) throws IOException { return buffer.setBytes(index, src, length); } + @Override public ByteBuffer toByteBuffer(int index, int length) { return buffer.toByteBuffer(index, length); } @@ -174,16 +189,19 @@ public int writeBytes(InputStream in, int length) throws IOException { } + @Override public byte[] array() { return buffer.array(); } + @Override public boolean hasArray() { return buffer.hasArray(); } + @Override public int arrayOffset() { return buffer.arrayOffset(); } diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/buffer/HeapChannelBuffer.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/buffer/HeapChannelBuffer.java index e61a7d05344..952b693b60e 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/buffer/HeapChannelBuffer.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/buffer/HeapChannelBuffer.java @@ -65,30 +65,37 @@ protected HeapChannelBuffer(byte[] array, int readerIndex, int writerIndex) { setIndex(readerIndex, writerIndex); } + @Override public boolean isDirect() { return false; } + @Override public int capacity() { return array.length; } + @Override public boolean hasArray() { return true; } + @Override public byte[] array() { return array; } + @Override public int arrayOffset() { return 0; } + @Override public byte getByte(int index) { return array[index]; } + @Override public void getBytes(int index, ChannelBuffer dst, int dstIndex, int length) { if (dst instanceof HeapChannelBuffer) { getBytes(index, ((HeapChannelBuffer) dst).array, dstIndex, length); @@ -97,14 +104,17 @@ public void getBytes(int index, ChannelBuffer dst, int dstIndex, int length) { } } + @Override public void getBytes(int index, byte[] dst, int dstIndex, int length) { System.arraycopy(array, index, dst, dstIndex, length); } + @Override public void getBytes(int index, ByteBuffer dst) { dst.put(array, index, Math.min(capacity() - index, dst.remaining())); } + @Override public void getBytes(int index, OutputStream out, int length) throws IOException { out.write(array, index, length); @@ -115,10 +125,12 @@ public int getBytes(int index, GatheringByteChannel out, int length) return out.write(ByteBuffer.wrap(array, index, length)); } + @Override public void setByte(int index, int value) { array[index] = (byte) value; } + @Override public void setBytes(int index, ChannelBuffer src, int srcIndex, int length) { if (src instanceof HeapChannelBuffer) { setBytes(index, ((HeapChannelBuffer) src).array, srcIndex, length); @@ -127,14 +139,17 @@ public void setBytes(int index, ChannelBuffer src, int srcIndex, int length) { } } + @Override public void setBytes(int index, byte[] src, int srcIndex, int length) { System.arraycopy(src, srcIndex, array, index, length); } + @Override public void setBytes(int index, ByteBuffer src) { src.get(array, index, src.remaining()); } + @Override public int setBytes(int index, InputStream in, int length) throws IOException { int readBytes = 0; do { @@ -180,6 +195,7 @@ public int setBytes(int index, ScatteringByteChannel in, int length) throws IOEx return readBytes; } + @Override public ChannelBuffer copy(int index, int length) { if (index < 0 || length < 0 || index + length > array.length) { throw new IndexOutOfBoundsException(); @@ -190,10 +206,12 @@ public ChannelBuffer copy(int index, int length) { return new HeapChannelBuffer(copiedArray); } + @Override public ChannelBufferFactory factory() { return HeapChannelBufferFactory.getInstance(); } + @Override public ByteBuffer toByteBuffer(int index, int length) { return ByteBuffer.wrap(array, index, length); } diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/buffer/HeapChannelBufferFactory.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/buffer/HeapChannelBufferFactory.java index d91f2c2f15a..88628a06181 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/buffer/HeapChannelBufferFactory.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/buffer/HeapChannelBufferFactory.java @@ -31,14 +31,17 @@ public static ChannelBufferFactory getInstance() { return INSTANCE; } + @Override public ChannelBuffer getBuffer(int capacity) { return ChannelBuffers.buffer(capacity); } + @Override public ChannelBuffer getBuffer(byte[] array, int offset, int length) { return ChannelBuffers.wrappedBuffer(array, offset, length); } + @Override public ChannelBuffer getBuffer(ByteBuffer nioBuffer) { if (nioBuffer.hasArray()) { return ChannelBuffers.wrappedBuffer(nioBuffer); diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/ExchangeChannel.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/ExchangeChannel.java index dd645c236d0..749c24cc1ec 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/ExchangeChannel.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/ExchangeChannel.java @@ -55,6 +55,7 @@ public interface ExchangeChannel extends Channel { * * @param timeout */ + @Override void close(int timeout); } \ No newline at end of file diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/codec/ExchangeCodec.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/codec/ExchangeCodec.java index c35da1eede8..10025d26bb0 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/codec/ExchangeCodec.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/codec/ExchangeCodec.java @@ -65,6 +65,7 @@ public Short getMagicCode() { return MAGIC; } + @Override public void encode(Channel channel, ChannelBuffer buffer, Object msg) throws IOException { if (msg instanceof Request) { encodeRequest(channel, buffer, (Request) msg); @@ -75,6 +76,7 @@ public void encode(Channel channel, ChannelBuffer buffer, Object msg) throws IOE } } + @Override public Object decode(Channel channel, ChannelBuffer buffer) throws IOException { int readable = buffer.readableBytes(); byte[] header = new byte[Math.min(readable, HEADER_LENGTH)]; @@ -82,6 +84,7 @@ public Object decode(Channel channel, ChannelBuffer buffer) throws IOException { return decode(channel, buffer, readable, header); } + @Override protected Object decode(Channel channel, ChannelBuffer buffer, int readable, byte[] header) throws IOException { // check magic number. if (readable > 0 && header[0] != MAGIC_HIGH diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/DefaultFuture.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/DefaultFuture.java index 9ce56ba5a0c..dd5f0d4bb85 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/DefaultFuture.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/DefaultFuture.java @@ -107,10 +107,12 @@ public static void received(Channel channel, Response response) { } } + @Override public Object get() throws RemotingException { return get(timeout); } + @Override public Object get(int timeout) throws RemotingException { if (timeout <= 0) { timeout = Constants.DEFAULT_TIMEOUT; @@ -145,10 +147,12 @@ public void cancel() { CHANNELS.remove(id); } + @Override public boolean isDone() { return response != null; } + @Override public void setCallback(ResponseCallback callback) { if (isDone()) { invokeCallback(callback); @@ -276,6 +280,7 @@ private String getTimeoutMessage(boolean scan) { private static class RemotingInvocationTimeoutScan implements Runnable { + @Override public void run() { while (true) { try { diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/ExchangeHandlerAdapter.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/ExchangeHandlerAdapter.java index aaefa9a291e..9025f345dd7 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/ExchangeHandlerAdapter.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/ExchangeHandlerAdapter.java @@ -26,6 +26,7 @@ */ public abstract class ExchangeHandlerAdapter extends TelnetHandlerAdapter implements ExchangeHandler { + @Override public Object reply(ExchangeChannel channel, Object msg) throws RemotingException { return null; } diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/ExchangeHandlerDispatcher.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/ExchangeHandlerDispatcher.java index d7709693276..7e61ca35aed 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/ExchangeHandlerDispatcher.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/ExchangeHandlerDispatcher.java @@ -80,31 +80,38 @@ public ExchangeHandlerDispatcher removeReplier(Class type) { return this; } + @Override @SuppressWarnings({"unchecked", "rawtypes"}) public Object reply(ExchangeChannel channel, Object request) throws RemotingException { return ((Replier) replierDispatcher).reply(channel, request); } + @Override public void connected(Channel channel) { handlerDispatcher.connected(channel); } + @Override public void disconnected(Channel channel) { handlerDispatcher.disconnected(channel); } + @Override public void sent(Channel channel, Object message) { handlerDispatcher.sent(channel, message); } + @Override public void received(Channel channel, Object message) { handlerDispatcher.received(channel, message); } + @Override public void caught(Channel channel, Throwable exception) { handlerDispatcher.caught(channel, exception); } + @Override public String telnet(Channel channel, String message) throws RemotingException { return telnetHandler.telnet(channel, message); } diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/ExchangeServerDelegate.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/ExchangeServerDelegate.java index bcb1f9eed33..030b306066f 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/ExchangeServerDelegate.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/ExchangeServerDelegate.java @@ -48,63 +48,78 @@ public void setServer(ExchangeServer server) { this.server = server; } + @Override public boolean isBound() { return server.isBound(); } + @Override public void reset(URL url) { server.reset(url); } + @Override @Deprecated public void reset(com.alibaba.dubbo.common.Parameters parameters) { reset(getUrl().addParameters(parameters.getParameters())); } + @Override public Collection getChannels() { return server.getChannels(); } + @Override public Channel getChannel(InetSocketAddress remoteAddress) { return server.getChannel(remoteAddress); } + @Override public URL getUrl() { return server.getUrl(); } + @Override public ChannelHandler getChannelHandler() { return server.getChannelHandler(); } + @Override public InetSocketAddress getLocalAddress() { return server.getLocalAddress(); } + @Override public void send(Object message) throws RemotingException { server.send(message); } + @Override public void send(Object message, boolean sent) throws RemotingException { server.send(message, sent); } + @Override public void close() { server.close(); } + @Override public boolean isClosed() { return server.isClosed(); } + @Override public Collection getExchangeChannels() { return server.getExchangeChannels(); } + @Override public ExchangeChannel getExchangeChannel(InetSocketAddress remoteAddress) { return server.getExchangeChannel(remoteAddress); } + @Override public void close(int timeout) { server.close(timeout); } diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/MultiMessage.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/MultiMessage.java index dc68b7e04bf..afd41f49b10 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/MultiMessage.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/MultiMessage.java @@ -78,6 +78,7 @@ public Collection removeMessages() { return result; } + @Override public Iterator iterator() { return messages.iterator(); } diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/ReplierDispatcher.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/ReplierDispatcher.java index 9bea4ee665d..69da73016f6 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/ReplierDispatcher.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/ReplierDispatcher.java @@ -68,6 +68,7 @@ private Replier getReplier(Class type) { throw new IllegalStateException("Replier not found, Unsupported message object: " + type); } + @Override @SuppressWarnings({"unchecked", "rawtypes"}) public Object reply(ExchangeChannel channel, Object request) throws RemotingException { return ((Replier) getReplier(request.getClass())).reply(channel, request); diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/SimpleFuture.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/SimpleFuture.java index 555c56e34bf..6155be143d1 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/SimpleFuture.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/SimpleFuture.java @@ -31,18 +31,22 @@ public SimpleFuture(Object value) { this.value = value; } + @Override public Object get() throws RemotingException { return value; } + @Override public Object get(int timeoutInMillis) throws RemotingException { return value; } + @Override public void setCallback(ResponseCallback callback) { callback.done(value); } + @Override public boolean isDone() { return true; } diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/header/HeaderExchangeChannel.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/header/HeaderExchangeChannel.java index 9654cef0c4e..c8d37ec30dc 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/header/HeaderExchangeChannel.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/header/HeaderExchangeChannel.java @@ -72,10 +72,12 @@ static void removeChannelIfDisconnected(Channel ch) { } } + @Override public void send(Object message) throws RemotingException { send(message, getUrl().getParameter(Constants.SENT_KEY, false)); } + @Override public void send(Object message, boolean sent) throws RemotingException { if (closed) { throw new RemotingException(this.getLocalAddress(), null, "Failed to send message " + message + ", cause: The channel " + this + " is closed!"); @@ -93,10 +95,12 @@ public void send(Object message, boolean sent) throws RemotingException { } } + @Override public ResponseFuture request(Object request) throws RemotingException { return request(request, channel.getUrl().getPositiveParameter(Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT)); } + @Override public ResponseFuture request(Object request, int timeout) throws RemotingException { if (closed) { throw new RemotingException(this.getLocalAddress(), null, "Failed to send request " + request + ", cause: The channel " + this + " is closed!"); @@ -116,10 +120,12 @@ public ResponseFuture request(Object request, int timeout) throws RemotingExcept return future; } + @Override public boolean isClosed() { return closed; } + @Override public void close() { try { channel.close(); @@ -129,6 +135,7 @@ public void close() { } // graceful close + @Override public void close(int timeout) { if (closed) { return; @@ -153,42 +160,52 @@ public void startClose() { channel.startClose(); } + @Override public InetSocketAddress getLocalAddress() { return channel.getLocalAddress(); } + @Override public InetSocketAddress getRemoteAddress() { return channel.getRemoteAddress(); } + @Override public URL getUrl() { return channel.getUrl(); } + @Override public boolean isConnected() { return channel.isConnected(); } + @Override public ChannelHandler getChannelHandler() { return channel.getChannelHandler(); } + @Override public ExchangeHandler getExchangeHandler() { return (ExchangeHandler) channel.getChannelHandler(); } + @Override public Object getAttribute(String key) { return channel.getAttribute(key); } + @Override public void setAttribute(String key, Object value) { channel.setAttribute(key, value); } + @Override public void removeAttribute(String key) { channel.removeAttribute(key); } + @Override public boolean hasAttribute(String key) { return channel.hasAttribute(key); } diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/header/HeaderExchangeClient.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/header/HeaderExchangeClient.java index acb95d1fd06..99462d9aa1a 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/header/HeaderExchangeClient.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/header/HeaderExchangeClient.java @@ -70,55 +70,68 @@ public HeaderExchangeClient(Client client, boolean needHeartbeat) { } } + @Override public ResponseFuture request(Object request) throws RemotingException { return channel.request(request); } + @Override public URL getUrl() { return channel.getUrl(); } + @Override public InetSocketAddress getRemoteAddress() { return channel.getRemoteAddress(); } + @Override public ResponseFuture request(Object request, int timeout) throws RemotingException { return channel.request(request, timeout); } + @Override public ChannelHandler getChannelHandler() { return channel.getChannelHandler(); } + @Override public boolean isConnected() { return channel.isConnected(); } + @Override public InetSocketAddress getLocalAddress() { return channel.getLocalAddress(); } + @Override public ExchangeHandler getExchangeHandler() { return channel.getExchangeHandler(); } + @Override public void send(Object message) throws RemotingException { channel.send(message); } + @Override public void send(Object message, boolean sent) throws RemotingException { channel.send(message, sent); } + @Override public boolean isClosed() { return channel.isClosed(); } + @Override public void close() { doClose(); channel.close(); } + @Override public void close(int timeout) { // Mark the client into the closure process startClose(); @@ -131,31 +144,38 @@ public void startClose() { channel.startClose(); } + @Override public void reset(URL url) { client.reset(url); } + @Override @Deprecated public void reset(com.alibaba.dubbo.common.Parameters parameters) { reset(getUrl().addParameters(parameters.getParameters())); } + @Override public void reconnect() throws RemotingException { client.reconnect(); } + @Override public Object getAttribute(String key) { return channel.getAttribute(key); } + @Override public void setAttribute(String key, Object value) { channel.setAttribute(key, value); } + @Override public void removeAttribute(String key) { channel.removeAttribute(key); } + @Override public boolean hasAttribute(String key) { return channel.hasAttribute(key); } @@ -165,6 +185,7 @@ private void startHeatbeatTimer() { if (heartbeat > 0) { heartbeatTimer = scheduled.scheduleWithFixedDelay( new HeartBeatTask(new HeartBeatTask.ChannelProvider() { + @Override public Collection getChannels() { return Collections.singletonList(HeaderExchangeClient.this); } diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/header/HeaderExchangeHandler.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/header/HeaderExchangeHandler.java index dedd61c787e..71dbf071436 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/header/HeaderExchangeHandler.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/header/HeaderExchangeHandler.java @@ -103,6 +103,7 @@ Response handleRequest(ExchangeChannel channel, Request req) throws RemotingExce return res; } + @Override public void connected(Channel channel) throws RemotingException { channel.setAttribute(KEY_READ_TIMESTAMP, System.currentTimeMillis()); channel.setAttribute(KEY_WRITE_TIMESTAMP, System.currentTimeMillis()); @@ -114,6 +115,7 @@ public void connected(Channel channel) throws RemotingException { } } + @Override public void disconnected(Channel channel) throws RemotingException { channel.setAttribute(KEY_READ_TIMESTAMP, System.currentTimeMillis()); channel.setAttribute(KEY_WRITE_TIMESTAMP, System.currentTimeMillis()); @@ -125,6 +127,7 @@ public void disconnected(Channel channel) throws RemotingException { } } + @Override public void sent(Channel channel, Object message) throws RemotingException { Throwable exception = null; try { @@ -154,6 +157,7 @@ public void sent(Channel channel, Object message) throws RemotingException { } } + @Override public void received(Channel channel, Object message) throws RemotingException { channel.setAttribute(KEY_READ_TIMESTAMP, System.currentTimeMillis()); ExchangeChannel exchangeChannel = HeaderExchangeChannel.getOrAddChannel(channel); @@ -191,6 +195,7 @@ public void received(Channel channel, Object message) throws RemotingException { } } + @Override public void caught(Channel channel, Throwable exception) throws RemotingException { if (exception instanceof ExecutionException) { ExecutionException e = (ExecutionException) exception; @@ -214,6 +219,7 @@ public void caught(Channel channel, Throwable exception) throws RemotingExceptio } } + @Override public ChannelHandler getHandler() { if (handler instanceof ChannelHandlerDelegate) { return ((ChannelHandlerDelegate) handler).getHandler(); diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/header/HeaderExchangeServer.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/header/HeaderExchangeServer.java index 6d77a1822af..48c6a7a9eb4 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/header/HeaderExchangeServer.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/header/HeaderExchangeServer.java @@ -77,6 +77,7 @@ public Server getServer() { return server; } + @Override public boolean isClosed() { return server.isClosed(); } @@ -91,11 +92,13 @@ private boolean isRunning() { return false; } + @Override public void close() { doClose(); server.close(); } + @Override public void close(final int timeout) { startClose(); if (timeout > 0) { @@ -151,6 +154,7 @@ private void doClose() { } } + @Override public Collection getExchangeChannels() { Collection exchangeChannels = new ArrayList(); Collection channels = server.getChannels(); @@ -162,36 +166,44 @@ public Collection getExchangeChannels() { return exchangeChannels; } + @Override public ExchangeChannel getExchangeChannel(InetSocketAddress remoteAddress) { Channel channel = server.getChannel(remoteAddress); return HeaderExchangeChannel.getOrAddChannel(channel); } + @Override @SuppressWarnings({"unchecked", "rawtypes"}) public Collection getChannels() { return (Collection) getExchangeChannels(); } + @Override public Channel getChannel(InetSocketAddress remoteAddress) { return getExchangeChannel(remoteAddress); } + @Override public boolean isBound() { return server.isBound(); } + @Override public InetSocketAddress getLocalAddress() { return server.getLocalAddress(); } + @Override public URL getUrl() { return server.getUrl(); } + @Override public ChannelHandler getChannelHandler() { return server.getChannelHandler(); } + @Override public void reset(URL url) { server.reset(url); try { @@ -213,11 +225,13 @@ public void reset(URL url) { } } + @Override @Deprecated public void reset(com.alibaba.dubbo.common.Parameters parameters) { reset(getUrl().addParameters(parameters.getParameters())); } + @Override public void send(Object message) throws RemotingException { if (closed.get()) { throw new RemotingException(this.getLocalAddress(), null, "Failed to send message " + message + ", cause: The server " + getLocalAddress() + " is closed!"); @@ -225,6 +239,7 @@ public void send(Object message) throws RemotingException { server.send(message); } + @Override public void send(Object message, boolean sent) throws RemotingException { if (closed.get()) { throw new RemotingException(this.getLocalAddress(), null, "Failed to send message " + message + ", cause: The server " + getLocalAddress() + " is closed!"); @@ -237,6 +252,7 @@ private void startHeatbeatTimer() { if (heartbeat > 0) { heatbeatTimer = scheduled.scheduleWithFixedDelay( new HeartBeatTask(new HeartBeatTask.ChannelProvider() { + @Override public Collection getChannels() { return Collections.unmodifiableCollection( HeaderExchangeServer.this.getChannels()); diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/header/HeaderExchanger.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/header/HeaderExchanger.java index 1c55ebe5e0c..4d0dfd38ba1 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/header/HeaderExchanger.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/header/HeaderExchanger.java @@ -34,10 +34,12 @@ public class HeaderExchanger implements Exchanger { public static final String NAME = "header"; + @Override public ExchangeClient connect(URL url, ExchangeHandler handler) throws RemotingException { return new HeaderExchangeClient(Transporters.connect(url, new DecodeHandler(new HeaderExchangeHandler(handler))), true); } + @Override public ExchangeServer bind(URL url, ExchangeHandler handler) throws RemotingException { return new HeaderExchangeServer(Transporters.bind(url, new DecodeHandler(new HeaderExchangeHandler(handler)))); } diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/header/HeartBeatTask.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/header/HeartBeatTask.java index 2d417b2e74d..ce529b9882c 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/header/HeartBeatTask.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/header/HeartBeatTask.java @@ -41,6 +41,7 @@ final class HeartBeatTask implements Runnable { this.heartbeatTimeout = heartbeatTimeout; } + @Override public void run() { try { long now = System.currentTimeMillis(); diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/header/HeartbeatHandler.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/header/HeartbeatHandler.java index ae88f8c3865..f2080ca0205 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/header/HeartbeatHandler.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/support/header/HeartbeatHandler.java @@ -39,23 +39,27 @@ public HeartbeatHandler(ChannelHandler handler) { super(handler); } + @Override public void connected(Channel channel) throws RemotingException { setReadTimestamp(channel); setWriteTimestamp(channel); handler.connected(channel); } + @Override public void disconnected(Channel channel) throws RemotingException { clearReadTimestamp(channel); clearWriteTimestamp(channel); handler.disconnected(channel); } + @Override public void sent(Channel channel, Object message) throws RemotingException { setWriteTimestamp(channel); handler.sent(channel, message); } + @Override public void received(Channel channel, Object message) throws RemotingException { setReadTimestamp(channel); if (isHeartbeatRequest(message)) { diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/telnet/codec/TelnetCodec.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/telnet/codec/TelnetCodec.java index afdbc3bf631..10fa6130195 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/telnet/codec/TelnetCodec.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/telnet/codec/TelnetCodec.java @@ -136,6 +136,7 @@ private static boolean endsWith(byte[] message, byte[] command) throws IOExcepti return true; } + @Override public void encode(Channel channel, ChannelBuffer buffer, Object message) throws IOException { if (message instanceof String) { if (isClientSide(channel)) { @@ -148,6 +149,7 @@ public void encode(Channel channel, ChannelBuffer buffer, Object message) throws } } + @Override public Object decode(Channel channel, ChannelBuffer buffer) throws IOException { int readable = buffer.readableBytes(); byte[] message = new byte[readable]; diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/telnet/support/TelnetHandlerAdapter.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/telnet/support/TelnetHandlerAdapter.java index 2f08b8ef549..478ce0f54ab 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/telnet/support/TelnetHandlerAdapter.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/telnet/support/TelnetHandlerAdapter.java @@ -27,6 +27,7 @@ public class TelnetHandlerAdapter extends ChannelHandlerAdapter implements Telne private final ExtensionLoader extensionLoader = ExtensionLoader.getExtensionLoader(TelnetHandler.class); + @Override public String telnet(Channel channel, String message) throws RemotingException { String prompt = channel.getUrl().getParameterAndDecoded(Constants.PROMPT_KEY, Constants.DEFAULT_PROMPT); boolean noprompt = message.contains("--no-prompt"); diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/telnet/support/command/ClearTelnetHandler.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/telnet/support/command/ClearTelnetHandler.java index 1ab7499ac21..c463e05928e 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/telnet/support/command/ClearTelnetHandler.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/telnet/support/command/ClearTelnetHandler.java @@ -29,6 +29,7 @@ @Help(parameter = "[lines]", summary = "Clear screen.", detail = "Clear screen.") public class ClearTelnetHandler implements TelnetHandler { + @Override public String telnet(Channel channel, String message) { int lines = 100; if (message.length() > 0) { diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/telnet/support/command/ExitTelnetHandler.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/telnet/support/command/ExitTelnetHandler.java index 596475305c6..4f69e1d6391 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/telnet/support/command/ExitTelnetHandler.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/telnet/support/command/ExitTelnetHandler.java @@ -28,6 +28,7 @@ @Help(parameter = "", summary = "Exit the telnet.", detail = "Exit the telnet.") public class ExitTelnetHandler implements TelnetHandler { + @Override public String telnet(Channel channel, String message) { channel.close(); return null; diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/telnet/support/command/HelpTelnetHandler.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/telnet/support/command/HelpTelnetHandler.java index 15bd4d408b3..7372148a688 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/telnet/support/command/HelpTelnetHandler.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/telnet/support/command/HelpTelnetHandler.java @@ -35,6 +35,7 @@ public class HelpTelnetHandler implements TelnetHandler { private final ExtensionLoader extensionLoader = ExtensionLoader.getExtensionLoader(TelnetHandler.class); + @Override public String telnet(Channel channel, String message) { if (message.length() > 0) { if (!extensionLoader.hasExtension(message)) { diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/telnet/support/command/LogTelnetHandler.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/telnet/support/command/LogTelnetHandler.java index 499669961ab..16adcd177b7 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/telnet/support/command/LogTelnetHandler.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/telnet/support/command/LogTelnetHandler.java @@ -41,6 +41,7 @@ public class LogTelnetHandler implements TelnetHandler { public static final String SERVICE_KEY = "telnet.log"; + @Override public String telnet(Channel channel, String message) { long size = 0; File file = LoggerFactory.getFile(); diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/telnet/support/command/StatusTelnetHandler.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/telnet/support/command/StatusTelnetHandler.java index a78ae65c40c..df192d6dfe7 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/telnet/support/command/StatusTelnetHandler.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/telnet/support/command/StatusTelnetHandler.java @@ -41,6 +41,7 @@ public class StatusTelnetHandler implements TelnetHandler { private final ExtensionLoader extensionLoader = ExtensionLoader.getExtensionLoader(StatusChecker.class); + @Override public String telnet(Channel channel, String message) { if (message.equals("-l")) { List checkers = extensionLoader.getActivateExtension(channel.getUrl(), "status"); diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/AbstractChannel.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/AbstractChannel.java index fd22def3d34..5f00ac58e9e 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/AbstractChannel.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/AbstractChannel.java @@ -30,6 +30,7 @@ public AbstractChannel(URL url, ChannelHandler handler) { super(url, handler); } + @Override public void send(Object message, boolean sent) throws RemotingException { if (isClosed()) { throw new RemotingException(this, "Failed to send message " diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/AbstractChannelHandlerDelegate.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/AbstractChannelHandlerDelegate.java index 8f28cbd8244..b2c660ccdca 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/AbstractChannelHandlerDelegate.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/AbstractChannelHandlerDelegate.java @@ -30,6 +30,7 @@ protected AbstractChannelHandlerDelegate(ChannelHandler handler) { this.handler = handler; } + @Override public ChannelHandler getHandler() { if (handler instanceof ChannelHandlerDelegate) { return ((ChannelHandlerDelegate) handler).getHandler(); @@ -37,22 +38,27 @@ public ChannelHandler getHandler() { return handler; } + @Override public void connected(Channel channel) throws RemotingException { handler.connected(channel); } + @Override public void disconnected(Channel channel) throws RemotingException { handler.disconnected(channel); } + @Override public void sent(Channel channel, Object message) throws RemotingException { handler.sent(channel, message); } + @Override public void received(Channel channel, Object message) throws RemotingException { handler.received(channel, message); } + @Override public void caught(Channel channel, Throwable exception) throws RemotingException { handler.caught(channel, exception); } diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/AbstractClient.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/AbstractClient.java index 44f822fd649..67222981a64 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/AbstractClient.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/AbstractClient.java @@ -149,6 +149,7 @@ private synchronized void initConnectStatusCheckCommand() { int reconnect = getReconnectParam(getUrl()); if (reconnect > 0 && (reconnectExecutorFuture == null || reconnectExecutorFuture.isCancelled())) { Runnable connectStatusCheckCommand = new Runnable() { + @Override public void run() { try { if (!isConnected()) { @@ -195,6 +196,7 @@ public InetSocketAddress getConnectAddress() { return new InetSocketAddress(NetUtils.filterLocalHost(getUrl().getHost()), getUrl().getPort()); } + @Override public InetSocketAddress getRemoteAddress() { Channel channel = getChannel(); if (channel == null) @@ -202,6 +204,7 @@ public InetSocketAddress getRemoteAddress() { return channel.getRemoteAddress(); } + @Override public InetSocketAddress getLocalAddress() { Channel channel = getChannel(); if (channel == null) @@ -209,6 +212,7 @@ public InetSocketAddress getLocalAddress() { return channel.getLocalAddress(); } + @Override public boolean isConnected() { Channel channel = getChannel(); if (channel == null) @@ -216,6 +220,7 @@ public boolean isConnected() { return channel.isConnected(); } + @Override public Object getAttribute(String key) { Channel channel = getChannel(); if (channel == null) @@ -223,6 +228,7 @@ public Object getAttribute(String key) { return channel.getAttribute(key); } + @Override public void setAttribute(String key, Object value) { Channel channel = getChannel(); if (channel == null) @@ -230,6 +236,7 @@ public void setAttribute(String key, Object value) { channel.setAttribute(key, value); } + @Override public void removeAttribute(String key) { Channel channel = getChannel(); if (channel == null) @@ -237,6 +244,7 @@ public void removeAttribute(String key) { channel.removeAttribute(key); } + @Override public boolean hasAttribute(String key) { Channel channel = getChannel(); if (channel == null) @@ -244,6 +252,7 @@ public boolean hasAttribute(String key) { return channel.hasAttribute(key); } + @Override public void send(Object message, boolean sent) throws RemotingException { if (send_reconnect && !isConnected()) { connect(); @@ -310,11 +319,13 @@ public void disconnect() { } } + @Override public void reconnect() throws RemotingException { disconnect(); connect(); } + @Override public void close() { try { if (executor != null) { @@ -340,6 +351,7 @@ public void close() { } } + @Override public void close(int timeout) { ExecutorUtil.gracefulShutdown(executor, timeout); close(); diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/AbstractEndpoint.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/AbstractEndpoint.java index e8ccfe4f37d..76b3e5de415 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/AbstractEndpoint.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/AbstractEndpoint.java @@ -57,6 +57,7 @@ protected static Codec2 getChannelCodec(URL url) { } } + @Override public void reset(URL url) { if (isClosed()) { throw new IllegalStateException("Failed to reset parameters " diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/AbstractPeer.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/AbstractPeer.java index a44c2c9f960..15fe08191fc 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/AbstractPeer.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/AbstractPeer.java @@ -48,18 +48,22 @@ public AbstractPeer(URL url, ChannelHandler handler) { this.handler = handler; } + @Override public void send(Object message) throws RemotingException { send(message, url.getParameter(Constants.SENT_KEY, false)); } + @Override public void close() { closed = true; } + @Override public void close(int timeout) { close(); } + @Override public void startClose() { if (isClosed()) { return; @@ -67,6 +71,7 @@ public void startClose() { closing = true; } + @Override public URL getUrl() { return url; } @@ -78,6 +83,7 @@ protected void setUrl(URL url) { this.url = url; } + @Override public ChannelHandler getChannelHandler() { if (handler instanceof ChannelHandlerDelegate) { return ((ChannelHandlerDelegate) handler).getHandler(); @@ -103,6 +109,7 @@ public ChannelHandler getDelegateHandler() { return handler; } + @Override public boolean isClosed() { return closed; } @@ -111,6 +118,7 @@ public boolean isClosing() { return closing && !closed; } + @Override public void connected(Channel ch) throws RemotingException { if (closed) { return; @@ -118,10 +126,12 @@ public void connected(Channel ch) throws RemotingException { handler.connected(ch); } + @Override public void disconnected(Channel ch) throws RemotingException { handler.disconnected(ch); } + @Override public void sent(Channel ch, Object msg) throws RemotingException { if (closed) { return; @@ -129,6 +139,7 @@ public void sent(Channel ch, Object msg) throws RemotingException { handler.sent(ch, msg); } + @Override public void received(Channel ch, Object msg) throws RemotingException { if (closed) { return; @@ -136,6 +147,7 @@ public void received(Channel ch, Object msg) throws RemotingException { handler.received(ch, msg); } + @Override public void caught(Channel ch, Throwable ex) throws RemotingException { handler.caught(ch, ex); } diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/AbstractServer.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/AbstractServer.java index d0b4842dc80..40b99097fee 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/AbstractServer.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/AbstractServer.java @@ -77,6 +77,7 @@ public AbstractServer(URL url, ChannelHandler handler) throws RemotingException protected abstract void doClose() throws Throwable; + @Override public void reset(URL url) { if (url == null) { return; @@ -128,6 +129,7 @@ public void reset(URL url) { super.setUrl(getUrl().addParameters(url.getParameters())); } + @Override public void send(Object message, boolean sent) throws RemotingException { Collection channels = getChannels(); for (Channel channel : channels) { @@ -137,6 +139,7 @@ public void send(Object message, boolean sent) throws RemotingException { } } + @Override public void close() { if (logger.isInfoEnabled()) { logger.info("Close " + getClass().getSimpleName() + " bind " + getBindAddress() + ", export " + getLocalAddress()); @@ -154,11 +157,13 @@ public void close() { } } + @Override public void close(int timeout) { ExecutorUtil.gracefulShutdown(executor, timeout); close(); } + @Override public InetSocketAddress getLocalAddress() { return localAddress; } diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/ChannelDelegate.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/ChannelDelegate.java index df69efb0d17..cede12e229e 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/ChannelDelegate.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/ChannelDelegate.java @@ -48,54 +48,67 @@ public void setChannel(Channel channel) { this.channel = channel; } + @Override public URL getUrl() { return channel.getUrl(); } + @Override public InetSocketAddress getRemoteAddress() { return channel.getRemoteAddress(); } + @Override public ChannelHandler getChannelHandler() { return channel.getChannelHandler(); } + @Override public boolean isConnected() { return channel.isConnected(); } + @Override public InetSocketAddress getLocalAddress() { return channel.getLocalAddress(); } + @Override public boolean hasAttribute(String key) { return channel.hasAttribute(key); } + @Override public void send(Object message) throws RemotingException { channel.send(message); } + @Override public Object getAttribute(String key) { return channel.getAttribute(key); } + @Override public void setAttribute(String key, Object value) { channel.setAttribute(key, value); } + @Override public void send(Object message, boolean sent) throws RemotingException { channel.send(message, sent); } + @Override public void removeAttribute(String key) { channel.removeAttribute(key); } + @Override public void close() { channel.close(); } + @Override public void close(int timeout) { channel.close(timeout); } @@ -105,6 +118,7 @@ public void startClose() { channel.startClose(); } + @Override public boolean isClosed() { return channel.isClosed(); } diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/ChannelHandlerAdapter.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/ChannelHandlerAdapter.java index 08f710f5eb6..075653c0152 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/ChannelHandlerAdapter.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/ChannelHandlerAdapter.java @@ -25,18 +25,23 @@ */ public class ChannelHandlerAdapter implements ChannelHandler { + @Override public void connected(Channel channel) throws RemotingException { } + @Override public void disconnected(Channel channel) throws RemotingException { } + @Override public void sent(Channel channel, Object message) throws RemotingException { } + @Override public void received(Channel channel, Object message) throws RemotingException { } + @Override public void caught(Channel channel, Throwable exception) throws RemotingException { } diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/ChannelHandlerDispatcher.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/ChannelHandlerDispatcher.java index 6a2d9817c99..c42d0510de1 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/ChannelHandlerDispatcher.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/ChannelHandlerDispatcher.java @@ -61,6 +61,7 @@ public ChannelHandlerDispatcher removeChannelHandler(ChannelHandler handler) { return this; } + @Override public void connected(Channel channel) { for (ChannelHandler listener : channelHandlers) { try { @@ -71,6 +72,7 @@ public void connected(Channel channel) { } } + @Override public void disconnected(Channel channel) { for (ChannelHandler listener : channelHandlers) { try { @@ -81,6 +83,7 @@ public void disconnected(Channel channel) { } } + @Override public void sent(Channel channel, Object message) { for (ChannelHandler listener : channelHandlers) { try { @@ -91,6 +94,7 @@ public void sent(Channel channel, Object message) { } } + @Override public void received(Channel channel, Object message) { for (ChannelHandler listener : channelHandlers) { try { @@ -101,6 +105,7 @@ public void received(Channel channel, Object message) { } } + @Override public void caught(Channel channel, Throwable exception) { for (ChannelHandler listener : channelHandlers) { try { diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/ClientDelegate.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/ClientDelegate.java index b49af09b400..9d6b41ca4ba 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/ClientDelegate.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/ClientDelegate.java @@ -48,67 +48,83 @@ public void setClient(Client client) { this.client = client; } + @Override public void reset(URL url) { client.reset(url); } + @Override @Deprecated public void reset(com.alibaba.dubbo.common.Parameters parameters) { reset(getUrl().addParameters(parameters.getParameters())); } + @Override public URL getUrl() { return client.getUrl(); } + @Override public InetSocketAddress getRemoteAddress() { return client.getRemoteAddress(); } + @Override public void reconnect() throws RemotingException { client.reconnect(); } + @Override public ChannelHandler getChannelHandler() { return client.getChannelHandler(); } + @Override public boolean isConnected() { return client.isConnected(); } + @Override public InetSocketAddress getLocalAddress() { return client.getLocalAddress(); } + @Override public boolean hasAttribute(String key) { return client.hasAttribute(key); } + @Override public void send(Object message) throws RemotingException { client.send(message); } + @Override public Object getAttribute(String key) { return client.getAttribute(key); } + @Override public void setAttribute(String key, Object value) { client.setAttribute(key, value); } + @Override public void send(Object message, boolean sent) throws RemotingException { client.send(message, sent); } + @Override public void removeAttribute(String key) { client.removeAttribute(key); } + @Override public void close() { client.close(); } + @Override public void close(int timeout) { client.close(timeout); } @@ -118,6 +134,7 @@ public void startClose() { client.startClose(); } + @Override public boolean isClosed() { return client.isClosed(); } diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/DecodeHandler.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/DecodeHandler.java index fb46f0a70af..db5b6f57b2f 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/DecodeHandler.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/DecodeHandler.java @@ -34,6 +34,7 @@ public DecodeHandler(ChannelHandler handler) { super(handler); } + @Override public void received(Channel channel, Object message) throws RemotingException { if (message instanceof Decodeable) { decode(message); diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/ServerDelegate.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/ServerDelegate.java index 5be3b6d60b2..b604058dabb 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/ServerDelegate.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/ServerDelegate.java @@ -49,51 +49,63 @@ public void setServer(Server server) { this.server = server; } + @Override public boolean isBound() { return server.isBound(); } + @Override public void reset(URL url) { server.reset(url); } + @Override @Deprecated public void reset(com.alibaba.dubbo.common.Parameters parameters) { reset(getUrl().addParameters(parameters.getParameters())); } + @Override public Collection getChannels() { return server.getChannels(); } + @Override public Channel getChannel(InetSocketAddress remoteAddress) { return server.getChannel(remoteAddress); } + @Override public URL getUrl() { return server.getUrl(); } + @Override public ChannelHandler getChannelHandler() { return server.getChannelHandler(); } + @Override public InetSocketAddress getLocalAddress() { return server.getLocalAddress(); } + @Override public void send(Object message) throws RemotingException { server.send(message); } + @Override public void send(Object message, boolean sent) throws RemotingException { server.send(message, sent); } + @Override public void close() { server.close(); } + @Override public void close(int timeout) { server.close(timeout); } @@ -103,6 +115,7 @@ public void startClose() { server.startClose(); } + @Override public boolean isClosed() { return server.isClosed(); } diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/codec/CodecAdapter.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/codec/CodecAdapter.java index 0466fffad8e..dfc945ed0bd 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/codec/CodecAdapter.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/codec/CodecAdapter.java @@ -36,6 +36,7 @@ public CodecAdapter(Codec codec) { this.codec = codec; } + @Override public void encode(Channel channel, ChannelBuffer buffer, Object message) throws IOException { UnsafeByteArrayOutputStream os = new UnsafeByteArrayOutputStream(1024); @@ -43,6 +44,7 @@ public void encode(Channel channel, ChannelBuffer buffer, Object message) buffer.writeBytes(os.toByteArray()); } + @Override public Object decode(Channel channel, ChannelBuffer buffer) throws IOException { byte[] bytes = new byte[buffer.readableBytes()]; int savedReaderIndex = buffer.readerIndex(); diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/codec/TransportCodec.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/codec/TransportCodec.java index 71368754a31..00c1106d5eb 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/codec/TransportCodec.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/codec/TransportCodec.java @@ -35,6 +35,7 @@ */ public class TransportCodec extends AbstractCodec { + @Override public void encode(Channel channel, ChannelBuffer buffer, Object message) throws IOException { OutputStream output = new ChannelBufferOutputStream(buffer); ObjectOutput objectOutput = getSerialization(channel).serialize(channel.getUrl(), output); @@ -45,6 +46,7 @@ public void encode(Channel channel, ChannelBuffer buffer, Object message) throws } } + @Override public Object decode(Channel channel, ChannelBuffer buffer) throws IOException { InputStream input = new ChannelBufferInputStream(buffer); ObjectInput objectInput = getSerialization(channel).deserialize(channel.getUrl(), input); diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/ChannelEventRunnable.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/ChannelEventRunnable.java index 0c5e8765978..038adea56cf 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/ChannelEventRunnable.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/ChannelEventRunnable.java @@ -50,6 +50,7 @@ public ChannelEventRunnable(Channel channel, ChannelHandler handler, ChannelStat this.exception = exception; } + @Override public void run() { switch (state) { case CONNECTED: diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/WrappedChannelHandler.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/WrappedChannelHandler.java index e9975c8d3ff..f618dd9042c 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/WrappedChannelHandler.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/WrappedChannelHandler.java @@ -67,22 +67,27 @@ public void close() { } } + @Override public void connected(Channel channel) throws RemotingException { handler.connected(channel); } + @Override public void disconnected(Channel channel) throws RemotingException { handler.disconnected(channel); } + @Override public void sent(Channel channel, Object message) throws RemotingException { handler.sent(channel, message); } + @Override public void received(Channel channel, Object message) throws RemotingException { handler.received(channel, message); } + @Override public void caught(Channel channel, Throwable exception) throws RemotingException { handler.caught(channel, exception); } @@ -91,6 +96,7 @@ public ExecutorService getExecutor() { return executor; } + @Override public ChannelHandler getHandler() { if (handler instanceof ChannelHandlerDelegate) { return ((ChannelHandlerDelegate) handler).getHandler(); diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/all/AllChannelHandler.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/all/AllChannelHandler.java index 1dade1abfc0..66768352af6 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/all/AllChannelHandler.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/all/AllChannelHandler.java @@ -36,6 +36,7 @@ public AllChannelHandler(ChannelHandler handler, URL url) { super(handler, url); } + @Override public void connected(Channel channel) throws RemotingException { ExecutorService cexecutor = getExecutorService(); try { @@ -45,6 +46,7 @@ public void connected(Channel channel) throws RemotingException { } } + @Override public void disconnected(Channel channel) throws RemotingException { ExecutorService cexecutor = getExecutorService(); try { @@ -54,6 +56,7 @@ public void disconnected(Channel channel) throws RemotingException { } } + @Override public void received(Channel channel, Object message) throws RemotingException { ExecutorService cexecutor = getExecutorService(); try { @@ -76,6 +79,7 @@ public void received(Channel channel, Object message) throws RemotingException { } } + @Override public void caught(Channel channel, Throwable exception) throws RemotingException { ExecutorService cexecutor = getExecutorService(); try { diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/all/AllDispatcher.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/all/AllDispatcher.java index 823c50479a0..27a3394e15f 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/all/AllDispatcher.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/all/AllDispatcher.java @@ -27,6 +27,7 @@ public class AllDispatcher implements Dispatcher { public static final String NAME = "all"; + @Override public ChannelHandler dispatch(ChannelHandler handler, URL url) { return new AllChannelHandler(handler, url); } diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/connection/ConnectionOrderedChannelHandler.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/connection/ConnectionOrderedChannelHandler.java index ed7681182f9..ffd05520a91 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/connection/ConnectionOrderedChannelHandler.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/connection/ConnectionOrderedChannelHandler.java @@ -53,6 +53,7 @@ public ConnectionOrderedChannelHandler(ChannelHandler handler, URL url) { queuewarninglimit = url.getParameter(Constants.CONNECT_QUEUE_WARNING_SIZE, Constants.DEFAULT_CONNECT_QUEUE_WARNING_SIZE); } + @Override public void connected(Channel channel) throws RemotingException { try { checkQueueLength(); @@ -62,6 +63,7 @@ public void connected(Channel channel) throws RemotingException { } } + @Override public void disconnected(Channel channel) throws RemotingException { try { checkQueueLength(); @@ -71,6 +73,7 @@ public void disconnected(Channel channel) throws RemotingException { } } + @Override public void received(Channel channel, Object message) throws RemotingException { ExecutorService cexecutor = executor; if (cexecutor == null || cexecutor.isShutdown()) { @@ -95,6 +98,7 @@ public void received(Channel channel, Object message) throws RemotingException { } } + @Override public void caught(Channel channel, Throwable exception) throws RemotingException { ExecutorService cexecutor = executor; if (cexecutor == null || cexecutor.isShutdown()) { diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/connection/ConnectionOrderedDispatcher.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/connection/ConnectionOrderedDispatcher.java index 1209ccd36f1..fa79fcd1570 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/connection/ConnectionOrderedDispatcher.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/connection/ConnectionOrderedDispatcher.java @@ -27,6 +27,7 @@ public class ConnectionOrderedDispatcher implements Dispatcher { public static final String NAME = "connection"; + @Override public ChannelHandler dispatch(ChannelHandler handler, URL url) { return new ConnectionOrderedChannelHandler(handler, url); } diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/direct/DirectDispatcher.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/direct/DirectDispatcher.java index bd192717208..c2ec5a715ba 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/direct/DirectDispatcher.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/direct/DirectDispatcher.java @@ -27,6 +27,7 @@ public class DirectDispatcher implements Dispatcher { public static final String NAME = "direct"; + @Override public ChannelHandler dispatch(ChannelHandler handler, URL url) { return handler; } diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/execution/ExecutionChannelHandler.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/execution/ExecutionChannelHandler.java index fd1261cde26..3926fffb268 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/execution/ExecutionChannelHandler.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/execution/ExecutionChannelHandler.java @@ -35,14 +35,17 @@ public ExecutionChannelHandler(ChannelHandler handler, URL url) { super(handler, url); } + @Override public void connected(Channel channel) throws RemotingException { executor.execute(new ChannelEventRunnable(channel, handler, ChannelState.CONNECTED)); } + @Override public void disconnected(Channel channel) throws RemotingException { executor.execute(new ChannelEventRunnable(channel, handler, ChannelState.DISCONNECTED)); } + @Override public void received(Channel channel, Object message) throws RemotingException { try { executor.execute(new ChannelEventRunnable(channel, handler, ChannelState.RECEIVED, message)); @@ -65,6 +68,7 @@ public void received(Channel channel, Object message) throws RemotingException { } } + @Override public void caught(Channel channel, Throwable exception) throws RemotingException { executor.execute(new ChannelEventRunnable(channel, handler, ChannelState.CAUGHT, exception)); } diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/execution/ExecutionDispatcher.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/execution/ExecutionDispatcher.java index a62bee7b4fb..a3757f7b269 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/execution/ExecutionDispatcher.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/execution/ExecutionDispatcher.java @@ -27,6 +27,7 @@ public class ExecutionDispatcher implements Dispatcher { public static final String NAME = "execution"; + @Override public ChannelHandler dispatch(ChannelHandler handler, URL url) { return new ExecutionChannelHandler(handler, url); } diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/message/MessageOnlyChannelHandler.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/message/MessageOnlyChannelHandler.java index 457d763c0de..d8513e7287c 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/message/MessageOnlyChannelHandler.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/message/MessageOnlyChannelHandler.java @@ -33,6 +33,7 @@ public MessageOnlyChannelHandler(ChannelHandler handler, URL url) { super(handler, url); } + @Override public void received(Channel channel, Object message) throws RemotingException { ExecutorService cexecutor = executor; if (cexecutor == null || cexecutor.isShutdown()) { diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/message/MessageOnlyDispatcher.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/message/MessageOnlyDispatcher.java index 0435c9b5f5f..740d72a4537 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/message/MessageOnlyDispatcher.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/message/MessageOnlyDispatcher.java @@ -27,6 +27,7 @@ public class MessageOnlyDispatcher implements Dispatcher { public static final String NAME = "message"; + @Override public ChannelHandler dispatch(ChannelHandler handler, URL url) { return new MessageOnlyChannelHandler(handler, url); } diff --git a/dubbo-remoting/dubbo-remoting-grizzly/src/main/java/com/alibaba/dubbo/remoting/transport/grizzly/GrizzlyChannel.java b/dubbo-remoting/dubbo-remoting-grizzly/src/main/java/com/alibaba/dubbo/remoting/transport/grizzly/GrizzlyChannel.java index 3d9695d99c1..d43e7dab66d 100644 --- a/dubbo-remoting/dubbo-remoting-grizzly/src/main/java/com/alibaba/dubbo/remoting/transport/grizzly/GrizzlyChannel.java +++ b/dubbo-remoting/dubbo-remoting-grizzly/src/main/java/com/alibaba/dubbo/remoting/transport/grizzly/GrizzlyChannel.java @@ -81,18 +81,22 @@ static void removeChannelIfDisconnectd(Connection connection) { } } + @Override public InetSocketAddress getRemoteAddress() { return (InetSocketAddress) connection.getPeerAddress(); } + @Override public boolean isConnected() { return connection.isOpen(); } + @Override public InetSocketAddress getLocalAddress() { return (InetSocketAddress) connection.getLocalAddress(); } + @Override @SuppressWarnings("rawtypes") public void send(Object message, boolean sent) throws RemotingException { super.send(message, sent); @@ -112,6 +116,7 @@ public void send(Object message, boolean sent) throws RemotingException { } } + @Override public void close() { try { super.close(); @@ -133,18 +138,22 @@ public void close() { } } + @Override public boolean hasAttribute(String key) { return getAttribute(key) == null; } + @Override public Object getAttribute(String key) { return Grizzly.DEFAULT_ATTRIBUTE_BUILDER.createAttribute(key).get(connection); } + @Override public void setAttribute(String key, Object value) { Grizzly.DEFAULT_ATTRIBUTE_BUILDER.createAttribute(key).set(connection, value); } + @Override public void removeAttribute(String key) { Grizzly.DEFAULT_ATTRIBUTE_BUILDER.createAttribute(key).remove(connection); } diff --git a/dubbo-remoting/dubbo-remoting-grizzly/src/main/java/com/alibaba/dubbo/remoting/transport/grizzly/GrizzlyServer.java b/dubbo-remoting/dubbo-remoting-grizzly/src/main/java/com/alibaba/dubbo/remoting/transport/grizzly/GrizzlyServer.java index 0376ec3988d..0ec4fd967e2 100644 --- a/dubbo-remoting/dubbo-remoting-grizzly/src/main/java/com/alibaba/dubbo/remoting/transport/grizzly/GrizzlyServer.java +++ b/dubbo-remoting/dubbo-remoting-grizzly/src/main/java/com/alibaba/dubbo/remoting/transport/grizzly/GrizzlyServer.java @@ -93,14 +93,17 @@ protected void doClose() throws Throwable { } } + @Override public boolean isBound() { return !transport.isStopped(); } + @Override public Collection getChannels() { return channels.values(); } + @Override public Channel getChannel(InetSocketAddress remoteAddress) { return channels.get(NetUtils.toAddressString(remoteAddress)); } diff --git a/dubbo-remoting/dubbo-remoting-grizzly/src/main/java/com/alibaba/dubbo/remoting/transport/grizzly/GrizzlyTransporter.java b/dubbo-remoting/dubbo-remoting-grizzly/src/main/java/com/alibaba/dubbo/remoting/transport/grizzly/GrizzlyTransporter.java index fef6424638e..db8740d3d37 100644 --- a/dubbo-remoting/dubbo-remoting-grizzly/src/main/java/com/alibaba/dubbo/remoting/transport/grizzly/GrizzlyTransporter.java +++ b/dubbo-remoting/dubbo-remoting-grizzly/src/main/java/com/alibaba/dubbo/remoting/transport/grizzly/GrizzlyTransporter.java @@ -30,10 +30,12 @@ public class GrizzlyTransporter implements Transporter { public static final String NAME = "grizzly"; + @Override public Server bind(URL url, ChannelHandler listener) throws RemotingException { return new GrizzlyServer(url, listener); } + @Override public Client connect(URL url, ChannelHandler listener) throws RemotingException { return new GrizzlyClient(url, listener); } diff --git a/dubbo-remoting/dubbo-remoting-http/src/main/java/com/alibaba/dubbo/remoting/http/jetty/JettyHttpBinder.java b/dubbo-remoting/dubbo-remoting-http/src/main/java/com/alibaba/dubbo/remoting/http/jetty/JettyHttpBinder.java index b75eabd910f..e8e021e888f 100644 --- a/dubbo-remoting/dubbo-remoting-http/src/main/java/com/alibaba/dubbo/remoting/http/jetty/JettyHttpBinder.java +++ b/dubbo-remoting/dubbo-remoting-http/src/main/java/com/alibaba/dubbo/remoting/http/jetty/JettyHttpBinder.java @@ -26,6 +26,7 @@ */ public class JettyHttpBinder implements HttpBinder { + @Override public HttpServer bind(URL url, HttpHandler handler) { return new JettyHttpServer(url, handler); } diff --git a/dubbo-remoting/dubbo-remoting-http/src/main/java/com/alibaba/dubbo/remoting/http/jetty/JettyHttpServer.java b/dubbo-remoting/dubbo-remoting-http/src/main/java/com/alibaba/dubbo/remoting/http/jetty/JettyHttpServer.java index ed137f15ca2..0ea93e37ece 100644 --- a/dubbo-remoting/dubbo-remoting-http/src/main/java/com/alibaba/dubbo/remoting/http/jetty/JettyHttpServer.java +++ b/dubbo-remoting/dubbo-remoting-http/src/main/java/com/alibaba/dubbo/remoting/http/jetty/JettyHttpServer.java @@ -90,6 +90,7 @@ public JettyHttpServer(URL url, final HttpHandler handler) { } } + @Override public void close() { super.close(); diff --git a/dubbo-remoting/dubbo-remoting-http/src/main/java/com/alibaba/dubbo/remoting/http/servlet/BootstrapListener.java b/dubbo-remoting/dubbo-remoting-http/src/main/java/com/alibaba/dubbo/remoting/http/servlet/BootstrapListener.java index 8407405e3dd..5a570702f0e 100644 --- a/dubbo-remoting/dubbo-remoting-http/src/main/java/com/alibaba/dubbo/remoting/http/servlet/BootstrapListener.java +++ b/dubbo-remoting/dubbo-remoting-http/src/main/java/com/alibaba/dubbo/remoting/http/servlet/BootstrapListener.java @@ -25,10 +25,12 @@ */ public class BootstrapListener implements ServletContextListener { + @Override public void contextInitialized(ServletContextEvent servletContextEvent) { ServletManager.getInstance().addServletContext(ServletManager.EXTERNAL_SERVER_PORT, servletContextEvent.getServletContext()); } + @Override public void contextDestroyed(ServletContextEvent servletContextEvent) { ServletManager.getInstance().removeServletContext(ServletManager.EXTERNAL_SERVER_PORT); } diff --git a/dubbo-remoting/dubbo-remoting-http/src/main/java/com/alibaba/dubbo/remoting/http/servlet/DispatcherServlet.java b/dubbo-remoting/dubbo-remoting-http/src/main/java/com/alibaba/dubbo/remoting/http/servlet/DispatcherServlet.java index 2f9425310c9..af5620d5ebf 100644 --- a/dubbo-remoting/dubbo-remoting-http/src/main/java/com/alibaba/dubbo/remoting/http/servlet/DispatcherServlet.java +++ b/dubbo-remoting/dubbo-remoting-http/src/main/java/com/alibaba/dubbo/remoting/http/servlet/DispatcherServlet.java @@ -51,6 +51,7 @@ public static DispatcherServlet getInstance() { return INSTANCE; } + @Override protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpHandler handler = handlers.get(request.getLocalPort()); diff --git a/dubbo-remoting/dubbo-remoting-http/src/main/java/com/alibaba/dubbo/remoting/http/servlet/ServletHttpBinder.java b/dubbo-remoting/dubbo-remoting-http/src/main/java/com/alibaba/dubbo/remoting/http/servlet/ServletHttpBinder.java index 09589bc8391..0a93ad832e1 100644 --- a/dubbo-remoting/dubbo-remoting-http/src/main/java/com/alibaba/dubbo/remoting/http/servlet/ServletHttpBinder.java +++ b/dubbo-remoting/dubbo-remoting-http/src/main/java/com/alibaba/dubbo/remoting/http/servlet/ServletHttpBinder.java @@ -27,6 +27,7 @@ */ public class ServletHttpBinder implements HttpBinder { + @Override @Adaptive() public HttpServer bind(URL url, HttpHandler handler) { return new ServletHttpServer(url, handler); diff --git a/dubbo-remoting/dubbo-remoting-http/src/main/java/com/alibaba/dubbo/remoting/http/support/AbstractHttpServer.java b/dubbo-remoting/dubbo-remoting-http/src/main/java/com/alibaba/dubbo/remoting/http/support/AbstractHttpServer.java index fec16a5e187..bb19028703c 100644 --- a/dubbo-remoting/dubbo-remoting-http/src/main/java/com/alibaba/dubbo/remoting/http/support/AbstractHttpServer.java +++ b/dubbo-remoting/dubbo-remoting-http/src/main/java/com/alibaba/dubbo/remoting/http/support/AbstractHttpServer.java @@ -44,33 +44,41 @@ public AbstractHttpServer(URL url, HttpHandler handler) { this.handler = handler; } + @Override public HttpHandler getHttpHandler() { return handler; } + @Override public URL getUrl() { return url; } + @Override public void reset(URL url) { } + @Override public boolean isBound() { return true; } + @Override public InetSocketAddress getLocalAddress() { return url.toInetSocketAddress(); } + @Override public void close() { closed = true; } + @Override public void close(int timeout) { close(); } + @Override public boolean isClosed() { return closed; } diff --git a/dubbo-remoting/dubbo-remoting-http/src/main/java/com/alibaba/dubbo/remoting/http/tomcat/TomcatHttpBinder.java b/dubbo-remoting/dubbo-remoting-http/src/main/java/com/alibaba/dubbo/remoting/http/tomcat/TomcatHttpBinder.java index 8ff017e029d..9bcf7aeae6f 100755 --- a/dubbo-remoting/dubbo-remoting-http/src/main/java/com/alibaba/dubbo/remoting/http/tomcat/TomcatHttpBinder.java +++ b/dubbo-remoting/dubbo-remoting-http/src/main/java/com/alibaba/dubbo/remoting/http/tomcat/TomcatHttpBinder.java @@ -23,6 +23,7 @@ public class TomcatHttpBinder implements HttpBinder { + @Override public HttpServer bind(URL url, HttpHandler handler) { return new TomcatHttpServer(url, handler); } diff --git a/dubbo-remoting/dubbo-remoting-http/src/main/java/com/alibaba/dubbo/remoting/http/tomcat/TomcatHttpServer.java b/dubbo-remoting/dubbo-remoting-http/src/main/java/com/alibaba/dubbo/remoting/http/tomcat/TomcatHttpServer.java index 7ed61f90460..29780b181bf 100755 --- a/dubbo-remoting/dubbo-remoting-http/src/main/java/com/alibaba/dubbo/remoting/http/tomcat/TomcatHttpServer.java +++ b/dubbo-remoting/dubbo-remoting-http/src/main/java/com/alibaba/dubbo/remoting/http/tomcat/TomcatHttpServer.java @@ -74,6 +74,7 @@ public TomcatHttpServer(URL url, final HttpHandler handler) { } } + @Override public void close() { super.close(); diff --git a/dubbo-remoting/dubbo-remoting-mina/src/main/java/com/alibaba/dubbo/remoting/transport/mina/MinaChannel.java b/dubbo-remoting/dubbo-remoting-mina/src/main/java/com/alibaba/dubbo/remoting/transport/mina/MinaChannel.java index 95790fed450..63d5eda07f1 100644 --- a/dubbo-remoting/dubbo-remoting-mina/src/main/java/com/alibaba/dubbo/remoting/transport/mina/MinaChannel.java +++ b/dubbo-remoting/dubbo-remoting-mina/src/main/java/com/alibaba/dubbo/remoting/transport/mina/MinaChannel.java @@ -72,18 +72,22 @@ static void removeChannelIfDisconnectd(IoSession session) { } } + @Override public InetSocketAddress getLocalAddress() { return (InetSocketAddress) session.getLocalAddress(); } + @Override public InetSocketAddress getRemoteAddress() { return (InetSocketAddress) session.getRemoteAddress(); } + @Override public boolean isConnected() { return session.isConnected(); } + @Override public void send(Object message, boolean sent) throws RemotingException { super.send(message, sent); @@ -105,6 +109,7 @@ public void send(Object message, boolean sent) throws RemotingException { } } + @Override public void close() { try { super.close(); @@ -126,18 +131,22 @@ public void close() { } } + @Override public boolean hasAttribute(String key) { return session.containsAttribute(key); } + @Override public Object getAttribute(String key) { return session.getAttribute(key); } + @Override public void setAttribute(String key, Object value) { session.setAttribute(key, value); } + @Override public void removeAttribute(String key) { session.removeAttribute(key); } diff --git a/dubbo-remoting/dubbo-remoting-mina/src/main/java/com/alibaba/dubbo/remoting/transport/mina/MinaClient.java b/dubbo-remoting/dubbo-remoting-mina/src/main/java/com/alibaba/dubbo/remoting/transport/mina/MinaClient.java index 3aa2c8cd619..b0fbacf4b5f 100644 --- a/dubbo-remoting/dubbo-remoting-mina/src/main/java/com/alibaba/dubbo/remoting/transport/mina/MinaClient.java +++ b/dubbo-remoting/dubbo-remoting-mina/src/main/java/com/alibaba/dubbo/remoting/transport/mina/MinaClient.java @@ -93,6 +93,7 @@ protected void doConnect() throws Throwable { final AtomicReference exception = new AtomicReference(); final CountDownLatch finish = new CountDownLatch(1); // resolve future.awaitUninterruptibly() dead lock future.addListener(new IoFutureListener() { + @Override public void operationComplete(IoFuture future) { try { if (future.isReady()) { diff --git a/dubbo-remoting/dubbo-remoting-mina/src/main/java/com/alibaba/dubbo/remoting/transport/mina/MinaCodecAdapter.java b/dubbo-remoting/dubbo-remoting-mina/src/main/java/com/alibaba/dubbo/remoting/transport/mina/MinaCodecAdapter.java index 7d3dfd2a8bc..2ade05e4d5c 100644 --- a/dubbo-remoting/dubbo-remoting-mina/src/main/java/com/alibaba/dubbo/remoting/transport/mina/MinaCodecAdapter.java +++ b/dubbo-remoting/dubbo-remoting-mina/src/main/java/com/alibaba/dubbo/remoting/transport/mina/MinaCodecAdapter.java @@ -58,19 +58,23 @@ public MinaCodecAdapter(Codec2 codec, URL url, ChannelHandler handler) { this.bufferSize = b >= Constants.MIN_BUFFER_SIZE && b <= Constants.MAX_BUFFER_SIZE ? b : Constants.DEFAULT_BUFFER_SIZE; } + @Override public ProtocolEncoder getEncoder() { return encoder; } + @Override public ProtocolDecoder getDecoder() { return decoder; } private class InternalEncoder implements ProtocolEncoder { + @Override public void dispose(IoSession session) throws Exception { } + @Override public void encode(IoSession session, Object msg, ProtocolEncoderOutput out) throws Exception { ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(1024); MinaChannel channel = MinaChannel.getOrAddChannel(session, url, handler); @@ -88,6 +92,7 @@ private class InternalDecoder implements ProtocolDecoder { private ChannelBuffer buffer = ChannelBuffers.EMPTY_BUFFER; + @Override public void decode(IoSession session, ByteBuffer in, ProtocolDecoderOutput out) throws Exception { int readable = in.limit(); if (readable <= 0) return; @@ -145,9 +150,11 @@ public void decode(IoSession session, ByteBuffer in, ProtocolDecoderOutput out) } } + @Override public void dispose(IoSession session) throws Exception { } + @Override public void finishDecode(IoSession session, ProtocolDecoderOutput out) throws Exception { } } diff --git a/dubbo-remoting/dubbo-remoting-mina/src/main/java/com/alibaba/dubbo/remoting/transport/mina/MinaServer.java b/dubbo-remoting/dubbo-remoting-mina/src/main/java/com/alibaba/dubbo/remoting/transport/mina/MinaServer.java index be45b567e54..e8dc0a8d63e 100644 --- a/dubbo-remoting/dubbo-remoting-mina/src/main/java/com/alibaba/dubbo/remoting/transport/mina/MinaServer.java +++ b/dubbo-remoting/dubbo-remoting-mina/src/main/java/com/alibaba/dubbo/remoting/transport/mina/MinaServer.java @@ -79,6 +79,7 @@ protected void doClose() throws Throwable { } } + @Override public Collection getChannels() { Set sessions = acceptor.getManagedSessions(getBindAddress()); Collection channels = new HashSet(); @@ -90,6 +91,7 @@ public Collection getChannels() { return channels; } + @Override public Channel getChannel(InetSocketAddress remoteAddress) { Set sessions = acceptor.getManagedSessions(getBindAddress()); for (IoSession session : sessions) { @@ -100,6 +102,7 @@ public Channel getChannel(InetSocketAddress remoteAddress) { return null; } + @Override public boolean isBound() { return acceptor.isManaged(getBindAddress()); } diff --git a/dubbo-remoting/dubbo-remoting-mina/src/main/java/com/alibaba/dubbo/remoting/transport/mina/MinaTransporter.java b/dubbo-remoting/dubbo-remoting-mina/src/main/java/com/alibaba/dubbo/remoting/transport/mina/MinaTransporter.java index 9b2100cfd62..2380444cbd7 100644 --- a/dubbo-remoting/dubbo-remoting-mina/src/main/java/com/alibaba/dubbo/remoting/transport/mina/MinaTransporter.java +++ b/dubbo-remoting/dubbo-remoting-mina/src/main/java/com/alibaba/dubbo/remoting/transport/mina/MinaTransporter.java @@ -27,10 +27,12 @@ public class MinaTransporter implements Transporter { public static final String NAME = "mina"; + @Override public Server bind(URL url, ChannelHandler handler) throws RemotingException { return new MinaServer(url, handler); } + @Override public Client connect(URL url, ChannelHandler handler) throws RemotingException { return new MinaClient(url, handler); } diff --git a/dubbo-remoting/dubbo-remoting-netty/src/main/java/com/alibaba/dubbo/remoting/transport/netty/NettyBackedChannelBuffer.java b/dubbo-remoting/dubbo-remoting-netty/src/main/java/com/alibaba/dubbo/remoting/transport/netty/NettyBackedChannelBuffer.java index bcfbb5193e3..7d4462ef9c0 100644 --- a/dubbo-remoting/dubbo-remoting-netty/src/main/java/com/alibaba/dubbo/remoting/transport/netty/NettyBackedChannelBuffer.java +++ b/dubbo-remoting/dubbo-remoting-netty/src/main/java/com/alibaba/dubbo/remoting/transport/netty/NettyBackedChannelBuffer.java @@ -39,36 +39,43 @@ public org.jboss.netty.buffer.ChannelBuffer nettyChannelBuffer() { return buffer; } + @Override public int capacity() { return buffer.capacity(); } + @Override public ChannelBuffer copy(int index, int length) { return new NettyBackedChannelBuffer(buffer.copy(index, length)); } + @Override public ChannelBufferFactory factory() { return NettyBackedChannelBufferFactory.getInstance(); } + @Override public byte getByte(int index) { return buffer.getByte(index); } + @Override public void getBytes(int index, byte[] dst, int dstIndex, int length) { buffer.getBytes(index, dst, dstIndex, length); } + @Override public void getBytes(int index, ByteBuffer dst) { buffer.getBytes(index, dst); } + @Override public void getBytes(int index, ChannelBuffer dst, int dstIndex, int length) { // careful byte[] data = new byte[length]; @@ -77,31 +84,37 @@ public void getBytes(int index, ChannelBuffer dst, int dstIndex, int length) { } + @Override public void getBytes(int index, OutputStream dst, int length) throws IOException { buffer.getBytes(index, dst, length); } + @Override public boolean isDirect() { return buffer.isDirect(); } + @Override public void setByte(int index, int value) { buffer.setByte(index, value); } + @Override public void setBytes(int index, byte[] src, int srcIndex, int length) { buffer.setBytes(index, src, srcIndex, length); } + @Override public void setBytes(int index, ByteBuffer src) { buffer.setBytes(index, src); } + @Override public void setBytes(int index, ChannelBuffer src, int srcIndex, int length) { // careful byte[] data = new byte[length]; @@ -110,26 +123,31 @@ public void setBytes(int index, ChannelBuffer src, int srcIndex, int length) { } + @Override public int setBytes(int index, InputStream src, int length) throws IOException { return buffer.setBytes(index, src, length); } + @Override public ByteBuffer toByteBuffer(int index, int length) { return buffer.toByteBuffer(index, length); } + @Override public byte[] array() { return buffer.array(); } + @Override public boolean hasArray() { return buffer.hasArray(); } + @Override public int arrayOffset() { return buffer.arrayOffset(); } @@ -138,37 +156,44 @@ public int arrayOffset() { // AbstractChannelBuffer + @Override public void clear() { buffer.clear(); } + @Override public ChannelBuffer copy() { return new NettyBackedChannelBuffer(buffer.copy()); } + @Override public void discardReadBytes() { buffer.discardReadBytes(); } + @Override public void ensureWritableBytes(int writableBytes) { buffer.ensureWritableBytes(writableBytes); } + @Override public void getBytes(int index, byte[] dst) { buffer.getBytes(index, dst); } + @Override public void getBytes(int index, ChannelBuffer dst) { // careful getBytes(index, dst, dst.writableBytes()); } + @Override public void getBytes(int index, ChannelBuffer dst, int length) { // careful if (length > dst.writableBytes()) { @@ -179,52 +204,62 @@ public void getBytes(int index, ChannelBuffer dst, int length) { } + @Override public void markReaderIndex() { buffer.markReaderIndex(); } + @Override public void markWriterIndex() { buffer.markWriterIndex(); } + @Override public boolean readable() { return buffer.readable(); } + @Override public int readableBytes() { return buffer.readableBytes(); } + @Override public byte readByte() { return buffer.readByte(); } + @Override public void readBytes(byte[] dst) { buffer.readBytes(dst); } + @Override public void readBytes(byte[] dst, int dstIndex, int length) { buffer.readBytes(dst, dstIndex, length); } + @Override public void readBytes(ByteBuffer dst) { buffer.readBytes(dst); } + @Override public void readBytes(ChannelBuffer dst) { // careful readBytes(dst, dst.writableBytes()); } + @Override public void readBytes(ChannelBuffer dst, int length) { // carefule if (length > dst.writableBytes()) { @@ -235,6 +270,7 @@ public void readBytes(ChannelBuffer dst, int length) { } + @Override public void readBytes(ChannelBuffer dst, int dstIndex, int length) { // careful if (readableBytes() < length) { @@ -246,47 +282,56 @@ public void readBytes(ChannelBuffer dst, int dstIndex, int length) { } + @Override public ChannelBuffer readBytes(int length) { return new NettyBackedChannelBuffer(buffer.readBytes(length)); } + @Override public void resetReaderIndex() { buffer.resetReaderIndex(); } + @Override public void resetWriterIndex() { buffer.resetWriterIndex(); } + @Override public int readerIndex() { return buffer.readerIndex(); } + @Override public void readerIndex(int readerIndex) { buffer.readerIndex(readerIndex); } + @Override public void readBytes(OutputStream dst, int length) throws IOException { buffer.readBytes(dst, length); } + @Override public void setBytes(int index, byte[] src) { buffer.setBytes(index, src); } + @Override public void setBytes(int index, ChannelBuffer src) { // careful setBytes(index, src, src.readableBytes()); } + @Override public void setBytes(int index, ChannelBuffer src, int length) { // careful if (length > src.readableBytes()) { @@ -297,57 +342,68 @@ public void setBytes(int index, ChannelBuffer src, int length) { } + @Override public void setIndex(int readerIndex, int writerIndex) { buffer.setIndex(readerIndex, writerIndex); } + @Override public void skipBytes(int length) { buffer.skipBytes(length); } + @Override public ByteBuffer toByteBuffer() { return buffer.toByteBuffer(); } + @Override public boolean writable() { return buffer.writable(); } + @Override public int writableBytes() { return buffer.writableBytes(); } + @Override public void writeByte(int value) { buffer.writeByte(value); } + @Override public void writeBytes(byte[] src) { buffer.writeBytes(src); } + @Override public void writeBytes(byte[] src, int index, int length) { buffer.writeBytes(src, index, length); } + @Override public void writeBytes(ByteBuffer src) { buffer.writeBytes(src); } + @Override public void writeBytes(ChannelBuffer src) { // careful writeBytes(src, src.readableBytes()); } + @Override public void writeBytes(ChannelBuffer src, int length) { // careful if (length > src.readableBytes()) { @@ -358,6 +414,7 @@ public void writeBytes(ChannelBuffer src, int length) { } + @Override public void writeBytes(ChannelBuffer src, int srcIndex, int length) { // careful byte[] data = new byte[length]; @@ -366,21 +423,25 @@ public void writeBytes(ChannelBuffer src, int srcIndex, int length) { } + @Override public int writeBytes(InputStream src, int length) throws IOException { return buffer.writeBytes(src, length); } + @Override public int writerIndex() { return buffer.writerIndex(); } + @Override public void writerIndex(int writerIndex) { buffer.writerIndex(writerIndex); } + @Override public int compareTo(ChannelBuffer o) { return ChannelBuffers.compare(this, o); } diff --git a/dubbo-remoting/dubbo-remoting-netty/src/main/java/com/alibaba/dubbo/remoting/transport/netty/NettyBackedChannelBufferFactory.java b/dubbo-remoting/dubbo-remoting-netty/src/main/java/com/alibaba/dubbo/remoting/transport/netty/NettyBackedChannelBufferFactory.java index f35909eb740..68f73c67ad5 100644 --- a/dubbo-remoting/dubbo-remoting-netty/src/main/java/com/alibaba/dubbo/remoting/transport/netty/NettyBackedChannelBufferFactory.java +++ b/dubbo-remoting/dubbo-remoting-netty/src/main/java/com/alibaba/dubbo/remoting/transport/netty/NettyBackedChannelBufferFactory.java @@ -35,11 +35,13 @@ public static ChannelBufferFactory getInstance() { } + @Override public ChannelBuffer getBuffer(int capacity) { return new NettyBackedChannelBuffer(ChannelBuffers.dynamicBuffer(capacity)); } + @Override public ChannelBuffer getBuffer(byte[] array, int offset, int length) { org.jboss.netty.buffer.ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(length); buffer.writeBytes(array, offset, length); @@ -47,6 +49,7 @@ public ChannelBuffer getBuffer(byte[] array, int offset, int length) { } + @Override public ChannelBuffer getBuffer(ByteBuffer nioBuffer) { return new NettyBackedChannelBuffer(ChannelBuffers.wrappedBuffer(nioBuffer)); } diff --git a/dubbo-remoting/dubbo-remoting-netty/src/main/java/com/alibaba/dubbo/remoting/transport/netty/NettyChannel.java b/dubbo-remoting/dubbo-remoting-netty/src/main/java/com/alibaba/dubbo/remoting/transport/netty/NettyChannel.java index a866db2b390..c40c0b906aa 100644 --- a/dubbo-remoting/dubbo-remoting-netty/src/main/java/com/alibaba/dubbo/remoting/transport/netty/NettyChannel.java +++ b/dubbo-remoting/dubbo-remoting-netty/src/main/java/com/alibaba/dubbo/remoting/transport/netty/NettyChannel.java @@ -75,18 +75,22 @@ static void removeChannelIfDisconnected(org.jboss.netty.channel.Channel ch) { } } + @Override public InetSocketAddress getLocalAddress() { return (InetSocketAddress) channel.getLocalAddress(); } + @Override public InetSocketAddress getRemoteAddress() { return (InetSocketAddress) channel.getRemoteAddress(); } + @Override public boolean isConnected() { return channel.isConnected(); } + @Override public void send(Object message, boolean sent) throws RemotingException { super.send(message, sent); @@ -112,6 +116,7 @@ public void send(Object message, boolean sent) throws RemotingException { } } + @Override public void close() { try { super.close(); @@ -138,14 +143,17 @@ public void close() { } } + @Override public boolean hasAttribute(String key) { return attributes.containsKey(key); } + @Override public Object getAttribute(String key) { return attributes.get(key); } + @Override public void setAttribute(String key, Object value) { if (value == null) { // The null value unallowed in the ConcurrentHashMap. attributes.remove(key); @@ -154,6 +162,7 @@ public void setAttribute(String key, Object value) { } } + @Override public void removeAttribute(String key) { attributes.remove(key); } diff --git a/dubbo-remoting/dubbo-remoting-netty/src/main/java/com/alibaba/dubbo/remoting/transport/netty/NettyClient.java b/dubbo-remoting/dubbo-remoting-netty/src/main/java/com/alibaba/dubbo/remoting/transport/netty/NettyClient.java index 404fbb898c0..9aed6a1ca79 100644 --- a/dubbo-remoting/dubbo-remoting-netty/src/main/java/com/alibaba/dubbo/remoting/transport/netty/NettyClient.java +++ b/dubbo-remoting/dubbo-remoting-netty/src/main/java/com/alibaba/dubbo/remoting/transport/netty/NettyClient.java @@ -70,6 +70,7 @@ protected void doOpen() throws Throwable { bootstrap.setOption("connectTimeoutMillis", getTimeout()); final NettyHandler nettyHandler = new NettyHandler(getUrl(), this); bootstrap.setPipelineFactory(new ChannelPipelineFactory() { + @Override public ChannelPipeline getPipeline() { NettyCodecAdapter adapter = new NettyCodecAdapter(getCodec(), getUrl(), NettyClient.this); ChannelPipeline pipeline = Channels.pipeline(); @@ -81,6 +82,7 @@ public ChannelPipeline getPipeline() { }); } + @Override protected void doConnect() throws Throwable { long start = System.currentTimeMillis(); ChannelFuture future = bootstrap.connect(getConnectAddress()); diff --git a/dubbo-remoting/dubbo-remoting-netty/src/main/java/com/alibaba/dubbo/remoting/transport/netty/NettyHelper.java b/dubbo-remoting/dubbo-remoting-netty/src/main/java/com/alibaba/dubbo/remoting/transport/netty/NettyHelper.java index 93ceced419a..edf0c64b133 100644 --- a/dubbo-remoting/dubbo-remoting-netty/src/main/java/com/alibaba/dubbo/remoting/transport/netty/NettyHelper.java +++ b/dubbo-remoting/dubbo-remoting-netty/src/main/java/com/alibaba/dubbo/remoting/transport/netty/NettyHelper.java @@ -48,50 +48,62 @@ static class DubboLogger extends AbstractInternalLogger { this.logger = logger; } + @Override public boolean isDebugEnabled() { return logger.isDebugEnabled(); } + @Override public boolean isInfoEnabled() { return logger.isInfoEnabled(); } + @Override public boolean isWarnEnabled() { return logger.isWarnEnabled(); } + @Override public boolean isErrorEnabled() { return logger.isErrorEnabled(); } + @Override public void debug(String msg) { logger.debug(msg); } + @Override public void debug(String msg, Throwable cause) { logger.debug(msg, cause); } + @Override public void info(String msg) { logger.info(msg); } + @Override public void info(String msg, Throwable cause) { logger.info(msg, cause); } + @Override public void warn(String msg) { logger.warn(msg); } + @Override public void warn(String msg, Throwable cause) { logger.warn(msg, cause); } + @Override public void error(String msg) { logger.error(msg); } + @Override public void error(String msg, Throwable cause) { logger.error(msg, cause); } diff --git a/dubbo-remoting/dubbo-remoting-netty/src/main/java/com/alibaba/dubbo/remoting/transport/netty/NettyServer.java b/dubbo-remoting/dubbo-remoting-netty/src/main/java/com/alibaba/dubbo/remoting/transport/netty/NettyServer.java index c7e77d7e6fe..66d13c6533a 100644 --- a/dubbo-remoting/dubbo-remoting-netty/src/main/java/com/alibaba/dubbo/remoting/transport/netty/NettyServer.java +++ b/dubbo-remoting/dubbo-remoting-netty/src/main/java/com/alibaba/dubbo/remoting/transport/netty/NettyServer.java @@ -75,6 +75,7 @@ protected void doOpen() throws Throwable { // https://issues.jboss.org/browse/NETTY-379 // final Timer timer = new HashedWheelTimer(new NamedThreadFactory("NettyIdleTimer", true)); bootstrap.setPipelineFactory(new ChannelPipelineFactory() { + @Override public ChannelPipeline getPipeline() { NettyCodecAdapter adapter = new NettyCodecAdapter(getCodec(), getUrl(), NettyServer.this); ChannelPipeline pipeline = Channels.pipeline(); @@ -133,6 +134,7 @@ protected void doClose() throws Throwable { } } + @Override public Collection getChannels() { Collection chs = new HashSet(); for (Channel channel : this.channels.values()) { @@ -145,10 +147,12 @@ public Collection getChannels() { return chs; } + @Override public Channel getChannel(InetSocketAddress remoteAddress) { return channels.get(NetUtils.toAddressString(remoteAddress)); } + @Override public boolean isBound() { return channel.isBound(); } diff --git a/dubbo-remoting/dubbo-remoting-netty/src/main/java/com/alibaba/dubbo/remoting/transport/netty/NettyTransporter.java b/dubbo-remoting/dubbo-remoting-netty/src/main/java/com/alibaba/dubbo/remoting/transport/netty/NettyTransporter.java index 128f046433c..bbe0e96cf0b 100644 --- a/dubbo-remoting/dubbo-remoting-netty/src/main/java/com/alibaba/dubbo/remoting/transport/netty/NettyTransporter.java +++ b/dubbo-remoting/dubbo-remoting-netty/src/main/java/com/alibaba/dubbo/remoting/transport/netty/NettyTransporter.java @@ -27,10 +27,12 @@ public class NettyTransporter implements Transporter { public static final String NAME = "netty"; + @Override public Server bind(URL url, ChannelHandler listener) throws RemotingException { return new NettyServer(url, listener); } + @Override public Client connect(URL url, ChannelHandler listener) throws RemotingException { return new NettyClient(url, listener); } diff --git a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/com/alibaba/dubbo/remoting/transport/netty4/NettyBackedChannelBuffer.java b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/com/alibaba/dubbo/remoting/transport/netty4/NettyBackedChannelBuffer.java index 1748be20506..e6167cde522 100644 --- a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/com/alibaba/dubbo/remoting/transport/netty4/NettyBackedChannelBuffer.java +++ b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/com/alibaba/dubbo/remoting/transport/netty4/NettyBackedChannelBuffer.java @@ -37,36 +37,43 @@ public NettyBackedChannelBuffer(ByteBuf buffer) { } + @Override public int capacity() { return buffer.capacity(); } + @Override public ChannelBuffer copy(int index, int length) { return new NettyBackedChannelBuffer(buffer.copy(index, length)); } //has nothing use + @Override public ChannelBufferFactory factory() { return null; } + @Override public byte getByte(int index) { return buffer.getByte(index); } + @Override public void getBytes(int index, byte[] dst, int dstIndex, int length) { buffer.getBytes(index, dst, dstIndex, length); } + @Override public void getBytes(int index, ByteBuffer dst) { buffer.getBytes(index, dst); } + @Override public void getBytes(int index, ChannelBuffer dst, int dstIndex, int length) { // careful byte[] data = new byte[length]; @@ -75,31 +82,37 @@ public void getBytes(int index, ChannelBuffer dst, int dstIndex, int length) { } + @Override public void getBytes(int index, OutputStream dst, int length) throws IOException { buffer.getBytes(index, dst, length); } + @Override public boolean isDirect() { return buffer.isDirect(); } + @Override public void setByte(int index, int value) { buffer.setByte(index, value); } + @Override public void setBytes(int index, byte[] src, int srcIndex, int length) { buffer.setBytes(index, src, srcIndex, length); } + @Override public void setBytes(int index, ByteBuffer src) { buffer.setBytes(index, src); } + @Override public void setBytes(int index, ChannelBuffer src, int srcIndex, int length) { // careful byte[] data = new byte[length]; @@ -108,26 +121,31 @@ public void setBytes(int index, ChannelBuffer src, int srcIndex, int length) { } + @Override public int setBytes(int index, InputStream src, int length) throws IOException { return buffer.setBytes(index, src, length); } + @Override public ByteBuffer toByteBuffer(int index, int length) { return buffer.nioBuffer(index, length); } + @Override public byte[] array() { return buffer.array(); } + @Override public boolean hasArray() { return buffer.hasArray(); } + @Override public int arrayOffset() { return buffer.arrayOffset(); } @@ -137,37 +155,44 @@ public int arrayOffset() { + @Override public void clear() { buffer.clear(); } + @Override public ChannelBuffer copy() { return new NettyBackedChannelBuffer(buffer.copy()); } + @Override public void discardReadBytes() { buffer.discardReadBytes(); } + @Override public void ensureWritableBytes(int writableBytes) { buffer.ensureWritable(writableBytes); } + @Override public void getBytes(int index, byte[] dst) { buffer.getBytes(index, dst); } + @Override public void getBytes(int index, ChannelBuffer dst) { // careful getBytes(index, dst, dst.writableBytes()); } + @Override public void getBytes(int index, ChannelBuffer dst, int length) { // careful if (length > dst.writableBytes()) { @@ -178,52 +203,62 @@ public void getBytes(int index, ChannelBuffer dst, int length) { } + @Override public void markReaderIndex() { buffer.markReaderIndex(); } + @Override public void markWriterIndex() { buffer.markWriterIndex(); } + @Override public boolean readable() { return buffer.isReadable(); } + @Override public int readableBytes() { return buffer.readableBytes(); } + @Override public byte readByte() { return buffer.readByte(); } + @Override public void readBytes(byte[] dst) { buffer.readBytes(dst); } + @Override public void readBytes(byte[] dst, int dstIndex, int length) { buffer.readBytes(dst, dstIndex, length); } + @Override public void readBytes(ByteBuffer dst) { buffer.readBytes(dst); } + @Override public void readBytes(ChannelBuffer dst) { // careful readBytes(dst, dst.writableBytes()); } + @Override public void readBytes(ChannelBuffer dst, int length) { // carefule if (length > dst.writableBytes()) { @@ -234,6 +269,7 @@ public void readBytes(ChannelBuffer dst, int length) { } + @Override public void readBytes(ChannelBuffer dst, int dstIndex, int length) { // careful if (readableBytes() < length) { @@ -245,47 +281,56 @@ public void readBytes(ChannelBuffer dst, int dstIndex, int length) { } + @Override public ChannelBuffer readBytes(int length) { return new NettyBackedChannelBuffer(buffer.readBytes(length)); } + @Override public void resetReaderIndex() { buffer.resetReaderIndex(); } + @Override public void resetWriterIndex() { buffer.resetWriterIndex(); } + @Override public int readerIndex() { return buffer.readerIndex(); } + @Override public void readerIndex(int readerIndex) { buffer.readerIndex(readerIndex); } + @Override public void readBytes(OutputStream dst, int length) throws IOException { buffer.readBytes(dst, length); } + @Override public void setBytes(int index, byte[] src) { buffer.setBytes(index, src); } + @Override public void setBytes(int index, ChannelBuffer src) { // careful setBytes(index, src, src.readableBytes()); } + @Override public void setBytes(int index, ChannelBuffer src, int length) { // careful if (length > src.readableBytes()) { @@ -296,57 +341,68 @@ public void setBytes(int index, ChannelBuffer src, int length) { } + @Override public void setIndex(int readerIndex, int writerIndex) { buffer.setIndex(readerIndex, writerIndex); } + @Override public void skipBytes(int length) { buffer.skipBytes(length); } + @Override public ByteBuffer toByteBuffer() { return buffer.nioBuffer(); } + @Override public boolean writable() { return buffer.isWritable(); } + @Override public int writableBytes() { return buffer.writableBytes(); } + @Override public void writeByte(int value) { buffer.writeByte(value); } + @Override public void writeBytes(byte[] src) { buffer.writeBytes(src); } + @Override public void writeBytes(byte[] src, int index, int length) { buffer.writeBytes(src, index, length); } + @Override public void writeBytes(ByteBuffer src) { buffer.writeBytes(src); } + @Override public void writeBytes(ChannelBuffer src) { // careful writeBytes(src, src.readableBytes()); } + @Override public void writeBytes(ChannelBuffer src, int length) { // careful if (length > src.readableBytes()) { @@ -357,6 +413,7 @@ public void writeBytes(ChannelBuffer src, int length) { } + @Override public void writeBytes(ChannelBuffer src, int srcIndex, int length) { // careful byte[] data = new byte[length]; @@ -365,21 +422,25 @@ public void writeBytes(ChannelBuffer src, int srcIndex, int length) { } + @Override public int writeBytes(InputStream src, int length) throws IOException { return buffer.writeBytes(src, length); } + @Override public int writerIndex() { return buffer.writerIndex(); } + @Override public void writerIndex(int writerIndex) { buffer.writerIndex(writerIndex); } + @Override public int compareTo(ChannelBuffer o) { return ChannelBuffers.compare(this, o); } diff --git a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/com/alibaba/dubbo/remoting/transport/netty4/NettyChannel.java b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/com/alibaba/dubbo/remoting/transport/netty4/NettyChannel.java index 9cb0bd1154e..9f3873e0b8d 100644 --- a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/com/alibaba/dubbo/remoting/transport/netty4/NettyChannel.java +++ b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/com/alibaba/dubbo/remoting/transport/netty4/NettyChannel.java @@ -76,18 +76,22 @@ static void removeChannelIfDisconnected(Channel ch) { } } + @Override public InetSocketAddress getLocalAddress() { return (InetSocketAddress) channel.localAddress(); } + @Override public InetSocketAddress getRemoteAddress() { return (InetSocketAddress) channel.remoteAddress(); } + @Override public boolean isConnected() { return !isClosed() && channel.isActive(); } + @Override public void send(Object message, boolean sent) throws RemotingException { super.send(message, sent); @@ -113,6 +117,7 @@ public void send(Object message, boolean sent) throws RemotingException { } } + @Override public void close() { try { super.close(); @@ -139,14 +144,17 @@ public void close() { } } + @Override public boolean hasAttribute(String key) { return attributes.containsKey(key); } + @Override public Object getAttribute(String key) { return attributes.get(key); } + @Override public void setAttribute(String key, Object value) { if (value == null) { // The null value unallowed in the ConcurrentHashMap. attributes.remove(key); @@ -155,6 +163,7 @@ public void setAttribute(String key, Object value) { } } + @Override public void removeAttribute(String key) { attributes.remove(key); } diff --git a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/com/alibaba/dubbo/remoting/transport/netty4/NettyClient.java b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/com/alibaba/dubbo/remoting/transport/netty4/NettyClient.java index d356bc8f212..73c54b7499a 100644 --- a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/com/alibaba/dubbo/remoting/transport/netty4/NettyClient.java +++ b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/com/alibaba/dubbo/remoting/transport/netty4/NettyClient.java @@ -76,6 +76,7 @@ protected void doOpen() throws Throwable { bootstrap.handler(new ChannelInitializer() { + @Override protected void initChannel(Channel ch) throws Exception { NettyCodecAdapter adapter = new NettyCodecAdapter(getCodec(), getUrl(), NettyClient.this); ch.pipeline()//.addLast("logging",new LoggingHandler(LogLevel.INFO))//for debug @@ -86,6 +87,7 @@ protected void initChannel(Channel ch) throws Exception { }); } + @Override protected void doConnect() throws Throwable { long start = System.currentTimeMillis(); ChannelFuture future = bootstrap.connect(getConnectAddress()); diff --git a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/com/alibaba/dubbo/remoting/transport/netty4/NettyCodecAdapter.java b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/com/alibaba/dubbo/remoting/transport/netty4/NettyCodecAdapter.java index dc15705c30e..c319eadae84 100644 --- a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/com/alibaba/dubbo/remoting/transport/netty4/NettyCodecAdapter.java +++ b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/com/alibaba/dubbo/remoting/transport/netty4/NettyCodecAdapter.java @@ -61,6 +61,7 @@ public ChannelHandler getDecoder() { private class InternalEncoder extends MessageToByteEncoder { + @Override protected void encode(ChannelHandlerContext ctx, Object msg, ByteBuf out) throws Exception { com.alibaba.dubbo.remoting.buffer.ChannelBuffer buffer = new NettyBackedChannelBuffer(out); Channel ch = ctx.channel(); @@ -75,6 +76,7 @@ protected void encode(ChannelHandlerContext ctx, Object msg, ByteBuf out) throws private class InternalDecoder extends ByteToMessageDecoder { + @Override protected void decode(ChannelHandlerContext ctx, ByteBuf input, List out) throws Exception { ChannelBuffer message = new NettyBackedChannelBuffer(input); diff --git a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/com/alibaba/dubbo/remoting/transport/netty4/NettyServer.java b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/com/alibaba/dubbo/remoting/transport/netty4/NettyServer.java index ef70c2d9026..124b9a72c25 100644 --- a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/com/alibaba/dubbo/remoting/transport/netty4/NettyServer.java +++ b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/com/alibaba/dubbo/remoting/transport/netty4/NettyServer.java @@ -142,6 +142,7 @@ protected void doClose() throws Throwable { } } + @Override public Collection getChannels() { Collection chs = new HashSet(); for (Channel channel : this.channels.values()) { @@ -154,10 +155,12 @@ public Collection getChannels() { return chs; } + @Override public Channel getChannel(InetSocketAddress remoteAddress) { return channels.get(NetUtils.toAddressString(remoteAddress)); } + @Override public boolean isBound() { return channel.isActive(); } diff --git a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/com/alibaba/dubbo/remoting/transport/netty4/NettyTransporter.java b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/com/alibaba/dubbo/remoting/transport/netty4/NettyTransporter.java index 4a4ac209bd3..1a1f4bc7f75 100644 --- a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/com/alibaba/dubbo/remoting/transport/netty4/NettyTransporter.java +++ b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/com/alibaba/dubbo/remoting/transport/netty4/NettyTransporter.java @@ -27,10 +27,12 @@ public class NettyTransporter implements Transporter { public static final String NAME = "netty4"; + @Override public Server bind(URL url, ChannelHandler listener) throws RemotingException { return new NettyServer(url, listener); } + @Override public Client connect(URL url, ChannelHandler listener) throws RemotingException { return new NettyClient(url, listener); } diff --git a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/com/alibaba/dubbo/remoting/transport/netty4/logging/NettyHelper.java b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/com/alibaba/dubbo/remoting/transport/netty4/logging/NettyHelper.java index 7b54636fddf..715aa6479dc 100644 --- a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/com/alibaba/dubbo/remoting/transport/netty4/logging/NettyHelper.java +++ b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/com/alibaba/dubbo/remoting/transport/netty4/logging/NettyHelper.java @@ -48,16 +48,19 @@ static class DubboLogger extends AbstractInternalLogger { this.logger = logger; } + @Override public boolean isTraceEnabled() { return logger.isTraceEnabled(); } + @Override public void trace(String msg) { if (isTraceEnabled()) { logger.trace(msg); } } + @Override public void trace(String format, Object arg) { if (isTraceEnabled()) { FormattingTuple ft = MessageFormatter.format(format, arg); @@ -66,6 +69,7 @@ public void trace(String format, Object arg) { } + @Override public void trace(String format, Object argA, Object argB) { if (isTraceEnabled()) { FormattingTuple ft = MessageFormatter.format(format, argA, argB); @@ -73,6 +77,7 @@ public void trace(String format, Object argA, Object argB) { } } + @Override public void trace(String format, Object... arguments) { if (isTraceEnabled()) { FormattingTuple ft = MessageFormatter.arrayFormat(format, arguments); @@ -80,22 +85,26 @@ public void trace(String format, Object... arguments) { } } + @Override public void trace(String msg, Throwable t) { if (isTraceEnabled()) { logger.trace(msg, t); } } + @Override public boolean isDebugEnabled() { return logger.isDebugEnabled(); } + @Override public void debug(String msg) { if (isDebugEnabled()) { logger.debug(msg); } } + @Override public void debug(String format, Object arg) { if (isDebugEnabled()) { FormattingTuple ft = MessageFormatter.format(format, arg); @@ -103,6 +112,7 @@ public void debug(String format, Object arg) { } } + @Override public void debug(String format, Object argA, Object argB) { if (isDebugEnabled()) { FormattingTuple ft = MessageFormatter.format(format, argA, argB); @@ -110,6 +120,7 @@ public void debug(String format, Object argA, Object argB) { } } + @Override public void debug(String format, Object... arguments) { if (isDebugEnabled()) { FormattingTuple ft = MessageFormatter.arrayFormat(format, arguments); @@ -117,22 +128,26 @@ public void debug(String format, Object... arguments) { } } + @Override public void debug(String msg, Throwable t) { if (isDebugEnabled()) { logger.debug(msg, t); } } + @Override public boolean isInfoEnabled() { return logger.isInfoEnabled(); } + @Override public void info(String msg) { if (isInfoEnabled()) { logger.info(msg); } } + @Override public void info(String format, Object arg) { if (isInfoEnabled()) { FormattingTuple ft = MessageFormatter.format(format, arg); @@ -140,6 +155,7 @@ public void info(String format, Object arg) { } } + @Override public void info(String format, Object argA, Object argB) { if (isInfoEnabled()) { FormattingTuple ft = MessageFormatter.format(format, argA, argB); @@ -147,6 +163,7 @@ public void info(String format, Object argA, Object argB) { } } + @Override public void info(String format, Object... arguments) { if (isInfoEnabled()) { FormattingTuple ft = MessageFormatter.arrayFormat(format, arguments); @@ -154,22 +171,26 @@ public void info(String format, Object... arguments) { } } + @Override public void info(String msg, Throwable t) { if (isInfoEnabled()) { logger.info(msg, t); } } + @Override public boolean isWarnEnabled() { return false; } + @Override public void warn(String msg) { if (isWarnEnabled()) { logger.warn(msg); } } + @Override public void warn(String format, Object arg) { if (isWarnEnabled()) { FormattingTuple ft = MessageFormatter.format(format, arg); @@ -177,6 +198,7 @@ public void warn(String format, Object arg) { } } + @Override public void warn(String format, Object... arguments) { if (isWarnEnabled()) { FormattingTuple ft = MessageFormatter.arrayFormat(format, arguments); @@ -184,6 +206,7 @@ public void warn(String format, Object... arguments) { } } + @Override public void warn(String format, Object argA, Object argB) { if (isWarnEnabled()) { FormattingTuple ft = MessageFormatter.format(format, argA, argB); @@ -191,22 +214,26 @@ public void warn(String format, Object argA, Object argB) { } } + @Override public void warn(String msg, Throwable t) { if (isWarnEnabled()) { logger.warn(msg, t); } } + @Override public boolean isErrorEnabled() { return logger.isErrorEnabled(); } + @Override public void error(String msg) { if (isErrorEnabled()) { logger.error(msg); } } + @Override public void error(String format, Object arg) { if (isErrorEnabled()) { FormattingTuple ft = MessageFormatter.format(format, arg); @@ -214,6 +241,7 @@ public void error(String format, Object arg) { } } + @Override public void error(String format, Object argA, Object argB) { if (isErrorEnabled()) { FormattingTuple ft = MessageFormatter.format(format, argA, argB); @@ -221,6 +249,7 @@ public void error(String format, Object argA, Object argB) { } } + @Override public void error(String format, Object... arguments) { if (isErrorEnabled()) { FormattingTuple ft = MessageFormatter.arrayFormat(format, arguments); @@ -228,6 +257,7 @@ public void error(String format, Object... arguments) { } } + @Override public void error(String msg, Throwable t) { if (isErrorEnabled()) { logger.error(msg, t); diff --git a/dubbo-remoting/dubbo-remoting-p2p/src/main/java/com/alibaba/dubbo/remoting/p2p/exchange/support/AbstractExchangeGroup.java b/dubbo-remoting/dubbo-remoting-p2p/src/main/java/com/alibaba/dubbo/remoting/p2p/exchange/support/AbstractExchangeGroup.java index 32767c9231d..da18b8db0fa 100644 --- a/dubbo-remoting/dubbo-remoting-p2p/src/main/java/com/alibaba/dubbo/remoting/p2p/exchange/support/AbstractExchangeGroup.java +++ b/dubbo-remoting/dubbo-remoting-p2p/src/main/java/com/alibaba/dubbo/remoting/p2p/exchange/support/AbstractExchangeGroup.java @@ -59,10 +59,12 @@ public AbstractExchangeGroup(URL url) { this.url = url; } + @Override public URL getUrl() { return url; } + @Override public void close() { for (URL url : new ArrayList(servers.keySet())) { try { @@ -80,10 +82,12 @@ public void close() { } } + @Override public Peer join(URL url, ChannelHandler handler) throws RemotingException { return join(url, (ExchangeHandler) handler); } + @Override public ExchangePeer join(URL url, ExchangeHandler handler) throws RemotingException { ExchangeServer server = servers.get(url); if (server == null) { // TODO exist concurrent gap @@ -94,6 +98,7 @@ public ExchangePeer join(URL url, ExchangeHandler handler) throws RemotingExcept return new ExchangeServerPeer(server, clients, this); } + @Override public void leave(URL url) throws RemotingException { Server server = servers.remove(url); if (server != null) { diff --git a/dubbo-remoting/dubbo-remoting-p2p/src/main/java/com/alibaba/dubbo/remoting/p2p/exchange/support/ExchangeServerPeer.java b/dubbo-remoting/dubbo-remoting-p2p/src/main/java/com/alibaba/dubbo/remoting/p2p/exchange/support/ExchangeServerPeer.java index b6d7768222d..b9382cff53b 100644 --- a/dubbo-remoting/dubbo-remoting-p2p/src/main/java/com/alibaba/dubbo/remoting/p2p/exchange/support/ExchangeServerPeer.java +++ b/dubbo-remoting/dubbo-remoting-p2p/src/main/java/com/alibaba/dubbo/remoting/p2p/exchange/support/ExchangeServerPeer.java @@ -52,6 +52,7 @@ public ExchangeServerPeer(ExchangeServer server, Map client this.group = group; } + @Override public void leave() throws RemotingException { group.leave(getUrl()); } diff --git a/dubbo-remoting/dubbo-remoting-p2p/src/main/java/com/alibaba/dubbo/remoting/p2p/exchange/support/FileExchangeGroup.java b/dubbo-remoting/dubbo-remoting-p2p/src/main/java/com/alibaba/dubbo/remoting/p2p/exchange/support/FileExchangeGroup.java index e0dd35c481c..136cb70a687 100644 --- a/dubbo-remoting/dubbo-remoting-p2p/src/main/java/com/alibaba/dubbo/remoting/p2p/exchange/support/FileExchangeGroup.java +++ b/dubbo-remoting/dubbo-remoting-p2p/src/main/java/com/alibaba/dubbo/remoting/p2p/exchange/support/FileExchangeGroup.java @@ -54,6 +54,7 @@ public FileExchangeGroup(URL url) { throw new IllegalStateException("The group file not exists. file: " + path); } checkModifiedFuture = scheduledExecutorService.scheduleWithFixedDelay(new Runnable() { + @Override public void run() { // check the file change try { @@ -65,6 +66,7 @@ public void run() { }, 2000, 2000, TimeUnit.MILLISECONDS); } + @Override public void close() { super.close(); try { diff --git a/dubbo-remoting/dubbo-remoting-p2p/src/main/java/com/alibaba/dubbo/remoting/p2p/exchange/support/FileExchangeNetworker.java b/dubbo-remoting/dubbo-remoting-p2p/src/main/java/com/alibaba/dubbo/remoting/p2p/exchange/support/FileExchangeNetworker.java index cd651ba03d9..5e474b65c2c 100644 --- a/dubbo-remoting/dubbo-remoting-p2p/src/main/java/com/alibaba/dubbo/remoting/p2p/exchange/support/FileExchangeNetworker.java +++ b/dubbo-remoting/dubbo-remoting-p2p/src/main/java/com/alibaba/dubbo/remoting/p2p/exchange/support/FileExchangeNetworker.java @@ -26,6 +26,7 @@ */ public class FileExchangeNetworker implements ExchangeNetworker { + @Override public ExchangeGroup lookup(URL url) throws RemotingException { return new FileExchangeGroup(url); } diff --git a/dubbo-remoting/dubbo-remoting-p2p/src/main/java/com/alibaba/dubbo/remoting/p2p/exchange/support/MulticastExchangeGroup.java b/dubbo-remoting/dubbo-remoting-p2p/src/main/java/com/alibaba/dubbo/remoting/p2p/exchange/support/MulticastExchangeGroup.java index a9d3e6d2e21..46f643d9062 100644 --- a/dubbo-remoting/dubbo-remoting-p2p/src/main/java/com/alibaba/dubbo/remoting/p2p/exchange/support/MulticastExchangeGroup.java +++ b/dubbo-remoting/dubbo-remoting-p2p/src/main/java/com/alibaba/dubbo/remoting/p2p/exchange/support/MulticastExchangeGroup.java @@ -52,6 +52,7 @@ public MulticastExchangeGroup(URL url) { mutilcastSocket.setLoopbackMode(false); mutilcastSocket.joinGroup(mutilcastAddress); Thread thread = new Thread(new Runnable() { + @Override public void run() { byte[] buf = new byte[1024]; DatagramPacket recv = new DatagramPacket(buf, buf.length); diff --git a/dubbo-remoting/dubbo-remoting-p2p/src/main/java/com/alibaba/dubbo/remoting/p2p/exchange/support/MulticastExchangeNetworker.java b/dubbo-remoting/dubbo-remoting-p2p/src/main/java/com/alibaba/dubbo/remoting/p2p/exchange/support/MulticastExchangeNetworker.java index 048ff23c33e..d2084caffe7 100644 --- a/dubbo-remoting/dubbo-remoting-p2p/src/main/java/com/alibaba/dubbo/remoting/p2p/exchange/support/MulticastExchangeNetworker.java +++ b/dubbo-remoting/dubbo-remoting-p2p/src/main/java/com/alibaba/dubbo/remoting/p2p/exchange/support/MulticastExchangeNetworker.java @@ -26,6 +26,7 @@ */ public class MulticastExchangeNetworker implements ExchangeNetworker { + @Override public ExchangeGroup lookup(URL url) throws RemotingException { return new MulticastExchangeGroup(url); } diff --git a/dubbo-remoting/dubbo-remoting-p2p/src/main/java/com/alibaba/dubbo/remoting/p2p/support/AbstractGroup.java b/dubbo-remoting/dubbo-remoting-p2p/src/main/java/com/alibaba/dubbo/remoting/p2p/support/AbstractGroup.java index 4374d4b4c0b..d2fbb290e35 100644 --- a/dubbo-remoting/dubbo-remoting-p2p/src/main/java/com/alibaba/dubbo/remoting/p2p/support/AbstractGroup.java +++ b/dubbo-remoting/dubbo-remoting-p2p/src/main/java/com/alibaba/dubbo/remoting/p2p/support/AbstractGroup.java @@ -55,10 +55,12 @@ public AbstractGroup(URL url) { this.url = url; } + @Override public URL getUrl() { return url; } + @Override public void close() { for (URL url : new ArrayList(servers.keySet())) { try { @@ -76,6 +78,7 @@ public void close() { } } + @Override public Peer join(URL url, ChannelHandler handler) throws RemotingException { Server server = servers.get(url); if (server == null) { // TODO exist concurrent gap @@ -86,6 +89,7 @@ public Peer join(URL url, ChannelHandler handler) throws RemotingException { return new ServerPeer(server, clients, this); } + @Override public void leave(URL url) throws RemotingException { Server server = servers.remove(url); if (server != null) { diff --git a/dubbo-remoting/dubbo-remoting-p2p/src/main/java/com/alibaba/dubbo/remoting/p2p/support/FileGroup.java b/dubbo-remoting/dubbo-remoting-p2p/src/main/java/com/alibaba/dubbo/remoting/p2p/support/FileGroup.java index 346559cde0f..859035247db 100644 --- a/dubbo-remoting/dubbo-remoting-p2p/src/main/java/com/alibaba/dubbo/remoting/p2p/support/FileGroup.java +++ b/dubbo-remoting/dubbo-remoting-p2p/src/main/java/com/alibaba/dubbo/remoting/p2p/support/FileGroup.java @@ -51,6 +51,7 @@ public FileGroup(URL url) { String path = url.getAbsolutePath(); file = new File(path); checkModifiedFuture = scheduledExecutorService.scheduleWithFixedDelay(new Runnable() { + @Override public void run() { // Check the file change try { @@ -62,6 +63,7 @@ public void run() { }, 2000, 2000, TimeUnit.MILLISECONDS); } + @Override public void close() { super.close(); try { @@ -92,6 +94,7 @@ private void changed() throws RemotingException { } } + @Override public Peer join(URL url, ChannelHandler handler) throws RemotingException { Peer peer = super.join(url, handler); try { diff --git a/dubbo-remoting/dubbo-remoting-p2p/src/main/java/com/alibaba/dubbo/remoting/p2p/support/FileNetworker.java b/dubbo-remoting/dubbo-remoting-p2p/src/main/java/com/alibaba/dubbo/remoting/p2p/support/FileNetworker.java index d09ef2e8171..9c1ebc7a6dc 100644 --- a/dubbo-remoting/dubbo-remoting-p2p/src/main/java/com/alibaba/dubbo/remoting/p2p/support/FileNetworker.java +++ b/dubbo-remoting/dubbo-remoting-p2p/src/main/java/com/alibaba/dubbo/remoting/p2p/support/FileNetworker.java @@ -26,6 +26,7 @@ */ public class FileNetworker implements Networker { + @Override public Group lookup(URL url) throws RemotingException { return new FileGroup(url); } diff --git a/dubbo-remoting/dubbo-remoting-p2p/src/main/java/com/alibaba/dubbo/remoting/p2p/support/MulticastGroup.java b/dubbo-remoting/dubbo-remoting-p2p/src/main/java/com/alibaba/dubbo/remoting/p2p/support/MulticastGroup.java index bb3592ea96b..3805d38105c 100644 --- a/dubbo-remoting/dubbo-remoting-p2p/src/main/java/com/alibaba/dubbo/remoting/p2p/support/MulticastGroup.java +++ b/dubbo-remoting/dubbo-remoting-p2p/src/main/java/com/alibaba/dubbo/remoting/p2p/support/MulticastGroup.java @@ -52,6 +52,7 @@ public MulticastGroup(URL url) { mutilcastSocket.setLoopbackMode(false); mutilcastSocket.joinGroup(mutilcastAddress); Thread thread = new Thread(new Runnable() { + @Override public void run() { byte[] buf = new byte[1024]; DatagramPacket recv = new DatagramPacket(buf, buf.length); diff --git a/dubbo-remoting/dubbo-remoting-p2p/src/main/java/com/alibaba/dubbo/remoting/p2p/support/MulticastNetworker.java b/dubbo-remoting/dubbo-remoting-p2p/src/main/java/com/alibaba/dubbo/remoting/p2p/support/MulticastNetworker.java index 0755de623e6..c7ef7879a80 100644 --- a/dubbo-remoting/dubbo-remoting-p2p/src/main/java/com/alibaba/dubbo/remoting/p2p/support/MulticastNetworker.java +++ b/dubbo-remoting/dubbo-remoting-p2p/src/main/java/com/alibaba/dubbo/remoting/p2p/support/MulticastNetworker.java @@ -26,6 +26,7 @@ */ public class MulticastNetworker implements Networker { + @Override public Group lookup(URL url) throws RemotingException { return new MulticastGroup(url); } diff --git a/dubbo-remoting/dubbo-remoting-p2p/src/main/java/com/alibaba/dubbo/remoting/p2p/support/ServerPeer.java b/dubbo-remoting/dubbo-remoting-p2p/src/main/java/com/alibaba/dubbo/remoting/p2p/support/ServerPeer.java index a6bc7f9e867..a1c40b430eb 100644 --- a/dubbo-remoting/dubbo-remoting-p2p/src/main/java/com/alibaba/dubbo/remoting/p2p/support/ServerPeer.java +++ b/dubbo-remoting/dubbo-remoting-p2p/src/main/java/com/alibaba/dubbo/remoting/p2p/support/ServerPeer.java @@ -50,6 +50,7 @@ public ServerPeer(Server server, Map clients, Group group) { this.group = group; } + @Override public void leave() throws RemotingException { group.leave(getUrl()); } diff --git a/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/com/alibaba/dubbo/remoting/zookeeper/curator/CuratorZookeeperClient.java b/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/com/alibaba/dubbo/remoting/zookeeper/curator/CuratorZookeeperClient.java index 33ddf43d24f..a08edc9a2be 100644 --- a/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/com/alibaba/dubbo/remoting/zookeeper/curator/CuratorZookeeperClient.java +++ b/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/com/alibaba/dubbo/remoting/zookeeper/curator/CuratorZookeeperClient.java @@ -53,6 +53,7 @@ public CuratorZookeeperClient(URL url) { } client = builder.build(); client.getConnectionStateListenable().addListener(new ConnectionStateListener() { + @Override public void stateChanged(CuratorFramework client, ConnectionState state) { if (state == ConnectionState.LOST) { CuratorZookeeperClient.this.stateChanged(StateListener.DISCONNECTED); @@ -69,6 +70,7 @@ public void stateChanged(CuratorFramework client, ConnectionState state) { } } + @Override public void createPersistent(String path) { try { client.create().forPath(path); @@ -78,6 +80,7 @@ public void createPersistent(String path) { } } + @Override public void createEphemeral(String path) { try { client.create().withMode(CreateMode.EPHEMERAL).forPath(path); @@ -87,6 +90,7 @@ public void createEphemeral(String path) { } } + @Override public void delete(String path) { try { client.delete().forPath(path); @@ -96,6 +100,7 @@ public void delete(String path) { } } + @Override public List getChildren(String path) { try { return client.getChildren().forPath(path); @@ -106,6 +111,7 @@ public List getChildren(String path) { } } + @Override public boolean checkExists(String path) { try { if (client.checkExists().forPath(path) != null) { @@ -115,18 +121,22 @@ public boolean checkExists(String path) { } return false; } + @Override public boolean isConnected() { return client.getZookeeperClient().isConnected(); } + @Override public void doClose() { client.close(); } + @Override public CuratorWatcher createTargetChildListener(String path, ChildListener listener) { return new CuratorWatcherImpl(listener); } + @Override public List addTargetChildListener(String path, CuratorWatcher listener) { try { return client.getChildren().usingWatcher(listener).forPath(path); @@ -137,6 +147,7 @@ public List addTargetChildListener(String path, CuratorWatcher listener) } } + @Override public void removeTargetChildListener(String path, CuratorWatcher listener) { ((CuratorWatcherImpl) listener).unwatch(); } @@ -153,6 +164,7 @@ public void unwatch() { this.listener = null; } + @Override public void process(WatchedEvent event) throws Exception { if (listener != null) { String path = event.getPath() == null ? "" : event.getPath(); diff --git a/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/com/alibaba/dubbo/remoting/zookeeper/curator/CuratorZookeeperTransporter.java b/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/com/alibaba/dubbo/remoting/zookeeper/curator/CuratorZookeeperTransporter.java index db07ed91929..4d7afef59a1 100644 --- a/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/com/alibaba/dubbo/remoting/zookeeper/curator/CuratorZookeeperTransporter.java +++ b/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/com/alibaba/dubbo/remoting/zookeeper/curator/CuratorZookeeperTransporter.java @@ -22,6 +22,7 @@ public class CuratorZookeeperTransporter implements ZookeeperTransporter { + @Override public ZookeeperClient connect(URL url) { return new CuratorZookeeperClient(url); } diff --git a/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/com/alibaba/dubbo/remoting/zookeeper/support/AbstractZookeeperClient.java b/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/com/alibaba/dubbo/remoting/zookeeper/support/AbstractZookeeperClient.java index 0b4070adcaf..9efd8b45493 100644 --- a/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/com/alibaba/dubbo/remoting/zookeeper/support/AbstractZookeeperClient.java +++ b/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/com/alibaba/dubbo/remoting/zookeeper/support/AbstractZookeeperClient.java @@ -45,10 +45,12 @@ public AbstractZookeeperClient(URL url) { this.url = url; } + @Override public URL getUrl() { return url; } + @Override public void create(String path, boolean ephemeral) { int i = path.lastIndexOf('/'); if (i > 0) { @@ -64,10 +66,12 @@ public void create(String path, boolean ephemeral) { } } + @Override public void addStateListener(StateListener listener) { stateListeners.add(listener); } + @Override public void removeStateListener(StateListener listener) { stateListeners.remove(listener); } @@ -76,6 +80,7 @@ public Set getSessionListeners() { return stateListeners; } + @Override public List addChildListener(String path, final ChildListener listener) { ConcurrentMap listeners = childListeners.get(path); if (listeners == null) { @@ -90,6 +95,7 @@ public List addChildListener(String path, final ChildListener listener) return addTargetChildListener(path, targetListener); } + @Override public void removeChildListener(String path, ChildListener listener) { ConcurrentMap listeners = childListeners.get(path); if (listeners != null) { @@ -106,6 +112,7 @@ protected void stateChanged(int state) { } } + @Override public void close() { if (closed) { return; diff --git a/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/com/alibaba/dubbo/remoting/zookeeper/zkclient/ZkclientZookeeperClient.java b/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/com/alibaba/dubbo/remoting/zookeeper/zkclient/ZkclientZookeeperClient.java index a8b4466c1a8..a27aab611ca 100644 --- a/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/com/alibaba/dubbo/remoting/zookeeper/zkclient/ZkclientZookeeperClient.java +++ b/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/com/alibaba/dubbo/remoting/zookeeper/zkclient/ZkclientZookeeperClient.java @@ -39,6 +39,7 @@ public ZkclientZookeeperClient(URL url) { super(url); client = new ZkClientWrapper(url.getBackupAddress(), 30000); client.addListener(new IZkStateListener() { + @Override public void handleStateChanged(KeeperState state) throws Exception { ZkclientZookeeperClient.this.state = state; if (state == KeeperState.Disconnected) { @@ -48,6 +49,7 @@ public void handleStateChanged(KeeperState state) throws Exception { } } + @Override public void handleNewSession() throws Exception { stateChanged(StateListener.RECONNECTED); } @@ -56,6 +58,7 @@ public void handleNewSession() throws Exception { } + @Override public void createPersistent(String path) { try { client.createPersistent(path); @@ -63,6 +66,7 @@ public void createPersistent(String path) { } } + @Override public void createEphemeral(String path) { try { client.createEphemeral(path); @@ -70,6 +74,7 @@ public void createEphemeral(String path) { } } + @Override public void delete(String path) { try { client.delete(path); @@ -77,6 +82,7 @@ public void delete(String path) { } } + @Override public List getChildren(String path) { try { return client.getChildren(path); @@ -85,6 +91,7 @@ public List getChildren(String path) { } } + @Override public boolean checkExists(String path) { try { return client.exists(path); @@ -93,16 +100,20 @@ public boolean checkExists(String path) { return false; } + @Override public boolean isConnected() { return state == KeeperState.SyncConnected; } + @Override public void doClose() { client.close(); } + @Override public IZkChildListener createTargetChildListener(String path, final ChildListener listener) { return new IZkChildListener() { + @Override public void handleChildChange(String parentPath, List currentChilds) throws Exception { listener.childChanged(parentPath, currentChilds); @@ -110,10 +121,12 @@ public void handleChildChange(String parentPath, List currentChilds) }; } + @Override public List addTargetChildListener(String path, final IZkChildListener listener) { return client.subscribeChildChanges(path, listener); } + @Override public void removeTargetChildListener(String path, IZkChildListener listener) { client.unsubscribeChildChanges(path, listener); } diff --git a/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/com/alibaba/dubbo/remoting/zookeeper/zkclient/ZkclientZookeeperTransporter.java b/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/com/alibaba/dubbo/remoting/zookeeper/zkclient/ZkclientZookeeperTransporter.java index 82a7f268f12..17be601a07c 100644 --- a/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/com/alibaba/dubbo/remoting/zookeeper/zkclient/ZkclientZookeeperTransporter.java +++ b/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/com/alibaba/dubbo/remoting/zookeeper/zkclient/ZkclientZookeeperTransporter.java @@ -22,6 +22,7 @@ public class ZkclientZookeeperTransporter implements ZookeeperTransporter { + @Override public ZookeeperClient connect(URL url) { return new ZkclientZookeeperClient(url); } diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/RpcContext.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/RpcContext.java index e7ecebb2e72..a4fdcca944b 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/RpcContext.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/RpcContext.java @@ -616,6 +616,7 @@ public Future asyncCall(Callable callable) { //local invoke will return directly if (o != null) { FutureTask f = new FutureTask(new Callable() { + @Override public T call() throws Exception { return o; } @@ -632,22 +633,27 @@ public T call() throws Exception { } } catch (final RpcException e) { return new Future() { + @Override public boolean cancel(boolean mayInterruptIfRunning) { return false; } + @Override public boolean isCancelled() { return false; } + @Override public boolean isDone() { return true; } + @Override public T get() throws InterruptedException, ExecutionException { throw new ExecutionException(e.getCause()); } + @Override public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/RpcInvocation.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/RpcInvocation.java index 245644ed567..d04f88bb9ff 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/RpcInvocation.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/RpcInvocation.java @@ -104,6 +104,7 @@ public RpcInvocation(String methodName, Class[] parameterTypes, Object[] argu this.invoker = invoker; } + @Override public Invoker getInvoker() { return invoker; } @@ -112,6 +113,7 @@ public void setInvoker(Invoker invoker) { this.invoker = invoker; } + @Override public String getMethodName() { return methodName; } @@ -120,6 +122,7 @@ public void setMethodName(String methodName) { this.methodName = methodName; } + @Override public Class[] getParameterTypes() { return parameterTypes; } @@ -128,6 +131,7 @@ public void setParameterTypes(Class[] parameterTypes) { this.parameterTypes = parameterTypes == null ? new Class[0] : parameterTypes; } + @Override public Object[] getArguments() { return arguments; } @@ -136,6 +140,7 @@ public void setArguments(Object[] arguments) { this.arguments = arguments == null ? new Object[0] : arguments; } + @Override public Map getAttachments() { return attachments; } @@ -179,6 +184,7 @@ public void addAttachmentsIfAbsent(Map attachments) { } } + @Override public String getAttachment(String key) { if (attachments == null) { return null; @@ -186,6 +192,7 @@ public String getAttachment(String key) { return attachments.get(key); } + @Override public String getAttachment(String key, String defaultValue) { if (attachments == null) { return defaultValue; diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/RpcResult.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/RpcResult.java index 9a65d7068af..e42e6f867c9 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/RpcResult.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/RpcResult.java @@ -46,6 +46,7 @@ public RpcResult(Throwable exception) { this.exception = exception; } + @Override public Object recreate() throws Throwable { if (exception != null) { throw exception; @@ -57,6 +58,7 @@ public Object recreate() throws Throwable { * @see com.alibaba.dubbo.rpc.RpcResult#getValue() * @deprecated Replace to getValue() */ + @Override @Deprecated public Object getResult() { return getValue(); @@ -71,6 +73,7 @@ public void setResult(Object result) { setValue(result); } + @Override public Object getValue() { return result; } @@ -79,6 +82,7 @@ public void setValue(Object value) { this.result = value; } + @Override public Throwable getException() { return exception; } @@ -87,10 +91,12 @@ public void setException(Throwable e) { this.exception = e; } + @Override public boolean hasException() { return exception != null; } + @Override public Map getAttachments() { return attachments; } @@ -106,10 +112,12 @@ public void setAttachments(Map map) { } } + @Override public String getAttachment(String key) { return attachments.get(key); } + @Override public String getAttachment(String key, String defaultValue) { String result = attachments.get(key); if (result == null || result.length() == 0) { diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/AccessLogFilter.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/AccessLogFilter.java index 26513a7a11c..5494c59fcf5 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/AccessLogFilter.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/AccessLogFilter.java @@ -102,6 +102,7 @@ private void log(String accesslog, String logmessage) { } } + @Override public Result invoke(Invoker invoker, Invocation inv) throws RpcException { try { String accesslog = invoker.getUrl().getParameter(Constants.ACCESS_LOG_KEY); @@ -155,6 +156,7 @@ public Result invoke(Invoker invoker, Invocation inv) throws RpcException { } private class LogTask implements Runnable { + @Override public void run() { try { if (logQueue != null && logQueue.size() > 0) { diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/ActiveLimitFilter.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/ActiveLimitFilter.java index 4dfaf8ebd46..42d5ab4fe51 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/ActiveLimitFilter.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/ActiveLimitFilter.java @@ -32,6 +32,7 @@ @Activate(group = Constants.CONSUMER, value = Constants.ACTIVES_KEY) public class ActiveLimitFilter implements Filter { + @Override public Result invoke(Invoker invoker, Invocation invocation) throws RpcException { URL url = invoker.getUrl(); String methodName = invocation.getMethodName(); diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/ClassLoaderFilter.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/ClassLoaderFilter.java index 4d6bcc86982..144a90187f6 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/ClassLoaderFilter.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/ClassLoaderFilter.java @@ -30,6 +30,7 @@ @Activate(group = Constants.PROVIDER, order = -30000) public class ClassLoaderFilter implements Filter { + @Override public Result invoke(Invoker invoker, Invocation invocation) throws RpcException { ClassLoader ocl = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(invoker.getInterface().getClassLoader()); diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/CompatibleFilter.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/CompatibleFilter.java index 6ffb4dc3ad5..09cd1f638b7 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/CompatibleFilter.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/CompatibleFilter.java @@ -38,6 +38,7 @@ public class CompatibleFilter implements Filter { private static Logger logger = LoggerFactory.getLogger(CompatibleFilter.class); + @Override public Result invoke(Invoker invoker, Invocation invocation) throws RpcException { Result result = invoker.invoke(invocation); if (!invocation.getMethodName().startsWith("$") && !result.hasException()) { diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/ConsumerContextFilter.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/ConsumerContextFilter.java index 1c86a9b1f78..0d0a98a6e75 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/ConsumerContextFilter.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/ConsumerContextFilter.java @@ -33,6 +33,7 @@ @Activate(group = Constants.CONSUMER, order = -10000) public class ConsumerContextFilter implements Filter { + @Override public Result invoke(Invoker invoker, Invocation invocation) throws RpcException { RpcContext.getContext() .setInvoker(invoker) diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/ContextFilter.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/ContextFilter.java index ad53baf2879..2e81fed508a 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/ContextFilter.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/ContextFilter.java @@ -35,6 +35,7 @@ @Activate(group = Constants.PROVIDER, order = -10000) public class ContextFilter implements Filter { + @Override public Result invoke(Invoker invoker, Invocation invocation) throws RpcException { Map attachments = invocation.getAttachments(); if (attachments != null) { diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/DeprecatedFilter.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/DeprecatedFilter.java index e42fec299ee..9da266ba872 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/DeprecatedFilter.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/DeprecatedFilter.java @@ -39,6 +39,7 @@ public class DeprecatedFilter implements Filter { private static final Set logged = new ConcurrentHashSet(); + @Override public Result invoke(Invoker invoker, Invocation invocation) throws RpcException { String key = invoker.getInterface().getName() + "." + invocation.getMethodName(); if (!logged.contains(key)) { diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/EchoFilter.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/EchoFilter.java index 4ecec7fb2b3..6cddeda95f3 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/EchoFilter.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/EchoFilter.java @@ -31,6 +31,7 @@ @Activate(group = Constants.PROVIDER, order = -110000) public class EchoFilter implements Filter { + @Override public Result invoke(Invoker invoker, Invocation inv) throws RpcException { if (inv.getMethodName().equals(Constants.$ECHO) && inv.getArguments() != null && inv.getArguments().length == 1) return new RpcResult(inv.getArguments()[0]); diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/ExceptionFilter.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/ExceptionFilter.java index b84fb646482..185fa968180 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/ExceptionFilter.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/ExceptionFilter.java @@ -56,6 +56,7 @@ public ExceptionFilter(Logger logger) { this.logger = logger; } + @Override public Result invoke(Invoker invoker, Invocation invocation) throws RpcException { try { Result result = invoker.invoke(invocation); diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/ExecuteLimitFilter.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/ExecuteLimitFilter.java index 59e6ae51d1e..538d54b51ed 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/ExecuteLimitFilter.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/ExecuteLimitFilter.java @@ -34,6 +34,7 @@ @Activate(group = Constants.PROVIDER, value = Constants.EXECUTES_KEY) public class ExecuteLimitFilter implements Filter { + @Override public Result invoke(Invoker invoker, Invocation invocation) throws RpcException { URL url = invoker.getUrl(); String methodName = invocation.getMethodName(); diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/GenericFilter.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/GenericFilter.java index 231d74dfe56..2227221f678 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/GenericFilter.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/GenericFilter.java @@ -47,6 +47,7 @@ @Activate(group = Constants.PROVIDER, order = -20000) public class GenericFilter implements Filter { + @Override public Result invoke(Invoker invoker, Invocation inv) throws RpcException { if (inv.getMethodName().equals(Constants.$INVOKE) && inv.getArguments() != null diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/GenericImplFilter.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/GenericImplFilter.java index f79baa10710..c1b91f00a05 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/GenericImplFilter.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/GenericImplFilter.java @@ -49,6 +49,7 @@ public class GenericImplFilter implements Filter { private static final Class[] GENERIC_PARAMETER_TYPES = new Class[]{String.class, String[].class, Object[].class}; + @Override public Result invoke(Invoker invoker, Invocation invocation) throws RpcException { String generic = invoker.getUrl().getParameter(Constants.GENERIC_KEY); if (ProtocolUtils.isGeneric(generic) diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/TimeoutFilter.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/TimeoutFilter.java index 06ff3b9cb57..f4dcaac8110 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/TimeoutFilter.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/TimeoutFilter.java @@ -36,6 +36,7 @@ public class TimeoutFilter implements Filter { private static final Logger logger = LoggerFactory.getLogger(TimeoutFilter.class); + @Override public Result invoke(Invoker invoker, Invocation invocation) throws RpcException { long start = System.currentTimeMillis(); Result result = invoker.invoke(invocation); diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/TokenFilter.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/TokenFilter.java index 551a48e6b85..60e11067e66 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/TokenFilter.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/TokenFilter.java @@ -34,6 +34,7 @@ @Activate(group = Constants.PROVIDER, value = Constants.TOKEN_KEY) public class TokenFilter implements Filter { + @Override public Result invoke(Invoker invoker, Invocation inv) throws RpcException { String token = invoker.getUrl().getParameter(Constants.TOKEN_KEY); diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/TpsLimitFilter.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/TpsLimitFilter.java index 0b5eafcceeb..01e49a68d05 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/TpsLimitFilter.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/TpsLimitFilter.java @@ -35,6 +35,7 @@ public class TpsLimitFilter implements Filter { private final TPSLimiter tpsLimiter = new DefaultTPSLimiter(); + @Override public Result invoke(Invoker invoker, Invocation invocation) throws RpcException { if (!tpsLimiter.isAllowable(invoker.getUrl(), invocation)) { diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/tps/DefaultTPSLimiter.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/tps/DefaultTPSLimiter.java index ffec670603f..03890cb63c7 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/tps/DefaultTPSLimiter.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/tps/DefaultTPSLimiter.java @@ -28,6 +28,7 @@ public class DefaultTPSLimiter implements TPSLimiter { private final ConcurrentMap stats = new ConcurrentHashMap(); + @Override public boolean isAllowable(URL url, Invocation invocation) { int rate = url.getParameter(Constants.TPS_LIMIT_RATE_KEY, -1); long interval = url.getParameter(Constants.TPS_LIMIT_INTERVAL_KEY, diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/tps/StatItem.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/tps/StatItem.java index f1cc91acab3..d3b768f4538 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/tps/StatItem.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/tps/StatItem.java @@ -63,6 +63,7 @@ int getToken() { return token.get(); } + @Override public String toString() { return new StringBuilder(32).append("StatItem ") .append("[name=").append(name).append(", ") diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/listener/DeprecatedInvokerListener.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/listener/DeprecatedInvokerListener.java index c5af95de94a..62e17c8df6a 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/listener/DeprecatedInvokerListener.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/listener/DeprecatedInvokerListener.java @@ -31,6 +31,7 @@ public class DeprecatedInvokerListener extends InvokerListenerAdapter { private static final Logger LOGGER = LoggerFactory.getLogger(DeprecatedInvokerListener.class); + @Override public void referred(Invoker invoker) throws RpcException { if (invoker.getUrl().getParameter(Constants.DEPRECATED_KEY, false)) { LOGGER.error("The service " + invoker.getInterface().getName() + " is DEPRECATED! Declare from " + invoker.getUrl()); diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/listener/ExporterListenerAdapter.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/listener/ExporterListenerAdapter.java index b411a531aee..a8b4fb72fdb 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/listener/ExporterListenerAdapter.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/listener/ExporterListenerAdapter.java @@ -25,9 +25,11 @@ */ public abstract class ExporterListenerAdapter implements ExporterListener { + @Override public void exported(Exporter exporter) throws RpcException { } + @Override public void unexported(Exporter exporter) throws RpcException { } diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/listener/InvokerListenerAdapter.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/listener/InvokerListenerAdapter.java index 64c42565e0c..bc41b4345f1 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/listener/InvokerListenerAdapter.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/listener/InvokerListenerAdapter.java @@ -25,9 +25,11 @@ */ public abstract class InvokerListenerAdapter implements InvokerListener { + @Override public void referred(Invoker invoker) throws RpcException { } + @Override public void destroyed(Invoker invoker) { } diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/listener/ListenerExporterWrapper.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/listener/ListenerExporterWrapper.java index bd8f1e56c3a..1410df25538 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/listener/ListenerExporterWrapper.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/listener/ListenerExporterWrapper.java @@ -59,10 +59,12 @@ public ListenerExporterWrapper(Exporter exporter, List list } } + @Override public Invoker getInvoker() { return exporter.getInvoker(); } + @Override public void unexport() { try { exporter.unexport(); diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/listener/ListenerInvokerWrapper.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/listener/ListenerInvokerWrapper.java index 6c7785ce0c0..f585b2aed59 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/listener/ListenerInvokerWrapper.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/listener/ListenerInvokerWrapper.java @@ -57,18 +57,22 @@ public ListenerInvokerWrapper(Invoker invoker, List listener } } + @Override public Class getInterface() { return invoker.getInterface(); } + @Override public URL getUrl() { return invoker.getUrl(); } + @Override public boolean isAvailable() { return invoker.isAvailable(); } + @Override public Result invoke(Invocation invocation) throws RpcException { return invoker.invoke(invocation); } @@ -78,6 +82,7 @@ public String toString() { return getInterface() + " -> " + (getUrl() == null ? " " : getUrl().toString()); } + @Override public void destroy() { try { invoker.destroy(); diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/protocol/AbstractExporter.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/protocol/AbstractExporter.java index 668de9195c4..b9c2772f291 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/protocol/AbstractExporter.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/protocol/AbstractExporter.java @@ -42,10 +42,12 @@ public AbstractExporter(Invoker invoker) { this.invoker = invoker; } + @Override public Invoker getInvoker() { return invoker; } + @Override public void unexport() { if (unexported) { return; @@ -54,6 +56,7 @@ public void unexport() { getInvoker().destroy(); } + @Override public String toString() { return getInvoker().toString(); } diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/protocol/AbstractInvoker.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/protocol/AbstractInvoker.java index 533b5c8ee57..47a86be96d5 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/protocol/AbstractInvoker.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/protocol/AbstractInvoker.java @@ -86,14 +86,17 @@ private static Map convertAttachment(URL url, String[] keys) { return attachment; } + @Override public Class getInterface() { return type; } + @Override public URL getUrl() { return url; } + @Override public boolean isAvailable() { return available; } @@ -102,6 +105,7 @@ protected void setAvailable(boolean available) { this.available = available; } + @Override public void destroy() { if (!destroyed.compareAndSet(false, true)) { return; @@ -113,10 +117,12 @@ public boolean isDestroyed() { return destroyed.get(); } + @Override public String toString() { return getInterface() + " -> " + (getUrl() == null ? "" : getUrl().toString()); } + @Override public Result invoke(Invocation inv) throws RpcException { if (destroyed.get()) { throw new RpcException("Rpc invoker for service " + this + " on consumer " + NetUtils.getLocalHost() diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/protocol/AbstractProtocol.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/protocol/AbstractProtocol.java index 1dc01faa13a..5d139badfe7 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/protocol/AbstractProtocol.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/protocol/AbstractProtocol.java @@ -53,6 +53,7 @@ protected static String serviceKey(int port, String serviceName, String serviceV return ProtocolUtils.serviceKey(port, serviceName, serviceVersion, serviceGroup); } + @Override public void destroy() { for (Invoker invoker : invokers) { if (invoker != null) { diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/protocol/AbstractProxyProtocol.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/protocol/AbstractProxyProtocol.java index 9eb3d8f0de4..8136cc02165 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/protocol/AbstractProxyProtocol.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/protocol/AbstractProxyProtocol.java @@ -60,6 +60,7 @@ public void setProxyFactory(ProxyFactory proxyFactory) { this.proxyFactory = proxyFactory; } + @Override @SuppressWarnings("unchecked") public Exporter export(final Invoker invoker) throws RpcException { final String uri = serviceKey(invoker.getUrl()); @@ -69,6 +70,7 @@ public Exporter export(final Invoker invoker) throws RpcException { } final Runnable runnable = doExport(proxyFactory.getProxy(invoker), invoker.getInterface(), invoker.getUrl()); exporter = new AbstractExporter(invoker) { + @Override public void unexport() { super.unexport(); exporterMap.remove(uri); @@ -85,6 +87,7 @@ public void unexport() { return exporter; } + @Override public Invoker refer(final Class type, final URL url) throws RpcException { final Invoker tagert = proxyFactory.getInvoker(doRefer(type, url), type, url); Invoker invoker = new AbstractInvoker(type, url) { diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/protocol/InvokerWrapper.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/protocol/InvokerWrapper.java index 593d6f215d5..d7ac256d051 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/protocol/InvokerWrapper.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/protocol/InvokerWrapper.java @@ -36,22 +36,27 @@ public InvokerWrapper(Invoker invoker, URL url) { this.url = url; } + @Override public Class getInterface() { return invoker.getInterface(); } + @Override public URL getUrl() { return url; } + @Override public boolean isAvailable() { return invoker.isAvailable(); } + @Override public Result invoke(Invocation invocation) throws RpcException { return invoker.invoke(invocation); } + @Override public void destroy() { invoker.destroy(); } diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/protocol/ProtocolFilterWrapper.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/protocol/ProtocolFilterWrapper.java index 77653eef2ea..bf9faef1b1c 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/protocol/ProtocolFilterWrapper.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/protocol/ProtocolFilterWrapper.java @@ -52,22 +52,27 @@ private static Invoker buildInvokerChain(final Invoker invoker, String final Invoker next = last; last = new Invoker() { + @Override public Class getInterface() { return invoker.getInterface(); } + @Override public URL getUrl() { return invoker.getUrl(); } + @Override public boolean isAvailable() { return invoker.isAvailable(); } + @Override public Result invoke(Invocation invocation) throws RpcException { return filter.invoke(next, invocation); } + @Override public void destroy() { invoker.destroy(); } @@ -82,10 +87,12 @@ public String toString() { return last; } + @Override public int getDefaultPort() { return protocol.getDefaultPort(); } + @Override public Exporter export(Invoker invoker) throws RpcException { if (Constants.REGISTRY_PROTOCOL.equals(invoker.getUrl().getProtocol())) { return protocol.export(invoker); @@ -93,6 +100,7 @@ public Exporter export(Invoker invoker) throws RpcException { return protocol.export(buildInvokerChain(invoker, Constants.SERVICE_FILTER_KEY, Constants.PROVIDER)); } + @Override public Invoker refer(Class type, URL url) throws RpcException { if (Constants.REGISTRY_PROTOCOL.equals(url.getProtocol())) { return protocol.refer(type, url); @@ -100,6 +108,7 @@ public Invoker refer(Class type, URL url) throws RpcException { return buildInvokerChain(protocol.refer(type, url), Constants.REFERENCE_FILTER_KEY, Constants.CONSUMER); } + @Override public void destroy() { protocol.destroy(); } diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/protocol/ProtocolListenerWrapper.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/protocol/ProtocolListenerWrapper.java index 473ae871b1e..0ec2046f53a 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/protocol/ProtocolListenerWrapper.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/protocol/ProtocolListenerWrapper.java @@ -45,10 +45,12 @@ public ProtocolListenerWrapper(Protocol protocol) { this.protocol = protocol; } + @Override public int getDefaultPort() { return protocol.getDefaultPort(); } + @Override public Exporter export(Invoker invoker) throws RpcException { if (Constants.REGISTRY_PROTOCOL.equals(invoker.getUrl().getProtocol())) { return protocol.export(invoker); @@ -58,6 +60,7 @@ public Exporter export(Invoker invoker) throws RpcException { .getActivateExtension(invoker.getUrl(), Constants.EXPORTER_LISTENER_KEY))); } + @Override public Invoker refer(Class type, URL url) throws RpcException { if (Constants.REGISTRY_PROTOCOL.equals(url.getProtocol())) { return protocol.refer(type, url); @@ -68,6 +71,7 @@ public Invoker refer(Class type, URL url) throws RpcException { .getActivateExtension(url, Constants.INVOKER_LISTENER_KEY))); } + @Override public void destroy() { protocol.destroy(); } diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/proxy/AbstractProxyFactory.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/proxy/AbstractProxyFactory.java index 6540fe079ac..c69c8769952 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/proxy/AbstractProxyFactory.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/proxy/AbstractProxyFactory.java @@ -28,6 +28,7 @@ */ public abstract class AbstractProxyFactory implements ProxyFactory { + @Override public T getProxy(Invoker invoker) throws RpcException { Class[] interfaces = null; String config = invoker.getUrl().getParameter("interfaces"); diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/proxy/AbstractProxyInvoker.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/proxy/AbstractProxyInvoker.java index 966f739b5b2..26dfdafb013 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/proxy/AbstractProxyInvoker.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/proxy/AbstractProxyInvoker.java @@ -51,21 +51,26 @@ public AbstractProxyInvoker(T proxy, Class type, URL url) { this.url = url; } + @Override public Class getInterface() { return type; } + @Override public URL getUrl() { return url; } + @Override public boolean isAvailable() { return true; } + @Override public void destroy() { } + @Override public Result invoke(Invocation invocation) throws RpcException { try { return new RpcResult(doInvoke(proxy, invocation.getMethodName(), invocation.getParameterTypes(), invocation.getArguments())); diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/proxy/InvokerInvocationHandler.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/proxy/InvokerInvocationHandler.java index 75b5603ba0f..01760cc8328 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/proxy/InvokerInvocationHandler.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/proxy/InvokerInvocationHandler.java @@ -33,6 +33,7 @@ public InvokerInvocationHandler(Invoker handler) { this.invoker = handler; } + @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { String methodName = method.getName(); Class[] parameterTypes = method.getParameterTypes(); diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/proxy/javassist/JavassistProxyFactory.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/proxy/javassist/JavassistProxyFactory.java index da7df0e7ad9..3adc7717eba 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/proxy/javassist/JavassistProxyFactory.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/proxy/javassist/JavassistProxyFactory.java @@ -29,11 +29,13 @@ */ public class JavassistProxyFactory extends AbstractProxyFactory { + @Override @SuppressWarnings("unchecked") public T getProxy(Invoker invoker, Class[] interfaces) { return (T) Proxy.getProxy(interfaces).newInstance(new InvokerInvocationHandler(invoker)); } + @Override public Invoker getInvoker(T proxy, Class type, URL url) { // TODO Wrapper cannot handle this scenario correctly: the classname contains '$' final Wrapper wrapper = Wrapper.getWrapper(proxy.getClass().getName().indexOf('$') < 0 ? proxy.getClass() : type); diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/proxy/jdk/JdkProxyFactory.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/proxy/jdk/JdkProxyFactory.java index 0608979d613..d61592b9417 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/proxy/jdk/JdkProxyFactory.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/proxy/jdk/JdkProxyFactory.java @@ -30,11 +30,13 @@ */ public class JdkProxyFactory extends AbstractProxyFactory { + @Override @SuppressWarnings("unchecked") public T getProxy(Invoker invoker, Class[] interfaces) { return (T) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), interfaces, new InvokerInvocationHandler(invoker)); } + @Override public Invoker getInvoker(T proxy, Class type, URL url) { return new AbstractProxyInvoker(proxy, type, url) { @Override diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/proxy/wrapper/StubProxyFactoryWrapper.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/proxy/wrapper/StubProxyFactoryWrapper.java index 68128edb397..33d9d34056f 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/proxy/wrapper/StubProxyFactoryWrapper.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/proxy/wrapper/StubProxyFactoryWrapper.java @@ -54,6 +54,7 @@ public void setProtocol(Protocol protocol) { this.protocol = protocol; } + @Override @SuppressWarnings({"unchecked", "rawtypes"}) public T getProxy(Invoker invoker) throws RpcException { T proxy = proxyFactory.getProxy(invoker); @@ -99,6 +100,7 @@ public T getProxy(Invoker invoker) throws RpcException { return proxy; } + @Override public Invoker getInvoker(T proxy, Class type, URL url) throws RpcException { return proxyFactory.getInvoker(proxy, type, url); } diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/support/DelegateExporter.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/support/DelegateExporter.java index fd9b2fdb9a8..14be9ea958b 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/support/DelegateExporter.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/support/DelegateExporter.java @@ -35,10 +35,12 @@ public DelegateExporter(Exporter exporter) { } + @Override public Invoker getInvoker() { return exporter.getInvoker(); } + @Override public void unexport() { exporter.unexport(); } diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/support/DelegateInvoker.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/support/DelegateInvoker.java index ffd16f4b8a7..97060a8f389 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/support/DelegateInvoker.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/support/DelegateInvoker.java @@ -33,22 +33,27 @@ public DelegateInvoker(Invoker invoker) { this.invoker = invoker; } + @Override public Class getInterface() { return invoker.getInterface(); } + @Override public URL getUrl() { return invoker.getUrl(); } + @Override public boolean isAvailable() { return invoker.isAvailable(); } + @Override public Result invoke(Invocation invocation) throws RpcException { return invoker.invoke(invocation); } + @Override public void destroy() { invoker.destroy(); } diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/support/MockInvoker.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/support/MockInvoker.java index f572ad0f165..77797bf302f 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/support/MockInvoker.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/support/MockInvoker.java @@ -83,6 +83,7 @@ public static Object parseMockValue(String mock, Type[] returnTypes) throws Exce return value; } + @Override public Result invoke(Invocation invocation) throws RpcException { String mock = getUrl().getParameter(invocation.getMethodName() + "." + Constants.MOCK_KEY); if (invocation instanceof RpcInvocation) { @@ -201,18 +202,22 @@ private String normallizeMock(String mock) { return mock; } + @Override public URL getUrl() { return this.url; } + @Override public boolean isAvailable() { return true; } + @Override public void destroy() { //do nothing } + @Override public Class getInterface() { //FIXME return null; diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/support/MockProtocol.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/support/MockProtocol.java index 7a884e71f77..aec5586bfb1 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/support/MockProtocol.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/support/MockProtocol.java @@ -27,14 +27,17 @@ */ final public class MockProtocol extends AbstractProtocol { + @Override public int getDefaultPort() { return 0; } + @Override public Exporter export(Invoker invoker) throws RpcException { throw new UnsupportedOperationException(); } + @Override public Invoker refer(Class type, URL url) throws RpcException { return new MockInvoker(url); } diff --git a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/ChannelWrappedInvoker.java b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/ChannelWrappedInvoker.java index bd60b3ec6d5..05820e0f70c 100644 --- a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/ChannelWrappedInvoker.java +++ b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/ChannelWrappedInvoker.java @@ -79,6 +79,7 @@ protected Result doInvoke(Invocation invocation) throws Throwable { } } + @Override public void destroy() { // super.destroy(); // try { @@ -98,62 +99,77 @@ public static class ChannelWrapper extends ClientDelegate { this.url = channel.getUrl().addParameter("codec", DubboCodec.NAME); } + @Override public URL getUrl() { return url; } + @Override public ChannelHandler getChannelHandler() { return channel.getChannelHandler(); } + @Override public InetSocketAddress getLocalAddress() { return channel.getLocalAddress(); } + @Override public void close() { channel.close(); } + @Override public boolean isClosed() { return channel == null || channel.isClosed(); } + @Override public void reset(URL url) { throw new RpcException("ChannelInvoker can not reset."); } + @Override public InetSocketAddress getRemoteAddress() { return channel.getLocalAddress(); } + @Override public boolean isConnected() { return channel != null && channel.isConnected(); } + @Override public boolean hasAttribute(String key) { return channel.hasAttribute(key); } + @Override public Object getAttribute(String key) { return channel.getAttribute(key); } + @Override public void setAttribute(String key, Object value) { channel.setAttribute(key, value); } + @Override public void removeAttribute(String key) { channel.removeAttribute(key); } + @Override public void reconnect() throws RemotingException { } + @Override public void send(Object message) throws RemotingException { channel.send(message); } + @Override public void send(Object message, boolean sent) throws RemotingException { channel.send(message, sent); } diff --git a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/DecodeableRpcInvocation.java b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/DecodeableRpcInvocation.java index 23e3d796828..7fdaf83fd34 100644 --- a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/DecodeableRpcInvocation.java +++ b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/DecodeableRpcInvocation.java @@ -63,6 +63,7 @@ public DecodeableRpcInvocation(Channel channel, Request request, InputStream is, this.serializationType = id; } + @Override public void decode() throws Exception { if (!hasDecoded && channel != null && inputStream != null) { try { @@ -79,10 +80,12 @@ public void decode() throws Exception { } } + @Override public void encode(Channel channel, OutputStream output, Object message) throws IOException { throw new UnsupportedOperationException(); } + @Override public Object decode(Channel channel, InputStream input) throws IOException { ObjectInput in = CodecSupport.getSerialization(channel.getUrl(), serializationType) .deserialize(channel.getUrl(), input); diff --git a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/DecodeableRpcResult.java b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/DecodeableRpcResult.java index 75ef0ac55f8..9e84e88e707 100644 --- a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/DecodeableRpcResult.java +++ b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/DecodeableRpcResult.java @@ -63,10 +63,12 @@ public DecodeableRpcResult(Channel channel, Response response, InputStream is, I this.serializationType = id; } + @Override public void encode(Channel channel, OutputStream output, Object message) throws IOException { throw new UnsupportedOperationException(); } + @Override public Object decode(Channel channel, InputStream input) throws IOException { ObjectInput in = CodecSupport.getSerialization(channel.getUrl(), serializationType) .deserialize(channel.getUrl(), input); @@ -104,6 +106,7 @@ public Object decode(Channel channel, InputStream input) throws IOException { return this; } + @Override public void decode() throws Exception { if (!hasDecoded && channel != null && inputStream != null) { try { diff --git a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/DubboCodec.java b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/DubboCodec.java index 012051cbc43..d4bb55e7dae 100644 --- a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/DubboCodec.java +++ b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/DubboCodec.java @@ -57,6 +57,7 @@ public class DubboCodec extends ExchangeCodec implements Codec2 { public static final Class[] EMPTY_CLASS_ARRAY = new Class[0]; private static final Logger log = LoggerFactory.getLogger(DubboCodec.class); + @Override protected Object decodeBody(Channel channel, InputStream is, byte[] header) throws IOException { byte flag = header[2], proto = (byte) (flag & SERIALIZATION_MASK); Serialization s = CodecSupport.getSerialization(channel.getUrl(), proto); diff --git a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/DubboCountCodec.java b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/DubboCountCodec.java index 159dbfda545..6305f97619c 100644 --- a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/DubboCountCodec.java +++ b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/DubboCountCodec.java @@ -33,10 +33,12 @@ public final class DubboCountCodec implements Codec2 { private DubboCodec codec = new DubboCodec(); + @Override public void encode(Channel channel, ChannelBuffer buffer, Object msg) throws IOException { codec.encode(channel, buffer, msg); } + @Override public Object decode(Channel channel, ChannelBuffer buffer) throws IOException { int save = buffer.readerIndex(); MultiMessage result = MultiMessage.create(); diff --git a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/DubboInvoker.java b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/DubboInvoker.java index a5624fd76c0..843b5d9e382 100644 --- a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/DubboInvoker.java +++ b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/DubboInvoker.java @@ -114,6 +114,7 @@ public boolean isAvailable() { return false; } + @Override public void destroy() { // in order to avoid closing a client multiple times, a counter is used in case of connection per jvm, every // time when client.close() is called, counter counts down once, and when counter reaches zero, client will be diff --git a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/DubboProtocol.java b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/DubboProtocol.java index e30a50f9cd3..5c75b5dd3af 100644 --- a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/DubboProtocol.java +++ b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/DubboProtocol.java @@ -71,6 +71,7 @@ public class DubboProtocol extends AbstractProtocol { private final ConcurrentMap stubServiceMethodsMap = new ConcurrentHashMap(); private ExchangeHandler requestHandler = new ExchangeHandlerAdapter() { + @Override public Object reply(ExchangeChannel channel, Object message) throws RemotingException { if (message instanceof Invocation) { Invocation inv = (Invocation) message; @@ -217,10 +218,12 @@ public Collection> getInvokers() { return Collections.unmodifiableCollection(invokers); } + @Override public int getDefaultPort() { return DEFAULT_PORT; } + @Override public Exporter export(Invoker invoker) throws RpcException { URL url = invoker.getUrl(); @@ -326,6 +329,7 @@ private void optimizeSerialization(URL url) throws RpcException { } } + @Override public Invoker refer(Class serviceType, URL url) throws RpcException { optimizeSerialization(url); // create rpc invoker. @@ -410,6 +414,7 @@ private ExchangeClient initClient(URL url) { return client; } + @Override public void destroy() { for (String key : new ArrayList(serverMap.keySet())) { ExchangeServer server = serverMap.remove(key); diff --git a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/FutureAdapter.java b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/FutureAdapter.java index 66cdc2f6fd6..b8a1d8bb16a 100644 --- a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/FutureAdapter.java +++ b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/FutureAdapter.java @@ -42,18 +42,22 @@ public ResponseFuture getFuture() { return future; } + @Override public boolean cancel(boolean mayInterruptIfRunning) { return false; } + @Override public boolean isCancelled() { return false; } + @Override public boolean isDone() { return future.isDone(); } + @Override @SuppressWarnings("unchecked") public V get() throws InterruptedException, ExecutionException { try { @@ -65,6 +69,7 @@ public V get() throws InterruptedException, ExecutionException { } } + @Override @SuppressWarnings("unchecked") public V get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { int timeoutInMillis = (int) TimeUnit.MILLISECONDS.convert(timeout, unit); diff --git a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/LazyConnectExchangeClient.java b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/LazyConnectExchangeClient.java index 9a79207c367..a9f8bc40f90 100644 --- a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/LazyConnectExchangeClient.java +++ b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/LazyConnectExchangeClient.java @@ -77,16 +77,19 @@ private void initClient() throws RemotingException { } } + @Override public ResponseFuture request(Object request) throws RemotingException { warning(request); initClient(); return client.request(request); } + @Override public URL getUrl() { return url; } + @Override public InetSocketAddress getRemoteAddress() { if (client == null) { return InetSocketAddress.createUnresolved(url.getHost(), url.getPort()); @@ -95,6 +98,7 @@ public InetSocketAddress getRemoteAddress() { } } + @Override public ResponseFuture request(Object request, int timeout) throws RemotingException { warning(request); initClient(); @@ -115,11 +119,13 @@ private void warning(Object request) { } } + @Override public ChannelHandler getChannelHandler() { checkClient(); return client.getChannelHandler(); } + @Override public boolean isConnected() { if (client == null) { return initialState; @@ -128,6 +134,7 @@ public boolean isConnected() { } } + @Override public InetSocketAddress getLocalAddress() { if (client == null) { return InetSocketAddress.createUnresolved(NetUtils.getLocalHost(), 0); @@ -136,20 +143,24 @@ public InetSocketAddress getLocalAddress() { } } + @Override public ExchangeHandler getExchangeHandler() { return requestHandler; } + @Override public void send(Object message) throws RemotingException { initClient(); client.send(message); } + @Override public void send(Object message, boolean sent) throws RemotingException { initClient(); client.send(message, sent); } + @Override public boolean isClosed() { if (client != null) return client.isClosed(); @@ -157,11 +168,13 @@ public boolean isClosed() { return true; } + @Override public void close() { if (client != null) client.close(); } + @Override public void close(int timeout) { if (client != null) client.close(timeout); @@ -174,21 +187,25 @@ public void startClose() { } } + @Override public void reset(URL url) { checkClient(); client.reset(url); } + @Override @Deprecated public void reset(Parameters parameters) { reset(getUrl().addParameters(parameters.getParameters())); } + @Override public void reconnect() throws RemotingException { checkClient(); client.reconnect(); } + @Override public Object getAttribute(String key) { if (client == null) { return null; @@ -197,16 +214,19 @@ public Object getAttribute(String key) { } } + @Override public void setAttribute(String key, Object value) { checkClient(); client.setAttribute(key, value); } + @Override public void removeAttribute(String key) { checkClient(); client.removeAttribute(key); } + @Override public boolean hasAttribute(String key) { if (client == null) { return false; diff --git a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/ReferenceCountExchangeClient.java b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/ReferenceCountExchangeClient.java index b030c67f0bd..b25d76e66f2 100644 --- a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/ReferenceCountExchangeClient.java +++ b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/ReferenceCountExchangeClient.java @@ -53,70 +53,87 @@ public ReferenceCountExchangeClient(ExchangeClient client, ConcurrentMap invoker, final Invocation invocation) throws RpcException { final boolean isAsync = RpcUtils.isAsync(invoker.getUrl(), invocation); @@ -72,6 +73,7 @@ private void asyncCallback(final Invoker invoker, final Invocation invocation if (f instanceof FutureAdapter) { ResponseFuture future = ((FutureAdapter) f).getFuture(); future.setCallback(new ResponseCallback() { + @Override public void done(Object rpcResult) { if (rpcResult == null) { logger.error(new IllegalStateException("invalid result value : null, expected " + Result.class.getName())); @@ -90,6 +92,7 @@ public void done(Object rpcResult) { } } + @Override public void caught(Throwable exception) { fireThrowCallback(invoker, invocation, exception); } diff --git a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/filter/TraceFilter.java b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/filter/TraceFilter.java index 043ff034ba4..145621d5196 100644 --- a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/filter/TraceFilter.java +++ b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/filter/TraceFilter.java @@ -72,6 +72,7 @@ public static void removeTracer(Class type, String method, Channel channel) { } } + @Override public Result invoke(Invoker invoker, Invocation invocation) throws RpcException { long start = System.currentTimeMillis(); Result result = invoker.invoke(invocation); diff --git a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/status/ServerStatusChecker.java b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/status/ServerStatusChecker.java index 90d552e8c96..6e2caab2681 100644 --- a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/status/ServerStatusChecker.java +++ b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/status/ServerStatusChecker.java @@ -30,6 +30,7 @@ @Activate public class ServerStatusChecker implements StatusChecker { + @Override public Status check() { Collection servers = DubboProtocol.getDubboProtocol().getServers(); if (servers == null || servers.isEmpty()) { diff --git a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/status/ThreadPoolStatusChecker.java b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/status/ThreadPoolStatusChecker.java index bf299a7e9f4..9eb108697d5 100644 --- a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/status/ThreadPoolStatusChecker.java +++ b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/status/ThreadPoolStatusChecker.java @@ -33,6 +33,7 @@ @Activate public class ThreadPoolStatusChecker implements StatusChecker { + @Override public Status check() { DataStore dataStore = ExtensionLoader.getExtensionLoader(DataStore.class).getDefaultExtension(); Map executors = dataStore.get(Constants.EXECUTOR_SERVICE_COMPONENT_KEY); diff --git a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/ChangeTelnetHandler.java b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/ChangeTelnetHandler.java index 7e2c7a96940..f597062e3f5 100644 --- a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/ChangeTelnetHandler.java +++ b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/ChangeTelnetHandler.java @@ -32,6 +32,7 @@ public class ChangeTelnetHandler implements TelnetHandler { public static final String SERVICE_KEY = "telnet.service"; + @Override public String telnet(Channel channel, String message) { if (message == null || message.length() == 0) { return "Please input service name, eg: \r\ncd XxxService\r\ncd com.xxx.XxxService"; diff --git a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/CountTelnetHandler.java b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/CountTelnetHandler.java index 2fd1b6aa2fb..2b4b38d419d 100644 --- a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/CountTelnetHandler.java +++ b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/CountTelnetHandler.java @@ -40,6 +40,7 @@ @Help(parameter = "[service] [method] [times]", summary = "Count the service.", detail = "Count the service.") public class CountTelnetHandler implements TelnetHandler { + @Override public String telnet(final Channel channel, String message) { String service = (String) channel.getAttribute(ChangeTelnetHandler.SERVICE_KEY); if ((service == null || service.length() == 0) @@ -84,6 +85,7 @@ public String telnet(final Channel channel, String message) { final Invoker inv = invoker; final String prompt = channel.getUrl().getParameter("prompt", "telnet"); Thread thread = new Thread(new Runnable() { + @Override public void run() { for (int i = 0; i < t; i++) { String result = count(inv, mtd); diff --git a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/CurrentTelnetHandler.java b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/CurrentTelnetHandler.java index 3bb8a9bab6e..ead8d8069cc 100644 --- a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/CurrentTelnetHandler.java +++ b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/CurrentTelnetHandler.java @@ -28,6 +28,7 @@ @Help(parameter = "", summary = "Print working default service.", detail = "Print working default service.") public class CurrentTelnetHandler implements TelnetHandler { + @Override public String telnet(Channel channel, String message) { if (message.length() > 0) { return "Unsupported parameter " + message + " for pwd."; diff --git a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/InvokeTelnetHandler.java b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/InvokeTelnetHandler.java index fdff3f0cbbc..b10328a75fe 100644 --- a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/InvokeTelnetHandler.java +++ b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/InvokeTelnetHandler.java @@ -86,6 +86,7 @@ private static boolean isMatch(Class[] types, List args) { return true; } + @Override @SuppressWarnings("unchecked") public String telnet(Channel channel, String message) { if (message == null || message.length() == 0) { diff --git a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/ListTelnetHandler.java b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/ListTelnetHandler.java index 5d00c22d368..45a76eba5e5 100644 --- a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/ListTelnetHandler.java +++ b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/ListTelnetHandler.java @@ -34,6 +34,7 @@ @Help(parameter = "[-l] [service]", summary = "List services and methods.", detail = "List services and methods.") public class ListTelnetHandler implements TelnetHandler { + @Override public String telnet(Channel channel, String message) { StringBuilder buf = new StringBuilder(); String service = null; diff --git a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/LogTelnetHandler.java b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/LogTelnetHandler.java index b20f66a2b4d..14fa05ccab8 100644 --- a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/LogTelnetHandler.java +++ b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/LogTelnetHandler.java @@ -41,6 +41,7 @@ public class LogTelnetHandler implements TelnetHandler { public static final String SERVICE_KEY = "telnet.log"; + @Override public String telnet(Channel channel, String message) { long size = 0; File file = LoggerFactory.getFile(); diff --git a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/PortTelnetHandler.java b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/PortTelnetHandler.java index 24370248c81..1d05ec7c154 100644 --- a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/PortTelnetHandler.java +++ b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/PortTelnetHandler.java @@ -34,6 +34,7 @@ @Help(parameter = "[-l] [port]", summary = "Print server ports and connections.", detail = "Print server ports and connections.") public class PortTelnetHandler implements TelnetHandler { + @Override public String telnet(Channel channel, String message) { StringBuilder buf = new StringBuilder(); String port = null; diff --git a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/TraceTelnetHandler.java b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/TraceTelnetHandler.java index 651fbeb0482..df9b5307dc8 100644 --- a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/TraceTelnetHandler.java +++ b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/TraceTelnetHandler.java @@ -35,6 +35,7 @@ @Help(parameter = "[service] [method] [times]", summary = "Trace the service.", detail = "Trace the service.") public class TraceTelnetHandler implements TelnetHandler { + @Override public String telnet(Channel channel, String message) { String service = (String) channel.getAttribute(ChangeTelnetHandler.SERVICE_KEY); if ((service == null || service.length() == 0) diff --git a/dubbo-rpc/dubbo-rpc-hessian/src/main/java/com/alibaba/dubbo/rpc/protocol/hessian/HessianProtocol.java b/dubbo-rpc/dubbo-rpc-hessian/src/main/java/com/alibaba/dubbo/rpc/protocol/hessian/HessianProtocol.java index 607ac5ed524..f1eae5cf63c 100644 --- a/dubbo-rpc/dubbo-rpc-hessian/src/main/java/com/alibaba/dubbo/rpc/protocol/hessian/HessianProtocol.java +++ b/dubbo-rpc/dubbo-rpc-hessian/src/main/java/com/alibaba/dubbo/rpc/protocol/hessian/HessianProtocol.java @@ -59,10 +59,12 @@ public void setHttpBinder(HttpBinder httpBinder) { this.httpBinder = httpBinder; } + @Override public int getDefaultPort() { return 80; } + @Override protected Runnable doExport(T impl, Class type, URL url) throws RpcException { String addr = getAddr(url); HttpServer server = serverMap.get(addr); @@ -74,12 +76,14 @@ protected Runnable doExport(T impl, Class type, URL url) throws RpcExcept HessianSkeleton skeleton = new HessianSkeleton(impl, type); skeletonMap.put(path, skeleton); return new Runnable() { + @Override public void run() { skeletonMap.remove(path); } }; } + @Override @SuppressWarnings("unchecked") protected T doRefer(Class serviceType, URL url) throws RpcException { HessianProxyFactory hessianProxyFactory = new HessianProxyFactory(); @@ -99,6 +103,7 @@ protected T doRefer(Class serviceType, URL url) throws RpcException { return (T) hessianProxyFactory.create(serviceType, url.setProtocol("http").toJavaURL(), Thread.currentThread().getContextClassLoader()); } + @Override protected int getErrorCode(Throwable e) { if (e instanceof HessianConnectionException) { if (e.getCause() != null) { @@ -114,6 +119,7 @@ protected int getErrorCode(Throwable e) { return super.getErrorCode(e); } + @Override public void destroy() { super.destroy(); for (String key : new ArrayList(serverMap.keySet())) { @@ -133,6 +139,7 @@ public void destroy() { private class HessianHandler implements HttpHandler { + @Override public void handle(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { String uri = request.getRequestURI(); diff --git a/dubbo-rpc/dubbo-rpc-hessian/src/main/java/com/alibaba/dubbo/rpc/protocol/hessian/HttpClientConnection.java b/dubbo-rpc/dubbo-rpc-hessian/src/main/java/com/alibaba/dubbo/rpc/protocol/hessian/HttpClientConnection.java index 52ac3f5d9bf..cccb54919c8 100644 --- a/dubbo-rpc/dubbo-rpc-hessian/src/main/java/com/alibaba/dubbo/rpc/protocol/hessian/HttpClientConnection.java +++ b/dubbo-rpc/dubbo-rpc-hessian/src/main/java/com/alibaba/dubbo/rpc/protocol/hessian/HttpClientConnection.java @@ -48,35 +48,43 @@ public HttpClientConnection(HttpClient httpClient, URL url) { this.request = new HttpPost(url.toString()); } + @Override public void addHeader(String key, String value) { request.addHeader(new BasicHeader(key, value)); } + @Override public OutputStream getOutputStream() throws IOException { return output; } + @Override public void sendRequest() throws IOException { request.setEntity(new ByteArrayEntity(output.toByteArray())); this.response = httpClient.execute(request); } + @Override public int getStatusCode() { return response == null || response.getStatusLine() == null ? 0 : response.getStatusLine().getStatusCode(); } + @Override public String getStatusMessage() { return response == null || response.getStatusLine() == null ? null : response.getStatusLine().getReasonPhrase(); } + @Override public String getContentEncoding() { return (response == null || response.getEntity() == null || response.getEntity().getContentEncoding() == null) ? null : response.getEntity().getContentEncoding().getValue(); } + @Override public InputStream getInputStream() throws IOException { return response == null || response.getEntity() == null ? null : response.getEntity().getContent(); } + @Override public void close() throws IOException { HttpPost request = this.request; if (request != null) { @@ -84,6 +92,7 @@ public void close() throws IOException { } } + @Override public void destroy() throws IOException { } diff --git a/dubbo-rpc/dubbo-rpc-hessian/src/main/java/com/alibaba/dubbo/rpc/protocol/hessian/HttpClientConnectionFactory.java b/dubbo-rpc/dubbo-rpc-hessian/src/main/java/com/alibaba/dubbo/rpc/protocol/hessian/HttpClientConnectionFactory.java index 7a366e589fd..ffdc3b36312 100644 --- a/dubbo-rpc/dubbo-rpc-hessian/src/main/java/com/alibaba/dubbo/rpc/protocol/hessian/HttpClientConnectionFactory.java +++ b/dubbo-rpc/dubbo-rpc-hessian/src/main/java/com/alibaba/dubbo/rpc/protocol/hessian/HttpClientConnectionFactory.java @@ -33,11 +33,13 @@ public class HttpClientConnectionFactory implements HessianConnectionFactory { private final HttpClient httpClient = new DefaultHttpClient(); + @Override public void setHessianProxyFactory(HessianProxyFactory factory) { HttpConnectionParams.setConnectionTimeout(httpClient.getParams(), (int) factory.getConnectTimeout()); HttpConnectionParams.setSoTimeout(httpClient.getParams(), (int) factory.getReadTimeout()); } + @Override public HessianConnection open(URL url) throws IOException { return new HttpClientConnection(httpClient, url); } diff --git a/dubbo-rpc/dubbo-rpc-http/src/main/java/com/alibaba/dubbo/rpc/protocol/http/HttpProtocol.java b/dubbo-rpc/dubbo-rpc-http/src/main/java/com/alibaba/dubbo/rpc/protocol/http/HttpProtocol.java index 5593c7ae83d..d6b4537f404 100644 --- a/dubbo-rpc/dubbo-rpc-http/src/main/java/com/alibaba/dubbo/rpc/protocol/http/HttpProtocol.java +++ b/dubbo-rpc/dubbo-rpc-http/src/main/java/com/alibaba/dubbo/rpc/protocol/http/HttpProtocol.java @@ -61,10 +61,12 @@ public void setHttpBinder(HttpBinder httpBinder) { this.httpBinder = httpBinder; } + @Override public int getDefaultPort() { return DEFAULT_PORT; } + @Override protected Runnable doExport(final T impl, Class type, URL url) throws RpcException { String addr = getAddr(url); HttpServer server = serverMap.get(addr); @@ -83,12 +85,14 @@ protected Runnable doExport(final T impl, Class type, URL url) throws Rpc final String path = url.getAbsolutePath(); skeletonMap.put(path, httpServiceExporter); return new Runnable() { + @Override public void run() { skeletonMap.remove(path); } }; } + @Override @SuppressWarnings("unchecked") protected T doRefer(final Class serviceType, final URL url) throws RpcException { final HttpInvokerProxyFactoryBean httpProxyFactoryBean = new HttpInvokerProxyFactoryBean(); @@ -97,6 +101,7 @@ protected T doRefer(final Class serviceType, final URL url) throws RpcExc String client = url.getParameter(Constants.CLIENT_KEY); if (client == null || client.length() == 0 || "simple".equals(client)) { SimpleHttpInvokerRequestExecutor httpInvokerRequestExecutor = new SimpleHttpInvokerRequestExecutor() { + @Override protected void prepareConnection(HttpURLConnection con, int contentLength) throws IOException { super.prepareConnection(con, contentLength); @@ -116,6 +121,7 @@ protected void prepareConnection(HttpURLConnection con, return (T) httpProxyFactoryBean.getObject(); } + @Override protected int getErrorCode(Throwable e) { if (e instanceof RemoteAccessException) { e = e.getCause(); @@ -135,6 +141,7 @@ protected int getErrorCode(Throwable e) { private class InternalHandler implements HttpHandler { + @Override public void handle(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { String uri = request.getRequestURI(); diff --git a/dubbo-rpc/dubbo-rpc-injvm/src/main/java/com/alibaba/dubbo/rpc/protocol/injvm/InjvmExporter.java b/dubbo-rpc/dubbo-rpc-injvm/src/main/java/com/alibaba/dubbo/rpc/protocol/injvm/InjvmExporter.java index b3497546434..2118c07eb0f 100644 --- a/dubbo-rpc/dubbo-rpc-injvm/src/main/java/com/alibaba/dubbo/rpc/protocol/injvm/InjvmExporter.java +++ b/dubbo-rpc/dubbo-rpc-injvm/src/main/java/com/alibaba/dubbo/rpc/protocol/injvm/InjvmExporter.java @@ -38,6 +38,7 @@ class InjvmExporter extends AbstractExporter { exporterMap.put(key, this); } + @Override public void unexport() { super.unexport(); exporterMap.remove(key); diff --git a/dubbo-rpc/dubbo-rpc-injvm/src/main/java/com/alibaba/dubbo/rpc/protocol/injvm/InjvmInvoker.java b/dubbo-rpc/dubbo-rpc-injvm/src/main/java/com/alibaba/dubbo/rpc/protocol/injvm/InjvmInvoker.java index 952135f4f67..dcd80e183de 100644 --- a/dubbo-rpc/dubbo-rpc-injvm/src/main/java/com/alibaba/dubbo/rpc/protocol/injvm/InjvmInvoker.java +++ b/dubbo-rpc/dubbo-rpc-injvm/src/main/java/com/alibaba/dubbo/rpc/protocol/injvm/InjvmInvoker.java @@ -52,6 +52,7 @@ public boolean isAvailable() { } } + @Override public Result doInvoke(Invocation invocation) throws Throwable { Exporter exporter = InjvmProtocol.getExporter(exporterMap, getUrl()); if (exporter == null) { diff --git a/dubbo-rpc/dubbo-rpc-injvm/src/main/java/com/alibaba/dubbo/rpc/protocol/injvm/InjvmProtocol.java b/dubbo-rpc/dubbo-rpc-injvm/src/main/java/com/alibaba/dubbo/rpc/protocol/injvm/InjvmProtocol.java index d9b0818a834..76a037ae5fb 100644 --- a/dubbo-rpc/dubbo-rpc-injvm/src/main/java/com/alibaba/dubbo/rpc/protocol/injvm/InjvmProtocol.java +++ b/dubbo-rpc/dubbo-rpc-injvm/src/main/java/com/alibaba/dubbo/rpc/protocol/injvm/InjvmProtocol.java @@ -76,14 +76,17 @@ static Exporter getExporter(Map> map, URL key) { } } + @Override public int getDefaultPort() { return DEFAULT_PORT; } + @Override public Exporter export(Invoker invoker) throws RpcException { return new InjvmExporter(invoker, invoker.getUrl().getServiceKey(), exporterMap); } + @Override public Invoker refer(Class serviceType, URL url) throws RpcException { return new InjvmInvoker(serviceType, url, url.getServiceKey(), exporterMap); } diff --git a/dubbo-rpc/dubbo-rpc-memcached/src/main/java/com/alibaba/dubbo/rpc/protocol/memcached/MemcachedProtocol.java b/dubbo-rpc/dubbo-rpc-memcached/src/main/java/com/alibaba/dubbo/rpc/protocol/memcached/MemcachedProtocol.java index ff0bc9702d8..6cf4737e7a0 100644 --- a/dubbo-rpc/dubbo-rpc-memcached/src/main/java/com/alibaba/dubbo/rpc/protocol/memcached/MemcachedProtocol.java +++ b/dubbo-rpc/dubbo-rpc-memcached/src/main/java/com/alibaba/dubbo/rpc/protocol/memcached/MemcachedProtocol.java @@ -45,14 +45,17 @@ public class MemcachedProtocol extends AbstractProtocol { public static final int DEFAULT_PORT = 11211; + @Override public int getDefaultPort() { return DEFAULT_PORT; } + @Override public Exporter export(final Invoker invoker) throws RpcException { throw new UnsupportedOperationException("Unsupported export memcached service. url: " + invoker.getUrl()); } + @Override public Invoker refer(final Class type, final URL url) throws RpcException { try { String address = url.getAddress(); @@ -67,6 +70,7 @@ public Invoker refer(final Class type, final URL url) throws RpcExcept final String set = url.getParameter("set", Map.class.equals(type) ? "put" : "set"); final String delete = url.getParameter("delete", Map.class.equals(type) ? "remove" : "delete"); return new AbstractInvoker(type, url) { + @Override protected Result doInvoke(Invocation invocation) throws Throwable { try { if (get.equals(invocation.getMethodName())) { @@ -100,6 +104,7 @@ protected Result doInvoke(Invocation invocation) throws Throwable { } } + @Override public void destroy() { super.destroy(); try { diff --git a/dubbo-rpc/dubbo-rpc-redis/src/main/java/com/alibaba/dubbo/rpc/protocol/redis/RedisProtocol.java b/dubbo-rpc/dubbo-rpc-redis/src/main/java/com/alibaba/dubbo/rpc/protocol/redis/RedisProtocol.java index bd0aad38eef..dba2ac1b0ea 100644 --- a/dubbo-rpc/dubbo-rpc-redis/src/main/java/com/alibaba/dubbo/rpc/protocol/redis/RedisProtocol.java +++ b/dubbo-rpc/dubbo-rpc-redis/src/main/java/com/alibaba/dubbo/rpc/protocol/redis/RedisProtocol.java @@ -52,10 +52,12 @@ public class RedisProtocol extends AbstractProtocol { public static final int DEFAULT_PORT = 6379; + @Override public int getDefaultPort() { return DEFAULT_PORT; } + @Override public Exporter export(final Invoker invoker) throws RpcException { throw new UnsupportedOperationException("Unsupported export redis service. url: " + invoker.getUrl()); } @@ -64,6 +66,7 @@ private Serialization getSerialization(URL url) { return ExtensionLoader.getExtensionLoader(Serialization.class).getExtension(url.getParameter(Constants.SERIALIZATION_KEY, "java")); } + @Override public Invoker refer(final Class type, final URL url) throws RpcException { try { GenericObjectPoolConfig config = new GenericObjectPoolConfig(); @@ -93,6 +96,7 @@ public Invoker refer(final Class type, final URL url) throws RpcExcept final String set = url.getParameter("set", Map.class.equals(type) ? "put" : "set"); final String delete = url.getParameter("delete", Map.class.equals(type) ? "remove" : "delete"); return new AbstractInvoker(type, url) { + @Override protected Result doInvoke(Invocation invocation) throws Throwable { Jedis resource = null; try { @@ -151,6 +155,7 @@ protected Result doInvoke(Invocation invocation) throws Throwable { } } + @Override public void destroy() { super.destroy(); try { diff --git a/dubbo-rpc/dubbo-rpc-rest/src/main/java/com/alibaba/dubbo/rpc/protocol/rest/BaseRestServer.java b/dubbo-rpc/dubbo-rpc-rest/src/main/java/com/alibaba/dubbo/rpc/protocol/rest/BaseRestServer.java index 999cca7898a..1942971cba1 100644 --- a/dubbo-rpc/dubbo-rpc-rest/src/main/java/com/alibaba/dubbo/rpc/protocol/rest/BaseRestServer.java +++ b/dubbo-rpc/dubbo-rpc-rest/src/main/java/com/alibaba/dubbo/rpc/protocol/rest/BaseRestServer.java @@ -24,6 +24,7 @@ public abstract class BaseRestServer implements RestServer { + @Override public void start(URL url) { getDeployment().getMediaTypeMappings().put("json", "application/json"); getDeployment().getMediaTypeMappings().put("xml", "text/xml"); @@ -37,6 +38,7 @@ public void start(URL url) { doStart(url); } + @Override public void deploy(Class resourceDef, Object resourceInstance, String contextPath) { if (StringUtils.isEmpty(contextPath)) { getDeployment().getRegistry().addResourceFactory(new DubboResourceFactory(resourceInstance, resourceDef)); @@ -45,6 +47,7 @@ public void deploy(Class resourceDef, Object resourceInstance, String contextPat } } + @Override public void undeploy(Class resourceDef) { getDeployment().getRegistry().removeRegistrations(resourceDef); } diff --git a/dubbo-rpc/dubbo-rpc-rest/src/main/java/com/alibaba/dubbo/rpc/protocol/rest/DubboHttpServer.java b/dubbo-rpc/dubbo-rpc-rest/src/main/java/com/alibaba/dubbo/rpc/protocol/rest/DubboHttpServer.java index 7f74445be4c..895e5853b41 100644 --- a/dubbo-rpc/dubbo-rpc-rest/src/main/java/com/alibaba/dubbo/rpc/protocol/rest/DubboHttpServer.java +++ b/dubbo-rpc/dubbo-rpc-rest/src/main/java/com/alibaba/dubbo/rpc/protocol/rest/DubboHttpServer.java @@ -48,6 +48,7 @@ public DubboHttpServer(HttpBinder httpBinder) { this.httpBinder = httpBinder; } + @Override protected void doStart(URL url) { // TODO jetty will by default enable keepAlive so the xml config has no effect now httpServer = httpBinder.bind(url, new RestHandler()); @@ -70,16 +71,19 @@ protected void doStart(URL url) { } } + @Override public void stop() { httpServer.close(); } + @Override protected ResteasyDeployment getDeployment() { return deployment; } private class RestHandler implements HttpHandler { + @Override public void handle(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { RpcContext.getContext().setRemoteAddress(request.getRemoteAddr(), request.getRemotePort()); dispatcher.service(request, response); @@ -94,24 +98,30 @@ public SimpleServletConfig(ServletContext servletContext) { this.servletContext = servletContext; } + @Override public String getServletName() { return "DispatcherServlet"; } + @Override public ServletContext getServletContext() { return servletContext; } + @Override public String getInitParameter(String s) { return null; } + @Override public Enumeration getInitParameterNames() { return new Enumeration() { + @Override public boolean hasMoreElements() { return false; } + @Override public Object nextElement() { return null; } diff --git a/dubbo-rpc/dubbo-rpc-rest/src/main/java/com/alibaba/dubbo/rpc/protocol/rest/DubboResourceFactory.java b/dubbo-rpc/dubbo-rpc-rest/src/main/java/com/alibaba/dubbo/rpc/protocol/rest/DubboResourceFactory.java index 661ef52fcc3..4fdf890e1f8 100644 --- a/dubbo-rpc/dubbo-rpc-rest/src/main/java/com/alibaba/dubbo/rpc/protocol/rest/DubboResourceFactory.java +++ b/dubbo-rpc/dubbo-rpc-rest/src/main/java/com/alibaba/dubbo/rpc/protocol/rest/DubboResourceFactory.java @@ -41,23 +41,28 @@ public DubboResourceFactory(Object resourceInstance, Class scannableClass) { // return propertyInjector; // } + @Override public Object createResource(HttpRequest request, HttpResponse response, ResteasyProviderFactory factory) { return resourceInstance; } + @Override public Class getScannableClass() { return scannableClass; } + @Override public void registered(ResteasyProviderFactory factory) { // this.propertyInjector = factory.getInjectorFactory().createPropertyInjector(getScannableClass(), factory); } + @Override public void requestFinished(HttpRequest request, HttpResponse response, Object resource) { } + @Override public void unregistered() { } diff --git a/dubbo-rpc/dubbo-rpc-rest/src/main/java/com/alibaba/dubbo/rpc/protocol/rest/NettyServer.java b/dubbo-rpc/dubbo-rpc-rest/src/main/java/com/alibaba/dubbo/rpc/protocol/rest/NettyServer.java index dbbd9bf3509..efb2ca88f64 100644 --- a/dubbo-rpc/dubbo-rpc-rest/src/main/java/com/alibaba/dubbo/rpc/protocol/rest/NettyServer.java +++ b/dubbo-rpc/dubbo-rpc-rest/src/main/java/com/alibaba/dubbo/rpc/protocol/rest/NettyServer.java @@ -35,6 +35,7 @@ public class NettyServer extends BaseRestServer { private final NettyJaxrsServer server = new NettyJaxrsServer(); + @Override protected void doStart(URL url) { String bindIp = url.getParameter(Constants.BIND_IP_KEY, url.getHost()); if (!url.isAnyHost() && NetUtils.isValidLocalHost(bindIp)) { @@ -50,10 +51,12 @@ protected void doStart(URL url) { server.start(); } + @Override public void stop() { server.stop(); } + @Override protected ResteasyDeployment getDeployment() { return server.getDeployment(); } diff --git a/dubbo-rpc/dubbo-rpc-rest/src/main/java/com/alibaba/dubbo/rpc/protocol/rest/RestProtocol.java b/dubbo-rpc/dubbo-rpc-rest/src/main/java/com/alibaba/dubbo/rpc/protocol/rest/RestProtocol.java index 2177d0f3d01..91109b3cf56 100644 --- a/dubbo-rpc/dubbo-rpc-rest/src/main/java/com/alibaba/dubbo/rpc/protocol/rest/RestProtocol.java +++ b/dubbo-rpc/dubbo-rpc-rest/src/main/java/com/alibaba/dubbo/rpc/protocol/rest/RestProtocol.java @@ -75,10 +75,12 @@ public void setHttpBinder(HttpBinder httpBinder) { serverFactory.setHttpBinder(httpBinder); } + @Override public int getDefaultPort() { return DEFAULT_PORT; } + @Override protected Runnable doExport(T impl, Class type, URL url) throws RpcException { String addr = getAddr(url); Class implClass = ServiceClassHolder.getInstance().popServiceClass(); @@ -116,6 +118,7 @@ protected Runnable doExport(T impl, Class type, URL url) throws RpcExcept final RestServer s = server; return new Runnable() { + @Override public void run() { // TODO due to dubbo's current architecture, // it will be called from registry protocol in the shutdown process and won't appear in logs @@ -124,6 +127,7 @@ public void run() { }; } + @Override protected T doRefer(Class serviceType, URL url) throws RpcException { if (connectionMonitor == null) { connectionMonitor = new ConnectionMonitor(); @@ -148,6 +152,7 @@ protected T doRefer(Class serviceType, URL url) throws RpcException { CloseableHttpClient httpClient = HttpClientBuilder.create() .setKeepAliveStrategy(new ConnectionKeepAliveStrategy() { + @Override public long getKeepAliveDuration(HttpResponse response, HttpContext context) { HeaderElementIterator it = new BasicHeaderElementIterator(response.headerIterator(HTTP.CONN_KEEP_ALIVE)); while (it.hasNext()) { @@ -187,11 +192,13 @@ public long getKeepAliveDuration(HttpResponse response, HttpContext context) { return target.proxy(serviceType); } + @Override protected int getErrorCode(Throwable e) { // TODO return super.getErrorCode(e); } + @Override public void destroy() { super.destroy(); @@ -237,6 +244,7 @@ public void addConnectionManager(PoolingHttpClientConnectionManager connectionMa connectionManagers.add(connectionManager); } + @Override public void run() { try { while (!shutdown) { diff --git a/dubbo-rpc/dubbo-rpc-rest/src/main/java/com/alibaba/dubbo/rpc/protocol/rest/RpcContextFilter.java b/dubbo-rpc/dubbo-rpc-rest/src/main/java/com/alibaba/dubbo/rpc/protocol/rest/RpcContextFilter.java index f250425dec2..99bd681d878 100644 --- a/dubbo-rpc/dubbo-rpc-rest/src/main/java/com/alibaba/dubbo/rpc/protocol/rest/RpcContextFilter.java +++ b/dubbo-rpc/dubbo-rpc-rest/src/main/java/com/alibaba/dubbo/rpc/protocol/rest/RpcContextFilter.java @@ -39,6 +39,7 @@ public class RpcContextFilter implements ContainerRequestFilter, ClientRequestFi // currently we use a single header to hold the attachments so that the total attachment size limit is about 8k private static final int MAX_HEADER_SIZE = 8 * 1024; + @Override public void filter(ContainerRequestContext requestContext) throws IOException { HttpServletRequest request = ResteasyProviderFactory.getContextData(HttpServletRequest.class); RpcContext.getContext().setRequest(request); @@ -65,6 +66,7 @@ public void filter(ContainerRequestContext requestContext) throws IOException { } } + @Override public void filter(ClientRequestContext requestContext) throws IOException { int size = 0; for (Map.Entry entry : RpcContext.getContext().getAttachments().entrySet()) { diff --git a/dubbo-rpc/dubbo-rpc-rest/src/main/java/com/alibaba/dubbo/rpc/protocol/rest/RpcExceptionMapper.java b/dubbo-rpc/dubbo-rpc-rest/src/main/java/com/alibaba/dubbo/rpc/protocol/rest/RpcExceptionMapper.java index d88320da541..039819771b0 100644 --- a/dubbo-rpc/dubbo-rpc-rest/src/main/java/com/alibaba/dubbo/rpc/protocol/rest/RpcExceptionMapper.java +++ b/dubbo-rpc/dubbo-rpc-rest/src/main/java/com/alibaba/dubbo/rpc/protocol/rest/RpcExceptionMapper.java @@ -26,6 +26,7 @@ public class RpcExceptionMapper implements ExceptionMapper { + @Override public Response toResponse(RpcException e) { // TODO do more sophisticated exception handling and output if (e.getCause() instanceof ConstraintViolationException) { diff --git a/dubbo-rpc/dubbo-rpc-rest/src/main/java/com/alibaba/dubbo/rpc/protocol/rest/support/LoggingFilter.java b/dubbo-rpc/dubbo-rpc-rest/src/main/java/com/alibaba/dubbo/rpc/protocol/rest/support/LoggingFilter.java index 8c60eaebeea..679eb63c63f 100644 --- a/dubbo-rpc/dubbo-rpc-rest/src/main/java/com/alibaba/dubbo/rpc/protocol/rest/support/LoggingFilter.java +++ b/dubbo-rpc/dubbo-rpc-rest/src/main/java/com/alibaba/dubbo/rpc/protocol/rest/support/LoggingFilter.java @@ -52,22 +52,27 @@ public class LoggingFilter implements ContainerRequestFilter, ClientRequestFilte private static final Logger logger = LoggerFactory.getLogger(LoggingFilter.class); + @Override public void filter(ClientRequestContext context) throws IOException { logHttpHeaders(context.getStringHeaders()); } + @Override public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext) throws IOException { logHttpHeaders(responseContext.getHeaders()); } + @Override public void filter(ContainerRequestContext context) throws IOException { logHttpHeaders(context.getHeaders()); } + @Override public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) throws IOException { logHttpHeaders(responseContext.getStringHeaders()); } + @Override public Object aroundReadFrom(ReaderInterceptorContext context) throws IOException, WebApplicationException { byte[] buffer = IOUtils.toByteArray(context.getInputStream()); logger.info("The contents of request body is: \n" + new String(buffer, "UTF-8") + "\n"); @@ -75,6 +80,7 @@ public Object aroundReadFrom(ReaderInterceptorContext context) throws IOExceptio return context.proceed(); } + @Override public void aroundWriteTo(WriterInterceptorContext context) throws IOException, WebApplicationException { OutputStreamWrapper wrapper = new OutputStreamWrapper(context.getOutputStream()); context.setOutputStream(wrapper); diff --git a/dubbo-rpc/dubbo-rpc-rmi/src/main/java/com/alibaba/dubbo/rpc/protocol/rmi/RmiProtocol.java b/dubbo-rpc/dubbo-rpc-rmi/src/main/java/com/alibaba/dubbo/rpc/protocol/rmi/RmiProtocol.java index 20f4e992ec8..0ce06d07e58 100644 --- a/dubbo-rpc/dubbo-rpc-rmi/src/main/java/com/alibaba/dubbo/rpc/protocol/rmi/RmiProtocol.java +++ b/dubbo-rpc/dubbo-rpc-rmi/src/main/java/com/alibaba/dubbo/rpc/protocol/rmi/RmiProtocol.java @@ -44,10 +44,12 @@ public RmiProtocol() { super(RemoteAccessException.class, RemoteException.class); } + @Override public int getDefaultPort() { return DEFAULT_PORT; } + @Override protected Runnable doExport(final T impl, Class type, URL url) throws RpcException { final RmiServiceExporter rmiServiceExporter = new RmiServiceExporter(); rmiServiceExporter.setRegistryPort(url.getPort()); @@ -60,6 +62,7 @@ protected Runnable doExport(final T impl, Class type, URL url) throws Rpc throw new RpcException(e.getMessage(), e); } return new Runnable() { + @Override public void run() { try { rmiServiceExporter.destroy(); @@ -70,6 +73,7 @@ public void run() { }; } + @Override @SuppressWarnings("unchecked") protected T doRefer(final Class serviceType, final URL url) throws RpcException { final RmiProxyFactoryBean rmiProxyFactoryBean = new RmiProxyFactoryBean(); @@ -77,6 +81,7 @@ protected T doRefer(final Class serviceType, final URL url) throws RpcExc if (url.getParameter(Constants.DUBBO_VERSION_KEY, Version.getVersion()).equals(Version.getVersion())) { // Check dubbo version on provider, this feature only support rmiProxyFactoryBean.setRemoteInvocationFactory(new RemoteInvocationFactory() { + @Override public RemoteInvocation createRemoteInvocation(MethodInvocation methodInvocation) { return new RmiRemoteInvocation(methodInvocation); } @@ -91,6 +96,7 @@ public RemoteInvocation createRemoteInvocation(MethodInvocation methodInvocation return (T) rmiProxyFactoryBean.getObject(); } + @Override protected int getErrorCode(Throwable e) { if (e instanceof RemoteAccessException) { e = e.getCause(); diff --git a/dubbo-rpc/dubbo-rpc-thrift/src/main/java/com/alibaba/dubbo/rpc/protocol/thrift/DubboClassNameGenerator.java b/dubbo-rpc/dubbo-rpc-thrift/src/main/java/com/alibaba/dubbo/rpc/protocol/thrift/DubboClassNameGenerator.java index ac5312bcdf0..b6620721869 100644 --- a/dubbo-rpc/dubbo-rpc-thrift/src/main/java/com/alibaba/dubbo/rpc/protocol/thrift/DubboClassNameGenerator.java +++ b/dubbo-rpc/dubbo-rpc-thrift/src/main/java/com/alibaba/dubbo/rpc/protocol/thrift/DubboClassNameGenerator.java @@ -20,10 +20,12 @@ public class DubboClassNameGenerator implements ClassNameGenerator { public static final String NAME = "dubbo"; + @Override public String generateArgsClassName(String serviceName, String methodName) { return ThriftUtils.generateMethodArgsClassName(serviceName, methodName); } + @Override public String generateResultClassName(String serviceName, String methodName) { return ThriftUtils.generateMethodResultClassName(serviceName, methodName); } diff --git a/dubbo-rpc/dubbo-rpc-thrift/src/main/java/com/alibaba/dubbo/rpc/protocol/thrift/ThriftClassNameGenerator.java b/dubbo-rpc/dubbo-rpc-thrift/src/main/java/com/alibaba/dubbo/rpc/protocol/thrift/ThriftClassNameGenerator.java index 7298fdbdd67..ed867260d49 100644 --- a/dubbo-rpc/dubbo-rpc-thrift/src/main/java/com/alibaba/dubbo/rpc/protocol/thrift/ThriftClassNameGenerator.java +++ b/dubbo-rpc/dubbo-rpc-thrift/src/main/java/com/alibaba/dubbo/rpc/protocol/thrift/ThriftClassNameGenerator.java @@ -20,10 +20,12 @@ public class ThriftClassNameGenerator implements ClassNameGenerator { public static final String NAME = "thrift"; + @Override public String generateArgsClassName(String serviceName, String methodName) { return ThriftUtils.generateMethodArgsClassNameThrift(serviceName, methodName); } + @Override public String generateResultClassName(String serviceName, String methodName) { return ThriftUtils.generateMethodResultClassNameThrift(serviceName, methodName); } diff --git a/dubbo-rpc/dubbo-rpc-thrift/src/main/java/com/alibaba/dubbo/rpc/protocol/thrift/ThriftCodec.java b/dubbo-rpc/dubbo-rpc-thrift/src/main/java/com/alibaba/dubbo/rpc/protocol/thrift/ThriftCodec.java index ced64395207..a708e8f459e 100644 --- a/dubbo-rpc/dubbo-rpc-thrift/src/main/java/com/alibaba/dubbo/rpc/protocol/thrift/ThriftCodec.java +++ b/dubbo-rpc/dubbo-rpc-thrift/src/main/java/com/alibaba/dubbo/rpc/protocol/thrift/ThriftCodec.java @@ -96,6 +96,7 @@ static int getSeqId() { return THRIFT_SEQ_ID.get(); } + @Override public void encode(Channel channel, ChannelBuffer buffer, Object message) throws IOException { @@ -115,6 +116,7 @@ public void encode(Channel channel, ChannelBuffer buffer, Object message) } + @Override public Object decode(Channel channel, ChannelBuffer buffer) throws IOException { int available = buffer.readableBytes(); diff --git a/dubbo-rpc/dubbo-rpc-thrift/src/main/java/com/alibaba/dubbo/rpc/protocol/thrift/ThriftInvoker.java b/dubbo-rpc/dubbo-rpc-thrift/src/main/java/com/alibaba/dubbo/rpc/protocol/thrift/ThriftInvoker.java index c06225fd701..af39ddefef5 100644 --- a/dubbo-rpc/dubbo-rpc-thrift/src/main/java/com/alibaba/dubbo/rpc/protocol/thrift/ThriftInvoker.java +++ b/dubbo-rpc/dubbo-rpc-thrift/src/main/java/com/alibaba/dubbo/rpc/protocol/thrift/ThriftInvoker.java @@ -111,6 +111,7 @@ public boolean isAvailable() { return false; } + @Override public void destroy() { // in order to avoid closing a client multiple times, a counter is used in case of connection per jvm, every // time when client.close() is called, counter counts down once, and when counter reaches zero, client will be diff --git a/dubbo-rpc/dubbo-rpc-thrift/src/main/java/com/alibaba/dubbo/rpc/protocol/thrift/ThriftNativeCodec.java b/dubbo-rpc/dubbo-rpc-thrift/src/main/java/com/alibaba/dubbo/rpc/protocol/thrift/ThriftNativeCodec.java index 9d1f463f56a..38fd422762e 100644 --- a/dubbo-rpc/dubbo-rpc-thrift/src/main/java/com/alibaba/dubbo/rpc/protocol/thrift/ThriftNativeCodec.java +++ b/dubbo-rpc/dubbo-rpc-thrift/src/main/java/com/alibaba/dubbo/rpc/protocol/thrift/ThriftNativeCodec.java @@ -49,6 +49,7 @@ protected static TProtocol newProtocol(URL url, ChannelBuffer buffer) throws IOE throw new IOException("Unsupported protocol type " + protocol); } + @Override public void encode(Channel channel, ChannelBuffer buffer, Object message) throws IOException { if (message instanceof Request) { @@ -85,6 +86,7 @@ protected void encodeResponse(Channel channel, ChannelBuffer buffer, Response re } + @Override public Object decode(Channel channel, ChannelBuffer buffer) throws IOException { return null; } diff --git a/dubbo-rpc/dubbo-rpc-thrift/src/main/java/com/alibaba/dubbo/rpc/protocol/thrift/ThriftProtocol.java b/dubbo-rpc/dubbo-rpc-thrift/src/main/java/com/alibaba/dubbo/rpc/protocol/thrift/ThriftProtocol.java index 78325694401..c1fdcf19dc4 100644 --- a/dubbo-rpc/dubbo-rpc-thrift/src/main/java/com/alibaba/dubbo/rpc/protocol/thrift/ThriftProtocol.java +++ b/dubbo-rpc/dubbo-rpc-thrift/src/main/java/com/alibaba/dubbo/rpc/protocol/thrift/ThriftProtocol.java @@ -102,10 +102,12 @@ public void received(Channel channel, Object message) throws RemotingException { }; + @Override public int getDefaultPort() { return DEFAULT_PORT; } + @Override public Exporter export(Invoker invoker) throws RpcException { // can use thrift codec only @@ -125,6 +127,7 @@ public Exporter export(Invoker invoker) throws RpcException { return exporter; } + @Override public void destroy() { super.destroy(); @@ -148,6 +151,7 @@ public void destroy() { } // ~ end of method destroy + @Override public Invoker refer(Class type, URL url) throws RpcException { ThriftInvoker invoker = new ThriftInvoker(type, url, getClients(url), invokers); diff --git a/dubbo-rpc/dubbo-rpc-thrift/src/main/java/com/alibaba/dubbo/rpc/protocol/thrift/ext/MultiServiceProcessor.java b/dubbo-rpc/dubbo-rpc-thrift/src/main/java/com/alibaba/dubbo/rpc/protocol/thrift/ext/MultiServiceProcessor.java index 5877d9c3db3..88b80321d49 100644 --- a/dubbo-rpc/dubbo-rpc-thrift/src/main/java/com/alibaba/dubbo/rpc/protocol/thrift/ext/MultiServiceProcessor.java +++ b/dubbo-rpc/dubbo-rpc-thrift/src/main/java/com/alibaba/dubbo/rpc/protocol/thrift/ext/MultiServiceProcessor.java @@ -42,6 +42,7 @@ public class MultiServiceProcessor implements TProcessor { public MultiServiceProcessor() { } + @Override public boolean process(TProtocol in, TProtocol out) throws TException { short magic = in.readI16(); diff --git a/dubbo-rpc/dubbo-rpc-thrift/src/main/java/com/alibaba/dubbo/rpc/protocol/thrift/io/RandomAccessByteArrayOutputStream.java b/dubbo-rpc/dubbo-rpc-thrift/src/main/java/com/alibaba/dubbo/rpc/protocol/thrift/io/RandomAccessByteArrayOutputStream.java index b08eb3552b7..7afd90a6777 100644 --- a/dubbo-rpc/dubbo-rpc-thrift/src/main/java/com/alibaba/dubbo/rpc/protocol/thrift/io/RandomAccessByteArrayOutputStream.java +++ b/dubbo-rpc/dubbo-rpc-thrift/src/main/java/com/alibaba/dubbo/rpc/protocol/thrift/io/RandomAccessByteArrayOutputStream.java @@ -41,6 +41,7 @@ public RandomAccessByteArrayOutputStream(int size) { buffer = new byte[size]; } + @Override public void write(int b) { int newcount = count + 1; @@ -50,6 +51,7 @@ public void write(int b) { count = newcount; } + @Override public void write(byte b[], int off, int len) { if ((off < 0) || (off > b.length) || (len < 0) || ((off + len) > b.length) || ((off + len) < 0)) @@ -92,6 +94,7 @@ public void writeTo(OutputStream out) throws IOException { out.write(buffer, 0, count); } + @Override public String toString() { return new String(buffer, 0, count); @@ -102,6 +105,7 @@ public String toString(String charset) throws UnsupportedEncodingException { return new String(buffer, 0, count, charset); } + @Override public void close() throws IOException { } diff --git a/dubbo-rpc/dubbo-rpc-webservice/src/main/java/com/alibaba/dubbo/rpc/protocol/webservice/WebServiceProtocol.java b/dubbo-rpc/dubbo-rpc-webservice/src/main/java/com/alibaba/dubbo/rpc/protocol/webservice/WebServiceProtocol.java index 04450cad35c..d7def9ef465 100644 --- a/dubbo-rpc/dubbo-rpc-webservice/src/main/java/com/alibaba/dubbo/rpc/protocol/webservice/WebServiceProtocol.java +++ b/dubbo-rpc/dubbo-rpc-webservice/src/main/java/com/alibaba/dubbo/rpc/protocol/webservice/WebServiceProtocol.java @@ -72,10 +72,12 @@ public void setHttpBinder(HttpBinder httpBinder) { this.httpBinder = httpBinder; } + @Override public int getDefaultPort() { return DEFAULT_PORT; } + @Override protected Runnable doExport(T impl, Class type, URL url) throws RpcException { String addr = getAddr(url); HttpServer httpServer = serverMap.get(addr); @@ -91,12 +93,14 @@ protected Runnable doExport(T impl, Class type, URL url) throws RpcExcept serverFactoryBean.setDestinationFactory(transportFactory); serverFactoryBean.create(); return new Runnable() { + @Override public void run() { serverFactoryBean.destroy(); } }; } + @Override @SuppressWarnings("unchecked") protected T doRefer(final Class serviceType, final URL url) throws RpcException { ClientProxyFactoryBean proxyFactoryBean = new ClientProxyFactoryBean(); @@ -113,6 +117,7 @@ protected T doRefer(final Class serviceType, final URL url) throws RpcExc return ref; } + @Override protected int getErrorCode(Throwable e) { if (e instanceof Fault) { e = e.getCause(); @@ -129,6 +134,7 @@ private class WebServiceHandler implements HttpHandler { private volatile ServletController servletController; + @Override public void handle(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { if (servletController == null) { HttpServlet httpServlet = DispatcherServlet.getInstance(); diff --git a/dubbo-test/dubbo-test-benchmark/src/main/java/com/alibaba/dubbo/rpc/benchmark/AbstractBenchmarkServer.java b/dubbo-test/dubbo-test-benchmark/src/main/java/com/alibaba/dubbo/rpc/benchmark/AbstractBenchmarkServer.java index 115091ab7f6..4baa986ff18 100644 --- a/dubbo-test/dubbo-test-benchmark/src/main/java/com/alibaba/dubbo/rpc/benchmark/AbstractBenchmarkServer.java +++ b/dubbo-test/dubbo-test-benchmark/src/main/java/com/alibaba/dubbo/rpc/benchmark/AbstractBenchmarkServer.java @@ -55,6 +55,7 @@ public void run(String[] args) throws Exception { url.append(maxThreads); Exchangers.bind(url.toString(), new ExchangeHandlerAdapter() { + @Override public Object reply(ExchangeChannel channel, Object message) throws RemotingException { return new ResponseObject(responseSize); // send response } diff --git a/dubbo-test/dubbo-test-benchmark/src/main/java/com/alibaba/dubbo/rpc/benchmark/AbstractClientRunnable.java b/dubbo-test/dubbo-test-benchmark/src/main/java/com/alibaba/dubbo/rpc/benchmark/AbstractClientRunnable.java index c3897a54525..16a2e69675d 100644 --- a/dubbo-test/dubbo-test-benchmark/src/main/java/com/alibaba/dubbo/rpc/benchmark/AbstractClientRunnable.java +++ b/dubbo-test/dubbo-test-benchmark/src/main/java/com/alibaba/dubbo/rpc/benchmark/AbstractClientRunnable.java @@ -87,6 +87,7 @@ public AbstractClientRunnable(String targetIP, int targetPort, int clientNums, i } } + @Override public void run() { try { barrier.await(); @@ -148,6 +149,7 @@ private void runJavaAndHessian() { public abstract Object invoke(ServiceFactory serviceFactory); + @Override public List getResults() { List results = new ArrayList(); results.add(responseSpreads); diff --git a/dubbo-test/dubbo-test-benchmark/src/main/java/com/alibaba/dubbo/rpc/benchmark/DemoServiceImpl.java b/dubbo-test/dubbo-test-benchmark/src/main/java/com/alibaba/dubbo/rpc/benchmark/DemoServiceImpl.java index dd7809f4f42..dc35e3a3835 100644 --- a/dubbo-test/dubbo-test-benchmark/src/main/java/com/alibaba/dubbo/rpc/benchmark/DemoServiceImpl.java +++ b/dubbo-test/dubbo-test-benchmark/src/main/java/com/alibaba/dubbo/rpc/benchmark/DemoServiceImpl.java @@ -23,6 +23,7 @@ public class DemoServiceImpl implements DemoService { ResponseObject responseObject = new ResponseObject(100); + @Override public Object sendRequest(Object request) { return request; } diff --git a/dubbo-test/dubbo-test-benchmark/src/main/java/com/alibaba/dubbo/rpc/benchmark/ExchangeClientFactory.java b/dubbo-test/dubbo-test-benchmark/src/main/java/com/alibaba/dubbo/rpc/benchmark/ExchangeClientFactory.java index ef2008f12cb..2cf95c72437 100644 --- a/dubbo-test/dubbo-test-benchmark/src/main/java/com/alibaba/dubbo/rpc/benchmark/ExchangeClientFactory.java +++ b/dubbo-test/dubbo-test-benchmark/src/main/java/com/alibaba/dubbo/rpc/benchmark/ExchangeClientFactory.java @@ -56,6 +56,7 @@ public ExchangeClient get(final String targetIP, final int targetPort, final int FutureTask> task = new FutureTask>( new Callable>() { + @Override public List call() throws Exception { List clients = new ArrayList( diff --git a/dubbo-test/dubbo-test-benchmark/src/main/java/com/alibaba/dubbo/rpc/benchmark/SimpleProcessorBenchmarkClientRunnable.java b/dubbo-test/dubbo-test-benchmark/src/main/java/com/alibaba/dubbo/rpc/benchmark/SimpleProcessorBenchmarkClientRunnable.java index 2aa4be50d9a..ce105799106 100644 --- a/dubbo-test/dubbo-test-benchmark/src/main/java/com/alibaba/dubbo/rpc/benchmark/SimpleProcessorBenchmarkClientRunnable.java +++ b/dubbo-test/dubbo-test-benchmark/src/main/java/com/alibaba/dubbo/rpc/benchmark/SimpleProcessorBenchmarkClientRunnable.java @@ -98,6 +98,7 @@ public SimpleProcessorBenchmarkClientRunnable(String targetIP, int targetPort, i } } + @Override public void run() { try { barrier.await(); @@ -159,6 +160,7 @@ private void runJavaAndHessian() { } } + @Override public List getResults() { List results = new ArrayList(); results.add(responseSpreads); diff --git a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/annotation/impl/AnnotationServiceImpl.java b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/annotation/impl/AnnotationServiceImpl.java index 947b2681d57..7d7040bb79d 100644 --- a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/annotation/impl/AnnotationServiceImpl.java +++ b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/annotation/impl/AnnotationServiceImpl.java @@ -25,6 +25,7 @@ @Service public class AnnotationServiceImpl implements AnnotationService { + @Override public String sayHello(String name) { System.out.println("async provider received: " + name); return "annotation: hello, " + name; diff --git a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/async/AsyncConsumer.java b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/async/AsyncConsumer.java index fc74107c3ba..fe224ebc2c5 100644 --- a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/async/AsyncConsumer.java +++ b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/async/AsyncConsumer.java @@ -37,6 +37,7 @@ public static void main(String[] args) throws Exception { final AsyncService asyncService = (AsyncService) context.getBean("asyncService"); Future f = RpcContext.getContext().asyncCall(new Callable() { + @Override public String call() throws Exception { return asyncService.sayHello("async call request"); } @@ -45,6 +46,7 @@ public String call() throws Exception { System.out.println("async call ret :" + f.get()); RpcContext.getContext().asyncCall(new Runnable() { + @Override public void run() { asyncService.sayHello("oneway call request1"); asyncService.sayHello("oneway call request2"); diff --git a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/async/impl/AsyncServiceImpl.java b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/async/impl/AsyncServiceImpl.java index 7404abb6841..375063945bf 100644 --- a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/async/impl/AsyncServiceImpl.java +++ b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/async/impl/AsyncServiceImpl.java @@ -23,6 +23,7 @@ */ public class AsyncServiceImpl implements AsyncService { + @Override public String sayHello(String name) { System.out.println("async provider received: " + name); return "hello, " + name; diff --git a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/cache/impl/CacheServiceImpl.java b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/cache/impl/CacheServiceImpl.java index 49698745449..7b20d8071a6 100644 --- a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/cache/impl/CacheServiceImpl.java +++ b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/cache/impl/CacheServiceImpl.java @@ -27,6 +27,7 @@ public class CacheServiceImpl implements CacheService { private final AtomicInteger i = new AtomicInteger(); + @Override public String findCache(String id) { return "request: " + id + ", response: " + i.getAndIncrement(); } diff --git a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/callback/CallbackConsumer.java b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/callback/CallbackConsumer.java index 7a5fa79c427..743b476028c 100644 --- a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/callback/CallbackConsumer.java +++ b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/callback/CallbackConsumer.java @@ -32,6 +32,7 @@ public static void main(String[] args) throws Exception { context.start(); CallbackService callbackService = (CallbackService) context.getBean("callbackService"); callbackService.addListener("foo.bar", new CallbackListener() { + @Override public void changed(String msg) { System.out.println("callback1:" + msg); } diff --git a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/callback/impl/CallbackServiceImpl.java b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/callback/impl/CallbackServiceImpl.java index c0db27ec21e..38e7ec70498 100644 --- a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/callback/impl/CallbackServiceImpl.java +++ b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/callback/impl/CallbackServiceImpl.java @@ -33,6 +33,7 @@ public class CallbackServiceImpl implements CallbackService { public CallbackServiceImpl() { Thread t = new Thread(new Runnable() { + @Override public void run() { while (true) { try { @@ -54,6 +55,7 @@ public void run() { t.start(); } + @Override public void addListener(String key, CallbackListener listener) { listeners.put(key, listener); listener.changed(getChanged(key)); // send notification for change diff --git a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/generic/impl/UserServiceImpl.java b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/generic/impl/UserServiceImpl.java index 4a71985019c..92cf923137a 100644 --- a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/generic/impl/UserServiceImpl.java +++ b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/generic/impl/UserServiceImpl.java @@ -20,6 +20,7 @@ public class UserServiceImpl implements IUserService { + @Override public User get(Params params) { return new User(1, "charles"); } diff --git a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/heartbeat/HeartbeatClient.java b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/heartbeat/HeartbeatClient.java index 9a03b11abcb..3f678b734e8 100644 --- a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/heartbeat/HeartbeatClient.java +++ b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/heartbeat/HeartbeatClient.java @@ -50,6 +50,7 @@ public static void main(String[] args) throws Exception { Thread serverThread = new Thread(new Runnable() { + @Override public void run() { try { exchangeServer = new HeaderExchangeServer( diff --git a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/heartbeat/HeartbeatServer.java b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/heartbeat/HeartbeatServer.java index 611c15d2f02..b11f0f18d86 100644 --- a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/heartbeat/HeartbeatServer.java +++ b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/heartbeat/HeartbeatServer.java @@ -50,6 +50,7 @@ public static void main(String[] args) throws Exception { Thread serverThread = new Thread(new Runnable() { + @Override public void run() { try { exchangeServer = new HeaderExchangeServer( diff --git a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/heartbeat/impl/HelloServiceImpl.java b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/heartbeat/impl/HelloServiceImpl.java index a49e63f3afa..4927c3a8201 100644 --- a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/heartbeat/impl/HelloServiceImpl.java +++ b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/heartbeat/impl/HelloServiceImpl.java @@ -20,6 +20,7 @@ public class HelloServiceImpl implements HelloService { + @Override public String sayHello(String name) { return new StringBuilder(32).append("Hello, ").append(name).append("!").toString(); } diff --git a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/merge/impl/MergeServiceImpl.java b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/merge/impl/MergeServiceImpl.java index 723d1851add..a675066cf81 100644 --- a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/merge/impl/MergeServiceImpl.java +++ b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/merge/impl/MergeServiceImpl.java @@ -26,6 +26,7 @@ */ public class MergeServiceImpl implements MergeService { + @Override public List mergeResult() { List menus = new ArrayList(); menus.add("group-1.1"); diff --git a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/merge/impl/MergeServiceImpl2.java b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/merge/impl/MergeServiceImpl2.java index 4beb7311faa..b4c08f10594 100644 --- a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/merge/impl/MergeServiceImpl2.java +++ b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/merge/impl/MergeServiceImpl2.java @@ -26,6 +26,7 @@ */ public class MergeServiceImpl2 implements MergeService { + @Override public List mergeResult() { List menus = new ArrayList(); menus.add("group-2.1"); diff --git a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/merge/impl/MergeServiceImpl3.java b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/merge/impl/MergeServiceImpl3.java index 51e72df402a..8bd95c6d4ec 100644 --- a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/merge/impl/MergeServiceImpl3.java +++ b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/merge/impl/MergeServiceImpl3.java @@ -26,6 +26,7 @@ */ public class MergeServiceImpl3 implements MergeService { + @Override public List mergeResult() { List menus = new ArrayList(); menus.add("group-3.1"); diff --git a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/rest/api/extension/ClientTraceFilter.java b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/rest/api/extension/ClientTraceFilter.java index 9ebf2c87d33..e207cbb3b9f 100644 --- a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/rest/api/extension/ClientTraceFilter.java +++ b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/rest/api/extension/ClientTraceFilter.java @@ -25,10 +25,12 @@ public class ClientTraceFilter implements ClientRequestFilter, ClientResponseFilter { + @Override public void filter(ClientRequestContext requestContext) throws IOException { System.out.println("Client request filter invoked"); } + @Override public void filter(ClientRequestContext clientRequestContext, ClientResponseContext clientResponseContext) throws IOException { System.out.println("Client response filter invoked"); } diff --git a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/rest/api/extension/CustomExceptionMapper.java b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/rest/api/extension/CustomExceptionMapper.java index 398f1d8a7db..3b7f457fb7e 100644 --- a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/rest/api/extension/CustomExceptionMapper.java +++ b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/rest/api/extension/CustomExceptionMapper.java @@ -24,6 +24,7 @@ public class CustomExceptionMapper implements ExceptionMapper { + @Override public Response toResponse(NotFoundException e) { System.out.println("Exception mapper successfully got an exception: " + e + ":" + e.getMessage()); System.out.println("Client IP is " + RpcContext.getContext().getRemoteAddressString()); diff --git a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/rest/api/extension/DynamicTraceBinding.java b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/rest/api/extension/DynamicTraceBinding.java index 516f83ec765..73237dc46ca 100644 --- a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/rest/api/extension/DynamicTraceBinding.java +++ b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/rest/api/extension/DynamicTraceBinding.java @@ -22,6 +22,7 @@ public class DynamicTraceBinding implements DynamicFeature { + @Override public void configure(ResourceInfo resourceInfo, FeatureContext context) { context.register(DynamicTraceInterceptor.class); } diff --git a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/rest/api/extension/DynamicTraceInterceptor.java b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/rest/api/extension/DynamicTraceInterceptor.java index 47f7a71e11b..77f73181451 100644 --- a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/rest/api/extension/DynamicTraceInterceptor.java +++ b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/rest/api/extension/DynamicTraceInterceptor.java @@ -28,11 +28,13 @@ @Priority(Priorities.USER) public class DynamicTraceInterceptor implements ReaderInterceptor, WriterInterceptor { + @Override public Object aroundReadFrom(ReaderInterceptorContext readerInterceptorContext) throws IOException, WebApplicationException { System.out.println("Dynamic reader interceptor invoked"); return readerInterceptorContext.proceed(); } + @Override public void aroundWriteTo(WriterInterceptorContext writerInterceptorContext) throws IOException, WebApplicationException { System.out.println("Dynamic writer interceptor invoked"); writerInterceptorContext.proceed(); diff --git a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/rest/api/extension/LogFilter.java b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/rest/api/extension/LogFilter.java index cbde2dffb87..c3aed43095a 100644 --- a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/rest/api/extension/LogFilter.java +++ b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/rest/api/extension/LogFilter.java @@ -23,6 +23,7 @@ import com.alibaba.dubbo.rpc.RpcException; public class LogFilter implements Filter { + @Override public Result invoke(Invoker invoker, Invocation invocation) throws RpcException { System.out.println(invocation.getMethodName() + "is invoked"); return invoker.invoke(invocation); diff --git a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/rest/api/extension/TraceFilter.java b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/rest/api/extension/TraceFilter.java index 57f0158d23e..2a87cb02e98 100644 --- a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/rest/api/extension/TraceFilter.java +++ b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/rest/api/extension/TraceFilter.java @@ -27,10 +27,12 @@ @Priority(Priorities.USER) public class TraceFilter implements ContainerRequestFilter, ContainerResponseFilter { + @Override public void filter(ContainerRequestContext requestContext) throws IOException { System.out.println("Request filter invoked: " + requestContext.getUriInfo().getAbsolutePath()); } + @Override public void filter(ContainerRequestContext containerRequestContext, ContainerResponseContext containerResponseContext) throws IOException { System.out.println("Response filter invoked."); diff --git a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/rest/api/extension/TraceInterceptor.java b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/rest/api/extension/TraceInterceptor.java index 5fa723e839e..9c54e8aac48 100644 --- a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/rest/api/extension/TraceInterceptor.java +++ b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/rest/api/extension/TraceInterceptor.java @@ -28,11 +28,13 @@ @Priority(Priorities.USER) public class TraceInterceptor implements ReaderInterceptor, WriterInterceptor { + @Override public Object aroundReadFrom(ReaderInterceptorContext readerInterceptorContext) throws IOException, WebApplicationException { System.out.println("Reader interceptor invoked"); return readerInterceptorContext.proceed(); } + @Override public void aroundWriteTo(WriterInterceptorContext writerInterceptorContext) throws IOException, WebApplicationException { System.out.println("Writer interceptor invoked"); writerInterceptorContext.proceed(); diff --git a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/rest/impl/UserServiceImpl.java b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/rest/impl/UserServiceImpl.java index 5d8538d8663..6de02c8d59e 100644 --- a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/rest/impl/UserServiceImpl.java +++ b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/rest/impl/UserServiceImpl.java @@ -27,11 +27,13 @@ public class UserServiceImpl implements com.alibaba.dubbo.examples.rest.api.User private final AtomicLong idGen = new AtomicLong(); + @Override public User getUser(Long id) { return new User(id, "username" + id); } + @Override public Long registerUser(User user) { // System.out.println("Username is " + user.getName()); return idGen.incrementAndGet(); diff --git a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/rest/impl/facade/AnnotationDrivenUserRestServiceImpl.java b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/rest/impl/facade/AnnotationDrivenUserRestServiceImpl.java index f5ae44f6850..e475081c8ab 100644 --- a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/rest/impl/facade/AnnotationDrivenUserRestServiceImpl.java +++ b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/rest/impl/facade/AnnotationDrivenUserRestServiceImpl.java @@ -48,6 +48,7 @@ public void setUserService(UserService userService) { this.userService = userService; } + @Override @GET @Path("{id : \\d+}") public User getUser(@PathParam("id") Long id/*, @Context HttpServletRequest request*/) { @@ -57,6 +58,7 @@ public User getUser(@PathParam("id") Long id/*, @Context HttpServletRequest requ return userService.getUser(id); } + @Override @POST @Path("register") public RegistrationResult registerUser(User user) { diff --git a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/rest/impl/facade/AnotherUserRestServiceImpl.java b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/rest/impl/facade/AnotherUserRestServiceImpl.java index c669cdc24e8..99788466d76 100644 --- a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/rest/impl/facade/AnotherUserRestServiceImpl.java +++ b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/rest/impl/facade/AnotherUserRestServiceImpl.java @@ -35,12 +35,14 @@ public void setUserService(UserService userService) { this.userService = userService; } + @Override public User getUser(Long id) { System.out.println("Client name is " + RpcContext.getContext().getAttachment("clientName")); System.out.println("Client impl is " + RpcContext.getContext().getAttachment("clientImpl")); return userService.getUser(id); } + @Override public RegistrationResult registerUser(User user) { return new RegistrationResult(userService.registerUser(user)); } diff --git a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/rest/impl/facade/UserRestServiceImpl.java b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/rest/impl/facade/UserRestServiceImpl.java index 7e439383056..49fdb469e9f 100644 --- a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/rest/impl/facade/UserRestServiceImpl.java +++ b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/rest/impl/facade/UserRestServiceImpl.java @@ -51,6 +51,7 @@ public void setUserService(UserService userService) { this.userService = userService; } + @Override @GET @Path("{id : \\d+}") public User getUser(@PathParam("id") Long id/*, @Context HttpServletRequest request*/) { @@ -66,6 +67,7 @@ public User getUser(@PathParam("id") Long id/*, @Context HttpServletRequest requ return userService.getUser(id); } + @Override @POST @Path("register") public RegistrationResult registerUser(User user) { diff --git a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/validation/impl/ValidationServiceImpl.java b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/validation/impl/ValidationServiceImpl.java index 027433b565a..051d29f42c8 100644 --- a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/validation/impl/ValidationServiceImpl.java +++ b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/validation/impl/ValidationServiceImpl.java @@ -24,12 +24,15 @@ */ public class ValidationServiceImpl implements ValidationService { + @Override public void save(ValidationParameter parameter) { } + @Override public void update(ValidationParameter parameter) { } + @Override public void delete(long id, String operator) { } diff --git a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/version/impl/VersionServiceImpl.java b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/version/impl/VersionServiceImpl.java index ec93f8398f7..00e5a062df7 100644 --- a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/version/impl/VersionServiceImpl.java +++ b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/version/impl/VersionServiceImpl.java @@ -20,6 +20,7 @@ public class VersionServiceImpl implements VersionService { + @Override public String sayHello(String name) { return "hello, " + name; } diff --git a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/version/impl/VersionServiceImpl2.java b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/version/impl/VersionServiceImpl2.java index 24b4055ef82..adabc99af85 100644 --- a/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/version/impl/VersionServiceImpl2.java +++ b/dubbo-test/dubbo-test-examples/src/main/java/com/alibaba/dubbo/examples/version/impl/VersionServiceImpl2.java @@ -20,6 +20,7 @@ public class VersionServiceImpl2 implements VersionService { + @Override public String sayHello(String name) { return "hello2, " + name; } diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/AbstractDeserializer.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/AbstractDeserializer.java index 08f6da23f0c..e3e6c5e9adf 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/AbstractDeserializer.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/AbstractDeserializer.java @@ -54,10 +54,12 @@ * Deserializing an object. */ abstract public class AbstractDeserializer implements Deserializer { + @Override public Class getType() { return Object.class; } + @Override public Object readObject(AbstractHessianInput in) throws IOException { Object obj = in.readObject(); @@ -70,6 +72,7 @@ public Object readObject(AbstractHessianInput in) throw error(className + ": unexpected null value"); } + @Override public Object readList(AbstractHessianInput in, int length) throws IOException { throw new UnsupportedOperationException(String.valueOf(this)); @@ -83,6 +86,7 @@ public Object readList(AbstractHessianInput in, int length, Class expectType) throw new UnsupportedOperationException(String.valueOf(this)); } + @Override public Object readLengthList(AbstractHessianInput in, int length) throws IOException { throw new UnsupportedOperationException(String.valueOf(this)); @@ -96,6 +100,7 @@ public Object readLengthList(AbstractHessianInput in, int length, Class expec throw new UnsupportedOperationException(String.valueOf(this)); } + @Override public Object readMap(AbstractHessianInput in) throws IOException { Object obj = in.readObject(); @@ -116,6 +121,7 @@ public Object readMap(AbstractHessianInput in, Class expectKeyType, Class throw new UnsupportedOperationException(String.valueOf(this)); } + @Override public Object readObject(AbstractHessianInput in, String[] fieldNames) throws IOException { throw new UnsupportedOperationException(String.valueOf(this)); diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/AbstractHessianResolver.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/AbstractHessianResolver.java index cf8ba02d680..72a9822af6d 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/AbstractHessianResolver.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/AbstractHessianResolver.java @@ -57,6 +57,7 @@ public class AbstractHessianResolver implements HessianRemoteResolver { /** * Looks up a proxy object. */ + @Override public Object lookup(String type, String url) throws IOException { return new HessianRemote(type, url); diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/AbstractListDeserializer.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/AbstractListDeserializer.java index c8101d32981..f578d290492 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/AbstractListDeserializer.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/AbstractListDeserializer.java @@ -54,6 +54,7 @@ * Deserializing a JDK 1.2 Collection. */ public class AbstractListDeserializer extends AbstractDeserializer { + @Override public Object readObject(AbstractHessianInput in) throws IOException { Object obj = in.readObject(); diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/AbstractMapDeserializer.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/AbstractMapDeserializer.java index 74ee5f7beff..d8543d21fe6 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/AbstractMapDeserializer.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/AbstractMapDeserializer.java @@ -56,10 +56,12 @@ */ public class AbstractMapDeserializer extends AbstractDeserializer { + @Override public Class getType() { return HashMap.class; } + @Override public Object readObject(AbstractHessianInput in) throws IOException { Object obj = in.readObject(); diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/AbstractSerializer.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/AbstractSerializer.java index 48f8cf75bb2..088cf256c00 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/AbstractSerializer.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/AbstractSerializer.java @@ -58,6 +58,7 @@ abstract public class AbstractSerializer implements Serializer { protected static final Logger log = Logger.getLogger(AbstractSerializer.class.getName()); + @Override abstract public void writeObject(Object obj, AbstractHessianOutput out) throws IOException; } diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/ArrayDeserializer.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/ArrayDeserializer.java index 8c7c715a8f2..e575411ba8a 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/ArrayDeserializer.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/ArrayDeserializer.java @@ -73,6 +73,7 @@ public ArrayDeserializer(Class componentType) { _type = Object[].class; } + @Override public Class getType() { return _type; } @@ -80,6 +81,7 @@ public Class getType() { /** * Reads the array. */ + @Override public Object readList(AbstractHessianInput in, int length) throws IOException { if (length >= 0) { @@ -124,6 +126,7 @@ public Object readList(AbstractHessianInput in, int length) /** * Reads the array. */ + @Override public Object readLengthList(AbstractHessianInput in, int length) throws IOException { Object[] data = createArray(length); @@ -148,6 +151,7 @@ protected Object[] createArray(int length) { return new Object[length]; } + @Override public String toString() { return "ArrayDeserializer[" + _componentType + "]"; } diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/ArraySerializer.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/ArraySerializer.java index 31d7ca5f984..d6cfcc5cb4d 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/ArraySerializer.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/ArraySerializer.java @@ -54,6 +54,7 @@ * Serializing a Java array. */ public class ArraySerializer extends AbstractSerializer { + @Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { if (out.addRef(obj)) diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/BasicDeserializer.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/BasicDeserializer.java index 6b56d90ae7f..20c593f38be 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/BasicDeserializer.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/BasicDeserializer.java @@ -88,6 +88,7 @@ public BasicDeserializer(int code) { _code = code; } + @Override public Class getType() { switch (_code) { case NULL: @@ -144,6 +145,7 @@ public Class getType() { } } + @Override public Object readObject(AbstractHessianInput in) throws IOException { switch (_code) { @@ -265,6 +267,7 @@ public Object readObject(AbstractHessianInput in) } } + @Override public Object readList(AbstractHessianInput in, int length) throws IOException { switch (_code) { @@ -509,6 +512,7 @@ public Object readList(AbstractHessianInput in, int length) } } + @Override public Object readLengthList(AbstractHessianInput in, int length) throws IOException { switch (_code) { diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/BasicSerializer.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/BasicSerializer.java index dcaa9aa141d..6d5aee9f30a 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/BasicSerializer.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/BasicSerializer.java @@ -87,6 +87,7 @@ public BasicSerializer(int code) { this.code = code; } + @Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { switch (code) { diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/BeanDeserializer.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/BeanDeserializer.java index 81c60ca8570..a0f16c81ca1 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/BeanDeserializer.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/BeanDeserializer.java @@ -116,10 +116,12 @@ else if (double.class.equals(cl)) throw new UnsupportedOperationException(); } + @Override public Class getType() { return _type; } + @Override public Object readMap(AbstractHessianInput in) throws IOException { try { diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/BeanSerializer.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/BeanSerializer.java index e663cf6513d..a3a8ba5f226 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/BeanSerializer.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/BeanSerializer.java @@ -202,6 +202,7 @@ protected Method getWriteReplace(Class cl, Class param) { return null; } + @Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { if (out.addRef(obj)) @@ -301,6 +302,7 @@ private Method findSetter(Method[] methods, String getterName, Class arg) { } static class MethodNameCmp implements Comparator { + @Override public int compare(Method a, Method b) { return a.getName().compareTo(b.getName()); } diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/BeanSerializerFactory.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/BeanSerializerFactory.java index 2625e80198f..7c8e328a485 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/BeanSerializerFactory.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/BeanSerializerFactory.java @@ -60,6 +60,7 @@ public class BeanSerializerFactory extends SerializerFactory { * @param cl the class of the object that needs to be serialized. * @return a serializer object for the serialization. */ + @Override protected Serializer getDefaultSerializer(Class cl) { return new BeanSerializer(cl, getClassLoader()); } @@ -72,6 +73,7 @@ protected Serializer getDefaultSerializer(Class cl) { * @param cl the class of the object that needs to be serialized. * @return a serializer object for the serialization. */ + @Override protected Deserializer getDefaultDeserializer(Class cl) { return new BeanDeserializer(cl); } diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/CalendarSerializer.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/CalendarSerializer.java index 4ea9f5606be..0db6c148918 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/CalendarSerializer.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/CalendarSerializer.java @@ -61,6 +61,7 @@ public static CalendarSerializer create() { return SERIALIZER; } + @Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { if (obj == null) diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/ClassDeserializer.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/ClassDeserializer.java index 890a9e5785c..422333c6a32 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/ClassDeserializer.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/ClassDeserializer.java @@ -85,10 +85,12 @@ public ClassDeserializer(ClassLoader loader) { _loader = loader; } + @Override public Class getType() { return Class.class; } + @Override public Object readMap(AbstractHessianInput in) throws IOException { int ref = in.addRef(null); @@ -113,6 +115,7 @@ public Object readMap(AbstractHessianInput in) return value; } + @Override public Object readObject(AbstractHessianInput in, String[] fieldNames) throws IOException { int ref = in.addRef(null); diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/ClassSerializer.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/ClassSerializer.java index b65411e5bc1..7529e17b60c 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/ClassSerializer.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/ClassSerializer.java @@ -54,6 +54,7 @@ * Serializing a remote object. */ public class ClassSerializer extends AbstractSerializer { + @Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { Class cl = (Class) obj; diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/CollectionDeserializer.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/CollectionDeserializer.java index f517f541278..2d3390b0098 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/CollectionDeserializer.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/CollectionDeserializer.java @@ -67,10 +67,12 @@ public CollectionDeserializer(Class type) { _type = type; } + @Override public Class getType() { return _type; } + @Override public Object readList(AbstractHessianInput in, int length) throws IOException { return readList(in, length, null); @@ -97,6 +99,7 @@ public Object readList(AbstractHessianInput in, int length, Class expectType) return list; } + @Override public Object readLengthList(AbstractHessianInput in, int length) throws IOException { return readList(in, length, null); diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/CollectionSerializer.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/CollectionSerializer.java index 8d3ef754869..7ede5af0266 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/CollectionSerializer.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/CollectionSerializer.java @@ -74,6 +74,7 @@ public void setSendJavaType(boolean sendJavaType) { _sendJavaType = sendJavaType; } + @Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { if (out.addRef(obj)) diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/Deflation.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/Deflation.java index e26608e7682..11380adedea 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/Deflation.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/Deflation.java @@ -58,6 +58,7 @@ public class Deflation extends HessianEnvelope { public Deflation() { } + @Override public Hessian2Output wrap(Hessian2Output out) throws IOException { OutputStream os = new DeflateOutputStream(out); @@ -69,6 +70,7 @@ public Hessian2Output wrap(Hessian2Output out) return filterOut; } + @Override public Hessian2Input unwrap(Hessian2Input in) throws IOException { int version = in.readEnvelope(); @@ -82,6 +84,7 @@ public Hessian2Input unwrap(Hessian2Input in) return unwrapHeaders(in); } + @Override public Hessian2Input unwrapHeaders(Hessian2Input in) throws IOException { InputStream is = new DeflateInputStream(in); @@ -111,16 +114,19 @@ static class DeflateOutputStream extends OutputStream { _deflateOut = new DeflaterOutputStream(_bodyOut); } + @Override public void write(int ch) throws IOException { _deflateOut.write(ch); } + @Override public void write(byte[] buffer, int offset, int length) throws IOException { _deflateOut.write(buffer, offset, length); } + @Override public void close() throws IOException { Hessian2Output out = _out; @@ -159,16 +165,19 @@ static class DeflateInputStream extends InputStream { _inflateIn = new InflaterInputStream(_bodyIn); } + @Override public int read() throws IOException { return _inflateIn.read(); } + @Override public int read(byte[] buffer, int offset, int length) throws IOException { return _inflateIn.read(buffer, offset, length); } + @Override public void close() throws IOException { Hessian2Input in = _in; diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/EnumDeserializer.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/EnumDeserializer.java index 77db082314f..d1876a8cbc8 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/EnumDeserializer.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/EnumDeserializer.java @@ -75,10 +75,12 @@ else if (cl.getSuperclass().isEnum()) } } + @Override public Class getType() { return _enumType; } + @Override public Object readMap(AbstractHessianInput in) throws IOException { String name = null; @@ -101,6 +103,7 @@ public Object readMap(AbstractHessianInput in) return obj; } + @Override public Object readObject(AbstractHessianInput in, String[] fieldNames) throws IOException { String name = null; diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/EnumSerializer.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/EnumSerializer.java index bddd318102f..6ebf1386de7 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/EnumSerializer.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/EnumSerializer.java @@ -69,6 +69,7 @@ public EnumSerializer(Class cl) { } } + @Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { if (out.addRef(obj)) diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/EnumerationDeserializer.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/EnumerationDeserializer.java index 912e492d330..b912fa8d21a 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/EnumerationDeserializer.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/EnumerationDeserializer.java @@ -64,6 +64,7 @@ public static EnumerationDeserializer create() { return _deserializer; } + @Override public Object readList(AbstractHessianInput in, int length) throws IOException { Vector list = new Vector(); diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/EnumerationSerializer.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/EnumerationSerializer.java index aa8d25c4bc0..0665132d5da 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/EnumerationSerializer.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/EnumerationSerializer.java @@ -64,6 +64,7 @@ public static EnumerationSerializer create() { return _serializer; } + @Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { Enumeration iter = (Enumeration) obj; diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/ExtSerializerFactory.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/ExtSerializerFactory.java index 81be614d6d3..1b11a447dff 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/ExtSerializerFactory.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/ExtSerializerFactory.java @@ -83,6 +83,7 @@ public void addDeserializer(Class cl, Deserializer deserializer) { * @param cl the class of the object that needs to be serialized. * @return a serializer object for the serialization. */ + @Override public Serializer getSerializer(Class cl) throws HessianProtocolException { return (Serializer) _serializerMap.get(cl); @@ -94,6 +95,7 @@ public Serializer getSerializer(Class cl) * @param cl the class of the object that needs to be deserialized. * @return a deserializer object for the serialization. */ + @Override public Deserializer getDeserializer(Class cl) throws HessianProtocolException { return (Deserializer) _deserializerMap.get(cl); diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/Hessian2Input.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/Hessian2Input.java index 395399e64ea..268c6993d89 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/Hessian2Input.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/Hessian2Input.java @@ -145,6 +145,7 @@ public SerializerFactory getSerializerFactory() { /** * Sets the serializer factory. */ + @Override public void setSerializerFactory(SerializerFactory factory) { _serializerFactory = factory; } @@ -172,6 +173,7 @@ public void setCloseStreamOnClose(boolean isClose) { /** * Returns the calls method */ + @Override public String getMethod() { return _method; } @@ -190,6 +192,7 @@ public Throwable getReplyFault() { * c major minor * */ + @Override public int readCall() throws IOException { int tag = read(); @@ -253,6 +256,7 @@ public void completeEnvelope() * string * */ + @Override public String readMethod() throws IOException { _method = readString(); @@ -283,6 +287,7 @@ public int readMethodArgLength() * m b16 b8 method * */ + @Override public void startCall() throws IOException { readCall(); @@ -298,6 +303,7 @@ public void startCall() *
      * 
*/ + @Override public void completeCall() throws IOException { } @@ -345,6 +351,7 @@ else if (tag == 'F') { * r * */ + @Override public void startReply() throws Throwable { // XXX: for variable length (?) @@ -389,6 +396,7 @@ private Throwable prepareFault(HashMap fault) * z * */ + @Override public void completeReply() throws IOException { } @@ -417,6 +425,7 @@ public void completeValueReply() * H b16 b8 value * */ + @Override public String readHeader() throws IOException { return null; @@ -470,6 +479,7 @@ public void completeMessage() * N * */ + @Override public void readNull() throws IOException { int tag = read(); @@ -491,6 +501,7 @@ public void readNull() * F * */ + @Override public boolean readBoolean() throws IOException { int tag = _offset < _length ? (_buffer[_offset++] & 0xff) : read(); @@ -737,6 +748,7 @@ public short readShort() * I b32 b24 b16 b8 * */ + @Override public final int readInt() throws IOException { //int tag = _offset < _length ? (_buffer[_offset++] & 0xff) : read(); @@ -956,6 +968,7 @@ public final int readInt() * L b64 b56 b48 b40 b32 b24 b16 b8 * */ + @Override public long readLong() throws IOException { int tag = read(); @@ -1183,6 +1196,7 @@ public float readFloat() * D b64 b56 b48 b40 b32 b24 b16 b8 * */ + @Override public double readDouble() throws IOException { int tag = read(); @@ -1395,6 +1409,7 @@ public double readDouble() * T b64 b56 b48 b40 b32 b24 b16 b8 * */ + @Override public long readUTCDate() throws IOException { int tag = read(); @@ -1561,6 +1576,7 @@ else if (_chunkLength > 0 || !_isLastChunk) * S b16 b8 string value * */ + @Override public String readString() throws IOException { int tag = read(); @@ -1846,6 +1862,7 @@ public String readString() * B b16 b8 data value * */ + @Override public byte[] readBytes() throws IOException { int tag = read(); @@ -2052,6 +2069,7 @@ private HashMap readFault() /** * Reads an object from the input stream with an expected type. */ + @Override public Object readObject(Class cl) throws IOException { return readObject(cl, null, null); @@ -2255,6 +2273,7 @@ public Object readObject(Class expectedClass, Class... expectedTypes) throws * Reads an arbitrary object from the input stream when the type * is unknown. */ + @Override public Object readObject() throws IOException { return readObject((List>) null); @@ -2823,6 +2842,7 @@ private String readLenString(int len) /** * Reads a remote object. */ + @Override public Object readRemote() throws IOException { String type = readType(); @@ -2834,6 +2854,7 @@ public Object readRemote() /** * Reads a reference. */ + @Override public Object readRef() throws IOException { return _refs.get(parseInt()); @@ -2842,6 +2863,7 @@ public Object readRef() /** * Reads the start of a list. */ + @Override public int readListStart() throws IOException { return read(); @@ -2850,6 +2872,7 @@ public int readListStart() /** * Reads the start of a list. */ + @Override public int readMapStart() throws IOException { return read(); @@ -2858,6 +2881,7 @@ public int readMapStart() /** * Returns true if this is the end of a list or a map. */ + @Override public boolean isEnd() throws IOException { int code; @@ -2877,6 +2901,7 @@ public boolean isEnd() /** * Reads the end byte. */ + @Override public void readEnd() throws IOException { int code = _offset < _length ? (_buffer[_offset++] & 0xff) : read(); @@ -2892,6 +2917,7 @@ else if (code < 0) /** * Reads the end byte. */ + @Override public void readMapEnd() throws IOException { int code = _offset < _length ? (_buffer[_offset++] & 0xff) : read(); @@ -2903,6 +2929,7 @@ public void readMapEnd() /** * Reads the end byte. */ + @Override public void readListEnd() throws IOException { int code = _offset < _length ? (_buffer[_offset++] & 0xff) : read(); @@ -2914,6 +2941,7 @@ public void readListEnd() /** * Adds a list/map reference. */ + @Override public int addRef(Object ref) { if (_refs == null) _refs = new ArrayList(); @@ -2926,6 +2954,7 @@ public int addRef(Object ref) { /** * Adds a list/map reference. */ + @Override public void setRef(int i, Object ref) { _refs.set(i, ref); } @@ -2933,6 +2962,7 @@ public void setRef(int i, Object ref) { /** * Resets the references for streaming. */ + @Override public void resetReferences() { if (_refs != null) _refs.clear(); @@ -2967,6 +2997,7 @@ public Object resolveRemote(String type, String url) * type ::= int * */ + @Override public String readType() throws IOException { int code = _offset < _length ? (_buffer[_offset++] & 0xff) : read(); @@ -3041,6 +3072,7 @@ public String readType() * l b32 b24 b16 b8 * */ + @Override public int readLength() throws IOException { throw new UnsupportedOperationException(); @@ -3297,6 +3329,7 @@ private int parseByte() /** * Reads bytes based on an input stream. */ + @Override public InputStream readInputStream() throws IOException { int tag = read(); @@ -3452,6 +3485,7 @@ private final boolean readBuffer() return true; } + @Override public Reader getReader() { return null; } @@ -3496,6 +3530,7 @@ protected IOException error(String message) { return new HessianProtocolException(message); } + @Override public void close() throws IOException { InputStream is = _is; @@ -3528,6 +3563,7 @@ String[] getFieldNames() { class ReadInputStream extends InputStream { boolean _isClosed = false; + @Override public int read() throws IOException { if (_isClosed) @@ -3540,6 +3576,7 @@ public int read() return ch; } + @Override public int read(byte[] buffer, int offset, int length) throws IOException { if (_isClosed) @@ -3552,6 +3589,7 @@ public int read(byte[] buffer, int offset, int length) return len; } + @Override public void close() throws IOException { while (read() >= 0) { diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/Hessian2Output.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/Hessian2Output.java index 10c9d5d7ded..3eb98b577ba 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/Hessian2Output.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/Hessian2Output.java @@ -138,6 +138,7 @@ public void call(String method, Object[] args) * * @param method the method name to call. */ + @Override public void startCall(String method, int length) throws IOException { int offset = _offset; @@ -165,6 +166,7 @@ public void startCall(String method, int length) * * @param method the method name to call. */ + @Override public void startCall() throws IOException { flushIfFull(); @@ -221,6 +223,7 @@ public void completeEnvelope() * * @param method the method name to call. */ + @Override public void writeMethod(String method) throws IOException { writeString(method); @@ -233,6 +236,7 @@ public void writeMethod(String method) * z * */ + @Override public void completeCall() throws IOException { /* @@ -251,6 +255,7 @@ public void completeCall() * R * */ + @Override public void startReply() throws IOException { writeVersion(); @@ -277,6 +282,7 @@ public void writeVersion() * z * */ + @Override public void completeReply() throws IOException { } @@ -340,6 +346,7 @@ public void completeMessage() * * @param code the fault code, a three digit */ + @Override public void writeFault(String code, String message, Object detail) throws IOException { flushIfFull(); @@ -369,6 +376,7 @@ public void writeFault(String code, String message, Object detail) /** * Writes any object to the output stream. */ + @Override public void writeObject(Object object) throws IOException { if (object == null) { @@ -395,6 +403,7 @@ public void writeObject(Object object) * * @return true for variable lists, false for fixed lists */ + @Override public boolean writeListBegin(int length, String type) throws IOException { flushIfFull(); @@ -433,6 +442,7 @@ public boolean writeListBegin(int length, String type) /** * Writes the tail of the list to the stream for a variable-length list. */ + @Override public void writeListEnd() throws IOException { flushIfFull(); @@ -450,6 +460,7 @@ public void writeListEnd() * ::= H ( )* Z * */ + @Override public void writeMapBegin(String type) throws IOException { if (SIZE < _offset + 32) @@ -466,6 +477,7 @@ public void writeMapBegin(String type) /** * Writes the tail of the map to the stream. */ + @Override public void writeMapEnd() throws IOException { if (SIZE < _offset + 32) @@ -481,6 +493,7 @@ public void writeMapEnd() * C <string> <int> <string>* * */ + @Override public int writeObjectBegin(String type) throws IOException { if (_classRefs == null) @@ -521,6 +534,7 @@ public int writeObjectBegin(String type) /** * Writes the tail of the class definition to the stream. */ + @Override public void writeClassFieldLength(int len) throws IOException { writeInt(len); @@ -529,6 +543,7 @@ public void writeClassFieldLength(int len) /** * Writes the tail of the object definition to the stream. */ + @Override public void writeObjectEnd() throws IOException { } @@ -575,6 +590,7 @@ private void writeType(String type) * * @param value the boolean value to write. */ + @Override public void writeBoolean(boolean value) throws IOException { if (SIZE < _offset + 16) @@ -596,6 +612,7 @@ public void writeBoolean(boolean value) * * @param value the integer value to write. */ + @Override public void writeInt(int value) throws IOException { int offset = _offset; @@ -636,6 +653,7 @@ else if (INT_BYTE_MIN <= value && value <= INT_BYTE_MAX) { * * @param value the long value to write. */ + @Override public void writeLong(long value) throws IOException { int offset = _offset; @@ -690,6 +708,7 @@ public void writeLong(long value) * * @param value the double value to write. */ + @Override public void writeDouble(double value) throws IOException { int offset = _offset; @@ -772,6 +791,7 @@ public void writeDouble(double value) * * @param time the date in milliseconds from the epoch in UTC */ + @Override public void writeUTCDate(long time) throws IOException { if (SIZE < _offset + 32) @@ -820,6 +840,7 @@ public void writeUTCDate(long time) * * @param value the string value to write. */ + @Override public void writeNull() throws IOException { int offset = _offset; @@ -851,6 +872,7 @@ public void writeNull() * * @param value the string value to write. */ + @Override public void writeString(String value) throws IOException { int offset = _offset; @@ -937,6 +959,7 @@ public void writeString(String value) * * @param value the string value to write. */ + @Override public void writeString(char[] buffer, int offset, int length) throws IOException { if (buffer == null) { @@ -1001,6 +1024,7 @@ public void writeString(char[] buffer, int offset, int length) * * @param value the string value to write. */ + @Override public void writeBytes(byte[] buffer) throws IOException { if (buffer == null) { @@ -1028,6 +1052,7 @@ public void writeBytes(byte[] buffer) * * @param value the string value to write. */ + @Override public void writeBytes(byte[] buffer, int offset, int length) throws IOException { if (buffer == null) { @@ -1089,6 +1114,7 @@ public void writeBytes(byte[] buffer, int offset, int length) *
      * 
*/ + @Override public void writeByteBufferStart() throws IOException { } @@ -1100,6 +1126,7 @@ public void writeByteBufferStart() * b b16 b18 bytes * */ + @Override public void writeByteBufferPart(byte[] buffer, int offset, int length) throws IOException { while (length > 0) { @@ -1128,6 +1155,7 @@ public void writeByteBufferPart(byte[] buffer, int offset, int length) * b b16 b18 bytes * */ + @Override public void writeByteBufferEnd(byte[] buffer, int offset, int length) throws IOException { writeBytes(buffer, offset, length); @@ -1166,6 +1194,7 @@ protected void writeRef(int value) * * @return true if we're writing a ref. */ + @Override public boolean addRef(Object object) throws IOException { int ref = _refs.get(object); @@ -1184,6 +1213,7 @@ public boolean addRef(Object object) /** * Removes a reference. */ + @Override public boolean removeRef(Object obj) throws IOException { if (_refs != null) { @@ -1197,6 +1227,7 @@ public boolean removeRef(Object obj) /** * Replaces a reference from one object to another. */ + @Override public boolean replaceRef(Object oldRef, Object newRef) throws IOException { Integer value = (Integer) _refs.remove(oldRef); @@ -1211,6 +1242,7 @@ public boolean replaceRef(Object oldRef, Object newRef) /** * Resets the references for streaming. */ + @Override public void resetReferences() { if (_refs != null) _refs.clear(); @@ -1377,6 +1409,7 @@ private final void flushIfFull() } } + @Override public final void flush() throws IOException { flushBuffer(); @@ -1404,6 +1437,7 @@ public final void flushBuffer() } } + @Override public final void close() throws IOException { // hessian/3a8c diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/Hessian2StreamingInput.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/Hessian2StreamingInput.java index d935529368a..ebf8b779bd0 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/Hessian2StreamingInput.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/Hessian2StreamingInput.java @@ -91,6 +91,7 @@ static class StreamingInputStream extends InputStream { _is = is; } + @Override public int read() throws IOException { InputStream is = _is; @@ -117,6 +118,7 @@ else if (code != 'p' && code != 'P') return is.read(); } + @Override public int read(byte[] buffer, int offset, int length) throws IOException { InputStream is = _is; diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/HessianDebugInputStream.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/HessianDebugInputStream.java index 0485dde99a3..092fa22822e 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/HessianDebugInputStream.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/HessianDebugInputStream.java @@ -89,6 +89,7 @@ public void startTop2() { /** * Reads a character. */ + @Override public int read() throws IOException { int ch; @@ -109,6 +110,7 @@ public int read() /** * closes the stream. */ + @Override public void close() throws IOException { InputStream is = _is; @@ -138,6 +140,7 @@ public void write(char ch) { _sb.append((char) ch); } + @Override public void write(char[] buffer, int offset, int length) { for (int i = 0; i < length; i++) { char ch = buffer[offset + i]; @@ -150,9 +153,11 @@ public void write(char[] buffer, int offset, int length) { } } + @Override public void flush() { } + @Override public void close() { } } diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/HessianDebugOutputStream.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/HessianDebugOutputStream.java index 4e602465ff7..5d45d930e0a 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/HessianDebugOutputStream.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/HessianDebugOutputStream.java @@ -86,6 +86,7 @@ public void startTop2() { /** * Writes a character. */ + @Override public void write(int ch) throws IOException { ch = ch & 0xff; @@ -95,6 +96,7 @@ public void write(int ch) _state.next(ch); } + @Override public void flush() throws IOException { _os.flush(); @@ -103,6 +105,7 @@ public void flush() /** * closes the stream. */ + @Override public void close() throws IOException { OutputStream os = _os; @@ -132,6 +135,7 @@ public void write(char ch) { _sb.append((char) ch); } + @Override public void write(char[] buffer, int offset, int length) { for (int i = 0; i < length; i++) { char ch = buffer[offset + i]; @@ -144,9 +148,11 @@ public void write(char[] buffer, int offset, int length) { } } + @Override public void flush() { } + @Override public void close() { } } diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/HessianDebugState.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/HessianDebugState.java index 790796278d7..07982890707 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/HessianDebugState.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/HessianDebugState.java @@ -782,6 +782,7 @@ protected State nextObject(int ch) { } class InitialState extends State { + @Override State next(int ch) { println(); @@ -795,6 +796,7 @@ State next(int ch) { } class Top2State extends State { + @Override State next(int ch) { println(); @@ -836,6 +838,7 @@ class IntegerState extends State { _length = length; } + @Override State next(int ch) { _value = 256 * _value + (ch & 0xff); @@ -875,6 +878,7 @@ class LongState extends State { _length = length; } + @Override State next(int ch) { _value = 256 * _value + (ch & 0xff); @@ -904,6 +908,7 @@ class DoubleIntegerState extends State { _length = length; } + @Override State next(int ch) { if (_isFirst) _value = (byte) ch; @@ -987,6 +992,7 @@ class DateState extends State { } + @Override State next(int ch) { _value = 256 * _value + (ch & 0xff); @@ -1018,6 +1024,7 @@ class DoubleState extends State { super(next); } + @Override State next(int ch) { _value = 256 * _value + (ch & 0xff); @@ -1044,6 +1051,7 @@ class MillsState extends State { super(next); } + @Override State next(int ch) { _value = 256 * _value + (ch & 0xff); @@ -1103,6 +1111,7 @@ class StringState extends State { _lengthIndex = 1; } + @Override State next(int ch) { if (_lengthIndex < 2) { _length = 256 * _length + (ch & 0xff); @@ -1224,6 +1233,7 @@ class BinaryState extends State { _lengthIndex = 1; } + @Override State next(int ch) { if (_lengthIndex < 2) { _length = 256 * _length + (ch & 0xff); @@ -1353,6 +1363,7 @@ else if (_state == KEY) return _valueDepth; } + @Override State next(int ch) { switch (_state) { case TYPE: @@ -1455,6 +1466,7 @@ int depth() { return _next.depth() + 2; } + @Override State next(int ch) { switch (_state) { case TYPE: @@ -1545,6 +1557,7 @@ int depth() { return _fieldDepth; } + @Override State next(int ch) { switch (_state) { case TYPE: @@ -1638,6 +1651,7 @@ else if (_state == VALUE) return _next.depth() + 2; } + @Override State next(int ch) { switch (_state) { case TYPE: @@ -1768,6 +1782,7 @@ else if (_state == VALUE) return _next.depth() + 2; } + @Override State next(int ch) { switch (_state) { case TYPE: @@ -1807,10 +1822,12 @@ class Hessian2State extends State { super(next); } + @Override int depth() { return _next.depth() + 2; } + @Override State next(int ch) { switch (_state) { case MAJOR: @@ -1845,10 +1862,12 @@ class CallState extends State { super(next); } + @Override int depth() { return _next.depth() + 2; } + @Override State next(int ch) { switch (_state) { case MAJOR: @@ -1911,6 +1930,7 @@ class Call2State extends State { super(next); } + @Override int depth() { return _next.depth() + 5; } @@ -1982,10 +2002,12 @@ class ReplyState extends State { _next = next; } + @Override int depth() { return _next.depth() + 2; } + @Override State next(int ch) { switch (_state) { case MAJOR: @@ -2040,6 +2062,7 @@ class Reply2State extends State { println(-2, "Reply"); } + @Override int depth() { return _next.depth() + 2; } @@ -2057,6 +2080,7 @@ class Fault2State extends State { println(-2, "Fault"); } + @Override int depth() { return _next.depth() + 2; } @@ -2072,14 +2096,17 @@ class IndirectState extends State { super(next); } + @Override boolean isShift(Object object) { return _next.isShift(object); } + @Override State shift(Object object) { return _next.shift(object); } + @Override State next(int ch) { return nextObject(ch); } @@ -2098,6 +2125,7 @@ class RemoteState extends State { super(next); } + @Override State next(int ch) { switch (_state) { case TYPE: @@ -2138,6 +2166,7 @@ class StreamingState extends State { _childState = new InitialState(); } + @Override State next(int ch) { if (_digit < 2) { _length = 256 * _length + ch; diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/HessianInput.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/HessianInput.java index 62bb50047c0..c71f310148b 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/HessianInput.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/HessianInput.java @@ -130,6 +130,7 @@ public SerializerFactory getSerializerFactory() { /** * Sets the serializer factory. */ + @Override public void setSerializerFactory(SerializerFactory factory) { _serializerFactory = factory; } @@ -137,6 +138,7 @@ public void setSerializerFactory(SerializerFactory factory) { /** * Initialize the hessian stream with the underlying input stream. */ + @Override public void init(InputStream is) { _is = is; _method = null; @@ -153,6 +155,7 @@ public void init(InputStream is) { /** * Returns the calls method */ + @Override public String getMethod() { return _method; } @@ -171,6 +174,7 @@ public Throwable getReplyFault() { * c major minor * */ + @Override public int readCall() throws IOException { int tag = read(); @@ -187,6 +191,7 @@ public int readCall() /** * For backward compatibility with HessianSkeleton */ + @Override public void skipOptionalCall() throws IOException { int tag = read(); @@ -207,6 +212,7 @@ public void skipOptionalCall() * m b16 b8 method * */ + @Override public String readMethod() throws IOException { int tag = read(); @@ -238,6 +244,7 @@ public String readMethod() * m b16 b8 method * */ + @Override public void startCall() throws IOException { readCall(); @@ -258,6 +265,7 @@ public void startCall() * z * */ + @Override public void completeCall() throws IOException { int tag = read(); @@ -271,6 +279,7 @@ public void completeCall() * Reads a reply as an object. * If the reply has a fault, throws the exception. */ + @Override public Object readReply(Class expectedClass) throws Throwable { int tag = read(); @@ -304,6 +313,7 @@ public Object readReply(Class expectedClass) * r * */ + @Override public void startReply() throws Throwable { int tag = read(); @@ -360,6 +370,7 @@ private Throwable prepareFault() * z * */ + @Override public void completeReply() throws IOException { int tag = read(); @@ -392,6 +403,7 @@ public void completeValueReply() * H b16 b8 value * */ + @Override public String readHeader() throws IOException { int tag = read(); @@ -420,6 +432,7 @@ public String readHeader() * N * */ + @Override public void readNull() throws IOException { int tag = read(); @@ -456,6 +469,7 @@ public byte readByte() * F * */ + @Override public boolean readBoolean() throws IOException { int tag = read(); @@ -498,6 +512,7 @@ public short readShort() * I b32 b24 b16 b8 * */ + @Override public int readInt() throws IOException { int tag = read(); @@ -526,6 +541,7 @@ public int readInt() * L b64 b56 b48 b40 b32 b24 b16 b8 * */ + @Override public long readLong() throws IOException { int tag = read(); @@ -566,6 +582,7 @@ public float readFloat() * D b64 b56 b48 b40 b32 b24 b16 b8 * */ + @Override public double readDouble() throws IOException { int tag = read(); @@ -594,6 +611,7 @@ public double readDouble() * T b64 b56 b48 b40 b32 b24 b16 b8 * */ + @Override public long readUTCDate() throws IOException { int tag = read(); @@ -743,6 +761,7 @@ else if (_chunkLength > 0 || !_isLastChunk) * S b16 b8 string value * */ + @Override public String readString() throws IOException { int tag = read(); @@ -785,6 +804,7 @@ public String readString() * S b16 b8 string value * */ + @Override public org.w3c.dom.Node readNode() throws IOException { int tag = read(); @@ -814,6 +834,7 @@ public org.w3c.dom.Node readNode() * B b16 b8 data value * */ + @Override public byte[] readBytes() throws IOException { int tag = read(); @@ -975,6 +996,7 @@ private HashMap readFault() /** * Reads an object from the input stream with an expected type. */ + @Override public Object readObject(Class cl) throws IOException { if (cl == null || cl == Object.class) @@ -1048,6 +1070,7 @@ public Object readObject(Class cl) * Reads an arbitrary object from the input stream when the type * is unknown. */ + @Override public Object readObject() throws IOException { int tag = read(); @@ -1144,6 +1167,7 @@ public Object readObject() /** * Reads a remote object. */ + @Override public Object readRemote() throws IOException { String type = readType(); @@ -1155,6 +1179,7 @@ public Object readRemote() /** * Reads a reference. */ + @Override public Object readRef() throws IOException { return _refs.get(parseInt()); @@ -1163,6 +1188,7 @@ public Object readRef() /** * Reads the start of a list. */ + @Override public int readListStart() throws IOException { return read(); @@ -1171,6 +1197,7 @@ public int readListStart() /** * Reads the start of a list. */ + @Override public int readMapStart() throws IOException { return read(); @@ -1179,6 +1206,7 @@ public int readMapStart() /** * Returns true if this is the end of a list or a map. */ + @Override public boolean isEnd() throws IOException { int code = read(); @@ -1191,6 +1219,7 @@ public boolean isEnd() /** * Reads the end byte. */ + @Override public void readEnd() throws IOException { int code = read(); @@ -1202,6 +1231,7 @@ public void readEnd() /** * Reads the end byte. */ + @Override public void readMapEnd() throws IOException { int code = read(); @@ -1213,6 +1243,7 @@ public void readMapEnd() /** * Reads the end byte. */ + @Override public void readListEnd() throws IOException { int code = read(); @@ -1224,6 +1255,7 @@ public void readListEnd() /** * Adds a list/map reference. */ + @Override public int addRef(Object ref) { if (_refs == null) _refs = new ArrayList(); @@ -1236,6 +1268,7 @@ public int addRef(Object ref) { /** * Adds a list/map reference. */ + @Override public void setRef(int i, Object ref) { _refs.set(i, ref); } @@ -1243,6 +1276,7 @@ public void setRef(int i, Object ref) { /** * Resets the references for streaming. */ + @Override public void resetReferences() { if (_refs != null) _refs.clear(); @@ -1268,6 +1302,7 @@ public Object resolveRemote(String type, String url) * t b16 b8 * */ + @Override public String readType() throws IOException { int code = read(); @@ -1295,6 +1330,7 @@ public String readType() * l b32 b24 b16 b8 * */ + @Override public int readLength() throws IOException { int code = read(); @@ -1486,6 +1522,7 @@ private int parseByte() /** * Reads bytes based on an input stream. */ + @Override public InputStream readInputStream() throws IOException { int tag = read(); @@ -1507,6 +1544,7 @@ public InputStream readInputStream() return new InputStream() { boolean _isClosed = false; + @Override public int read() throws IOException { if (_isClosed || _is == null) @@ -1519,6 +1557,7 @@ public int read() return ch; } + @Override public int read(byte[] buffer, int offset, int length) throws IOException { if (_isClosed || _is == null) @@ -1531,6 +1570,7 @@ public int read(byte[] buffer, int offset, int length) return len; } + @Override public void close() throws IOException { while (read() >= 0) { @@ -1600,10 +1640,12 @@ final int read() return ch; } + @Override public void close() { _is = null; } + @Override public Reader getReader() { return null; } diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/HessianOutput.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/HessianOutput.java index 27bc974f957..aad614b98e5 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/HessianOutput.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/HessianOutput.java @@ -98,6 +98,7 @@ public HessianOutput() { /** * Initializes the output */ + @Override public void init(OutputStream os) { this.os = os; @@ -117,6 +118,7 @@ public void setVersion(int version) { /** * Writes a complete method call. */ + @Override public void call(String method, Object[] args) throws IOException { int length = args != null ? args.length : 0; @@ -141,6 +143,7 @@ public void call(String method, Object[] args) * * @param method the method name to call. */ + @Override public void startCall(String method, int length) throws IOException { os.write('c'); @@ -164,6 +167,7 @@ public void startCall(String method, int length) * * @param method the method name to call. */ + @Override public void startCall() throws IOException { os.write('c'); @@ -180,6 +184,7 @@ public void startCall() * * @param method the method name to call. */ + @Override public void writeMethod(String method) throws IOException { os.write('m'); @@ -196,6 +201,7 @@ public void writeMethod(String method) * z * */ + @Override public void completeCall() throws IOException { os.write('z'); @@ -210,6 +216,7 @@ public void completeCall() * r * */ + @Override public void startReply() throws IOException { os.write('r'); @@ -226,6 +233,7 @@ public void startReply() * z * */ + @Override public void completeReply() throws IOException { os.write('z'); @@ -238,6 +246,7 @@ public void completeReply() * H b16 b8 foo value * */ + @Override public void writeHeader(String name) throws IOException { int len = name.length(); @@ -270,6 +279,7 @@ public void writeHeader(String name) * * @param code the fault code, a three digit */ + @Override public void writeFault(String code, String message, Object detail) throws IOException { os.write('f'); @@ -289,6 +299,7 @@ public void writeFault(String code, String message, Object detail) /** * Writes any object to the output stream. */ + @Override public void writeObject(Object object) throws IOException { if (object == null) { @@ -314,6 +325,7 @@ public void writeObject(Object object) * l b32 b24 b16 b8 * */ + @Override public boolean writeListBegin(int length, String type) throws IOException { os.write('V'); @@ -337,6 +349,7 @@ public boolean writeListBegin(int length, String type) /** * Writes the tail of the list to the stream. */ + @Override public void writeListEnd() throws IOException { os.write('z'); @@ -351,6 +364,7 @@ public void writeListEnd() * Mt b16 b8 ( )z * */ + @Override public void writeMapBegin(String type) throws IOException { os.write('M'); @@ -361,6 +375,7 @@ public void writeMapBegin(String type) /** * Writes the tail of the map to the stream. */ + @Override public void writeMapEnd() throws IOException { os.write('z'); @@ -394,6 +409,7 @@ public void writeRemote(String type, String url) * * @param value the boolean value to write. */ + @Override public void writeBoolean(boolean value) throws IOException { if (value) @@ -412,6 +428,7 @@ public void writeBoolean(boolean value) * * @param value the integer value to write. */ + @Override public void writeInt(int value) throws IOException { os.write('I'); @@ -431,6 +448,7 @@ public void writeInt(int value) * * @param value the long value to write. */ + @Override public void writeLong(long value) throws IOException { os.write('L'); @@ -454,6 +472,7 @@ public void writeLong(long value) * * @param value the double value to write. */ + @Override public void writeDouble(double value) throws IOException { long bits = Double.doubleToLongBits(value); @@ -478,6 +497,7 @@ public void writeDouble(double value) * * @param time the date in milliseconds from the epoch in UTC */ + @Override public void writeUTCDate(long time) throws IOException { os.write('d'); @@ -501,6 +521,7 @@ public void writeUTCDate(long time) * * @param value the string value to write. */ + @Override public void writeNull() throws IOException { os.write('N'); @@ -522,6 +543,7 @@ public void writeNull() * * @param value the string value to write. */ + @Override public void writeString(String value) throws IOException { if (value == null) { @@ -573,6 +595,7 @@ public void writeString(String value) * * @param value the string value to write. */ + @Override public void writeString(char[] buffer, int offset, int length) throws IOException { if (buffer == null) { @@ -621,6 +644,7 @@ public void writeString(char[] buffer, int offset, int length) * * @param value the string value to write. */ + @Override public void writeBytes(byte[] buffer) throws IOException { if (buffer == null) @@ -645,6 +669,7 @@ public void writeBytes(byte[] buffer) * * @param value the string value to write. */ + @Override public void writeBytes(byte[] buffer, int offset, int length) throws IOException { if (buffer == null) { @@ -676,6 +701,7 @@ public void writeBytes(byte[] buffer, int offset, int length) *
      * 
*/ + @Override public void writeByteBufferStart() throws IOException { } @@ -687,6 +713,7 @@ public void writeByteBufferStart() * b b16 b18 bytes * */ + @Override public void writeByteBufferPart(byte[] buffer, int offset, int length) throws IOException { while (length > 0) { @@ -713,6 +740,7 @@ public void writeByteBufferPart(byte[] buffer, int offset, int length) * b b16 b18 bytes * */ + @Override public void writeByteBufferEnd(byte[] buffer, int offset, int length) throws IOException { writeBytes(buffer, offset, length); @@ -727,6 +755,7 @@ public void writeByteBufferEnd(byte[] buffer, int offset, int length) * * @param value the integer value to write. */ + @Override public void writeRef(int value) throws IOException { os.write('R'); @@ -753,6 +782,7 @@ public void writePlaceholder() * * @return true if we're writing a ref. */ + @Override public boolean addRef(Object object) throws IOException { if (_refs == null) @@ -775,6 +805,7 @@ public boolean addRef(Object object) /** * Resets the references for streaming. */ + @Override public void resetReferences() { if (_refs != null) _refs.clear(); @@ -783,6 +814,7 @@ public void resetReferences() { /** * Removes a reference. */ + @Override public boolean removeRef(Object obj) throws IOException { if (_refs != null) { @@ -796,6 +828,7 @@ public boolean removeRef(Object obj) /** * Replaces a reference from one object to another. */ + @Override public boolean replaceRef(Object oldRef, Object newRef) throws IOException { Integer value = (Integer) _refs.remove(oldRef); @@ -882,12 +915,14 @@ else if (ch < 0x800) { } } + @Override public void flush() throws IOException { if (this.os != null) this.os.flush(); } + @Override public void close() throws IOException { if (this.os != null) diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/HessianProtocolException.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/HessianProtocolException.java index 6456c1c9058..28aa320a926 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/HessianProtocolException.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/HessianProtocolException.java @@ -98,6 +98,7 @@ public Throwable getRootCause() { /** * Returns the underlying cause. */ + @Override public Throwable getCause() { return getRootCause(); } diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/HessianRemote.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/HessianRemote.java index 0bf6611adff..0f5755e8986 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/HessianRemote.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/HessianRemote.java @@ -97,6 +97,7 @@ public void setURL(String url) { /** * Defines the hashcode. */ + @Override public int hashCode() { return url.hashCode(); } @@ -104,6 +105,7 @@ public int hashCode() { /** * Defines equality */ + @Override public boolean equals(Object obj) { if (!(obj instanceof HessianRemote)) return false; @@ -116,6 +118,7 @@ public boolean equals(Object obj) { /** * Readable version of the remote. */ + @Override public String toString() { return "[HessianRemote " + url + "]"; } diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/IOExceptionWrapper.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/IOExceptionWrapper.java index 9b66c805c7d..261d4beca74 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/IOExceptionWrapper.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/IOExceptionWrapper.java @@ -68,6 +68,7 @@ public IOExceptionWrapper(String msg, Throwable cause) { _cause = cause; } + @Override public Throwable getCause() { return _cause; } diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/InputStreamDeserializer.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/InputStreamDeserializer.java index ab44e606f80..2dd02908e5d 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/InputStreamDeserializer.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/InputStreamDeserializer.java @@ -57,6 +57,7 @@ public class InputStreamDeserializer extends AbstractDeserializer { public InputStreamDeserializer() { } + @Override public Object readObject(AbstractHessianInput in) throws IOException { return in.readInputStream(); diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/InputStreamSerializer.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/InputStreamSerializer.java index aef872fb224..9bf87e6913a 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/InputStreamSerializer.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/InputStreamSerializer.java @@ -58,6 +58,7 @@ public class InputStreamSerializer extends AbstractSerializer { public InputStreamSerializer() { } + @Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { InputStream is = (InputStream) obj; diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/IteratorSerializer.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/IteratorSerializer.java index e09f0c9881b..2d704d2630d 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/IteratorSerializer.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/IteratorSerializer.java @@ -64,6 +64,7 @@ public static IteratorSerializer create() { return _serializer; } + @Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { Iterator iter = (Iterator) obj; diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/JavaDeserializer.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/JavaDeserializer.java index 86543367ffb..fb5b3127b55 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/JavaDeserializer.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/JavaDeserializer.java @@ -173,10 +173,12 @@ else if (e instanceof IOException) throw new HessianFieldException(fieldName + ": " + field.getType().getName() + " cannot be assigned from null", e); } + @Override public Class getType() { return _type; } + @Override public Object readMap(AbstractHessianInput in) throws IOException { try { @@ -192,6 +194,7 @@ public Object readMap(AbstractHessianInput in) } } + @Override public Object readObject(AbstractHessianInput in, String[] fieldNames) throws IOException { try { @@ -396,6 +399,7 @@ static class ObjectFieldDeserializer extends FieldDeserializer { _field = field; } + @Override void deserialize(AbstractHessianInput in, Object obj) throws IOException { Object value = null; @@ -417,6 +421,7 @@ static class BooleanFieldDeserializer extends FieldDeserializer { _field = field; } + @Override void deserialize(AbstractHessianInput in, Object obj) throws IOException { boolean value = false; @@ -438,6 +443,7 @@ static class ByteFieldDeserializer extends FieldDeserializer { _field = field; } + @Override void deserialize(AbstractHessianInput in, Object obj) throws IOException { int value = 0; @@ -459,6 +465,7 @@ static class ShortFieldDeserializer extends FieldDeserializer { _field = field; } + @Override void deserialize(AbstractHessianInput in, Object obj) throws IOException { int value = 0; @@ -480,6 +487,7 @@ static class ObjectMapFieldDeserializer extends FieldDeserializer { _field = field; } + @Override void deserialize(AbstractHessianInput in, Object obj) throws IOException { Object value = null; @@ -506,6 +514,7 @@ static class ObjectListFieldDeserializer extends FieldDeserializer { _field = field; } + @Override void deserialize(AbstractHessianInput in, Object obj) throws IOException { Object value = null; @@ -531,6 +540,7 @@ static class IntFieldDeserializer extends FieldDeserializer { _field = field; } + @Override void deserialize(AbstractHessianInput in, Object obj) throws IOException { int value = 0; @@ -552,6 +562,7 @@ static class LongFieldDeserializer extends FieldDeserializer { _field = field; } + @Override void deserialize(AbstractHessianInput in, Object obj) throws IOException { long value = 0; @@ -573,6 +584,7 @@ static class FloatFieldDeserializer extends FieldDeserializer { _field = field; } + @Override void deserialize(AbstractHessianInput in, Object obj) throws IOException { double value = 0; @@ -594,6 +606,7 @@ static class DoubleFieldDeserializer extends FieldDeserializer { _field = field; } + @Override void deserialize(AbstractHessianInput in, Object obj) throws IOException { double value = 0; @@ -615,6 +628,7 @@ static class StringFieldDeserializer extends FieldDeserializer { _field = field; } + @Override void deserialize(AbstractHessianInput in, Object obj) throws IOException { String value = null; @@ -636,6 +650,7 @@ static class SqlDateFieldDeserializer extends FieldDeserializer { _field = field; } + @Override void deserialize(AbstractHessianInput in, Object obj) throws IOException { java.sql.Date value = null; @@ -659,6 +674,7 @@ static class SqlTimestampFieldDeserializer extends FieldDeserializer { _field = field; } + @Override void deserialize(AbstractHessianInput in, Object obj) throws IOException { java.sql.Timestamp value = null; @@ -682,6 +698,7 @@ static class SqlTimeFieldDeserializer extends FieldDeserializer { _field = field; } + @Override void deserialize(AbstractHessianInput in, Object obj) throws IOException { java.sql.Time value = null; diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/JavaSerializer.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/JavaSerializer.java index a6c4a132b53..92a090f86da 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/JavaSerializer.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/JavaSerializer.java @@ -201,6 +201,7 @@ protected Method getWriteReplace(Class cl, Class param) { return null; } + @Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { if (out.addRef(obj)) { @@ -308,6 +309,7 @@ void serialize(AbstractHessianOutput out, Object obj, Field field) static class BooleanFieldSerializer extends FieldSerializer { static final FieldSerializer SER = new BooleanFieldSerializer(); + @Override void serialize(AbstractHessianOutput out, Object obj, Field field) throws IOException { boolean value = false; @@ -325,6 +327,7 @@ void serialize(AbstractHessianOutput out, Object obj, Field field) static class IntFieldSerializer extends FieldSerializer { static final FieldSerializer SER = new IntFieldSerializer(); + @Override void serialize(AbstractHessianOutput out, Object obj, Field field) throws IOException { int value = 0; @@ -342,6 +345,7 @@ void serialize(AbstractHessianOutput out, Object obj, Field field) static class LongFieldSerializer extends FieldSerializer { static final FieldSerializer SER = new LongFieldSerializer(); + @Override void serialize(AbstractHessianOutput out, Object obj, Field field) throws IOException { long value = 0; @@ -359,6 +363,7 @@ void serialize(AbstractHessianOutput out, Object obj, Field field) static class DoubleFieldSerializer extends FieldSerializer { static final FieldSerializer SER = new DoubleFieldSerializer(); + @Override void serialize(AbstractHessianOutput out, Object obj, Field field) throws IOException { double value = 0; @@ -376,6 +381,7 @@ void serialize(AbstractHessianOutput out, Object obj, Field field) static class StringFieldSerializer extends FieldSerializer { static final FieldSerializer SER = new StringFieldSerializer(); + @Override void serialize(AbstractHessianOutput out, Object obj, Field field) throws IOException { String value = null; @@ -393,6 +399,7 @@ void serialize(AbstractHessianOutput out, Object obj, Field field) static class DateFieldSerializer extends FieldSerializer { static final FieldSerializer SER = new DateFieldSerializer(); + @Override void serialize(AbstractHessianOutput out, Object obj, Field field) throws IOException { java.util.Date value = null; diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/LocaleSerializer.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/LocaleSerializer.java index 86f6cb0f3c0..2ac93936ae8 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/LocaleSerializer.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/LocaleSerializer.java @@ -61,6 +61,7 @@ public static LocaleSerializer create() { return SERIALIZER; } + @Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { if (obj == null) diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/MapDeserializer.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/MapDeserializer.java index 88415326efc..bc2aa71edc5 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/MapDeserializer.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/MapDeserializer.java @@ -84,6 +84,7 @@ public MapDeserializer(Class type) { } } + @Override public Class getType() { if (_type != null) return _type; @@ -91,6 +92,7 @@ public Class getType() { return HashMap.class; } + @Override public Object readMap(AbstractHessianInput in) throws IOException { return readMap(in, null, null); diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/MapSerializer.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/MapSerializer.java index b15893da3c7..5d48eaa009f 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/MapSerializer.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/MapSerializer.java @@ -73,6 +73,7 @@ public void setSendJavaType(boolean sendJavaType) { _isSendJavaType = sendJavaType; } + @Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { if (out.addRef(obj)) diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/ObjectDeserializer.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/ObjectDeserializer.java index ebd91aee3f1..c4e69f1c763 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/ObjectDeserializer.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/ObjectDeserializer.java @@ -60,25 +60,30 @@ public ObjectDeserializer(Class cl) { _cl = cl; } + @Override public Class getType() { return _cl; } + @Override public Object readObject(AbstractHessianInput in) throws IOException { return in.readObject(); } + @Override public Object readObject(AbstractHessianInput in, String[] fieldNames) throws IOException { throw new UnsupportedOperationException(String.valueOf(this)); } + @Override public Object readList(AbstractHessianInput in, int length) throws IOException { throw new UnsupportedOperationException(String.valueOf(this)); } + @Override public Object readLengthList(AbstractHessianInput in, int length) throws IOException { throw new UnsupportedOperationException(String.valueOf(this)); diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/RemoteSerializer.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/RemoteSerializer.java index c59c9d2475c..29146884ae8 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/RemoteSerializer.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/RemoteSerializer.java @@ -54,6 +54,7 @@ * Serializing a remote object. */ public class RemoteSerializer extends AbstractSerializer { + @Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { // XXX: needs to be handled as a separate class diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/SerializerFactory.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/SerializerFactory.java index 00404db2c4d..39bc5c194a7 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/SerializerFactory.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/SerializerFactory.java @@ -404,6 +404,7 @@ protected Serializer getDefaultSerializer(Class cl) { * @param cl the class of the object that needs to be deserialized. * @return a deserializer object for the serialization. */ + @Override public Deserializer getDeserializer(Class cl) throws HessianProtocolException { Deserializer deserializer; diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/SqlDateDeserializer.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/SqlDateDeserializer.java index d829c979116..df809d74572 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/SqlDateDeserializer.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/SqlDateDeserializer.java @@ -64,10 +64,12 @@ public SqlDateDeserializer(Class cl) _constructor = cl.getConstructor(new Class[]{long.class}); } + @Override public Class getType() { return _cl; } + @Override public Object readMap(AbstractHessianInput in) throws IOException { int ref = in.addRef(null); @@ -92,6 +94,7 @@ public Object readMap(AbstractHessianInput in) return value; } + @Override public Object readObject(AbstractHessianInput in, String[] fieldNames) throws IOException { int ref = in.addRef(null); diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/SqlDateSerializer.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/SqlDateSerializer.java index c812c7ede16..5e6c8f4a414 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/SqlDateSerializer.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/SqlDateSerializer.java @@ -55,6 +55,7 @@ * Serializing a sql date object. */ public class SqlDateSerializer extends AbstractSerializer { + @Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { if (obj == null) diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/StringValueDeserializer.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/StringValueDeserializer.java index 5d6f3e1ecc7..90ceef17052 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/StringValueDeserializer.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/StringValueDeserializer.java @@ -67,10 +67,12 @@ public StringValueDeserializer(Class cl) { } } + @Override public Class getType() { return _cl; } + @Override public Object readMap(AbstractHessianInput in) throws IOException { String value = null; @@ -93,6 +95,7 @@ public Object readMap(AbstractHessianInput in) return object; } + @Override public Object readObject(AbstractHessianInput in, String[] fieldNames) throws IOException { String value = null; diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/StringValueSerializer.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/StringValueSerializer.java index 59ae0ecb632..16a00b4e5db 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/StringValueSerializer.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/StringValueSerializer.java @@ -54,6 +54,7 @@ * Serializing a remote object. */ public class StringValueSerializer extends AbstractSerializer { + @Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { if (obj == null) diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/ThrowableSerializer.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/ThrowableSerializer.java index ebe319cde0b..1f65e7f05b6 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/ThrowableSerializer.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/ThrowableSerializer.java @@ -58,6 +58,7 @@ public ThrowableSerializer(Class cl, ClassLoader loader) { super(cl, loader); } + @Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { Throwable e = (Throwable) obj; diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/ValueDeserializer.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/ValueDeserializer.java index ea99666c39e..af548ac5232 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/ValueDeserializer.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/ValueDeserializer.java @@ -54,6 +54,7 @@ * Deserializing a string valued object */ abstract public class ValueDeserializer extends AbstractDeserializer { + @Override public Object readMap(AbstractHessianInput in) throws IOException { String initValue = null; @@ -72,6 +73,7 @@ public Object readMap(AbstractHessianInput in) return create(initValue); } + @Override public Object readObject(AbstractHessianInput in, String[] fieldNames) throws IOException { String initValue = null; diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/security/X509Encryption.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/security/X509Encryption.java index ea4a2179f57..2156cec2b91 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/security/X509Encryption.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/security/X509Encryption.java @@ -140,6 +140,7 @@ public void setSecureRandom(SecureRandom random) { _secureRandom = random; } + @Override public Hessian2Output wrap(Hessian2Output out) throws IOException { if (_cert == null) @@ -154,6 +155,7 @@ public Hessian2Output wrap(Hessian2Output out) return filterOut; } + @Override public Hessian2Input unwrap(Hessian2Input in) throws IOException { if (_privateKey == null) @@ -173,6 +175,7 @@ public Hessian2Input unwrap(Hessian2Input in) return unwrapHeaders(in); } + @Override public Hessian2Input unwrapHeaders(Hessian2Input in) throws IOException { if (_privateKey == null) @@ -258,16 +261,19 @@ class EncryptOutputStream extends OutputStream { } } + @Override public void write(int ch) throws IOException { _cipherOut.write(ch); } + @Override public void write(byte[] buffer, int offset, int length) throws IOException { _cipherOut.write(buffer, offset, length); } + @Override public void close() throws IOException { Hessian2Output out = _out; @@ -337,16 +343,19 @@ else if ("key".equals(header)) } } + @Override public int read() throws IOException { return _cipherIn.read(); } + @Override public int read(byte[] buffer, int offset, int length) throws IOException { return _cipherIn.read(buffer, offset, length); } + @Override public void close() throws IOException { Hessian2Input in = _in; diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/security/X509Signature.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/security/X509Signature.java index 4d1de844847..a8023e729bf 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/security/X509Signature.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/security/X509Signature.java @@ -135,6 +135,7 @@ public void setSecureRandom(SecureRandom random) { _secureRandom = random; } + @Override public Hessian2Output wrap(Hessian2Output out) throws IOException { if (_privateKey == null) @@ -152,6 +153,7 @@ public Hessian2Output wrap(Hessian2Output out) return filterOut; } + @Override public Hessian2Input unwrap(Hessian2Input in) throws IOException { if (_cert == null) @@ -168,6 +170,7 @@ public Hessian2Input unwrap(Hessian2Input in) return unwrapHeaders(in); } + @Override public Hessian2Input unwrapHeaders(Hessian2Input in) throws IOException { if (_cert == null) @@ -237,18 +240,21 @@ class SignatureOutputStream extends OutputStream { } } + @Override public void write(int ch) throws IOException { _bodyOut.write(ch); _mac.update((byte) ch); } + @Override public void write(byte[] buffer, int offset, int length) throws IOException { _bodyOut.write(buffer, offset, length); _mac.update(buffer, offset, length); } + @Override public void close() throws IOException { Hessian2Output out = _out; @@ -321,6 +327,7 @@ else if ("key".equals(header)) } } + @Override public int read() throws IOException { int ch = _bodyIn.read(); @@ -333,6 +340,7 @@ public int read() return ch; } + @Override public int read(byte[] buffer, int offset, int length) throws IOException { int len = _bodyIn.read(buffer, offset, length); @@ -345,6 +353,7 @@ public int read(byte[] buffer, int offset, int length) return len; } + @Override public void close() throws IOException { Hessian2Input in = _in; diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/util/IdentityIntMap.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/util/IdentityIntMap.java index 9be45e3ba97..afa3a9f992f 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/util/IdentityIntMap.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/util/IdentityIntMap.java @@ -219,6 +219,7 @@ else if (mapKey == key) { } } + @Override public String toString() { StringBuffer sbuf = new StringBuffer(); diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/util/IntMap.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/util/IntMap.java index d31dcb2342d..8711570f14e 100644 --- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/util/IntMap.java +++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/util/IntMap.java @@ -219,6 +219,7 @@ else if (mapKey == key) { } } + @Override public String toString() { StringBuffer sbuf = new StringBuffer(); From 5cfe610654d8482c86ea0962622ed486a175adc4 Mon Sep 17 00:00:00 2001 From: xiuyuhang <442367943@qq.com> Date: Tue, 27 Feb 2018 10:24:55 +0800 Subject: [PATCH 09/21] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8D=95=E5=85=83?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/alibaba/dubbo/common/utils/ConfigUtilsTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/dubbo-common/src/test/java/com/alibaba/dubbo/common/utils/ConfigUtilsTest.java b/dubbo-common/src/test/java/com/alibaba/dubbo/common/utils/ConfigUtilsTest.java index 3969b011689..b3cb010dee0 100644 --- a/dubbo-common/src/test/java/com/alibaba/dubbo/common/utils/ConfigUtilsTest.java +++ b/dubbo-common/src/test/java/com/alibaba/dubbo/common/utils/ConfigUtilsTest.java @@ -116,6 +116,7 @@ public void test_loadProperties_oneFile_notRootPath() throws Exception { expected.put("fixed", "com.alibaba.dubbo.common.threadpool.support.fixed.FixedThreadPool"); expected.put("cached", "com.alibaba.dubbo.common.threadpool.support.cached.CachedThreadPool"); expected.put("limited", "com.alibaba.dubbo.common.threadpool.support.limited.LimitedThreadPool"); + expected.put("enhanced", "com.alibaba.dubbo.common.threadpool.support.enhanced.EnhancedThreadPool"); Assert.assertEquals(expected, p); } From be1418f2ae6c5d9bafe6964e2861006d8a8a4959 Mon Sep 17 00:00:00 2001 From: xiuyuhang <442367943@qq.com> Date: Wed, 25 Apr 2018 10:19:08 +0800 Subject: [PATCH 10/21] remove enhanced --- .../support/enhanced/EnhancedTaskQueue.java | 56 ------------------- .../support/enhanced/EnhancedThreadPool.java | 32 ----------- .../enhanced/EnhancedThreadPoolExecutor.java | 45 --------------- 3 files changed, 133 deletions(-) delete mode 100644 dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/enhanced/EnhancedTaskQueue.java delete mode 100644 dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/enhanced/EnhancedThreadPool.java delete mode 100644 dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/enhanced/EnhancedThreadPoolExecutor.java diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/enhanced/EnhancedTaskQueue.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/enhanced/EnhancedTaskQueue.java deleted file mode 100644 index 65cedaf2f2c..00000000000 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/enhanced/EnhancedTaskQueue.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.alibaba.dubbo.common.threadpool.support.enhanced; - -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.RejectedExecutionException; - -/** - * enhanced task queue - */ -public class EnhancedTaskQueue extends LinkedBlockingQueue { - - private static final long serialVersionUID = -2635853580887179627L; - - private EnhancedThreadPoolExecutor executor; - - public EnhancedTaskQueue(int capacity) { - super(capacity); - } - - public void setExecutor(EnhancedThreadPoolExecutor exec) { - executor = exec; - } - - @Override - public boolean offer(Runnable runnable) { - if (executor == null) { - throw new RejectedExecutionException("enhanced queue does not have executor !"); - } - int currentPoolThreadSize = executor.getPoolSize(); - //have free worker. put task into queue to let the worker deal with task. - if (executor.getSubmittedTaskCount() < currentPoolThreadSize) { - return super.offer(runnable); - } - - // return false to let executor create new worker. - if (currentPoolThreadSize < executor.getMaximumPoolSize()) { - return false; - } - - //currentPoolThreadSize >= max - return super.offer(runnable); - } - - /** - * retry offer task - * - * @param o task - * @return offer success or not - * @throws RejectedExecutionException if executor is terminated. - */ - public boolean retryOffer(Runnable o) { - if (executor.isShutdown()) { - throw new RejectedExecutionException("Executor is shutdown !"); - } - return super.offer(o); - } -} \ No newline at end of file diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/enhanced/EnhancedThreadPool.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/enhanced/EnhancedThreadPool.java deleted file mode 100644 index e9285797113..00000000000 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/enhanced/EnhancedThreadPool.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.alibaba.dubbo.common.threadpool.support.enhanced; - -import com.alibaba.dubbo.common.Constants; -import com.alibaba.dubbo.common.URL; -import com.alibaba.dubbo.common.threadpool.ThreadPool; -import com.alibaba.dubbo.common.threadpool.support.AbortPolicyWithReport; -import com.alibaba.dubbo.common.utils.NamedThreadFactory; - -import java.util.concurrent.*; - -/** - * enhanced thread pool. - * When the core threads are all in busy , create new thread instead of putting task into blocking queue . - */ -public class EnhancedThreadPool implements ThreadPool { - - @Override - public Executor getExecutor(URL url) { - String name = url.getParameter(Constants.THREAD_NAME_KEY, Constants.DEFAULT_THREAD_NAME); - int cores = url.getParameter(Constants.CORE_THREADS_KEY, Constants.DEFAULT_CORE_THREADS); - int threads = url.getParameter(Constants.THREADS_KEY, Integer.MAX_VALUE); - int queues = url.getParameter(Constants.QUEUES_KEY, Constants.DEFAULT_QUEUES); - int alive = url.getParameter(Constants.ALIVE_KEY, Constants.DEFAULT_ALIVE); - - //init queue and enhanced executor - EnhancedTaskQueue enhancedTaskQueue = new EnhancedTaskQueue(queues <= 0 ? 1 : queues); - EnhancedThreadPoolExecutor executor = new EnhancedThreadPoolExecutor(cores, threads, alive, TimeUnit.MILLISECONDS, enhancedTaskQueue, - new NamedThreadFactory(name, true), new AbortPolicyWithReport(name, url)); - enhancedTaskQueue.setExecutor(executor); - return executor; - } -} diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/enhanced/EnhancedThreadPoolExecutor.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/enhanced/EnhancedThreadPoolExecutor.java deleted file mode 100644 index f19f162e7ec..00000000000 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/enhanced/EnhancedThreadPoolExecutor.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.alibaba.dubbo.common.threadpool.support.enhanced; - -import java.util.concurrent.*; -import java.util.concurrent.atomic.AtomicInteger; - -/** - * Enhanced thread pool - */ -public class EnhancedThreadPoolExecutor extends ThreadPoolExecutor { - - //task count - private final AtomicInteger submittedTaskCount = new AtomicInteger(0); - - public EnhancedThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, EnhancedTaskQueue workQueue, ThreadFactory threadFactory, RejectedExecutionHandler handler) { - super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, threadFactory, handler); - } - - /** - * @return current tasks which are executed - */ - public int getSubmittedTaskCount() { - return submittedTaskCount.get(); - } - - @Override - protected void afterExecute(Runnable r, Throwable t) { - submittedTaskCount.decrementAndGet(); - } - - @Override - public void execute(Runnable command) { - //do not increment in method beforeExecute! - submittedTaskCount.incrementAndGet(); - try { - super.execute(command); - } catch (RejectedExecutionException rx) { - //retry to offer the task into queue . - final EnhancedTaskQueue queue = (EnhancedTaskQueue) super.getQueue(); - if (!queue.retryOffer(command)) { - submittedTaskCount.decrementAndGet(); - throw new RejectedExecutionException(); - } - } - } -} \ No newline at end of file From 96535535121b8efda2ddf8a92d784360c294b326 Mon Sep 17 00:00:00 2001 From: xiuyuhang <442367943@qq.com> Date: Wed, 25 Apr 2018 10:22:06 +0800 Subject: [PATCH 11/21] remove enhanced --- .../enhanced/EnhancedThreadPoolTest.java | 78 ------------------- 1 file changed, 78 deletions(-) delete mode 100644 dubbo-common/src/test/java/com/alibaba/dubbo/common/threadpool/support/enhanced/EnhancedThreadPoolTest.java diff --git a/dubbo-common/src/test/java/com/alibaba/dubbo/common/threadpool/support/enhanced/EnhancedThreadPoolTest.java b/dubbo-common/src/test/java/com/alibaba/dubbo/common/threadpool/support/enhanced/EnhancedThreadPoolTest.java deleted file mode 100644 index b51ffe5cc3d..00000000000 --- a/dubbo-common/src/test/java/com/alibaba/dubbo/common/threadpool/support/enhanced/EnhancedThreadPoolTest.java +++ /dev/null @@ -1,78 +0,0 @@ -package com.alibaba.dubbo.common.threadpool.support.enhanced; - -import com.alibaba.dubbo.common.URL; -import com.alibaba.dubbo.common.extension.ExtensionLoader; -import com.alibaba.dubbo.common.threadpool.ThreadPool; -import com.alibaba.dubbo.common.threadpool.support.AbortPolicyWithReport; -import com.alibaba.dubbo.common.utils.NamedThreadFactory; -import org.junit.Assert; -import org.junit.Test; - -import java.util.concurrent.ExecutorService; -import java.util.concurrent.TimeUnit; - -public class EnhancedThreadPoolTest { - - private static final URL URL = new URL("dubbo", "localhost", 8080); - - /** - * it print like this: - * thread number in current pool:1, task number in task queue:0 executor size: 1 - * thread number in current pool:2, task number in task queue:0 executor size: 2 - * thread number in current pool:3, task number in task queue:0 executor size: 3 - * thread number in current pool:4, task number in task queue:0 executor size: 4 - * thread number in current pool:5, task number in task queue:0 executor size: 5 - * thread number in current pool:6, task number in task queue:0 executor size: 6 - * thread number in current pool:7, task number in task queue:0 executor size: 7 - * thread number in current pool:8, task number in task queue:0 executor size: 8 - * thread number in current pool:9, task number in task queue:0 executor size: 9 - * thread number in current pool:10, task number in task queue:0 executor size: 10 - * thread number in current pool:10, task number in task queue:4 executor size: 10 - * thread number in current pool:10, task number in task queue:3 executor size: 10 - * thread number in current pool:10, task number in task queue:2 executor size: 10 - * thread number in current pool:10, task number in task queue:1 executor size: 10 - * thread number in current pool:10, task number in task queue:0 executor size: 10 - *

- * we can see , when the core threads are in busy , the thread pool create thread (but thread nums always less than max) instead of put task into queue. - */ - @Test - public void testEnhancedThreadPool() throws Exception { - String name = "enhanced-tf"; - int queues = 5; - int cores = 5; - int threads = 10; - //alive 1 second - long alive = 1000; - - //init queue and enhanced executor - EnhancedTaskQueue enhancedTaskQueue = new EnhancedTaskQueue(queues); - final EnhancedThreadPoolExecutor executor = new EnhancedThreadPoolExecutor(cores, threads, alive, TimeUnit.MILLISECONDS, enhancedTaskQueue, - new NamedThreadFactory(name, true), new AbortPolicyWithReport(name, URL)); - enhancedTaskQueue.setExecutor(executor); - - for (int i = 0; i < 15; i++) { - Thread.sleep(50); - executor.execute(new Runnable() { - @Override - public void run() { - System.out.println("thread number in current pool:" + executor.getPoolSize() + ", task number in task queue:" + executor.getQueue().size() + " executor size: " + executor.getPoolSize()); - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - }); - } - Thread.sleep(5000); - //cores theads are all alive - Assert.assertTrue("more than cores threads alive!", executor.getPoolSize() == cores); - } - - @Test - public void testSPI() { - ExecutorService executorService = (ExecutorService) ExtensionLoader.getExtensionLoader(ThreadPool.class).getExtension("enhanced").getExecutor(URL); - Assert.assertTrue("test spi fail!", executorService.getClass().getSimpleName().equals("EnhancedThreadPoolExecutor")); - } - -} \ No newline at end of file From dc41214da446cb2dd50db4c75263df4378922271 Mon Sep 17 00:00:00 2001 From: xiuyuhang <442367943@qq.com> Date: Sat, 5 May 2018 15:52:06 +0800 Subject: [PATCH 12/21] Faster ThreadLocal impl in internal use * Used in RpcContext`s LOCAL field. * Faster get than the traditional ThreadLocal --- .../common/threadlocal/InternalThread.java | 59 ++++++ .../threadlocal/InternalThreadLocal.java | 183 ++++++++++++++++++ .../threadlocal/InternalThreadLocalMap.java | 148 ++++++++++++++ .../NamedInternalThreadFactory.java | 33 ++++ .../support/cached/CachedThreadPool.java | 11 +- .../support/eager/EagerThreadPool.java | 4 +- .../support/fixed/FixedThreadPool.java | 10 +- .../support/limited/LimitedThreadPool.java | 10 +- .../common/utils/NamedThreadFactory.java | 11 +- .../threadlocal/InternalThreadLocalTest.java | 148 ++++++++++++++ .../com/alibaba/dubbo/rpc/RpcContext.java | 7 +- 11 files changed, 594 insertions(+), 30 deletions(-) create mode 100644 dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/InternalThread.java create mode 100644 dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocal.java create mode 100644 dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocalMap.java create mode 100644 dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/NamedInternalThreadFactory.java create mode 100644 dubbo-common/src/test/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocalTest.java diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/InternalThread.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/InternalThread.java new file mode 100644 index 00000000000..f3cd046966c --- /dev/null +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/InternalThread.java @@ -0,0 +1,59 @@ +package com.alibaba.dubbo.common.threadlocal; + +/** + * InternalThread + * + * @author xiuyuhang [xiuyuhang] + * @since 2018-05-05 + */ +public class InternalThread extends Thread { + + private InternalThreadLocalMap threadLocalMap; + + public InternalThread() { + } + + public InternalThread(Runnable target) { + super(target); + } + + public InternalThread(ThreadGroup group, Runnable target) { + super(group, target); + } + + public InternalThread(String name) { + super(name); + } + + public InternalThread(ThreadGroup group, String name) { + super(group, name); + } + + public InternalThread(Runnable target, String name) { + super(target, name); + } + + public InternalThread(ThreadGroup group, Runnable target, String name) { + super(group, target, name); + } + + public InternalThread(ThreadGroup group, Runnable target, String name, long stackSize) { + super(group, target, name, stackSize); + } + + /** + * Returns the internal data structure that keeps the threadLocal variables bound to this thread. + * Note that this method is for internal use only, and thus is subject to change at any time. + */ + public final InternalThreadLocalMap threadLocalMap() { + return threadLocalMap; + } + + /** + * Sets the internal data structure that keeps the threadLocal variables bound to this thread. + * Note that this method is for internal use only, and thus is subject to change at any time. + */ + public final void setThreadLocalMap(InternalThreadLocalMap threadLocalMap) { + this.threadLocalMap = threadLocalMap; + } +} diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocal.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocal.java new file mode 100644 index 00000000000..be72ebf5e8e --- /dev/null +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocal.java @@ -0,0 +1,183 @@ +package com.alibaba.dubbo.common.threadlocal; + +import java.util.Collections; +import java.util.IdentityHashMap; +import java.util.Set; + +/** + * InternalThreadLocal + * A special variant of {@link ThreadLocal} that yields higher access performance when accessed from a + * {@link InternalThread}. + *

+ * Internally, a {@link InternalThread} uses a constant index in an array, instead of using hash code and hash table, + * to look for a variable. Although seemingly very subtle, it yields slight performance advantage over using a hash + * table, and it is useful when accessed frequently. + *

+ * This design is learning from {@see io.netty.util.concurrent.FastThreadLocal} which is in Netty. + * + * @author xiuyuhang [xiuyuhang] + * @since 2018-05-05 + */ +public class InternalThreadLocal { + + private static final int variablesToRemoveIndex = InternalThreadLocalMap.nextVariableIndex(); + + private final int index; + + public InternalThreadLocal() { + index = InternalThreadLocalMap.nextVariableIndex(); + } + + /** + * Removes all {@link InternalThreadLocal} variables bound to the current thread. This operation is useful when you + * are in a container environment, and you don't want to leave the thread local variables in the threads you do not + * manage. + */ + @SuppressWarnings("unchecked") + public static void removeAll() { + InternalThreadLocalMap threadLocalMap = InternalThreadLocalMap.getIfSet(); + if (threadLocalMap == null) { + return; + } + + try { + Object v = threadLocalMap.indexedVariable(variablesToRemoveIndex); + if (v != null && v != InternalThreadLocalMap.UNSET) { + Set> variablesToRemove = (Set>) v; + for (InternalThreadLocal tlv : variablesToRemove) { + tlv.remove(threadLocalMap); + } + } + } finally { + InternalThreadLocalMap.remove(); + } + } + + /** + * Returns the number of thread local variables bound to the current thread. + */ + public static int size() { + InternalThreadLocalMap threadLocalMap = InternalThreadLocalMap.getIfSet(); + if (threadLocalMap == null) { + return 0; + } else { + return threadLocalMap.size(); + } + } + + public static void destroy() { + InternalThreadLocalMap.destroy(); + } + + @SuppressWarnings("unchecked") + private static void addToVariablesToRemove(InternalThreadLocalMap threadLocalMap, InternalThreadLocal variable) { + Object v = threadLocalMap.indexedVariable(variablesToRemoveIndex); + Set> variablesToRemove; + if (v == InternalThreadLocalMap.UNSET || v == null) { + variablesToRemove = Collections.newSetFromMap(new IdentityHashMap, Boolean>()); + threadLocalMap.setIndexedVariable(variablesToRemoveIndex, variablesToRemove); + } else { + variablesToRemove = (Set>) v; + } + + variablesToRemove.add(variable); + } + + @SuppressWarnings("unchecked") + private static void removeFromVariablesToRemove(InternalThreadLocalMap threadLocalMap, InternalThreadLocal variable) { + + Object v = threadLocalMap.indexedVariable(variablesToRemoveIndex); + + if (v == InternalThreadLocalMap.UNSET || v == null) { + return; + } + + Set> variablesToRemove = (Set>) v; + variablesToRemove.remove(variable); + } + + /** + * Returns the current value for the current thread + */ + @SuppressWarnings("unchecked") + public final V get() { + InternalThreadLocalMap threadLocalMap = InternalThreadLocalMap.get(); + Object v = threadLocalMap.indexedVariable(index); + if (v != InternalThreadLocalMap.UNSET) { + return (V) v; + } + + return initialize(threadLocalMap); + } + + private V initialize(InternalThreadLocalMap threadLocalMap) { + V v = null; + try { + v = initialValue(); + } catch (Exception e) { + throw new RuntimeException(e); + } + + threadLocalMap.setIndexedVariable(index, v); + addToVariablesToRemove(threadLocalMap, this); + return v; + } + + /** + * Sets the value for the current thread. + */ + public final void set(V value) { + if (value == null || value == InternalThreadLocalMap.UNSET) { + remove(); + } else { + InternalThreadLocalMap threadLocalMap = InternalThreadLocalMap.get(); + if (threadLocalMap.setIndexedVariable(index, value)) { + addToVariablesToRemove(threadLocalMap, this); + } + } + } + + /** + * Sets the value to uninitialized; a proceeding call to get() will trigger a call to initialValue(). + */ + @SuppressWarnings("unchecked") + public final void remove() { + remove(InternalThreadLocalMap.getIfSet()); + } + + /** + * Sets the value to uninitialized for the specified thread local map; + * a proceeding call to get() will trigger a call to initialValue(). + * The specified thread local map must be for the current thread. + */ + @SuppressWarnings("unchecked") + public final void remove(InternalThreadLocalMap threadLocalMap) { + if (threadLocalMap == null) { + return; + } + + Object v = threadLocalMap.removeIndexedVariable(index); + removeFromVariablesToRemove(threadLocalMap, this); + + if (v != InternalThreadLocalMap.UNSET) { + try { + onRemoval((V) v); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } + + /** + * Returns the initial value for this thread-local variable. + */ + protected V initialValue() throws Exception { + return null; + } + + /** + * Invoked when this thread local variable is removed by {@link #remove()}. + */ + protected void onRemoval(@SuppressWarnings("unused") V value) throws Exception { + } +} diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocalMap.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocalMap.java new file mode 100644 index 00000000000..a2ffec77611 --- /dev/null +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocalMap.java @@ -0,0 +1,148 @@ +package com.alibaba.dubbo.common.threadlocal; + +import java.util.Arrays; +import java.util.concurrent.atomic.AtomicInteger; + +/** + * The internal data structure that stores the threadLocal variables for Netty and all {@link InternalThread}s. + * Note that this class is for internal use only. Use {@link InternalThread} + * unless you know what you are doing. + */ +public final class InternalThreadLocalMap { + + private Object[] indexedVariables; + + private static final ThreadLocal slowThreadLocalMap = new ThreadLocal<>(); + + private static final AtomicInteger nextIndex = new AtomicInteger(); + + public static final Object UNSET = new Object(); + + public static InternalThreadLocalMap getIfSet() { + Thread thread = Thread.currentThread(); + if (thread instanceof InternalThread) { + return ((InternalThread) thread).threadLocalMap(); + } + return slowThreadLocalMap.get(); + } + + public static InternalThreadLocalMap get() { + Thread thread = Thread.currentThread(); + if (thread instanceof InternalThread) { + return fastGet((InternalThread) thread); + } + return slowGet(); + } + + public static void remove() { + Thread thread = Thread.currentThread(); + if (thread instanceof InternalThread) { + ((InternalThread) thread).setThreadLocalMap(null); + } else { + slowThreadLocalMap.remove(); + } + } + + public static void destroy() { + slowThreadLocalMap.remove(); + } + + public static int nextVariableIndex() { + int index = nextIndex.getAndIncrement(); + if (index < 0) { + nextIndex.decrementAndGet(); + throw new IllegalStateException("Too many thread-local indexed variables"); + } + return index; + } + + public static int lastVariableIndex() { + return nextIndex.get() - 1; + } + + private InternalThreadLocalMap() { + indexedVariables = newIndexedVariableTable(); + } + + public Object indexedVariable(int index) { + Object[] lookup = indexedVariables; + return index < lookup.length ? lookup[index] : UNSET; + } + + /** + * @return {@code true} if and only if a new thread-local variable has been created + */ + public boolean setIndexedVariable(int index, Object value) { + Object[] lookup = indexedVariables; + if (index < lookup.length) { + Object oldValue = lookup[index]; + lookup[index] = value; + return oldValue == UNSET; + } else { + expandIndexedVariableTableAndSet(index, value); + return true; + } + } + + public Object removeIndexedVariable(int index) { + Object[] lookup = indexedVariables; + if (index < lookup.length) { + Object v = lookup[index]; + lookup[index] = UNSET; + return v; + } else { + return UNSET; + } + } + + public int size() { + int count = 0; + for (Object o : indexedVariables) { + if (o != UNSET) { + ++count; + } + } + return count; + } + + private static Object[] newIndexedVariableTable() { + Object[] array = new Object[32]; + Arrays.fill(array, UNSET); + return array; + } + + private static InternalThreadLocalMap fastGet(InternalThread thread) { + InternalThreadLocalMap threadLocalMap = thread.threadLocalMap(); + if (threadLocalMap == null) { + thread.setThreadLocalMap(threadLocalMap = new InternalThreadLocalMap()); + } + return threadLocalMap; + } + + private static InternalThreadLocalMap slowGet() { + ThreadLocal slowThreadLocalMap = InternalThreadLocalMap.slowThreadLocalMap; + InternalThreadLocalMap ret = slowThreadLocalMap.get(); + if (ret == null) { + ret = new InternalThreadLocalMap(); + slowThreadLocalMap.set(ret); + } + return ret; + } + + private void expandIndexedVariableTableAndSet(int index, Object value) { + Object[] oldArray = indexedVariables; + final int oldCapacity = oldArray.length; + int newCapacity = index; + newCapacity |= newCapacity >>> 1; + newCapacity |= newCapacity >>> 2; + newCapacity |= newCapacity >>> 4; + newCapacity |= newCapacity >>> 8; + newCapacity |= newCapacity >>> 16; + newCapacity++; + + Object[] newArray = Arrays.copyOf(oldArray, newCapacity); + Arrays.fill(newArray, oldCapacity, newArray.length, UNSET); + newArray[index] = value; + indexedVariables = newArray; + } +} diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/NamedInternalThreadFactory.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/NamedInternalThreadFactory.java new file mode 100644 index 00000000000..8c177ffd3a0 --- /dev/null +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/NamedInternalThreadFactory.java @@ -0,0 +1,33 @@ +package com.alibaba.dubbo.common.threadlocal; + +import com.alibaba.dubbo.common.utils.NamedThreadFactory; + +/** + * NamedInternalThreadFactory + * This is a threadFactory which produce {@link InternalThread} + * + * @author xiuyuhang [xiuyuhang] + * @since 2018-05-05 + */ +public class NamedInternalThreadFactory extends NamedThreadFactory { + + public NamedInternalThreadFactory() { + super(); + } + + public NamedInternalThreadFactory(String prefix) { + super(prefix, false); + } + + public NamedInternalThreadFactory(String prefix, boolean daemon) { + super(prefix, daemon); + } + + @Override + public Thread newThread(Runnable runnable) { + String name = mPrefix + mThreadNum.getAndIncrement(); + InternalThread ret = new InternalThread(mGroup, runnable, name, 0); + ret.setDaemon(mDaemon); + return ret; + } +} diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/cached/CachedThreadPool.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/cached/CachedThreadPool.java index f808ab926f3..b4447f76753 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/cached/CachedThreadPool.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/cached/CachedThreadPool.java @@ -18,15 +18,11 @@ import com.alibaba.dubbo.common.Constants; import com.alibaba.dubbo.common.URL; +import com.alibaba.dubbo.common.threadlocal.NamedInternalThreadFactory; import com.alibaba.dubbo.common.threadpool.ThreadPool; import com.alibaba.dubbo.common.threadpool.support.AbortPolicyWithReport; -import com.alibaba.dubbo.common.utils.NamedThreadFactory; -import java.util.concurrent.Executor; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.SynchronousQueue; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; +import java.util.concurrent.*; /** * This thread pool is self-tuned. Thread will be recycled after idle for one minute, and new thread will be created for @@ -47,7 +43,6 @@ public Executor getExecutor(URL url) { queues == 0 ? new SynchronousQueue() : (queues < 0 ? new LinkedBlockingQueue() : new LinkedBlockingQueue(queues)), - new NamedThreadFactory(name, true), new AbortPolicyWithReport(name, url)); + new NamedInternalThreadFactory(name, true), new AbortPolicyWithReport(name, url)); } - } diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/eager/EagerThreadPool.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/eager/EagerThreadPool.java index eb4e1f3feb7..2f97b6b517a 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/eager/EagerThreadPool.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/eager/EagerThreadPool.java @@ -19,9 +19,9 @@ import com.alibaba.dubbo.common.Constants; import com.alibaba.dubbo.common.URL; +import com.alibaba.dubbo.common.threadlocal.NamedInternalThreadFactory; import com.alibaba.dubbo.common.threadpool.ThreadPool; import com.alibaba.dubbo.common.threadpool.support.AbortPolicyWithReport; -import com.alibaba.dubbo.common.utils.NamedThreadFactory; import java.util.concurrent.Executor; import java.util.concurrent.TimeUnit; @@ -48,7 +48,7 @@ public Executor getExecutor(URL url) { alive, TimeUnit.MILLISECONDS, taskQueue, - new NamedThreadFactory(name, true), + new NamedInternalThreadFactory(name, true), new AbortPolicyWithReport(name, url)); taskQueue.setExecutor(executor); return executor; diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/fixed/FixedThreadPool.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/fixed/FixedThreadPool.java index 15ebb20d08d..801c53b53e3 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/fixed/FixedThreadPool.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/fixed/FixedThreadPool.java @@ -18,15 +18,11 @@ import com.alibaba.dubbo.common.Constants; import com.alibaba.dubbo.common.URL; +import com.alibaba.dubbo.common.threadlocal.NamedInternalThreadFactory; import com.alibaba.dubbo.common.threadpool.ThreadPool; import com.alibaba.dubbo.common.threadpool.support.AbortPolicyWithReport; -import com.alibaba.dubbo.common.utils.NamedThreadFactory; -import java.util.concurrent.Executor; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.SynchronousQueue; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; +import java.util.concurrent.*; /** * Creates a thread pool that reuses a fixed number of threads @@ -44,7 +40,7 @@ public Executor getExecutor(URL url) { queues == 0 ? new SynchronousQueue() : (queues < 0 ? new LinkedBlockingQueue() : new LinkedBlockingQueue(queues)), - new NamedThreadFactory(name, true), new AbortPolicyWithReport(name, url)); + new NamedInternalThreadFactory(name, true), new AbortPolicyWithReport(name, url)); } } diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/limited/LimitedThreadPool.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/limited/LimitedThreadPool.java index aa5a71f3da0..6420bfc1377 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/limited/LimitedThreadPool.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/limited/LimitedThreadPool.java @@ -19,15 +19,11 @@ import com.alibaba.dubbo.common.Constants; import com.alibaba.dubbo.common.URL; +import com.alibaba.dubbo.common.threadlocal.NamedInternalThreadFactory; import com.alibaba.dubbo.common.threadpool.ThreadPool; import com.alibaba.dubbo.common.threadpool.support.AbortPolicyWithReport; -import com.alibaba.dubbo.common.utils.NamedThreadFactory; -import java.util.concurrent.Executor; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.SynchronousQueue; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; +import java.util.concurrent.*; /** * Creates a thread pool that creates new threads as needed until limits reaches. This thread pool will not shrink @@ -45,7 +41,7 @@ public Executor getExecutor(URL url) { queues == 0 ? new SynchronousQueue() : (queues < 0 ? new LinkedBlockingQueue() : new LinkedBlockingQueue(queues)), - new NamedThreadFactory(name, true), new AbortPolicyWithReport(name, url)); + new NamedInternalThreadFactory(name, true), new AbortPolicyWithReport(name, url)); } } diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/NamedThreadFactory.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/NamedThreadFactory.java index 3d30a037239..36ace7ddf54 100755 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/NamedThreadFactory.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/NamedThreadFactory.java @@ -23,15 +23,16 @@ * InternalThreadFactory. */ public class NamedThreadFactory implements ThreadFactory { - private static final AtomicInteger POOL_SEQ = new AtomicInteger(1); - private final AtomicInteger mThreadNum = new AtomicInteger(1); + protected static final AtomicInteger POOL_SEQ = new AtomicInteger(1); - private final String mPrefix; + protected final AtomicInteger mThreadNum = new AtomicInteger(1); - private final boolean mDaemon; + protected final String mPrefix; - private final ThreadGroup mGroup; + protected final boolean mDaemon; + + protected final ThreadGroup mGroup; public NamedThreadFactory() { this("pool-" + POOL_SEQ.getAndIncrement(), false); diff --git a/dubbo-common/src/test/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocalTest.java b/dubbo-common/src/test/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocalTest.java new file mode 100644 index 00000000000..e337fcdbc54 --- /dev/null +++ b/dubbo-common/src/test/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocalTest.java @@ -0,0 +1,148 @@ +package com.alibaba.dubbo.common.threadlocal; + +import org.junit.Assert; +import org.junit.Test; + +import java.util.Objects; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.locks.LockSupport; + +public class InternalThreadLocalTest { + + private static final int THREADS = 10; + + private static final int PERFORMANCE_THREAD_COUNT = 1000; + + @Test + public void testInternalThreadLocal() throws InterruptedException { + AtomicInteger index = new AtomicInteger(0); + + final InternalThreadLocal internalThreadLocal = new InternalThreadLocal() { + + @Override + protected Integer initialValue() throws Exception { + Integer v = index.getAndIncrement(); + System.out.println("thread : " + Thread.currentThread().getName() + " init value : " + v); + return v; + } + }; + + for (int i = 0; i < THREADS; i++) { + new Thread(new Runnable() { + @Override + public void run() { + internalThreadLocal.get(); + } + }).start(); + } + + Thread.sleep(2000); + } + + @Test + public void testSetAndGet() { + final Integer testVal = 10; + final InternalThreadLocal internalThreadLocal = new InternalThreadLocal(); + internalThreadLocal.set(testVal); + Assert.assertTrue("set is not equals get", Objects.equals(testVal, internalThreadLocal.get())); + } + + @Test + public void testMultiThreadSetAndGet() throws InterruptedException { + final Integer testVal1 = 10; + final Integer testVal2 = 20; + final InternalThreadLocal internalThreadLocal = new InternalThreadLocal(); + final CountDownLatch countDownLatch = new CountDownLatch(2); + new Thread(new Runnable() { + @Override + public void run() { + + internalThreadLocal.set(testVal1); + Assert.assertTrue("set is not equals get", Objects.equals(testVal1, internalThreadLocal.get())); + countDownLatch.countDown(); + } + }).start(); + + new Thread(new Runnable() { + @Override + public void run() { + internalThreadLocal.set(testVal2); + Assert.assertTrue("set is not equals get", Objects.equals(testVal2, internalThreadLocal.get())); + countDownLatch.countDown(); + } + }).start(); + countDownLatch.await(); + } + + /** + * print + * take[2689]ms + *

+ * This test is based on a Machine with 4 core and 16g memory. + */ + @Test + public void testPerformanceTradition() { + final ThreadLocal[] caches1 = new ThreadLocal[PERFORMANCE_THREAD_COUNT]; + final Thread mainThread = Thread.currentThread(); + for (int i = 0; i < PERFORMANCE_THREAD_COUNT; i++) { + caches1[i] = new ThreadLocal<>(); + } + Thread t1 = new Thread(new Runnable() { + @Override + public void run() { + for (int i = 0; i < PERFORMANCE_THREAD_COUNT; i++) { + caches1[i].set("float.lu"); + } + long start = System.nanoTime(); + for (int i = 0; i < PERFORMANCE_THREAD_COUNT; i++) { + for (int j = 0; j < 1000000; j++) { + caches1[i].get(); + } + } + long end = System.nanoTime(); + System.out.println("take[" + TimeUnit.NANOSECONDS.toMillis(end - start) + + "]ms"); + LockSupport.unpark(mainThread); + } + }); + t1.start(); + LockSupport.park(mainThread); + } + + /** + * print + * take[14]ms + *

+ * This test is based on a Machine with 4 core and 16g memory. + */ + @Test + public void testPerformance() { + final InternalThreadLocal[] caches = new InternalThreadLocal[PERFORMANCE_THREAD_COUNT]; + final Thread mainThread = Thread.currentThread(); + for (int i = 0; i < PERFORMANCE_THREAD_COUNT; i++) { + caches[i] = new InternalThreadLocal<>(); + } + Thread t = new InternalThread(new Runnable() { + @Override + public void run() { + for (int i = 0; i < PERFORMANCE_THREAD_COUNT; i++) { + caches[i].set("float.lu"); + } + long start = System.nanoTime(); + for (int i = 0; i < PERFORMANCE_THREAD_COUNT; i++) { + for (int j = 0; j < 1000000; j++) { + caches[i].get(); + } + } + long end = System.nanoTime(); + System.out.println("take[" + TimeUnit.NANOSECONDS.toMillis(end - start) + + "]ms"); + LockSupport.unpark(mainThread); + } + }); + t.start(); + LockSupport.park(mainThread); + } +} \ No newline at end of file diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/RpcContext.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/RpcContext.java index a542cd64888..bf56e2d12d4 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/RpcContext.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/RpcContext.java @@ -18,6 +18,7 @@ import com.alibaba.dubbo.common.Constants; import com.alibaba.dubbo.common.URL; +import com.alibaba.dubbo.common.threadlocal.InternalThreadLocal; import com.alibaba.dubbo.common.utils.NetUtils; import java.net.InetSocketAddress; @@ -45,12 +46,16 @@ */ public class RpcContext { - private static final ThreadLocal LOCAL = new ThreadLocal() { + /** + * use internal thread local to improve performance + */ + private static final InternalThreadLocal LOCAL = new InternalThreadLocal() { @Override protected RpcContext initialValue() { return new RpcContext(); } }; + private final Map attachments = new HashMap(); private final Map values = new HashMap(); private Future future; From 11373cf4788dd90a439030f352db0cde250e89d7 Mon Sep 17 00:00:00 2001 From: xiuyuhang <442367943@qq.com> Date: Sat, 5 May 2018 15:55:05 +0800 Subject: [PATCH 13/21] add License --- .../common/threadlocal/InternalThread.java | 17 +++++++++++++++++ .../common/threadlocal/InternalThreadLocal.java | 17 +++++++++++++++++ .../threadlocal/InternalThreadLocalMap.java | 17 +++++++++++++++++ .../threadlocal/NamedInternalThreadFactory.java | 17 +++++++++++++++++ .../threadlocal/InternalThreadLocalTest.java | 17 +++++++++++++++++ 5 files changed, 85 insertions(+) diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/InternalThread.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/InternalThread.java index f3cd046966c..64ff4af25b5 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/InternalThread.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/InternalThread.java @@ -1,3 +1,20 @@ +/* + * 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.alibaba.dubbo.common.threadlocal; /** diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocal.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocal.java index be72ebf5e8e..b96608e0d0f 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocal.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocal.java @@ -1,3 +1,20 @@ +/* + * 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.alibaba.dubbo.common.threadlocal; import java.util.Collections; diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocalMap.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocalMap.java index a2ffec77611..3c5e89f473a 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocalMap.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocalMap.java @@ -1,3 +1,20 @@ +/* + * 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.alibaba.dubbo.common.threadlocal; import java.util.Arrays; diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/NamedInternalThreadFactory.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/NamedInternalThreadFactory.java index 8c177ffd3a0..2e34cb3a0e9 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/NamedInternalThreadFactory.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/NamedInternalThreadFactory.java @@ -1,3 +1,20 @@ +/* + * 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.alibaba.dubbo.common.threadlocal; import com.alibaba.dubbo.common.utils.NamedThreadFactory; diff --git a/dubbo-common/src/test/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocalTest.java b/dubbo-common/src/test/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocalTest.java index e337fcdbc54..d76b1646b37 100644 --- a/dubbo-common/src/test/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocalTest.java +++ b/dubbo-common/src/test/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocalTest.java @@ -1,3 +1,20 @@ +/* + * 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.alibaba.dubbo.common.threadlocal; import org.junit.Assert; From 6d4102c6de4cc49a8c3794253ca58784296a0b07 Mon Sep 17 00:00:00 2001 From: xiuyuhang <442367943@qq.com> Date: Sat, 5 May 2018 16:22:03 +0800 Subject: [PATCH 14/21] fix ci failed --- .../common/threadpool/support/cached/CachedThreadPool.java | 6 +++++- .../common/threadpool/support/fixed/FixedThreadPool.java | 6 +++++- .../threadpool/support/limited/LimitedThreadPool.java | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/cached/CachedThreadPool.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/cached/CachedThreadPool.java index b4447f76753..c5aa285930c 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/cached/CachedThreadPool.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/cached/CachedThreadPool.java @@ -22,7 +22,11 @@ import com.alibaba.dubbo.common.threadpool.ThreadPool; import com.alibaba.dubbo.common.threadpool.support.AbortPolicyWithReport; -import java.util.concurrent.*; +import java.util.concurrent.Executor; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.SynchronousQueue; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; /** * This thread pool is self-tuned. Thread will be recycled after idle for one minute, and new thread will be created for diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/fixed/FixedThreadPool.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/fixed/FixedThreadPool.java index 801c53b53e3..d3b61a58691 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/fixed/FixedThreadPool.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/fixed/FixedThreadPool.java @@ -22,7 +22,11 @@ import com.alibaba.dubbo.common.threadpool.ThreadPool; import com.alibaba.dubbo.common.threadpool.support.AbortPolicyWithReport; -import java.util.concurrent.*; +import java.util.concurrent.Executor; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.SynchronousQueue; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; /** * Creates a thread pool that reuses a fixed number of threads diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/limited/LimitedThreadPool.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/limited/LimitedThreadPool.java index 6420bfc1377..b50bc9ee715 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/limited/LimitedThreadPool.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadpool/support/limited/LimitedThreadPool.java @@ -23,7 +23,11 @@ import com.alibaba.dubbo.common.threadpool.ThreadPool; import com.alibaba.dubbo.common.threadpool.support.AbortPolicyWithReport; -import java.util.concurrent.*; +import java.util.concurrent.Executor; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.SynchronousQueue; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; /** * Creates a thread pool that creates new threads as needed until limits reaches. This thread pool will not shrink From c831e2c1d83275ef3f812c2e917b461b402a389d Mon Sep 17 00:00:00 2001 From: xiuyuhang <442367943@qq.com> Date: Sat, 5 May 2018 16:25:58 +0800 Subject: [PATCH 15/21] fix ci failed --- .../dubbo/common/threadlocal/InternalThreadLocalMap.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocalMap.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocalMap.java index 3c5e89f473a..19824efb055 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocalMap.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocalMap.java @@ -29,7 +29,7 @@ public final class InternalThreadLocalMap { private Object[] indexedVariables; - private static final ThreadLocal slowThreadLocalMap = new ThreadLocal<>(); + private static final ThreadLocal slowThreadLocalMap = new ThreadLocal(); private static final AtomicInteger nextIndex = new AtomicInteger(); From 3a055d21c0de685021ba2bb54c61f546d2b97bd2 Mon Sep 17 00:00:00 2001 From: xiuyuhang <442367943@qq.com> Date: Sat, 5 May 2018 16:29:13 +0800 Subject: [PATCH 16/21] fix ci failed --- .../dubbo/common/threadlocal/InternalThreadLocalTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dubbo-common/src/test/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocalTest.java b/dubbo-common/src/test/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocalTest.java index d76b1646b37..c86603924d2 100644 --- a/dubbo-common/src/test/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocalTest.java +++ b/dubbo-common/src/test/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocalTest.java @@ -104,7 +104,7 @@ public void testPerformanceTradition() { final ThreadLocal[] caches1 = new ThreadLocal[PERFORMANCE_THREAD_COUNT]; final Thread mainThread = Thread.currentThread(); for (int i = 0; i < PERFORMANCE_THREAD_COUNT; i++) { - caches1[i] = new ThreadLocal<>(); + caches1[i] = new ThreadLocal(); } Thread t1 = new Thread(new Runnable() { @Override @@ -139,7 +139,7 @@ public void testPerformance() { final InternalThreadLocal[] caches = new InternalThreadLocal[PERFORMANCE_THREAD_COUNT]; final Thread mainThread = Thread.currentThread(); for (int i = 0; i < PERFORMANCE_THREAD_COUNT; i++) { - caches[i] = new InternalThreadLocal<>(); + caches[i] = new InternalThreadLocal(); } Thread t = new InternalThread(new Runnable() { @Override From 722b757db3535dfaf3107104fa261620c109dd0f Mon Sep 17 00:00:00 2001 From: xiuyuhang <442367943@qq.com> Date: Sat, 5 May 2018 16:37:45 +0800 Subject: [PATCH 17/21] fix ci failed --- .../threadlocal/InternalThreadLocalTest.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/dubbo-common/src/test/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocalTest.java b/dubbo-common/src/test/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocalTest.java index c86603924d2..144b087f51b 100644 --- a/dubbo-common/src/test/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocalTest.java +++ b/dubbo-common/src/test/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocalTest.java @@ -32,6 +32,8 @@ public class InternalThreadLocalTest { private static final int PERFORMANCE_THREAD_COUNT = 1000; + private static final int GET_COUNT = 1000000; + @Test public void testInternalThreadLocal() throws InterruptedException { AtomicInteger index = new AtomicInteger(0); @@ -63,7 +65,8 @@ public void testSetAndGet() { final Integer testVal = 10; final InternalThreadLocal internalThreadLocal = new InternalThreadLocal(); internalThreadLocal.set(testVal); - Assert.assertTrue("set is not equals get", Objects.equals(testVal, internalThreadLocal.get())); + Assert.assertTrue("set is not equals get", + Objects.equals(testVal, internalThreadLocal.get())); } @Test @@ -77,7 +80,8 @@ public void testMultiThreadSetAndGet() throws InterruptedException { public void run() { internalThreadLocal.set(testVal1); - Assert.assertTrue("set is not equals get", Objects.equals(testVal1, internalThreadLocal.get())); + Assert.assertTrue("set is not equals get", + Objects.equals(testVal1, internalThreadLocal.get())); countDownLatch.countDown(); } }).start(); @@ -86,7 +90,8 @@ public void run() { @Override public void run() { internalThreadLocal.set(testVal2); - Assert.assertTrue("set is not equals get", Objects.equals(testVal2, internalThreadLocal.get())); + Assert.assertTrue("set is not equals get", + Objects.equals(testVal2, internalThreadLocal.get())); countDownLatch.countDown(); } }).start(); @@ -114,7 +119,7 @@ public void run() { } long start = System.nanoTime(); for (int i = 0; i < PERFORMANCE_THREAD_COUNT; i++) { - for (int j = 0; j < 1000000; j++) { + for (int j = 0; j < GET_COUNT; j++) { caches1[i].get(); } } @@ -149,7 +154,7 @@ public void run() { } long start = System.nanoTime(); for (int i = 0; i < PERFORMANCE_THREAD_COUNT; i++) { - for (int j = 0; j < 1000000; j++) { + for (int j = 0; j < GET_COUNT; j++) { caches[i].get(); } } From 3a2fad73497eb507326b3f24afd9194e006f2c21 Mon Sep 17 00:00:00 2001 From: xiuyuhang <442367943@qq.com> Date: Sat, 5 May 2018 16:49:13 +0800 Subject: [PATCH 18/21] fix ci failed --- .../threadlocal/InternalThreadLocalTest.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/dubbo-common/src/test/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocalTest.java b/dubbo-common/src/test/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocalTest.java index 144b087f51b..b0a8c28c294 100644 --- a/dubbo-common/src/test/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocalTest.java +++ b/dubbo-common/src/test/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocalTest.java @@ -36,7 +36,7 @@ public class InternalThreadLocalTest { @Test public void testInternalThreadLocal() throws InterruptedException { - AtomicInteger index = new AtomicInteger(0); + final AtomicInteger index = new AtomicInteger(0); final InternalThreadLocal internalThreadLocal = new InternalThreadLocal() { @@ -49,12 +49,13 @@ protected Integer initialValue() throws Exception { }; for (int i = 0; i < THREADS; i++) { - new Thread(new Runnable() { + Thread t = new Thread(new Runnable() { @Override public void run() { internalThreadLocal.get(); } - }).start(); + }); + t.start(); } Thread.sleep(2000); @@ -75,7 +76,7 @@ public void testMultiThreadSetAndGet() throws InterruptedException { final Integer testVal2 = 20; final InternalThreadLocal internalThreadLocal = new InternalThreadLocal(); final CountDownLatch countDownLatch = new CountDownLatch(2); - new Thread(new Runnable() { + Thread t1 = new Thread(new Runnable() { @Override public void run() { @@ -84,9 +85,10 @@ public void run() { Objects.equals(testVal1, internalThreadLocal.get())); countDownLatch.countDown(); } - }).start(); + }); + t1.start(); - new Thread(new Runnable() { + Thread t2 = new Thread(new Runnable() { @Override public void run() { internalThreadLocal.set(testVal2); @@ -94,7 +96,8 @@ public void run() { Objects.equals(testVal2, internalThreadLocal.get())); countDownLatch.countDown(); } - }).start(); + }); + t2.start(); countDownLatch.await(); } From ffac33f0e23e60aff3c0435e614535c1812e2f10 Mon Sep 17 00:00:00 2001 From: xiuyuhang <442367943@qq.com> Date: Mon, 14 May 2018 16:30:31 +0800 Subject: [PATCH 19/21] remove author info --- .../com/alibaba/dubbo/common/threadlocal/InternalThread.java | 3 --- .../alibaba/dubbo/common/threadlocal/InternalThreadLocal.java | 3 --- .../dubbo/common/threadlocal/NamedInternalThreadFactory.java | 3 --- 3 files changed, 9 deletions(-) diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/InternalThread.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/InternalThread.java index 64ff4af25b5..a836561c50a 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/InternalThread.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/InternalThread.java @@ -19,9 +19,6 @@ /** * InternalThread - * - * @author xiuyuhang [xiuyuhang] - * @since 2018-05-05 */ public class InternalThread extends Thread { diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocal.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocal.java index b96608e0d0f..4eed57c4e84 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocal.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocal.java @@ -31,9 +31,6 @@ * table, and it is useful when accessed frequently. *

* This design is learning from {@see io.netty.util.concurrent.FastThreadLocal} which is in Netty. - * - * @author xiuyuhang [xiuyuhang] - * @since 2018-05-05 */ public class InternalThreadLocal { diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/NamedInternalThreadFactory.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/NamedInternalThreadFactory.java index 2e34cb3a0e9..03868b91751 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/NamedInternalThreadFactory.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/NamedInternalThreadFactory.java @@ -22,9 +22,6 @@ /** * NamedInternalThreadFactory * This is a threadFactory which produce {@link InternalThread} - * - * @author xiuyuhang [xiuyuhang] - * @since 2018-05-05 */ public class NamedInternalThreadFactory extends NamedThreadFactory { From c3ec317f8a36aada3ba24b48a5774c5eff8960d8 Mon Sep 17 00:00:00 2001 From: xiuyuhang <442367943@qq.com> Date: Mon, 14 May 2018 19:25:42 +0800 Subject: [PATCH 20/21] fix destroy method --- .../dubbo/common/threadlocal/InternalThreadLocalMap.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocalMap.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocalMap.java index 19824efb055..9695e71c5e9 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocalMap.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocalMap.java @@ -29,7 +29,7 @@ public final class InternalThreadLocalMap { private Object[] indexedVariables; - private static final ThreadLocal slowThreadLocalMap = new ThreadLocal(); + private static ThreadLocal slowThreadLocalMap = new ThreadLocal(); private static final AtomicInteger nextIndex = new AtomicInteger(); @@ -61,7 +61,7 @@ public static void remove() { } public static void destroy() { - slowThreadLocalMap.remove(); + slowThreadLocalMap = null; } public static int nextVariableIndex() { From 1e38ad8cd03db991120fe409fe9f38749baf1ef5 Mon Sep 17 00:00:00 2001 From: xiuyuhang <442367943@qq.com> Date: Mon, 14 May 2018 19:51:31 +0800 Subject: [PATCH 21/21] fix bug at method size. --- .../dubbo/common/threadlocal/InternalThreadLocalMap.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocalMap.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocalMap.java index 9695e71c5e9..e2aa0fd30dc 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocalMap.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/threadlocal/InternalThreadLocalMap.java @@ -119,7 +119,10 @@ public int size() { ++count; } } - return count; + + //the fist element in `indexedVariables` is a set to keep all the InternalThreadLocal to remove + //look at method `addToVariablesToRemove` + return count - 1; } private static Object[] newIndexedVariableTable() {