You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@dubbo.apache.org by GitBox <gi...@apache.org> on 2018/03/30 08:23:47 UTC
[GitHub] mercyblitz closed pull request #1527: 2.5.11
mercyblitz closed pull request #1527: 2.5.11
URL: https://github.com/apache/incubator-dubbo/pull/1527
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/.mvn/wrapper/maven-wrapper.jar b/.mvn/wrapper/maven-wrapper.jar
deleted file mode 100755
index 41c70a7e0b..0000000000
Binary files a/.mvn/wrapper/maven-wrapper.jar and /dev/null differ
diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties
deleted file mode 100755
index c315043703..0000000000
--- a/.mvn/wrapper/maven-wrapper.properties
+++ /dev/null
@@ -1 +0,0 @@
-distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip
diff --git a/dubbo-admin/pom.xml b/dubbo-admin/pom.xml
index fd5bda541e..3b7b2ccb04 100644
--- a/dubbo-admin/pom.xml
+++ b/dubbo-admin/pom.xml
@@ -1,170 +1,170 @@
-<!--
- - 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.
--->
-<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>com.alibaba</groupId>
- <artifactId>dubbo-parent</artifactId>
- <version>2.5.10</version>
- </parent>
- <artifactId>dubbo-admin</artifactId>
- <packaging>war</packaging>
- <name>${project.artifactId}</name>
- <description>The admin module of dubbo project</description>
- <properties>
- <wtpversion>1.5</wtpversion>
- <wtpContextName>/</wtpContextName>
- <eclipse.useProjectReferences>false</eclipse.useProjectReferences>
- <skip_maven_deploy>false</skip_maven_deploy>
- </properties>
- <!-- Fix webx 3.x not compatible with spring 4.x or higher -->
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-framework-bom</artifactId>
- <version>3.2.16.RELEASE</version>
- <scope>import</scope>
- <type>pom</type>
- </dependency>
- </dependencies>
- </dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>com.alibaba</groupId>
- <artifactId>dubbo</artifactId>
- <version>${project.parent.version}</version>
- </dependency>
- <dependency>
- <groupId>com.alibaba.citrus</groupId>
- <artifactId>citrus-webx-all</artifactId>
- </dependency>
- <dependency>
- <groupId>org.javassist</groupId>
- <artifactId>javassist</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.netty</groupId>
- <artifactId>netty</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.mina</groupId>
- <artifactId>mina-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.glassfish.grizzly</groupId>
- <artifactId>grizzly-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpclient</artifactId>
- </dependency>
- <dependency>
- <groupId>com.alibaba</groupId>
- <artifactId>fastjson</artifactId>
- </dependency>
- <dependency>
- <groupId>com.thoughtworks.xstream</groupId>
- <artifactId>xstream</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.bsf</groupId>
- <artifactId>bsf-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.zookeeper</groupId>
- <artifactId>zookeeper</artifactId>
- </dependency>
- <dependency>
- <groupId>com.101tec</groupId>
- <artifactId>zkclient</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.curator</groupId>
- <artifactId>curator-framework</artifactId>
- </dependency>
- <dependency>
- <groupId>com.googlecode.xmemcached</groupId>
- <artifactId>xmemcached</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.thrift</groupId>
- <artifactId>libthrift</artifactId>
- </dependency>
- <dependency>
- <groupId>com.caucho</groupId>
- <artifactId>hessian</artifactId>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- </dependency>
- <dependency>
- <groupId>redis.clients</groupId>
- <artifactId>jedis</artifactId>
- </dependency>
- <dependency>
- <groupId>javax.validation</groupId>
- <artifactId>validation-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-validator</artifactId>
- </dependency>
- <dependency>
- <groupId>javax.cache</groupId>
- <artifactId>cache-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.velocity</groupId>
- <artifactId>velocity</artifactId>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>maven-jetty-plugin</artifactId>
- <version>${jetty_version}</version>
- <configuration>
- <contextPath>/</contextPath>
- <scanIntervalSeconds>10</scanIntervalSeconds>
- <connectors>
- <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
- <port>8080</port>
- <maxIdleTime>60000</maxIdleTime>
- </connector>
- </connectors>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
+<!--
+ - 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.
+-->
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>com.alibaba</groupId>
+ <artifactId>dubbo-parent</artifactId>
+ <version>2.5.11</version>
+ </parent>
+ <artifactId>dubbo-admin</artifactId>
+ <packaging>war</packaging>
+ <name>${project.artifactId}</name>
+ <description>The admin module of dubbo project</description>
+ <properties>
+ <wtpversion>1.5</wtpversion>
+ <wtpContextName>/</wtpContextName>
+ <eclipse.useProjectReferences>false</eclipse.useProjectReferences>
+ <skip_maven_deploy>false</skip_maven_deploy>
+ </properties>
+ <!-- Fix webx 3.x not compatible with spring 4.x or higher -->
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-framework-bom</artifactId>
+ <version>3.2.16.RELEASE</version>
+ <scope>import</scope>
+ <type>pom</type>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>com.alibaba</groupId>
+ <artifactId>dubbo</artifactId>
+ <version>${project.parent.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.alibaba.citrus</groupId>
+ <artifactId>citrus-webx-all</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.javassist</groupId>
+ <artifactId>javassist</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.netty</groupId>
+ <artifactId>netty</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.mina</groupId>
+ <artifactId>mina-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish.grizzly</groupId>
+ <artifactId>grizzly-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.alibaba</groupId>
+ <artifactId>fastjson</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.thoughtworks.xstream</groupId>
+ <artifactId>xstream</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.bsf</groupId>
+ <artifactId>bsf-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.zookeeper</groupId>
+ <artifactId>zookeeper</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.101tec</groupId>
+ <artifactId>zkclient</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.curator</groupId>
+ <artifactId>curator-framework</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.googlecode.xmemcached</groupId>
+ <artifactId>xmemcached</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.thrift</groupId>
+ <artifactId>libthrift</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.caucho</groupId>
+ <artifactId>hessian</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>redis.clients</groupId>
+ <artifactId>jedis</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.validation</groupId>
+ <artifactId>validation-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-validator</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.cache</groupId>
+ <artifactId>cache-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.velocity</groupId>
+ <artifactId>velocity</artifactId>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>maven-jetty-plugin</artifactId>
+ <version>${jetty_version}</version>
+ <configuration>
+ <contextPath>/</contextPath>
+ <scanIntervalSeconds>10</scanIntervalSeconds>
+ <connectors>
+ <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
+ <port>8080</port>
+ <maxIdleTime>60000</maxIdleTime>
+ </connector>
+ </connectors>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/dubbo-admin/src/test/assembly/bin/setup.bat b/dubbo-admin/src/test/assembly/bin/setup.bat
index 25f79d4dd4..eac0ee7768 100755
--- a/dubbo-admin/src/test/assembly/bin/setup.bat
+++ b/dubbo-admin/src/test/assembly/bin/setup.bat
@@ -1,83 +1,83 @@
-@echo off
-set username=root
-set password=mysql
-set devuser=dubbo_registry
-set devuserpass=dubbo_registry
-set database=dubbo_registry
-set sqlpath=..\..\..\..\..\dubbo.registry.server\src\main\assembly\sql\mysql.sql
-
-echo.
-echo prerequisites check...
-
-mysql --version 1> nul 2>nul
-IF %ERRORLEVEL% == 0 (echo --mysql client exist, okay!) ELSE (GOTO NO_MYSQL_CLIENT)
-
-:: check if we can login to database with root account
-ECHO select 1 | mysql -u %username% -p%password% 1> nul 2>nul
-IF %ERRORLEVEL% == 0 (echo --mysql login with root, okay!) ELSE (GOTO CANT_LOGIN)
-
-:: check if populate sql exists
-IF EXIST %sqlpath% (echo --mysql.sql exist, okay!) ELSE GOTO SQLPATH_INVALID
-
-echo prerequisites all okay!
-echo.
-
-
-:: check if dubbo_registry exists
-ECHO use %database% | mysql -u %username% -p%password% 1> nul 2>nul
-IF %ERRORLEVEL% == 0 (echo %database% exists, drop it.) ELSE (GOTO NO_DROP)
-
-:: drop database
-ECHO drop database %database% | mysql -u %username% -p%password% 1> nul 2>nul
-IF %ERRORLEVEL% == 0 (echo %database% dropped.) ELSE (GOTO DROP_FAILED)
-
-:NO_DROP
-:: re-create the database
-ECHO create database %database% | mysql -u %username% -p%password% 1> nul 2>nul
-IF %ERRORLEVEL% == 0 (echo %database% re-created.) ELSE (GOTO CREATE_FAILED)
-
-:: create user and grant priviliges
-ECHO grant all privileges on %database%.* to %devuser%@'%' identified by '%devuserpass%' | mysql -u %username% -p%password% 1> nul 2>nul
-IF %ERRORLEVEL% == 0 (echo privilige of %database% to %devuser% granted.) ELSE (GOTO GRANT_FAILED)
-
-:: populate tables
-mysql -u %username% -p%password% %database% < %sqlpath%
-IF %ERRORLEVEL% == 0 (echo tables for %database% populated.) ELSE (GOTO POPULATE_FAILED)
-
-GOTO SUCCESS
-
-:: error handling section
-:NO_MYSQL_CLIENT
-echo please install mysql client first!
-goto FAILED
-
-:CANT_LOGIN
-echo please ensure: 1. mysql service is on. 2. root password is 111111
-goto FAILED
-
-:SQLPATH_INVALID
-echo sql file path (%sqlpath%) does not exist!
-goto FAILED
-
-:DROP_FAILED
-echo drop database %database% failed!
-goto FAILED
-
-:DROP_FAILED
-echo re-create database %database% failed!
-goto FAILED
-
-:POPULATE_FAILED
-echo populate tables for database %database% failed!
-goto FAILED
-
-:GRANT_FAILED
-echo privilige of %database% to %username% grant failed!
-goto FAILED
-
-:SUCCESS
-echo.
-echo dev environment setup successfully!
-
-:FAILED
-
+@echo off
+set username=root
+set password=mysql
+set devuser=dubbo_registry
+set devuserpass=dubbo_registry
+set database=dubbo_registry
+set sqlpath=..\..\..\..\..\dubbo.registry.server\src\main\assembly\sql\mysql.sql
+
+echo.
+echo prerequisites check...
+
+mysql --version 1> nul 2>nul
+IF %ERRORLEVEL% == 0 (echo --mysql client exist, okay!) ELSE (GOTO NO_MYSQL_CLIENT)
+
+:: check if we can login to database with root account
+ECHO select 1 | mysql -u %username% -p%password% 1> nul 2>nul
+IF %ERRORLEVEL% == 0 (echo --mysql login with root, okay!) ELSE (GOTO CANT_LOGIN)
+
+:: check if populate sql exists
+IF EXIST %sqlpath% (echo --mysql.sql exist, okay!) ELSE GOTO SQLPATH_INVALID
+
+echo prerequisites all okay!
+echo.
+
+
+:: check if dubbo_registry exists
+ECHO use %database% | mysql -u %username% -p%password% 1> nul 2>nul
+IF %ERRORLEVEL% == 0 (echo %database% exists, drop it.) ELSE (GOTO NO_DROP)
+
+:: drop database
+ECHO drop database %database% | mysql -u %username% -p%password% 1> nul 2>nul
+IF %ERRORLEVEL% == 0 (echo %database% dropped.) ELSE (GOTO DROP_FAILED)
+
+:NO_DROP
+:: re-create the database
+ECHO create database %database% | mysql -u %username% -p%password% 1> nul 2>nul
+IF %ERRORLEVEL% == 0 (echo %database% re-created.) ELSE (GOTO CREATE_FAILED)
+
+:: create user and grant priviliges
+ECHO grant all privileges on %database%.* to %devuser%@'%' identified by '%devuserpass%' | mysql -u %username% -p%password% 1> nul 2>nul
+IF %ERRORLEVEL% == 0 (echo privilige of %database% to %devuser% granted.) ELSE (GOTO GRANT_FAILED)
+
+:: populate tables
+mysql -u %username% -p%password% %database% < %sqlpath%
+IF %ERRORLEVEL% == 0 (echo tables for %database% populated.) ELSE (GOTO POPULATE_FAILED)
+
+GOTO SUCCESS
+
+:: error handling section
+:NO_MYSQL_CLIENT
+echo please install mysql client first!
+goto FAILED
+
+:CANT_LOGIN
+echo please ensure: 1. mysql service is on. 2. root password is 111111
+goto FAILED
+
+:SQLPATH_INVALID
+echo sql file path (%sqlpath%) does not exist!
+goto FAILED
+
+:DROP_FAILED
+echo drop database %database% failed!
+goto FAILED
+
+:DROP_FAILED
+echo re-create database %database% failed!
+goto FAILED
+
+:POPULATE_FAILED
+echo populate tables for database %database% failed!
+goto FAILED
+
+:GRANT_FAILED
+echo privilige of %database% to %username% grant failed!
+goto FAILED
+
+:SUCCESS
+echo.
+echo dev environment setup successfully!
+
+:FAILED
+
diff --git a/dubbo-cluster/pom.xml b/dubbo-cluster/pom.xml
index 3f79976646..ef37a24e58 100644
--- a/dubbo-cluster/pom.xml
+++ b/dubbo-cluster/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-parent</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>dubbo-cluster</artifactId>
<packaging>jar</packaging>
diff --git a/dubbo-common/pom.xml b/dubbo-common/pom.xml
index 18ec4dd489..1c99c37508 100644
--- a/dubbo-common/pom.xml
+++ b/dubbo-common/pom.xml
@@ -21,7 +21,7 @@ limitations under the License.
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-parent</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>dubbo-common</artifactId>
<packaging>jar</packaging>
diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/Serialization.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/Serialization.java
index 43da3d6a6f..ad0da60ddf 100644
--- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/Serialization.java
+++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/Serialization.java
@@ -1,69 +1,69 @@
-/*
- * 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.serialize;
-
-import com.alibaba.dubbo.common.URL;
-import com.alibaba.dubbo.common.extension.Adaptive;
-import com.alibaba.dubbo.common.extension.SPI;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-/**
- * Serialization. (SPI, Singleton, ThreadSafe)
- */
-@SPI("hessian2")
-public interface Serialization {
-
- /**
- * get content type id
- *
- * @return content type id
- */
- byte getContentTypeId();
-
- /**
- * get content type
- *
- * @return content type
- */
- String getContentType();
-
- /**
- * create serializer
- *
- * @param url
- * @param output
- * @return serializer
- * @throws IOException
- */
- @Adaptive
- ObjectOutput serialize(URL url, OutputStream output) throws IOException;
-
- /**
- * create deserializer
- *
- * @param url
- * @param input
- * @return deserializer
- * @throws IOException
- */
- @Adaptive
- ObjectInput deserialize(URL url, InputStream input) throws IOException;
-
+/*
+ * 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.serialize;
+
+import com.alibaba.dubbo.common.URL;
+import com.alibaba.dubbo.common.extension.Adaptive;
+import com.alibaba.dubbo.common.extension.SPI;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * Serialization. (SPI, Singleton, ThreadSafe)
+ */
+@SPI("hessian2")
+public interface Serialization {
+
+ /**
+ * get content type id
+ *
+ * @return content type id
+ */
+ byte getContentTypeId();
+
+ /**
+ * get content type
+ *
+ * @return content type
+ */
+ String getContentType();
+
+ /**
+ * create serializer
+ *
+ * @param url
+ * @param output
+ * @return serializer
+ * @throws IOException
+ */
+ @Adaptive
+ ObjectOutput serialize(URL url, OutputStream output) throws IOException;
+
+ /**
+ * create deserializer
+ *
+ * @param url
+ * @param input
+ * @return deserializer
+ * @throws IOException
+ */
+ @Adaptive
+ ObjectInput deserialize(URL url, InputStream input) throws IOException;
+
}
\ No newline at end of file
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 3a475285b2..da5321c57c 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
@@ -1,46 +1,46 @@
-/*
- * 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.serialize.support.dubbo;
-
-import com.alibaba.dubbo.common.URL;
-import com.alibaba.dubbo.common.serialize.ObjectInput;
-import com.alibaba.dubbo.common.serialize.ObjectOutput;
-import com.alibaba.dubbo.common.serialize.Serialization;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-public class DubboSerialization implements Serialization {
-
- public byte getContentTypeId() {
- return 1;
- }
-
- public String getContentType() {
- return "x-application/dubbo";
- }
-
- public ObjectOutput serialize(URL url, OutputStream out) throws IOException {
- return new GenericObjectOutput(out);
- }
-
- public ObjectInput deserialize(URL url, InputStream is) throws IOException {
- return new GenericObjectInput(is);
- }
-
+/*
+ * 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.serialize.support.dubbo;
+
+import com.alibaba.dubbo.common.URL;
+import com.alibaba.dubbo.common.serialize.ObjectInput;
+import com.alibaba.dubbo.common.serialize.ObjectOutput;
+import com.alibaba.dubbo.common.serialize.Serialization;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+public class DubboSerialization implements Serialization {
+
+ public byte getContentTypeId() {
+ return 1;
+ }
+
+ public String getContentType() {
+ return "x-application/dubbo";
+ }
+
+ public ObjectOutput serialize(URL url, OutputStream out) throws IOException {
+ return new GenericObjectOutput(out);
+ }
+
+ public ObjectInput deserialize(URL url, InputStream is) throws IOException {
+ return new GenericObjectInput(is);
+ }
+
}
\ No newline at end of file
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 eb78df0502..e6276218d3 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
@@ -1,48 +1,48 @@
-/*
- * 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.serialize.support.hessian;
-
-import com.alibaba.dubbo.common.URL;
-import com.alibaba.dubbo.common.serialize.ObjectInput;
-import com.alibaba.dubbo.common.serialize.ObjectOutput;
-import com.alibaba.dubbo.common.serialize.Serialization;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-public class Hessian2Serialization implements Serialization {
-
- public static final byte ID = 2;
-
- public byte getContentTypeId() {
- return ID;
- }
-
- public String getContentType() {
- return "x-application/hessian2";
- }
-
- public ObjectOutput serialize(URL url, OutputStream out) throws IOException {
- return new Hessian2ObjectOutput(out);
- }
-
- public ObjectInput deserialize(URL url, InputStream is) throws IOException {
- return new Hessian2ObjectInput(is);
- }
-
+/*
+ * 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.serialize.support.hessian;
+
+import com.alibaba.dubbo.common.URL;
+import com.alibaba.dubbo.common.serialize.ObjectInput;
+import com.alibaba.dubbo.common.serialize.ObjectOutput;
+import com.alibaba.dubbo.common.serialize.Serialization;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+public class Hessian2Serialization implements Serialization {
+
+ public static final byte ID = 2;
+
+ public byte getContentTypeId() {
+ return ID;
+ }
+
+ public String getContentType() {
+ return "x-application/hessian2";
+ }
+
+ public ObjectOutput serialize(URL url, OutputStream out) throws IOException {
+ return new Hessian2ObjectOutput(out);
+ }
+
+ public ObjectInput deserialize(URL url, InputStream is) throws IOException {
+ return new Hessian2ObjectInput(is);
+ }
+
}
\ No newline at end of file
diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/hessian/Hessian2SerializerFactory.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/hessian/Hessian2SerializerFactory.java
index 2d5b7aae4d..ace5d4d67e 100644
--- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/hessian/Hessian2SerializerFactory.java
+++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/hessian/Hessian2SerializerFactory.java
@@ -1,33 +1,33 @@
-/*
- * 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.serialize.support.hessian;
-
-import com.alibaba.com.caucho.hessian.io.SerializerFactory;
-
-public class Hessian2SerializerFactory extends SerializerFactory {
-
- public static final SerializerFactory SERIALIZER_FACTORY = new Hessian2SerializerFactory();
-
- private Hessian2SerializerFactory() {
- }
-
- @Override
- public ClassLoader getClassLoader() {
- return Thread.currentThread().getContextClassLoader();
- }
-
-}
+/*
+ * 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.serialize.support.hessian;
+
+import com.alibaba.com.caucho.hessian.io.SerializerFactory;
+
+public class Hessian2SerializerFactory extends SerializerFactory {
+
+ public static final SerializerFactory SERIALIZER_FACTORY = new Hessian2SerializerFactory();
+
+ private Hessian2SerializerFactory() {
+ }
+
+ @Override
+ public ClassLoader getClassLoader() {
+ return Thread.currentThread().getContextClassLoader();
+ }
+
+}
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 04da07a871..b95ce0789b 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
@@ -1,46 +1,46 @@
-/*
- * 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.serialize.support.java;
-
-import com.alibaba.dubbo.common.URL;
-import com.alibaba.dubbo.common.serialize.ObjectInput;
-import com.alibaba.dubbo.common.serialize.ObjectOutput;
-import com.alibaba.dubbo.common.serialize.Serialization;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-public class CompactedJavaSerialization implements Serialization {
-
- public byte getContentTypeId() {
- return 4;
- }
-
- public String getContentType() {
- return "x-application/compactedjava";
- }
-
- public ObjectOutput serialize(URL url, OutputStream out) throws IOException {
- return new JavaObjectOutput(out, true);
- }
-
- public ObjectInput deserialize(URL url, InputStream is) throws IOException {
- return new JavaObjectInput(is, true);
- }
-
+/*
+ * 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.serialize.support.java;
+
+import com.alibaba.dubbo.common.URL;
+import com.alibaba.dubbo.common.serialize.ObjectInput;
+import com.alibaba.dubbo.common.serialize.ObjectOutput;
+import com.alibaba.dubbo.common.serialize.Serialization;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+public class CompactedJavaSerialization implements Serialization {
+
+ public byte getContentTypeId() {
+ return 4;
+ }
+
+ public String getContentType() {
+ return "x-application/compactedjava";
+ }
+
+ public ObjectOutput serialize(URL url, OutputStream out) throws IOException {
+ return new JavaObjectOutput(out, true);
+ }
+
+ public ObjectInput deserialize(URL url, InputStream is) throws IOException {
+ return new JavaObjectInput(is, true);
+ }
+
}
\ No newline at end of file
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 c4206b5215..bb12356469 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
@@ -1,46 +1,46 @@
-/*
- * 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.serialize.support.java;
-
-import com.alibaba.dubbo.common.URL;
-import com.alibaba.dubbo.common.serialize.ObjectInput;
-import com.alibaba.dubbo.common.serialize.ObjectOutput;
-import com.alibaba.dubbo.common.serialize.Serialization;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-public class JavaSerialization implements Serialization {
-
- public byte getContentTypeId() {
- return 3;
- }
-
- public String getContentType() {
- return "x-application/java";
- }
-
- public ObjectOutput serialize(URL url, OutputStream out) throws IOException {
- return new JavaObjectOutput(out);
- }
-
- public ObjectInput deserialize(URL url, InputStream is) throws IOException {
- return new JavaObjectInput(is);
- }
-
+/*
+ * 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.serialize.support.java;
+
+import com.alibaba.dubbo.common.URL;
+import com.alibaba.dubbo.common.serialize.ObjectInput;
+import com.alibaba.dubbo.common.serialize.ObjectOutput;
+import com.alibaba.dubbo.common.serialize.Serialization;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+public class JavaSerialization implements Serialization {
+
+ public byte getContentTypeId() {
+ return 3;
+ }
+
+ public String getContentType() {
+ return "x-application/java";
+ }
+
+ public ObjectOutput serialize(URL url, OutputStream out) throws IOException {
+ return new JavaObjectOutput(out);
+ }
+
+ public ObjectInput deserialize(URL url, InputStream is) throws IOException {
+ return new JavaObjectInput(is);
+ }
+
}
\ No newline at end of file
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 9861698c82..1eba8467ad 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
@@ -1,136 +1,136 @@
-/*
- * 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.serialize.support.json;
-
-import com.alibaba.dubbo.common.serialize.ObjectInput;
-import com.alibaba.dubbo.common.utils.PojoUtils;
-import com.alibaba.fastjson.JSON;
-
-import java.io.BufferedReader;
-import java.io.EOFException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.lang.reflect.Type;
-
-/**
- * JsonObjectInput
- */
-public class FastJsonObjectInput implements ObjectInput {
-
- private final BufferedReader reader;
-
- public FastJsonObjectInput(InputStream in) {
- this(new InputStreamReader(in));
- }
-
- public FastJsonObjectInput(Reader reader) {
- this.reader = new BufferedReader(reader);
- }
-
- public boolean readBool() throws IOException {
- try {
- return readObject(boolean.class);
- } catch (ClassNotFoundException e) {
- throw new IOException(e.getMessage());
- }
- }
-
- public byte readByte() throws IOException {
- try {
- return readObject(byte.class);
- } catch (ClassNotFoundException e) {
- throw new IOException(e.getMessage());
- }
- }
-
- public short readShort() throws IOException {
- try {
- return readObject(short.class);
- } catch (ClassNotFoundException e) {
- throw new IOException(e.getMessage());
- }
- }
-
- public int readInt() throws IOException {
- try {
- return readObject(int.class);
- } catch (ClassNotFoundException e) {
- throw new IOException(e.getMessage());
- }
- }
-
- public long readLong() throws IOException {
- try {
- return readObject(long.class);
- } catch (ClassNotFoundException e) {
- throw new IOException(e.getMessage());
- }
- }
-
- public float readFloat() throws IOException {
- try {
- return readObject(float.class);
- } catch (ClassNotFoundException e) {
- throw new IOException(e.getMessage());
- }
- }
-
- public double readDouble() throws IOException {
- try {
- return readObject(double.class);
- } catch (ClassNotFoundException e) {
- throw new IOException(e.getMessage());
- }
- }
-
- public String readUTF() throws IOException {
- try {
- return readObject(String.class);
- } catch (ClassNotFoundException e) {
- throw new IOException(e.getMessage());
- }
- }
-
- public byte[] readBytes() throws IOException {
- return readLine().getBytes();
- }
-
- public Object readObject() throws IOException, ClassNotFoundException {
- String json = readLine();
- return JSON.parse(json);
- }
-
- public <T> T readObject(Class<T> cls) throws IOException, ClassNotFoundException {
- String json = readLine();
- return JSON.parseObject(json, cls);
- }
-
- @SuppressWarnings("unchecked")
- public <T> T readObject(Class<T> cls, Type type) throws IOException, ClassNotFoundException {
- Object value = readObject(cls);
- return (T) PojoUtils.realize(value, cls, type);
- }
-
- private String readLine() throws IOException, EOFException {
- String line = reader.readLine();
- if (line == null || line.trim().length() == 0) throw new EOFException();
- return line;
- }
-
+/*
+ * 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.serialize.support.json;
+
+import com.alibaba.dubbo.common.serialize.ObjectInput;
+import com.alibaba.dubbo.common.utils.PojoUtils;
+import com.alibaba.fastjson.JSON;
+
+import java.io.BufferedReader;
+import java.io.EOFException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.lang.reflect.Type;
+
+/**
+ * JsonObjectInput
+ */
+public class FastJsonObjectInput implements ObjectInput {
+
+ private final BufferedReader reader;
+
+ public FastJsonObjectInput(InputStream in) {
+ this(new InputStreamReader(in));
+ }
+
+ public FastJsonObjectInput(Reader reader) {
+ this.reader = new BufferedReader(reader);
+ }
+
+ public boolean readBool() throws IOException {
+ try {
+ return readObject(boolean.class);
+ } catch (ClassNotFoundException e) {
+ throw new IOException(e.getMessage());
+ }
+ }
+
+ public byte readByte() throws IOException {
+ try {
+ return readObject(byte.class);
+ } catch (ClassNotFoundException e) {
+ throw new IOException(e.getMessage());
+ }
+ }
+
+ public short readShort() throws IOException {
+ try {
+ return readObject(short.class);
+ } catch (ClassNotFoundException e) {
+ throw new IOException(e.getMessage());
+ }
+ }
+
+ public int readInt() throws IOException {
+ try {
+ return readObject(int.class);
+ } catch (ClassNotFoundException e) {
+ throw new IOException(e.getMessage());
+ }
+ }
+
+ public long readLong() throws IOException {
+ try {
+ return readObject(long.class);
+ } catch (ClassNotFoundException e) {
+ throw new IOException(e.getMessage());
+ }
+ }
+
+ public float readFloat() throws IOException {
+ try {
+ return readObject(float.class);
+ } catch (ClassNotFoundException e) {
+ throw new IOException(e.getMessage());
+ }
+ }
+
+ public double readDouble() throws IOException {
+ try {
+ return readObject(double.class);
+ } catch (ClassNotFoundException e) {
+ throw new IOException(e.getMessage());
+ }
+ }
+
+ public String readUTF() throws IOException {
+ try {
+ return readObject(String.class);
+ } catch (ClassNotFoundException e) {
+ throw new IOException(e.getMessage());
+ }
+ }
+
+ public byte[] readBytes() throws IOException {
+ return readLine().getBytes();
+ }
+
+ public Object readObject() throws IOException, ClassNotFoundException {
+ String json = readLine();
+ return JSON.parse(json);
+ }
+
+ public <T> T readObject(Class<T> cls) throws IOException, ClassNotFoundException {
+ String json = readLine();
+ return JSON.parseObject(json, cls);
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> T readObject(Class<T> cls, Type type) throws IOException, ClassNotFoundException {
+ Object value = readObject(cls);
+ return (T) PojoUtils.realize(value, cls, type);
+ }
+
+ private String readLine() throws IOException, EOFException {
+ String line = reader.readLine();
+ if (line == null || line.trim().length() == 0) throw new EOFException();
+ return line;
+ }
+
}
\ No newline at end of file
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 4048e8a10a..a98911adcf 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
@@ -1,100 +1,100 @@
-/*
- * 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.serialize.support.json;
-
-import com.alibaba.dubbo.common.serialize.ObjectOutput;
-import com.alibaba.fastjson.serializer.JSONSerializer;
-import com.alibaba.fastjson.serializer.SerializeWriter;
-import com.alibaba.fastjson.serializer.SerializerFeature;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
-import java.io.Writer;
-
-/**
- * JsonObjectOutput
- */
-public class FastJsonObjectOutput implements ObjectOutput {
-
- private final PrintWriter writer;
-
- public FastJsonObjectOutput(OutputStream out) {
- this(new OutputStreamWriter(out));
- }
-
- public FastJsonObjectOutput(Writer writer) {
- this.writer = new PrintWriter(writer);
- }
-
- public void writeBool(boolean v) throws IOException {
- writeObject(v);
- }
-
- public void writeByte(byte v) throws IOException {
- writeObject(v);
- }
-
- public void writeShort(short v) throws IOException {
- writeObject(v);
- }
-
- public void writeInt(int v) throws IOException {
- writeObject(v);
- }
-
- public void writeLong(long v) throws IOException {
- writeObject(v);
- }
-
- public void writeFloat(float v) throws IOException {
- writeObject(v);
- }
-
- public void writeDouble(double v) throws IOException {
- writeObject(v);
- }
-
- public void writeUTF(String v) throws IOException {
- writeObject(v);
- }
-
- public void writeBytes(byte[] b) throws IOException {
- writer.println(new String(b));
- }
-
- public void writeBytes(byte[] b, int off, int len) throws IOException {
- writer.println(new String(b, off, len));
- }
-
- public void writeObject(Object obj) throws IOException {
- SerializeWriter out = new SerializeWriter();
- JSONSerializer serializer = new JSONSerializer(out);
- serializer.config(SerializerFeature.WriteEnumUsingToString, true);
- serializer.write(obj);
- out.writeTo(writer);
- out.close(); // for reuse SerializeWriter buf
- writer.println();
- writer.flush();
- }
-
- public void flushBuffer() throws IOException {
- writer.flush();
- }
-
+/*
+ * 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.serialize.support.json;
+
+import com.alibaba.dubbo.common.serialize.ObjectOutput;
+import com.alibaba.fastjson.serializer.JSONSerializer;
+import com.alibaba.fastjson.serializer.SerializeWriter;
+import com.alibaba.fastjson.serializer.SerializerFeature;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.io.Writer;
+
+/**
+ * JsonObjectOutput
+ */
+public class FastJsonObjectOutput implements ObjectOutput {
+
+ private final PrintWriter writer;
+
+ public FastJsonObjectOutput(OutputStream out) {
+ this(new OutputStreamWriter(out));
+ }
+
+ public FastJsonObjectOutput(Writer writer) {
+ this.writer = new PrintWriter(writer);
+ }
+
+ public void writeBool(boolean v) throws IOException {
+ writeObject(v);
+ }
+
+ public void writeByte(byte v) throws IOException {
+ writeObject(v);
+ }
+
+ public void writeShort(short v) throws IOException {
+ writeObject(v);
+ }
+
+ public void writeInt(int v) throws IOException {
+ writeObject(v);
+ }
+
+ public void writeLong(long v) throws IOException {
+ writeObject(v);
+ }
+
+ public void writeFloat(float v) throws IOException {
+ writeObject(v);
+ }
+
+ public void writeDouble(double v) throws IOException {
+ writeObject(v);
+ }
+
+ public void writeUTF(String v) throws IOException {
+ writeObject(v);
+ }
+
+ public void writeBytes(byte[] b) throws IOException {
+ writer.println(new String(b));
+ }
+
+ public void writeBytes(byte[] b, int off, int len) throws IOException {
+ writer.println(new String(b, off, len));
+ }
+
+ public void writeObject(Object obj) throws IOException {
+ SerializeWriter out = new SerializeWriter();
+ JSONSerializer serializer = new JSONSerializer(out);
+ serializer.config(SerializerFeature.WriteEnumUsingToString, true);
+ serializer.write(obj);
+ out.writeTo(writer);
+ out.close(); // for reuse SerializeWriter buf
+ writer.println();
+ writer.flush();
+ }
+
+ public void flushBuffer() throws IOException {
+ writer.flush();
+ }
+
}
\ No newline at end of file
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 7100ccf094..5a840ff5c4 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
@@ -1,49 +1,49 @@
-/*
- * 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.serialize.support.json;
-
-import com.alibaba.dubbo.common.URL;
-import com.alibaba.dubbo.common.serialize.ObjectInput;
-import com.alibaba.dubbo.common.serialize.ObjectOutput;
-import com.alibaba.dubbo.common.serialize.Serialization;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-/**
- * FastJsonSerialization
- */
-public class FastJsonSerialization implements Serialization {
-
- public byte getContentTypeId() {
- return 6;
- }
-
- public String getContentType() {
- return "text/json";
- }
-
- public ObjectOutput serialize(URL url, OutputStream output) throws IOException {
- return new FastJsonObjectOutput(output);
- }
-
- public ObjectInput deserialize(URL url, InputStream input) throws IOException {
- return new FastJsonObjectInput(input);
- }
-
+/*
+ * 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.serialize.support.json;
+
+import com.alibaba.dubbo.common.URL;
+import com.alibaba.dubbo.common.serialize.ObjectInput;
+import com.alibaba.dubbo.common.serialize.ObjectOutput;
+import com.alibaba.dubbo.common.serialize.Serialization;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * FastJsonSerialization
+ */
+public class FastJsonSerialization implements Serialization {
+
+ public byte getContentTypeId() {
+ return 6;
+ }
+
+ public String getContentType() {
+ return "text/json";
+ }
+
+ public ObjectOutput serialize(URL url, OutputStream output) throws IOException {
+ return new FastJsonObjectOutput(output);
+ }
+
+ public ObjectInput deserialize(URL url, InputStream input) throws IOException {
+ return new FastJsonObjectInput(input);
+ }
+
}
\ No newline at end of file
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 3a4a718cb7..b8605a040f 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
@@ -1,156 +1,156 @@
-/*
- * 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.serialize.support.json;
-
-import com.alibaba.dubbo.common.json.JSON;
-import com.alibaba.dubbo.common.json.ParseException;
-import com.alibaba.dubbo.common.serialize.ObjectInput;
-import com.alibaba.dubbo.common.utils.PojoUtils;
-
-import java.io.BufferedReader;
-import java.io.EOFException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.lang.reflect.Type;
-import java.util.Map;
-
-/**
- * JsonObjectInput
- */
-@Deprecated
-public class JsonObjectInput implements ObjectInput {
-
- private final BufferedReader reader;
-
- public JsonObjectInput(InputStream in) {
- this(new InputStreamReader(in));
- }
-
- public JsonObjectInput(Reader reader) {
- this.reader = new BufferedReader(reader);
- }
-
- public boolean readBool() throws IOException {
- try {
- return readObject(boolean.class);
- } catch (ClassNotFoundException e) {
- throw new IOException(e.getMessage());
- }
- }
-
- public byte readByte() throws IOException {
- try {
- return readObject(byte.class);
- } catch (ClassNotFoundException e) {
- throw new IOException(e.getMessage());
- }
- }
-
- public short readShort() throws IOException {
- try {
- return readObject(short.class);
- } catch (ClassNotFoundException e) {
- throw new IOException(e.getMessage());
- }
- }
-
- public int readInt() throws IOException {
- try {
- return readObject(int.class);
- } catch (ClassNotFoundException e) {
- throw new IOException(e.getMessage());
- }
- }
-
- public long readLong() throws IOException {
- try {
- return readObject(long.class);
- } catch (ClassNotFoundException e) {
- throw new IOException(e.getMessage());
- }
- }
-
- public float readFloat() throws IOException {
- try {
- return readObject(float.class);
- } catch (ClassNotFoundException e) {
- throw new IOException(e.getMessage());
- }
- }
-
- public double readDouble() throws IOException {
- try {
- return readObject(double.class);
- } catch (ClassNotFoundException e) {
- throw new IOException(e.getMessage());
- }
- }
-
- public String readUTF() throws IOException {
- try {
- return readObject(String.class);
- } catch (ClassNotFoundException e) {
- throw new IOException(e.getMessage());
- }
- }
-
- public byte[] readBytes() throws IOException {
- return readLine().getBytes();
- }
-
- public Object readObject() throws IOException, ClassNotFoundException {
- try {
- String json = readLine();
- if (json.startsWith("{")) {
- return JSON.parse(json, Map.class);
- } else {
- json = "{\"value\":" + json + "}";
-
- @SuppressWarnings("unchecked")
- Map<String, Object> map = JSON.parse(json, Map.class);
- return map.get("value");
- }
- } catch (ParseException e) {
- throw new IOException(e.getMessage());
- }
- }
-
- @SuppressWarnings("unchecked")
- public <T> T readObject(Class<T> cls) throws IOException, ClassNotFoundException {
- Object value = readObject();
- return (T) PojoUtils.realize(value, cls);
- /*try {
- return JSON.parse(readLine(), cls);
- } catch (ParseException e) {
- throw new IOException(e.getMessage());
- }*/
- }
-
- @SuppressWarnings("unchecked")
- public <T> T readObject(Class<T> cls, Type type) throws IOException, ClassNotFoundException {
- Object value = readObject();
- return (T) PojoUtils.realize(value, cls, type);
- }
-
- private String readLine() throws IOException, EOFException {
- String line = reader.readLine();
- if (line == null || line.trim().length() == 0) throw new EOFException();
- return line;
- }
+/*
+ * 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.serialize.support.json;
+
+import com.alibaba.dubbo.common.json.JSON;
+import com.alibaba.dubbo.common.json.ParseException;
+import com.alibaba.dubbo.common.serialize.ObjectInput;
+import com.alibaba.dubbo.common.utils.PojoUtils;
+
+import java.io.BufferedReader;
+import java.io.EOFException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.lang.reflect.Type;
+import java.util.Map;
+
+/**
+ * JsonObjectInput
+ */
+@Deprecated
+public class JsonObjectInput implements ObjectInput {
+
+ private final BufferedReader reader;
+
+ public JsonObjectInput(InputStream in) {
+ this(new InputStreamReader(in));
+ }
+
+ public JsonObjectInput(Reader reader) {
+ this.reader = new BufferedReader(reader);
+ }
+
+ public boolean readBool() throws IOException {
+ try {
+ return readObject(boolean.class);
+ } catch (ClassNotFoundException e) {
+ throw new IOException(e.getMessage());
+ }
+ }
+
+ public byte readByte() throws IOException {
+ try {
+ return readObject(byte.class);
+ } catch (ClassNotFoundException e) {
+ throw new IOException(e.getMessage());
+ }
+ }
+
+ public short readShort() throws IOException {
+ try {
+ return readObject(short.class);
+ } catch (ClassNotFoundException e) {
+ throw new IOException(e.getMessage());
+ }
+ }
+
+ public int readInt() throws IOException {
+ try {
+ return readObject(int.class);
+ } catch (ClassNotFoundException e) {
+ throw new IOException(e.getMessage());
+ }
+ }
+
+ public long readLong() throws IOException {
+ try {
+ return readObject(long.class);
+ } catch (ClassNotFoundException e) {
+ throw new IOException(e.getMessage());
+ }
+ }
+
+ public float readFloat() throws IOException {
+ try {
+ return readObject(float.class);
+ } catch (ClassNotFoundException e) {
+ throw new IOException(e.getMessage());
+ }
+ }
+
+ public double readDouble() throws IOException {
+ try {
+ return readObject(double.class);
+ } catch (ClassNotFoundException e) {
+ throw new IOException(e.getMessage());
+ }
+ }
+
+ public String readUTF() throws IOException {
+ try {
+ return readObject(String.class);
+ } catch (ClassNotFoundException e) {
+ throw new IOException(e.getMessage());
+ }
+ }
+
+ public byte[] readBytes() throws IOException {
+ return readLine().getBytes();
+ }
+
+ public Object readObject() throws IOException, ClassNotFoundException {
+ try {
+ String json = readLine();
+ if (json.startsWith("{")) {
+ return JSON.parse(json, Map.class);
+ } else {
+ json = "{\"value\":" + json + "}";
+
+ @SuppressWarnings("unchecked")
+ Map<String, Object> map = JSON.parse(json, Map.class);
+ return map.get("value");
+ }
+ } catch (ParseException e) {
+ throw new IOException(e.getMessage());
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> T readObject(Class<T> cls) throws IOException, ClassNotFoundException {
+ Object value = readObject();
+ return (T) PojoUtils.realize(value, cls);
+ /*try {
+ return JSON.parse(readLine(), cls);
+ } catch (ParseException e) {
+ throw new IOException(e.getMessage());
+ }*/
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> T readObject(Class<T> cls, Type type) throws IOException, ClassNotFoundException {
+ Object value = readObject();
+ return (T) PojoUtils.realize(value, cls, type);
+ }
+
+ private String readLine() throws IOException, EOFException {
+ String line = reader.readLine();
+ if (line == null || line.trim().length() == 0) throw new EOFException();
+ return line;
+ }
}
\ No newline at end of file
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 491f173d5a..efcf5b4c82 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
@@ -1,105 +1,105 @@
-/*
- * 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.serialize.support.json;
-
-import com.alibaba.dubbo.common.json.JSON;
-import com.alibaba.dubbo.common.serialize.ObjectOutput;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
-import java.io.Writer;
-
-/**
- * JsonObjectOutput
- */
-@Deprecated
-public class JsonObjectOutput implements ObjectOutput {
-
- private final PrintWriter writer;
-
- private final boolean writeClass;
-
- public JsonObjectOutput(OutputStream out) {
- this(new OutputStreamWriter(out), false);
- }
-
- public JsonObjectOutput(Writer writer) {
- this(writer, false);
- }
-
- public JsonObjectOutput(OutputStream out, boolean writeClass) {
- this(new OutputStreamWriter(out), writeClass);
- }
-
- public JsonObjectOutput(Writer writer, boolean writeClass) {
- this.writer = new PrintWriter(writer);
- this.writeClass = writeClass;
- }
-
- public void writeBool(boolean v) throws IOException {
- writeObject(v);
- }
-
- public void writeByte(byte v) throws IOException {
- writeObject(v);
- }
-
- public void writeShort(short v) throws IOException {
- writeObject(v);
- }
-
- public void writeInt(int v) throws IOException {
- writeObject(v);
- }
-
- public void writeLong(long v) throws IOException {
- writeObject(v);
- }
-
- public void writeFloat(float v) throws IOException {
- writeObject(v);
- }
-
- public void writeDouble(double v) throws IOException {
- writeObject(v);
- }
-
- public void writeUTF(String v) throws IOException {
- writeObject(v);
- }
-
- public void writeBytes(byte[] b) throws IOException {
- writer.println(new String(b));
- }
-
- public void writeBytes(byte[] b, int off, int len) throws IOException {
- writer.println(new String(b, off, len));
- }
-
- public void writeObject(Object obj) throws IOException {
- JSON.json(obj, writer, writeClass);
- writer.println();
- writer.flush();
- }
-
- public void flushBuffer() throws IOException {
- writer.flush();
- }
-
+/*
+ * 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.serialize.support.json;
+
+import com.alibaba.dubbo.common.json.JSON;
+import com.alibaba.dubbo.common.serialize.ObjectOutput;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.io.Writer;
+
+/**
+ * JsonObjectOutput
+ */
+@Deprecated
+public class JsonObjectOutput implements ObjectOutput {
+
+ private final PrintWriter writer;
+
+ private final boolean writeClass;
+
+ public JsonObjectOutput(OutputStream out) {
+ this(new OutputStreamWriter(out), false);
+ }
+
+ public JsonObjectOutput(Writer writer) {
+ this(writer, false);
+ }
+
+ public JsonObjectOutput(OutputStream out, boolean writeClass) {
+ this(new OutputStreamWriter(out), writeClass);
+ }
+
+ public JsonObjectOutput(Writer writer, boolean writeClass) {
+ this.writer = new PrintWriter(writer);
+ this.writeClass = writeClass;
+ }
+
+ public void writeBool(boolean v) throws IOException {
+ writeObject(v);
+ }
+
+ public void writeByte(byte v) throws IOException {
+ writeObject(v);
+ }
+
+ public void writeShort(short v) throws IOException {
+ writeObject(v);
+ }
+
+ public void writeInt(int v) throws IOException {
+ writeObject(v);
+ }
+
+ public void writeLong(long v) throws IOException {
+ writeObject(v);
+ }
+
+ public void writeFloat(float v) throws IOException {
+ writeObject(v);
+ }
+
+ public void writeDouble(double v) throws IOException {
+ writeObject(v);
+ }
+
+ public void writeUTF(String v) throws IOException {
+ writeObject(v);
+ }
+
+ public void writeBytes(byte[] b) throws IOException {
+ writer.println(new String(b));
+ }
+
+ public void writeBytes(byte[] b, int off, int len) throws IOException {
+ writer.println(new String(b, off, len));
+ }
+
+ public void writeObject(Object obj) throws IOException {
+ JSON.json(obj, writer, writeClass);
+ writer.println();
+ writer.flush();
+ }
+
+ public void flushBuffer() throws IOException {
+ writer.flush();
+ }
+
}
\ No newline at end of file
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 488786961b..0dfb604221 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
@@ -1,50 +1,50 @@
-/*
- * 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.serialize.support.json;
-
-import com.alibaba.dubbo.common.URL;
-import com.alibaba.dubbo.common.serialize.ObjectInput;
-import com.alibaba.dubbo.common.serialize.ObjectOutput;
-import com.alibaba.dubbo.common.serialize.Serialization;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-/**
- * JsonSerialization
- */
-@Deprecated
-public class JsonSerialization implements Serialization {
-
- public byte getContentTypeId() {
- return 5;
- }
-
- public String getContentType() {
- return "text/json";
- }
-
- public ObjectOutput serialize(URL url, OutputStream output) throws IOException {
- return new JsonObjectOutput(output, url.getParameter("with.class", true));
- }
-
- public ObjectInput deserialize(URL url, InputStream input) throws IOException {
- return new JsonObjectInput(input);
- }
-
+/*
+ * 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.serialize.support.json;
+
+import com.alibaba.dubbo.common.URL;
+import com.alibaba.dubbo.common.serialize.ObjectInput;
+import com.alibaba.dubbo.common.serialize.ObjectOutput;
+import com.alibaba.dubbo.common.serialize.Serialization;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * JsonSerialization
+ */
+@Deprecated
+public class JsonSerialization implements Serialization {
+
+ public byte getContentTypeId() {
+ return 5;
+ }
+
+ public String getContentType() {
+ return "text/json";
+ }
+
+ public ObjectOutput serialize(URL url, OutputStream output) throws IOException {
+ return new JsonObjectOutput(output, url.getParameter("with.class", true));
+ }
+
+ public ObjectInput deserialize(URL url, InputStream input) throws IOException {
+ return new JsonObjectInput(input);
+ }
+
}
\ No newline at end of file
diff --git a/dubbo-common/src/main/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.serialize.Serialization b/dubbo-common/src/main/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.serialize.Serialization
index 01fb303512..edcfc652f5 100644
--- a/dubbo-common/src/main/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.serialize.Serialization
+++ b/dubbo-common/src/main/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.serialize.Serialization
@@ -1,6 +1,6 @@
-dubbo=com.alibaba.dubbo.common.serialize.support.dubbo.DubboSerialization
-hessian2=com.alibaba.dubbo.common.serialize.support.hessian.Hessian2Serialization
-java=com.alibaba.dubbo.common.serialize.support.java.JavaSerialization
-compactedjava=com.alibaba.dubbo.common.serialize.support.java.CompactedJavaSerialization
-fastjson=com.alibaba.dubbo.common.serialize.support.json.FastJsonSerialization
+dubbo=com.alibaba.dubbo.common.serialize.support.dubbo.DubboSerialization
+hessian2=com.alibaba.dubbo.common.serialize.support.hessian.Hessian2Serialization
+java=com.alibaba.dubbo.common.serialize.support.java.JavaSerialization
+compactedjava=com.alibaba.dubbo.common.serialize.support.java.CompactedJavaSerialization
+fastjson=com.alibaba.dubbo.common.serialize.support.json.FastJsonSerialization
nativejava=com.alibaba.dubbo.common.serialize.support.nativejava.NativeJavaSerialization
\ No newline at end of file
diff --git a/dubbo-common/src/test/java/com/alibaba/dubbo/common/serialize/serialization/CompactedJavaSerializationTest.java b/dubbo-common/src/test/java/com/alibaba/dubbo/common/serialize/serialization/CompactedJavaSerializationTest.java
index e1127f5952..8700dec163 100644
--- a/dubbo-common/src/test/java/com/alibaba/dubbo/common/serialize/serialization/CompactedJavaSerializationTest.java
+++ b/dubbo-common/src/test/java/com/alibaba/dubbo/common/serialize/serialization/CompactedJavaSerializationTest.java
@@ -1,25 +1,25 @@
-/*
- * 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.serialize.serialization;
-
-import com.alibaba.dubbo.common.serialize.support.java.CompactedJavaSerialization;
-
-public class CompactedJavaSerializationTest extends AbstractSerializationPersionFailTest {
- {
- serialization = new CompactedJavaSerialization();
- }
+/*
+ * 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.serialize.serialization;
+
+import com.alibaba.dubbo.common.serialize.support.java.CompactedJavaSerialization;
+
+public class CompactedJavaSerializationTest extends AbstractSerializationPersionFailTest {
+ {
+ serialization = new CompactedJavaSerialization();
+ }
}
\ No newline at end of file
diff --git a/dubbo-common/src/test/java/com/alibaba/dubbo/common/serialize/serialization/JavaSerializationTest.java b/dubbo-common/src/test/java/com/alibaba/dubbo/common/serialize/serialization/JavaSerializationTest.java
index 96b7fefccb..e125993feb 100644
--- a/dubbo-common/src/test/java/com/alibaba/dubbo/common/serialize/serialization/JavaSerializationTest.java
+++ b/dubbo-common/src/test/java/com/alibaba/dubbo/common/serialize/serialization/JavaSerializationTest.java
@@ -1,25 +1,25 @@
-/*
- * 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.serialize.serialization;
-
-import com.alibaba.dubbo.common.serialize.support.java.JavaSerialization;
-
-public class JavaSerializationTest extends AbstractSerializationPersionFailTest {
- {
- serialization = new JavaSerialization();
- }
+/*
+ * 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.serialize.serialization;
+
+import com.alibaba.dubbo.common.serialize.support.java.JavaSerialization;
+
+public class JavaSerializationTest extends AbstractSerializationPersionFailTest {
+ {
+ serialization = new JavaSerialization();
+ }
}
\ No newline at end of file
diff --git a/dubbo-config/dubbo-config-api/pom.xml b/dubbo-config/dubbo-config-api/pom.xml
index e3467ff6c6..9aebc38730 100644
--- a/dubbo-config/dubbo-config-api/pom.xml
+++ b/dubbo-config/dubbo-config-api/pom.xml
@@ -20,7 +20,7 @@ limitations under the License.
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-config</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>dubbo-config-api</artifactId>
<packaging>jar</packaging>
diff --git a/dubbo-config/dubbo-config-spring/pom.xml b/dubbo-config/dubbo-config-spring/pom.xml
index 7687ceb46c..717c8083a9 100644
--- a/dubbo-config/dubbo-config-spring/pom.xml
+++ b/dubbo-config/dubbo-config-spring/pom.xml
@@ -20,7 +20,7 @@ limitations under the License.
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-config</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>dubbo-config-spring</artifactId>
<packaging>jar</packaging>
diff --git a/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/beans/factory/annotation/AnnotationPropertyValuesAdapter.java b/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/beans/factory/annotation/AnnotationPropertyValuesAdapter.java
new file mode 100644
index 0000000000..751399f849
--- /dev/null
+++ b/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/beans/factory/annotation/AnnotationPropertyValuesAdapter.java
@@ -0,0 +1,92 @@
+/*
+ * 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.config.spring.beans.factory.annotation;
+
+import org.springframework.beans.MutablePropertyValues;
+import org.springframework.beans.PropertyValue;
+import org.springframework.beans.PropertyValues;
+import org.springframework.core.env.PropertyResolver;
+
+import java.lang.annotation.Annotation;
+
+import static com.alibaba.dubbo.config.spring.util.AnnotationUtils.getAttributes;
+
+/**
+ * {@link Annotation} {@link PropertyValues} Adapter
+ *
+ * @see Annotation
+ * @see PropertyValues
+ * @since 2.5.11
+ */
+class AnnotationPropertyValuesAdapter implements PropertyValues {
+
+ private final Annotation annotation;
+
+ private final PropertyResolver propertyResolver;
+
+ private final boolean ignoreDefaultValue;
+
+ private final PropertyValues delegate;
+
+ public AnnotationPropertyValuesAdapter(Annotation annotation, PropertyResolver propertyResolver, boolean ignoreDefaultValue, String... ignoreAttributeNames) {
+ this.annotation = annotation;
+ this.propertyResolver = propertyResolver;
+ this.ignoreDefaultValue = ignoreDefaultValue;
+ this.delegate = adapt(annotation, ignoreDefaultValue, ignoreAttributeNames);
+ }
+
+ public AnnotationPropertyValuesAdapter(Annotation annotation, PropertyResolver propertyResolver, String... ignoreAttributeNames) {
+ this(annotation, propertyResolver, true, ignoreAttributeNames);
+ }
+
+ private PropertyValues adapt(Annotation annotation, boolean ignoreDefaultValue, String... ignoreAttributeNames) {
+ return new MutablePropertyValues(getAttributes(annotation, propertyResolver, ignoreDefaultValue, ignoreAttributeNames));
+ }
+
+ public Annotation getAnnotation() {
+ return annotation;
+ }
+
+ public boolean isIgnoreDefaultValue() {
+ return ignoreDefaultValue;
+ }
+
+ @Override
+ public PropertyValue[] getPropertyValues() {
+ return delegate.getPropertyValues();
+ }
+
+ @Override
+ public PropertyValue getPropertyValue(String propertyName) {
+ return delegate.getPropertyValue(propertyName);
+ }
+
+ @Override
+ public PropertyValues changesSince(PropertyValues old) {
+ return delegate.changesSince(old);
+ }
+
+ @Override
+ public boolean contains(String propertyName) {
+ return delegate.contains(propertyName);
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return delegate.isEmpty();
+ }
+}
diff --git a/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/beans/factory/annotation/DubboConfigBindingBeanPostProcessor.java b/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/beans/factory/annotation/DubboConfigBindingBeanPostProcessor.java
index 6899ad42fc..6248ed32ff 100644
--- a/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/beans/factory/annotation/DubboConfigBindingBeanPostProcessor.java
+++ b/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/beans/factory/annotation/DubboConfigBindingBeanPostProcessor.java
@@ -17,13 +17,25 @@
package com.alibaba.dubbo.config.spring.beans.factory.annotation;
import com.alibaba.dubbo.common.utils.Assert;
+import com.alibaba.dubbo.config.AbstractConfig;
import com.alibaba.dubbo.config.spring.context.annotation.DubboConfigBindingRegistrar;
import com.alibaba.dubbo.config.spring.context.annotation.EnableDubboConfigBinding;
+import com.alibaba.dubbo.config.spring.context.properties.DefaultDubboConfigBinder;
+import com.alibaba.dubbo.config.spring.context.properties.DubboConfigBinder;
+import com.alibaba.dubbo.config.spring.util.BeanFactoryUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.PropertyValues;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.BeanPostProcessor;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.context.EnvironmentAware;
+import org.springframework.core.env.Environment;
import org.springframework.validation.DataBinder;
import java.util.Arrays;
@@ -35,43 +47,52 @@
* @see DubboConfigBindingRegistrar
* @since 2.5.8
*/
-public class DubboConfigBindingBeanPostProcessor implements BeanPostProcessor {
+
+public class DubboConfigBindingBeanPostProcessor implements BeanPostProcessor, ApplicationContextAware, InitializingBean {
private final Log log = LogFactory.getLog(getClass());
/**
- * Binding Bean Name
+ * The prefix of Configuration Properties
*/
- private final String beanName;
+ private final String prefix;
/**
- * Binding {@link PropertyValues}
+ * Binding Bean Name
*/
- private final PropertyValues propertyValues;
+ private final String beanName;
+ private DubboConfigBinder dubboConfigBinder;
+
+ private ApplicationContext applicationContext;
+
+ private boolean ignoreUnknownFields = true;
+
+ private boolean ignoreInvalidFields = true;
/**
- * @param beanName Binding Bean Name
- * @param propertyValues {@link PropertyValues}
+ * @param prefix the prefix of Configuration Properties
+ * @param beanName the binding Bean Name
*/
- public DubboConfigBindingBeanPostProcessor(String beanName, PropertyValues propertyValues) {
+ public DubboConfigBindingBeanPostProcessor(String prefix, String beanName) {
+ Assert.notNull(prefix, "The prefix of Configuration Properties must not be null");
Assert.notNull(beanName, "The name of bean must not be null");
- Assert.notNull(propertyValues, "The PropertyValues of bean must not be null");
+ this.prefix = prefix;
this.beanName = beanName;
- this.propertyValues = propertyValues;
}
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
- if (beanName.equals(this.beanName)) {
- DataBinder dataBinder = new DataBinder(bean);
- // TODO ignore invalid fields by annotation attribute
- dataBinder.setIgnoreInvalidFields(true);
- dataBinder.bind(propertyValues);
+ if (beanName.equals(this.beanName) && bean instanceof AbstractConfig) {
+
+ AbstractConfig dubboConfig = (AbstractConfig) bean;
+
+ dubboConfigBinder.bind(prefix, dubboConfig);
+
if (log.isInfoEnabled()) {
- log.info("The properties of bean [name : " + beanName + "] have been binding by values : "
- + Arrays.asList(propertyValues.getPropertyValues()));
+ log.info("The properties of bean [name : " + beanName + "] have been binding by prefix of " +
+ "configuration properties : " + prefix);
}
}
@@ -79,10 +100,70 @@ public Object postProcessBeforeInitialization(Object bean, String beanName) thro
}
+ public boolean isIgnoreUnknownFields() {
+ return ignoreUnknownFields;
+ }
+
+ public void setIgnoreUnknownFields(boolean ignoreUnknownFields) {
+ this.ignoreUnknownFields = ignoreUnknownFields;
+ }
+
+ public boolean isIgnoreInvalidFields() {
+ return ignoreInvalidFields;
+ }
+
+ public void setIgnoreInvalidFields(boolean ignoreInvalidFields) {
+ this.ignoreInvalidFields = ignoreInvalidFields;
+ }
+
+ public DubboConfigBinder getDubboConfigBinder() {
+ return dubboConfigBinder;
+ }
+
+ public void setDubboConfigBinder(DubboConfigBinder dubboConfigBinder) {
+ this.dubboConfigBinder = dubboConfigBinder;
+ }
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
return bean;
}
+ @Override
+ public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+ this.applicationContext = applicationContext;
+ }
+
+ @Override
+ public void afterPropertiesSet() throws Exception {
+
+ if (dubboConfigBinder == null) {
+ try {
+ dubboConfigBinder = applicationContext.getBean(DubboConfigBinder.class);
+ } catch (BeansException ignored) {
+ if (log.isDebugEnabled()) {
+ log.debug("DubboConfigBinder Bean can't be found in ApplicationContext.");
+ }
+ // Use Default implementation
+ dubboConfigBinder = createDubboConfigBinder(applicationContext.getEnvironment());
+ }
+ }
+
+ dubboConfigBinder.setIgnoreUnknownFields(ignoreUnknownFields);
+ dubboConfigBinder.setIgnoreInvalidFields(ignoreInvalidFields);
+
+ }
+
+ /**
+ * Create {@link DubboConfigBinder} instance.
+ *
+ * @param environment
+ * @return {@link DefaultDubboConfigBinder}
+ */
+ protected DubboConfigBinder createDubboConfigBinder(Environment environment) {
+ DefaultDubboConfigBinder defaultDubboConfigBinder = new DefaultDubboConfigBinder();
+ defaultDubboConfigBinder.setEnvironment(environment);
+ return defaultDubboConfigBinder;
+ }
+
}
diff --git a/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/beans/factory/annotation/ReferenceAnnotationBeanPostProcessor.java b/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/beans/factory/annotation/ReferenceAnnotationBeanPostProcessor.java
index d8411de364..31478f6cff 100644
--- a/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/beans/factory/annotation/ReferenceAnnotationBeanPostProcessor.java
+++ b/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/beans/factory/annotation/ReferenceAnnotationBeanPostProcessor.java
@@ -33,6 +33,7 @@
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.core.PriorityOrdered;
+import org.springframework.core.env.Environment;
import org.springframework.util.ClassUtils;
import org.springframework.util.ReflectionUtils;
import org.springframework.util.StringUtils;
@@ -41,9 +42,7 @@
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.List;
+import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
@@ -73,8 +72,8 @@
private ClassLoader classLoader;
- private final ConcurrentMap<String, InjectionMetadata> injectionMetadataCache =
- new ConcurrentHashMap<String, InjectionMetadata>(256);
+ private final ConcurrentMap<String, ReferenceInjectionMetadata> injectionMetadataCache =
+ new ConcurrentHashMap<String, ReferenceInjectionMetadata>(256);
private final ConcurrentMap<String, ReferenceBean<?>> referenceBeansCache =
new ConcurrentHashMap<String, ReferenceBean<?>>();
@@ -101,9 +100,9 @@ public PropertyValues postProcessPropertyValues(
* @param beanClass The {@link Class} of Bean
* @return non-null {@link List}
*/
- private List<InjectionMetadata.InjectedElement> findFieldReferenceMetadata(final Class<?> beanClass) {
+ private List<ReferenceFieldElement> findFieldReferenceMetadata(final Class<?> beanClass) {
- final List<InjectionMetadata.InjectedElement> elements = new LinkedList<InjectionMetadata.InjectedElement>();
+ final List<ReferenceFieldElement> elements = new LinkedList<ReferenceFieldElement>();
ReflectionUtils.doWithFields(beanClass, new ReflectionUtils.FieldCallback() {
@Override
@@ -136,9 +135,9 @@ public void doWith(Field field) throws IllegalArgumentException, IllegalAccessEx
* @param beanClass The {@link Class} of Bean
* @return non-null {@link List}
*/
- private List<InjectionMetadata.InjectedElement> findMethodReferenceMetadata(final Class<?> beanClass) {
+ private List<ReferenceMethodElement> findMethodReferenceMetadata(final Class<?> beanClass) {
- final List<InjectionMetadata.InjectedElement> elements = new LinkedList<InjectionMetadata.InjectedElement>();
+ final List<ReferenceMethodElement> elements = new LinkedList<ReferenceMethodElement>();
ReflectionUtils.doWithMethods(beanClass, new ReflectionUtils.MethodCallback() {
@Override
@@ -180,15 +179,10 @@ public void doWith(Method method) throws IllegalArgumentException, IllegalAccess
* @param beanClass
* @return
*/
- private InjectionMetadata buildReferenceMetadata(final Class<?> beanClass) {
-
- final List<InjectionMetadata.InjectedElement> elements = new LinkedList<InjectionMetadata.InjectedElement>();
-
- elements.addAll(findFieldReferenceMetadata(beanClass));
-
- elements.addAll(findMethodReferenceMetadata(beanClass));
-
- return new InjectionMetadata(beanClass, elements);
+ private ReferenceInjectionMetadata buildReferenceMetadata(final Class<?> beanClass) {
+ Collection<ReferenceFieldElement> fieldElements = findFieldReferenceMetadata(beanClass);
+ Collection<ReferenceMethodElement> methodElements = findMethodReferenceMetadata(beanClass);
+ return new ReferenceInjectionMetadata(beanClass, fieldElements, methodElements);
}
@@ -196,7 +190,7 @@ private InjectionMetadata findReferenceMetadata(String beanName, Class<?> clazz,
// Fall back to class name as cache key, for backwards compatibility with custom callers.
String cacheKey = (StringUtils.hasLength(beanName) ? beanName : clazz.getName());
// Quick check on the concurrent map first, with minimal locking.
- InjectionMetadata metadata = this.injectionMetadataCache.get(cacheKey);
+ ReferenceInjectionMetadata metadata = this.injectionMetadataCache.get(cacheKey);
if (InjectionMetadata.needsRefresh(metadata, clazz)) {
synchronized (this.injectionMetadataCache) {
metadata = this.injectionMetadataCache.get(cacheKey);
@@ -270,6 +264,43 @@ public void setBeanClassLoader(ClassLoader classLoader) {
return this.referenceBeansCache.values();
}
+
+ /**
+ * {@link Reference} {@link InjectionMetadata} implementation
+ *
+ * @since 2.5.11
+ */
+ private static class ReferenceInjectionMetadata extends InjectionMetadata {
+
+ private final Collection<ReferenceFieldElement> fieldElements;
+
+ private final Collection<ReferenceMethodElement> methodElements;
+
+
+ public ReferenceInjectionMetadata(Class<?> targetClass, Collection<ReferenceFieldElement> fieldElements,
+ Collection<ReferenceMethodElement> methodElements) {
+ super(targetClass, combine(fieldElements, methodElements));
+ this.fieldElements = fieldElements;
+ this.methodElements = methodElements;
+ }
+
+ private static <T> Collection<T> combine(Collection<? extends T>... elements) {
+ List<T> allElements = new ArrayList<T>();
+ for (Collection<? extends T> e : elements) {
+ allElements.addAll(e);
+ }
+ return allElements;
+ }
+
+ public Collection<ReferenceFieldElement> getFieldElements() {
+ return fieldElements;
+ }
+
+ public Collection<ReferenceMethodElement> getMethodElements() {
+ return methodElements;
+ }
+ }
+
/**
* {@link Reference} {@link Method} {@link InjectionMetadata.InjectedElement}
*/
@@ -279,6 +310,8 @@ public void setBeanClassLoader(ClassLoader classLoader) {
private final Reference reference;
+ private volatile ReferenceBean<?> referenceBean;
+
protected ReferenceMethodElement(Method method, PropertyDescriptor pd, Reference reference) {
super(method, pd);
this.method = method;
@@ -290,11 +323,11 @@ protected void inject(Object bean, String beanName, PropertyValues pvs) throws T
Class<?> referenceClass = pd.getPropertyType();
- Object referenceBean = buildReferenceBean(reference, referenceClass);
+ referenceBean = buildReferenceBean(reference, referenceClass);
ReflectionUtils.makeAccessible(method);
- method.invoke(bean, referenceBean);
+ method.invoke(bean, referenceBean.getObject());
}
@@ -309,6 +342,8 @@ protected void inject(Object bean, String beanName, PropertyValues pvs) throws T
private final Reference reference;
+ private volatile ReferenceBean<?> referenceBean;
+
protected ReferenceFieldElement(Field field, Reference reference) {
super(field, null);
this.field = field;
@@ -320,17 +355,17 @@ protected void inject(Object bean, String beanName, PropertyValues pvs) throws T
Class<?> referenceClass = field.getType();
- Object referenceBean = buildReferenceBean(reference, referenceClass);
+ referenceBean = buildReferenceBean(reference, referenceClass);
ReflectionUtils.makeAccessible(field);
- field.set(bean, referenceBean);
+ field.set(bean, referenceBean.getObject());
}
}
- private Object buildReferenceBean(Reference reference, Class<?> referenceClass) throws Exception {
+ private ReferenceBean<?> buildReferenceBean(Reference reference, Class<?> referenceClass) throws Exception {
String referenceBeanCacheKey = generateReferenceBeanCacheKey(reference, referenceClass);
@@ -348,8 +383,8 @@ private Object buildReferenceBean(Reference reference, Class<?> referenceClass)
}
+ return referenceBean;
- return referenceBean.get();
}
@@ -360,11 +395,17 @@ private Object buildReferenceBean(Reference reference, Class<?> referenceClass)
* @param beanClass {@link Class}
* @return
*/
- private static String generateReferenceBeanCacheKey(Reference reference, Class<?> beanClass) {
+ private String generateReferenceBeanCacheKey(Reference reference, Class<?> beanClass) {
String interfaceName = resolveInterfaceName(reference, beanClass);
- String key = reference.group() + "/" + interfaceName + ":" + reference.version();
+ String key = reference.url() + "/" + interfaceName +
+ "/" + reference.version() +
+ "/" + reference.group();
+
+ Environment environment = applicationContext.getEnvironment();
+
+ key = environment.resolvePlaceholders(key);
return key;
@@ -390,4 +431,70 @@ private static String resolveInterfaceName(Reference reference, Class<?> beanCla
}
+
+ /**
+ * Get {@link ReferenceBean} {@link Map} in injected field.
+ *
+ * @return non-null {@link Map}
+ * @since 2.5.11
+ */
+ public Map<InjectionMetadata.InjectedElement, ReferenceBean<?>> getInjectedFieldReferenceBeanMap() {
+
+ Map<InjectionMetadata.InjectedElement, ReferenceBean<?>> injectedElementReferenceBeanMap =
+ new LinkedHashMap<InjectionMetadata.InjectedElement, ReferenceBean<?>>();
+
+ for (ReferenceInjectionMetadata metadata : injectionMetadataCache.values()) {
+
+ Collection<ReferenceFieldElement> fieldElements = metadata.getFieldElements();
+
+ for (ReferenceFieldElement fieldElement : fieldElements) {
+
+ injectedElementReferenceBeanMap.put(fieldElement, fieldElement.referenceBean);
+
+ }
+
+ }
+
+ return injectedElementReferenceBeanMap;
+
+ }
+
+ /**
+ * Get {@link ReferenceBean} {@link Map} in injected method.
+ *
+ * @return non-null {@link Map}
+ * @since 2.5.11
+ */
+ public Map<InjectionMetadata.InjectedElement, ReferenceBean<?>> getInjectedMethodReferenceBeanMap() {
+
+ Map<InjectionMetadata.InjectedElement, ReferenceBean<?>> injectedElementReferenceBeanMap =
+ new LinkedHashMap<InjectionMetadata.InjectedElement, ReferenceBean<?>>();
+
+ for (ReferenceInjectionMetadata metadata : injectionMetadataCache.values()) {
+
+ Collection<ReferenceMethodElement> methodElements = metadata.getMethodElements();
+
+ for (ReferenceMethodElement methodElement : methodElements) {
+
+ injectedElementReferenceBeanMap.put(methodElement, methodElement.referenceBean);
+
+ }
+
+ }
+
+ return injectedElementReferenceBeanMap;
+
+ }
+
+ private <T> T getFieldValue(Object object, String fieldName, Class<T> fieldType) {
+
+ Field field = ReflectionUtils.findField(object.getClass(), fieldName, fieldType);
+
+ ReflectionUtils.makeAccessible(field);
+
+ return (T) ReflectionUtils.getField(field, object);
+
+ }
+
+
}
diff --git a/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/beans/factory/annotation/ReferenceBeanBuilder.java b/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/beans/factory/annotation/ReferenceBeanBuilder.java
index d2cc56d2bf..5d9418fbc8 100644
--- a/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/beans/factory/annotation/ReferenceBeanBuilder.java
+++ b/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/beans/factory/annotation/ReferenceBeanBuilder.java
@@ -19,12 +19,18 @@
import com.alibaba.dubbo.config.ConsumerConfig;
import com.alibaba.dubbo.config.annotation.Reference;
import com.alibaba.dubbo.config.spring.ReferenceBean;
+import com.alibaba.dubbo.config.spring.convert.converter.StringArrayToMapConverter;
+import com.alibaba.dubbo.config.spring.convert.converter.StringArrayToStringConverter;
import org.springframework.context.ApplicationContext;
+import org.springframework.core.convert.ConversionService;
+import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
+import org.springframework.validation.DataBinder;
import static com.alibaba.dubbo.config.spring.util.BeanFactoryUtils.getOptionalBean;
+import static com.alibaba.dubbo.config.spring.util.ObjectUtils.of;
/**
* {@link ReferenceBean} Builder
@@ -80,14 +86,30 @@ private void configureConsumerConfig(Reference reference, ReferenceBean<?> refer
@Override
protected ReferenceBean doBuild() {
- return new ReferenceBean<Object>(annotation);
+ return new ReferenceBean<Object>();
}
@Override
- protected void preConfigureBean(Reference annotation, ReferenceBean bean) {
+ protected void preConfigureBean(Reference reference, ReferenceBean referenceBean) {
Assert.notNull(interfaceClass, "The interface class must set first!");
+ DataBinder dataBinder = new DataBinder(referenceBean);
+ // Set ConversionService
+ dataBinder.setConversionService(getConversionService());
+ // Ignore those fields
+ String[] ignoreAttributeNames = of("application", "module", "consumer", "monitor", "registry");
+// dataBinder.setDisallowedFields(ignoreAttributeNames);
+ // Bind annotation attributes
+ dataBinder.bind(new AnnotationPropertyValuesAdapter(reference, applicationContext.getEnvironment(), ignoreAttributeNames));
}
+ private ConversionService getConversionService() {
+ DefaultConversionService conversionService = new DefaultConversionService();
+ conversionService.addConverter(new StringArrayToStringConverter());
+ conversionService.addConverter(new StringArrayToMapConverter());
+ return conversionService;
+ }
+
+
@Override
protected String resolveModuleConfigBeanName(Reference annotation) {
return annotation.module();
diff --git a/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/beans/factory/annotation/ServiceAnnotationBeanPostProcessor.java b/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/beans/factory/annotation/ServiceAnnotationBeanPostProcessor.java
index 1d273451bf..207b3f7d03 100644
--- a/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/beans/factory/annotation/ServiceAnnotationBeanPostProcessor.java
+++ b/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/beans/factory/annotation/ServiceAnnotationBeanPostProcessor.java
@@ -21,20 +21,11 @@
import com.alibaba.dubbo.config.annotation.Service;
import com.alibaba.dubbo.config.spring.ServiceBean;
import com.alibaba.dubbo.config.spring.context.annotation.DubboClassPathBeanDefinitionScanner;
-
import org.springframework.beans.BeansException;
+import org.springframework.beans.MutablePropertyValues;
import org.springframework.beans.factory.BeanClassLoaderAware;
-import org.springframework.beans.factory.config.BeanDefinition;
-import org.springframework.beans.factory.config.BeanDefinitionHolder;
-import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
-import org.springframework.beans.factory.config.RuntimeBeanReference;
-import org.springframework.beans.factory.config.SingletonBeanRegistry;
-import org.springframework.beans.factory.support.AbstractBeanDefinition;
-import org.springframework.beans.factory.support.BeanDefinitionBuilder;
-import org.springframework.beans.factory.support.BeanDefinitionRegistry;
-import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
-import org.springframework.beans.factory.support.BeanNameGenerator;
-import org.springframework.beans.factory.support.ManagedList;
+import org.springframework.beans.factory.config.*;
+import org.springframework.beans.factory.support.*;
import org.springframework.context.EnvironmentAware;
import org.springframework.context.ResourceLoaderAware;
import org.springframework.context.annotation.AnnotationBeanNameGenerator;
@@ -44,18 +35,11 @@
import org.springframework.core.env.Environment;
import org.springframework.core.io.ResourceLoader;
import org.springframework.core.type.filter.AnnotationTypeFilter;
-import org.springframework.util.Assert;
-import org.springframework.util.ClassUtils;
-import org.springframework.util.CollectionUtils;
-import org.springframework.util.ObjectUtils;
-import org.springframework.util.StringUtils;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Set;
+import org.springframework.util.*;
+
+import java.util.*;
+import static com.alibaba.dubbo.config.spring.util.ObjectUtils.of;
import static org.springframework.beans.factory.support.BeanDefinitionBuilder.rootBeanDefinition;
import static org.springframework.context.annotation.AnnotationConfigUtils.CONFIGURATION_BEAN_NAME_GENERATOR;
import static org.springframework.core.annotation.AnnotationUtils.findAnnotation;
@@ -356,11 +340,20 @@ private String generateServiceBeanName(Class<?> interfaceClass, String annotated
private AbstractBeanDefinition buildServiceBeanDefinition(Service service, Class<?> interfaceClass,
String annotatedServiceBeanName) {
- BeanDefinitionBuilder builder = rootBeanDefinition(ServiceBean.class)
- .addConstructorArgValue(service)
- // References "ref" property to annotated-@Service Bean
- .addPropertyReference("ref", annotatedServiceBeanName)
- .addPropertyValue("interface", interfaceClass.getName());
+ BeanDefinitionBuilder builder = rootBeanDefinition(ServiceBean.class);
+
+ AbstractBeanDefinition beanDefinition = builder.getBeanDefinition();
+
+ MutablePropertyValues propertyValues = beanDefinition.getPropertyValues();
+
+ String[] ignoreAttributeNames = of("provider", "monitor", "application", "module", "registry", "protocol", "interface");
+
+ propertyValues.addPropertyValues(new AnnotationPropertyValuesAdapter(service, environment, ignoreAttributeNames));
+
+ // References "ref" property to annotated-@Service Bean
+ addPropertyReference(builder, "ref", annotatedServiceBeanName);
+ // Set interface
+ builder.addPropertyValue("interface", interfaceClass.getName());
/**
* Add {@link com.alibaba.dubbo.config.ProviderConfig} Bean reference
diff --git a/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/context/annotation/DubboConfigBindingRegistrar.java b/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/context/annotation/DubboConfigBindingRegistrar.java
index cd9cadd3e7..452d9d3a23 100644
--- a/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/context/annotation/DubboConfigBindingRegistrar.java
+++ b/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/context/annotation/DubboConfigBindingRegistrar.java
@@ -20,8 +20,6 @@
import com.alibaba.dubbo.config.spring.beans.factory.annotation.DubboConfigBindingBeanPostProcessor;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.springframework.beans.MutablePropertyValues;
-import org.springframework.beans.PropertyValues;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
@@ -30,15 +28,21 @@
import org.springframework.context.EnvironmentAware;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.annotation.AnnotationAttributes;
-import org.springframework.core.env.*;
+import org.springframework.core.env.ConfigurableEnvironment;
+import org.springframework.core.env.Environment;
+import org.springframework.core.env.PropertySources;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
-import java.util.*;
+import java.util.Collections;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.Set;
import static com.alibaba.dubbo.config.spring.util.PropertySourcesUtils.getSubProperties;
+import static com.alibaba.dubbo.config.spring.util.PropertySourcesUtils.normalizePrefix;
import static org.springframework.beans.factory.support.BeanDefinitionBuilder.rootBeanDefinition;
import static org.springframework.beans.factory.support.BeanDefinitionReaderUtils.registerWithGeneratedName;
@@ -82,9 +86,7 @@ private void registerDubboConfigBeans(String prefix,
boolean multiple,
BeanDefinitionRegistry registry) {
- PropertySources propertySources = environment.getPropertySources();
-
- Map<String, String> properties = getSubProperties(propertySources, prefix);
+ Map<String, String> properties = getSubProperties(environment.getPropertySources(), prefix);
if (CollectionUtils.isEmpty(properties)) {
if (log.isDebugEnabled()) {
@@ -94,16 +96,14 @@ private void registerDubboConfigBeans(String prefix,
return;
}
- Set<String> beanNames = multiple ? resolveMultipleBeanNames(prefix, properties) :
- Collections.singleton(resolveSingleBeanName(configClass, properties, registry));
+ Set<String> beanNames = multiple ? resolveMultipleBeanNames(properties) :
+ Collections.singleton(resolveSingleBeanName(properties, configClass, registry));
for (String beanName : beanNames) {
registerDubboConfigBean(beanName, configClass, registry);
- MutablePropertyValues propertyValues = resolveBeanPropertyValues(beanName, multiple, properties);
-
- registerDubboConfigBindingBeanPostProcessor(beanName, propertyValues, registry);
+ registerDubboConfigBindingBeanPostProcessor(prefix, beanName, multiple, registry);
}
@@ -125,14 +125,16 @@ private void registerDubboConfigBean(String beanName, Class<? extends AbstractCo
}
- private void registerDubboConfigBindingBeanPostProcessor(String beanName, PropertyValues propertyValues,
+ private void registerDubboConfigBindingBeanPostProcessor(String prefix, String beanName, boolean multiple,
BeanDefinitionRegistry registry) {
Class<?> processorClass = DubboConfigBindingBeanPostProcessor.class;
BeanDefinitionBuilder builder = rootBeanDefinition(processorClass);
- builder.addConstructorArgValue(beanName).addConstructorArgValue(propertyValues);
+ String actualPrefix = multiple ? normalizePrefix(prefix) + beanName : prefix;
+
+ builder.addConstructorArgValue(actualPrefix).addConstructorArgValue(beanName);
AbstractBeanDefinition beanDefinition = builder.getBeanDefinition();
@@ -147,36 +149,6 @@ private void registerDubboConfigBindingBeanPostProcessor(String beanName, Proper
}
- private MutablePropertyValues resolveBeanPropertyValues(String beanName, boolean multiple,
- Map<String, String> properties) {
-
- MutablePropertyValues propertyValues = new MutablePropertyValues();
-
- if (multiple) { // For Multiple Beans
-
- MutablePropertySources propertySources = new MutablePropertySources();
- propertySources.addFirst(new MapPropertySource(beanName, new TreeMap<String, Object>(properties)));
-
- Map<String, String> subProperties = getSubProperties(propertySources, beanName);
-
- propertyValues.addPropertyValues(subProperties);
-
-
- } else { // For Single Bean
-
- for (Map.Entry<String, String> entry : properties.entrySet()) {
- String propertyName = entry.getKey();
- if (!propertyName.contains(".")) { // ignore property name with "."
- propertyValues.addPropertyValue(propertyName, entry.getValue());
- }
- }
-
- }
-
- return propertyValues;
-
- }
-
@Override
public void setEnvironment(Environment environment) {
@@ -186,7 +158,7 @@ public void setEnvironment(Environment environment) {
}
- private Set<String> resolveMultipleBeanNames(String prefix, Map<String, String> properties) {
+ private Set<String> resolveMultipleBeanNames(Map<String, String> properties) {
Set<String> beanNames = new LinkedHashSet<String>();
@@ -207,7 +179,7 @@ public void setEnvironment(Environment environment) {
}
- private String resolveSingleBeanName(Class<? extends AbstractConfig> configClass, Map<String, String> properties,
+ private String resolveSingleBeanName(Map<String, String> properties, Class<? extends AbstractConfig> configClass,
BeanDefinitionRegistry registry) {
String beanName = properties.get("id");
diff --git a/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/context/properties/AbstractDubboConfigBinder.java b/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/context/properties/AbstractDubboConfigBinder.java
new file mode 100644
index 0000000000..b10336797f
--- /dev/null
+++ b/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/context/properties/AbstractDubboConfigBinder.java
@@ -0,0 +1,69 @@
+/*
+ * 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.config.spring.context.properties;
+
+import org.springframework.core.env.ConfigurableEnvironment;
+import org.springframework.core.env.Environment;
+import org.springframework.core.env.PropertySource;
+
+/**
+ * Abstract {@link DubboConfigBinder} implementation
+ */
+public abstract class AbstractDubboConfigBinder implements DubboConfigBinder {
+
+ private Iterable<PropertySource<?>> propertySources;
+
+ private boolean ignoreUnknownFields = true;
+
+ private boolean ignoreInvalidFields = false;
+
+ /**
+ * Get multiple {@link PropertySource propertySources}
+ *
+ * @return multiple {@link PropertySource propertySources}
+ */
+ protected Iterable<PropertySource<?>> getPropertySources() {
+ return propertySources;
+ }
+
+ public boolean isIgnoreUnknownFields() {
+ return ignoreUnknownFields;
+ }
+
+ @Override
+ public void setIgnoreUnknownFields(boolean ignoreUnknownFields) {
+ this.ignoreUnknownFields = ignoreUnknownFields;
+ }
+
+ public boolean isIgnoreInvalidFields() {
+ return ignoreInvalidFields;
+ }
+
+ @Override
+ public void setIgnoreInvalidFields(boolean ignoreInvalidFields) {
+ this.ignoreInvalidFields = ignoreInvalidFields;
+ }
+
+ @Override
+ public final void setEnvironment(Environment environment) {
+
+ if (environment instanceof ConfigurableEnvironment) {
+ this.propertySources = ((ConfigurableEnvironment) environment).getPropertySources();
+ }
+
+ }
+}
diff --git a/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/context/properties/DefaultDubboConfigBinder.java b/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/context/properties/DefaultDubboConfigBinder.java
new file mode 100644
index 0000000000..52cc87ca4f
--- /dev/null
+++ b/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/context/properties/DefaultDubboConfigBinder.java
@@ -0,0 +1,46 @@
+/*
+ * 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.config.spring.context.properties;
+
+import com.alibaba.dubbo.config.AbstractConfig;
+import org.springframework.beans.MutablePropertyValues;
+import org.springframework.validation.DataBinder;
+
+import java.util.Map;
+
+import static com.alibaba.dubbo.config.spring.util.PropertySourcesUtils.getSubProperties;
+
+/**
+ * Default {@link DubboConfigBinder} implementation based on Spring {@link DataBinder}
+ */
+public class DefaultDubboConfigBinder extends AbstractDubboConfigBinder {
+
+ @Override
+ public <C extends AbstractConfig> void bind(String prefix, C dubboConfig) {
+ DataBinder dataBinder = new DataBinder(dubboConfig);
+ // Set ignored*
+ dataBinder.setIgnoreInvalidFields(isIgnoreInvalidFields());
+ dataBinder.setIgnoreUnknownFields(isIgnoreUnknownFields());
+ // Get properties under specified prefix from PropertySources
+ Map<String, String> properties = getSubProperties(getPropertySources(), prefix);
+ // Convert Map to MutablePropertyValues
+ MutablePropertyValues propertyValues = new MutablePropertyValues(properties);
+ // Bind
+ dataBinder.bind(propertyValues);
+ }
+
+}
diff --git a/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/context/properties/DubboConfigBinder.java b/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/context/properties/DubboConfigBinder.java
new file mode 100644
index 0000000000..c19fadce27
--- /dev/null
+++ b/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/context/properties/DubboConfigBinder.java
@@ -0,0 +1,58 @@
+/*
+ * 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.config.spring.context.properties;
+
+import com.alibaba.dubbo.config.AbstractConfig;
+import org.springframework.context.EnvironmentAware;
+
+/**
+ * {@link AbstractConfig DubboConfig} Binder
+ *
+ * @see AbstractConfig
+ * @see EnvironmentAware
+ * @since 2.5.11
+ */
+public interface DubboConfigBinder extends EnvironmentAware {
+
+ /**
+ * Set whether to ignore unknown fields, that is, whether to ignore bind
+ * parameters that do not have corresponding fields in the target object.
+ * <p>Default is "true". Turn this off to enforce that all bind parameters
+ * must have a matching field in the target object.
+ *
+ * @see #bind
+ */
+ void setIgnoreUnknownFields(boolean ignoreUnknownFields);
+
+ /**
+ * Set whether to ignore invalid fields, that is, whether to ignore bind
+ * parameters that have corresponding fields in the target object which are
+ * not accessible (for example because of null values in the nested path).
+ * <p>Default is "false".
+ *
+ * @see #bind
+ */
+ void setIgnoreInvalidFields(boolean ignoreInvalidFields);
+
+ /**
+ * Bind the properties to {@link C Dubbo Config} Object under specified prefix.
+ *
+ * @param prefix
+ * @param dubboConfig
+ */
+ <C extends AbstractConfig> void bind(String prefix, C dubboConfig);
+}
diff --git a/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/convert/converter/StringArrayToMapConverter.java b/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/convert/converter/StringArrayToMapConverter.java
new file mode 100644
index 0000000000..56c6d4c4cc
--- /dev/null
+++ b/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/convert/converter/StringArrayToMapConverter.java
@@ -0,0 +1,38 @@
+/*
+ * 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.config.spring.convert.converter;
+
+import com.alibaba.dubbo.common.utils.CollectionUtils;
+import org.springframework.core.convert.converter.Converter;
+import org.springframework.util.ObjectUtils;
+
+import java.util.Map;
+
+/**
+ * {@link String}[] to {@link Map} {@link Converter}
+ *
+ * @see CollectionUtils#toStringMap(String[])
+ * @since 2.5.11
+ */
+public class StringArrayToMapConverter implements Converter<String[], Map<String, String>> {
+
+ @Override
+ public Map<String, String> convert(String[] source) {
+ return ObjectUtils.isEmpty(source) ? null : CollectionUtils.toStringMap(source);
+ }
+
+}
diff --git a/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/convert/converter/StringArrayToStringConverter.java b/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/convert/converter/StringArrayToStringConverter.java
new file mode 100644
index 0000000000..23e948b064
--- /dev/null
+++ b/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/convert/converter/StringArrayToStringConverter.java
@@ -0,0 +1,37 @@
+/*
+ * 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.config.spring.convert.converter;
+
+import org.springframework.core.convert.converter.Converter;
+import org.springframework.util.ObjectUtils;
+import org.springframework.util.StringUtils;
+
+
+/**
+ * String[] to String {@ConditionalGenericConverter}
+ *
+ * @see StringUtils#arrayToCommaDelimitedString(Object[])
+ * @since 2.5.11
+ */
+public class StringArrayToStringConverter implements Converter<String[], String> {
+
+ @Override
+ public String convert(String[] source) {
+ return ObjectUtils.isEmpty(source) ? null : StringUtils.arrayToCommaDelimitedString(source);
+ }
+
+}
diff --git a/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/util/AnnotationUtils.java b/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/util/AnnotationUtils.java
new file mode 100644
index 0000000000..aa15e567eb
--- /dev/null
+++ b/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/util/AnnotationUtils.java
@@ -0,0 +1,89 @@
+/*
+ * 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.config.spring.util;
+
+import org.springframework.core.env.PropertyResolver;
+
+import java.lang.annotation.Annotation;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Set;
+
+import static java.lang.String.valueOf;
+import static org.springframework.core.annotation.AnnotationUtils.getAnnotationAttributes;
+import static org.springframework.core.annotation.AnnotationUtils.getDefaultValue;
+import static org.springframework.util.CollectionUtils.arrayToList;
+import static org.springframework.util.ObjectUtils.nullSafeEquals;
+import static org.springframework.util.StringUtils.trimAllWhitespace;
+
+/**
+ * Annotation Utilities Class
+ *
+ * @see org.springframework.core.annotation.AnnotationUtils
+ * @since 2.5.11
+ */
+public class AnnotationUtils {
+
+ /**
+ * Get {@link Annotation} attributes
+ *
+ * @param annotation
+ * @param propertyResolver
+ * @param ignoreDefaultValue
+ * @return non-null
+ */
+ public static Map<String, Object> getAttributes(Annotation annotation, PropertyResolver propertyResolver,
+ boolean ignoreDefaultValue, String... ignoreAttributeNames) {
+
+ Set<String> ignoreAttributeNamesSet = new HashSet<String>(arrayToList(ignoreAttributeNames));
+
+ Map<String, Object> attributes = getAnnotationAttributes(annotation);
+
+ Map<String, Object> actualAttributes = new LinkedHashMap<String, Object>();
+
+ boolean requiredResolve = propertyResolver != null;
+
+ for (Map.Entry<String, Object> entry : attributes.entrySet()) {
+
+ String attributeName = entry.getKey();
+ Object attributeValue = entry.getValue();
+
+ // ignore default attribute value
+ if (ignoreDefaultValue && nullSafeEquals(attributeValue, getDefaultValue(annotation, attributeName))) {
+ continue;
+ }
+
+ // ignore attribute name
+ if (ignoreAttributeNamesSet.contains(attributeName)) {
+ continue;
+ }
+
+ if (requiredResolve && attributeValue instanceof String) { // Resolve Placeholder
+ String resolvedValue = propertyResolver.resolvePlaceholders(valueOf(attributeValue));
+ attributeValue = trimAllWhitespace(resolvedValue);
+ }
+
+ actualAttributes.put(attributeName, attributeValue);
+
+ }
+
+ return actualAttributes;
+
+ }
+
+}
diff --git a/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/util/ObjectUtils.java b/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/util/ObjectUtils.java
new file mode 100644
index 0000000000..00db1e770f
--- /dev/null
+++ b/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/util/ObjectUtils.java
@@ -0,0 +1,37 @@
+/*
+ * 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.config.spring.util;
+
+/**
+ * Object Utilities Class
+ *
+ * @since 2.5.11
+ */
+public class ObjectUtils {
+
+ /**
+ * of factory method
+ *
+ * @param values
+ * @param <T>
+ * @return
+ */
+ public static <T> T[] of(T... values) {
+ return values;
+ }
+
+}
diff --git a/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/util/PropertySourcesUtils.java b/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/util/PropertySourcesUtils.java
index fe1c61bbbd..5b183e1f2f 100644
--- a/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/util/PropertySourcesUtils.java
+++ b/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/util/PropertySourcesUtils.java
@@ -35,16 +35,16 @@
/**
* Get Sub {@link Properties}
*
- * @param propertySources {@link PropertySources}
+ * @param propertySources {@link PropertySource} Iterable
* @param prefix the prefix of property name
- * @return Map<String, String>
+ * @return Map<String , String>
* @see Properties
*/
- public static Map<String, String> getSubProperties(PropertySources propertySources, String prefix) {
+ public static Map<String, String> getSubProperties(Iterable<PropertySource<?>> propertySources, String prefix) {
Map<String, String> subProperties = new LinkedHashMap<String, String>();
- String normalizedPrefix = prefix.endsWith(".") ? prefix : prefix + ".";
+ String normalizedPrefix = normalizePrefix(prefix);
for (PropertySource<?> source : propertySources) {
if (source instanceof EnumerablePropertySource) {
@@ -62,4 +62,14 @@
}
+ /**
+ * Normalize the prefix
+ *
+ * @param prefix the prefix
+ * @return the prefix
+ */
+ public static String normalizePrefix(String prefix) {
+ return prefix.endsWith(".") ? prefix : prefix + ".";
+ }
+
}
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/com/alibaba/dubbo/config/spring/annotation/provider/AnnotationServiceImpl.java b/dubbo-config/dubbo-config-spring/src/test/java/com/alibaba/dubbo/config/spring/annotation/provider/AnnotationServiceImpl.java
index 7766a1a602..327f4d91ba 100644
--- a/dubbo-config/dubbo-config-spring/src/test/java/com/alibaba/dubbo/config/spring/annotation/provider/AnnotationServiceImpl.java
+++ b/dubbo-config/dubbo-config-spring/src/test/java/com/alibaba/dubbo/config/spring/annotation/provider/AnnotationServiceImpl.java
@@ -23,7 +23,7 @@
/**
* DemoServiceImpl
*/
-@Service(version = "1.2")
+@Service(version = "${provider.version}")
public class AnnotationServiceImpl implements DemoService {
public String sayName(String name) {
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/com/alibaba/dubbo/config/spring/beans/factory/annotation/AnnotationPropertyValuesAdapterTest.java b/dubbo-config/dubbo-config-spring/src/test/java/com/alibaba/dubbo/config/spring/beans/factory/annotation/AnnotationPropertyValuesAdapterTest.java
new file mode 100644
index 0000000000..36def719d3
--- /dev/null
+++ b/dubbo-config/dubbo-config-spring/src/test/java/com/alibaba/dubbo/config/spring/beans/factory/annotation/AnnotationPropertyValuesAdapterTest.java
@@ -0,0 +1,158 @@
+/*
+ * 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.config.spring.beans.factory.annotation;
+
+
+import com.alibaba.dubbo.common.utils.CollectionUtils;
+import com.alibaba.dubbo.config.annotation.Reference;
+import com.alibaba.dubbo.config.spring.ReferenceBean;
+import com.alibaba.dubbo.config.spring.api.DemoService;
+import org.junit.Assert;
+import org.junit.Test;
+import org.springframework.core.annotation.AnnotationUtils;
+import org.springframework.core.convert.converter.Converter;
+import org.springframework.core.convert.support.DefaultConversionService;
+import org.springframework.mock.env.MockEnvironment;
+import org.springframework.util.ReflectionUtils;
+import org.springframework.validation.DataBinder;
+
+import java.lang.reflect.Field;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import static org.springframework.util.StringUtils.arrayToCommaDelimitedString;
+
+/**
+ * {@link AnnotationPropertyValuesAdapter} Test
+ *
+ * @since 2.5.11
+ */
+public class AnnotationPropertyValuesAdapterTest {
+
+ @Test
+ public void test() {
+
+ MockEnvironment mockEnvironment = new MockEnvironment();
+
+ mockEnvironment.setProperty("version", "1.0.0");
+
+ mockEnvironment.setProperty("url", " dubbo://localhost:12345");
+
+ Field field = ReflectionUtils.findField(TestBean.class, "demoService");
+
+ Reference reference = AnnotationUtils.getAnnotation(field, Reference.class);
+
+ AnnotationPropertyValuesAdapter propertyValues = new AnnotationPropertyValuesAdapter(reference, mockEnvironment);
+
+ ReferenceBean referenceBean = new ReferenceBean();
+
+ DataBinder dataBinder = new DataBinder(referenceBean);
+
+ dataBinder.setDisallowedFields("application", "module", "consumer", "monitor", "registry");
+
+ DefaultConversionService conversionService = new DefaultConversionService();
+
+ conversionService.addConverter(new Converter<String[], String>() {
+ @Override
+ public String convert(String[] source) {
+ return arrayToCommaDelimitedString(source);
+ }
+ });
+
+ conversionService.addConverter(new Converter<String[], Map<String, String>>() {
+ @Override
+ public Map<String, String> convert(String[] source) {
+ return CollectionUtils.toStringMap(source);
+ }
+ });
+
+
+ dataBinder.setConversionService(conversionService);
+
+
+ dataBinder.bind(propertyValues);
+
+// System.out.println(referenceBean);
+
+ Assert.assertEquals(DemoService.class, referenceBean.getInterfaceClass());
+ Assert.assertEquals("com.alibaba.dubbo.config.spring.api.DemoService", referenceBean.getInterface());
+ Assert.assertEquals("1.0.0", referenceBean.getVersion());
+ Assert.assertEquals("group", referenceBean.getGroup());
+ Assert.assertEquals("dubbo://localhost:12345", referenceBean.getUrl());
+ Assert.assertEquals("client", referenceBean.getClient());
+ Assert.assertEquals(true, referenceBean.isGeneric());
+ Assert.assertEquals(true, referenceBean.isInjvm());
+ Assert.assertEquals(false, referenceBean.isCheck());
+ Assert.assertEquals(true, referenceBean.isInit());
+ Assert.assertEquals(true, referenceBean.getLazy());
+ Assert.assertEquals(true, referenceBean.getStubevent());
+ Assert.assertEquals("reconnect", referenceBean.getReconnect());
+ Assert.assertEquals(true, referenceBean.getSticky());
+
+ Assert.assertEquals("javassist", referenceBean.getProxy());
+
+ Assert.assertEquals("stub", referenceBean.getStub());
+ Assert.assertEquals("failover", referenceBean.getCluster());
+ Assert.assertEquals(Integer.valueOf(1), referenceBean.getConnections());
+ Assert.assertEquals(Integer.valueOf(1), referenceBean.getCallbacks());
+ Assert.assertEquals("onconnect", referenceBean.getOnconnect());
+ Assert.assertEquals("ondisconnect", referenceBean.getOndisconnect());
+ Assert.assertEquals("owner", referenceBean.getOwner());
+ Assert.assertEquals("layer", referenceBean.getLayer());
+ Assert.assertEquals(Integer.valueOf(2), referenceBean.getRetries());
+ Assert.assertEquals("random", referenceBean.getLoadbalance());
+ Assert.assertEquals(true, referenceBean.isAsync());
+ Assert.assertEquals(Integer.valueOf(1), referenceBean.getActives());
+ Assert.assertEquals(true, referenceBean.getSent());
+ Assert.assertEquals("mock", referenceBean.getMock());
+ Assert.assertEquals("validation", referenceBean.getValidation());
+ Assert.assertEquals(Integer.valueOf(2), referenceBean.getTimeout());
+ Assert.assertEquals("cache", referenceBean.getCache());
+ Assert.assertEquals("default,default", referenceBean.getFilter());
+ Assert.assertEquals("default,default", referenceBean.getListener());
+
+ Map<String, String> data = new LinkedHashMap<String, String>();
+ data.put("key1", "value1");
+
+ Assert.assertEquals(data, referenceBean.getParameters());
+ // Bean compare
+ Assert.assertEquals(null, referenceBean.getApplication());
+ Assert.assertEquals(null, referenceBean.getModule());
+ Assert.assertEquals(null, referenceBean.getConsumer());
+ Assert.assertEquals(null, referenceBean.getMonitor());
+ Assert.assertEquals(null, referenceBean.getRegistry());
+
+ }
+
+ private static class TestBean {
+
+ @Reference(
+ interfaceClass = DemoService.class, interfaceName = "com.alibaba.dubbo.config.spring.api.DemoService", version = "${version}", group = "group",
+ url = "${url} ", client = "client", generic = true, injvm = true,
+ check = false, init = true, lazy = true, stubevent = true,
+ reconnect = "reconnect", sticky = true, proxy = "javassist", stub = "stub",
+ cluster = "failover", connections = 1, callbacks = 1, onconnect = "onconnect",
+ ondisconnect = "ondisconnect", owner = "owner", layer = "layer", retries = 2,
+ loadbalance = "random", async = true, actives = 1, sent = true,
+ mock = "mock", validation = "validation", timeout = 2, cache = "cache",
+ filter = {"default", "default"}, listener = {"default", "default"}, parameters = {"key1", "value1"}, application = "application",
+ module = "module", consumer = "consumer", monitor = "monitor", registry = {"registry1", "registry2"}
+ )
+ private DemoService demoService;
+
+ }
+}
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/com/alibaba/dubbo/config/spring/beans/factory/annotation/DubboConfigBindingBeanPostProcessorTest.java b/dubbo-config/dubbo-config-spring/src/test/java/com/alibaba/dubbo/config/spring/beans/factory/annotation/DubboConfigBindingBeanPostProcessorTest.java
new file mode 100644
index 0000000000..05a49807d4
--- /dev/null
+++ b/dubbo-config/dubbo-config-spring/src/test/java/com/alibaba/dubbo/config/spring/beans/factory/annotation/DubboConfigBindingBeanPostProcessorTest.java
@@ -0,0 +1,66 @@
+/*
+ * 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.config.spring.beans.factory.annotation;
+
+import com.alibaba.dubbo.config.ApplicationConfig;
+import com.alibaba.dubbo.config.spring.context.properties.DefaultDubboConfigBinder;
+import com.alibaba.dubbo.config.spring.context.properties.DubboConfigBinder;
+import org.junit.Assert;
+import org.junit.Test;
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.PropertySource;
+
+import static org.springframework.beans.factory.support.BeanDefinitionBuilder.rootBeanDefinition;
+
+/**
+ * {@link DubboConfigBindingBeanPostProcessor}
+ */
+@PropertySource({"classpath:/META-INF/config.properties"})
+@Configuration
+public class DubboConfigBindingBeanPostProcessorTest {
+
+ @Bean("applicationBean")
+ public ApplicationConfig applicationConfig() {
+ return new ApplicationConfig();
+ }
+
+ @Bean
+ public DubboConfigBinder dubboConfigBinder() {
+ return new DefaultDubboConfigBinder();
+ }
+
+ @Test
+ public void test() {
+
+ final AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();
+
+ applicationContext.register(getClass());
+
+ Class<?> processorClass = DubboConfigBindingBeanPostProcessor.class;
+
+ applicationContext.registerBeanDefinition("DubboConfigBindingBeanPostProcessor", rootBeanDefinition(processorClass).addConstructorArgValue("dubbo.application").addConstructorArgValue("applicationBean").getBeanDefinition());
+
+ applicationContext.refresh();
+
+ ApplicationConfig applicationConfig = applicationContext.getBean(ApplicationConfig.class);
+
+ Assert.assertEquals("dubbo-demo-application", applicationConfig.getName());
+
+ }
+}
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/com/alibaba/dubbo/config/spring/beans/factory/annotation/ReferenceAnnotationBeanPostProcessorTest.java b/dubbo-config/dubbo-config-spring/src/test/java/com/alibaba/dubbo/config/spring/beans/factory/annotation/ReferenceAnnotationBeanPostProcessorTest.java
index 3f9a50e1af..5f334914d3 100644
--- a/dubbo-config/dubbo-config-spring/src/test/java/com/alibaba/dubbo/config/spring/beans/factory/annotation/ReferenceAnnotationBeanPostProcessorTest.java
+++ b/dubbo-config/dubbo-config-spring/src/test/java/com/alibaba/dubbo/config/spring/beans/factory/annotation/ReferenceAnnotationBeanPostProcessorTest.java
@@ -20,16 +20,16 @@
import com.alibaba.dubbo.config.spring.ReferenceBean;
import com.alibaba.dubbo.config.spring.api.DemoService;
import com.alibaba.dubbo.config.spring.context.annotation.DubboComponentScan;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.*;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.InjectionMetadata;
import org.springframework.context.ApplicationContext;
+import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ImportResource;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
import java.util.Collection;
+import java.util.Map;
import static com.alibaba.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor.BEAN_NAME;
@@ -40,12 +40,27 @@
*/
public class ReferenceAnnotationBeanPostProcessorTest {
- private static final String PROVIDER_LOCATION = "META-INF/spring/dubbo-provider.xml";
+ private ConfigurableApplicationContext providerApplicationContext;
+
+ @BeforeClass
+ public static void prepare() {
+ System.setProperty("provider.version", "1.2");
+ System.setProperty("package1", "com.alibaba.dubbo.config.spring.annotation.provider");
+ System.setProperty("packagesToScan", "${package1}");
+ System.setProperty("consumer.version", "1.2");
+ System.setProperty("consumer.url", "dubbo://127.0.0.1:12345");
+ }
@Before
- public void before() {
+ public void init() {
// Starts Provider
- new ClassPathXmlApplicationContext(PROVIDER_LOCATION);
+ providerApplicationContext = new AnnotationConfigApplicationContext(ServiceAnnotationBeanPostProcessorTest.TestConfiguration.class);
+ }
+
+ @After
+ public void destroy() {
+ // Shutdowns Provider
+ providerApplicationContext.close();
}
@Test
@@ -95,6 +110,66 @@ public void testGetReferenceBeans() {
}
+ @Test
+ public void testGetInjectedFieldReferenceBeanMap() {
+
+ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(TestBean.class);
+
+ ReferenceAnnotationBeanPostProcessor beanPostProcessor = context.getBean(BEAN_NAME,
+ ReferenceAnnotationBeanPostProcessor.class);
+
+
+ Map<InjectionMetadata.InjectedElement, ReferenceBean<?>> referenceBeanMap =
+ beanPostProcessor.getInjectedFieldReferenceBeanMap();
+
+ Assert.assertEquals(1, referenceBeanMap.size());
+
+ for (Map.Entry<InjectionMetadata.InjectedElement, ReferenceBean<?>> entry : referenceBeanMap.entrySet()) {
+
+ InjectionMetadata.InjectedElement injectedElement = entry.getKey();
+
+ Assert.assertEquals("com.alibaba.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor$ReferenceFieldElement",
+ injectedElement.getClass().getName());
+
+ ReferenceBean<?> referenceBean = entry.getValue();
+
+ Assert.assertEquals("1.2", referenceBean.getVersion());
+ Assert.assertEquals("dubbo://127.0.0.1:12345", referenceBean.getUrl());
+
+ }
+
+ }
+
+ @Test
+ public void testGetInjectedMethodReferenceBeanMap() {
+
+ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(TestBean.class);
+
+ ReferenceAnnotationBeanPostProcessor beanPostProcessor = context.getBean(BEAN_NAME,
+ ReferenceAnnotationBeanPostProcessor.class);
+
+
+ Map<InjectionMetadata.InjectedElement, ReferenceBean<?>> referenceBeanMap =
+ beanPostProcessor.getInjectedMethodReferenceBeanMap();
+
+ Assert.assertEquals(2, referenceBeanMap.size());
+
+ for (Map.Entry<InjectionMetadata.InjectedElement, ReferenceBean<?>> entry : referenceBeanMap.entrySet()) {
+
+ InjectionMetadata.InjectedElement injectedElement = entry.getKey();
+
+ Assert.assertEquals("com.alibaba.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor$ReferenceMethodElement",
+ injectedElement.getClass().getName());
+
+ ReferenceBean<?> referenceBean = entry.getValue();
+
+ Assert.assertEquals("1.2", referenceBean.getVersion());
+ Assert.assertEquals("dubbo://127.0.0.1:12345", referenceBean.getUrl());
+
+ }
+
+ }
+
private static class AncestorBean {
@@ -121,7 +196,7 @@ public ApplicationContext getApplicationContext() {
private static class ParentBean extends AncestorBean {
- @Reference(version = "1.2", url = "dubbo://127.0.0.1:12345")
+ @Reference(version = "${consumer.version}", url = "${consumer.url}")
private DemoService demoServiceFromParent;
public DemoService getDemoServiceFromParent() {
@@ -133,7 +208,7 @@ public DemoService getDemoServiceFromParent() {
@ImportResource("META-INF/spring/dubbo-annotation-consumer.xml")
@DubboComponentScan(basePackageClasses = ReferenceAnnotationBeanPostProcessorTest.class)
- private static class TestBean extends ParentBean {
+ static class TestBean extends ParentBean {
private DemoService demoService;
@@ -150,4 +225,4 @@ public void setDemoService(DemoService demoService) {
}
}
-}
+}
\ No newline at end of file
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/com/alibaba/dubbo/config/spring/beans/factory/annotation/ServiceAnnotationBeanPostProcessorTest.java b/dubbo-config/dubbo-config-spring/src/test/java/com/alibaba/dubbo/config/spring/beans/factory/annotation/ServiceAnnotationBeanPostProcessorTest.java
index e5714c7f25..c096441814 100644
--- a/dubbo-config/dubbo-config-spring/src/test/java/com/alibaba/dubbo/config/spring/beans/factory/annotation/ServiceAnnotationBeanPostProcessorTest.java
+++ b/dubbo-config/dubbo-config-spring/src/test/java/com/alibaba/dubbo/config/spring/beans/factory/annotation/ServiceAnnotationBeanPostProcessorTest.java
@@ -44,7 +44,8 @@
classes = {ServiceAnnotationBeanPostProcessorTest.TestConfiguration.class})
@TestPropertySource(properties = {
"package1 = com.alibaba.dubbo.config.spring.context.annotation",
- "packagesToScan = ${package1}"
+ "packagesToScan = ${package1}",
+ "provider.version = 1.2"
})
public class ServiceAnnotationBeanPostProcessorTest {
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/com/alibaba/dubbo/config/spring/context/properties/DefaultDubboConfigBinderTest.java b/dubbo-config/dubbo-config-spring/src/test/java/com/alibaba/dubbo/config/spring/context/properties/DefaultDubboConfigBinderTest.java
new file mode 100644
index 0000000000..f0ec69f505
--- /dev/null
+++ b/dubbo-config/dubbo-config-spring/src/test/java/com/alibaba/dubbo/config/spring/context/properties/DefaultDubboConfigBinderTest.java
@@ -0,0 +1,56 @@
+/*
+ * 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.config.spring.context.properties;
+
+
+import com.alibaba.dubbo.config.ApplicationConfig;
+import com.alibaba.dubbo.config.ProtocolConfig;
+import com.alibaba.dubbo.config.RegistryConfig;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.TestPropertySource;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@TestPropertySource(locations = "classpath:/dubbo.properties")
+@ContextConfiguration(classes = DefaultDubboConfigBinder.class)
+public class DefaultDubboConfigBinderTest {
+
+ @Autowired
+ private DubboConfigBinder dubboConfigBinder;
+
+ @Test
+ public void testBinder() {
+
+ ApplicationConfig applicationConfig = new ApplicationConfig();
+ dubboConfigBinder.bind("dubbo.application", applicationConfig);
+ Assert.assertEquals("hello", applicationConfig.getName());
+ Assert.assertEquals("world", applicationConfig.getOwner());
+
+ RegistryConfig registryConfig = new RegistryConfig();
+ dubboConfigBinder.bind("dubbo.registry", registryConfig);
+ Assert.assertEquals("10.20.153.17", registryConfig.getAddress());
+
+ ProtocolConfig protocolConfig = new ProtocolConfig();
+ dubboConfigBinder.bind("dubbo.protocol", protocolConfig);
+ Assert.assertEquals(Integer.valueOf(20881), protocolConfig.getPort());
+
+ }
+}
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/com/alibaba/dubbo/config/spring/convert/converter/StringArrayToMapConverterTest.java b/dubbo-config/dubbo-config-spring/src/test/java/com/alibaba/dubbo/config/spring/convert/converter/StringArrayToMapConverterTest.java
new file mode 100644
index 0000000000..51be7c3f2f
--- /dev/null
+++ b/dubbo-config/dubbo-config-spring/src/test/java/com/alibaba/dubbo/config/spring/convert/converter/StringArrayToMapConverterTest.java
@@ -0,0 +1,52 @@
+/*
+ * 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.config.spring.convert.converter;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * {@link StringArrayToMapConverter} Test
+ */
+public class StringArrayToMapConverterTest {
+
+ @Test
+ public void testConvert() {
+
+ StringArrayToMapConverter converter = new StringArrayToMapConverter();
+
+ Map<String, String> value = converter.convert(new String[]{"Hello", "World"});
+
+ Map<String, String> expected = new LinkedHashMap<String, String>();
+
+ expected.put("Hello", "World");
+
+ Assert.assertEquals(expected, value);
+
+ value = converter.convert(new String[]{});
+
+ Assert.assertNull(value);
+
+ value = converter.convert(null);
+
+ Assert.assertNull(value);
+
+ }
+}
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/com/alibaba/dubbo/config/spring/convert/converter/StringArrayToStringConverterTest.java b/dubbo-config/dubbo-config-spring/src/test/java/com/alibaba/dubbo/config/spring/convert/converter/StringArrayToStringConverterTest.java
new file mode 100644
index 0000000000..67e8247923
--- /dev/null
+++ b/dubbo-config/dubbo-config-spring/src/test/java/com/alibaba/dubbo/config/spring/convert/converter/StringArrayToStringConverterTest.java
@@ -0,0 +1,46 @@
+/*
+ * 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.config.spring.convert.converter;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * {@link StringArrayToStringConverter} Test
+ */
+public class StringArrayToStringConverterTest {
+
+ @Test
+ public void testConvert() {
+
+ StringArrayToStringConverter converter = new StringArrayToStringConverter();
+
+ String value = converter.convert(new String[]{"Hello", "World"});
+
+ Assert.assertEquals("Hello,World", value);
+
+ value = converter.convert(new String[]{});
+
+ Assert.assertNull(value);
+
+ value = converter.convert(null);
+
+ Assert.assertNull(value);
+
+ }
+
+}
diff --git a/dubbo-config/pom.xml b/dubbo-config/pom.xml
index e49f638d48..b50c037965 100644
--- a/dubbo-config/pom.xml
+++ b/dubbo-config/pom.xml
@@ -20,7 +20,7 @@ limitations under the License.
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-parent</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>dubbo-config</artifactId>
<packaging>pom</packaging>
diff --git a/dubbo-container/dubbo-container-api/pom.xml b/dubbo-container/dubbo-container-api/pom.xml
index 0704ce9273..d4f02d9535 100644
--- a/dubbo-container/dubbo-container-api/pom.xml
+++ b/dubbo-container/dubbo-container-api/pom.xml
@@ -20,7 +20,7 @@ limitations under the License.
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-container</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>dubbo-container-api</artifactId>
<packaging>jar</packaging>
diff --git a/dubbo-container/dubbo-container-api/src/main/java/com/alibaba/dubbo/container/page/Menu.java b/dubbo-container/dubbo-container-api/src/main/java/com/alibaba/dubbo/container/page/Menu.java
index 0ea64a5557..46eec25365 100644
--- a/dubbo-container/dubbo-container-api/src/main/java/com/alibaba/dubbo/container/page/Menu.java
+++ b/dubbo-container/dubbo-container-api/src/main/java/com/alibaba/dubbo/container/page/Menu.java
@@ -1,39 +1,39 @@
-/*
- * 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.container.page;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Menu
- */
-@Documented
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.TYPE})
-public @interface Menu {
-
- String name();
-
- String desc() default "";
-
- int order() default 0;
-
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.alibaba.dubbo.container.page;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Menu
+ */
+@Documented
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE})
+public @interface Menu {
+
+ String name();
+
+ String desc() default "";
+
+ int order() default 0;
+
}
\ No newline at end of file
diff --git a/dubbo-container/dubbo-container-api/src/main/java/com/alibaba/dubbo/container/page/MenuComparator.java b/dubbo-container/dubbo-container-api/src/main/java/com/alibaba/dubbo/container/page/MenuComparator.java
index 57b0330f61..c73f77981b 100644
--- a/dubbo-container/dubbo-container-api/src/main/java/com/alibaba/dubbo/container/page/MenuComparator.java
+++ b/dubbo-container/dubbo-container-api/src/main/java/com/alibaba/dubbo/container/page/MenuComparator.java
@@ -1,43 +1,43 @@
-/*
- * 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.container.page;
-
-import java.io.Serializable;
-import java.util.Comparator;
-
-/**
- * MenuComparator
- */
-public class MenuComparator implements Comparator<PageHandler>, Serializable {
-
- private static final long serialVersionUID = -3161526932904414029L;
-
- public int compare(PageHandler o1, PageHandler o2) {
- if (o1 == null && o2 == null) {
- return 0;
- }
- if (o1 == null) {
- return -1;
- }
- if (o2 == null) {
- return 1;
- }
- return o1.equals(o2) ? 0 : (o1.getClass().getAnnotation(Menu.class).order()
- > o2.getClass().getAnnotation(Menu.class).order() ? 1 : -1);
- }
-
+/*
+ * 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.container.page;
+
+import java.io.Serializable;
+import java.util.Comparator;
+
+/**
+ * MenuComparator
+ */
+public class MenuComparator implements Comparator<PageHandler>, Serializable {
+
+ private static final long serialVersionUID = -3161526932904414029L;
+
+ public int compare(PageHandler o1, PageHandler o2) {
+ if (o1 == null && o2 == null) {
+ return 0;
+ }
+ if (o1 == null) {
+ return -1;
+ }
+ if (o2 == null) {
+ return 1;
+ }
+ return o1.equals(o2) ? 0 : (o1.getClass().getAnnotation(Menu.class).order()
+ > o2.getClass().getAnnotation(Menu.class).order() ? 1 : -1);
+ }
+
}
\ No newline at end of file
diff --git a/dubbo-container/dubbo-container-api/src/main/java/com/alibaba/dubbo/container/page/Page.java b/dubbo-container/dubbo-container-api/src/main/java/com/alibaba/dubbo/container/page/Page.java
index 748fe7f886..c586a9c470 100644
--- a/dubbo-container/dubbo-container-api/src/main/java/com/alibaba/dubbo/container/page/Page.java
+++ b/dubbo-container/dubbo-container-api/src/main/java/com/alibaba/dubbo/container/page/Page.java
@@ -1,82 +1,82 @@
-/*
- * 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.container.page;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Page
- */
-public class Page {
-
- private final String navigation;
-
- private final String title;
-
- private final List<String> columns;
-
- private final List<List<String>> rows;
-
- public Page(String navigation) {
- this(navigation, (String) null, (String[]) null, (List<List<String>>) null);
- }
-
- public Page(String navigation, String title,
- String column, String row) {
- this(navigation, title, column == null ? null : Arrays.asList(new String[]{column}), row == null ? null : stringToList(row));
- }
-
- public Page(String navigation, String title,
- String[] columns, List<List<String>> rows) {
- this(navigation, title, columns == null ? null : Arrays.asList(columns), rows);
- }
-
- public Page(String navigation, String title,
- List<String> columns, List<List<String>> rows) {
- this.navigation = navigation;
- this.title = title;
- this.columns = columns;
- this.rows = rows;
- }
-
- private static List<List<String>> stringToList(String str) {
- List<List<String>> rows = new ArrayList<List<String>>();
- List<String> row = new ArrayList<String>();
- row.add(str);
- rows.add(row);
- return rows;
- }
-
- public String getNavigation() {
- return navigation;
- }
-
- public String getTitle() {
- return title;
- }
-
- public List<String> getColumns() {
- return columns;
- }
-
- public List<List<String>> getRows() {
- return rows;
- }
-
+/*
+ * 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.container.page;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Page
+ */
+public class Page {
+
+ private final String navigation;
+
+ private final String title;
+
+ private final List<String> columns;
+
+ private final List<List<String>> rows;
+
+ public Page(String navigation) {
+ this(navigation, (String) null, (String[]) null, (List<List<String>>) null);
+ }
+
+ public Page(String navigation, String title,
+ String column, String row) {
+ this(navigation, title, column == null ? null : Arrays.asList(new String[]{column}), row == null ? null : stringToList(row));
+ }
+
+ public Page(String navigation, String title,
+ String[] columns, List<List<String>> rows) {
+ this(navigation, title, columns == null ? null : Arrays.asList(columns), rows);
+ }
+
+ public Page(String navigation, String title,
+ List<String> columns, List<List<String>> rows) {
+ this.navigation = navigation;
+ this.title = title;
+ this.columns = columns;
+ this.rows = rows;
+ }
+
+ private static List<List<String>> stringToList(String str) {
+ List<List<String>> rows = new ArrayList<List<String>>();
+ List<String> row = new ArrayList<String>();
+ row.add(str);
+ rows.add(row);
+ return rows;
+ }
+
+ public String getNavigation() {
+ return navigation;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public List<String> getColumns() {
+ return columns;
+ }
+
+ public List<List<String>> getRows() {
+ return rows;
+ }
+
}
\ No newline at end of file
diff --git a/dubbo-container/dubbo-container-api/src/main/java/com/alibaba/dubbo/container/page/PageHandler.java b/dubbo-container/dubbo-container-api/src/main/java/com/alibaba/dubbo/container/page/PageHandler.java
index 36590b3177..326e8e4a14 100644
--- a/dubbo-container/dubbo-container-api/src/main/java/com/alibaba/dubbo/container/page/PageHandler.java
+++ b/dubbo-container/dubbo-container-api/src/main/java/com/alibaba/dubbo/container/page/PageHandler.java
@@ -1,36 +1,36 @@
-/*
- * 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.container.page;
-
-import com.alibaba.dubbo.common.URL;
-import com.alibaba.dubbo.common.extension.SPI;
-
-/**
- * PageHandler
- */
-@SPI
-public interface PageHandler {
-
- /**
- * Handle the page.
- *
- * @param url
- * @return the page.
- */
- Page handle(URL url);
-
+/*
+ * 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.container.page;
+
+import com.alibaba.dubbo.common.URL;
+import com.alibaba.dubbo.common.extension.SPI;
+
+/**
+ * PageHandler
+ */
+@SPI
+public interface PageHandler {
+
+ /**
+ * Handle the page.
+ *
+ * @param url
+ * @return the page.
+ */
+ Page handle(URL url);
+
}
\ No newline at end of file
diff --git a/dubbo-container/dubbo-container-api/src/main/java/com/alibaba/dubbo/container/page/PageServlet.java b/dubbo-container/dubbo-container-api/src/main/java/com/alibaba/dubbo/container/page/PageServlet.java
index 36ec09dddd..400a7be0ea 100644
--- a/dubbo-container/dubbo-container-api/src/main/java/com/alibaba/dubbo/container/page/PageServlet.java
+++ b/dubbo-container/dubbo-container-api/src/main/java/com/alibaba/dubbo/container/page/PageServlet.java
@@ -1,279 +1,279 @@
-/*
- * 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.container.page;
-
-import com.alibaba.dubbo.common.Constants;
-import com.alibaba.dubbo.common.URL;
-import com.alibaba.dubbo.common.extension.ExtensionLoader;
-import com.alibaba.dubbo.common.logger.Logger;
-import com.alibaba.dubbo.common.logger.LoggerFactory;
-import com.alibaba.dubbo.common.utils.StringUtils;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * PageServlet
- */
-public class PageServlet extends HttpServlet {
-
- protected static final Logger logger = LoggerFactory.getLogger(PageServlet.class);
- private static final long serialVersionUID = -8370312705453328501L;
- private static PageServlet INSTANCE;
- protected final Random random = new Random();
- protected final Map<String, PageHandler> pages = new ConcurrentHashMap<String, PageHandler>();
- protected final List<PageHandler> menus = new ArrayList<PageHandler>();
-
- public static PageServlet getInstance() {
- return INSTANCE;
- }
-
- public List<PageHandler> getMenus() {
- return Collections.unmodifiableList(menus);
- }
-
- @Override
- public void init() throws ServletException {
- super.init();
- INSTANCE = this;
- String config = getServletConfig().getInitParameter("pages");
- Collection<String> names;
- if (config != null && config.length() > 0) {
- names = Arrays.asList(Constants.COMMA_SPLIT_PATTERN.split(config));
- } else {
- names = ExtensionLoader.getExtensionLoader(PageHandler.class).getSupportedExtensions();
- }
- for (String name : names) {
- PageHandler handler = ExtensionLoader.getExtensionLoader(PageHandler.class).getExtension(name);
- pages.put(ExtensionLoader.getExtensionLoader(PageHandler.class).getExtensionName(handler), handler);
- Menu menu = handler.getClass().getAnnotation(Menu.class);
- if (menu != null) {
- menus.add(handler);
- }
- }
- Collections.sort(menus, new MenuComparator());
- }
-
- @Override
- protected final void doGet(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- doPost(request, response);
- }
-
- @Override
- protected final void doPost(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- if (!response.isCommitted()) {
- PrintWriter writer = response.getWriter();
- String uri = request.getRequestURI();
- boolean isHtml = false;
- if (uri == null || uri.length() == 0 || "/".equals(uri)) {
- uri = "index";
- isHtml = true;
- } else {
- if (uri.startsWith("/")) {
- uri = uri.substring(1);
- }
- if (uri.endsWith(".html")) {
- uri = uri.substring(0, uri.length() - ".html".length());
- isHtml = true;
- }
- }
- if (uri.endsWith("favicon.ico")) {
- response.sendError(HttpServletResponse.SC_NOT_FOUND);
- return;
- }
- ExtensionLoader<PageHandler> pageHandlerLoader = ExtensionLoader.getExtensionLoader(PageHandler.class);
- PageHandler pageHandler = pageHandlerLoader.hasExtension(uri) ? pageHandlerLoader.getExtension(uri) : null;
- if (isHtml) {
- writer.println("<html><head><title>Dubbo</title>");
- writer.println("<style type=\"text/css\">html, body {margin: 10;padding: 0;background-color: #6D838C;font-family: Arial, Verdana;font-size: 12px;color: #FFFFFF;text-align: center;vertical-align: middle;word-break: break-all; } table {width: 90%; margin: 0px auto;border-collapse: collapse;border: 8px solid #FFFFFF; } thead tr {background-color: #253c46; } tbody tr {background-color: #8da5af; } th {padding-top: 4px;padding-bottom: 4px;font-size: 14px;height: 20px; } td {margin: 3px;padding: 3px;border: 2px solid #FFFFFF;font-size: 14px;height: 25px; } a {color: #FFFFFF;cursor: pointer;text-decoration: underline; } a:hover {text-decoration: none; }</style>");
- writer.println("</head><body>");
- }
- if (pageHandler != null) {
- Page page = null;
- try {
- String query = request.getQueryString();
- page = pageHandler.handle(URL.valueOf(request.getRequestURL().toString()
- + (query == null || query.length() == 0 ? "" : "?" + query)));
- } catch (Throwable t) {
- logger.warn(t.getMessage(), t);
- String msg = t.getMessage();
- if (msg == null) {
- msg = StringUtils.toString(t);
- }
- if (isHtml) {
- writer.println("<table>");
- writer.println("<thead>");
- writer.println(" <tr>");
- writer.println(" <th>Error</th>");
- writer.println(" </tr>");
- writer.println("</thead>");
- writer.println("<tbody>");
- writer.println(" <tr>");
- writer.println(" <td>");
- writer.println(" " + msg.replace("<", "<").replace(">", "<").replace("\n", "<br/>"));
- writer.println(" </td>");
- writer.println(" </tr>");
- writer.println("</tbody>");
- writer.println("</table>");
- writer.println("<br/>");
- } else {
- writer.println(msg);
- }
- }
- if (page != null) {
- if (isHtml) {
- String nav = page.getNavigation();
- if (nav == null || nav.length() == 0) {
- nav = ExtensionLoader.getExtensionLoader(PageHandler.class).getExtensionName(pageHandler);
- nav = nav.substring(0, 1).toUpperCase() + nav.substring(1);
- }
- if (!"index".equals(uri)) {
- nav = "<a href=\"/\">Home</a> > " + nav;
- }
- writeMenu(request, writer, nav);
- writeTable(writer, page.getTitle(), page.getColumns(),
- page.getRows());
- } else {
- if (page.getRows().size() > 0 && page.getRows().get(0).size() > 0) {
- writer.println(page.getRows().get(0).get(0));
- }
- }
- }
- } else {
- if (isHtml) {
- writer.println("<table>");
- writer.println("<thead>");
- writer.println(" <tr>");
- writer.println(" <th>Error</th>");
- writer.println(" </tr>");
- writer.println("</thead>");
- writer.println("<tbody>");
- writer.println(" <tr>");
- writer.println(" <td>");
- writer.println(" Not found " + uri + " page. Please goto <a href=\"/\">Home</a> page.");
- writer.println(" </td>");
- writer.println(" </tr>");
- writer.println("</tbody>");
- writer.println("</table>");
- writer.println("<br/>");
- } else {
- writer.println("Not found " + uri + " page.");
- }
- }
- if (isHtml) {
- writer.println("</body></html>");
- }
- writer.flush();
- }
- }
-
- protected final void writeMenu(HttpServletRequest request, PrintWriter writer, String nav) {
- writer.println("<table>");
- writer.println("<thead>");
- writer.println(" <tr>");
- for (PageHandler handler : menus) {
- String uri = ExtensionLoader.getExtensionLoader(PageHandler.class).getExtensionName(handler);
- Menu menu = handler.getClass().getAnnotation(Menu.class);
- writer.println(" <th><a href=\"" + uri + ".html\">" + menu.name() + "</a></th>");
- }
- writer.println(" </tr>");
- writer.println("</thead>");
- writer.println("<tbody>");
- writer.println(" <tr>");
- writer.println(" <td style=\"text-align: left\" colspan=\"" + menus.size() + "\">");
- writer.println(nav);
- writer.println(" </td>");
- writer.println(" </tr>");
- writer.println("</tbody>");
- writer.println("</table>");
- writer.println("<br/>");
- }
-
- protected final void writeTable(PrintWriter writer, String title, List<String> columns,
- List<List<String>> rows) {
- int n = random.nextInt();
- int c = (columns == null ? (rows == null || rows.size() == 0 ? 0 : rows.get(0).size())
- : columns.size());
- int r = (rows == null ? 0 : rows.size());
- writer.println("<table>");
- writer.println("<thead>");
- writer.println(" <tr>");
- writer.println(" <th colspan=\"" + c + "\">" + title + "</th>");
- writer.println(" </tr>");
- if (columns != null && columns.size() > 0) {
- writer.println(" <tr>");
- for (int i = 0; i < columns.size(); i++) {
- String col = columns.get(i);
- if (col.endsWith(":")) {
- col += " <input type=\"text\" id=\"in_"
- + n
- + "_"
- + i
- + "\" onkeyup=\"for (var i = 0; i < "
- + r
- + "; i ++) { var m = true; for (var j = 0; j < "
- + columns.size()
- + "; j ++) { if (document.getElementById('in_"
- + n
- + "_' + j)) { var iv = document.getElementById('in_"
- + n
- + "_' + j).value; var tv = document.getElementById('td_"
- + n
- + "_' + i + '_' + j).innerHTML; if (iv.length > 0 && (tv.length < iv.length || tv.indexOf(iv) == -1)) { m = false; break; } } } document.getElementById('tr_"
- + n
- + "_' + i).style.display = (m ? '' : 'none');}\" sytle=\"width: 100%\" />";
- }
- writer.println(" <td>" + col + "</td>");
- }
- writer.println(" </tr>");
- }
- writer.println("</thead>");
- if (rows != null && rows.size() > 0) {
- writer.println("<tbody>");
- int i = 0;
- for (Collection<String> row : rows) {
- writer.println(" <tr id=\"tr_" + n + "_" + i + "\">");
- int j = 0;
- for (String col : row) {
- writer.println(" <td id=\"td_" + n + "_" + i + "_" + j
- + "\" style=\"display: ;\">" + col + "</td>");
- j++;
- }
- writer.println(" </tr>");
- i++;
- }
- writer.println("</tbody>");
- }
- writer.println("</table>");
- writer.println("<br/>");
- }
-
+/*
+ * 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.container.page;
+
+import com.alibaba.dubbo.common.Constants;
+import com.alibaba.dubbo.common.URL;
+import com.alibaba.dubbo.common.extension.ExtensionLoader;
+import com.alibaba.dubbo.common.logger.Logger;
+import com.alibaba.dubbo.common.logger.LoggerFactory;
+import com.alibaba.dubbo.common.utils.StringUtils;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * PageServlet
+ */
+public class PageServlet extends HttpServlet {
+
+ protected static final Logger logger = LoggerFactory.getLogger(PageServlet.class);
+ private static final long serialVersionUID = -8370312705453328501L;
+ private static PageServlet INSTANCE;
+ protected final Random random = new Random();
+ protected final Map<String, PageHandler> pages = new ConcurrentHashMap<String, PageHandler>();
+ protected final List<PageHandler> menus = new ArrayList<PageHandler>();
+
+ public static PageServlet getInstance() {
+ return INSTANCE;
+ }
+
+ public List<PageHandler> getMenus() {
+ return Collections.unmodifiableList(menus);
+ }
+
+ @Override
+ public void init() throws ServletException {
+ super.init();
+ INSTANCE = this;
+ String config = getServletConfig().getInitParameter("pages");
+ Collection<String> names;
+ if (config != null && config.length() > 0) {
+ names = Arrays.asList(Constants.COMMA_SPLIT_PATTERN.split(config));
+ } else {
+ names = ExtensionLoader.getExtensionLoader(PageHandler.class).getSupportedExtensions();
+ }
+ for (String name : names) {
+ PageHandler handler = ExtensionLoader.getExtensionLoader(PageHandler.class).getExtension(name);
+ pages.put(ExtensionLoader.getExtensionLoader(PageHandler.class).getExtensionName(handler), handler);
+ Menu menu = handler.getClass().getAnnotation(Menu.class);
+ if (menu != null) {
+ menus.add(handler);
+ }
+ }
+ Collections.sort(menus, new MenuComparator());
+ }
+
+ @Override
+ protected final void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ protected final void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ if (!response.isCommitted()) {
+ PrintWriter writer = response.getWriter();
+ String uri = request.getRequestURI();
+ boolean isHtml = false;
+ if (uri == null || uri.length() == 0 || "/".equals(uri)) {
+ uri = "index";
+ isHtml = true;
+ } else {
+ if (uri.startsWith("/")) {
+ uri = uri.substring(1);
+ }
+ if (uri.endsWith(".html")) {
+ uri = uri.substring(0, uri.length() - ".html".length());
+ isHtml = true;
+ }
+ }
+ if (uri.endsWith("favicon.ico")) {
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
+ return;
+ }
+ ExtensionLoader<PageHandler> pageHandlerLoader = ExtensionLoader.getExtensionLoader(PageHandler.class);
+ PageHandler pageHandler = pageHandlerLoader.hasExtension(uri) ? pageHandlerLoader.getExtension(uri) : null;
+ if (isHtml) {
+ writer.println("<html><head><title>Dubbo</title>");
+ writer.println("<style type=\"text/css\">html, body {margin: 10;padding: 0;background-color: #6D838C;font-family: Arial, Verdana;font-size: 12px;color: #FFFFFF;text-align: center;vertical-align: middle;word-break: break-all; } table {width: 90%; margin: 0px auto;border-collapse: collapse;border: 8px solid #FFFFFF; } thead tr {background-color: #253c46; } tbody tr {background-color: #8da5af; } th {padding-top: 4px;padding-bottom: 4px;font-size: 14px;height: 20px; } td {margin: 3px;padding: 3px;border: 2px solid #FFFFFF;font-size: 14px;height: 25px; } a {color: #FFFFFF;cursor: pointer;text-decoration: underline; } a:hover {text-decoration: none; }</style>");
+ writer.println("</head><body>");
+ }
+ if (pageHandler != null) {
+ Page page = null;
+ try {
+ String query = request.getQueryString();
+ page = pageHandler.handle(URL.valueOf(request.getRequestURL().toString()
+ + (query == null || query.length() == 0 ? "" : "?" + query)));
+ } catch (Throwable t) {
+ logger.warn(t.getMessage(), t);
+ String msg = t.getMessage();
+ if (msg == null) {
+ msg = StringUtils.toString(t);
+ }
+ if (isHtml) {
+ writer.println("<table>");
+ writer.println("<thead>");
+ writer.println(" <tr>");
+ writer.println(" <th>Error</th>");
+ writer.println(" </tr>");
+ writer.println("</thead>");
+ writer.println("<tbody>");
+ writer.println(" <tr>");
+ writer.println(" <td>");
+ writer.println(" " + msg.replace("<", "<").replace(">", "<").replace("\n", "<br/>"));
+ writer.println(" </td>");
+ writer.println(" </tr>");
+ writer.println("</tbody>");
+ writer.println("</table>");
+ writer.println("<br/>");
+ } else {
+ writer.println(msg);
+ }
+ }
+ if (page != null) {
+ if (isHtml) {
+ String nav = page.getNavigation();
+ if (nav == null || nav.length() == 0) {
+ nav = ExtensionLoader.getExtensionLoader(PageHandler.class).getExtensionName(pageHandler);
+ nav = nav.substring(0, 1).toUpperCase() + nav.substring(1);
+ }
+ if (!"index".equals(uri)) {
+ nav = "<a href=\"/\">Home</a> > " + nav;
+ }
+ writeMenu(request, writer, nav);
+ writeTable(writer, page.getTitle(), page.getColumns(),
+ page.getRows());
+ } else {
+ if (page.getRows().size() > 0 && page.getRows().get(0).size() > 0) {
+ writer.println(page.getRows().get(0).get(0));
+ }
+ }
+ }
+ } else {
+ if (isHtml) {
+ writer.println("<table>");
+ writer.println("<thead>");
+ writer.println(" <tr>");
+ writer.println(" <th>Error</th>");
+ writer.println(" </tr>");
+ writer.println("</thead>");
+ writer.println("<tbody>");
+ writer.println(" <tr>");
+ writer.println(" <td>");
+ writer.println(" Not found " + uri + " page. Please goto <a href=\"/\">Home</a> page.");
+ writer.println(" </td>");
+ writer.println(" </tr>");
+ writer.println("</tbody>");
+ writer.println("</table>");
+ writer.println("<br/>");
+ } else {
+ writer.println("Not found " + uri + " page.");
+ }
+ }
+ if (isHtml) {
+ writer.println("</body></html>");
+ }
+ writer.flush();
+ }
+ }
+
+ protected final void writeMenu(HttpServletRequest request, PrintWriter writer, String nav) {
+ writer.println("<table>");
+ writer.println("<thead>");
+ writer.println(" <tr>");
+ for (PageHandler handler : menus) {
+ String uri = ExtensionLoader.getExtensionLoader(PageHandler.class).getExtensionName(handler);
+ Menu menu = handler.getClass().getAnnotation(Menu.class);
+ writer.println(" <th><a href=\"" + uri + ".html\">" + menu.name() + "</a></th>");
+ }
+ writer.println(" </tr>");
+ writer.println("</thead>");
+ writer.println("<tbody>");
+ writer.println(" <tr>");
+ writer.println(" <td style=\"text-align: left\" colspan=\"" + menus.size() + "\">");
+ writer.println(nav);
+ writer.println(" </td>");
+ writer.println(" </tr>");
+ writer.println("</tbody>");
+ writer.println("</table>");
+ writer.println("<br/>");
+ }
+
+ protected final void writeTable(PrintWriter writer, String title, List<String> columns,
+ List<List<String>> rows) {
+ int n = random.nextInt();
+ int c = (columns == null ? (rows == null || rows.size() == 0 ? 0 : rows.get(0).size())
+ : columns.size());
+ int r = (rows == null ? 0 : rows.size());
+ writer.println("<table>");
+ writer.println("<thead>");
+ writer.println(" <tr>");
+ writer.println(" <th colspan=\"" + c + "\">" + title + "</th>");
+ writer.println(" </tr>");
+ if (columns != null && columns.size() > 0) {
+ writer.println(" <tr>");
+ for (int i = 0; i < columns.size(); i++) {
+ String col = columns.get(i);
+ if (col.endsWith(":")) {
+ col += " <input type=\"text\" id=\"in_"
+ + n
+ + "_"
+ + i
+ + "\" onkeyup=\"for (var i = 0; i < "
+ + r
+ + "; i ++) { var m = true; for (var j = 0; j < "
+ + columns.size()
+ + "; j ++) { if (document.getElementById('in_"
+ + n
+ + "_' + j)) { var iv = document.getElementById('in_"
+ + n
+ + "_' + j).value; var tv = document.getElementById('td_"
+ + n
+ + "_' + i + '_' + j).innerHTML; if (iv.length > 0 && (tv.length < iv.length || tv.indexOf(iv) == -1)) { m = false; break; } } } document.getElementById('tr_"
+ + n
+ + "_' + i).style.display = (m ? '' : 'none');}\" sytle=\"width: 100%\" />";
+ }
+ writer.println(" <td>" + col + "</td>");
+ }
+ writer.println(" </tr>");
+ }
+ writer.println("</thead>");
+ if (rows != null && rows.size() > 0) {
+ writer.println("<tbody>");
+ int i = 0;
+ for (Collection<String> row : rows) {
+ writer.println(" <tr id=\"tr_" + n + "_" + i + "\">");
+ int j = 0;
+ for (String col : row) {
+ writer.println(" <td id=\"td_" + n + "_" + i + "_" + j
+ + "\" style=\"display: ;\">" + col + "</td>");
+ j++;
+ }
+ writer.println(" </tr>");
+ i++;
+ }
+ writer.println("</tbody>");
+ }
+ writer.println("</table>");
+ writer.println("<br/>");
+ }
+
}
\ No newline at end of file
diff --git a/dubbo-container/dubbo-container-api/src/main/java/com/alibaba/dubbo/container/page/ResourceFilter.java b/dubbo-container/dubbo-container-api/src/main/java/com/alibaba/dubbo/container/page/ResourceFilter.java
index eefdafaa79..56a50dd966 100644
--- a/dubbo-container/dubbo-container-api/src/main/java/com/alibaba/dubbo/container/page/ResourceFilter.java
+++ b/dubbo-container/dubbo-container-api/src/main/java/com/alibaba/dubbo/container/page/ResourceFilter.java
@@ -1,151 +1,151 @@
-/*
- * 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.container.page;
-
-import com.alibaba.dubbo.common.Constants;
-
-import javax.servlet.Filter;
-import javax.servlet.FilterChain;
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * ResourceServlet
- */
-public class ResourceFilter implements Filter {
-
- private static final String CLASSPATH_PREFIX = "classpath:";
-
- private final long start = System.currentTimeMillis();
-
- private final List<String> resources = new ArrayList<String>();
-
- public void init(FilterConfig filterConfig) throws ServletException {
- String config = filterConfig.getInitParameter("resources");
- if (config != null && config.length() > 0) {
- String[] configs = Constants.COMMA_SPLIT_PATTERN.split(config);
- for (String c : configs) {
- if (c != null && c.length() > 0) {
- c = c.replace('\\', '/');
- if (c.endsWith("/")) {
- c = c.substring(0, c.length() - 1);
- }
- resources.add(c);
- }
- }
- }
- }
-
- public void destroy() {
- }
-
- public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
- throws IOException, ServletException {
- HttpServletRequest request = (HttpServletRequest) req;
- HttpServletResponse response = (HttpServletResponse) res;
- if (response.isCommitted()) {
- return;
- }
- String uri = request.getRequestURI();
- String context = request.getContextPath();
- if (uri.endsWith("/favicon.ico")) {
- uri = "/favicon.ico";
- } else if (context != null && !"/".equals(context)) {
- uri = uri.substring(context.length());
- }
- if (!uri.startsWith("/")) {
- uri = "/" + uri;
- }
- long lastModified = getLastModified(uri);
- long since = request.getDateHeader("If-Modified-Since");
- if (since >= lastModified) {
- response.sendError(HttpServletResponse.SC_NOT_MODIFIED);
- return;
- }
- byte[] data;
- InputStream input = getInputStream(uri);
- if (input == null) {
- chain.doFilter(req, res);
- return;
- }
- try {
- ByteArrayOutputStream output = new ByteArrayOutputStream();
- byte[] buffer = new byte[8192];
- int n = 0;
- while (-1 != (n = input.read(buffer))) {
- output.write(buffer, 0, n);
- }
- data = output.toByteArray();
- } finally {
- input.close();
- }
- response.setDateHeader("Last-Modified", lastModified);
- OutputStream output = response.getOutputStream();
- output.write(data);
- output.flush();
- }
-
- private boolean isFile(String path) {
- return path.startsWith("/") || path.indexOf(":") <= 1;
- }
-
- private long getLastModified(String uri) {
- for (String resource : resources) {
- if (resource != null && resource.length() > 0) {
- String path = resource + uri;
- if (isFile(path)) {
- File file = new File(path);
- if (file.exists()) {
- return file.lastModified();
- }
- }
- }
- }
- return start;
- }
-
- private InputStream getInputStream(String uri) {
- for (String resource : resources) {
- String path = resource + uri;
- try {
- if (isFile(path)) {
- return new FileInputStream(path);
- } else if (path.startsWith(CLASSPATH_PREFIX)) {
- return Thread.currentThread().getContextClassLoader().getResourceAsStream(path.substring(CLASSPATH_PREFIX.length()));
- } else {
- return new URL(path).openStream();
- }
- } catch (IOException e) {
- }
- }
- return null;
- }
-
+/*
+ * 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.container.page;
+
+import com.alibaba.dubbo.common.Constants;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * ResourceServlet
+ */
+public class ResourceFilter implements Filter {
+
+ private static final String CLASSPATH_PREFIX = "classpath:";
+
+ private final long start = System.currentTimeMillis();
+
+ private final List<String> resources = new ArrayList<String>();
+
+ public void init(FilterConfig filterConfig) throws ServletException {
+ String config = filterConfig.getInitParameter("resources");
+ if (config != null && config.length() > 0) {
+ String[] configs = Constants.COMMA_SPLIT_PATTERN.split(config);
+ for (String c : configs) {
+ if (c != null && c.length() > 0) {
+ c = c.replace('\\', '/');
+ if (c.endsWith("/")) {
+ c = c.substring(0, c.length() - 1);
+ }
+ resources.add(c);
+ }
+ }
+ }
+ }
+
+ public void destroy() {
+ }
+
+ public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
+ throws IOException, ServletException {
+ HttpServletRequest request = (HttpServletRequest) req;
+ HttpServletResponse response = (HttpServletResponse) res;
+ if (response.isCommitted()) {
+ return;
+ }
+ String uri = request.getRequestURI();
+ String context = request.getContextPath();
+ if (uri.endsWith("/favicon.ico")) {
+ uri = "/favicon.ico";
+ } else if (context != null && !"/".equals(context)) {
+ uri = uri.substring(context.length());
+ }
+ if (!uri.startsWith("/")) {
+ uri = "/" + uri;
+ }
+ long lastModified = getLastModified(uri);
+ long since = request.getDateHeader("If-Modified-Since");
+ if (since >= lastModified) {
+ response.sendError(HttpServletResponse.SC_NOT_MODIFIED);
+ return;
+ }
+ byte[] data;
+ InputStream input = getInputStream(uri);
+ if (input == null) {
+ chain.doFilter(req, res);
+ return;
+ }
+ try {
+ ByteArrayOutputStream output = new ByteArrayOutputStream();
+ byte[] buffer = new byte[8192];
+ int n = 0;
+ while (-1 != (n = input.read(buffer))) {
+ output.write(buffer, 0, n);
+ }
+ data = output.toByteArray();
+ } finally {
+ input.close();
+ }
+ response.setDateHeader("Last-Modified", lastModified);
+ OutputStream output = response.getOutputStream();
+ output.write(data);
+ output.flush();
+ }
+
+ private boolean isFile(String path) {
+ return path.startsWith("/") || path.indexOf(":") <= 1;
+ }
+
+ private long getLastModified(String uri) {
+ for (String resource : resources) {
+ if (resource != null && resource.length() > 0) {
+ String path = resource + uri;
+ if (isFile(path)) {
+ File file = new File(path);
+ if (file.exists()) {
+ return file.lastModified();
+ }
+ }
+ }
+ }
+ return start;
+ }
+
+ private InputStream getInputStream(String uri) {
+ for (String resource : resources) {
+ String path = resource + uri;
+ try {
+ if (isFile(path)) {
+ return new FileInputStream(path);
+ } else if (path.startsWith(CLASSPATH_PREFIX)) {
+ return Thread.currentThread().getContextClassLoader().getResourceAsStream(path.substring(CLASSPATH_PREFIX.length()));
+ } else {
+ return new URL(path).openStream();
+ }
+ } catch (IOException e) {
+ }
+ }
+ return null;
+ }
+
}
\ No newline at end of file
diff --git a/dubbo-container/dubbo-container-api/src/main/java/com/alibaba/dubbo/container/page/pages/HomePageHandler.java b/dubbo-container/dubbo-container-api/src/main/java/com/alibaba/dubbo/container/page/pages/HomePageHandler.java
index ce3e22782f..f69f0f1e0d 100644
--- a/dubbo-container/dubbo-container-api/src/main/java/com/alibaba/dubbo/container/page/pages/HomePageHandler.java
+++ b/dubbo-container/dubbo-container-api/src/main/java/com/alibaba/dubbo/container/page/pages/HomePageHandler.java
@@ -1,48 +1,48 @@
-/*
- * 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.container.page.pages;
-
-import com.alibaba.dubbo.common.URL;
-import com.alibaba.dubbo.common.extension.ExtensionLoader;
-import com.alibaba.dubbo.container.page.Menu;
-import com.alibaba.dubbo.container.page.Page;
-import com.alibaba.dubbo.container.page.PageHandler;
-import com.alibaba.dubbo.container.page.PageServlet;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * HomePageHandler
- */
-@Menu(name = "Home", desc = "Home page.", order = Integer.MIN_VALUE)
-public class HomePageHandler implements PageHandler {
-
- public Page handle(URL url) {
- List<List<String>> rows = new ArrayList<List<String>>();
- for (PageHandler handler : PageServlet.getInstance().getMenus()) {
- String uri = ExtensionLoader.getExtensionLoader(PageHandler.class).getExtensionName(handler);
- Menu menu = handler.getClass().getAnnotation(Menu.class);
- List<String> row = new ArrayList<String>();
- row.add("<a href=\"" + uri + ".html\">" + menu.name() + "</a>");
- row.add(menu.desc());
- rows.add(row);
- }
- return new Page("Home", "Menus", new String[]{"Menu Name", "Menu Desc"}, rows);
- }
-
+/*
+ * 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.container.page.pages;
+
+import com.alibaba.dubbo.common.URL;
+import com.alibaba.dubbo.common.extension.ExtensionLoader;
+import com.alibaba.dubbo.container.page.Menu;
+import com.alibaba.dubbo.container.page.Page;
+import com.alibaba.dubbo.container.page.PageHandler;
+import com.alibaba.dubbo.container.page.PageServlet;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * HomePageHandler
+ */
+@Menu(name = "Home", desc = "Home page.", order = Integer.MIN_VALUE)
+public class HomePageHandler implements PageHandler {
+
+ public Page handle(URL url) {
+ List<List<String>> rows = new ArrayList<List<String>>();
+ for (PageHandler handler : PageServlet.getInstance().getMenus()) {
+ String uri = ExtensionLoader.getExtensionLoader(PageHandler.class).getExtensionName(handler);
+ Menu menu = handler.getClass().getAnnotation(Menu.class);
+ List<String> row = new ArrayList<String>();
+ row.add("<a href=\"" + uri + ".html\">" + menu.name() + "</a>");
+ row.add(menu.desc());
+ rows.add(row);
+ }
+ return new Page("Home", "Menus", new String[]{"Menu Name", "Menu Desc"}, rows);
+ }
+
}
\ No newline at end of file
diff --git a/dubbo-container/dubbo-container-api/src/main/java/com/alibaba/dubbo/container/page/pages/LogPageHandler.java b/dubbo-container/dubbo-container-api/src/main/java/com/alibaba/dubbo/container/page/pages/LogPageHandler.java
index 5c7fecb8d7..82933f1016 100644
--- a/dubbo-container/dubbo-container-api/src/main/java/com/alibaba/dubbo/container/page/pages/LogPageHandler.java
+++ b/dubbo-container/dubbo-container-api/src/main/java/com/alibaba/dubbo/container/page/pages/LogPageHandler.java
@@ -1,106 +1,106 @@
-/*
- * 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.container.page.pages;
-
-import com.alibaba.dubbo.common.URL;
-import com.alibaba.dubbo.container.page.Menu;
-import com.alibaba.dubbo.container.page.Page;
-import com.alibaba.dubbo.container.page.PageHandler;
-
-import org.apache.log4j.Appender;
-import org.apache.log4j.FileAppender;
-import org.apache.log4j.Level;
-import org.apache.log4j.LogManager;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.nio.channels.FileChannel;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.Enumeration;
-import java.util.List;
-
-/**
- * LogPageHandler
- */
-@Menu(name = "Log", desc = "Show system log.", order = Integer.MAX_VALUE - 11000)
-public class LogPageHandler implements PageHandler {
-
- private static final int SHOW_LOG_LENGTH = 30000;
-
- private File file;
-
- @SuppressWarnings("unchecked")
- public LogPageHandler() {
- try {
- org.apache.log4j.Logger logger = LogManager.getRootLogger();
- if (logger != null) {
- Enumeration<Appender> appenders = logger.getAllAppenders();
- if (appenders != null) {
- while (appenders.hasMoreElements()) {
- Appender appender = appenders.nextElement();
- if (appender instanceof FileAppender) {
- FileAppender fileAppender = (FileAppender) appender;
- String filename = fileAppender.getFile();
- file = new File(filename);
- break;
- }
- }
- }
- }
- } catch (Throwable t) {
- }
- }
-
- public Page handle(URL url) {
- long size = 0;
- String content = "";
- String modified = "Not exist";
- if (file != null && file.exists()) {
- try {
- FileInputStream fis = new FileInputStream(file);
- FileChannel channel = fis.getChannel();
- size = channel.size();
- ByteBuffer bb;
- if (size <= SHOW_LOG_LENGTH) {
- bb = ByteBuffer.allocate((int) size);
- channel.read(bb, 0);
- } else {
- int pos = (int) (size - SHOW_LOG_LENGTH);
- bb = ByteBuffer.allocate(SHOW_LOG_LENGTH);
- channel.read(bb, pos);
- }
- bb.flip();
- content = new String(bb.array()).replace("<", "<")
- .replace(">", ">").replace("\n", "<br/><br/>");
- modified = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
- .format(new Date(file.lastModified()));
- } catch (IOException e) {
- }
- }
- Level level = LogManager.getRootLogger().getLevel();
- List<List<String>> rows = new ArrayList<List<String>>();
- List<String> row = new ArrayList<String>();
- row.add(content);
- rows.add(row);
- return new Page("Log", "Log", new String[]{(file == null ? "" : file.getName()) + ", " + size + " bytes, " + modified + ", " + level}, rows);
- }
-
+/*
+ * 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.container.page.pages;
+
+import com.alibaba.dubbo.common.URL;
+import com.alibaba.dubbo.container.page.Menu;
+import com.alibaba.dubbo.container.page.Page;
+import com.alibaba.dubbo.container.page.PageHandler;
+
+import org.apache.log4j.Appender;
+import org.apache.log4j.FileAppender;
+import org.apache.log4j.Level;
+import org.apache.log4j.LogManager;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.channels.FileChannel;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Enumeration;
+import java.util.List;
+
+/**
+ * LogPageHandler
+ */
+@Menu(name = "Log", desc = "Show system log.", order = Integer.MAX_VALUE - 11000)
+public class LogPageHandler implements PageHandler {
+
+ private static final int SHOW_LOG_LENGTH = 30000;
+
+ private File file;
+
+ @SuppressWarnings("unchecked")
+ public LogPageHandler() {
+ try {
+ org.apache.log4j.Logger logger = LogManager.getRootLogger();
+ if (logger != null) {
+ Enumeration<Appender> appenders = logger.getAllAppenders();
+ if (appenders != null) {
+ while (appenders.hasMoreElements()) {
+ Appender appender = appenders.nextElement();
+ if (appender instanceof FileAppender) {
+ FileAppender fileAppender = (FileAppender) appender;
+ String filename = fileAppender.getFile();
+ file = new File(filename);
+ break;
+ }
+ }
+ }
+ }
+ } catch (Throwable t) {
+ }
+ }
+
+ public Page handle(URL url) {
+ long size = 0;
+ String content = "";
+ String modified = "Not exist";
+ if (file != null && file.exists()) {
+ try {
+ FileInputStream fis = new FileInputStream(file);
+ FileChannel channel = fis.getChannel();
+ size = channel.size();
+ ByteBuffer bb;
+ if (size <= SHOW_LOG_LENGTH) {
+ bb = ByteBuffer.allocate((int) size);
+ channel.read(bb, 0);
+ } else {
+ int pos = (int) (size - SHOW_LOG_LENGTH);
+ bb = ByteBuffer.allocate(SHOW_LOG_LENGTH);
+ channel.read(bb, pos);
+ }
+ bb.flip();
+ content = new String(bb.array()).replace("<", "<")
+ .replace(">", ">").replace("\n", "<br/><br/>");
+ modified = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
+ .format(new Date(file.lastModified()));
+ } catch (IOException e) {
+ }
+ }
+ Level level = LogManager.getRootLogger().getLevel();
+ List<List<String>> rows = new ArrayList<List<String>>();
+ List<String> row = new ArrayList<String>();
+ row.add(content);
+ rows.add(row);
+ return new Page("Log", "Log", new String[]{(file == null ? "" : file.getName()) + ", " + size + " bytes, " + modified + ", " + level}, rows);
+ }
+
}
\ No newline at end of file
diff --git a/dubbo-container/dubbo-container-api/src/main/java/com/alibaba/dubbo/container/page/pages/StatusPageHandler.java b/dubbo-container/dubbo-container-api/src/main/java/com/alibaba/dubbo/container/page/pages/StatusPageHandler.java
index d3c4246092..4517647283 100644
--- a/dubbo-container/dubbo-container-api/src/main/java/com/alibaba/dubbo/container/page/pages/StatusPageHandler.java
+++ b/dubbo-container/dubbo-container-api/src/main/java/com/alibaba/dubbo/container/page/pages/StatusPageHandler.java
@@ -1,84 +1,84 @@
-/*
- * 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.container.page.pages;
-
-import com.alibaba.dubbo.common.URL;
-import com.alibaba.dubbo.common.extension.ExtensionLoader;
-import com.alibaba.dubbo.common.status.Status;
-import com.alibaba.dubbo.common.status.StatusChecker;
-import com.alibaba.dubbo.common.status.support.StatusUtils;
-import com.alibaba.dubbo.container.page.Menu;
-import com.alibaba.dubbo.container.page.Page;
-import com.alibaba.dubbo.container.page.PageHandler;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * StatusPageHandler
- */
-@Menu(name = "Status", desc = "Show system status.", order = Integer.MAX_VALUE - 12000)
-public class StatusPageHandler implements PageHandler {
-
- public Page handle(URL url) {
- List<List<String>> rows = new ArrayList<List<String>>();
- Set<String> names = ExtensionLoader.getExtensionLoader(StatusChecker.class).getSupportedExtensions();
- Map<String, Status> statuses = new HashMap<String, Status>();
- for (String name : names) {
- StatusChecker checker = ExtensionLoader.getExtensionLoader(StatusChecker.class).getExtension(name);
- List<String> row = new ArrayList<String>();
- row.add(name);
- Status status = checker.check();
- if (status != null && !Status.Level.UNKNOWN.equals(status.getLevel())) {
- statuses.put(name, status);
- row.add(getLevelHtml(status.getLevel()));
- row.add(status.getMessage());
- rows.add(row);
- }
- }
- Status status = StatusUtils.getSummaryStatus(statuses);
- if ("status".equals(url.getPath())) {
- return new Page("", "", "", status.getLevel().toString());
- } else {
- List<String> row = new ArrayList<String>();
- row.add("summary");
- row.add(getLevelHtml(status.getLevel()));
- row.add("<a href=\"/status\" target=\"_blank\">summary</a>");
- rows.add(row);
- return new Page("Status (<a href=\"/status\" target=\"_blank\">summary</a>)", "Status", new String[]{"Name", "Status", "Description"}, rows);
- }
- }
-
- private String getLevelHtml(Status.Level level) {
- return "<font color=\"" + getLevelColor(level) + "\">" + level.name() + "</font>";
- }
-
- private String getLevelColor(Status.Level level) {
- if (level == Status.Level.OK) {
- return "green";
- } else if (level == Status.Level.ERROR) {
- return "red";
- } else if (level == Status.Level.WARN) {
- return "yellow";
- }
- return "gray";
- }
-
+/*
+ * 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.container.page.pages;
+
+import com.alibaba.dubbo.common.URL;
+import com.alibaba.dubbo.common.extension.ExtensionLoader;
+import com.alibaba.dubbo.common.status.Status;
+import com.alibaba.dubbo.common.status.StatusChecker;
+import com.alibaba.dubbo.common.status.support.StatusUtils;
+import com.alibaba.dubbo.container.page.Menu;
+import com.alibaba.dubbo.container.page.Page;
+import com.alibaba.dubbo.container.page.PageHandler;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * StatusPageHandler
+ */
+@Menu(name = "Status", desc = "Show system status.", order = Integer.MAX_VALUE - 12000)
+public class StatusPageHandler implements PageHandler {
+
+ public Page handle(URL url) {
+ List<List<String>> rows = new ArrayList<List<String>>();
+ Set<String> names = ExtensionLoader.getExtensionLoader(StatusChecker.class).getSupportedExtensions();
+ Map<String, Status> statuses = new HashMap<String, Status>();
+ for (String name : names) {
+ StatusChecker checker = ExtensionLoader.getExtensionLoader(StatusChecker.class).getExtension(name);
+ List<String> row = new ArrayList<String>();
+ row.add(name);
+ Status status = checker.check();
+ if (status != null && !Status.Level.UNKNOWN.equals(status.getLevel())) {
+ statuses.put(name, status);
+ row.add(getLevelHtml(status.getLevel()));
+ row.add(status.getMessage());
+ rows.add(row);
+ }
+ }
+ Status status = StatusUtils.getSummaryStatus(statuses);
+ if ("status".equals(url.getPath())) {
+ return new Page("", "", "", status.getLevel().toString());
+ } else {
+ List<String> row = new ArrayList<String>();
+ row.add("summary");
+ row.add(getLevelHtml(status.getLevel()));
+ row.add("<a href=\"/status\" target=\"_blank\">summary</a>");
+ rows.add(row);
+ return new Page("Status (<a href=\"/status\" target=\"_blank\">summary</a>)", "Status", new String[]{"Name", "Status", "Description"}, rows);
+ }
+ }
+
+ private String getLevelHtml(Status.Level level) {
+ return "<font color=\"" + getLevelColor(level) + "\">" + level.name() + "</font>";
+ }
+
+ private String getLevelColor(Status.Level level) {
+ if (level == Status.Level.OK) {
+ return "green";
+ } else if (level == Status.Level.ERROR) {
+ return "red";
+ } else if (level == Status.Level.WARN) {
+ return "yellow";
+ }
+ return "gray";
+ }
+
}
\ No newline at end of file
diff --git a/dubbo-container/dubbo-container-api/src/main/java/com/alibaba/dubbo/container/page/pages/SystemPageHandler.java b/dubbo-container/dubbo-container-api/src/main/java/com/alibaba/dubbo/container/page/pages/SystemPageHandler.java
index 24c7baf3f0..06b7ab5cfb 100644
--- a/dubbo-container/dubbo-container-api/src/main/java/com/alibaba/dubbo/container/page/pages/SystemPageHandler.java
+++ b/dubbo-container/dubbo-container-api/src/main/java/com/alibaba/dubbo/container/page/pages/SystemPageHandler.java
@@ -1,137 +1,137 @@
-/*
- * 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.container.page.pages;
-
-import com.alibaba.dubbo.common.URL;
-import com.alibaba.dubbo.common.Version;
-import com.alibaba.dubbo.common.utils.NetUtils;
-import com.alibaba.dubbo.container.page.Menu;
-import com.alibaba.dubbo.container.page.Page;
-import com.alibaba.dubbo.container.page.PageHandler;
-
-import java.lang.management.ManagementFactory;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Locale;
-
-/**
- * SystemPageHandler
- */
-@Menu(name = "System", desc = "Show system environment information.", order = Integer.MAX_VALUE - 10000)
-public class SystemPageHandler implements PageHandler {
-
- private static final long SECOND = 1000;
- private static final long MINUTE = 60 * SECOND;
- private static final long HOUR = 60 * MINUTE;
- private static final long DAY = 24 * HOUR;
-
- public Page handle(URL url) {
- List<List<String>> rows = new ArrayList<List<String>>();
- List<String> row;
-
- row = new ArrayList<String>();
- row.add("Version");
- row.add(Version.getVersion(SystemPageHandler.class, "2.0.0"));
- rows.add(row);
-
- row = new ArrayList<String>();
- row.add("Host");
- String address = NetUtils.getLocalHost();
- row.add(NetUtils.getHostName(address) + "/" + address);
- rows.add(row);
-
- row = new ArrayList<String>();
- row.add("OS");
- row.add(System.getProperty("os.name") + " " + System.getProperty("os.version"));
- rows.add(row);
-
- row = new ArrayList<String>();
- row.add("JVM");
- row.add(System.getProperty("java.runtime.name") + " " + System.getProperty("java.runtime.version") + ",<br/>" + System.getProperty("java.vm.name") + " " + System.getProperty("java.vm.version") + " " + System.getProperty("java.vm.info", ""));
- rows.add(row);
-
- row = new ArrayList<String>();
- row.add("CPU");
- row.add(System.getProperty("os.arch", "") + ", " + String.valueOf(Runtime.getRuntime().availableProcessors()) + " cores");
- rows.add(row);
-
- row = new ArrayList<String>();
- row.add("Locale");
- row.add(Locale.getDefault().toString() + "/" + System.getProperty("file.encoding"));
- rows.add(row);
-
- row = new ArrayList<String>();
- row.add("Uptime");
- row.add(formatUptime(ManagementFactory.getRuntimeMXBean().getUptime()));
- rows.add(row);
-
- row = new ArrayList<String>();
- row.add("Time");
- row.add(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS Z").format(new Date()));
- rows.add(row);
-
- return new Page("System", "System", new String[]{
- "Property", "Value"}, rows);
- }
-
- private String formatUptime(long uptime) {
- StringBuilder buf = new StringBuilder();
- if (uptime > DAY) {
- long days = (uptime - uptime % DAY) / DAY;
- buf.append(days);
- buf.append(" Days");
- uptime = uptime % DAY;
- }
- if (uptime > HOUR) {
- long hours = (uptime - uptime % HOUR) / HOUR;
- if (buf.length() > 0) {
- buf.append(", ");
- }
- buf.append(hours);
- buf.append(" Hours");
- uptime = uptime % HOUR;
- }
- if (uptime > MINUTE) {
- long minutes = (uptime - uptime % MINUTE) / MINUTE;
- if (buf.length() > 0) {
- buf.append(", ");
- }
- buf.append(minutes);
- buf.append(" Minutes");
- uptime = uptime % MINUTE;
- }
- if (uptime > SECOND) {
- long seconds = (uptime - uptime % SECOND) / SECOND;
- if (buf.length() > 0) {
- buf.append(", ");
- }
- buf.append(seconds);
- buf.append(" Seconds");
- uptime = uptime % SECOND;
- }
- if (uptime > 0) {
- if (buf.length() > 0) {
- buf.append(", ");
- }
- buf.append(uptime);
- buf.append(" Milliseconds");
- }
- return buf.toString();
- }
+/*
+ * 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.container.page.pages;
+
+import com.alibaba.dubbo.common.URL;
+import com.alibaba.dubbo.common.Version;
+import com.alibaba.dubbo.common.utils.NetUtils;
+import com.alibaba.dubbo.container.page.Menu;
+import com.alibaba.dubbo.container.page.Page;
+import com.alibaba.dubbo.container.page.PageHandler;
+
+import java.lang.management.ManagementFactory;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Locale;
+
+/**
+ * SystemPageHandler
+ */
+@Menu(name = "System", desc = "Show system environment information.", order = Integer.MAX_VALUE - 10000)
+public class SystemPageHandler implements PageHandler {
+
+ private static final long SECOND = 1000;
+ private static final long MINUTE = 60 * SECOND;
+ private static final long HOUR = 60 * MINUTE;
+ private static final long DAY = 24 * HOUR;
+
+ public Page handle(URL url) {
+ List<List<String>> rows = new ArrayList<List<String>>();
+ List<String> row;
+
+ row = new ArrayList<String>();
+ row.add("Version");
+ row.add(Version.getVersion(SystemPageHandler.class, "2.0.0"));
+ rows.add(row);
+
+ row = new ArrayList<String>();
+ row.add("Host");
+ String address = NetUtils.getLocalHost();
+ row.add(NetUtils.getHostName(address) + "/" + address);
+ rows.add(row);
+
+ row = new ArrayList<String>();
+ row.add("OS");
+ row.add(System.getProperty("os.name") + " " + System.getProperty("os.version"));
+ rows.add(row);
+
+ row = new ArrayList<String>();
+ row.add("JVM");
+ row.add(System.getProperty("java.runtime.name") + " " + System.getProperty("java.runtime.version") + ",<br/>" + System.getProperty("java.vm.name") + " " + System.getProperty("java.vm.version") + " " + System.getProperty("java.vm.info", ""));
+ rows.add(row);
+
+ row = new ArrayList<String>();
+ row.add("CPU");
+ row.add(System.getProperty("os.arch", "") + ", " + String.valueOf(Runtime.getRuntime().availableProcessors()) + " cores");
+ rows.add(row);
+
+ row = new ArrayList<String>();
+ row.add("Locale");
+ row.add(Locale.getDefault().toString() + "/" + System.getProperty("file.encoding"));
+ rows.add(row);
+
+ row = new ArrayList<String>();
+ row.add("Uptime");
+ row.add(formatUptime(ManagementFactory.getRuntimeMXBean().getUptime()));
+ rows.add(row);
+
+ row = new ArrayList<String>();
+ row.add("Time");
+ row.add(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS Z").format(new Date()));
+ rows.add(row);
+
+ return new Page("System", "System", new String[]{
+ "Property", "Value"}, rows);
+ }
+
+ private String formatUptime(long uptime) {
+ StringBuilder buf = new StringBuilder();
+ if (uptime > DAY) {
+ long days = (uptime - uptime % DAY) / DAY;
+ buf.append(days);
+ buf.append(" Days");
+ uptime = uptime % DAY;
+ }
+ if (uptime > HOUR) {
+ long hours = (uptime - uptime % HOUR) / HOUR;
+ if (buf.length() > 0) {
+ buf.append(", ");
+ }
+ buf.append(hours);
+ buf.append(" Hours");
+ uptime = uptime % HOUR;
+ }
+ if (uptime > MINUTE) {
+ long minutes = (uptime - uptime % MINUTE) / MINUTE;
+ if (buf.length() > 0) {
+ buf.append(", ");
+ }
+ buf.append(minutes);
+ buf.append(" Minutes");
+ uptime = uptime % MINUTE;
+ }
+ if (uptime > SECOND) {
+ long seconds = (uptime - uptime % SECOND) / SECOND;
+ if (buf.length() > 0) {
+ buf.append(", ");
+ }
+ buf.append(seconds);
+ buf.append(" Seconds");
+ uptime = uptime % SECOND;
+ }
+ if (uptime > 0) {
+ if (buf.length() > 0) {
+ buf.append(", ");
+ }
+ buf.append(uptime);
+ buf.append(" Milliseconds");
+ }
+ return buf.toString();
+ }
}
\ No newline at end of file
diff --git a/dubbo-container/dubbo-container-api/src/main/resources/META-INF/dubbo/internal/com.alibaba.dubbo.container.page.PageHandler b/dubbo-container/dubbo-container-api/src/main/resources/META-INF/dubbo/internal/com.alibaba.dubbo.container.page.PageHandler
index e1c39d6ca8..98558f3a24 100644
--- a/dubbo-container/dubbo-container-api/src/main/resources/META-INF/dubbo/internal/com.alibaba.dubbo.container.page.PageHandler
+++ b/dubbo-container/dubbo-container-api/src/main/resources/META-INF/dubbo/internal/com.alibaba.dubbo.container.page.PageHandler
@@ -1,4 +1,4 @@
-index=com.alibaba.dubbo.container.page.pages.HomePageHandler
-status=com.alibaba.dubbo.container.page.pages.StatusPageHandler
-log=com.alibaba.dubbo.container.page.pages.LogPageHandler
+index=com.alibaba.dubbo.container.page.pages.HomePageHandler
+status=com.alibaba.dubbo.container.page.pages.StatusPageHandler
+log=com.alibaba.dubbo.container.page.pages.LogPageHandler
system=com.alibaba.dubbo.container.page.pages.SystemPageHandler
\ No newline at end of file
diff --git a/dubbo-container/dubbo-container-jetty/pom.xml b/dubbo-container/dubbo-container-jetty/pom.xml
index 53e81e08e9..7e6d55084b 100644
--- a/dubbo-container/dubbo-container-jetty/pom.xml
+++ b/dubbo-container/dubbo-container-jetty/pom.xml
@@ -1,39 +1,39 @@
-<!--
-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.
--->
-<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>com.alibaba</groupId>
- <artifactId>dubbo-container</artifactId>
- <version>2.5.10</version>
- </parent>
- <artifactId>dubbo-container-jetty</artifactId>
- <packaging>jar</packaging>
- <name>${project.artifactId}</name>
- <description>The jetty container module of dubbo project</description>
- <properties>
- <skip_maven_deploy>true</skip_maven_deploy>
- </properties>
- <dependencies>
- <dependency>
- <groupId>com.alibaba</groupId>
- <artifactId>dubbo-container-api</artifactId>
- <version>${project.parent.version}</version>
- </dependency>
- </dependencies>
+<!--
+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.
+-->
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>com.alibaba</groupId>
+ <artifactId>dubbo-container</artifactId>
+ <version>2.5.11</version>
+ </parent>
+ <artifactId>dubbo-container-jetty</artifactId>
+ <packaging>jar</packaging>
+ <name>${project.artifactId}</name>
+ <description>The jetty container module of dubbo project</description>
+ <properties>
+ <skip_maven_deploy>true</skip_maven_deploy>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>com.alibaba</groupId>
+ <artifactId>dubbo-container-api</artifactId>
+ <version>${project.parent.version}</version>
+ </dependency>
+ </dependencies>
</project>
\ No newline at end of file
diff --git a/dubbo-container/dubbo-container-jetty/src/main/java/com/alibaba/dubbo/container/jetty/JettyContainer.java b/dubbo-container/dubbo-container-jetty/src/main/java/com/alibaba/dubbo/container/jetty/JettyContainer.java
index 7f0563f5c3..e340942e2e 100644
--- a/dubbo-container/dubbo-container-jetty/src/main/java/com/alibaba/dubbo/container/jetty/JettyContainer.java
+++ b/dubbo-container/dubbo-container-jetty/src/main/java/com/alibaba/dubbo/container/jetty/JettyContainer.java
@@ -1,89 +1,89 @@
-/*
- * 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.container.jetty;
-
-import com.alibaba.dubbo.common.logger.Logger;
-import com.alibaba.dubbo.common.logger.LoggerFactory;
-import com.alibaba.dubbo.common.utils.ConfigUtils;
-import com.alibaba.dubbo.common.utils.NetUtils;
-import com.alibaba.dubbo.container.Container;
-import com.alibaba.dubbo.container.page.PageServlet;
-import com.alibaba.dubbo.container.page.ResourceFilter;
-
-import org.mortbay.jetty.Handler;
-import org.mortbay.jetty.Server;
-import org.mortbay.jetty.nio.SelectChannelConnector;
-import org.mortbay.jetty.servlet.FilterHolder;
-import org.mortbay.jetty.servlet.ServletHandler;
-import org.mortbay.jetty.servlet.ServletHolder;
-
-/**
- * JettyContainer. (SPI, Singleton, ThreadSafe)
- */
-public class JettyContainer implements Container {
-
- public static final String JETTY_PORT = "dubbo.jetty.port";
- public static final String JETTY_DIRECTORY = "dubbo.jetty.directory";
- public static final String JETTY_PAGES = "dubbo.jetty.page";
- public static final int DEFAULT_JETTY_PORT = 8080;
- private static final Logger logger = LoggerFactory.getLogger(JettyContainer.class);
- SelectChannelConnector connector;
-
- public void start() {
- String serverPort = ConfigUtils.getProperty(JETTY_PORT);
- int port;
- if (serverPort == null || serverPort.length() == 0) {
- port = DEFAULT_JETTY_PORT;
- } else {
- port = Integer.parseInt(serverPort);
- }
- connector = new SelectChannelConnector();
- connector.setPort(port);
- ServletHandler handler = new ServletHandler();
-
- String resources = ConfigUtils.getProperty(JETTY_DIRECTORY);
- if (resources != null && resources.length() > 0) {
- FilterHolder resourceHolder = handler.addFilterWithMapping(ResourceFilter.class, "/*", Handler.DEFAULT);
- resourceHolder.setInitParameter("resources", resources);
- }
-
- ServletHolder pageHolder = handler.addServletWithMapping(PageServlet.class, "/*");
- pageHolder.setInitParameter("pages", ConfigUtils.getProperty(JETTY_PAGES));
- pageHolder.setInitOrder(2);
-
- Server server = new Server();
- server.addConnector(connector);
- server.addHandler(handler);
- try {
- server.start();
- } catch (Exception e) {
- throw new IllegalStateException("Failed to start jetty server on " + NetUtils.getLocalHost() + ":" + port + ", cause: " + e.getMessage(), e);
- }
- }
-
- public void stop() {
- try {
- if (connector != null) {
- connector.close();
- connector = null;
- }
- } catch (Throwable e) {
- logger.error(e.getMessage(), e);
- }
- }
-
+/*
+ * 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.container.jetty;
+
+import com.alibaba.dubbo.common.logger.Logger;
+import com.alibaba.dubbo.common.logger.LoggerFactory;
+import com.alibaba.dubbo.common.utils.ConfigUtils;
+import com.alibaba.dubbo.common.utils.NetUtils;
+import com.alibaba.dubbo.container.Container;
+import com.alibaba.dubbo.container.page.PageServlet;
+import com.alibaba.dubbo.container.page.ResourceFilter;
+
+import org.mortbay.jetty.Handler;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.nio.SelectChannelConnector;
+import org.mortbay.jetty.servlet.FilterHolder;
+import org.mortbay.jetty.servlet.ServletHandler;
+import org.mortbay.jetty.servlet.ServletHolder;
+
+/**
+ * JettyContainer. (SPI, Singleton, ThreadSafe)
+ */
+public class JettyContainer implements Container {
+
+ public static final String JETTY_PORT = "dubbo.jetty.port";
+ public static final String JETTY_DIRECTORY = "dubbo.jetty.directory";
+ public static final String JETTY_PAGES = "dubbo.jetty.page";
+ public static final int DEFAULT_JETTY_PORT = 8080;
+ private static final Logger logger = LoggerFactory.getLogger(JettyContainer.class);
+ SelectChannelConnector connector;
+
+ public void start() {
+ String serverPort = ConfigUtils.getProperty(JETTY_PORT);
+ int port;
+ if (serverPort == null || serverPort.length() == 0) {
+ port = DEFAULT_JETTY_PORT;
+ } else {
+ port = Integer.parseInt(serverPort);
+ }
+ connector = new SelectChannelConnector();
+ connector.setPort(port);
+ ServletHandler handler = new ServletHandler();
+
+ String resources = ConfigUtils.getProperty(JETTY_DIRECTORY);
+ if (resources != null && resources.length() > 0) {
+ FilterHolder resourceHolder = handler.addFilterWithMapping(ResourceFilter.class, "/*", Handler.DEFAULT);
+ resourceHolder.setInitParameter("resources", resources);
+ }
+
+ ServletHolder pageHolder = handler.addServletWithMapping(PageServlet.class, "/*");
+ pageHolder.setInitParameter("pages", ConfigUtils.getProperty(JETTY_PAGES));
+ pageHolder.setInitOrder(2);
+
+ Server server = new Server();
+ server.addConnector(connector);
+ server.addHandler(handler);
+ try {
+ server.start();
+ } catch (Exception e) {
+ throw new IllegalStateException("Failed to start jetty server on " + NetUtils.getLocalHost() + ":" + port + ", cause: " + e.getMessage(), e);
+ }
+ }
+
+ public void stop() {
+ try {
+ if (connector != null) {
+ connector.close();
+ connector = null;
+ }
+ } catch (Throwable e) {
+ logger.error(e.getMessage(), e);
+ }
+ }
+
}
\ No newline at end of file
diff --git a/dubbo-container/dubbo-container-jetty/src/test/java/com/alibaba/dubbo/container/jetty/JettyContainerTest.java b/dubbo-container/dubbo-container-jetty/src/test/java/com/alibaba/dubbo/container/jetty/JettyContainerTest.java
index 957cb50244..7ebc2c34b0 100644
--- a/dubbo-container/dubbo-container-jetty/src/test/java/com/alibaba/dubbo/container/jetty/JettyContainerTest.java
+++ b/dubbo-container/dubbo-container-jetty/src/test/java/com/alibaba/dubbo/container/jetty/JettyContainerTest.java
@@ -1,38 +1,38 @@
-/*
- * 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.container.jetty;
-
-import com.alibaba.dubbo.common.extension.ExtensionLoader;
-import com.alibaba.dubbo.container.Container;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-/**
- * StandaloneContainerTest
- */
-public class JettyContainerTest {
-
- @Test
- public void testContainer() {
- JettyContainer container = (JettyContainer) ExtensionLoader.getExtensionLoader(Container.class).getExtension("jetty");
- container.start();
- Assert.assertTrue(container.connector.isStarted());
- container.stop();
- }
-
+/*
+ * 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.container.jetty;
+
+import com.alibaba.dubbo.common.extension.ExtensionLoader;
+import com.alibaba.dubbo.container.Container;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * StandaloneContainerTest
+ */
+public class JettyContainerTest {
+
+ @Test
+ public void testContainer() {
+ JettyContainer container = (JettyContainer) ExtensionLoader.getExtensionLoader(Container.class).getExtension("jetty");
+ container.start();
+ Assert.assertTrue(container.connector.isStarted());
+ container.stop();
+ }
+
}
\ No newline at end of file
diff --git a/dubbo-container/dubbo-container-log4j/pom.xml b/dubbo-container/dubbo-container-log4j/pom.xml
index 0597db8f13..2a4aa222b5 100644
--- a/dubbo-container/dubbo-container-log4j/pom.xml
+++ b/dubbo-container/dubbo-container-log4j/pom.xml
@@ -20,7 +20,7 @@ limitations under the License.
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-container</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>dubbo-container-log4j</artifactId>
<packaging>jar</packaging>
diff --git a/dubbo-container/dubbo-container-logback/pom.xml b/dubbo-container/dubbo-container-logback/pom.xml
index 8656ab854b..2bec7bed00 100644
--- a/dubbo-container/dubbo-container-logback/pom.xml
+++ b/dubbo-container/dubbo-container-logback/pom.xml
@@ -20,7 +20,7 @@ limitations under the License.
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-container</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>dubbo-container-logback</artifactId>
<packaging>jar</packaging>
diff --git a/dubbo-container/dubbo-container-spring/pom.xml b/dubbo-container/dubbo-container-spring/pom.xml
index c08ed628ab..55a2e51b0f 100644
--- a/dubbo-container/dubbo-container-spring/pom.xml
+++ b/dubbo-container/dubbo-container-spring/pom.xml
@@ -20,7 +20,7 @@ limitations under the License.
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-container</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>dubbo-container-spring</artifactId>
<packaging>jar</packaging>
diff --git a/dubbo-container/pom.xml b/dubbo-container/pom.xml
index 2d9f829bec..1763ef3554 100644
--- a/dubbo-container/pom.xml
+++ b/dubbo-container/pom.xml
@@ -20,7 +20,7 @@ limitations under the License.
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-parent</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>dubbo-container</artifactId>
<packaging>pom</packaging>
diff --git a/dubbo-demo/dubbo-demo-api/pom.xml b/dubbo-demo/dubbo-demo-api/pom.xml
index dd28370c46..389d2ef2b7 100644
--- a/dubbo-demo/dubbo-demo-api/pom.xml
+++ b/dubbo-demo/dubbo-demo-api/pom.xml
@@ -20,7 +20,7 @@ limitations under the License.
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-demo</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>dubbo-demo-api</artifactId>
<packaging>jar</packaging>
diff --git a/dubbo-demo/dubbo-demo-consumer/pom.xml b/dubbo-demo/dubbo-demo-consumer/pom.xml
index 1ae8803c17..7d14dfe7b3 100644
--- a/dubbo-demo/dubbo-demo-consumer/pom.xml
+++ b/dubbo-demo/dubbo-demo-consumer/pom.xml
@@ -20,7 +20,7 @@ limitations under the License.
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-demo</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>dubbo-demo-consumer</artifactId>
<packaging>jar</packaging>
diff --git a/dubbo-demo/dubbo-demo-provider/pom.xml b/dubbo-demo/dubbo-demo-provider/pom.xml
index 458fe11281..250dad06b7 100644
--- a/dubbo-demo/dubbo-demo-provider/pom.xml
+++ b/dubbo-demo/dubbo-demo-provider/pom.xml
@@ -20,7 +20,7 @@ limitations under the License.
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-demo</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>dubbo-demo-provider</artifactId>
<packaging>jar</packaging>
diff --git a/dubbo-demo/pom.xml b/dubbo-demo/pom.xml
index f85dbf8d2b..15e81af19b 100644
--- a/dubbo-demo/pom.xml
+++ b/dubbo-demo/pom.xml
@@ -20,7 +20,7 @@ limitations under the License.
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-parent</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>dubbo-demo</artifactId>
<packaging>pom</packaging>
diff --git a/dubbo-filter/dubbo-filter-cache/pom.xml b/dubbo-filter/dubbo-filter-cache/pom.xml
index bd6578dd12..5d5ec3a01b 100644
--- a/dubbo-filter/dubbo-filter-cache/pom.xml
+++ b/dubbo-filter/dubbo-filter-cache/pom.xml
@@ -20,7 +20,7 @@ limitations under the License.
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-filter</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>dubbo-filter-cache</artifactId>
<packaging>jar</packaging>
diff --git a/dubbo-filter/dubbo-filter-validation/pom.xml b/dubbo-filter/dubbo-filter-validation/pom.xml
index 6c2eeb9a72..1dc9f117d8 100644
--- a/dubbo-filter/dubbo-filter-validation/pom.xml
+++ b/dubbo-filter/dubbo-filter-validation/pom.xml
@@ -20,7 +20,7 @@ limitations under the License.
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-filter</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>dubbo-filter-validation</artifactId>
<packaging>jar</packaging>
diff --git a/dubbo-filter/pom.xml b/dubbo-filter/pom.xml
index f771efcf7e..67ada860d7 100644
--- a/dubbo-filter/pom.xml
+++ b/dubbo-filter/pom.xml
@@ -20,7 +20,7 @@ limitations under the License.
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-parent</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>dubbo-filter</artifactId>
<packaging>pom</packaging>
diff --git a/dubbo-maven/pom.xml b/dubbo-maven/pom.xml
index 2c4069d800..1f0840cf8a 100644
--- a/dubbo-maven/pom.xml
+++ b/dubbo-maven/pom.xml
@@ -24,7 +24,7 @@ limitations under the License.
</parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
<packaging>jar</packaging>
<name>Dubbo</name>
<description>Dubbo is a high-performance, java based RPC framework open-sourced by Alibaba</description>
diff --git a/dubbo-monitor/dubbo-monitor-api/pom.xml b/dubbo-monitor/dubbo-monitor-api/pom.xml
index efc1a14dfa..306f744125 100644
--- a/dubbo-monitor/dubbo-monitor-api/pom.xml
+++ b/dubbo-monitor/dubbo-monitor-api/pom.xml
@@ -19,7 +19,7 @@
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-monitor</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>dubbo-monitor-api</artifactId>
<packaging>jar</packaging>
diff --git a/dubbo-monitor/dubbo-monitor-default/pom.xml b/dubbo-monitor/dubbo-monitor-default/pom.xml
index 2795670cef..4f59714ef3 100644
--- a/dubbo-monitor/dubbo-monitor-default/pom.xml
+++ b/dubbo-monitor/dubbo-monitor-default/pom.xml
@@ -20,7 +20,7 @@ limitations under the License.
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-monitor</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>dubbo-monitor-default</artifactId>
<packaging>jar</packaging>
diff --git a/dubbo-monitor/pom.xml b/dubbo-monitor/pom.xml
index 97ee4c51a6..6bc66fad1f 100644
--- a/dubbo-monitor/pom.xml
+++ b/dubbo-monitor/pom.xml
@@ -20,7 +20,7 @@ limitations under the License.
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-parent</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>dubbo-monitor</artifactId>
<packaging>pom</packaging>
diff --git a/dubbo-plugin/dubbo-qos/pom.xml b/dubbo-plugin/dubbo-qos/pom.xml
index 92dc00ddca..b26107bbb9 100644
--- a/dubbo-plugin/dubbo-qos/pom.xml
+++ b/dubbo-plugin/dubbo-qos/pom.xml
@@ -19,7 +19,7 @@ limitations under the License.
<parent>
<artifactId>dubbo-plugin</artifactId>
<groupId>com.alibaba</groupId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/dubbo-plugin/pom.xml b/dubbo-plugin/pom.xml
index e49a1a95d3..b85fff944d 100644
--- a/dubbo-plugin/pom.xml
+++ b/dubbo-plugin/pom.xml
@@ -19,7 +19,7 @@ limitations under the License.
<parent>
<artifactId>dubbo-parent</artifactId>
<groupId>com.alibaba</groupId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/dubbo-registry/dubbo-registry-api/pom.xml b/dubbo-registry/dubbo-registry-api/pom.xml
index e91e792433..1410051768 100644
--- a/dubbo-registry/dubbo-registry-api/pom.xml
+++ b/dubbo-registry/dubbo-registry-api/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-registry</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>dubbo-registry-api</artifactId>
<packaging>jar</packaging>
diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/pages/RegisteredPageHandler.java b/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/pages/RegisteredPageHandler.java
index 19a08c0bf0..f8f8b070b4 100644
--- a/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/pages/RegisteredPageHandler.java
+++ b/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/pages/RegisteredPageHandler.java
@@ -1,79 +1,79 @@
-/*
- * 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.registry.pages;
-
-import com.alibaba.dubbo.common.URL;
-import com.alibaba.dubbo.container.page.Page;
-import com.alibaba.dubbo.container.page.PageHandler;
-import com.alibaba.dubbo.registry.Registry;
-import com.alibaba.dubbo.registry.support.AbstractRegistry;
-import com.alibaba.dubbo.registry.support.AbstractRegistryFactory;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Set;
-
-/**
- * RegisteredPageHandler
- *
- */
-public class RegisteredPageHandler implements PageHandler {
-
- public Page handle(URL url) {
- String registryAddress = url.getParameter("registry", "");
- List<List<String>> rows = new ArrayList<List<String>>();
- Collection<Registry> registries = AbstractRegistryFactory.getRegistries();
- StringBuilder select = new StringBuilder();
- Registry registry = null;
- if (registries != null && registries.size() > 0) {
- if (registries.size() == 1) {
- registry = registries.iterator().next();
- select.append(" > " + registry.getUrl().getAddress());
- } else {
- select.append(" > <select onchange=\"window.location.href='registered.html?registry=' + this.value;\">");
- for (Registry r : registries) {
- String sp = r.getUrl().getAddress();
- select.append("<option value=\">");
- select.append(sp);
- if (((registryAddress == null || registryAddress.length() == 0) && registry == null)
- || registryAddress.equals(sp)) {
- registry = r;
- select.append("\" selected=\"selected");
- }
- select.append("\">");
- select.append(sp);
- select.append("</option>");
- }
- select.append("</select>");
- }
- }
- if (registry instanceof AbstractRegistry) {
- Set<URL> services = ((AbstractRegistry) registry).getRegistered();
- if (services != null && services.size() > 0) {
- for (URL u : services) {
- List<String> row = new ArrayList<String>();
- row.add(u.toFullString().replace("<", "<").replace(">", ">"));
- rows.add(row);
- }
- }
- }
- return new Page("<a href=\"registries.html\">Registries</a>" + select.toString() + " > Registered | <a href=\"subscribed.html?registry=" + registryAddress + "\">Subscribed</a>", "Registered (" + rows.size() + ")",
- new String[]{"Provider URL:"}, rows);
- }
-
+/*
+ * 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.registry.pages;
+
+import com.alibaba.dubbo.common.URL;
+import com.alibaba.dubbo.container.page.Page;
+import com.alibaba.dubbo.container.page.PageHandler;
+import com.alibaba.dubbo.registry.Registry;
+import com.alibaba.dubbo.registry.support.AbstractRegistry;
+import com.alibaba.dubbo.registry.support.AbstractRegistryFactory;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * RegisteredPageHandler
+ *
+ */
+public class RegisteredPageHandler implements PageHandler {
+
+ public Page handle(URL url) {
+ String registryAddress = url.getParameter("registry", "");
+ List<List<String>> rows = new ArrayList<List<String>>();
+ Collection<Registry> registries = AbstractRegistryFactory.getRegistries();
+ StringBuilder select = new StringBuilder();
+ Registry registry = null;
+ if (registries != null && registries.size() > 0) {
+ if (registries.size() == 1) {
+ registry = registries.iterator().next();
+ select.append(" > " + registry.getUrl().getAddress());
+ } else {
+ select.append(" > <select onchange=\"window.location.href='registered.html?registry=' + this.value;\">");
+ for (Registry r : registries) {
+ String sp = r.getUrl().getAddress();
+ select.append("<option value=\">");
+ select.append(sp);
+ if (((registryAddress == null || registryAddress.length() == 0) && registry == null)
+ || registryAddress.equals(sp)) {
+ registry = r;
+ select.append("\" selected=\"selected");
+ }
+ select.append("\">");
+ select.append(sp);
+ select.append("</option>");
+ }
+ select.append("</select>");
+ }
+ }
+ if (registry instanceof AbstractRegistry) {
+ Set<URL> services = ((AbstractRegistry) registry).getRegistered();
+ if (services != null && services.size() > 0) {
+ for (URL u : services) {
+ List<String> row = new ArrayList<String>();
+ row.add(u.toFullString().replace("<", "<").replace(">", ">"));
+ rows.add(row);
+ }
+ }
+ }
+ return new Page("<a href=\"registries.html\">Registries</a>" + select.toString() + " > Registered | <a href=\"subscribed.html?registry=" + registryAddress + "\">Subscribed</a>", "Registered (" + rows.size() + ")",
+ new String[]{"Provider URL:"}, rows);
+ }
+
}
\ No newline at end of file
diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/pages/RegistriesPageHandler.java b/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/pages/RegistriesPageHandler.java
index 8f1a88d6dd..65ecf8eff7 100644
--- a/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/pages/RegistriesPageHandler.java
+++ b/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/pages/RegistriesPageHandler.java
@@ -1,71 +1,71 @@
-/*
- * 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.registry.pages;
-
-import com.alibaba.dubbo.common.URL;
-import com.alibaba.dubbo.common.utils.NetUtils;
-import com.alibaba.dubbo.container.page.Menu;
-import com.alibaba.dubbo.container.page.Page;
-import com.alibaba.dubbo.container.page.PageHandler;
-import com.alibaba.dubbo.registry.Registry;
-import com.alibaba.dubbo.registry.support.AbstractRegistry;
-import com.alibaba.dubbo.registry.support.AbstractRegistryFactory;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-/**
- * RegistriesPageHandler
- *
- */
-@Menu(name = "Registries", desc = "Show connected registries.", order = 10000)
-public class RegistriesPageHandler implements PageHandler {
-
- public Page handle(URL url) {
- List<List<String>> rows = new ArrayList<List<String>>();
- Collection<Registry> registries = AbstractRegistryFactory.getRegistries();
- int registeredCount = 0;
- int subscribedCount = 0;
- if (registries != null && registries.size() > 0) {
- for (Registry registry : registries) {
- String server = registry.getUrl().getAddress();
- List<String> row = new ArrayList<String>();
- row.add(NetUtils.getHostName(server) + "/" + server);
- if (registry.isAvailable()) {
- row.add("<font color=\"green\">Connected</font>");
- } else {
- row.add("<font color=\"red\">Disconnected</font>");
- }
- int registeredSize = 0;
- int subscribedSize = 0;
- if (registry instanceof AbstractRegistry) {
- registeredSize = ((AbstractRegistry) registry).getRegistered().size();
- registeredCount += registeredSize;
- subscribedSize = ((AbstractRegistry) registry).getSubscribed().size();
- subscribedCount += subscribedSize;
- }
- row.add("<a href=\"registered.html?registry=" + server + "\">Registered(" + registeredSize + ")</a>");
- row.add("<a href=\"subscribed.html?registry=" + server + "\">Subscribed(" + subscribedSize + ")</a>");
- rows.add(row);
- }
- }
- return new Page("Registries", "Registries (" + rows.size() + ")",
- new String[]{"Registry Address:", "Status", "Registered(" + registeredCount + ")", "Subscribed(" + subscribedCount + ")"}, rows);
- }
-
+/*
+ * 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.registry.pages;
+
+import com.alibaba.dubbo.common.URL;
+import com.alibaba.dubbo.common.utils.NetUtils;
+import com.alibaba.dubbo.container.page.Menu;
+import com.alibaba.dubbo.container.page.Page;
+import com.alibaba.dubbo.container.page.PageHandler;
+import com.alibaba.dubbo.registry.Registry;
+import com.alibaba.dubbo.registry.support.AbstractRegistry;
+import com.alibaba.dubbo.registry.support.AbstractRegistryFactory;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * RegistriesPageHandler
+ *
+ */
+@Menu(name = "Registries", desc = "Show connected registries.", order = 10000)
+public class RegistriesPageHandler implements PageHandler {
+
+ public Page handle(URL url) {
+ List<List<String>> rows = new ArrayList<List<String>>();
+ Collection<Registry> registries = AbstractRegistryFactory.getRegistries();
+ int registeredCount = 0;
+ int subscribedCount = 0;
+ if (registries != null && registries.size() > 0) {
+ for (Registry registry : registries) {
+ String server = registry.getUrl().getAddress();
+ List<String> row = new ArrayList<String>();
+ row.add(NetUtils.getHostName(server) + "/" + server);
+ if (registry.isAvailable()) {
+ row.add("<font color=\"green\">Connected</font>");
+ } else {
+ row.add("<font color=\"red\">Disconnected</font>");
+ }
+ int registeredSize = 0;
+ int subscribedSize = 0;
+ if (registry instanceof AbstractRegistry) {
+ registeredSize = ((AbstractRegistry) registry).getRegistered().size();
+ registeredCount += registeredSize;
+ subscribedSize = ((AbstractRegistry) registry).getSubscribed().size();
+ subscribedCount += subscribedSize;
+ }
+ row.add("<a href=\"registered.html?registry=" + server + "\">Registered(" + registeredSize + ")</a>");
+ row.add("<a href=\"subscribed.html?registry=" + server + "\">Subscribed(" + subscribedSize + ")</a>");
+ rows.add(row);
+ }
+ }
+ return new Page("Registries", "Registries (" + rows.size() + ")",
+ new String[]{"Registry Address:", "Status", "Registered(" + registeredCount + ")", "Subscribed(" + subscribedCount + ")"}, rows);
+ }
+
}
\ No newline at end of file
diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/pages/SubscribedPageHandler.java b/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/pages/SubscribedPageHandler.java
index b048eb90f8..7710ea0013 100644
--- a/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/pages/SubscribedPageHandler.java
+++ b/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/pages/SubscribedPageHandler.java
@@ -1,79 +1,79 @@
-/*
- * 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.registry.pages;
-
-import com.alibaba.dubbo.common.URL;
-import com.alibaba.dubbo.container.page.Page;
-import com.alibaba.dubbo.container.page.PageHandler;
-import com.alibaba.dubbo.registry.Registry;
-import com.alibaba.dubbo.registry.support.AbstractRegistry;
-import com.alibaba.dubbo.registry.support.AbstractRegistryFactory;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Set;
-
-/**
- * SubscribedPageHandler
- *
- */
-public class SubscribedPageHandler implements PageHandler {
-
- public Page handle(URL url) {
- String registryAddress = url.getParameter("registry", "");
- List<List<String>> rows = new ArrayList<List<String>>();
- Collection<Registry> registries = AbstractRegistryFactory.getRegistries();
- StringBuilder select = new StringBuilder();
- Registry registry = null;
- if (registries != null && registries.size() > 0) {
- if (registries.size() == 1) {
- registry = registries.iterator().next();
- select.append(" > " + registry.getUrl().getAddress());
- } else {
- select.append(" > <select onchange=\"window.location.href='subscribed.html?registry=' + this.value;\">");
- for (Registry r : registries) {
- String sp = r.getUrl().getAddress();
- select.append("<option value=\">");
- select.append(sp);
- if (((registryAddress == null || registryAddress.length() == 0) && registry == null)
- || registryAddress.equals(sp)) {
- registry = r;
- select.append("\" selected=\"selected");
- }
- select.append("\">");
- select.append(sp);
- select.append("</option>");
- }
- select.append("</select>");
- }
- }
- if (registry instanceof AbstractRegistry) {
- Set<URL> services = ((AbstractRegistry) registry).getSubscribed().keySet();
- if (services != null && services.size() > 0) {
- for (URL u : services) {
- List<String> row = new ArrayList<String>();
- row.add(u.toFullString().replace("<", "<").replace(">", ">"));
- rows.add(row);
- }
- }
- }
- return new Page("<a href=\"registries.html\">Registries</a>" + select.toString() + " > <a href=\"registered.html?registry=" + registryAddress + "\">Registered</a> | Subscribed", "Subscribed (" + rows.size() + ")",
- new String[]{"Consumer URL:"}, rows);
- }
-
+/*
+ * 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.registry.pages;
+
+import com.alibaba.dubbo.common.URL;
+import com.alibaba.dubbo.container.page.Page;
+import com.alibaba.dubbo.container.page.PageHandler;
+import com.alibaba.dubbo.registry.Registry;
+import com.alibaba.dubbo.registry.support.AbstractRegistry;
+import com.alibaba.dubbo.registry.support.AbstractRegistryFactory;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * SubscribedPageHandler
+ *
+ */
+public class SubscribedPageHandler implements PageHandler {
+
+ public Page handle(URL url) {
+ String registryAddress = url.getParameter("registry", "");
+ List<List<String>> rows = new ArrayList<List<String>>();
+ Collection<Registry> registries = AbstractRegistryFactory.getRegistries();
+ StringBuilder select = new StringBuilder();
+ Registry registry = null;
+ if (registries != null && registries.size() > 0) {
+ if (registries.size() == 1) {
+ registry = registries.iterator().next();
+ select.append(" > " + registry.getUrl().getAddress());
+ } else {
+ select.append(" > <select onchange=\"window.location.href='subscribed.html?registry=' + this.value;\">");
+ for (Registry r : registries) {
+ String sp = r.getUrl().getAddress();
+ select.append("<option value=\">");
+ select.append(sp);
+ if (((registryAddress == null || registryAddress.length() == 0) && registry == null)
+ || registryAddress.equals(sp)) {
+ registry = r;
+ select.append("\" selected=\"selected");
+ }
+ select.append("\">");
+ select.append(sp);
+ select.append("</option>");
+ }
+ select.append("</select>");
+ }
+ }
+ if (registry instanceof AbstractRegistry) {
+ Set<URL> services = ((AbstractRegistry) registry).getSubscribed().keySet();
+ if (services != null && services.size() > 0) {
+ for (URL u : services) {
+ List<String> row = new ArrayList<String>();
+ row.add(u.toFullString().replace("<", "<").replace(">", ">"));
+ rows.add(row);
+ }
+ }
+ }
+ return new Page("<a href=\"registries.html\">Registries</a>" + select.toString() + " > <a href=\"registered.html?registry=" + registryAddress + "\">Registered</a> | Subscribed", "Subscribed (" + rows.size() + ")",
+ new String[]{"Consumer URL:"}, rows);
+ }
+
}
\ No newline at end of file
diff --git a/dubbo-registry/dubbo-registry-api/src/main/resources/META-INF/dubbo/internal/com.alibaba.dubbo.container.page.PageHandler b/dubbo-registry/dubbo-registry-api/src/main/resources/META-INF/dubbo/internal/com.alibaba.dubbo.container.page.PageHandler
index 8e75ea0504..35e5c5e552 100644
--- a/dubbo-registry/dubbo-registry-api/src/main/resources/META-INF/dubbo/internal/com.alibaba.dubbo.container.page.PageHandler
+++ b/dubbo-registry/dubbo-registry-api/src/main/resources/META-INF/dubbo/internal/com.alibaba.dubbo.container.page.PageHandler
@@ -1,3 +1,3 @@
-registries=com.alibaba.dubbo.registry.pages.RegistriesPageHandler
-registered=com.alibaba.dubbo.registry.pages.RegisteredPageHandler
+registries=com.alibaba.dubbo.registry.pages.RegistriesPageHandler
+registered=com.alibaba.dubbo.registry.pages.RegisteredPageHandler
subscribed=com.alibaba.dubbo.registry.pages.SubscribedPageHandler
\ No newline at end of file
diff --git a/dubbo-registry/dubbo-registry-default/pom.xml b/dubbo-registry/dubbo-registry-default/pom.xml
index 4cfc707695..6005d25bfb 100644
--- a/dubbo-registry/dubbo-registry-default/pom.xml
+++ b/dubbo-registry/dubbo-registry-default/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-registry</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>dubbo-registry-default</artifactId>
<packaging>jar</packaging>
diff --git a/dubbo-registry/dubbo-registry-multicast/pom.xml b/dubbo-registry/dubbo-registry-multicast/pom.xml
index e8316c9cb7..c9a919e11e 100644
--- a/dubbo-registry/dubbo-registry-multicast/pom.xml
+++ b/dubbo-registry/dubbo-registry-multicast/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-registry</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>dubbo-registry-multicast</artifactId>
<packaging>jar</packaging>
diff --git a/dubbo-registry/dubbo-registry-redis/pom.xml b/dubbo-registry/dubbo-registry-redis/pom.xml
index 28460cf759..9b60f00d7b 100644
--- a/dubbo-registry/dubbo-registry-redis/pom.xml
+++ b/dubbo-registry/dubbo-registry-redis/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-registry</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>dubbo-registry-redis</artifactId>
<packaging>jar</packaging>
diff --git a/dubbo-registry/dubbo-registry-zookeeper/pom.xml b/dubbo-registry/dubbo-registry-zookeeper/pom.xml
index 375dd48fae..8bcacc5550 100644
--- a/dubbo-registry/dubbo-registry-zookeeper/pom.xml
+++ b/dubbo-registry/dubbo-registry-zookeeper/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-registry</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>dubbo-registry-zookeeper</artifactId>
<packaging>jar</packaging>
diff --git a/dubbo-registry/pom.xml b/dubbo-registry/pom.xml
index 202fdf370f..e148fc3376 100644
--- a/dubbo-registry/pom.xml
+++ b/dubbo-registry/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-parent</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>dubbo-registry</artifactId>
<packaging>pom</packaging>
diff --git a/dubbo-remoting/dubbo-remoting-api/pom.xml b/dubbo-remoting/dubbo-remoting-api/pom.xml
index 2e66f6c0ed..1035108172 100644
--- a/dubbo-remoting/dubbo-remoting-api/pom.xml
+++ b/dubbo-remoting/dubbo-remoting-api/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-remoting</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>dubbo-remoting-api</artifactId>
<packaging>jar</packaging>
diff --git a/dubbo-remoting/dubbo-remoting-grizzly/pom.xml b/dubbo-remoting/dubbo-remoting-grizzly/pom.xml
index 5675c9c091..62307cfe38 100644
--- a/dubbo-remoting/dubbo-remoting-grizzly/pom.xml
+++ b/dubbo-remoting/dubbo-remoting-grizzly/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-remoting</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>dubbo-remoting-grizzly</artifactId>
<packaging>jar</packaging>
diff --git a/dubbo-remoting/dubbo-remoting-http/pom.xml b/dubbo-remoting/dubbo-remoting-http/pom.xml
index faa339ce20..4b5a63d141 100644
--- a/dubbo-remoting/dubbo-remoting-http/pom.xml
+++ b/dubbo-remoting/dubbo-remoting-http/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-remoting</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>dubbo-remoting-http</artifactId>
<packaging>jar</packaging>
diff --git a/dubbo-remoting/dubbo-remoting-mina/pom.xml b/dubbo-remoting/dubbo-remoting-mina/pom.xml
index 7ce3aa61e6..963c126df1 100644
--- a/dubbo-remoting/dubbo-remoting-mina/pom.xml
+++ b/dubbo-remoting/dubbo-remoting-mina/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-remoting</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>dubbo-remoting-mina</artifactId>
<packaging>jar</packaging>
diff --git a/dubbo-remoting/dubbo-remoting-netty/pom.xml b/dubbo-remoting/dubbo-remoting-netty/pom.xml
index 10d514247e..239a00d200 100644
--- a/dubbo-remoting/dubbo-remoting-netty/pom.xml
+++ b/dubbo-remoting/dubbo-remoting-netty/pom.xml
@@ -19,7 +19,7 @@
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-remoting</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>dubbo-remoting-netty</artifactId>
<packaging>jar</packaging>
diff --git a/dubbo-remoting/dubbo-remoting-netty4/pom.xml b/dubbo-remoting/dubbo-remoting-netty4/pom.xml
index f436e3f815..f161850b83 100644
--- a/dubbo-remoting/dubbo-remoting-netty4/pom.xml
+++ b/dubbo-remoting/dubbo-remoting-netty4/pom.xml
@@ -19,7 +19,7 @@
<parent>
<artifactId>dubbo-remoting</artifactId>
<groupId>com.alibaba</groupId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/dubbo-remoting/dubbo-remoting-p2p/pom.xml b/dubbo-remoting/dubbo-remoting-p2p/pom.xml
index 04cf677c46..52c3971efb 100644
--- a/dubbo-remoting/dubbo-remoting-p2p/pom.xml
+++ b/dubbo-remoting/dubbo-remoting-p2p/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-remoting</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>dubbo-remoting-p2p</artifactId>
<packaging>jar</packaging>
diff --git a/dubbo-remoting/dubbo-remoting-zookeeper/pom.xml b/dubbo-remoting/dubbo-remoting-zookeeper/pom.xml
index 18ce348bb8..e605326299 100644
--- a/dubbo-remoting/dubbo-remoting-zookeeper/pom.xml
+++ b/dubbo-remoting/dubbo-remoting-zookeeper/pom.xml
@@ -19,7 +19,7 @@
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-remoting</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>dubbo-remoting-zookeeper</artifactId>
<packaging>jar</packaging>
diff --git a/dubbo-remoting/pom.xml b/dubbo-remoting/pom.xml
index 064180baa3..1f41cf9fbd 100644
--- a/dubbo-remoting/pom.xml
+++ b/dubbo-remoting/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-parent</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>dubbo-remoting</artifactId>
<packaging>pom</packaging>
diff --git a/dubbo-rpc/dubbo-rpc-api/pom.xml b/dubbo-rpc/dubbo-rpc-api/pom.xml
index 09f46d1ee3..1f85d005a8 100644
--- a/dubbo-rpc/dubbo-rpc-api/pom.xml
+++ b/dubbo-rpc/dubbo-rpc-api/pom.xml
@@ -20,7 +20,7 @@ limitations under the License.
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-rpc</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>dubbo-rpc-api</artifactId>
<packaging>jar</packaging>
diff --git a/dubbo-rpc/dubbo-rpc-default/pom.xml b/dubbo-rpc/dubbo-rpc-default/pom.xml
index 550dc006a0..fd7b2313c9 100644
--- a/dubbo-rpc/dubbo-rpc-default/pom.xml
+++ b/dubbo-rpc/dubbo-rpc-default/pom.xml
@@ -20,7 +20,7 @@ limitations under the License.
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-rpc</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>dubbo-rpc-default</artifactId>
<packaging>jar</packaging>
diff --git a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/DubboExporter.java b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/DubboExporter.java
index c148f5c7ca..82b4c11b44 100644
--- a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/DubboExporter.java
+++ b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/DubboExporter.java
@@ -1,46 +1,46 @@
-/*
- * 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.rpc.protocol.dubbo;
-
-import com.alibaba.dubbo.rpc.Exporter;
-import com.alibaba.dubbo.rpc.Invoker;
-import com.alibaba.dubbo.rpc.protocol.AbstractExporter;
-
-import java.util.Map;
-
-/**
- * DubboExporter
- */
-public class DubboExporter<T> extends AbstractExporter<T> {
-
- private final String key;
-
- private final Map<String, Exporter<?>> exporterMap;
-
- public DubboExporter(Invoker<T> invoker, String key, Map<String, Exporter<?>> exporterMap) {
- super(invoker);
- this.key = key;
- this.exporterMap = exporterMap;
- }
-
- @Override
- public void unexport() {
- super.unexport();
- exporterMap.remove(key);
- }
-
+/*
+ * 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.rpc.protocol.dubbo;
+
+import com.alibaba.dubbo.rpc.Exporter;
+import com.alibaba.dubbo.rpc.Invoker;
+import com.alibaba.dubbo.rpc.protocol.AbstractExporter;
+
+import java.util.Map;
+
+/**
+ * DubboExporter
+ */
+public class DubboExporter<T> extends AbstractExporter<T> {
+
+ private final String key;
+
+ private final Map<String, Exporter<?>> exporterMap;
+
+ public DubboExporter(Invoker<T> invoker, String key, Map<String, Exporter<?>> exporterMap) {
+ super(invoker);
+ this.key = key;
+ this.exporterMap = exporterMap;
+ }
+
+ @Override
+ public void unexport() {
+ super.unexport();
+ exporterMap.remove(key);
+ }
+
}
\ No newline at end of file
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 a5624fd76c..3d4c8d5286 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
@@ -1,147 +1,147 @@
-/*
- * 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.rpc.protocol.dubbo;
-
-import com.alibaba.dubbo.common.Constants;
-import com.alibaba.dubbo.common.URL;
-import com.alibaba.dubbo.common.utils.AtomicPositiveInteger;
-import com.alibaba.dubbo.common.utils.ConfigUtils;
-import com.alibaba.dubbo.remoting.RemotingException;
-import com.alibaba.dubbo.remoting.TimeoutException;
-import com.alibaba.dubbo.remoting.exchange.ExchangeClient;
-import com.alibaba.dubbo.remoting.exchange.ResponseFuture;
-import com.alibaba.dubbo.rpc.Invocation;
-import com.alibaba.dubbo.rpc.Invoker;
-import com.alibaba.dubbo.rpc.Result;
-import com.alibaba.dubbo.rpc.RpcContext;
-import com.alibaba.dubbo.rpc.RpcException;
-import com.alibaba.dubbo.rpc.RpcInvocation;
-import com.alibaba.dubbo.rpc.RpcResult;
-import com.alibaba.dubbo.rpc.protocol.AbstractInvoker;
-import com.alibaba.dubbo.rpc.support.RpcUtils;
-
-import java.util.Set;
-import java.util.concurrent.locks.ReentrantLock;
-
-/**
- * DubboInvoker
- */
-public class DubboInvoker<T> extends AbstractInvoker<T> {
-
- private final ExchangeClient[] clients;
-
- private final AtomicPositiveInteger index = new AtomicPositiveInteger();
-
- private final String version;
-
- private final ReentrantLock destroyLock = new ReentrantLock();
-
- private final Set<Invoker<?>> invokers;
-
- public DubboInvoker(Class<T> serviceType, URL url, ExchangeClient[] clients) {
- this(serviceType, url, clients, null);
- }
-
- public DubboInvoker(Class<T> serviceType, URL url, ExchangeClient[] clients, Set<Invoker<?>> invokers) {
- super(serviceType, url, new String[]{Constants.INTERFACE_KEY, Constants.GROUP_KEY, Constants.TOKEN_KEY, Constants.TIMEOUT_KEY});
- this.clients = clients;
- // get version.
- this.version = url.getParameter(Constants.VERSION_KEY, "0.0.0");
- this.invokers = invokers;
- }
-
- @Override
- protected Result doInvoke(final Invocation invocation) throws Throwable {
- RpcInvocation inv = (RpcInvocation) invocation;
- final String methodName = RpcUtils.getMethodName(invocation);
- inv.setAttachment(Constants.PATH_KEY, getUrl().getPath());
- inv.setAttachment(Constants.VERSION_KEY, version);
-
- ExchangeClient currentClient;
- if (clients.length == 1) {
- currentClient = clients[0];
- } else {
- currentClient = clients[index.getAndIncrement() % clients.length];
- }
- try {
- boolean isAsync = RpcUtils.isAsync(getUrl(), invocation);
- boolean isOneway = RpcUtils.isOneway(getUrl(), invocation);
- int timeout = getUrl().getMethodParameter(methodName, Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT);
- if (isOneway) {
- boolean isSent = getUrl().getMethodParameter(methodName, Constants.SENT_KEY, false);
- currentClient.send(inv, isSent);
- RpcContext.getContext().setFuture(null);
- return new RpcResult();
- } else if (isAsync) {
- ResponseFuture future = currentClient.request(inv, timeout);
- RpcContext.getContext().setFuture(new FutureAdapter<Object>(future));
- return new RpcResult();
- } else {
- RpcContext.getContext().setFuture(null);
- return (Result) currentClient.request(inv, timeout).get();
- }
- } catch (TimeoutException e) {
- throw new RpcException(RpcException.TIMEOUT_EXCEPTION, "Invoke remote method timeout. method: " + invocation.getMethodName() + ", provider: " + getUrl() + ", cause: " + e.getMessage(), e);
- } catch (RemotingException e) {
- throw new RpcException(RpcException.NETWORK_EXCEPTION, "Failed to invoke remote method: " + invocation.getMethodName() + ", provider: " + getUrl() + ", cause: " + e.getMessage(), e);
- }
- }
-
- @Override
- public boolean isAvailable() {
- if (!super.isAvailable())
- return false;
- for (ExchangeClient client : clients) {
- if (client.isConnected() && !client.hasAttribute(Constants.CHANNEL_ATTRIBUTE_READONLY_KEY)) {
- //cannot write == not Available ?
- return true;
- }
- }
- return false;
- }
-
- 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
- // closed.
- if (super.isDestroyed()) {
- return;
- } else {
- // double check to avoid dup close
- destroyLock.lock();
- try {
- if (super.isDestroyed()) {
- return;
- }
- super.destroy();
- if (invokers != null) {
- invokers.remove(this);
- }
- for (ExchangeClient client : clients) {
- try {
- client.close(ConfigUtils.getServerShutdownTimeout());
- } catch (Throwable t) {
- logger.warn(t.getMessage(), t);
- }
- }
-
- } finally {
- destroyLock.unlock();
- }
- }
- }
+/*
+ * 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.rpc.protocol.dubbo;
+
+import com.alibaba.dubbo.common.Constants;
+import com.alibaba.dubbo.common.URL;
+import com.alibaba.dubbo.common.utils.AtomicPositiveInteger;
+import com.alibaba.dubbo.common.utils.ConfigUtils;
+import com.alibaba.dubbo.remoting.RemotingException;
+import com.alibaba.dubbo.remoting.TimeoutException;
+import com.alibaba.dubbo.remoting.exchange.ExchangeClient;
+import com.alibaba.dubbo.remoting.exchange.ResponseFuture;
+import com.alibaba.dubbo.rpc.Invocation;
+import com.alibaba.dubbo.rpc.Invoker;
+import com.alibaba.dubbo.rpc.Result;
+import com.alibaba.dubbo.rpc.RpcContext;
+import com.alibaba.dubbo.rpc.RpcException;
+import com.alibaba.dubbo.rpc.RpcInvocation;
+import com.alibaba.dubbo.rpc.RpcResult;
+import com.alibaba.dubbo.rpc.protocol.AbstractInvoker;
+import com.alibaba.dubbo.rpc.support.RpcUtils;
+
+import java.util.Set;
+import java.util.concurrent.locks.ReentrantLock;
+
+/**
+ * DubboInvoker
+ */
+public class DubboInvoker<T> extends AbstractInvoker<T> {
+
+ private final ExchangeClient[] clients;
+
+ private final AtomicPositiveInteger index = new AtomicPositiveInteger();
+
+ private final String version;
+
+ private final ReentrantLock destroyLock = new ReentrantLock();
+
+ private final Set<Invoker<?>> invokers;
+
+ public DubboInvoker(Class<T> serviceType, URL url, ExchangeClient[] clients) {
+ this(serviceType, url, clients, null);
+ }
+
+ public DubboInvoker(Class<T> serviceType, URL url, ExchangeClient[] clients, Set<Invoker<?>> invokers) {
+ super(serviceType, url, new String[]{Constants.INTERFACE_KEY, Constants.GROUP_KEY, Constants.TOKEN_KEY, Constants.TIMEOUT_KEY});
+ this.clients = clients;
+ // get version.
+ this.version = url.getParameter(Constants.VERSION_KEY, "0.0.0");
+ this.invokers = invokers;
+ }
+
+ @Override
+ protected Result doInvoke(final Invocation invocation) throws Throwable {
+ RpcInvocation inv = (RpcInvocation) invocation;
+ final String methodName = RpcUtils.getMethodName(invocation);
+ inv.setAttachment(Constants.PATH_KEY, getUrl().getPath());
+ inv.setAttachment(Constants.VERSION_KEY, version);
+
+ ExchangeClient currentClient;
+ if (clients.length == 1) {
+ currentClient = clients[0];
+ } else {
+ currentClient = clients[index.getAndIncrement() % clients.length];
+ }
+ try {
+ boolean isAsync = RpcUtils.isAsync(getUrl(), invocation);
+ boolean isOneway = RpcUtils.isOneway(getUrl(), invocation);
+ int timeout = getUrl().getMethodParameter(methodName, Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT);
+ if (isOneway) {
+ boolean isSent = getUrl().getMethodParameter(methodName, Constants.SENT_KEY, false);
+ currentClient.send(inv, isSent);
+ RpcContext.getContext().setFuture(null);
+ return new RpcResult();
+ } else if (isAsync) {
+ ResponseFuture future = currentClient.request(inv, timeout);
+ RpcContext.getContext().setFuture(new FutureAdapter<Object>(future));
+ return new RpcResult();
+ } else {
+ RpcContext.getContext().setFuture(null);
+ return (Result) currentClient.request(inv, timeout).get();
+ }
+ } catch (TimeoutException e) {
+ throw new RpcException(RpcException.TIMEOUT_EXCEPTION, "Invoke remote method timeout. method: " + invocation.getMethodName() + ", provider: " + getUrl() + ", cause: " + e.getMessage(), e);
+ } catch (RemotingException e) {
+ throw new RpcException(RpcException.NETWORK_EXCEPTION, "Failed to invoke remote method: " + invocation.getMethodName() + ", provider: " + getUrl() + ", cause: " + e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public boolean isAvailable() {
+ if (!super.isAvailable())
+ return false;
+ for (ExchangeClient client : clients) {
+ if (client.isConnected() && !client.hasAttribute(Constants.CHANNEL_ATTRIBUTE_READONLY_KEY)) {
+ //cannot write == not Available ?
+ return true;
+ }
+ }
+ return false;
+ }
+
+ 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
+ // closed.
+ if (super.isDestroyed()) {
+ return;
+ } else {
+ // double check to avoid dup close
+ destroyLock.lock();
+ try {
+ if (super.isDestroyed()) {
+ return;
+ }
+ super.destroy();
+ if (invokers != null) {
+ invokers.remove(this);
+ }
+ for (ExchangeClient client : clients) {
+ try {
+ client.close(ConfigUtils.getServerShutdownTimeout());
+ } catch (Throwable t) {
+ logger.warn(t.getMessage(), t);
+ }
+ }
+
+ } finally {
+ destroyLock.unlock();
+ }
+ }
+ }
}
\ No newline at end of file
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 66cdc2f6fd..1fe553a9bc 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
@@ -1,82 +1,82 @@
-/*
- * 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.rpc.protocol.dubbo;
-
-import com.alibaba.dubbo.common.utils.StringUtils;
-import com.alibaba.dubbo.remoting.RemotingException;
-import com.alibaba.dubbo.remoting.exchange.ResponseFuture;
-import com.alibaba.dubbo.rpc.Result;
-import com.alibaba.dubbo.rpc.RpcException;
-
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
-/**
- * FutureAdapter
- */
-public class FutureAdapter<V> implements Future<V> {
-
- private final ResponseFuture future;
-
- public FutureAdapter(ResponseFuture future) {
- this.future = future;
- }
-
- public ResponseFuture getFuture() {
- return future;
- }
-
- public boolean cancel(boolean mayInterruptIfRunning) {
- return false;
- }
-
- public boolean isCancelled() {
- return false;
- }
-
- public boolean isDone() {
- return future.isDone();
- }
-
- @SuppressWarnings("unchecked")
- public V get() throws InterruptedException, ExecutionException {
- try {
- return (V) (((Result) future.get()).recreate());
- } catch (RemotingException e) {
- throw new ExecutionException(e.getMessage(), e);
- } catch (Throwable e) {
- throw new RpcException(e);
- }
- }
-
- @SuppressWarnings("unchecked")
- public V get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
- int timeoutInMillis = (int) TimeUnit.MILLISECONDS.convert(timeout, unit);
- try {
- return (V) (((Result) future.get(timeoutInMillis)).recreate());
- } catch (com.alibaba.dubbo.remoting.TimeoutException e) {
- throw new TimeoutException(StringUtils.toString(e));
- } catch (RemotingException e) {
- throw new ExecutionException(e.getMessage(), e);
- } catch (Throwable e) {
- throw new RpcException(e);
- }
- }
-
+/*
+ * 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.rpc.protocol.dubbo;
+
+import com.alibaba.dubbo.common.utils.StringUtils;
+import com.alibaba.dubbo.remoting.RemotingException;
+import com.alibaba.dubbo.remoting.exchange.ResponseFuture;
+import com.alibaba.dubbo.rpc.Result;
+import com.alibaba.dubbo.rpc.RpcException;
+
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+/**
+ * FutureAdapter
+ */
+public class FutureAdapter<V> implements Future<V> {
+
+ private final ResponseFuture future;
+
+ public FutureAdapter(ResponseFuture future) {
+ this.future = future;
+ }
+
+ public ResponseFuture getFuture() {
+ return future;
+ }
+
+ public boolean cancel(boolean mayInterruptIfRunning) {
+ return false;
+ }
+
+ public boolean isCancelled() {
+ return false;
+ }
+
+ public boolean isDone() {
+ return future.isDone();
+ }
+
+ @SuppressWarnings("unchecked")
+ public V get() throws InterruptedException, ExecutionException {
+ try {
+ return (V) (((Result) future.get()).recreate());
+ } catch (RemotingException e) {
+ throw new ExecutionException(e.getMessage(), e);
+ } catch (Throwable e) {
+ throw new RpcException(e);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public V get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
+ int timeoutInMillis = (int) TimeUnit.MILLISECONDS.convert(timeout, unit);
+ try {
+ return (V) (((Result) future.get(timeoutInMillis)).recreate());
+ } catch (com.alibaba.dubbo.remoting.TimeoutException e) {
+ throw new TimeoutException(StringUtils.toString(e));
+ } catch (RemotingException e) {
+ throw new ExecutionException(e.getMessage(), e);
+ } catch (Throwable e) {
+ throw new RpcException(e);
+ }
+ }
+
}
\ No newline at end of file
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 b030c67f0b..7be36b95db 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
@@ -1,173 +1,173 @@
-/*
- * 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.rpc.protocol.dubbo;
-
-import com.alibaba.dubbo.common.Constants;
-import com.alibaba.dubbo.common.Parameters;
-import com.alibaba.dubbo.common.URL;
-import com.alibaba.dubbo.remoting.ChannelHandler;
-import com.alibaba.dubbo.remoting.RemotingException;
-import com.alibaba.dubbo.remoting.exchange.ExchangeClient;
-import com.alibaba.dubbo.remoting.exchange.ExchangeHandler;
-import com.alibaba.dubbo.remoting.exchange.ResponseFuture;
-
-import java.net.InetSocketAddress;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.atomic.AtomicInteger;
-
-/**
- * dubbo protocol support class.
- */
-@SuppressWarnings("deprecation")
-final class ReferenceCountExchangeClient implements ExchangeClient {
-
- private final URL url;
- private final AtomicInteger refenceCount = new AtomicInteger(0);
-
- // private final ExchangeHandler handler;
- private final ConcurrentMap<String, LazyConnectExchangeClient> ghostClientMap;
- private ExchangeClient client;
-
-
- public ReferenceCountExchangeClient(ExchangeClient client, ConcurrentMap<String, LazyConnectExchangeClient> ghostClientMap) {
- this.client = client;
- refenceCount.incrementAndGet();
- this.url = client.getUrl();
- if (ghostClientMap == null) {
- throw new IllegalStateException("ghostClientMap can not be null, url: " + url);
- }
- this.ghostClientMap = ghostClientMap;
- }
-
- public void reset(URL url) {
- client.reset(url);
- }
-
- public ResponseFuture request(Object request) throws RemotingException {
- return client.request(request);
- }
-
- public URL getUrl() {
- return client.getUrl();
- }
-
- public InetSocketAddress getRemoteAddress() {
- return client.getRemoteAddress();
- }
-
- public ChannelHandler getChannelHandler() {
- return client.getChannelHandler();
- }
-
- public ResponseFuture request(Object request, int timeout) throws RemotingException {
- return client.request(request, timeout);
- }
-
- public boolean isConnected() {
- return client.isConnected();
- }
-
- public void reconnect() throws RemotingException {
- client.reconnect();
- }
-
- public InetSocketAddress getLocalAddress() {
- return client.getLocalAddress();
- }
-
- public boolean hasAttribute(String key) {
- return client.hasAttribute(key);
- }
-
- public void reset(Parameters parameters) {
- client.reset(parameters);
- }
-
- public void send(Object message) throws RemotingException {
- client.send(message);
- }
-
- public ExchangeHandler getExchangeHandler() {
- return client.getExchangeHandler();
- }
-
- public Object getAttribute(String key) {
- return client.getAttribute(key);
- }
-
- public void send(Object message, boolean sent) throws RemotingException {
- client.send(message, sent);
- }
-
- public void setAttribute(String key, Object value) {
- client.setAttribute(key, value);
- }
-
- public void removeAttribute(String key) {
- client.removeAttribute(key);
- }
-
- /**
- * close() is not idempotent any longer
- */
- public void close() {
- close(0);
- }
-
- public void close(int timeout) {
- if (refenceCount.decrementAndGet() <= 0) {
- if (timeout == 0) {
- client.close();
- } else {
- client.close(timeout);
- }
- client = replaceWithLazyClient();
- }
- }
-
- public void startClose() {
- client.startClose();
- }
-
- // ghost client
- private LazyConnectExchangeClient replaceWithLazyClient() {
- // this is a defensive operation to avoid client is closed by accident, the initial state of the client is false
- URL lazyUrl = url.addParameter(Constants.LAZY_CONNECT_INITIAL_STATE_KEY, Boolean.FALSE)
- .addParameter(Constants.RECONNECT_KEY, Boolean.FALSE)
- .addParameter(Constants.SEND_RECONNECT_KEY, Boolean.TRUE.toString())
- .addParameter("warning", Boolean.TRUE.toString())
- .addParameter(LazyConnectExchangeClient.REQUEST_WITH_WARNING_KEY, true)
- .addParameter("_client_memo", "referencecounthandler.replacewithlazyclient");
-
- String key = url.getAddress();
- // in worst case there's only one ghost connection.
- LazyConnectExchangeClient gclient = ghostClientMap.get(key);
- if (gclient == null || gclient.isClosed()) {
- gclient = new LazyConnectExchangeClient(lazyUrl, client.getExchangeHandler());
- ghostClientMap.put(key, gclient);
- }
- return gclient;
- }
-
- public boolean isClosed() {
- return client.isClosed();
- }
-
- public void incrementAndGetCount() {
- refenceCount.incrementAndGet();
- }
+/*
+ * 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.rpc.protocol.dubbo;
+
+import com.alibaba.dubbo.common.Constants;
+import com.alibaba.dubbo.common.Parameters;
+import com.alibaba.dubbo.common.URL;
+import com.alibaba.dubbo.remoting.ChannelHandler;
+import com.alibaba.dubbo.remoting.RemotingException;
+import com.alibaba.dubbo.remoting.exchange.ExchangeClient;
+import com.alibaba.dubbo.remoting.exchange.ExchangeHandler;
+import com.alibaba.dubbo.remoting.exchange.ResponseFuture;
+
+import java.net.InetSocketAddress;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * dubbo protocol support class.
+ */
+@SuppressWarnings("deprecation")
+final class ReferenceCountExchangeClient implements ExchangeClient {
+
+ private final URL url;
+ private final AtomicInteger refenceCount = new AtomicInteger(0);
+
+ // private final ExchangeHandler handler;
+ private final ConcurrentMap<String, LazyConnectExchangeClient> ghostClientMap;
+ private ExchangeClient client;
+
+
+ public ReferenceCountExchangeClient(ExchangeClient client, ConcurrentMap<String, LazyConnectExchangeClient> ghostClientMap) {
+ this.client = client;
+ refenceCount.incrementAndGet();
+ this.url = client.getUrl();
+ if (ghostClientMap == null) {
+ throw new IllegalStateException("ghostClientMap can not be null, url: " + url);
+ }
+ this.ghostClientMap = ghostClientMap;
+ }
+
+ public void reset(URL url) {
+ client.reset(url);
+ }
+
+ public ResponseFuture request(Object request) throws RemotingException {
+ return client.request(request);
+ }
+
+ public URL getUrl() {
+ return client.getUrl();
+ }
+
+ public InetSocketAddress getRemoteAddress() {
+ return client.getRemoteAddress();
+ }
+
+ public ChannelHandler getChannelHandler() {
+ return client.getChannelHandler();
+ }
+
+ public ResponseFuture request(Object request, int timeout) throws RemotingException {
+ return client.request(request, timeout);
+ }
+
+ public boolean isConnected() {
+ return client.isConnected();
+ }
+
+ public void reconnect() throws RemotingException {
+ client.reconnect();
+ }
+
+ public InetSocketAddress getLocalAddress() {
+ return client.getLocalAddress();
+ }
+
+ public boolean hasAttribute(String key) {
+ return client.hasAttribute(key);
+ }
+
+ public void reset(Parameters parameters) {
+ client.reset(parameters);
+ }
+
+ public void send(Object message) throws RemotingException {
+ client.send(message);
+ }
+
+ public ExchangeHandler getExchangeHandler() {
+ return client.getExchangeHandler();
+ }
+
+ public Object getAttribute(String key) {
+ return client.getAttribute(key);
+ }
+
+ public void send(Object message, boolean sent) throws RemotingException {
+ client.send(message, sent);
+ }
+
+ public void setAttribute(String key, Object value) {
+ client.setAttribute(key, value);
+ }
+
+ public void removeAttribute(String key) {
+ client.removeAttribute(key);
+ }
+
+ /**
+ * close() is not idempotent any longer
+ */
+ public void close() {
+ close(0);
+ }
+
+ public void close(int timeout) {
+ if (refenceCount.decrementAndGet() <= 0) {
+ if (timeout == 0) {
+ client.close();
+ } else {
+ client.close(timeout);
+ }
+ client = replaceWithLazyClient();
+ }
+ }
+
+ public void startClose() {
+ client.startClose();
+ }
+
+ // ghost client
+ private LazyConnectExchangeClient replaceWithLazyClient() {
+ // this is a defensive operation to avoid client is closed by accident, the initial state of the client is false
+ URL lazyUrl = url.addParameter(Constants.LAZY_CONNECT_INITIAL_STATE_KEY, Boolean.FALSE)
+ .addParameter(Constants.RECONNECT_KEY, Boolean.FALSE)
+ .addParameter(Constants.SEND_RECONNECT_KEY, Boolean.TRUE.toString())
+ .addParameter("warning", Boolean.TRUE.toString())
+ .addParameter(LazyConnectExchangeClient.REQUEST_WITH_WARNING_KEY, true)
+ .addParameter("_client_memo", "referencecounthandler.replacewithlazyclient");
+
+ String key = url.getAddress();
+ // in worst case there's only one ghost connection.
+ LazyConnectExchangeClient gclient = ghostClientMap.get(key);
+ if (gclient == null || gclient.isClosed()) {
+ gclient = new LazyConnectExchangeClient(lazyUrl, client.getExchangeHandler());
+ ghostClientMap.put(key, gclient);
+ }
+ return gclient;
+ }
+
+ public boolean isClosed() {
+ return client.isClosed();
+ }
+
+ public void incrementAndGetCount() {
+ refenceCount.incrementAndGet();
+ }
}
\ No newline at end of file
diff --git a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/filter/FutureFilter.java b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/filter/FutureFilter.java
index d9494e353d..967cc8cb24 100644
--- a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/filter/FutureFilter.java
+++ b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/filter/FutureFilter.java
@@ -1,206 +1,206 @@
-/*
- * 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.rpc.protocol.dubbo.filter;
-
-import com.alibaba.dubbo.common.Constants;
-import com.alibaba.dubbo.common.extension.Activate;
-import com.alibaba.dubbo.common.logger.Logger;
-import com.alibaba.dubbo.common.logger.LoggerFactory;
-import com.alibaba.dubbo.remoting.exchange.ResponseCallback;
-import com.alibaba.dubbo.remoting.exchange.ResponseFuture;
-import com.alibaba.dubbo.rpc.Filter;
-import com.alibaba.dubbo.rpc.Invocation;
-import com.alibaba.dubbo.rpc.Invoker;
-import com.alibaba.dubbo.rpc.Result;
-import com.alibaba.dubbo.rpc.RpcContext;
-import com.alibaba.dubbo.rpc.RpcException;
-import com.alibaba.dubbo.rpc.StaticContext;
-import com.alibaba.dubbo.rpc.protocol.dubbo.FutureAdapter;
-import com.alibaba.dubbo.rpc.support.RpcUtils;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.concurrent.Future;
-
-/**
- * EventFilter
- */
-@Activate(group = Constants.CONSUMER)
-public class FutureFilter implements Filter {
-
- protected static final Logger logger = LoggerFactory.getLogger(FutureFilter.class);
-
- public Result invoke(final Invoker<?> invoker, final Invocation invocation) throws RpcException {
- final boolean isAsync = RpcUtils.isAsync(invoker.getUrl(), invocation);
-
- fireInvokeCallback(invoker, invocation);
- // need to configure if there's return value before the invocation in order to help invoker to judge if it's
- // necessary to return future.
- Result result = invoker.invoke(invocation);
- if (isAsync) {
- asyncCallback(invoker, invocation);
- } else {
- syncCallback(invoker, invocation, result);
- }
- return result;
- }
-
- private void syncCallback(final Invoker<?> invoker, final Invocation invocation, final Result result) {
- if (result.hasException()) {
- fireThrowCallback(invoker, invocation, result.getException());
- } else {
- fireReturnCallback(invoker, invocation, result.getValue());
- }
- }
-
- private void asyncCallback(final Invoker<?> invoker, final Invocation invocation) {
- Future<?> f = RpcContext.getContext().getFuture();
- if (f instanceof FutureAdapter) {
- ResponseFuture future = ((FutureAdapter<?>) f).getFuture();
- future.setCallback(new ResponseCallback() {
- public void done(Object rpcResult) {
- if (rpcResult == null) {
- logger.error(new IllegalStateException("invalid result value : null, expected " + Result.class.getName()));
- return;
- }
- ///must be rpcResult
- if (!(rpcResult instanceof Result)) {
- logger.error(new IllegalStateException("invalid result type :" + rpcResult.getClass() + ", expected " + Result.class.getName()));
- return;
- }
- Result result = (Result) rpcResult;
- if (result.hasException()) {
- fireThrowCallback(invoker, invocation, result.getException());
- } else {
- fireReturnCallback(invoker, invocation, result.getValue());
- }
- }
-
- public void caught(Throwable exception) {
- fireThrowCallback(invoker, invocation, exception);
- }
- });
- }
- }
-
- private void fireInvokeCallback(final Invoker<?> invoker, final Invocation invocation) {
- final Method onInvokeMethod = (Method) StaticContext.getSystemContext().get(StaticContext.getKey(invoker.getUrl(), invocation.getMethodName(), Constants.ON_INVOKE_METHOD_KEY));
- final Object onInvokeInst = StaticContext.getSystemContext().get(StaticContext.getKey(invoker.getUrl(), invocation.getMethodName(), Constants.ON_INVOKE_INSTANCE_KEY));
-
- if (onInvokeMethod == null && onInvokeInst == null) {
- return;
- }
- if (onInvokeMethod == null || onInvokeInst == null) {
- throw new IllegalStateException("service:" + invoker.getUrl().getServiceKey() + " has a onreturn callback config , but no such " + (onInvokeMethod == null ? "method" : "instance") + " found. url:" + invoker.getUrl());
- }
- if (onInvokeMethod != null && !onInvokeMethod.isAccessible()) {
- onInvokeMethod.setAccessible(true);
- }
-
- Object[] params = invocation.getArguments();
- try {
- onInvokeMethod.invoke(onInvokeInst, params);
- } catch (InvocationTargetException e) {
- fireThrowCallback(invoker, invocation, e.getTargetException());
- } catch (Throwable e) {
- fireThrowCallback(invoker, invocation, e);
- }
- }
-
- private void fireReturnCallback(final Invoker<?> invoker, final Invocation invocation, final Object result) {
- final Method onReturnMethod = (Method) StaticContext.getSystemContext().get(StaticContext.getKey(invoker.getUrl(), invocation.getMethodName(), Constants.ON_RETURN_METHOD_KEY));
- final Object onReturnInst = StaticContext.getSystemContext().get(StaticContext.getKey(invoker.getUrl(), invocation.getMethodName(), Constants.ON_RETURN_INSTANCE_KEY));
-
- //not set onreturn callback
- if (onReturnMethod == null && onReturnInst == null) {
- return;
- }
-
- if (onReturnMethod == null || onReturnInst == null) {
- throw new IllegalStateException("service:" + invoker.getUrl().getServiceKey() + " has a onreturn callback config , but no such " + (onReturnMethod == null ? "method" : "instance") + " found. url:" + invoker.getUrl());
- }
- if (onReturnMethod != null && !onReturnMethod.isAccessible()) {
- onReturnMethod.setAccessible(true);
- }
-
- Object[] args = invocation.getArguments();
- Object[] params;
- Class<?>[] rParaTypes = onReturnMethod.getParameterTypes();
- if (rParaTypes.length > 1) {
- if (rParaTypes.length == 2 && rParaTypes[1].isAssignableFrom(Object[].class)) {
- params = new Object[2];
- params[0] = result;
- params[1] = args;
- } else {
- params = new Object[args.length + 1];
- params[0] = result;
- System.arraycopy(args, 0, params, 1, args.length);
- }
- } else {
- params = new Object[]{result};
- }
- try {
- onReturnMethod.invoke(onReturnInst, params);
- } catch (InvocationTargetException e) {
- fireThrowCallback(invoker, invocation, e.getTargetException());
- } catch (Throwable e) {
- fireThrowCallback(invoker, invocation, e);
- }
- }
-
- private void fireThrowCallback(final Invoker<?> invoker, final Invocation invocation, final Throwable exception) {
- final Method onthrowMethod = (Method) StaticContext.getSystemContext().get(StaticContext.getKey(invoker.getUrl(), invocation.getMethodName(), Constants.ON_THROW_METHOD_KEY));
- final Object onthrowInst = StaticContext.getSystemContext().get(StaticContext.getKey(invoker.getUrl(), invocation.getMethodName(), Constants.ON_THROW_INSTANCE_KEY));
-
- //onthrow callback not configured
- if (onthrowMethod == null && onthrowInst == null) {
- return;
- }
- if (onthrowMethod == null || onthrowInst == null) {
- throw new IllegalStateException("service:" + invoker.getUrl().getServiceKey() + " has a onthrow callback config , but no such " + (onthrowMethod == null ? "method" : "instance") + " found. url:" + invoker.getUrl());
- }
- if (onthrowMethod != null && !onthrowMethod.isAccessible()) {
- onthrowMethod.setAccessible(true);
- }
- Class<?>[] rParaTypes = onthrowMethod.getParameterTypes();
- if (rParaTypes[0].isAssignableFrom(exception.getClass())) {
- try {
- Object[] args = invocation.getArguments();
- Object[] params;
-
- if (rParaTypes.length > 1) {
- if (rParaTypes.length == 2 && rParaTypes[1].isAssignableFrom(Object[].class)) {
- params = new Object[2];
- params[0] = exception;
- params[1] = args;
- } else {
- params = new Object[args.length + 1];
- params[0] = exception;
- System.arraycopy(args, 0, params, 1, args.length);
- }
- } else {
- params = new Object[]{exception};
- }
- onthrowMethod.invoke(onthrowInst, params);
- } catch (Throwable e) {
- logger.error(invocation.getMethodName() + ".call back method invoke error . callback method :" + onthrowMethod + ", url:" + invoker.getUrl(), e);
- }
- } else {
- logger.error(invocation.getMethodName() + ".call back method invoke error . callback method :" + onthrowMethod + ", url:" + invoker.getUrl(), exception);
- }
- }
+/*
+ * 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.rpc.protocol.dubbo.filter;
+
+import com.alibaba.dubbo.common.Constants;
+import com.alibaba.dubbo.common.extension.Activate;
+import com.alibaba.dubbo.common.logger.Logger;
+import com.alibaba.dubbo.common.logger.LoggerFactory;
+import com.alibaba.dubbo.remoting.exchange.ResponseCallback;
+import com.alibaba.dubbo.remoting.exchange.ResponseFuture;
+import com.alibaba.dubbo.rpc.Filter;
+import com.alibaba.dubbo.rpc.Invocation;
+import com.alibaba.dubbo.rpc.Invoker;
+import com.alibaba.dubbo.rpc.Result;
+import com.alibaba.dubbo.rpc.RpcContext;
+import com.alibaba.dubbo.rpc.RpcException;
+import com.alibaba.dubbo.rpc.StaticContext;
+import com.alibaba.dubbo.rpc.protocol.dubbo.FutureAdapter;
+import com.alibaba.dubbo.rpc.support.RpcUtils;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.concurrent.Future;
+
+/**
+ * EventFilter
+ */
+@Activate(group = Constants.CONSUMER)
+public class FutureFilter implements Filter {
+
+ protected static final Logger logger = LoggerFactory.getLogger(FutureFilter.class);
+
+ public Result invoke(final Invoker<?> invoker, final Invocation invocation) throws RpcException {
+ final boolean isAsync = RpcUtils.isAsync(invoker.getUrl(), invocation);
+
+ fireInvokeCallback(invoker, invocation);
+ // need to configure if there's return value before the invocation in order to help invoker to judge if it's
+ // necessary to return future.
+ Result result = invoker.invoke(invocation);
+ if (isAsync) {
+ asyncCallback(invoker, invocation);
+ } else {
+ syncCallback(invoker, invocation, result);
+ }
+ return result;
+ }
+
+ private void syncCallback(final Invoker<?> invoker, final Invocation invocation, final Result result) {
+ if (result.hasException()) {
+ fireThrowCallback(invoker, invocation, result.getException());
+ } else {
+ fireReturnCallback(invoker, invocation, result.getValue());
+ }
+ }
+
+ private void asyncCallback(final Invoker<?> invoker, final Invocation invocation) {
+ Future<?> f = RpcContext.getContext().getFuture();
+ if (f instanceof FutureAdapter) {
+ ResponseFuture future = ((FutureAdapter<?>) f).getFuture();
+ future.setCallback(new ResponseCallback() {
+ public void done(Object rpcResult) {
+ if (rpcResult == null) {
+ logger.error(new IllegalStateException("invalid result value : null, expected " + Result.class.getName()));
+ return;
+ }
+ ///must be rpcResult
+ if (!(rpcResult instanceof Result)) {
+ logger.error(new IllegalStateException("invalid result type :" + rpcResult.getClass() + ", expected " + Result.class.getName()));
+ return;
+ }
+ Result result = (Result) rpcResult;
+ if (result.hasException()) {
+ fireThrowCallback(invoker, invocation, result.getException());
+ } else {
+ fireReturnCallback(invoker, invocation, result.getValue());
+ }
+ }
+
+ public void caught(Throwable exception) {
+ fireThrowCallback(invoker, invocation, exception);
+ }
+ });
+ }
+ }
+
+ private void fireInvokeCallback(final Invoker<?> invoker, final Invocation invocation) {
+ final Method onInvokeMethod = (Method) StaticContext.getSystemContext().get(StaticContext.getKey(invoker.getUrl(), invocation.getMethodName(), Constants.ON_INVOKE_METHOD_KEY));
+ final Object onInvokeInst = StaticContext.getSystemContext().get(StaticContext.getKey(invoker.getUrl(), invocation.getMethodName(), Constants.ON_INVOKE_INSTANCE_KEY));
+
+ if (onInvokeMethod == null && onInvokeInst == null) {
+ return;
+ }
+ if (onInvokeMethod == null || onInvokeInst == null) {
+ throw new IllegalStateException("service:" + invoker.getUrl().getServiceKey() + " has a onreturn callback config , but no such " + (onInvokeMethod == null ? "method" : "instance") + " found. url:" + invoker.getUrl());
+ }
+ if (onInvokeMethod != null && !onInvokeMethod.isAccessible()) {
+ onInvokeMethod.setAccessible(true);
+ }
+
+ Object[] params = invocation.getArguments();
+ try {
+ onInvokeMethod.invoke(onInvokeInst, params);
+ } catch (InvocationTargetException e) {
+ fireThrowCallback(invoker, invocation, e.getTargetException());
+ } catch (Throwable e) {
+ fireThrowCallback(invoker, invocation, e);
+ }
+ }
+
+ private void fireReturnCallback(final Invoker<?> invoker, final Invocation invocation, final Object result) {
+ final Method onReturnMethod = (Method) StaticContext.getSystemContext().get(StaticContext.getKey(invoker.getUrl(), invocation.getMethodName(), Constants.ON_RETURN_METHOD_KEY));
+ final Object onReturnInst = StaticContext.getSystemContext().get(StaticContext.getKey(invoker.getUrl(), invocation.getMethodName(), Constants.ON_RETURN_INSTANCE_KEY));
+
+ //not set onreturn callback
+ if (onReturnMethod == null && onReturnInst == null) {
+ return;
+ }
+
+ if (onReturnMethod == null || onReturnInst == null) {
+ throw new IllegalStateException("service:" + invoker.getUrl().getServiceKey() + " has a onreturn callback config , but no such " + (onReturnMethod == null ? "method" : "instance") + " found. url:" + invoker.getUrl());
+ }
+ if (onReturnMethod != null && !onReturnMethod.isAccessible()) {
+ onReturnMethod.setAccessible(true);
+ }
+
+ Object[] args = invocation.getArguments();
+ Object[] params;
+ Class<?>[] rParaTypes = onReturnMethod.getParameterTypes();
+ if (rParaTypes.length > 1) {
+ if (rParaTypes.length == 2 && rParaTypes[1].isAssignableFrom(Object[].class)) {
+ params = new Object[2];
+ params[0] = result;
+ params[1] = args;
+ } else {
+ params = new Object[args.length + 1];
+ params[0] = result;
+ System.arraycopy(args, 0, params, 1, args.length);
+ }
+ } else {
+ params = new Object[]{result};
+ }
+ try {
+ onReturnMethod.invoke(onReturnInst, params);
+ } catch (InvocationTargetException e) {
+ fireThrowCallback(invoker, invocation, e.getTargetException());
+ } catch (Throwable e) {
+ fireThrowCallback(invoker, invocation, e);
+ }
+ }
+
+ private void fireThrowCallback(final Invoker<?> invoker, final Invocation invocation, final Throwable exception) {
+ final Method onthrowMethod = (Method) StaticContext.getSystemContext().get(StaticContext.getKey(invoker.getUrl(), invocation.getMethodName(), Constants.ON_THROW_METHOD_KEY));
+ final Object onthrowInst = StaticContext.getSystemContext().get(StaticContext.getKey(invoker.getUrl(), invocation.getMethodName(), Constants.ON_THROW_INSTANCE_KEY));
+
+ //onthrow callback not configured
+ if (onthrowMethod == null && onthrowInst == null) {
+ return;
+ }
+ if (onthrowMethod == null || onthrowInst == null) {
+ throw new IllegalStateException("service:" + invoker.getUrl().getServiceKey() + " has a onthrow callback config , but no such " + (onthrowMethod == null ? "method" : "instance") + " found. url:" + invoker.getUrl());
+ }
+ if (onthrowMethod != null && !onthrowMethod.isAccessible()) {
+ onthrowMethod.setAccessible(true);
+ }
+ Class<?>[] rParaTypes = onthrowMethod.getParameterTypes();
+ if (rParaTypes[0].isAssignableFrom(exception.getClass())) {
+ try {
+ Object[] args = invocation.getArguments();
+ Object[] params;
+
+ if (rParaTypes.length > 1) {
+ if (rParaTypes.length == 2 && rParaTypes[1].isAssignableFrom(Object[].class)) {
+ params = new Object[2];
+ params[0] = exception;
+ params[1] = args;
+ } else {
+ params = new Object[args.length + 1];
+ params[0] = exception;
+ System.arraycopy(args, 0, params, 1, args.length);
+ }
+ } else {
+ params = new Object[]{exception};
+ }
+ onthrowMethod.invoke(onthrowInst, params);
+ } catch (Throwable e) {
+ logger.error(invocation.getMethodName() + ".call back method invoke error . callback method :" + onthrowMethod + ", url:" + invoker.getUrl(), e);
+ }
+ } else {
+ logger.error(invocation.getMethodName() + ".call back method invoke error . callback method :" + onthrowMethod + ", url:" + invoker.getUrl(), exception);
+ }
+ }
}
\ No newline at end of file
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 3924ad9422..9ed34eeb90 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
@@ -1,127 +1,127 @@
-/*
- * 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.rpc.protocol.dubbo.filter;
-
-import com.alibaba.dubbo.common.Constants;
-import com.alibaba.dubbo.common.extension.Activate;
-import com.alibaba.fastjson.JSON;
-import com.alibaba.dubbo.common.logger.Logger;
-import com.alibaba.dubbo.common.logger.LoggerFactory;
-import com.alibaba.dubbo.common.utils.ConcurrentHashSet;
-import com.alibaba.dubbo.remoting.Channel;
-import com.alibaba.dubbo.rpc.Filter;
-import com.alibaba.dubbo.rpc.Invocation;
-import com.alibaba.dubbo.rpc.Invoker;
-import com.alibaba.dubbo.rpc.Result;
-import com.alibaba.dubbo.rpc.RpcContext;
-import com.alibaba.dubbo.rpc.RpcException;
-
-import java.util.ArrayList;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.atomic.AtomicInteger;
-
-/**
- * TraceFilter
- */
-@Activate(group = Constants.PROVIDER)
-public class TraceFilter implements Filter {
-
- private static final Logger logger = LoggerFactory.getLogger(TraceFilter.class);
-
- private static final String TRACE_MAX = "trace.max";
-
- private static final String TRACE_COUNT = "trace.count";
-
- private static final ConcurrentMap<String, Set<Channel>> tracers = new ConcurrentHashMap<String, Set<Channel>>();
-
- public static void addTracer(Class<?> type, String method, Channel channel, int max) {
- channel.setAttribute(TRACE_MAX, max);
- channel.setAttribute(TRACE_COUNT, new AtomicInteger());
- String key = method != null && method.length() > 0 ? type.getName() + "." + method : type.getName();
- Set<Channel> channels = tracers.get(key);
- if (channels == null) {
- tracers.putIfAbsent(key, new ConcurrentHashSet<Channel>());
- channels = tracers.get(key);
- }
- channels.add(channel);
- }
-
- public static void removeTracer(Class<?> type, String method, Channel channel) {
- channel.removeAttribute(TRACE_MAX);
- channel.removeAttribute(TRACE_COUNT);
- String key = method != null && method.length() > 0 ? type.getName() + "." + method : type.getName();
- Set<Channel> channels = tracers.get(key);
- if (channels != null) {
- channels.remove(channel);
- }
- }
-
- public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
- long start = System.currentTimeMillis();
- Result result = invoker.invoke(invocation);
- long end = System.currentTimeMillis();
- if (tracers.size() > 0) {
- String key = invoker.getInterface().getName() + "." + invocation.getMethodName();
- Set<Channel> channels = tracers.get(key);
- if (channels == null || channels.size() == 0) {
- key = invoker.getInterface().getName();
- channels = tracers.get(key);
- }
- if (channels != null && channels.size() > 0) {
- for (Channel channel : new ArrayList<Channel>(channels)) {
- if (channel.isConnected()) {
- try {
- int max = 1;
- Integer m = (Integer) channel.getAttribute(TRACE_MAX);
- if (m != null) {
- max = (int) m;
- }
- int count = 0;
- AtomicInteger c = (AtomicInteger) channel.getAttribute(TRACE_COUNT);
- if (c == null) {
- c = new AtomicInteger();
- channel.setAttribute(TRACE_COUNT, c);
- }
- count = c.getAndIncrement();
- if (count < max) {
- String prompt = channel.getUrl().getParameter(Constants.PROMPT_KEY, Constants.DEFAULT_PROMPT);
- channel.send("\r\n" + RpcContext.getContext().getRemoteAddress() + " -> "
- + invoker.getInterface().getName()
- + "." + invocation.getMethodName()
- + "(" + JSON.toJSONString(invocation.getArguments()) + ")" + " -> " + JSON.toJSONString(result.getValue())
- + "\r\nelapsed: " + (end - start) + " ms."
- + "\r\n\r\n" + prompt);
- }
- if (count >= max - 1) {
- channels.remove(channel);
- }
- } catch (Throwable e) {
- channels.remove(channel);
- logger.warn(e.getMessage(), e);
- }
- } else {
- channels.remove(channel);
- }
- }
- }
- }
- return result;
- }
-
+/*
+ * 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.rpc.protocol.dubbo.filter;
+
+import com.alibaba.dubbo.common.Constants;
+import com.alibaba.dubbo.common.extension.Activate;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.dubbo.common.logger.Logger;
+import com.alibaba.dubbo.common.logger.LoggerFactory;
+import com.alibaba.dubbo.common.utils.ConcurrentHashSet;
+import com.alibaba.dubbo.remoting.Channel;
+import com.alibaba.dubbo.rpc.Filter;
+import com.alibaba.dubbo.rpc.Invocation;
+import com.alibaba.dubbo.rpc.Invoker;
+import com.alibaba.dubbo.rpc.Result;
+import com.alibaba.dubbo.rpc.RpcContext;
+import com.alibaba.dubbo.rpc.RpcException;
+
+import java.util.ArrayList;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * TraceFilter
+ */
+@Activate(group = Constants.PROVIDER)
+public class TraceFilter implements Filter {
+
+ private static final Logger logger = LoggerFactory.getLogger(TraceFilter.class);
+
+ private static final String TRACE_MAX = "trace.max";
+
+ private static final String TRACE_COUNT = "trace.count";
+
+ private static final ConcurrentMap<String, Set<Channel>> tracers = new ConcurrentHashMap<String, Set<Channel>>();
+
+ public static void addTracer(Class<?> type, String method, Channel channel, int max) {
+ channel.setAttribute(TRACE_MAX, max);
+ channel.setAttribute(TRACE_COUNT, new AtomicInteger());
+ String key = method != null && method.length() > 0 ? type.getName() + "." + method : type.getName();
+ Set<Channel> channels = tracers.get(key);
+ if (channels == null) {
+ tracers.putIfAbsent(key, new ConcurrentHashSet<Channel>());
+ channels = tracers.get(key);
+ }
+ channels.add(channel);
+ }
+
+ public static void removeTracer(Class<?> type, String method, Channel channel) {
+ channel.removeAttribute(TRACE_MAX);
+ channel.removeAttribute(TRACE_COUNT);
+ String key = method != null && method.length() > 0 ? type.getName() + "." + method : type.getName();
+ Set<Channel> channels = tracers.get(key);
+ if (channels != null) {
+ channels.remove(channel);
+ }
+ }
+
+ public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
+ long start = System.currentTimeMillis();
+ Result result = invoker.invoke(invocation);
+ long end = System.currentTimeMillis();
+ if (tracers.size() > 0) {
+ String key = invoker.getInterface().getName() + "." + invocation.getMethodName();
+ Set<Channel> channels = tracers.get(key);
+ if (channels == null || channels.size() == 0) {
+ key = invoker.getInterface().getName();
+ channels = tracers.get(key);
+ }
+ if (channels != null && channels.size() > 0) {
+ for (Channel channel : new ArrayList<Channel>(channels)) {
+ if (channel.isConnected()) {
+ try {
+ int max = 1;
+ Integer m = (Integer) channel.getAttribute(TRACE_MAX);
+ if (m != null) {
+ max = (int) m;
+ }
+ int count = 0;
+ AtomicInteger c = (AtomicInteger) channel.getAttribute(TRACE_COUNT);
+ if (c == null) {
+ c = new AtomicInteger();
+ channel.setAttribute(TRACE_COUNT, c);
+ }
+ count = c.getAndIncrement();
+ if (count < max) {
+ String prompt = channel.getUrl().getParameter(Constants.PROMPT_KEY, Constants.DEFAULT_PROMPT);
+ channel.send("\r\n" + RpcContext.getContext().getRemoteAddress() + " -> "
+ + invoker.getInterface().getName()
+ + "." + invocation.getMethodName()
+ + "(" + JSON.toJSONString(invocation.getArguments()) + ")" + " -> " + JSON.toJSONString(result.getValue())
+ + "\r\nelapsed: " + (end - start) + " ms."
+ + "\r\n\r\n" + prompt);
+ }
+ if (count >= max - 1) {
+ channels.remove(channel);
+ }
+ } catch (Throwable e) {
+ channels.remove(channel);
+ logger.warn(e.getMessage(), e);
+ }
+ } else {
+ channels.remove(channel);
+ }
+ }
+ }
+ }
+ return result;
+ }
+
}
\ No newline at end of file
diff --git a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/page/ClientsPageHandler.java b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/page/ClientsPageHandler.java
index a841e0d2d6..b9f7594c30 100644
--- a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/page/ClientsPageHandler.java
+++ b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/page/ClientsPageHandler.java
@@ -1,77 +1,77 @@
-/*
- * 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.rpc.protocol.dubbo.page;
-
-import com.alibaba.dubbo.common.URL;
-import com.alibaba.dubbo.common.utils.NetUtils;
-import com.alibaba.dubbo.container.page.Page;
-import com.alibaba.dubbo.container.page.PageHandler;
-import com.alibaba.dubbo.remoting.exchange.ExchangeChannel;
-import com.alibaba.dubbo.remoting.exchange.ExchangeServer;
-import com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-/**
- * ClientsPageHandler
- */
-public class ClientsPageHandler implements PageHandler {
-
- public Page handle(URL url) {
- String port = url.getParameter("port");
- int p = port == null || port.length() == 0 ? 0 : Integer.parseInt(port);
- Collection<ExchangeServer> servers = DubboProtocol.getDubboProtocol().getServers();
- ExchangeServer server = null;
- StringBuilder select = new StringBuilder();
- if (servers != null && servers.size() > 0) {
- if (servers.size() == 1) {
- server = servers.iterator().next();
- String address = server.getUrl().getAddress();
- select.append(" > " + NetUtils.getHostName(address) + "/" + address);
- } else {
- select.append(" > <select onchange=\"window.location.href='clients.html?port=' + this.value;\">");
- for (ExchangeServer s : servers) {
- int sp = s.getUrl().getPort();
- select.append("<option value=\">");
- select.append(sp);
- if (p == 0 && server == null || p == sp) {
- server = s;
- select.append("\" selected=\"selected");
- }
- select.append("\">");
- select.append(s.getUrl().getAddress());
- select.append("</option>");
- }
- select.append("</select>");
- }
- }
- List<List<String>> rows = new ArrayList<List<String>>();
- if (server != null) {
- Collection<ExchangeChannel> channels = server.getExchangeChannels();
- for (ExchangeChannel c : channels) {
- List<String> row = new ArrayList<String>();
- String address = NetUtils.toAddressString(c.getRemoteAddress());
- row.add(NetUtils.getHostName(address) + "/" + address);
- rows.add(row);
- }
- }
- return new Page("<a href=\"servers.html\">Servers</a>" + select.toString() + " > Clients", "Clients (" + rows.size() + ")", new String[]{"Client Address:"}, rows);
- }
-
+/*
+ * 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.rpc.protocol.dubbo.page;
+
+import com.alibaba.dubbo.common.URL;
+import com.alibaba.dubbo.common.utils.NetUtils;
+import com.alibaba.dubbo.container.page.Page;
+import com.alibaba.dubbo.container.page.PageHandler;
+import com.alibaba.dubbo.remoting.exchange.ExchangeChannel;
+import com.alibaba.dubbo.remoting.exchange.ExchangeServer;
+import com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * ClientsPageHandler
+ */
+public class ClientsPageHandler implements PageHandler {
+
+ public Page handle(URL url) {
+ String port = url.getParameter("port");
+ int p = port == null || port.length() == 0 ? 0 : Integer.parseInt(port);
+ Collection<ExchangeServer> servers = DubboProtocol.getDubboProtocol().getServers();
+ ExchangeServer server = null;
+ StringBuilder select = new StringBuilder();
+ if (servers != null && servers.size() > 0) {
+ if (servers.size() == 1) {
+ server = servers.iterator().next();
+ String address = server.getUrl().getAddress();
+ select.append(" > " + NetUtils.getHostName(address) + "/" + address);
+ } else {
+ select.append(" > <select onchange=\"window.location.href='clients.html?port=' + this.value;\">");
+ for (ExchangeServer s : servers) {
+ int sp = s.getUrl().getPort();
+ select.append("<option value=\">");
+ select.append(sp);
+ if (p == 0 && server == null || p == sp) {
+ server = s;
+ select.append("\" selected=\"selected");
+ }
+ select.append("\">");
+ select.append(s.getUrl().getAddress());
+ select.append("</option>");
+ }
+ select.append("</select>");
+ }
+ }
+ List<List<String>> rows = new ArrayList<List<String>>();
+ if (server != null) {
+ Collection<ExchangeChannel> channels = server.getExchangeChannels();
+ for (ExchangeChannel c : channels) {
+ List<String> row = new ArrayList<String>();
+ String address = NetUtils.toAddressString(c.getRemoteAddress());
+ row.add(NetUtils.getHostName(address) + "/" + address);
+ rows.add(row);
+ }
+ }
+ return new Page("<a href=\"servers.html\">Servers</a>" + select.toString() + " > Clients", "Clients (" + rows.size() + ")", new String[]{"Client Address:"}, rows);
+ }
+
}
\ No newline at end of file
diff --git a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/page/ServersPageHandler.java b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/page/ServersPageHandler.java
index b6e1c32157..e8d7bb77fd 100644
--- a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/page/ServersPageHandler.java
+++ b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/page/ServersPageHandler.java
@@ -1,55 +1,55 @@
-/*
- * 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.rpc.protocol.dubbo.page;
-
-import com.alibaba.dubbo.common.URL;
-import com.alibaba.dubbo.common.utils.NetUtils;
-import com.alibaba.dubbo.container.page.Menu;
-import com.alibaba.dubbo.container.page.Page;
-import com.alibaba.dubbo.container.page.PageHandler;
-import com.alibaba.dubbo.remoting.exchange.ExchangeServer;
-import com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-/**
- * ServersPageHandler
- */
-@Menu(name = "Servers", desc = "Show exported service servers.", order = 14000)
-public class ServersPageHandler implements PageHandler {
-
- public Page handle(URL url) {
- List<List<String>> rows = new ArrayList<List<String>>();
- Collection<ExchangeServer> servers = DubboProtocol.getDubboProtocol().getServers();
- int clientCount = 0;
- if (servers != null && servers.size() > 0) {
- for (ExchangeServer s : servers) {
- List<String> row = new ArrayList<String>();
- String address = s.getUrl().getAddress();
- row.add(NetUtils.getHostName(address) + "/" + address);
- int clientSize = s.getExchangeChannels().size();
- clientCount += clientSize;
- row.add("<a href=\"clients.html?port=" + s.getUrl().getPort() + "\">Clients(" + clientSize + ")</a>");
- rows.add(row);
- }
- }
- return new Page("Servers", "Servers (" + rows.size() + ")", new String[]{"Server Address:", "Clients(" + clientCount + ")"}, rows);
- }
-
+/*
+ * 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.rpc.protocol.dubbo.page;
+
+import com.alibaba.dubbo.common.URL;
+import com.alibaba.dubbo.common.utils.NetUtils;
+import com.alibaba.dubbo.container.page.Menu;
+import com.alibaba.dubbo.container.page.Page;
+import com.alibaba.dubbo.container.page.PageHandler;
+import com.alibaba.dubbo.remoting.exchange.ExchangeServer;
+import com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * ServersPageHandler
+ */
+@Menu(name = "Servers", desc = "Show exported service servers.", order = 14000)
+public class ServersPageHandler implements PageHandler {
+
+ public Page handle(URL url) {
+ List<List<String>> rows = new ArrayList<List<String>>();
+ Collection<ExchangeServer> servers = DubboProtocol.getDubboProtocol().getServers();
+ int clientCount = 0;
+ if (servers != null && servers.size() > 0) {
+ for (ExchangeServer s : servers) {
+ List<String> row = new ArrayList<String>();
+ String address = s.getUrl().getAddress();
+ row.add(NetUtils.getHostName(address) + "/" + address);
+ int clientSize = s.getExchangeChannels().size();
+ clientCount += clientSize;
+ row.add("<a href=\"clients.html?port=" + s.getUrl().getPort() + "\">Clients(" + clientSize + ")</a>");
+ rows.add(row);
+ }
+ }
+ return new Page("Servers", "Servers (" + rows.size() + ")", new String[]{"Server Address:", "Clients(" + clientCount + ")"}, rows);
+ }
+
}
\ No newline at end of file
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 00f47ad7ff..09af47c0b9 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
@@ -1,58 +1,58 @@
-/*
- * 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.rpc.protocol.dubbo.status;
-
-import com.alibaba.dubbo.common.extension.Activate;
-import com.alibaba.dubbo.common.status.Status;
-import com.alibaba.dubbo.common.status.StatusChecker;
-import com.alibaba.dubbo.remoting.exchange.ExchangeServer;
-import com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol;
-
-import java.util.Collection;
-
-/**
- * ServerStatusChecker
- */
-@Activate
-public class ServerStatusChecker implements StatusChecker {
-
- public Status check() {
- Collection<ExchangeServer> servers = DubboProtocol.getDubboProtocol().getServers();
- if (servers == null || servers.size() == 0) {
- return new Status(Status.Level.UNKNOWN);
- }
- Status.Level level = Status.Level.OK;
- StringBuilder buf = new StringBuilder();
- for (ExchangeServer server : servers) {
- if (!server.isBound()) {
- level = Status.Level.ERROR;
- buf.setLength(0);
- buf.append(server.getLocalAddress());
- break;
- }
- if (buf.length() > 0) {
- buf.append(",");
- }
- buf.append(server.getLocalAddress());
- buf.append("(clients:");
- buf.append(server.getChannels().size());
- buf.append(")");
- }
- return new Status(level, buf.toString());
- }
-
+/*
+ * 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.rpc.protocol.dubbo.status;
+
+import com.alibaba.dubbo.common.extension.Activate;
+import com.alibaba.dubbo.common.status.Status;
+import com.alibaba.dubbo.common.status.StatusChecker;
+import com.alibaba.dubbo.remoting.exchange.ExchangeServer;
+import com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol;
+
+import java.util.Collection;
+
+/**
+ * ServerStatusChecker
+ */
+@Activate
+public class ServerStatusChecker implements StatusChecker {
+
+ public Status check() {
+ Collection<ExchangeServer> servers = DubboProtocol.getDubboProtocol().getServers();
+ if (servers == null || servers.size() == 0) {
+ return new Status(Status.Level.UNKNOWN);
+ }
+ Status.Level level = Status.Level.OK;
+ StringBuilder buf = new StringBuilder();
+ for (ExchangeServer server : servers) {
+ if (!server.isBound()) {
+ level = Status.Level.ERROR;
+ buf.setLength(0);
+ buf.append(server.getLocalAddress());
+ break;
+ }
+ if (buf.length() > 0) {
+ buf.append(",");
+ }
+ buf.append(server.getLocalAddress());
+ buf.append("(clients:");
+ buf.append(server.getChannels().size());
+ buf.append(")");
+ }
+ return new Status(level, buf.toString());
+ }
+
}
\ No newline at end of file
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 bf299a7e9f..89f67b8af0 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
@@ -1,70 +1,70 @@
-/*
- * 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.rpc.protocol.dubbo.status;
-
-import com.alibaba.dubbo.common.Constants;
-import com.alibaba.dubbo.common.extension.Activate;
-import com.alibaba.dubbo.common.extension.ExtensionLoader;
-import com.alibaba.dubbo.common.status.Status;
-import com.alibaba.dubbo.common.status.StatusChecker;
-import com.alibaba.dubbo.common.store.DataStore;
-
-import java.util.Map;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.ThreadPoolExecutor;
-
-/**
- * ThreadPoolStatusChecker
- */
-@Activate
-public class ThreadPoolStatusChecker implements StatusChecker {
-
- public Status check() {
- DataStore dataStore = ExtensionLoader.getExtensionLoader(DataStore.class).getDefaultExtension();
- Map<String, Object> executors = dataStore.get(Constants.EXECUTOR_SERVICE_COMPONENT_KEY);
-
- StringBuilder msg = new StringBuilder();
- Status.Level level = Status.Level.OK;
- for (Map.Entry<String, Object> entry : executors.entrySet()) {
- String port = entry.getKey();
- ExecutorService executor = (ExecutorService) entry.getValue();
-
- if (executor != null && executor instanceof ThreadPoolExecutor) {
- ThreadPoolExecutor tp = (ThreadPoolExecutor) executor;
- boolean ok = tp.getActiveCount() < tp.getMaximumPoolSize() - 1;
- Status.Level lvl = Status.Level.OK;
- if (!ok) {
- level = Status.Level.WARN;
- lvl = Status.Level.WARN;
- }
-
- if (msg.length() > 0) {
- msg.append(";");
- }
- msg.append("Pool status:" + lvl
- + ", max:" + tp.getMaximumPoolSize()
- + ", core:" + tp.getCorePoolSize()
- + ", largest:" + tp.getLargestPoolSize()
- + ", active:" + tp.getActiveCount()
- + ", task:" + tp.getTaskCount()
- + ", service port: " + port);
- }
- }
- return msg.length() == 0 ? new Status(Status.Level.UNKNOWN) : new Status(level, msg.toString());
- }
-
+/*
+ * 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.rpc.protocol.dubbo.status;
+
+import com.alibaba.dubbo.common.Constants;
+import com.alibaba.dubbo.common.extension.Activate;
+import com.alibaba.dubbo.common.extension.ExtensionLoader;
+import com.alibaba.dubbo.common.status.Status;
+import com.alibaba.dubbo.common.status.StatusChecker;
+import com.alibaba.dubbo.common.store.DataStore;
+
+import java.util.Map;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.ThreadPoolExecutor;
+
+/**
+ * ThreadPoolStatusChecker
+ */
+@Activate
+public class ThreadPoolStatusChecker implements StatusChecker {
+
+ public Status check() {
+ DataStore dataStore = ExtensionLoader.getExtensionLoader(DataStore.class).getDefaultExtension();
+ Map<String, Object> executors = dataStore.get(Constants.EXECUTOR_SERVICE_COMPONENT_KEY);
+
+ StringBuilder msg = new StringBuilder();
+ Status.Level level = Status.Level.OK;
+ for (Map.Entry<String, Object> entry : executors.entrySet()) {
+ String port = entry.getKey();
+ ExecutorService executor = (ExecutorService) entry.getValue();
+
+ if (executor != null && executor instanceof ThreadPoolExecutor) {
+ ThreadPoolExecutor tp = (ThreadPoolExecutor) executor;
+ boolean ok = tp.getActiveCount() < tp.getMaximumPoolSize() - 1;
+ Status.Level lvl = Status.Level.OK;
+ if (!ok) {
+ level = Status.Level.WARN;
+ lvl = Status.Level.WARN;
+ }
+
+ if (msg.length() > 0) {
+ msg.append(";");
+ }
+ msg.append("Pool status:" + lvl
+ + ", max:" + tp.getMaximumPoolSize()
+ + ", core:" + tp.getCorePoolSize()
+ + ", largest:" + tp.getLargestPoolSize()
+ + ", active:" + tp.getActiveCount()
+ + ", task:" + tp.getTaskCount()
+ + ", service port: " + port);
+ }
+ }
+ return msg.length() == 0 ? new Status(Status.Level.UNKNOWN) : new Status(level, msg.toString());
+ }
+
}
\ No newline at end of file
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 7e2c7a9694..712ec967e4 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
@@ -1,64 +1,64 @@
-/*
- * 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.rpc.protocol.dubbo.telnet;
-
-import com.alibaba.dubbo.common.extension.Activate;
-import com.alibaba.dubbo.remoting.Channel;
-import com.alibaba.dubbo.remoting.telnet.TelnetHandler;
-import com.alibaba.dubbo.remoting.telnet.support.Help;
-import com.alibaba.dubbo.rpc.Exporter;
-import com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol;
-
-/**
- * ChangeServiceTelnetHandler
- */
-@Activate
-@Help(parameter = "[service]", summary = "Change default service.", detail = "Change default service.")
-public class ChangeTelnetHandler implements TelnetHandler {
-
- public static final String SERVICE_KEY = "telnet.service";
-
- 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";
- }
- StringBuilder buf = new StringBuilder();
- if (message.equals("/") || message.equals("..")) {
- String service = (String) channel.getAttribute(SERVICE_KEY);
- channel.removeAttribute(SERVICE_KEY);
- buf.append("Cancelled default service " + service + ".");
- } else {
- boolean found = false;
- for (Exporter<?> exporter : DubboProtocol.getDubboProtocol().getExporters()) {
- if (message.equals(exporter.getInvoker().getInterface().getSimpleName())
- || message.equals(exporter.getInvoker().getInterface().getName())
- || message.equals(exporter.getInvoker().getUrl().getPath())) {
- found = true;
- break;
- }
- }
- if (found) {
- channel.setAttribute(SERVICE_KEY, message);
- buf.append("Used the " + message + " as default.\r\nYou can cancel default service by command: cd /");
- } else {
- buf.append("No such service " + message);
- }
- }
- return buf.toString();
- }
-
+/*
+ * 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.rpc.protocol.dubbo.telnet;
+
+import com.alibaba.dubbo.common.extension.Activate;
+import com.alibaba.dubbo.remoting.Channel;
+import com.alibaba.dubbo.remoting.telnet.TelnetHandler;
+import com.alibaba.dubbo.remoting.telnet.support.Help;
+import com.alibaba.dubbo.rpc.Exporter;
+import com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol;
+
+/**
+ * ChangeServiceTelnetHandler
+ */
+@Activate
+@Help(parameter = "[service]", summary = "Change default service.", detail = "Change default service.")
+public class ChangeTelnetHandler implements TelnetHandler {
+
+ public static final String SERVICE_KEY = "telnet.service";
+
+ 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";
+ }
+ StringBuilder buf = new StringBuilder();
+ if (message.equals("/") || message.equals("..")) {
+ String service = (String) channel.getAttribute(SERVICE_KEY);
+ channel.removeAttribute(SERVICE_KEY);
+ buf.append("Cancelled default service " + service + ".");
+ } else {
+ boolean found = false;
+ for (Exporter<?> exporter : DubboProtocol.getDubboProtocol().getExporters()) {
+ if (message.equals(exporter.getInvoker().getInterface().getSimpleName())
+ || message.equals(exporter.getInvoker().getInterface().getName())
+ || message.equals(exporter.getInvoker().getUrl().getPath())) {
+ found = true;
+ break;
+ }
+ }
+ if (found) {
+ channel.setAttribute(SERVICE_KEY, message);
+ buf.append("Used the " + message + " as default.\r\nYou can cancel default service by command: cd /");
+ } else {
+ buf.append("No such service " + message);
+ }
+ }
+ return buf.toString();
+ }
+
}
\ No newline at end of file
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 2fd1b6aa2f..292f5a0ad7 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
@@ -1,165 +1,165 @@
-/*
- * 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.rpc.protocol.dubbo.telnet;
-
-import com.alibaba.dubbo.common.URL;
-import com.alibaba.dubbo.common.extension.Activate;
-import com.alibaba.dubbo.common.utils.StringUtils;
-import com.alibaba.dubbo.remoting.Channel;
-import com.alibaba.dubbo.remoting.RemotingException;
-import com.alibaba.dubbo.remoting.telnet.TelnetHandler;
-import com.alibaba.dubbo.remoting.telnet.support.Help;
-import com.alibaba.dubbo.remoting.telnet.support.TelnetUtils;
-import com.alibaba.dubbo.rpc.Exporter;
-import com.alibaba.dubbo.rpc.Invoker;
-import com.alibaba.dubbo.rpc.RpcStatus;
-import com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol;
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * CountTelnetHandler
- */
-@Activate
-@Help(parameter = "[service] [method] [times]", summary = "Count the service.", detail = "Count the service.")
-public class CountTelnetHandler implements TelnetHandler {
-
- public String telnet(final Channel channel, String message) {
- String service = (String) channel.getAttribute(ChangeTelnetHandler.SERVICE_KEY);
- if ((service == null || service.length() == 0)
- && (message == null || message.length() == 0)) {
- return "Please input service name, eg: \r\ncount XxxService\r\ncount XxxService xxxMethod\r\ncount XxxService xxxMethod 10\r\nor \"cd XxxService\" firstly.";
- }
- StringBuilder buf = new StringBuilder();
- if (service != null && service.length() > 0) {
- buf.append("Use default service " + service + ".\r\n");
- }
- String[] parts = message.split("\\s+");
- String method;
- String times;
- if (service == null || service.length() == 0) {
- service = parts.length > 0 ? parts[0] : null;
- method = parts.length > 1 ? parts[1] : null;
- } else {
- method = parts.length > 0 ? parts[0] : null;
- }
- if (StringUtils.isInteger(method)) {
- times = method;
- method = null;
- } else {
- times = parts.length > 2 ? parts[2] : "1";
- }
- if (!StringUtils.isInteger(times)) {
- return "Illegal times " + times + ", must be integer.";
- }
- final int t = Integer.parseInt(times);
- Invoker<?> invoker = null;
- for (Exporter<?> exporter : DubboProtocol.getDubboProtocol().getExporters()) {
- if (service.equals(exporter.getInvoker().getInterface().getSimpleName())
- || service.equals(exporter.getInvoker().getInterface().getName())
- || service.equals(exporter.getInvoker().getUrl().getPath())) {
- invoker = exporter.getInvoker();
- break;
- }
- }
- if (invoker != null) {
- if (t > 0) {
- final String mtd = method;
- final Invoker<?> inv = invoker;
- final String prompt = channel.getUrl().getParameter("prompt", "telnet");
- Thread thread = new Thread(new Runnable() {
- public void run() {
- for (int i = 0; i < t; i++) {
- String result = count(inv, mtd);
- try {
- channel.send("\r\n" + result);
- } catch (RemotingException e1) {
- return;
- }
- if (i < t - 1) {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- }
- }
- }
- try {
- channel.send("\r\n" + prompt + "> ");
- } catch (RemotingException e1) {
- return;
- }
- }
- }, "TelnetCount");
- thread.setDaemon(true);
- thread.start();
- }
- } else {
- buf.append("No such service " + service);
- }
- return buf.toString();
- }
-
- private String count(Invoker<?> invoker, String method) {
- URL url = invoker.getUrl();
- List<List<String>> table = new ArrayList<List<String>>();
- List<String> header = new ArrayList<String>();
- header.add("method");
- header.add("total");
- header.add("failed");
- header.add("active");
- header.add("average");
- header.add("max");
- if (method == null || method.length() == 0) {
- for (Method m : invoker.getInterface().getMethods()) {
- RpcStatus count = RpcStatus.getStatus(url, m.getName());
- List<String> row = new ArrayList<String>();
- row.add(m.getName());
- row.add(String.valueOf(count.getTotal()));
- row.add(String.valueOf(count.getFailed()));
- row.add(String.valueOf(count.getActive()));
- row.add(String.valueOf(count.getSucceededAverageElapsed()) + "ms");
- row.add(String.valueOf(count.getSucceededMaxElapsed()) + "ms");
- table.add(row);
- }
- } else {
- boolean found = false;
- for (Method m : invoker.getInterface().getMethods()) {
- if (m.getName().equals(method)) {
- found = true;
- break;
- }
- }
- if (found) {
- RpcStatus count = RpcStatus.getStatus(url, method);
- List<String> row = new ArrayList<String>();
- row.add(method);
- row.add(String.valueOf(count.getTotal()));
- row.add(String.valueOf(count.getFailed()));
- row.add(String.valueOf(count.getActive()));
- row.add(String.valueOf(count.getSucceededAverageElapsed()) + "ms");
- row.add(String.valueOf(count.getSucceededMaxElapsed()) + "ms");
- table.add(row);
- } else {
- return "No such method " + method + " in class " + invoker.getInterface().getName();
- }
- }
- return TelnetUtils.toTable(header, table);
- }
-
+/*
+ * 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.rpc.protocol.dubbo.telnet;
+
+import com.alibaba.dubbo.common.URL;
+import com.alibaba.dubbo.common.extension.Activate;
+import com.alibaba.dubbo.common.utils.StringUtils;
+import com.alibaba.dubbo.remoting.Channel;
+import com.alibaba.dubbo.remoting.RemotingException;
+import com.alibaba.dubbo.remoting.telnet.TelnetHandler;
+import com.alibaba.dubbo.remoting.telnet.support.Help;
+import com.alibaba.dubbo.remoting.telnet.support.TelnetUtils;
+import com.alibaba.dubbo.rpc.Exporter;
+import com.alibaba.dubbo.rpc.Invoker;
+import com.alibaba.dubbo.rpc.RpcStatus;
+import com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * CountTelnetHandler
+ */
+@Activate
+@Help(parameter = "[service] [method] [times]", summary = "Count the service.", detail = "Count the service.")
+public class CountTelnetHandler implements TelnetHandler {
+
+ public String telnet(final Channel channel, String message) {
+ String service = (String) channel.getAttribute(ChangeTelnetHandler.SERVICE_KEY);
+ if ((service == null || service.length() == 0)
+ && (message == null || message.length() == 0)) {
+ return "Please input service name, eg: \r\ncount XxxService\r\ncount XxxService xxxMethod\r\ncount XxxService xxxMethod 10\r\nor \"cd XxxService\" firstly.";
+ }
+ StringBuilder buf = new StringBuilder();
+ if (service != null && service.length() > 0) {
+ buf.append("Use default service " + service + ".\r\n");
+ }
+ String[] parts = message.split("\\s+");
+ String method;
+ String times;
+ if (service == null || service.length() == 0) {
+ service = parts.length > 0 ? parts[0] : null;
+ method = parts.length > 1 ? parts[1] : null;
+ } else {
+ method = parts.length > 0 ? parts[0] : null;
+ }
+ if (StringUtils.isInteger(method)) {
+ times = method;
+ method = null;
+ } else {
+ times = parts.length > 2 ? parts[2] : "1";
+ }
+ if (!StringUtils.isInteger(times)) {
+ return "Illegal times " + times + ", must be integer.";
+ }
+ final int t = Integer.parseInt(times);
+ Invoker<?> invoker = null;
+ for (Exporter<?> exporter : DubboProtocol.getDubboProtocol().getExporters()) {
+ if (service.equals(exporter.getInvoker().getInterface().getSimpleName())
+ || service.equals(exporter.getInvoker().getInterface().getName())
+ || service.equals(exporter.getInvoker().getUrl().getPath())) {
+ invoker = exporter.getInvoker();
+ break;
+ }
+ }
+ if (invoker != null) {
+ if (t > 0) {
+ final String mtd = method;
+ final Invoker<?> inv = invoker;
+ final String prompt = channel.getUrl().getParameter("prompt", "telnet");
+ Thread thread = new Thread(new Runnable() {
+ public void run() {
+ for (int i = 0; i < t; i++) {
+ String result = count(inv, mtd);
+ try {
+ channel.send("\r\n" + result);
+ } catch (RemotingException e1) {
+ return;
+ }
+ if (i < t - 1) {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ }
+ }
+ }
+ try {
+ channel.send("\r\n" + prompt + "> ");
+ } catch (RemotingException e1) {
+ return;
+ }
+ }
+ }, "TelnetCount");
+ thread.setDaemon(true);
+ thread.start();
+ }
+ } else {
+ buf.append("No such service " + service);
+ }
+ return buf.toString();
+ }
+
+ private String count(Invoker<?> invoker, String method) {
+ URL url = invoker.getUrl();
+ List<List<String>> table = new ArrayList<List<String>>();
+ List<String> header = new ArrayList<String>();
+ header.add("method");
+ header.add("total");
+ header.add("failed");
+ header.add("active");
+ header.add("average");
+ header.add("max");
+ if (method == null || method.length() == 0) {
+ for (Method m : invoker.getInterface().getMethods()) {
+ RpcStatus count = RpcStatus.getStatus(url, m.getName());
+ List<String> row = new ArrayList<String>();
+ row.add(m.getName());
+ row.add(String.valueOf(count.getTotal()));
+ row.add(String.valueOf(count.getFailed()));
+ row.add(String.valueOf(count.getActive()));
+ row.add(String.valueOf(count.getSucceededAverageElapsed()) + "ms");
+ row.add(String.valueOf(count.getSucceededMaxElapsed()) + "ms");
+ table.add(row);
+ }
+ } else {
+ boolean found = false;
+ for (Method m : invoker.getInterface().getMethods()) {
+ if (m.getName().equals(method)) {
+ found = true;
+ break;
+ }
+ }
+ if (found) {
+ RpcStatus count = RpcStatus.getStatus(url, method);
+ List<String> row = new ArrayList<String>();
+ row.add(method);
+ row.add(String.valueOf(count.getTotal()));
+ row.add(String.valueOf(count.getFailed()));
+ row.add(String.valueOf(count.getActive()));
+ row.add(String.valueOf(count.getSucceededAverageElapsed()) + "ms");
+ row.add(String.valueOf(count.getSucceededMaxElapsed()) + "ms");
+ table.add(row);
+ } else {
+ return "No such method " + method + " in class " + invoker.getInterface().getName();
+ }
+ }
+ return TelnetUtils.toTable(header, table);
+ }
+
}
\ No newline at end of file
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 3bb8a9bab6..35b8a5639e 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
@@ -1,45 +1,45 @@
-/*
- * 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.rpc.protocol.dubbo.telnet;
-
-import com.alibaba.dubbo.common.extension.Activate;
-import com.alibaba.dubbo.remoting.Channel;
-import com.alibaba.dubbo.remoting.telnet.TelnetHandler;
-import com.alibaba.dubbo.remoting.telnet.support.Help;
-
-/**
- * CurrentServiceTelnetHandler
- */
-@Activate
-@Help(parameter = "", summary = "Print working default service.", detail = "Print working default service.")
-public class CurrentTelnetHandler implements TelnetHandler {
-
- public String telnet(Channel channel, String message) {
- if (message.length() > 0) {
- return "Unsupported parameter " + message + " for pwd.";
- }
- String service = (String) channel.getAttribute(ChangeTelnetHandler.SERVICE_KEY);
- StringBuilder buf = new StringBuilder();
- if (service == null || service.length() == 0) {
- buf.append("/");
- } else {
- buf.append(service);
- }
- return buf.toString();
- }
-
+/*
+ * 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.rpc.protocol.dubbo.telnet;
+
+import com.alibaba.dubbo.common.extension.Activate;
+import com.alibaba.dubbo.remoting.Channel;
+import com.alibaba.dubbo.remoting.telnet.TelnetHandler;
+import com.alibaba.dubbo.remoting.telnet.support.Help;
+
+/**
+ * CurrentServiceTelnetHandler
+ */
+@Activate
+@Help(parameter = "", summary = "Print working default service.", detail = "Print working default service.")
+public class CurrentTelnetHandler implements TelnetHandler {
+
+ public String telnet(Channel channel, String message) {
+ if (message.length() > 0) {
+ return "Unsupported parameter " + message + " for pwd.";
+ }
+ String service = (String) channel.getAttribute(ChangeTelnetHandler.SERVICE_KEY);
+ StringBuilder buf = new StringBuilder();
+ if (service == null || service.length() == 0) {
+ buf.append("/");
+ } else {
+ buf.append(service);
+ }
+ return buf.toString();
+ }
+
}
\ No newline at end of file
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 fdff3f0cbb..465489def2 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
@@ -1,159 +1,159 @@
-/*
- * 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.rpc.protocol.dubbo.telnet;
-
-import com.alibaba.dubbo.common.extension.Activate;
-import com.alibaba.dubbo.common.utils.PojoUtils;
-import com.alibaba.dubbo.common.utils.ReflectUtils;
-import com.alibaba.dubbo.common.utils.StringUtils;
-import com.alibaba.dubbo.remoting.Channel;
-import com.alibaba.dubbo.remoting.telnet.TelnetHandler;
-import com.alibaba.dubbo.remoting.telnet.support.Help;
-import com.alibaba.dubbo.rpc.Exporter;
-import com.alibaba.dubbo.rpc.Invoker;
-import com.alibaba.dubbo.rpc.RpcContext;
-import com.alibaba.dubbo.rpc.RpcInvocation;
-import com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol;
-import com.alibaba.fastjson.JSON;
-
-import java.lang.reflect.Method;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-/**
- * InvokeTelnetHandler
- */
-@Activate
-@Help(parameter = "[service.]method(args)", summary = "Invoke the service method.", detail = "Invoke the service method.")
-public class InvokeTelnetHandler implements TelnetHandler {
-
- private static Method findMethod(Exporter<?> exporter, String method, List<Object> args) {
- Invoker<?> invoker = exporter.getInvoker();
- Method[] methods = invoker.getInterface().getMethods();
- for (Method m : methods) {
- if (m.getName().equals(method) && isMatch(m.getParameterTypes(), args)) {
- return m;
- }
- }
- return null;
- }
-
- private static boolean isMatch(Class<?>[] types, List<Object> args) {
- if (types.length != args.size()) {
- return false;
- }
- for (int i = 0; i < types.length; i++) {
- Class<?> type = types[i];
- Object arg = args.get(i);
- if (ReflectUtils.isPrimitive(arg.getClass())) {
- if (!ReflectUtils.isPrimitive(type)) {
- return false;
- }
- } else if (arg instanceof Map) {
- String name = (String) ((Map<?, ?>) arg).get("class");
- Class<?> cls = arg.getClass();
- if (name != null && name.length() > 0) {
- cls = ReflectUtils.forName(name);
- }
- if (!type.isAssignableFrom(cls)) {
- return false;
- }
- } else if (arg instanceof Collection) {
- if (!type.isArray() && !type.isAssignableFrom(arg.getClass())) {
- return false;
- }
- } else {
- if (!type.isAssignableFrom(arg.getClass())) {
- return false;
- }
- }
- }
- return true;
- }
-
- @SuppressWarnings("unchecked")
- public String telnet(Channel channel, String message) {
- if (message == null || message.length() == 0) {
- return "Please input method name, eg: \r\ninvoke xxxMethod(1234, \"abcd\", {\"prop\" : \"value\"})\r\ninvoke XxxService.xxxMethod(1234, \"abcd\", {\"prop\" : \"value\"})\r\ninvoke com.xxx.XxxService.xxxMethod(1234, \"abcd\", {\"prop\" : \"value\"})";
- }
- StringBuilder buf = new StringBuilder();
- String service = (String) channel.getAttribute(ChangeTelnetHandler.SERVICE_KEY);
- if (service != null && service.length() > 0) {
- buf.append("Use default service " + service + ".\r\n");
- }
- int i = message.indexOf("(");
- if (i < 0 || !message.endsWith(")")) {
- return "Invalid parameters, format: service.method(args)";
- }
- String method = message.substring(0, i).trim();
- String args = message.substring(i + 1, message.length() - 1).trim();
- i = method.lastIndexOf(".");
- if (i >= 0) {
- service = method.substring(0, i).trim();
- method = method.substring(i + 1).trim();
- }
- List<Object> list;
- try {
- list = JSON.parseArray("[" + args + "]", Object.class);
- } catch (Throwable t) {
- return "Invalid json argument, cause: " + t.getMessage();
- }
- Invoker<?> invoker = null;
- Method invokeMethod = null;
- for (Exporter<?> exporter : DubboProtocol.getDubboProtocol().getExporters()) {
- if (service == null || service.length() == 0) {
- invokeMethod = findMethod(exporter, method, list);
- if (invokeMethod != null) {
- invoker = exporter.getInvoker();
- break;
- }
- } else {
- if (service.equals(exporter.getInvoker().getInterface().getSimpleName())
- || service.equals(exporter.getInvoker().getInterface().getName())
- || service.equals(exporter.getInvoker().getUrl().getPath())) {
- invokeMethod = findMethod(exporter, method, list);
- invoker = exporter.getInvoker();
- break;
- }
- }
- }
- if (invoker != null) {
- if (invokeMethod != null) {
- try {
- Object[] array = PojoUtils.realize(list.toArray(), invokeMethod.getParameterTypes(), invokeMethod.getGenericParameterTypes());
- RpcContext.getContext().setLocalAddress(channel.getLocalAddress()).setRemoteAddress(channel.getRemoteAddress());
- long start = System.currentTimeMillis();
- Object result = invoker.invoke(new RpcInvocation(invokeMethod, array)).recreate();
- long end = System.currentTimeMillis();
- buf.append(JSON.toJSONString(result));
- buf.append("\r\nelapsed: ");
- buf.append(end - start);
- buf.append(" ms.");
- } catch (Throwable t) {
- return "Failed to invoke method " + invokeMethod.getName() + ", cause: " + StringUtils.toString(t);
- }
- } else {
- buf.append("No such method " + method + " in service " + service);
- }
- } else {
- buf.append("No such service " + service);
- }
- return buf.toString();
- }
-
+/*
+ * 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.rpc.protocol.dubbo.telnet;
+
+import com.alibaba.dubbo.common.extension.Activate;
+import com.alibaba.dubbo.common.utils.PojoUtils;
+import com.alibaba.dubbo.common.utils.ReflectUtils;
+import com.alibaba.dubbo.common.utils.StringUtils;
+import com.alibaba.dubbo.remoting.Channel;
+import com.alibaba.dubbo.remoting.telnet.TelnetHandler;
+import com.alibaba.dubbo.remoting.telnet.support.Help;
+import com.alibaba.dubbo.rpc.Exporter;
+import com.alibaba.dubbo.rpc.Invoker;
+import com.alibaba.dubbo.rpc.RpcContext;
+import com.alibaba.dubbo.rpc.RpcInvocation;
+import com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol;
+import com.alibaba.fastjson.JSON;
+
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * InvokeTelnetHandler
+ */
+@Activate
+@Help(parameter = "[service.]method(args)", summary = "Invoke the service method.", detail = "Invoke the service method.")
+public class InvokeTelnetHandler implements TelnetHandler {
+
+ private static Method findMethod(Exporter<?> exporter, String method, List<Object> args) {
+ Invoker<?> invoker = exporter.getInvoker();
+ Method[] methods = invoker.getInterface().getMethods();
+ for (Method m : methods) {
+ if (m.getName().equals(method) && isMatch(m.getParameterTypes(), args)) {
+ return m;
+ }
+ }
+ return null;
+ }
+
+ private static boolean isMatch(Class<?>[] types, List<Object> args) {
+ if (types.length != args.size()) {
+ return false;
+ }
+ for (int i = 0; i < types.length; i++) {
+ Class<?> type = types[i];
+ Object arg = args.get(i);
+ if (ReflectUtils.isPrimitive(arg.getClass())) {
+ if (!ReflectUtils.isPrimitive(type)) {
+ return false;
+ }
+ } else if (arg instanceof Map) {
+ String name = (String) ((Map<?, ?>) arg).get("class");
+ Class<?> cls = arg.getClass();
+ if (name != null && name.length() > 0) {
+ cls = ReflectUtils.forName(name);
+ }
+ if (!type.isAssignableFrom(cls)) {
+ return false;
+ }
+ } else if (arg instanceof Collection) {
+ if (!type.isArray() && !type.isAssignableFrom(arg.getClass())) {
+ return false;
+ }
+ } else {
+ if (!type.isAssignableFrom(arg.getClass())) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ @SuppressWarnings("unchecked")
+ public String telnet(Channel channel, String message) {
+ if (message == null || message.length() == 0) {
+ return "Please input method name, eg: \r\ninvoke xxxMethod(1234, \"abcd\", {\"prop\" : \"value\"})\r\ninvoke XxxService.xxxMethod(1234, \"abcd\", {\"prop\" : \"value\"})\r\ninvoke com.xxx.XxxService.xxxMethod(1234, \"abcd\", {\"prop\" : \"value\"})";
+ }
+ StringBuilder buf = new StringBuilder();
+ String service = (String) channel.getAttribute(ChangeTelnetHandler.SERVICE_KEY);
+ if (service != null && service.length() > 0) {
+ buf.append("Use default service " + service + ".\r\n");
+ }
+ int i = message.indexOf("(");
+ if (i < 0 || !message.endsWith(")")) {
+ return "Invalid parameters, format: service.method(args)";
+ }
+ String method = message.substring(0, i).trim();
+ String args = message.substring(i + 1, message.length() - 1).trim();
+ i = method.lastIndexOf(".");
+ if (i >= 0) {
+ service = method.substring(0, i).trim();
+ method = method.substring(i + 1).trim();
+ }
+ List<Object> list;
+ try {
+ list = JSON.parseArray("[" + args + "]", Object.class);
+ } catch (Throwable t) {
+ return "Invalid json argument, cause: " + t.getMessage();
+ }
+ Invoker<?> invoker = null;
+ Method invokeMethod = null;
+ for (Exporter<?> exporter : DubboProtocol.getDubboProtocol().getExporters()) {
+ if (service == null || service.length() == 0) {
+ invokeMethod = findMethod(exporter, method, list);
+ if (invokeMethod != null) {
+ invoker = exporter.getInvoker();
+ break;
+ }
+ } else {
+ if (service.equals(exporter.getInvoker().getInterface().getSimpleName())
+ || service.equals(exporter.getInvoker().getInterface().getName())
+ || service.equals(exporter.getInvoker().getUrl().getPath())) {
+ invokeMethod = findMethod(exporter, method, list);
+ invoker = exporter.getInvoker();
+ break;
+ }
+ }
+ }
+ if (invoker != null) {
+ if (invokeMethod != null) {
+ try {
+ Object[] array = PojoUtils.realize(list.toArray(), invokeMethod.getParameterTypes(), invokeMethod.getGenericParameterTypes());
+ RpcContext.getContext().setLocalAddress(channel.getLocalAddress()).setRemoteAddress(channel.getRemoteAddress());
+ long start = System.currentTimeMillis();
+ Object result = invoker.invoke(new RpcInvocation(invokeMethod, array)).recreate();
+ long end = System.currentTimeMillis();
+ buf.append(JSON.toJSONString(result));
+ buf.append("\r\nelapsed: ");
+ buf.append(end - start);
+ buf.append(" ms.");
+ } catch (Throwable t) {
+ return "Failed to invoke method " + invokeMethod.getName() + ", cause: " + StringUtils.toString(t);
+ }
+ } else {
+ buf.append("No such method " + method + " in service " + service);
+ }
+ } else {
+ buf.append("No such service " + service);
+ }
+ return buf.toString();
+ }
+
}
\ No newline at end of file
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 5d00c22d36..aad5b99cf6 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
@@ -1,99 +1,99 @@
-/*
- * 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.rpc.protocol.dubbo.telnet;
-
-import com.alibaba.dubbo.common.extension.Activate;
-import com.alibaba.dubbo.common.utils.ReflectUtils;
-import com.alibaba.dubbo.remoting.Channel;
-import com.alibaba.dubbo.remoting.telnet.TelnetHandler;
-import com.alibaba.dubbo.remoting.telnet.support.Help;
-import com.alibaba.dubbo.rpc.Exporter;
-import com.alibaba.dubbo.rpc.Invoker;
-import com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol;
-
-import java.lang.reflect.Method;
-
-/**
- * ListTelnetHandler
- */
-@Activate
-@Help(parameter = "[-l] [service]", summary = "List services and methods.", detail = "List services and methods.")
-public class ListTelnetHandler implements TelnetHandler {
-
- public String telnet(Channel channel, String message) {
- StringBuilder buf = new StringBuilder();
- String service = null;
- boolean detail = false;
- if (message.length() > 0) {
- String[] parts = message.split("\\s+");
- for (String part : parts) {
- if ("-l".equals(part)) {
- detail = true;
- } else {
- if (service != null && service.length() > 0) {
- return "Invaild parameter " + part;
- }
- service = part;
- }
- }
- } else {
- service = (String) channel.getAttribute(ChangeTelnetHandler.SERVICE_KEY);
- if (service != null && service.length() > 0) {
- buf.append("Use default service " + service + ".\r\n");
- }
- }
- if (service == null || service.length() == 0) {
- for (Exporter<?> exporter : DubboProtocol.getDubboProtocol().getExporters()) {
- if (buf.length() > 0) {
- buf.append("\r\n");
- }
- buf.append(exporter.getInvoker().getInterface().getName());
- if (detail) {
- buf.append(" -> ");
- buf.append(exporter.getInvoker().getUrl());
- }
- }
- } else {
- Invoker<?> invoker = null;
- for (Exporter<?> exporter : DubboProtocol.getDubboProtocol().getExporters()) {
- if (service.equals(exporter.getInvoker().getInterface().getSimpleName())
- || service.equals(exporter.getInvoker().getInterface().getName())
- || service.equals(exporter.getInvoker().getUrl().getPath())) {
- invoker = exporter.getInvoker();
- break;
- }
- }
- if (invoker != null) {
- Method[] methods = invoker.getInterface().getMethods();
- for (Method method : methods) {
- if (buf.length() > 0) {
- buf.append("\r\n");
- }
- if (detail) {
- buf.append(ReflectUtils.getName(method));
- } else {
- buf.append(method.getName());
- }
- }
- } else {
- buf.append("No such service " + service);
- }
- }
- return buf.toString();
- }
-
+/*
+ * 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.rpc.protocol.dubbo.telnet;
+
+import com.alibaba.dubbo.common.extension.Activate;
+import com.alibaba.dubbo.common.utils.ReflectUtils;
+import com.alibaba.dubbo.remoting.Channel;
+import com.alibaba.dubbo.remoting.telnet.TelnetHandler;
+import com.alibaba.dubbo.remoting.telnet.support.Help;
+import com.alibaba.dubbo.rpc.Exporter;
+import com.alibaba.dubbo.rpc.Invoker;
+import com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol;
+
+import java.lang.reflect.Method;
+
+/**
+ * ListTelnetHandler
+ */
+@Activate
+@Help(parameter = "[-l] [service]", summary = "List services and methods.", detail = "List services and methods.")
+public class ListTelnetHandler implements TelnetHandler {
+
+ public String telnet(Channel channel, String message) {
+ StringBuilder buf = new StringBuilder();
+ String service = null;
+ boolean detail = false;
+ if (message.length() > 0) {
+ String[] parts = message.split("\\s+");
+ for (String part : parts) {
+ if ("-l".equals(part)) {
+ detail = true;
+ } else {
+ if (service != null && service.length() > 0) {
+ return "Invaild parameter " + part;
+ }
+ service = part;
+ }
+ }
+ } else {
+ service = (String) channel.getAttribute(ChangeTelnetHandler.SERVICE_KEY);
+ if (service != null && service.length() > 0) {
+ buf.append("Use default service " + service + ".\r\n");
+ }
+ }
+ if (service == null || service.length() == 0) {
+ for (Exporter<?> exporter : DubboProtocol.getDubboProtocol().getExporters()) {
+ if (buf.length() > 0) {
+ buf.append("\r\n");
+ }
+ buf.append(exporter.getInvoker().getInterface().getName());
+ if (detail) {
+ buf.append(" -> ");
+ buf.append(exporter.getInvoker().getUrl());
+ }
+ }
+ } else {
+ Invoker<?> invoker = null;
+ for (Exporter<?> exporter : DubboProtocol.getDubboProtocol().getExporters()) {
+ if (service.equals(exporter.getInvoker().getInterface().getSimpleName())
+ || service.equals(exporter.getInvoker().getInterface().getName())
+ || service.equals(exporter.getInvoker().getUrl().getPath())) {
+ invoker = exporter.getInvoker();
+ break;
+ }
+ }
+ if (invoker != null) {
+ Method[] methods = invoker.getInterface().getMethods();
+ for (Method method : methods) {
+ if (buf.length() > 0) {
+ buf.append("\r\n");
+ }
+ if (detail) {
+ buf.append(ReflectUtils.getName(method));
+ } else {
+ buf.append(method.getName());
+ }
+ }
+ } else {
+ buf.append("No such service " + service);
+ }
+ }
+ return buf.toString();
+ }
+
}
\ No newline at end of file
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 24370248c8..72642e7fa1 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
@@ -1,93 +1,93 @@
-/*
- * 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.rpc.protocol.dubbo.telnet;
-
-import com.alibaba.dubbo.common.extension.Activate;
-import com.alibaba.dubbo.common.utils.StringUtils;
-import com.alibaba.dubbo.remoting.Channel;
-import com.alibaba.dubbo.remoting.exchange.ExchangeChannel;
-import com.alibaba.dubbo.remoting.exchange.ExchangeServer;
-import com.alibaba.dubbo.remoting.telnet.TelnetHandler;
-import com.alibaba.dubbo.remoting.telnet.support.Help;
-import com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol;
-
-import java.util.Collection;
-
-/**
- * ServerTelnetHandler
- */
-@Activate
-@Help(parameter = "[-l] [port]", summary = "Print server ports and connections.", detail = "Print server ports and connections.")
-public class PortTelnetHandler implements TelnetHandler {
-
- public String telnet(Channel channel, String message) {
- StringBuilder buf = new StringBuilder();
- String port = null;
- boolean detail = false;
- if (message.length() > 0) {
- String[] parts = message.split("\\s+");
- for (String part : parts) {
- if ("-l".equals(part)) {
- detail = true;
- } else {
- if (!StringUtils.isInteger(part)) {
- return "Illegal port " + part + ", must be integer.";
- }
- port = part;
- }
- }
- }
- if (port == null || port.length() == 0) {
- for (ExchangeServer server : DubboProtocol.getDubboProtocol().getServers()) {
- if (buf.length() > 0) {
- buf.append("\r\n");
- }
- if (detail) {
- buf.append(server.getUrl().getProtocol() + "://" + server.getUrl().getAddress());
- } else {
- buf.append(server.getUrl().getPort());
- }
- }
- } else {
- int p = Integer.parseInt(port);
- ExchangeServer server = null;
- for (ExchangeServer s : DubboProtocol.getDubboProtocol().getServers()) {
- if (p == s.getUrl().getPort()) {
- server = s;
- break;
- }
- }
- if (server != null) {
- Collection<ExchangeChannel> channels = server.getExchangeChannels();
- for (ExchangeChannel c : channels) {
- if (buf.length() > 0) {
- buf.append("\r\n");
- }
- if (detail) {
- buf.append(c.getRemoteAddress() + " -> " + c.getLocalAddress());
- } else {
- buf.append(c.getRemoteAddress());
- }
- }
- } else {
- buf.append("No such port " + port);
- }
- }
- return buf.toString();
- }
-
+/*
+ * 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.rpc.protocol.dubbo.telnet;
+
+import com.alibaba.dubbo.common.extension.Activate;
+import com.alibaba.dubbo.common.utils.StringUtils;
+import com.alibaba.dubbo.remoting.Channel;
+import com.alibaba.dubbo.remoting.exchange.ExchangeChannel;
+import com.alibaba.dubbo.remoting.exchange.ExchangeServer;
+import com.alibaba.dubbo.remoting.telnet.TelnetHandler;
+import com.alibaba.dubbo.remoting.telnet.support.Help;
+import com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol;
+
+import java.util.Collection;
+
+/**
+ * ServerTelnetHandler
+ */
+@Activate
+@Help(parameter = "[-l] [port]", summary = "Print server ports and connections.", detail = "Print server ports and connections.")
+public class PortTelnetHandler implements TelnetHandler {
+
+ public String telnet(Channel channel, String message) {
+ StringBuilder buf = new StringBuilder();
+ String port = null;
+ boolean detail = false;
+ if (message.length() > 0) {
+ String[] parts = message.split("\\s+");
+ for (String part : parts) {
+ if ("-l".equals(part)) {
+ detail = true;
+ } else {
+ if (!StringUtils.isInteger(part)) {
+ return "Illegal port " + part + ", must be integer.";
+ }
+ port = part;
+ }
+ }
+ }
+ if (port == null || port.length() == 0) {
+ for (ExchangeServer server : DubboProtocol.getDubboProtocol().getServers()) {
+ if (buf.length() > 0) {
+ buf.append("\r\n");
+ }
+ if (detail) {
+ buf.append(server.getUrl().getProtocol() + "://" + server.getUrl().getAddress());
+ } else {
+ buf.append(server.getUrl().getPort());
+ }
+ }
+ } else {
+ int p = Integer.parseInt(port);
+ ExchangeServer server = null;
+ for (ExchangeServer s : DubboProtocol.getDubboProtocol().getServers()) {
+ if (p == s.getUrl().getPort()) {
+ server = s;
+ break;
+ }
+ }
+ if (server != null) {
+ Collection<ExchangeChannel> channels = server.getExchangeChannels();
+ for (ExchangeChannel c : channels) {
+ if (buf.length() > 0) {
+ buf.append("\r\n");
+ }
+ if (detail) {
+ buf.append(c.getRemoteAddress() + " -> " + c.getLocalAddress());
+ } else {
+ buf.append(c.getRemoteAddress());
+ }
+ }
+ } else {
+ buf.append("No such port " + port);
+ }
+ }
+ return buf.toString();
+ }
+
}
\ No newline at end of file
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 651fbeb048..a28ee2a8e5 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
@@ -1,91 +1,91 @@
-/*
- * 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.rpc.protocol.dubbo.telnet;
-
-import com.alibaba.dubbo.common.extension.Activate;
-import com.alibaba.dubbo.common.utils.StringUtils;
-import com.alibaba.dubbo.remoting.Channel;
-import com.alibaba.dubbo.remoting.telnet.TelnetHandler;
-import com.alibaba.dubbo.remoting.telnet.support.Help;
-import com.alibaba.dubbo.rpc.Exporter;
-import com.alibaba.dubbo.rpc.Invoker;
-import com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol;
-import com.alibaba.dubbo.rpc.protocol.dubbo.filter.TraceFilter;
-
-import java.lang.reflect.Method;
-
-/**
- * TraceTelnetHandler
- */
-@Activate
-@Help(parameter = "[service] [method] [times]", summary = "Trace the service.", detail = "Trace the service.")
-public class TraceTelnetHandler implements TelnetHandler {
-
- public String telnet(Channel channel, String message) {
- String service = (String) channel.getAttribute(ChangeTelnetHandler.SERVICE_KEY);
- if ((service == null || service.length() == 0)
- && (message == null || message.length() == 0)) {
- return "Please input service name, eg: \r\ntrace XxxService\r\ntrace XxxService xxxMethod\r\ntrace XxxService xxxMethod 10\r\nor \"cd XxxService\" firstly.";
- }
- String[] parts = message.split("\\s+");
- String method;
- String times;
- if (service == null || service.length() == 0) {
- service = parts.length > 0 ? parts[0] : null;
- method = parts.length > 1 ? parts[1] : null;
- } else {
- method = parts.length > 0 ? parts[0] : null;
- }
- if (StringUtils.isInteger(method)) {
- times = method;
- method = null;
- } else {
- times = parts.length > 2 ? parts[2] : "1";
- }
- if (!StringUtils.isInteger(times)) {
- return "Illegal times " + times + ", must be integer.";
- }
- Invoker<?> invoker = null;
- for (Exporter<?> exporter : DubboProtocol.getDubboProtocol().getExporters()) {
- if (service.equals(exporter.getInvoker().getInterface().getSimpleName())
- || service.equals(exporter.getInvoker().getInterface().getName())
- || service.equals(exporter.getInvoker().getUrl().getPath())) {
- invoker = exporter.getInvoker();
- break;
- }
- }
- if (invoker != null) {
- if (method != null && method.length() > 0) {
- boolean found = false;
- for (Method m : invoker.getInterface().getMethods()) {
- if (m.getName().equals(method)) {
- found = true;
- break;
- }
- }
- if (!found) {
- return "No such method " + method + " in class " + invoker.getInterface().getName();
- }
- }
- TraceFilter.addTracer(invoker.getInterface(), method, channel, Integer.parseInt(times));
- } else {
- return "No such service " + service;
- }
- return null;
- }
-
+/*
+ * 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.rpc.protocol.dubbo.telnet;
+
+import com.alibaba.dubbo.common.extension.Activate;
+import com.alibaba.dubbo.common.utils.StringUtils;
+import com.alibaba.dubbo.remoting.Channel;
+import com.alibaba.dubbo.remoting.telnet.TelnetHandler;
+import com.alibaba.dubbo.remoting.telnet.support.Help;
+import com.alibaba.dubbo.rpc.Exporter;
+import com.alibaba.dubbo.rpc.Invoker;
+import com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol;
+import com.alibaba.dubbo.rpc.protocol.dubbo.filter.TraceFilter;
+
+import java.lang.reflect.Method;
+
+/**
+ * TraceTelnetHandler
+ */
+@Activate
+@Help(parameter = "[service] [method] [times]", summary = "Trace the service.", detail = "Trace the service.")
+public class TraceTelnetHandler implements TelnetHandler {
+
+ public String telnet(Channel channel, String message) {
+ String service = (String) channel.getAttribute(ChangeTelnetHandler.SERVICE_KEY);
+ if ((service == null || service.length() == 0)
+ && (message == null || message.length() == 0)) {
+ return "Please input service name, eg: \r\ntrace XxxService\r\ntrace XxxService xxxMethod\r\ntrace XxxService xxxMethod 10\r\nor \"cd XxxService\" firstly.";
+ }
+ String[] parts = message.split("\\s+");
+ String method;
+ String times;
+ if (service == null || service.length() == 0) {
+ service = parts.length > 0 ? parts[0] : null;
+ method = parts.length > 1 ? parts[1] : null;
+ } else {
+ method = parts.length > 0 ? parts[0] : null;
+ }
+ if (StringUtils.isInteger(method)) {
+ times = method;
+ method = null;
+ } else {
+ times = parts.length > 2 ? parts[2] : "1";
+ }
+ if (!StringUtils.isInteger(times)) {
+ return "Illegal times " + times + ", must be integer.";
+ }
+ Invoker<?> invoker = null;
+ for (Exporter<?> exporter : DubboProtocol.getDubboProtocol().getExporters()) {
+ if (service.equals(exporter.getInvoker().getInterface().getSimpleName())
+ || service.equals(exporter.getInvoker().getInterface().getName())
+ || service.equals(exporter.getInvoker().getUrl().getPath())) {
+ invoker = exporter.getInvoker();
+ break;
+ }
+ }
+ if (invoker != null) {
+ if (method != null && method.length() > 0) {
+ boolean found = false;
+ for (Method m : invoker.getInterface().getMethods()) {
+ if (m.getName().equals(method)) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ return "No such method " + method + " in class " + invoker.getInterface().getName();
+ }
+ }
+ TraceFilter.addTracer(invoker.getInterface(), method, channel, Integer.parseInt(times));
+ } else {
+ return "No such service " + service;
+ }
+ return null;
+ }
+
}
\ No newline at end of file
diff --git a/dubbo-rpc/dubbo-rpc-default/src/main/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.status.StatusChecker b/dubbo-rpc/dubbo-rpc-default/src/main/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.status.StatusChecker
index 2729db5122..3e063fb5b8 100644
--- a/dubbo-rpc/dubbo-rpc-default/src/main/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.status.StatusChecker
+++ b/dubbo-rpc/dubbo-rpc-default/src/main/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.status.StatusChecker
@@ -1,2 +1,2 @@
-server=com.alibaba.dubbo.rpc.protocol.dubbo.status.ServerStatusChecker
+server=com.alibaba.dubbo.rpc.protocol.dubbo.status.ServerStatusChecker
threadpool=com.alibaba.dubbo.rpc.protocol.dubbo.status.ThreadPoolStatusChecker
\ No newline at end of file
diff --git a/dubbo-rpc/dubbo-rpc-default/src/main/resources/META-INF/dubbo/internal/com.alibaba.dubbo.container.page.PageHandler b/dubbo-rpc/dubbo-rpc-default/src/main/resources/META-INF/dubbo/internal/com.alibaba.dubbo.container.page.PageHandler
index 63122b4182..7fc33d4f8d 100644
--- a/dubbo-rpc/dubbo-rpc-default/src/main/resources/META-INF/dubbo/internal/com.alibaba.dubbo.container.page.PageHandler
+++ b/dubbo-rpc/dubbo-rpc-default/src/main/resources/META-INF/dubbo/internal/com.alibaba.dubbo.container.page.PageHandler
@@ -1,2 +1,2 @@
-servers=com.alibaba.dubbo.rpc.protocol.dubbo.page.ServersPageHandler
+servers=com.alibaba.dubbo.rpc.protocol.dubbo.page.ServersPageHandler
clients=com.alibaba.dubbo.rpc.protocol.dubbo.page.ClientsPageHandler
\ No newline at end of file
diff --git a/dubbo-rpc/dubbo-rpc-default/src/main/resources/META-INF/dubbo/internal/com.alibaba.dubbo.remoting.telnet.TelnetHandler b/dubbo-rpc/dubbo-rpc-default/src/main/resources/META-INF/dubbo/internal/com.alibaba.dubbo.remoting.telnet.TelnetHandler
index 780deef718..33ebee2d0b 100644
--- a/dubbo-rpc/dubbo-rpc-default/src/main/resources/META-INF/dubbo/internal/com.alibaba.dubbo.remoting.telnet.TelnetHandler
+++ b/dubbo-rpc/dubbo-rpc-default/src/main/resources/META-INF/dubbo/internal/com.alibaba.dubbo.remoting.telnet.TelnetHandler
@@ -1,7 +1,7 @@
-ls=com.alibaba.dubbo.rpc.protocol.dubbo.telnet.ListTelnetHandler
-ps=com.alibaba.dubbo.rpc.protocol.dubbo.telnet.PortTelnetHandler
-cd=com.alibaba.dubbo.rpc.protocol.dubbo.telnet.ChangeTelnetHandler
-pwd=com.alibaba.dubbo.rpc.protocol.dubbo.telnet.CurrentTelnetHandler
-invoke=com.alibaba.dubbo.rpc.protocol.dubbo.telnet.InvokeTelnetHandler
-trace=com.alibaba.dubbo.rpc.protocol.dubbo.telnet.TraceTelnetHandler
+ls=com.alibaba.dubbo.rpc.protocol.dubbo.telnet.ListTelnetHandler
+ps=com.alibaba.dubbo.rpc.protocol.dubbo.telnet.PortTelnetHandler
+cd=com.alibaba.dubbo.rpc.protocol.dubbo.telnet.ChangeTelnetHandler
+pwd=com.alibaba.dubbo.rpc.protocol.dubbo.telnet.CurrentTelnetHandler
+invoke=com.alibaba.dubbo.rpc.protocol.dubbo.telnet.InvokeTelnetHandler
+trace=com.alibaba.dubbo.rpc.protocol.dubbo.telnet.TraceTelnetHandler
count=com.alibaba.dubbo.rpc.protocol.dubbo.telnet.CountTelnetHandler
\ No newline at end of file
diff --git a/dubbo-rpc/dubbo-rpc-default/src/main/resources/META-INF/dubbo/internal/com.alibaba.dubbo.rpc.Filter b/dubbo-rpc/dubbo-rpc-default/src/main/resources/META-INF/dubbo/internal/com.alibaba.dubbo.rpc.Filter
index ff24401f70..749239254d 100644
--- a/dubbo-rpc/dubbo-rpc-default/src/main/resources/META-INF/dubbo/internal/com.alibaba.dubbo.rpc.Filter
+++ b/dubbo-rpc/dubbo-rpc-default/src/main/resources/META-INF/dubbo/internal/com.alibaba.dubbo.rpc.Filter
@@ -1,2 +1,2 @@
-trace=com.alibaba.dubbo.rpc.protocol.dubbo.filter.TraceFilter
+trace=com.alibaba.dubbo.rpc.protocol.dubbo.filter.TraceFilter
future=com.alibaba.dubbo.rpc.protocol.dubbo.filter.FutureFilter
\ No newline at end of file
diff --git a/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/FutureFilterTest.java b/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/FutureFilterTest.java
index 4d359cd937..0a49cde0d1 100644
--- a/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/FutureFilterTest.java
+++ b/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/FutureFilterTest.java
@@ -1,81 +1,81 @@
-/*
- * 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.rpc.protocol.dubbo;
-
-import com.alibaba.dubbo.common.Constants;
-import com.alibaba.dubbo.common.URL;
-import com.alibaba.dubbo.rpc.Filter;
-import com.alibaba.dubbo.rpc.Invoker;
-import com.alibaba.dubbo.rpc.Result;
-import com.alibaba.dubbo.rpc.RpcException;
-import com.alibaba.dubbo.rpc.RpcInvocation;
-import com.alibaba.dubbo.rpc.RpcResult;
-import com.alibaba.dubbo.rpc.protocol.dubbo.filter.FutureFilter;
-import com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService;
-import org.easymock.EasyMock;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * EventFilterTest.java
- * TODO rely on callback integration test for now
- */
-public class FutureFilterTest {
- private static RpcInvocation invocation;
- Filter eventFilter = new FutureFilter();
-
- @BeforeClass
- public static void setUp() {
- invocation = new RpcInvocation();
- invocation.setMethodName("echo");
- invocation.setParameterTypes(new Class<?>[]{Enum.class});
- invocation.setArguments(new Object[]{"hello"});
- }
-
- @Test
- public void testSyncCallback() {
- @SuppressWarnings("unchecked")
- Invoker<DemoService> invoker = EasyMock.createMock(Invoker.class);
- EasyMock.expect(invoker.isAvailable()).andReturn(true).anyTimes();
- EasyMock.expect(invoker.getInterface()).andReturn(DemoService.class).anyTimes();
- RpcResult result = new RpcResult();
- result.setValue("High");
- EasyMock.expect(invoker.invoke(invocation)).andReturn(result).anyTimes();
- URL url = URL.valueOf("test://test:11/test?group=dubbo&version=1.1");
- EasyMock.expect(invoker.getUrl()).andReturn(url).anyTimes();
- EasyMock.replay(invoker);
- Result filterResult = eventFilter.invoke(invoker, invocation);
- assertEquals("High", filterResult.getValue());
- }
-
- @Test(expected = RuntimeException.class)
- public void testSyncCallbackHasException() throws RpcException, Throwable {
- @SuppressWarnings("unchecked")
- Invoker<DemoService> invoker = EasyMock.createMock(Invoker.class);
- EasyMock.expect(invoker.isAvailable()).andReturn(true).anyTimes();
- EasyMock.expect(invoker.getInterface()).andReturn(DemoService.class).anyTimes();
- RpcResult result = new RpcResult();
- result.setException(new RuntimeException());
- EasyMock.expect(invoker.invoke(invocation)).andReturn(result).anyTimes();
- URL url = URL.valueOf("test://test:11/test?group=dubbo&version=1.1&" + Constants.ON_THROW_METHOD_KEY + "=echo");
- EasyMock.expect(invoker.getUrl()).andReturn(url).anyTimes();
- EasyMock.replay(invoker);
- eventFilter.invoke(invoker, invocation).recreate();
- }
+/*
+ * 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.rpc.protocol.dubbo;
+
+import com.alibaba.dubbo.common.Constants;
+import com.alibaba.dubbo.common.URL;
+import com.alibaba.dubbo.rpc.Filter;
+import com.alibaba.dubbo.rpc.Invoker;
+import com.alibaba.dubbo.rpc.Result;
+import com.alibaba.dubbo.rpc.RpcException;
+import com.alibaba.dubbo.rpc.RpcInvocation;
+import com.alibaba.dubbo.rpc.RpcResult;
+import com.alibaba.dubbo.rpc.protocol.dubbo.filter.FutureFilter;
+import com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService;
+import org.easymock.EasyMock;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * EventFilterTest.java
+ * TODO rely on callback integration test for now
+ */
+public class FutureFilterTest {
+ private static RpcInvocation invocation;
+ Filter eventFilter = new FutureFilter();
+
+ @BeforeClass
+ public static void setUp() {
+ invocation = new RpcInvocation();
+ invocation.setMethodName("echo");
+ invocation.setParameterTypes(new Class<?>[]{Enum.class});
+ invocation.setArguments(new Object[]{"hello"});
+ }
+
+ @Test
+ public void testSyncCallback() {
+ @SuppressWarnings("unchecked")
+ Invoker<DemoService> invoker = EasyMock.createMock(Invoker.class);
+ EasyMock.expect(invoker.isAvailable()).andReturn(true).anyTimes();
+ EasyMock.expect(invoker.getInterface()).andReturn(DemoService.class).anyTimes();
+ RpcResult result = new RpcResult();
+ result.setValue("High");
+ EasyMock.expect(invoker.invoke(invocation)).andReturn(result).anyTimes();
+ URL url = URL.valueOf("test://test:11/test?group=dubbo&version=1.1");
+ EasyMock.expect(invoker.getUrl()).andReturn(url).anyTimes();
+ EasyMock.replay(invoker);
+ Result filterResult = eventFilter.invoke(invoker, invocation);
+ assertEquals("High", filterResult.getValue());
+ }
+
+ @Test(expected = RuntimeException.class)
+ public void testSyncCallbackHasException() throws RpcException, Throwable {
+ @SuppressWarnings("unchecked")
+ Invoker<DemoService> invoker = EasyMock.createMock(Invoker.class);
+ EasyMock.expect(invoker.isAvailable()).andReturn(true).anyTimes();
+ EasyMock.expect(invoker.getInterface()).andReturn(DemoService.class).anyTimes();
+ RpcResult result = new RpcResult();
+ result.setException(new RuntimeException());
+ EasyMock.expect(invoker.invoke(invocation)).andReturn(result).anyTimes();
+ URL url = URL.valueOf("test://test:11/test?group=dubbo&version=1.1&" + Constants.ON_THROW_METHOD_KEY + "=echo");
+ EasyMock.expect(invoker.getUrl()).andReturn(url).anyTimes();
+ EasyMock.replay(invoker);
+ eventFilter.invoke(invoker, invocation).recreate();
+ }
}
\ No newline at end of file
diff --git a/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/support/NonSerialized.java b/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/support/NonSerialized.java
index abb3d14410..e047aa2ddf 100644
--- a/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/support/NonSerialized.java
+++ b/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/support/NonSerialized.java
@@ -1,24 +1,24 @@
-/*
- * 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.rpc.protocol.dubbo.support;
-
-/**
- * NonSerialized
- */
-public class NonSerialized {
-
-}
+/*
+ * 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.rpc.protocol.dubbo.support;
+
+/**
+ * NonSerialized
+ */
+public class NonSerialized {
+
+}
diff --git a/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/support/Person.java b/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/support/Person.java
index 96c9b61f25..7268503342 100644
--- a/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/support/Person.java
+++ b/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/support/Person.java
@@ -1,45 +1,45 @@
-/*
- * 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.rpc.protocol.dubbo.support;
-
-import java.io.Serializable;
-
-/**
- * Person.java
- */
-public class Person implements Serializable {
-
- private static final long serialVersionUID = 1L;
- private String name;
- private int age;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public int getAge() {
- return age;
- }
-
- public void setAge(int age) {
- this.age = age;
- }
+/*
+ * 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.rpc.protocol.dubbo.support;
+
+import java.io.Serializable;
+
+/**
+ * Person.java
+ */
+public class Person implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+ private String name;
+ private int age;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
}
\ No newline at end of file
diff --git a/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/support/ProtocolUtils.java b/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/support/ProtocolUtils.java
index b9ffb8b1b9..64895babff 100644
--- a/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/support/ProtocolUtils.java
+++ b/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/support/ProtocolUtils.java
@@ -1,65 +1,65 @@
-/*
- * 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.rpc.protocol.dubbo.support;
-
-import com.alibaba.dubbo.common.URL;
-import com.alibaba.dubbo.common.extension.ExtensionLoader;
-import com.alibaba.dubbo.remoting.exchange.ExchangeServer;
-import com.alibaba.dubbo.rpc.Exporter;
-import com.alibaba.dubbo.rpc.Invoker;
-import com.alibaba.dubbo.rpc.Protocol;
-import com.alibaba.dubbo.rpc.ProxyFactory;
-import com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol;
-
-import java.util.Collection;
-
-/**
- * TODO Comment of ProtocolUtils
- */
-public class ProtocolUtils {
-
- public static ProxyFactory proxy = ExtensionLoader.getExtensionLoader(ProxyFactory.class).getAdaptiveExtension();
- private static Protocol protocol = ExtensionLoader.getExtensionLoader(Protocol.class).getAdaptiveExtension();
-
- public static <T> T refer(Class<T> type, String url) {
- return refer(type, URL.valueOf(url));
- }
-
- public static <T> T refer(Class<T> type, URL url) {
- return proxy.getProxy(protocol.refer(type, url));
- }
-
- public static Invoker<?> referInvoker(Class<?> type, URL url) {
- return (Invoker<?>) protocol.refer(type, url);
- }
-
- public static <T> Exporter<T> export(T instance, Class<T> type, String url) {
- return export(instance, type, URL.valueOf(url));
- }
-
- public static <T> Exporter<T> export(T instance, Class<T> type, URL url) {
- return protocol.export(proxy.getInvoker(instance, type, url));
- }
-
- public static void closeAll() {
- DubboProtocol.getDubboProtocol().destroy();
- Collection<ExchangeServer> servers = DubboProtocol.getDubboProtocol().getServers();
- for (ExchangeServer server : servers) {
- server.close();
- }
- }
+/*
+ * 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.rpc.protocol.dubbo.support;
+
+import com.alibaba.dubbo.common.URL;
+import com.alibaba.dubbo.common.extension.ExtensionLoader;
+import com.alibaba.dubbo.remoting.exchange.ExchangeServer;
+import com.alibaba.dubbo.rpc.Exporter;
+import com.alibaba.dubbo.rpc.Invoker;
+import com.alibaba.dubbo.rpc.Protocol;
+import com.alibaba.dubbo.rpc.ProxyFactory;
+import com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol;
+
+import java.util.Collection;
+
+/**
+ * TODO Comment of ProtocolUtils
+ */
+public class ProtocolUtils {
+
+ public static ProxyFactory proxy = ExtensionLoader.getExtensionLoader(ProxyFactory.class).getAdaptiveExtension();
+ private static Protocol protocol = ExtensionLoader.getExtensionLoader(Protocol.class).getAdaptiveExtension();
+
+ public static <T> T refer(Class<T> type, String url) {
+ return refer(type, URL.valueOf(url));
+ }
+
+ public static <T> T refer(Class<T> type, URL url) {
+ return proxy.getProxy(protocol.refer(type, url));
+ }
+
+ public static Invoker<?> referInvoker(Class<?> type, URL url) {
+ return (Invoker<?>) protocol.refer(type, url);
+ }
+
+ public static <T> Exporter<T> export(T instance, Class<T> type, String url) {
+ return export(instance, type, URL.valueOf(url));
+ }
+
+ public static <T> Exporter<T> export(T instance, Class<T> type, URL url) {
+ return protocol.export(proxy.getInvoker(instance, type, url));
+ }
+
+ public static void closeAll() {
+ DubboProtocol.getDubboProtocol().destroy();
+ Collection<ExchangeServer> servers = DubboProtocol.getDubboProtocol().getServers();
+ for (ExchangeServer server : servers) {
+ server.close();
+ }
+ }
}
\ No newline at end of file
diff --git a/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/support/RemoteService.java b/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/support/RemoteService.java
index cd5a509581..d645d98e16 100644
--- a/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/support/RemoteService.java
+++ b/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/support/RemoteService.java
@@ -1,26 +1,26 @@
-/*
- * 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.rpc.protocol.dubbo.support;
-
-import java.rmi.Remote;
-import java.rmi.RemoteException;
-
-public interface RemoteService extends Remote {
- String sayHello(String name) throws RemoteException;
-
- String getThreadName() throws RemoteException;
+/*
+ * 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.rpc.protocol.dubbo.support;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+public interface RemoteService extends Remote {
+ String sayHello(String name) throws RemoteException;
+
+ String getThreadName() throws RemoteException;
}
\ No newline at end of file
diff --git a/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/support/Type.java b/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/support/Type.java
index 79ce766a42..7487881b4a 100644
--- a/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/support/Type.java
+++ b/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/support/Type.java
@@ -1,21 +1,21 @@
-/*
- * 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.rpc.protocol.dubbo.support;
-
-public enum Type {
- High, Normal, Lower
+/*
+ * 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.rpc.protocol.dubbo.support;
+
+public enum Type {
+ High, Normal, Lower
}
\ No newline at end of file
diff --git a/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/ChangeTelnetHandlerTest.java b/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/ChangeTelnetHandlerTest.java
index 96612cb10f..4df87ab5e0 100644
--- a/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/ChangeTelnetHandlerTest.java
+++ b/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/ChangeTelnetHandlerTest.java
@@ -1,120 +1,120 @@
-/*
- * 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.rpc.protocol.dubbo.telnet;
-
-import com.alibaba.dubbo.common.URL;
-import com.alibaba.dubbo.remoting.Channel;
-import com.alibaba.dubbo.remoting.RemotingException;
-import com.alibaba.dubbo.remoting.telnet.TelnetHandler;
-import com.alibaba.dubbo.rpc.Invoker;
-import com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol;
-import com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService;
-import com.alibaba.dubbo.rpc.protocol.dubbo.support.ProtocolUtils;
-
-import org.easymock.EasyMock;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * ChangeTelnetHandlerTest.java
- */
-public class ChangeTelnetHandlerTest {
-
- private static TelnetHandler change = new ChangeTelnetHandler();
- private Channel mockChannel;
- private Invoker<DemoService> mockInvoker;
-
- @AfterClass
- public static void tearDown() {
-
- }
-
- @SuppressWarnings("unchecked")
- @Before
- public void setUp() {
- mockChannel = EasyMock.createMock(Channel.class);
- mockInvoker = EasyMock.createMock(Invoker.class);
- EasyMock.expect(mockChannel.getAttribute("telnet.service")).andReturn("com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService").anyTimes();
- mockChannel.setAttribute("telnet.service", "DemoService");
- EasyMock.expectLastCall().anyTimes();
- mockChannel.setAttribute("telnet.service", "com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService");
- EasyMock.expectLastCall().anyTimes();
- mockChannel.setAttribute("telnet.service", "demo");
- EasyMock.expectLastCall().anyTimes();
- mockChannel.removeAttribute("telnet.service");
- EasyMock.expectLastCall().anyTimes();
- EasyMock.expect(mockInvoker.getInterface()).andReturn(DemoService.class).anyTimes();
- EasyMock.expect(mockInvoker.getUrl()).andReturn(URL.valueOf("dubbo://127.0.0.1:20883/demo")).anyTimes();
- EasyMock.replay(mockChannel, mockInvoker);
- }
-
- @After
- public void after() {
- ProtocolUtils.closeAll();
- EasyMock.reset(mockChannel, mockInvoker);
- }
-
- @Test
- public void testChangeSimpleName() throws RemotingException {
- DubboProtocol.getDubboProtocol().export(mockInvoker);
- String result = change.telnet(mockChannel, "DemoService");
- assertEquals("Used the DemoService as default.\r\nYou can cancel default service by command: cd /", result);
- }
-
- @Test
- public void testChangeName() throws RemotingException {
- DubboProtocol.getDubboProtocol().export(mockInvoker);
- String result = change.telnet(mockChannel, "com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService");
- assertEquals("Used the com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService as default.\r\nYou can cancel default service by command: cd /",
- result);
- }
-
- @Test
- public void testChangePath() throws RemotingException {
- DubboProtocol.getDubboProtocol().export(mockInvoker);
- String result = change.telnet(mockChannel, "demo");
- assertEquals("Used the demo as default.\r\nYou can cancel default service by command: cd /", result);
- }
-
- @Test
- public void testChangeMessageNull() throws RemotingException {
- String result = change.telnet(mockChannel, null);
- assertEquals("Please input service name, eg: \r\ncd XxxService\r\ncd com.xxx.XxxService", result);
- }
-
- @Test
- public void testChangeServiceNotExport() throws RemotingException {
- String result = change.telnet(mockChannel, "demo");
- assertEquals("No such service demo", result);
- }
-
- @Test
- public void testChangeCancel() throws RemotingException {
- String result = change.telnet(mockChannel, "..");
- assertEquals("Cancelled default service com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService.", result);
- }
-
- @Test
- public void testChangeCancel2() throws RemotingException {
- String result = change.telnet(mockChannel, "/");
- assertEquals("Cancelled default service com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService.", result);
- }
+/*
+ * 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.rpc.protocol.dubbo.telnet;
+
+import com.alibaba.dubbo.common.URL;
+import com.alibaba.dubbo.remoting.Channel;
+import com.alibaba.dubbo.remoting.RemotingException;
+import com.alibaba.dubbo.remoting.telnet.TelnetHandler;
+import com.alibaba.dubbo.rpc.Invoker;
+import com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol;
+import com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService;
+import com.alibaba.dubbo.rpc.protocol.dubbo.support.ProtocolUtils;
+
+import org.easymock.EasyMock;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * ChangeTelnetHandlerTest.java
+ */
+public class ChangeTelnetHandlerTest {
+
+ private static TelnetHandler change = new ChangeTelnetHandler();
+ private Channel mockChannel;
+ private Invoker<DemoService> mockInvoker;
+
+ @AfterClass
+ public static void tearDown() {
+
+ }
+
+ @SuppressWarnings("unchecked")
+ @Before
+ public void setUp() {
+ mockChannel = EasyMock.createMock(Channel.class);
+ mockInvoker = EasyMock.createMock(Invoker.class);
+ EasyMock.expect(mockChannel.getAttribute("telnet.service")).andReturn("com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService").anyTimes();
+ mockChannel.setAttribute("telnet.service", "DemoService");
+ EasyMock.expectLastCall().anyTimes();
+ mockChannel.setAttribute("telnet.service", "com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService");
+ EasyMock.expectLastCall().anyTimes();
+ mockChannel.setAttribute("telnet.service", "demo");
+ EasyMock.expectLastCall().anyTimes();
+ mockChannel.removeAttribute("telnet.service");
+ EasyMock.expectLastCall().anyTimes();
+ EasyMock.expect(mockInvoker.getInterface()).andReturn(DemoService.class).anyTimes();
+ EasyMock.expect(mockInvoker.getUrl()).andReturn(URL.valueOf("dubbo://127.0.0.1:20883/demo")).anyTimes();
+ EasyMock.replay(mockChannel, mockInvoker);
+ }
+
+ @After
+ public void after() {
+ ProtocolUtils.closeAll();
+ EasyMock.reset(mockChannel, mockInvoker);
+ }
+
+ @Test
+ public void testChangeSimpleName() throws RemotingException {
+ DubboProtocol.getDubboProtocol().export(mockInvoker);
+ String result = change.telnet(mockChannel, "DemoService");
+ assertEquals("Used the DemoService as default.\r\nYou can cancel default service by command: cd /", result);
+ }
+
+ @Test
+ public void testChangeName() throws RemotingException {
+ DubboProtocol.getDubboProtocol().export(mockInvoker);
+ String result = change.telnet(mockChannel, "com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService");
+ assertEquals("Used the com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService as default.\r\nYou can cancel default service by command: cd /",
+ result);
+ }
+
+ @Test
+ public void testChangePath() throws RemotingException {
+ DubboProtocol.getDubboProtocol().export(mockInvoker);
+ String result = change.telnet(mockChannel, "demo");
+ assertEquals("Used the demo as default.\r\nYou can cancel default service by command: cd /", result);
+ }
+
+ @Test
+ public void testChangeMessageNull() throws RemotingException {
+ String result = change.telnet(mockChannel, null);
+ assertEquals("Please input service name, eg: \r\ncd XxxService\r\ncd com.xxx.XxxService", result);
+ }
+
+ @Test
+ public void testChangeServiceNotExport() throws RemotingException {
+ String result = change.telnet(mockChannel, "demo");
+ assertEquals("No such service demo", result);
+ }
+
+ @Test
+ public void testChangeCancel() throws RemotingException {
+ String result = change.telnet(mockChannel, "..");
+ assertEquals("Cancelled default service com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService.", result);
+ }
+
+ @Test
+ public void testChangeCancel2() throws RemotingException {
+ String result = change.telnet(mockChannel, "/");
+ assertEquals("Cancelled default service com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService.", result);
+ }
}
\ No newline at end of file
diff --git a/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/CurrentTelnetHandlerTest.java b/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/CurrentTelnetHandlerTest.java
index fb6c04ea75..aa3601195e 100644
--- a/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/CurrentTelnetHandlerTest.java
+++ b/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/CurrentTelnetHandlerTest.java
@@ -1,68 +1,68 @@
-/*
- * 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.rpc.protocol.dubbo.telnet;
-
-import com.alibaba.dubbo.remoting.Channel;
-import com.alibaba.dubbo.remoting.RemotingException;
-import com.alibaba.dubbo.remoting.telnet.TelnetHandler;
-
-import org.easymock.EasyMock;
-import org.junit.After;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * CountTelnetHandlerTest.java
- */
-public class CurrentTelnetHandlerTest {
-
- private static TelnetHandler count = new CurrentTelnetHandler();
- private Channel mockChannel;
-
- @After
- public void after() {
- EasyMock.reset(mockChannel);
- }
-
- @Test
- public void testService() throws RemotingException {
- mockChannel = EasyMock.createMock(Channel.class);
- EasyMock.expect(mockChannel.getAttribute("telnet.service")).andReturn("com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService").anyTimes();
- EasyMock.replay(mockChannel);
- String result = count.telnet(mockChannel, "");
- assertEquals("com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService", result);
- }
-
- @Test
- public void testSlash() throws RemotingException {
- mockChannel = EasyMock.createMock(Channel.class);
- EasyMock.expect(mockChannel.getAttribute("telnet.service")).andReturn(null).anyTimes();
- EasyMock.replay(mockChannel);
- String result = count.telnet(mockChannel, "");
- assertEquals("/", result);
- }
-
- @Test
- public void testMessageError() throws RemotingException {
- mockChannel = EasyMock.createMock(Channel.class);
- EasyMock.expect(mockChannel.getAttribute("telnet.service")).andReturn(null).anyTimes();
- EasyMock.replay(mockChannel);
- String result = count.telnet(mockChannel, "test");
- assertEquals("Unsupported parameter test for pwd.", result);
- }
+/*
+ * 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.rpc.protocol.dubbo.telnet;
+
+import com.alibaba.dubbo.remoting.Channel;
+import com.alibaba.dubbo.remoting.RemotingException;
+import com.alibaba.dubbo.remoting.telnet.TelnetHandler;
+
+import org.easymock.EasyMock;
+import org.junit.After;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * CountTelnetHandlerTest.java
+ */
+public class CurrentTelnetHandlerTest {
+
+ private static TelnetHandler count = new CurrentTelnetHandler();
+ private Channel mockChannel;
+
+ @After
+ public void after() {
+ EasyMock.reset(mockChannel);
+ }
+
+ @Test
+ public void testService() throws RemotingException {
+ mockChannel = EasyMock.createMock(Channel.class);
+ EasyMock.expect(mockChannel.getAttribute("telnet.service")).andReturn("com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService").anyTimes();
+ EasyMock.replay(mockChannel);
+ String result = count.telnet(mockChannel, "");
+ assertEquals("com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService", result);
+ }
+
+ @Test
+ public void testSlash() throws RemotingException {
+ mockChannel = EasyMock.createMock(Channel.class);
+ EasyMock.expect(mockChannel.getAttribute("telnet.service")).andReturn(null).anyTimes();
+ EasyMock.replay(mockChannel);
+ String result = count.telnet(mockChannel, "");
+ assertEquals("/", result);
+ }
+
+ @Test
+ public void testMessageError() throws RemotingException {
+ mockChannel = EasyMock.createMock(Channel.class);
+ EasyMock.expect(mockChannel.getAttribute("telnet.service")).andReturn(null).anyTimes();
+ EasyMock.replay(mockChannel);
+ String result = count.telnet(mockChannel, "test");
+ assertEquals("Unsupported parameter test for pwd.", result);
+ }
}
\ No newline at end of file
diff --git a/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/InvokerTelnetHandlerTest.java b/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/InvokerTelnetHandlerTest.java
index 61784bbaa7..8013924e19 100644
--- a/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/InvokerTelnetHandlerTest.java
+++ b/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/InvokerTelnetHandlerTest.java
@@ -1,108 +1,108 @@
-/*
- * 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.rpc.protocol.dubbo.telnet;
-
-import com.alibaba.dubbo.common.URL;
-import com.alibaba.dubbo.common.utils.NetUtils;
-import com.alibaba.dubbo.remoting.Channel;
-import com.alibaba.dubbo.remoting.RemotingException;
-import com.alibaba.dubbo.remoting.telnet.TelnetHandler;
-import com.alibaba.dubbo.rpc.Invocation;
-import com.alibaba.dubbo.rpc.Invoker;
-import com.alibaba.dubbo.rpc.RpcResult;
-import com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol;
-import com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService;
-import com.alibaba.dubbo.rpc.protocol.dubbo.support.ProtocolUtils;
-
-import org.easymock.EasyMock;
-import org.junit.After;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-/**
- * CountTelnetHandlerTest.java
- */
-public class InvokerTelnetHandlerTest {
-
- private static TelnetHandler invoke = new InvokeTelnetHandler();
- private Channel mockChannel;
- private Invoker<DemoService> mockInvoker;
-
- @After
- public void after() {
- ProtocolUtils.closeAll();
- }
-
- @SuppressWarnings("unchecked")
- @Test
- public void testInvokeDefaultSService() throws RemotingException {
- mockInvoker = EasyMock.createMock(Invoker.class);
- EasyMock.expect(mockInvoker.getInterface()).andReturn(DemoService.class).anyTimes();
- EasyMock.expect(mockInvoker.getUrl()).andReturn(URL.valueOf("dubbo://127.0.0.1:20883/demo")).anyTimes();
- EasyMock.expect(mockInvoker.invoke((Invocation) EasyMock.anyObject())).andReturn(new RpcResult("ok")).anyTimes();
- mockChannel = EasyMock.createMock(Channel.class);
- EasyMock.expect(mockChannel.getAttribute("telnet.service")).andReturn("com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService").anyTimes();
- EasyMock.expect(mockChannel.getLocalAddress()).andReturn(NetUtils.toAddress("127.0.0.1:5555")).anyTimes();
- EasyMock.expect(mockChannel.getRemoteAddress()).andReturn(NetUtils.toAddress("127.0.0.1:20883")).anyTimes();
- EasyMock.replay(mockChannel, mockInvoker);
- DubboProtocol.getDubboProtocol().export(mockInvoker);
- String result = invoke.telnet(mockChannel, "DemoService.echo(\"ok\")");
- assertTrue(result.contains("Use default service com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService.\r\n\"ok\"\r\n"));
- EasyMock.reset(mockChannel, mockInvoker);
- }
-
- @SuppressWarnings("unchecked")
- @Test
- public void testInvokeAutoFindMethod() throws RemotingException {
- mockInvoker = EasyMock.createMock(Invoker.class);
- EasyMock.expect(mockInvoker.getInterface()).andReturn(DemoService.class).anyTimes();
- EasyMock.expect(mockInvoker.getUrl()).andReturn(URL.valueOf("dubbo://127.0.0.1:20883/demo")).anyTimes();
- EasyMock.expect(mockInvoker.invoke((Invocation) EasyMock.anyObject())).andReturn(new RpcResult("ok")).anyTimes();
- mockChannel = EasyMock.createMock(Channel.class);
- EasyMock.expect(mockChannel.getAttribute("telnet.service")).andReturn(null).anyTimes();
- EasyMock.expect(mockChannel.getLocalAddress()).andReturn(NetUtils.toAddress("127.0.0.1:5555")).anyTimes();
- EasyMock.expect(mockChannel.getRemoteAddress()).andReturn(NetUtils.toAddress("127.0.0.1:20883")).anyTimes();
- EasyMock.replay(mockChannel, mockInvoker);
- DubboProtocol.getDubboProtocol().export(mockInvoker);
- String result = invoke.telnet(mockChannel, "echo(\"ok\")");
- assertTrue(result.contains("ok"));
- EasyMock.reset(mockChannel, mockInvoker);
- }
-
- @Test
- public void testMessageNull() throws RemotingException {
- mockChannel = EasyMock.createMock(Channel.class);
- EasyMock.expect(mockChannel.getAttribute("telnet.service")).andReturn(null).anyTimes();
- EasyMock.replay(mockChannel);
- String result = invoke.telnet(mockChannel, null);
- assertEquals("Please input method name, eg: \r\ninvoke xxxMethod(1234, \"abcd\", {\"prop\" : \"value\"})\r\ninvoke XxxService.xxxMethod(1234, \"abcd\", {\"prop\" : \"value\"})\r\ninvoke com.xxx.XxxService.xxxMethod(1234, \"abcd\", {\"prop\" : \"value\"})",
- result);
- EasyMock.reset(mockChannel);
- }
-
- @Test
- public void testInvaildMessage() throws RemotingException {
- mockChannel = EasyMock.createMock(Channel.class);
- EasyMock.expect(mockChannel.getAttribute("telnet.service")).andReturn(null).anyTimes();
- EasyMock.replay(mockChannel);
- String result = invoke.telnet(mockChannel, "(");
- assertEquals("Invalid parameters, format: service.method(args)", result);
- EasyMock.reset(mockChannel);
- }
+/*
+ * 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.rpc.protocol.dubbo.telnet;
+
+import com.alibaba.dubbo.common.URL;
+import com.alibaba.dubbo.common.utils.NetUtils;
+import com.alibaba.dubbo.remoting.Channel;
+import com.alibaba.dubbo.remoting.RemotingException;
+import com.alibaba.dubbo.remoting.telnet.TelnetHandler;
+import com.alibaba.dubbo.rpc.Invocation;
+import com.alibaba.dubbo.rpc.Invoker;
+import com.alibaba.dubbo.rpc.RpcResult;
+import com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol;
+import com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService;
+import com.alibaba.dubbo.rpc.protocol.dubbo.support.ProtocolUtils;
+
+import org.easymock.EasyMock;
+import org.junit.After;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * CountTelnetHandlerTest.java
+ */
+public class InvokerTelnetHandlerTest {
+
+ private static TelnetHandler invoke = new InvokeTelnetHandler();
+ private Channel mockChannel;
+ private Invoker<DemoService> mockInvoker;
+
+ @After
+ public void after() {
+ ProtocolUtils.closeAll();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testInvokeDefaultSService() throws RemotingException {
+ mockInvoker = EasyMock.createMock(Invoker.class);
+ EasyMock.expect(mockInvoker.getInterface()).andReturn(DemoService.class).anyTimes();
+ EasyMock.expect(mockInvoker.getUrl()).andReturn(URL.valueOf("dubbo://127.0.0.1:20883/demo")).anyTimes();
+ EasyMock.expect(mockInvoker.invoke((Invocation) EasyMock.anyObject())).andReturn(new RpcResult("ok")).anyTimes();
+ mockChannel = EasyMock.createMock(Channel.class);
+ EasyMock.expect(mockChannel.getAttribute("telnet.service")).andReturn("com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService").anyTimes();
+ EasyMock.expect(mockChannel.getLocalAddress()).andReturn(NetUtils.toAddress("127.0.0.1:5555")).anyTimes();
+ EasyMock.expect(mockChannel.getRemoteAddress()).andReturn(NetUtils.toAddress("127.0.0.1:20883")).anyTimes();
+ EasyMock.replay(mockChannel, mockInvoker);
+ DubboProtocol.getDubboProtocol().export(mockInvoker);
+ String result = invoke.telnet(mockChannel, "DemoService.echo(\"ok\")");
+ assertTrue(result.contains("Use default service com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService.\r\n\"ok\"\r\n"));
+ EasyMock.reset(mockChannel, mockInvoker);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testInvokeAutoFindMethod() throws RemotingException {
+ mockInvoker = EasyMock.createMock(Invoker.class);
+ EasyMock.expect(mockInvoker.getInterface()).andReturn(DemoService.class).anyTimes();
+ EasyMock.expect(mockInvoker.getUrl()).andReturn(URL.valueOf("dubbo://127.0.0.1:20883/demo")).anyTimes();
+ EasyMock.expect(mockInvoker.invoke((Invocation) EasyMock.anyObject())).andReturn(new RpcResult("ok")).anyTimes();
+ mockChannel = EasyMock.createMock(Channel.class);
+ EasyMock.expect(mockChannel.getAttribute("telnet.service")).andReturn(null).anyTimes();
+ EasyMock.expect(mockChannel.getLocalAddress()).andReturn(NetUtils.toAddress("127.0.0.1:5555")).anyTimes();
+ EasyMock.expect(mockChannel.getRemoteAddress()).andReturn(NetUtils.toAddress("127.0.0.1:20883")).anyTimes();
+ EasyMock.replay(mockChannel, mockInvoker);
+ DubboProtocol.getDubboProtocol().export(mockInvoker);
+ String result = invoke.telnet(mockChannel, "echo(\"ok\")");
+ assertTrue(result.contains("ok"));
+ EasyMock.reset(mockChannel, mockInvoker);
+ }
+
+ @Test
+ public void testMessageNull() throws RemotingException {
+ mockChannel = EasyMock.createMock(Channel.class);
+ EasyMock.expect(mockChannel.getAttribute("telnet.service")).andReturn(null).anyTimes();
+ EasyMock.replay(mockChannel);
+ String result = invoke.telnet(mockChannel, null);
+ assertEquals("Please input method name, eg: \r\ninvoke xxxMethod(1234, \"abcd\", {\"prop\" : \"value\"})\r\ninvoke XxxService.xxxMethod(1234, \"abcd\", {\"prop\" : \"value\"})\r\ninvoke com.xxx.XxxService.xxxMethod(1234, \"abcd\", {\"prop\" : \"value\"})",
+ result);
+ EasyMock.reset(mockChannel);
+ }
+
+ @Test
+ public void testInvaildMessage() throws RemotingException {
+ mockChannel = EasyMock.createMock(Channel.class);
+ EasyMock.expect(mockChannel.getAttribute("telnet.service")).andReturn(null).anyTimes();
+ EasyMock.replay(mockChannel);
+ String result = invoke.telnet(mockChannel, "(");
+ assertEquals("Invalid parameters, format: service.method(args)", result);
+ EasyMock.reset(mockChannel);
+ }
}
\ No newline at end of file
diff --git a/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/ListTelnetHandlerTest.java b/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/ListTelnetHandlerTest.java
index 301e7874ab..956c1b62b1 100644
--- a/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/ListTelnetHandlerTest.java
+++ b/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/ListTelnetHandlerTest.java
@@ -1,169 +1,169 @@
-/*
- * 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.rpc.protocol.dubbo.telnet;
-
-import com.alibaba.dubbo.common.URL;
-import com.alibaba.dubbo.common.utils.NetUtils;
-import com.alibaba.dubbo.common.utils.ReflectUtils;
-import com.alibaba.dubbo.remoting.Channel;
-import com.alibaba.dubbo.remoting.RemotingException;
-import com.alibaba.dubbo.remoting.telnet.TelnetHandler;
-import com.alibaba.dubbo.rpc.Invocation;
-import com.alibaba.dubbo.rpc.Invoker;
-import com.alibaba.dubbo.rpc.RpcResult;
-import com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol;
-import com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService;
-import com.alibaba.dubbo.rpc.protocol.dubbo.support.ProtocolUtils;
-
-import org.easymock.EasyMock;
-import org.junit.After;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.lang.reflect.Method;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * CountTelnetHandlerTest.java
- */
-public class ListTelnetHandlerTest {
-
- private static TelnetHandler list = new ListTelnetHandler();
- private static String detailMethods;
- private static String methodsName;
- private Channel mockChannel;
- private Invoker<DemoService> mockInvoker;
-
- @BeforeClass
- public static void setUp() {
- StringBuilder buf = new StringBuilder();
- StringBuilder buf2 = new StringBuilder();
- Method[] methods = DemoService.class.getMethods();
- for (Method method : methods) {
- if (buf.length() > 0) {
- buf.append("\r\n");
- }
- if (buf2.length() > 0) {
- buf2.append("\r\n");
- }
- buf2.append(method.getName());
- buf.append(ReflectUtils.getName(method));
- }
- detailMethods = buf.toString();
- methodsName = buf2.toString();
-
- ProtocolUtils.closeAll();
- }
-
- @After
- public void after() {
- ProtocolUtils.closeAll();
- }
-
- @SuppressWarnings("unchecked")
- @Test
- public void testListDetailService() throws RemotingException {
- mockInvoker = EasyMock.createMock(Invoker.class);
- EasyMock.expect(mockInvoker.getInterface()).andReturn(DemoService.class).anyTimes();
- EasyMock.expect(mockInvoker.getUrl()).andReturn(URL.valueOf("dubbo://127.0.0.1:20885/demo")).anyTimes();
- EasyMock.expect(mockInvoker.invoke((Invocation) EasyMock.anyObject())).andReturn(new RpcResult("ok")).anyTimes();
- mockChannel = EasyMock.createMock(Channel.class);
- EasyMock.expect(mockChannel.getAttribute("telnet.service")).andReturn("com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService").anyTimes();
- EasyMock.replay(mockChannel, mockInvoker);
- DubboProtocol.getDubboProtocol().export(mockInvoker);
- String result = list.telnet(mockChannel, "-l DemoService");
- assertEquals(detailMethods, result);
- EasyMock.reset(mockChannel, mockInvoker);
- }
-
- @SuppressWarnings("unchecked")
- @Test
- public void testListService() throws RemotingException {
- mockInvoker = EasyMock.createMock(Invoker.class);
- EasyMock.expect(mockInvoker.getInterface()).andReturn(DemoService.class).anyTimes();
- EasyMock.expect(mockInvoker.getUrl()).andReturn(URL.valueOf("dubbo://127.0.0.1:20885/demo")).anyTimes();
- EasyMock.expect(mockInvoker.invoke((Invocation) EasyMock.anyObject())).andReturn(new RpcResult("ok")).anyTimes();
- mockChannel = EasyMock.createMock(Channel.class);
- EasyMock.expect(mockChannel.getAttribute("telnet.service")).andReturn("com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService").anyTimes();
- EasyMock.replay(mockChannel, mockInvoker);
- DubboProtocol.getDubboProtocol().export(mockInvoker);
- String result = list.telnet(mockChannel, "DemoService");
- assertEquals(methodsName, result);
- EasyMock.reset(mockChannel, mockInvoker);
- }
-
- @SuppressWarnings("unchecked")
- @Test
- public void testList() throws RemotingException {
- mockInvoker = EasyMock.createMock(Invoker.class);
- EasyMock.expect(mockInvoker.getInterface()).andReturn(DemoService.class).anyTimes();
- EasyMock.expect(mockInvoker.getUrl()).andReturn(URL.valueOf("dubbo://127.0.0.1:20885/demo")).anyTimes();
- EasyMock.expect(mockInvoker.invoke((Invocation) EasyMock.anyObject())).andReturn(new RpcResult("ok")).anyTimes();
- mockChannel = EasyMock.createMock(Channel.class);
- EasyMock.expect(mockChannel.getAttribute("telnet.service")).andReturn(null).anyTimes();
- EasyMock.replay(mockChannel, mockInvoker);
- DubboProtocol.getDubboProtocol().export(mockInvoker);
- String result = list.telnet(mockChannel, "");
- assertEquals("com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService", result);
- EasyMock.reset(mockChannel);
- }
-
- @SuppressWarnings("unchecked")
- @Test
- public void testListDetail() throws RemotingException {
- int port = NetUtils.getAvailablePort();
- mockInvoker = EasyMock.createMock(Invoker.class);
- EasyMock.expect(mockInvoker.getInterface()).andReturn(DemoService.class).anyTimes();
- EasyMock.expect(mockInvoker.getUrl()).andReturn(URL.valueOf("dubbo://127.0.0.1:" + port + "/demo")).anyTimes();
- EasyMock.expect(mockInvoker.invoke((Invocation) EasyMock.anyObject())).andReturn(new RpcResult("ok")).anyTimes();
- mockChannel = EasyMock.createMock(Channel.class);
- EasyMock.expect(mockChannel.getAttribute("telnet.service")).andReturn(null).anyTimes();
- EasyMock.replay(mockChannel, mockInvoker);
- DubboProtocol.getDubboProtocol().export(mockInvoker);
- String result = list.telnet(mockChannel, "-l");
- assertEquals("com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService -> dubbo://127.0.0.1:" + port + "/demo", result);
- EasyMock.reset(mockChannel);
- }
-
- @SuppressWarnings("unchecked")
- @Test
- public void testListDefault() throws RemotingException {
- mockInvoker = EasyMock.createMock(Invoker.class);
- EasyMock.expect(mockInvoker.getInterface()).andReturn(DemoService.class).anyTimes();
- EasyMock.expect(mockInvoker.getUrl()).andReturn(URL.valueOf("dubbo://127.0.0.1:20885/demo")).anyTimes();
- EasyMock.expect(mockInvoker.invoke((Invocation) EasyMock.anyObject())).andReturn(new RpcResult("ok")).anyTimes();
- mockChannel = EasyMock.createMock(Channel.class);
- EasyMock.expect(mockChannel.getAttribute("telnet.service")).andReturn("com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService").anyTimes();
- EasyMock.replay(mockChannel, mockInvoker);
- DubboProtocol.getDubboProtocol().export(mockInvoker);
- String result = list.telnet(mockChannel, "");
- assertEquals("Use default service com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService.\r\n\r\n"
- + methodsName, result);
- EasyMock.reset(mockChannel);
- }
-
- @Test
- public void testInvaildMessage() throws RemotingException {
- mockChannel = EasyMock.createMock(Channel.class);
- EasyMock.expect(mockChannel.getAttribute("telnet.service")).andReturn(null).anyTimes();
- EasyMock.replay(mockChannel);
- String result = list.telnet(mockChannel, "xx");
- assertEquals("No such service xx", result);
- EasyMock.reset(mockChannel);
- }
+/*
+ * 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.rpc.protocol.dubbo.telnet;
+
+import com.alibaba.dubbo.common.URL;
+import com.alibaba.dubbo.common.utils.NetUtils;
+import com.alibaba.dubbo.common.utils.ReflectUtils;
+import com.alibaba.dubbo.remoting.Channel;
+import com.alibaba.dubbo.remoting.RemotingException;
+import com.alibaba.dubbo.remoting.telnet.TelnetHandler;
+import com.alibaba.dubbo.rpc.Invocation;
+import com.alibaba.dubbo.rpc.Invoker;
+import com.alibaba.dubbo.rpc.RpcResult;
+import com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol;
+import com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService;
+import com.alibaba.dubbo.rpc.protocol.dubbo.support.ProtocolUtils;
+
+import org.easymock.EasyMock;
+import org.junit.After;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.lang.reflect.Method;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * CountTelnetHandlerTest.java
+ */
+public class ListTelnetHandlerTest {
+
+ private static TelnetHandler list = new ListTelnetHandler();
+ private static String detailMethods;
+ private static String methodsName;
+ private Channel mockChannel;
+ private Invoker<DemoService> mockInvoker;
+
+ @BeforeClass
+ public static void setUp() {
+ StringBuilder buf = new StringBuilder();
+ StringBuilder buf2 = new StringBuilder();
+ Method[] methods = DemoService.class.getMethods();
+ for (Method method : methods) {
+ if (buf.length() > 0) {
+ buf.append("\r\n");
+ }
+ if (buf2.length() > 0) {
+ buf2.append("\r\n");
+ }
+ buf2.append(method.getName());
+ buf.append(ReflectUtils.getName(method));
+ }
+ detailMethods = buf.toString();
+ methodsName = buf2.toString();
+
+ ProtocolUtils.closeAll();
+ }
+
+ @After
+ public void after() {
+ ProtocolUtils.closeAll();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testListDetailService() throws RemotingException {
+ mockInvoker = EasyMock.createMock(Invoker.class);
+ EasyMock.expect(mockInvoker.getInterface()).andReturn(DemoService.class).anyTimes();
+ EasyMock.expect(mockInvoker.getUrl()).andReturn(URL.valueOf("dubbo://127.0.0.1:20885/demo")).anyTimes();
+ EasyMock.expect(mockInvoker.invoke((Invocation) EasyMock.anyObject())).andReturn(new RpcResult("ok")).anyTimes();
+ mockChannel = EasyMock.createMock(Channel.class);
+ EasyMock.expect(mockChannel.getAttribute("telnet.service")).andReturn("com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService").anyTimes();
+ EasyMock.replay(mockChannel, mockInvoker);
+ DubboProtocol.getDubboProtocol().export(mockInvoker);
+ String result = list.telnet(mockChannel, "-l DemoService");
+ assertEquals(detailMethods, result);
+ EasyMock.reset(mockChannel, mockInvoker);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testListService() throws RemotingException {
+ mockInvoker = EasyMock.createMock(Invoker.class);
+ EasyMock.expect(mockInvoker.getInterface()).andReturn(DemoService.class).anyTimes();
+ EasyMock.expect(mockInvoker.getUrl()).andReturn(URL.valueOf("dubbo://127.0.0.1:20885/demo")).anyTimes();
+ EasyMock.expect(mockInvoker.invoke((Invocation) EasyMock.anyObject())).andReturn(new RpcResult("ok")).anyTimes();
+ mockChannel = EasyMock.createMock(Channel.class);
+ EasyMock.expect(mockChannel.getAttribute("telnet.service")).andReturn("com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService").anyTimes();
+ EasyMock.replay(mockChannel, mockInvoker);
+ DubboProtocol.getDubboProtocol().export(mockInvoker);
+ String result = list.telnet(mockChannel, "DemoService");
+ assertEquals(methodsName, result);
+ EasyMock.reset(mockChannel, mockInvoker);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testList() throws RemotingException {
+ mockInvoker = EasyMock.createMock(Invoker.class);
+ EasyMock.expect(mockInvoker.getInterface()).andReturn(DemoService.class).anyTimes();
+ EasyMock.expect(mockInvoker.getUrl()).andReturn(URL.valueOf("dubbo://127.0.0.1:20885/demo")).anyTimes();
+ EasyMock.expect(mockInvoker.invoke((Invocation) EasyMock.anyObject())).andReturn(new RpcResult("ok")).anyTimes();
+ mockChannel = EasyMock.createMock(Channel.class);
+ EasyMock.expect(mockChannel.getAttribute("telnet.service")).andReturn(null).anyTimes();
+ EasyMock.replay(mockChannel, mockInvoker);
+ DubboProtocol.getDubboProtocol().export(mockInvoker);
+ String result = list.telnet(mockChannel, "");
+ assertEquals("com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService", result);
+ EasyMock.reset(mockChannel);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testListDetail() throws RemotingException {
+ int port = NetUtils.getAvailablePort();
+ mockInvoker = EasyMock.createMock(Invoker.class);
+ EasyMock.expect(mockInvoker.getInterface()).andReturn(DemoService.class).anyTimes();
+ EasyMock.expect(mockInvoker.getUrl()).andReturn(URL.valueOf("dubbo://127.0.0.1:" + port + "/demo")).anyTimes();
+ EasyMock.expect(mockInvoker.invoke((Invocation) EasyMock.anyObject())).andReturn(new RpcResult("ok")).anyTimes();
+ mockChannel = EasyMock.createMock(Channel.class);
+ EasyMock.expect(mockChannel.getAttribute("telnet.service")).andReturn(null).anyTimes();
+ EasyMock.replay(mockChannel, mockInvoker);
+ DubboProtocol.getDubboProtocol().export(mockInvoker);
+ String result = list.telnet(mockChannel, "-l");
+ assertEquals("com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService -> dubbo://127.0.0.1:" + port + "/demo", result);
+ EasyMock.reset(mockChannel);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testListDefault() throws RemotingException {
+ mockInvoker = EasyMock.createMock(Invoker.class);
+ EasyMock.expect(mockInvoker.getInterface()).andReturn(DemoService.class).anyTimes();
+ EasyMock.expect(mockInvoker.getUrl()).andReturn(URL.valueOf("dubbo://127.0.0.1:20885/demo")).anyTimes();
+ EasyMock.expect(mockInvoker.invoke((Invocation) EasyMock.anyObject())).andReturn(new RpcResult("ok")).anyTimes();
+ mockChannel = EasyMock.createMock(Channel.class);
+ EasyMock.expect(mockChannel.getAttribute("telnet.service")).andReturn("com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService").anyTimes();
+ EasyMock.replay(mockChannel, mockInvoker);
+ DubboProtocol.getDubboProtocol().export(mockInvoker);
+ String result = list.telnet(mockChannel, "");
+ assertEquals("Use default service com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService.\r\n\r\n"
+ + methodsName, result);
+ EasyMock.reset(mockChannel);
+ }
+
+ @Test
+ public void testInvaildMessage() throws RemotingException {
+ mockChannel = EasyMock.createMock(Channel.class);
+ EasyMock.expect(mockChannel.getAttribute("telnet.service")).andReturn(null).anyTimes();
+ EasyMock.replay(mockChannel);
+ String result = list.telnet(mockChannel, "xx");
+ assertEquals("No such service xx", result);
+ EasyMock.reset(mockChannel);
+ }
}
\ No newline at end of file
diff --git a/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/LogTelnetHandlerTest.java b/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/LogTelnetHandlerTest.java
index bc6ef998af..5c6d3551e1 100644
--- a/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/LogTelnetHandlerTest.java
+++ b/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/LogTelnetHandlerTest.java
@@ -1,56 +1,56 @@
-/*
- * 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.rpc.protocol.dubbo.telnet;
-
-import com.alibaba.dubbo.remoting.Channel;
-import com.alibaba.dubbo.remoting.RemotingException;
-import com.alibaba.dubbo.remoting.telnet.TelnetHandler;
-
-import org.easymock.EasyMock;
-import org.junit.Test;
-
-import static org.junit.Assert.assertTrue;
-
-/**
- * LogTelnetHandlerTest.java
- */
-public class LogTelnetHandlerTest {
-
- private static TelnetHandler log = new LogTelnetHandler();
- private Channel mockChannel;
-
- @Test
- public void testChangeLogLevel() throws RemotingException {
- mockChannel = EasyMock.createMock(Channel.class);
- EasyMock.replay(mockChannel);
- String result = log.telnet(mockChannel, "error");
- assertTrue(result.contains("\r\nCURRENT LOG LEVEL:ERROR"));
- String result2 = log.telnet(mockChannel, "warn");
- assertTrue(result2.contains("\r\nCURRENT LOG LEVEL:WARN"));
- EasyMock.reset(mockChannel);
- }
-
- @Test
- public void testPrintLog() throws RemotingException {
- mockChannel = EasyMock.createMock(Channel.class);
- EasyMock.replay(mockChannel);
- String result = log.telnet(mockChannel, "100");
- assertTrue(result.contains("CURRENT LOG APPENDER"));
- EasyMock.reset(mockChannel);
- }
-
+/*
+ * 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.rpc.protocol.dubbo.telnet;
+
+import com.alibaba.dubbo.remoting.Channel;
+import com.alibaba.dubbo.remoting.RemotingException;
+import com.alibaba.dubbo.remoting.telnet.TelnetHandler;
+
+import org.easymock.EasyMock;
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
+
+/**
+ * LogTelnetHandlerTest.java
+ */
+public class LogTelnetHandlerTest {
+
+ private static TelnetHandler log = new LogTelnetHandler();
+ private Channel mockChannel;
+
+ @Test
+ public void testChangeLogLevel() throws RemotingException {
+ mockChannel = EasyMock.createMock(Channel.class);
+ EasyMock.replay(mockChannel);
+ String result = log.telnet(mockChannel, "error");
+ assertTrue(result.contains("\r\nCURRENT LOG LEVEL:ERROR"));
+ String result2 = log.telnet(mockChannel, "warn");
+ assertTrue(result2.contains("\r\nCURRENT LOG LEVEL:WARN"));
+ EasyMock.reset(mockChannel);
+ }
+
+ @Test
+ public void testPrintLog() throws RemotingException {
+ mockChannel = EasyMock.createMock(Channel.class);
+ EasyMock.replay(mockChannel);
+ String result = log.telnet(mockChannel, "100");
+ assertTrue(result.contains("CURRENT LOG APPENDER"));
+ EasyMock.reset(mockChannel);
+ }
+
}
\ No newline at end of file
diff --git a/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/PortTelnetHandlerTest.java b/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/PortTelnetHandlerTest.java
index 0bde791549..416ec93286 100644
--- a/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/PortTelnetHandlerTest.java
+++ b/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/PortTelnetHandlerTest.java
@@ -1,105 +1,105 @@
-/*
- * 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.rpc.protocol.dubbo.telnet;
-
-import com.alibaba.dubbo.common.URL;
-import com.alibaba.dubbo.remoting.RemotingException;
-import com.alibaba.dubbo.remoting.exchange.ExchangeClient;
-import com.alibaba.dubbo.remoting.exchange.Exchangers;
-import com.alibaba.dubbo.remoting.telnet.TelnetHandler;
-import com.alibaba.dubbo.rpc.Invoker;
-import com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol;
-import com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService;
-import com.alibaba.dubbo.rpc.protocol.dubbo.support.ProtocolUtils;
-
-import org.easymock.EasyMock;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-/**
- * PortTelnetHandlerTest.java
- */
-public class PortTelnetHandlerTest {
-
- private static TelnetHandler port = new PortTelnetHandler();
- private Invoker<DemoService> mockInvoker;
-
- @SuppressWarnings("unchecked")
- @Before
- public void before() {
- mockInvoker = EasyMock.createMock(Invoker.class);
- EasyMock.expect(mockInvoker.getInterface()).andReturn(DemoService.class).anyTimes();
- EasyMock.expect(mockInvoker.getUrl()).andReturn(URL.valueOf("dubbo://127.0.0.1:20887/demo")).anyTimes();
- EasyMock.replay(mockInvoker);
- DubboProtocol.getDubboProtocol().export(mockInvoker);
- }
-
- @After
- public void after() {
- EasyMock.reset(mockInvoker);
- ProtocolUtils.closeAll();
- }
-
- /**
- * In NAT network scenario, server's channel.getRemoteAddress() possibly get the address of network gateway, or
- * the address converted by NAT. In this case, check port only.
- */
- @Test
- public void testListClient() throws Exception {
- ExchangeClient client1 = Exchangers.connect("dubbo://127.0.0.1:20887/demo");
- ExchangeClient client2 = Exchangers.connect("dubbo://127.0.0.1:20887/demo");
- Thread.sleep(5000);
- String result = port.telnet(null, "-l 20887");
- String client1Addr = client1.getLocalAddress().toString();
- String client2Addr = client2.getLocalAddress().toString();
- System.out.printf("Result: %s %n", result);
- System.out.printf("Client 1 Address %s %n", client1Addr);
- System.out.printf("Client 2 Address %s %n", client2Addr);
- assertTrue(result.contains(String.valueOf(client1.getLocalAddress().getPort())));
- assertTrue(result.contains(String.valueOf(client2.getLocalAddress().getPort())));
-
- }
-
- @Test
- public void testListDetail() throws RemotingException {
- String result = port.telnet(null, "-l");
- assertEquals("dubbo://127.0.0.1:20887", result);
- }
-
- @Test
- public void testListAllPort() throws RemotingException {
- String result = port.telnet(null, "");
- assertEquals("20887", result);
- }
-
- @Test
- public void testErrorMessage() throws RemotingException {
- String result = port.telnet(null, "a");
- assertEquals("Illegal port a, must be integer.", result);
- }
-
- @Test
- public void testNoPort() throws RemotingException {
- String result = port.telnet(null, "-l 20880");
- assertEquals("No such port 20880", result);
- }
-
+/*
+ * 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.rpc.protocol.dubbo.telnet;
+
+import com.alibaba.dubbo.common.URL;
+import com.alibaba.dubbo.remoting.RemotingException;
+import com.alibaba.dubbo.remoting.exchange.ExchangeClient;
+import com.alibaba.dubbo.remoting.exchange.Exchangers;
+import com.alibaba.dubbo.remoting.telnet.TelnetHandler;
+import com.alibaba.dubbo.rpc.Invoker;
+import com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol;
+import com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService;
+import com.alibaba.dubbo.rpc.protocol.dubbo.support.ProtocolUtils;
+
+import org.easymock.EasyMock;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * PortTelnetHandlerTest.java
+ */
+public class PortTelnetHandlerTest {
+
+ private static TelnetHandler port = new PortTelnetHandler();
+ private Invoker<DemoService> mockInvoker;
+
+ @SuppressWarnings("unchecked")
+ @Before
+ public void before() {
+ mockInvoker = EasyMock.createMock(Invoker.class);
+ EasyMock.expect(mockInvoker.getInterface()).andReturn(DemoService.class).anyTimes();
+ EasyMock.expect(mockInvoker.getUrl()).andReturn(URL.valueOf("dubbo://127.0.0.1:20887/demo")).anyTimes();
+ EasyMock.replay(mockInvoker);
+ DubboProtocol.getDubboProtocol().export(mockInvoker);
+ }
+
+ @After
+ public void after() {
+ EasyMock.reset(mockInvoker);
+ ProtocolUtils.closeAll();
+ }
+
+ /**
+ * In NAT network scenario, server's channel.getRemoteAddress() possibly get the address of network gateway, or
+ * the address converted by NAT. In this case, check port only.
+ */
+ @Test
+ public void testListClient() throws Exception {
+ ExchangeClient client1 = Exchangers.connect("dubbo://127.0.0.1:20887/demo");
+ ExchangeClient client2 = Exchangers.connect("dubbo://127.0.0.1:20887/demo");
+ Thread.sleep(5000);
+ String result = port.telnet(null, "-l 20887");
+ String client1Addr = client1.getLocalAddress().toString();
+ String client2Addr = client2.getLocalAddress().toString();
+ System.out.printf("Result: %s %n", result);
+ System.out.printf("Client 1 Address %s %n", client1Addr);
+ System.out.printf("Client 2 Address %s %n", client2Addr);
+ assertTrue(result.contains(String.valueOf(client1.getLocalAddress().getPort())));
+ assertTrue(result.contains(String.valueOf(client2.getLocalAddress().getPort())));
+
+ }
+
+ @Test
+ public void testListDetail() throws RemotingException {
+ String result = port.telnet(null, "-l");
+ assertEquals("dubbo://127.0.0.1:20887", result);
+ }
+
+ @Test
+ public void testListAllPort() throws RemotingException {
+ String result = port.telnet(null, "");
+ assertEquals("20887", result);
+ }
+
+ @Test
+ public void testErrorMessage() throws RemotingException {
+ String result = port.telnet(null, "a");
+ assertEquals("Illegal port a, must be integer.", result);
+ }
+
+ @Test
+ public void testNoPort() throws RemotingException {
+ String result = port.telnet(null, "-l 20880");
+ assertEquals("No such port 20880", result);
+ }
+
}
\ No newline at end of file
diff --git a/dubbo-rpc/dubbo-rpc-default/src/test/resources/log4j.xml b/dubbo-rpc/dubbo-rpc-default/src/test/resources/log4j.xml
index 78c0215c13..4d2154511a 100644
--- a/dubbo-rpc/dubbo-rpc-default/src/test/resources/log4j.xml
+++ b/dubbo-rpc/dubbo-rpc-default/src/test/resources/log4j.xml
@@ -1,46 +1,46 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-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.
--->
-<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
-<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
- <!-- ===================================================================== -->
- <!-- 以下是appender的定义 -->
- <!-- ===================================================================== -->
- <appender name="dubbo" class="com.alibaba.dubbo.common.utils.DubboAppender">
- <param name="encoding" value="GBK"/>
- <layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern" value="%d %p [%c:%M] - %m%n"/>
- </layout>
- <!-- <filter class="org.apache.log4j.varia.LevelRangeFilter">
- <param name="LevelMin" value="DEBUG" />
- <param name="LevelMax" value="DEBUG" />
- </filter> -->
- </appender>
- <appender name="FILE" class="org.apache.log4j.FileAppender">
- <param name="File" value="dubbo.log"/>
- <layout class="org.apache.log4j.PatternLayout">
- <!-- <param name="ConversionPattern" value="[%t %d{dd/MM/yy hh:mm:ss:sss
- z}] %5p %c{2}: %L %m%n" /> -->
- <param name="ConversionPattern" value="[%t %l %d{dd/MM/yy hh:mm:ss:sss z}] %5p %m %n"/>
- </layout>
- </appender>
- <root>
- <level value="INFO"/>
- <appender-ref ref="dubbo"/>
- <appender-ref ref="FILE"/>
- </root>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+ <!-- ===================================================================== -->
+ <!-- 以下是appender的定义 -->
+ <!-- ===================================================================== -->
+ <appender name="dubbo" class="com.alibaba.dubbo.common.utils.DubboAppender">
+ <param name="encoding" value="GBK"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d %p [%c:%M] - %m%n"/>
+ </layout>
+ <!-- <filter class="org.apache.log4j.varia.LevelRangeFilter">
+ <param name="LevelMin" value="DEBUG" />
+ <param name="LevelMax" value="DEBUG" />
+ </filter> -->
+ </appender>
+ <appender name="FILE" class="org.apache.log4j.FileAppender">
+ <param name="File" value="dubbo.log"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- <param name="ConversionPattern" value="[%t %d{dd/MM/yy hh:mm:ss:sss
+ z}] %5p %c{2}: %L %m%n" /> -->
+ <param name="ConversionPattern" value="[%t %l %d{dd/MM/yy hh:mm:ss:sss z}] %5p %m %n"/>
+ </layout>
+ </appender>
+ <root>
+ <level value="INFO"/>
+ <appender-ref ref="dubbo"/>
+ <appender-ref ref="FILE"/>
+ </root>
</log4j:configuration>
\ No newline at end of file
diff --git a/dubbo-rpc/dubbo-rpc-hessian/pom.xml b/dubbo-rpc/dubbo-rpc-hessian/pom.xml
index 8ce6d56f5f..cae580572d 100644
--- a/dubbo-rpc/dubbo-rpc-hessian/pom.xml
+++ b/dubbo-rpc/dubbo-rpc-hessian/pom.xml
@@ -20,7 +20,7 @@ limitations under the License.
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-rpc</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>dubbo-rpc-hessian</artifactId>
<packaging>jar</packaging>
diff --git a/dubbo-rpc/dubbo-rpc-http/pom.xml b/dubbo-rpc/dubbo-rpc-http/pom.xml
index 47e59097d7..3c2d3f8583 100644
--- a/dubbo-rpc/dubbo-rpc-http/pom.xml
+++ b/dubbo-rpc/dubbo-rpc-http/pom.xml
@@ -20,7 +20,7 @@ limitations under the License.
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-rpc</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>dubbo-rpc-http</artifactId>
<packaging>jar</packaging>
diff --git a/dubbo-rpc/dubbo-rpc-injvm/pom.xml b/dubbo-rpc/dubbo-rpc-injvm/pom.xml
index 8f0eabf06d..b223e83560 100644
--- a/dubbo-rpc/dubbo-rpc-injvm/pom.xml
+++ b/dubbo-rpc/dubbo-rpc-injvm/pom.xml
@@ -20,7 +20,7 @@ limitations under the License.
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-rpc</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>dubbo-rpc-injvm</artifactId>
<packaging>jar</packaging>
diff --git a/dubbo-rpc/dubbo-rpc-memcached/pom.xml b/dubbo-rpc/dubbo-rpc-memcached/pom.xml
index 1a6eacb0c3..1e63d69162 100644
--- a/dubbo-rpc/dubbo-rpc-memcached/pom.xml
+++ b/dubbo-rpc/dubbo-rpc-memcached/pom.xml
@@ -20,7 +20,7 @@ limitations under the License.
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-rpc</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>dubbo-rpc-memcached</artifactId>
<packaging>jar</packaging>
diff --git a/dubbo-rpc/dubbo-rpc-redis/pom.xml b/dubbo-rpc/dubbo-rpc-redis/pom.xml
index f6dfca5703..460c6c9ca3 100644
--- a/dubbo-rpc/dubbo-rpc-redis/pom.xml
+++ b/dubbo-rpc/dubbo-rpc-redis/pom.xml
@@ -20,7 +20,7 @@ limitations under the License.
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-rpc</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>dubbo-rpc-redis</artifactId>
<packaging>jar</packaging>
diff --git a/dubbo-rpc/dubbo-rpc-rmi/pom.xml b/dubbo-rpc/dubbo-rpc-rmi/pom.xml
index 270303e13a..629e6e29c9 100644
--- a/dubbo-rpc/dubbo-rpc-rmi/pom.xml
+++ b/dubbo-rpc/dubbo-rpc-rmi/pom.xml
@@ -20,7 +20,7 @@ limitations under the License.
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-rpc</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>dubbo-rpc-rmi</artifactId>
<packaging>jar</packaging>
diff --git a/dubbo-rpc/dubbo-rpc-thrift/pom.xml b/dubbo-rpc/dubbo-rpc-thrift/pom.xml
index e574631c4a..ac48306f72 100644
--- a/dubbo-rpc/dubbo-rpc-thrift/pom.xml
+++ b/dubbo-rpc/dubbo-rpc-thrift/pom.xml
@@ -20,7 +20,7 @@ limitations under the License.
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-rpc</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>dubbo-rpc-thrift</artifactId>
<packaging>jar</packaging>
diff --git a/dubbo-rpc/dubbo-rpc-webservice/pom.xml b/dubbo-rpc/dubbo-rpc-webservice/pom.xml
index 72c77be165..7ccdddec14 100644
--- a/dubbo-rpc/dubbo-rpc-webservice/pom.xml
+++ b/dubbo-rpc/dubbo-rpc-webservice/pom.xml
@@ -20,7 +20,7 @@ limitations under the License.
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-rpc</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>dubbo-rpc-webservice</artifactId>
<packaging>jar</packaging>
diff --git a/dubbo-rpc/pom.xml b/dubbo-rpc/pom.xml
index 6d7c4bd607..6523cff8f8 100644
--- a/dubbo-rpc/pom.xml
+++ b/dubbo-rpc/pom.xml
@@ -20,7 +20,7 @@ limitations under the License.
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-parent</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>dubbo-rpc</artifactId>
<packaging>pom</packaging>
diff --git a/dubbo-simple/dubbo-monitor-simple/pom.xml b/dubbo-simple/dubbo-monitor-simple/pom.xml
index 164f387d2e..9077dd26a7 100644
--- a/dubbo-simple/dubbo-monitor-simple/pom.xml
+++ b/dubbo-simple/dubbo-monitor-simple/pom.xml
@@ -1,181 +1,181 @@
-<!--
-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.
--->
-<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>com.alibaba</groupId>
- <artifactId>dubbo-simple</artifactId>
- <version>2.5.10</version>
- </parent>
- <artifactId>dubbo-monitor-simple</artifactId>
- <packaging>jar</packaging>
- <name>${project.artifactId}</name>
- <description>The simple monitor module of dubbo project</description>
- <properties>
- <skip_maven_deploy>false</skip_maven_deploy>
- </properties>
- <dependencies>
- <dependency>
- <groupId>com.alibaba</groupId>
- <artifactId>dubbo</artifactId>
- <version>${project.parent.version}</version>
- </dependency>
- <dependency>
- <groupId>jfree</groupId>
- <artifactId>jfreechart</artifactId>
- </dependency>
- <dependency>
- <groupId>org.javassist</groupId>
- <artifactId>javassist</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.netty</groupId>
- <artifactId>netty</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.mina</groupId>
- <artifactId>mina-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.glassfish.grizzly</groupId>
- <artifactId>grizzly-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpclient</artifactId>
- </dependency>
- <dependency>
- <groupId>com.alibaba</groupId>
- <artifactId>fastjson</artifactId>
- </dependency>
- <dependency>
- <groupId>com.thoughtworks.xstream</groupId>
- <artifactId>xstream</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.bsf</groupId>
- <artifactId>bsf-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.zookeeper</groupId>
- <artifactId>zookeeper</artifactId>
- </dependency>
- <dependency>
- <groupId>com.101tec</groupId>
- <artifactId>zkclient</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.curator</groupId>
- <artifactId>curator-framework</artifactId>
- </dependency>
- <dependency>
- <groupId>com.googlecode.xmemcached</groupId>
- <artifactId>xmemcached</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-frontend-simple</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-transports-http</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.thrift</groupId>
- <artifactId>libthrift</artifactId>
- </dependency>
- <dependency>
- <groupId>com.caucho</groupId>
- <artifactId>hessian</artifactId>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>jetty</artifactId>
- </dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>redis.clients</groupId>
- <artifactId>jedis</artifactId>
- </dependency>
- <dependency>
- <groupId>javax.validation</groupId>
- <artifactId>validation-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-validator</artifactId>
- </dependency>
- <dependency>
- <groupId>javax.cache</groupId>
- <artifactId>cache-api</artifactId>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>unpack</id>
- <phase>package</phase>
- <goals>
- <goal>unpack</goal>
- </goals>
- <configuration>
- <artifactItems>
- <artifactItem>
- <groupId>com.alibaba</groupId>
- <artifactId>dubbo</artifactId>
- <version>${project.parent.version}</version>
- <outputDirectory>${project.build.directory}/dubbo</outputDirectory>
- <includes>META-INF/assembly/**</includes>
- </artifactItem>
- </artifactItems>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <configuration>
- <descriptor>src/main/assembly/assembly.xml</descriptor>
- </configuration>
- <executions>
- <execution>
- <id>make-assembly</id>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
+<!--
+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.
+-->
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>com.alibaba</groupId>
+ <artifactId>dubbo-simple</artifactId>
+ <version>2.5.11</version>
+ </parent>
+ <artifactId>dubbo-monitor-simple</artifactId>
+ <packaging>jar</packaging>
+ <name>${project.artifactId}</name>
+ <description>The simple monitor module of dubbo project</description>
+ <properties>
+ <skip_maven_deploy>false</skip_maven_deploy>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>com.alibaba</groupId>
+ <artifactId>dubbo</artifactId>
+ <version>${project.parent.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>jfree</groupId>
+ <artifactId>jfreechart</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.javassist</groupId>
+ <artifactId>javassist</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.netty</groupId>
+ <artifactId>netty</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.mina</groupId>
+ <artifactId>mina-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish.grizzly</groupId>
+ <artifactId>grizzly-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.alibaba</groupId>
+ <artifactId>fastjson</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.thoughtworks.xstream</groupId>
+ <artifactId>xstream</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.bsf</groupId>
+ <artifactId>bsf-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.zookeeper</groupId>
+ <artifactId>zookeeper</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.101tec</groupId>
+ <artifactId>zkclient</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.curator</groupId>
+ <artifactId>curator-framework</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.googlecode.xmemcached</groupId>
+ <artifactId>xmemcached</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-frontend-simple</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-transports-http</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.thrift</groupId>
+ <artifactId>libthrift</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.caucho</groupId>
+ <artifactId>hessian</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>redis.clients</groupId>
+ <artifactId>jedis</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.validation</groupId>
+ <artifactId>validation-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-validator</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.cache</groupId>
+ <artifactId>cache-api</artifactId>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>unpack</id>
+ <phase>package</phase>
+ <goals>
+ <goal>unpack</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>com.alibaba</groupId>
+ <artifactId>dubbo</artifactId>
+ <version>${project.parent.version}</version>
+ <outputDirectory>${project.build.directory}/dubbo</outputDirectory>
+ <includes>META-INF/assembly/**</includes>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <descriptor>src/main/assembly/assembly.xml</descriptor>
+ </configuration>
+ <executions>
+ <execution>
+ <id>make-assembly</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
</project>
\ No newline at end of file
diff --git a/dubbo-simple/dubbo-monitor-simple/src/main/assembly/assembly.xml b/dubbo-simple/dubbo-monitor-simple/src/main/assembly/assembly.xml
index 3942e38447..e2b58f1967 100644
--- a/dubbo-simple/dubbo-monitor-simple/src/main/assembly/assembly.xml
+++ b/dubbo-simple/dubbo-monitor-simple/src/main/assembly/assembly.xml
@@ -1,40 +1,40 @@
-<!--
-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.
--->
-<assembly>
- <id>assembly</id>
- <formats>
- <format>tar.gz</format>
- </formats>
- <includeBaseDirectory>true</includeBaseDirectory>
- <fileSets>
- <fileSet>
- <directory>${project.build.directory}/dubbo/META-INF/assembly/bin</directory>
- <outputDirectory>bin</outputDirectory>
- <fileMode>0755</fileMode>
- </fileSet>
- <fileSet>
- <directory>src/main/assembly/conf</directory>
- <outputDirectory>conf</outputDirectory>
- <fileMode>0644</fileMode>
- </fileSet>
- </fileSets>
- <dependencySets>
- <dependencySet>
- <outputDirectory>lib</outputDirectory>
- </dependencySet>
- </dependencySets>
+<!--
+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.
+-->
+<assembly>
+ <id>assembly</id>
+ <formats>
+ <format>tar.gz</format>
+ </formats>
+ <includeBaseDirectory>true</includeBaseDirectory>
+ <fileSets>
+ <fileSet>
+ <directory>${project.build.directory}/dubbo/META-INF/assembly/bin</directory>
+ <outputDirectory>bin</outputDirectory>
+ <fileMode>0755</fileMode>
+ </fileSet>
+ <fileSet>
+ <directory>src/main/assembly/conf</directory>
+ <outputDirectory>conf</outputDirectory>
+ <fileMode>0644</fileMode>
+ </fileSet>
+ </fileSets>
+ <dependencySets>
+ <dependencySet>
+ <outputDirectory>lib</outputDirectory>
+ </dependencySet>
+ </dependencySets>
</assembly>
\ No newline at end of file
diff --git a/dubbo-simple/dubbo-monitor-simple/src/main/assembly/conf/dubbo.properties b/dubbo-simple/dubbo-monitor-simple/src/main/assembly/conf/dubbo.properties
index 8c9de4ed1a..cee15aacb0 100644
--- a/dubbo-simple/dubbo-monitor-simple/src/main/assembly/conf/dubbo.properties
+++ b/dubbo-simple/dubbo-monitor-simple/src/main/assembly/conf/dubbo.properties
@@ -1,29 +1,29 @@
-# 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.
-
-dubbo.container=log4j,spring,registry,jetty
-dubbo.application.name=simple-monitor
-dubbo.application.owner=
-dubbo.registry.address=multicast://224.5.6.7:1234
-#dubbo.registry.address=zookeeper://127.0.0.1:2181
-#dubbo.registry.address=redis://127.0.0.1:6379
-#dubbo.registry.address=dubbo://127.0.0.1:9090
-dubbo.protocol.port=7070
-dubbo.jetty.port=8080
-dubbo.jetty.directory=${user.home}/monitor
-dubbo.charts.directory=${dubbo.jetty.directory}/charts
-dubbo.statistics.directory=${user.home}/monitor/statistics
-dubbo.log4j.file=logs/dubbo-monitor-simple.log
+# 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.
+
+dubbo.container=log4j,spring,registry,jetty
+dubbo.application.name=simple-monitor
+dubbo.application.owner=
+dubbo.registry.address=multicast://224.5.6.7:1234
+#dubbo.registry.address=zookeeper://127.0.0.1:2181
+#dubbo.registry.address=redis://127.0.0.1:6379
+#dubbo.registry.address=dubbo://127.0.0.1:9090
+dubbo.protocol.port=7070
+dubbo.jetty.port=8080
+dubbo.jetty.directory=${user.home}/monitor
+dubbo.charts.directory=${dubbo.jetty.directory}/charts
+dubbo.statistics.directory=${user.home}/monitor/statistics
+dubbo.log4j.file=logs/dubbo-monitor-simple.log
dubbo.log4j.level=WARN
\ No newline at end of file
diff --git a/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/CountUtils.java b/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/CountUtils.java
index de8b9d1c78..0e9e8a730c 100644
--- a/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/CountUtils.java
+++ b/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/CountUtils.java
@@ -1,92 +1,92 @@
-/*
- * 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.monitor.simple;
-
-import com.alibaba.dubbo.common.logger.Logger;
-import com.alibaba.dubbo.common.logger.LoggerFactory;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.regex.Pattern;
-
-/**
- * CountUtils
- */
-public class CountUtils {
-
- private static final Logger logger = LoggerFactory.getLogger(CountUtils.class);
-
- private static final Pattern NUMBER_PATTERN = Pattern.compile("\\d+");
-
- private static final int SUM = 0;
-
- private static final int MAX = 1;
-
- private static final int AVG = 2;
-
- public static long sum(File file) {
- return calc(file, SUM);
- }
-
- public static long max(File file) {
- return calc(file, MAX);
- }
-
- public static long avg(File file) {
- return calc(file, AVG);
- }
-
- private static long calc(File file, int op) {
- if (file.exists()) {
- try {
- BufferedReader reader = new BufferedReader(new FileReader(file));
- try {
- int times = 0;
- int count = 0;
- String line;
- while ((line = reader.readLine()) != null) {
- int i = line.indexOf(" ");
- if (i > 0) {
- line = line.substring(i + 1).trim();
- if (NUMBER_PATTERN.matcher(line).matches()) {
- int value = Integer.parseInt(line);
- times++;
- if (op == MAX) {
- count = Math.max(count, value);
- } else {
- count += value;
- }
- }
- }
- }
- if (op == AVG) {
- return count / times;
- }
- return count;
- } finally {
- reader.close();
- }
- } catch (IOException e) {
- logger.warn(e.getMessage(), e);
- }
- }
- return 0;
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.alibaba.dubbo.monitor.simple;
+
+import com.alibaba.dubbo.common.logger.Logger;
+import com.alibaba.dubbo.common.logger.LoggerFactory;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.regex.Pattern;
+
+/**
+ * CountUtils
+ */
+public class CountUtils {
+
+ private static final Logger logger = LoggerFactory.getLogger(CountUtils.class);
+
+ private static final Pattern NUMBER_PATTERN = Pattern.compile("\\d+");
+
+ private static final int SUM = 0;
+
+ private static final int MAX = 1;
+
+ private static final int AVG = 2;
+
+ public static long sum(File file) {
+ return calc(file, SUM);
+ }
+
+ public static long max(File file) {
+ return calc(file, MAX);
+ }
+
+ public static long avg(File file) {
+ return calc(file, AVG);
+ }
+
+ private static long calc(File file, int op) {
+ if (file.exists()) {
+ try {
+ BufferedReader reader = new BufferedReader(new FileReader(file));
+ try {
+ int times = 0;
+ int count = 0;
+ String line;
+ while ((line = reader.readLine()) != null) {
+ int i = line.indexOf(" ");
+ if (i > 0) {
+ line = line.substring(i + 1).trim();
+ if (NUMBER_PATTERN.matcher(line).matches()) {
+ int value = Integer.parseInt(line);
+ times++;
+ if (op == MAX) {
+ count = Math.max(count, value);
+ } else {
+ count += value;
+ }
+ }
+ }
+ }
+ if (op == AVG) {
+ return count / times;
+ }
+ return count;
+ } finally {
+ reader.close();
+ }
+ } catch (IOException e) {
+ logger.warn(e.getMessage(), e);
+ }
+ }
+ return 0;
+ }
+
+}
diff --git a/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/RegistryContainer.java b/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/RegistryContainer.java
index 8d6843f754..1b5803e84e 100644
--- a/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/RegistryContainer.java
+++ b/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/RegistryContainer.java
@@ -1,293 +1,293 @@
-/*
- * 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.monitor.simple;
-
-import com.alibaba.dubbo.common.Constants;
-import com.alibaba.dubbo.common.URL;
-import com.alibaba.dubbo.common.extension.ExtensionLoader;
-import com.alibaba.dubbo.common.utils.ConcurrentHashSet;
-import com.alibaba.dubbo.common.utils.ConfigUtils;
-import com.alibaba.dubbo.common.utils.NetUtils;
-import com.alibaba.dubbo.container.Container;
-import com.alibaba.dubbo.container.spring.SpringContainer;
-import com.alibaba.dubbo.registry.NotifyListener;
-import com.alibaba.dubbo.registry.RegistryService;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * RegistryContainer
- */
-public class RegistryContainer implements Container {
-
- public static final String REGISTRY_ADDRESS = "dubbo.registry.address";
- private static RegistryContainer INSTANCE = null;
- private final Set<String> applications = new ConcurrentHashSet<String>();
- private final Map<String, Set<String>> providerServiceApplications = new ConcurrentHashMap<String, Set<String>>();
- private final Map<String, Set<String>> providerApplicationServices = new ConcurrentHashMap<String, Set<String>>();
- private final Map<String, Set<String>> consumerServiceApplications = new ConcurrentHashMap<String, Set<String>>();
- private final Map<String, Set<String>> consumerApplicationServices = new ConcurrentHashMap<String, Set<String>>();
- private final Set<String> services = new ConcurrentHashSet<String>();
- private final Map<String, List<URL>> serviceProviders = new ConcurrentHashMap<String, List<URL>>();
- private final Map<String, List<URL>> serviceConsumers = new ConcurrentHashMap<String, List<URL>>();
- private RegistryService registry;
-
- public RegistryContainer() {
- INSTANCE = this;
- }
-
- public static RegistryContainer getInstance() {
- if (INSTANCE == null) {
- ExtensionLoader.getExtensionLoader(Container.class).getExtension("registry");
- }
- return INSTANCE;
- }
-
- public RegistryService getRegistry() {
- return registry;
- }
-
- public Set<String> getApplications() {
- return Collections.unmodifiableSet(applications);
- }
-
- public Set<String> getDependencies(String application, boolean reverse) {
- if (reverse) {
- Set<String> dependencies = new HashSet<String>();
- Set<String> services = providerApplicationServices.get(application);
- if (services != null && services.size() > 0) {
- for (String service : services) {
- Set<String> applications = consumerServiceApplications.get(service);
- if (applications != null && applications.size() > 0) {
- dependencies.addAll(applications);
- }
- }
- }
- return dependencies;
- } else {
- Set<String> dependencies = new HashSet<String>();
- Set<String> services = consumerApplicationServices.get(application);
- if (services != null && services.size() > 0) {
- for (String service : services) {
- Set<String> applications = providerServiceApplications.get(service);
- if (applications != null && applications.size() > 0) {
- dependencies.addAll(applications);
- }
- }
- }
- return dependencies;
- }
- }
-
- public Set<String> getServices() {
- return Collections.unmodifiableSet(services);
- }
-
- public Map<String, List<URL>> getServiceProviders() {
- return Collections.unmodifiableMap(serviceProviders);
- }
-
- public List<URL> getProvidersByService(String service) {
- List<URL> urls = serviceProviders.get(service);
- return urls == null ? null : Collections.unmodifiableList(urls);
- }
-
- public List<URL> getProvidersByHost(String host) {
- List<URL> urls = new ArrayList<URL>();
- if (host != null && host.length() > 0) {
- for (List<URL> providers : serviceProviders.values()) {
- for (URL url : providers) {
- if (host.equals(url.getHost())) {
- urls.add(url);
- }
- }
- }
- }
- return urls;
- }
-
- public List<URL> getProvidersByApplication(String application) {
- List<URL> urls = new ArrayList<URL>();
- if (application != null && application.length() > 0) {
- for (List<URL> providers : serviceProviders.values()) {
- for (URL url : providers) {
- if (application.equals(url.getParameter(Constants.APPLICATION_KEY))) {
- urls.add(url);
- }
- }
- }
- }
- return urls;
- }
-
- public Set<String> getHosts() {
- Set<String> addresses = new HashSet<String>();
- for (List<URL> providers : serviceProviders.values()) {
- for (URL url : providers) {
- addresses.add(url.getHost());
- }
- }
- for (List<URL> providers : serviceConsumers.values()) {
- for (URL url : providers) {
- addresses.add(url.getHost());
- }
- }
- return addresses;
- }
-
- public Map<String, List<URL>> getServiceConsumers() {
- return Collections.unmodifiableMap(serviceConsumers);
- }
-
- public List<URL> getConsumersByService(String service) {
- List<URL> urls = serviceConsumers.get(service);
- return urls == null ? null : Collections.unmodifiableList(urls);
- }
-
- public List<URL> getConsumersByHost(String host) {
- List<URL> urls = new ArrayList<URL>();
- if (host != null && host.length() > 0) {
- for (List<URL> consumers : serviceConsumers.values()) {
- for (URL url : consumers) {
- if (host.equals(url.getHost())) {
- urls.add(url);
- }
- }
- }
- }
- return Collections.unmodifiableList(urls);
- }
-
- public List<URL> getConsumersByApplication(String application) {
- List<URL> urls = new ArrayList<URL>();
- if (application != null && application.length() > 0) {
- for (List<URL> consumers : serviceConsumers.values()) {
- for (URL url : consumers) {
- if (application.equals(url.getParameter(Constants.APPLICATION_KEY))) {
- urls.add(url);
- }
- }
- }
- }
- return urls;
- }
-
- public void start() {
- String url = ConfigUtils.getProperty(REGISTRY_ADDRESS);
- if (url == null || url.length() == 0) {
- throw new IllegalArgumentException("Please set java start argument: -D" + REGISTRY_ADDRESS + "=zookeeper://127.0.0.1:2181");
- }
- registry = (RegistryService) SpringContainer.getContext().getBean("registryService");
- URL subscribeUrl = new URL(Constants.ADMIN_PROTOCOL, NetUtils.getLocalHost(), 0, "",
- Constants.INTERFACE_KEY, Constants.ANY_VALUE,
- Constants.GROUP_KEY, Constants.ANY_VALUE,
- Constants.VERSION_KEY, Constants.ANY_VALUE,
- Constants.CLASSIFIER_KEY, Constants.ANY_VALUE,
- Constants.CATEGORY_KEY, Constants.PROVIDERS_CATEGORY + ","
- + Constants.CONSUMERS_CATEGORY,
- Constants.CHECK_KEY, String.valueOf(false));
- registry.subscribe(subscribeUrl, new NotifyListener() {
- public void notify(List<URL> urls) {
- if (urls == null || urls.size() == 0) {
- return;
- }
- Map<String, List<URL>> proivderMap = new HashMap<String, List<URL>>();
- Map<String, List<URL>> consumerMap = new HashMap<String, List<URL>>();
- for (URL url : urls) {
- String application = url.getParameter(Constants.APPLICATION_KEY);
- if (application != null && application.length() > 0) {
- applications.add(application);
- }
- String service = url.getServiceInterface();
- services.add(service);
- String category = url.getParameter(Constants.CATEGORY_KEY, Constants.DEFAULT_CATEGORY);
- if (Constants.PROVIDERS_CATEGORY.equals(category)) {
- if (Constants.EMPTY_PROTOCOL.equals(url.getProtocol())) {
- serviceProviders.remove(service);
- } else {
- List<URL> list = proivderMap.get(service);
- if (list == null) {
- list = new ArrayList<URL>();
- proivderMap.put(service, list);
- }
- list.add(url);
- if (application != null && application.length() > 0) {
- Set<String> serviceApplications = providerServiceApplications.get(service);
- if (serviceApplications == null) {
- providerServiceApplications.put(service, new ConcurrentHashSet<String>());
- serviceApplications = providerServiceApplications.get(service);
- }
- serviceApplications.add(application);
-
- Set<String> applicationServices = providerApplicationServices.get(application);
- if (applicationServices == null) {
- providerApplicationServices.put(application, new ConcurrentHashSet<String>());
- applicationServices = providerApplicationServices.get(application);
- }
- applicationServices.add(service);
- }
- }
- } else if (Constants.CONSUMERS_CATEGORY.equals(category)) {
- if (Constants.EMPTY_PROTOCOL.equals(url.getProtocol())) {
- serviceConsumers.remove(service);
- } else {
- List<URL> list = consumerMap.get(service);
- if (list == null) {
- list = new ArrayList<URL>();
- consumerMap.put(service, list);
- }
- list.add(url);
- if (application != null && application.length() > 0) {
- Set<String> serviceApplications = consumerServiceApplications.get(service);
- if (serviceApplications == null) {
- consumerServiceApplications.put(service, new ConcurrentHashSet<String>());
- serviceApplications = consumerServiceApplications.get(service);
- }
- serviceApplications.add(application);
-
- Set<String> applicationServices = consumerApplicationServices.get(application);
- if (applicationServices == null) {
- consumerApplicationServices.put(application, new ConcurrentHashSet<String>());
- applicationServices = consumerApplicationServices.get(application);
- }
- applicationServices.add(service);
- }
-
- }
- }
- }
- if (proivderMap != null && proivderMap.size() > 0) {
- serviceProviders.putAll(proivderMap);
- }
- if (consumerMap != null && consumerMap.size() > 0) {
- serviceConsumers.putAll(consumerMap);
- }
- }
- });
- }
-
- public void stop() {
- }
-
+/*
+ * 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.monitor.simple;
+
+import com.alibaba.dubbo.common.Constants;
+import com.alibaba.dubbo.common.URL;
+import com.alibaba.dubbo.common.extension.ExtensionLoader;
+import com.alibaba.dubbo.common.utils.ConcurrentHashSet;
+import com.alibaba.dubbo.common.utils.ConfigUtils;
+import com.alibaba.dubbo.common.utils.NetUtils;
+import com.alibaba.dubbo.container.Container;
+import com.alibaba.dubbo.container.spring.SpringContainer;
+import com.alibaba.dubbo.registry.NotifyListener;
+import com.alibaba.dubbo.registry.RegistryService;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * RegistryContainer
+ */
+public class RegistryContainer implements Container {
+
+ public static final String REGISTRY_ADDRESS = "dubbo.registry.address";
+ private static RegistryContainer INSTANCE = null;
+ private final Set<String> applications = new ConcurrentHashSet<String>();
+ private final Map<String, Set<String>> providerServiceApplications = new ConcurrentHashMap<String, Set<String>>();
+ private final Map<String, Set<String>> providerApplicationServices = new ConcurrentHashMap<String, Set<String>>();
+ private final Map<String, Set<String>> consumerServiceApplications = new ConcurrentHashMap<String, Set<String>>();
+ private final Map<String, Set<String>> consumerApplicationServices = new ConcurrentHashMap<String, Set<String>>();
+ private final Set<String> services = new ConcurrentHashSet<String>();
+ private final Map<String, List<URL>> serviceProviders = new ConcurrentHashMap<String, List<URL>>();
+ private final Map<String, List<URL>> serviceConsumers = new ConcurrentHashMap<String, List<URL>>();
+ private RegistryService registry;
+
+ public RegistryContainer() {
+ INSTANCE = this;
+ }
+
+ public static RegistryContainer getInstance() {
+ if (INSTANCE == null) {
+ ExtensionLoader.getExtensionLoader(Container.class).getExtension("registry");
+ }
+ return INSTANCE;
+ }
+
+ public RegistryService getRegistry() {
+ return registry;
+ }
+
+ public Set<String> getApplications() {
+ return Collections.unmodifiableSet(applications);
+ }
+
+ public Set<String> getDependencies(String application, boolean reverse) {
+ if (reverse) {
+ Set<String> dependencies = new HashSet<String>();
+ Set<String> services = providerApplicationServices.get(application);
+ if (services != null && services.size() > 0) {
+ for (String service : services) {
+ Set<String> applications = consumerServiceApplications.get(service);
+ if (applications != null && applications.size() > 0) {
+ dependencies.addAll(applications);
+ }
+ }
+ }
+ return dependencies;
+ } else {
+ Set<String> dependencies = new HashSet<String>();
+ Set<String> services = consumerApplicationServices.get(application);
+ if (services != null && services.size() > 0) {
+ for (String service : services) {
+ Set<String> applications = providerServiceApplications.get(service);
+ if (applications != null && applications.size() > 0) {
+ dependencies.addAll(applications);
+ }
+ }
+ }
+ return dependencies;
+ }
+ }
+
+ public Set<String> getServices() {
+ return Collections.unmodifiableSet(services);
+ }
+
+ public Map<String, List<URL>> getServiceProviders() {
+ return Collections.unmodifiableMap(serviceProviders);
+ }
+
+ public List<URL> getProvidersByService(String service) {
+ List<URL> urls = serviceProviders.get(service);
+ return urls == null ? null : Collections.unmodifiableList(urls);
+ }
+
+ public List<URL> getProvidersByHost(String host) {
+ List<URL> urls = new ArrayList<URL>();
+ if (host != null && host.length() > 0) {
+ for (List<URL> providers : serviceProviders.values()) {
+ for (URL url : providers) {
+ if (host.equals(url.getHost())) {
+ urls.add(url);
+ }
+ }
+ }
+ }
+ return urls;
+ }
+
+ public List<URL> getProvidersByApplication(String application) {
+ List<URL> urls = new ArrayList<URL>();
+ if (application != null && application.length() > 0) {
+ for (List<URL> providers : serviceProviders.values()) {
+ for (URL url : providers) {
+ if (application.equals(url.getParameter(Constants.APPLICATION_KEY))) {
+ urls.add(url);
+ }
+ }
+ }
+ }
+ return urls;
+ }
+
+ public Set<String> getHosts() {
+ Set<String> addresses = new HashSet<String>();
+ for (List<URL> providers : serviceProviders.values()) {
+ for (URL url : providers) {
+ addresses.add(url.getHost());
+ }
+ }
+ for (List<URL> providers : serviceConsumers.values()) {
+ for (URL url : providers) {
+ addresses.add(url.getHost());
+ }
+ }
+ return addresses;
+ }
+
+ public Map<String, List<URL>> getServiceConsumers() {
+ return Collections.unmodifiableMap(serviceConsumers);
+ }
+
+ public List<URL> getConsumersByService(String service) {
+ List<URL> urls = serviceConsumers.get(service);
+ return urls == null ? null : Collections.unmodifiableList(urls);
+ }
+
+ public List<URL> getConsumersByHost(String host) {
+ List<URL> urls = new ArrayList<URL>();
+ if (host != null && host.length() > 0) {
+ for (List<URL> consumers : serviceConsumers.values()) {
+ for (URL url : consumers) {
+ if (host.equals(url.getHost())) {
+ urls.add(url);
+ }
+ }
+ }
+ }
+ return Collections.unmodifiableList(urls);
+ }
+
+ public List<URL> getConsumersByApplication(String application) {
+ List<URL> urls = new ArrayList<URL>();
+ if (application != null && application.length() > 0) {
+ for (List<URL> consumers : serviceConsumers.values()) {
+ for (URL url : consumers) {
+ if (application.equals(url.getParameter(Constants.APPLICATION_KEY))) {
+ urls.add(url);
+ }
+ }
+ }
+ }
+ return urls;
+ }
+
+ public void start() {
+ String url = ConfigUtils.getProperty(REGISTRY_ADDRESS);
+ if (url == null || url.length() == 0) {
+ throw new IllegalArgumentException("Please set java start argument: -D" + REGISTRY_ADDRESS + "=zookeeper://127.0.0.1:2181");
+ }
+ registry = (RegistryService) SpringContainer.getContext().getBean("registryService");
+ URL subscribeUrl = new URL(Constants.ADMIN_PROTOCOL, NetUtils.getLocalHost(), 0, "",
+ Constants.INTERFACE_KEY, Constants.ANY_VALUE,
+ Constants.GROUP_KEY, Constants.ANY_VALUE,
+ Constants.VERSION_KEY, Constants.ANY_VALUE,
+ Constants.CLASSIFIER_KEY, Constants.ANY_VALUE,
+ Constants.CATEGORY_KEY, Constants.PROVIDERS_CATEGORY + ","
+ + Constants.CONSUMERS_CATEGORY,
+ Constants.CHECK_KEY, String.valueOf(false));
+ registry.subscribe(subscribeUrl, new NotifyListener() {
+ public void notify(List<URL> urls) {
+ if (urls == null || urls.size() == 0) {
+ return;
+ }
+ Map<String, List<URL>> proivderMap = new HashMap<String, List<URL>>();
+ Map<String, List<URL>> consumerMap = new HashMap<String, List<URL>>();
+ for (URL url : urls) {
+ String application = url.getParameter(Constants.APPLICATION_KEY);
+ if (application != null && application.length() > 0) {
+ applications.add(application);
+ }
+ String service = url.getServiceInterface();
+ services.add(service);
+ String category = url.getParameter(Constants.CATEGORY_KEY, Constants.DEFAULT_CATEGORY);
+ if (Constants.PROVIDERS_CATEGORY.equals(category)) {
+ if (Constants.EMPTY_PROTOCOL.equals(url.getProtocol())) {
+ serviceProviders.remove(service);
+ } else {
+ List<URL> list = proivderMap.get(service);
+ if (list == null) {
+ list = new ArrayList<URL>();
+ proivderMap.put(service, list);
+ }
+ list.add(url);
+ if (application != null && application.length() > 0) {
+ Set<String> serviceApplications = providerServiceApplications.get(service);
+ if (serviceApplications == null) {
+ providerServiceApplications.put(service, new ConcurrentHashSet<String>());
+ serviceApplications = providerServiceApplications.get(service);
+ }
+ serviceApplications.add(application);
+
+ Set<String> applicationServices = providerApplicationServices.get(application);
+ if (applicationServices == null) {
+ providerApplicationServices.put(application, new ConcurrentHashSet<String>());
+ applicationServices = providerApplicationServices.get(application);
+ }
+ applicationServices.add(service);
+ }
+ }
+ } else if (Constants.CONSUMERS_CATEGORY.equals(category)) {
+ if (Constants.EMPTY_PROTOCOL.equals(url.getProtocol())) {
+ serviceConsumers.remove(service);
+ } else {
+ List<URL> list = consumerMap.get(service);
+ if (list == null) {
+ list = new ArrayList<URL>();
+ consumerMap.put(service, list);
+ }
+ list.add(url);
+ if (application != null && application.length() > 0) {
+ Set<String> serviceApplications = consumerServiceApplications.get(service);
+ if (serviceApplications == null) {
+ consumerServiceApplications.put(service, new ConcurrentHashSet<String>());
+ serviceApplications = consumerServiceApplications.get(service);
+ }
+ serviceApplications.add(application);
+
+ Set<String> applicationServices = consumerApplicationServices.get(application);
+ if (applicationServices == null) {
+ consumerApplicationServices.put(application, new ConcurrentHashSet<String>());
+ applicationServices = consumerApplicationServices.get(application);
+ }
+ applicationServices.add(service);
+ }
+
+ }
+ }
+ }
+ if (proivderMap != null && proivderMap.size() > 0) {
+ serviceProviders.putAll(proivderMap);
+ }
+ if (consumerMap != null && consumerMap.size() > 0) {
+ serviceConsumers.putAll(consumerMap);
+ }
+ }
+ });
+ }
+
+ public void stop() {
+ }
+
}
\ No newline at end of file
diff --git a/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/SimpleMonitorService.java b/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/SimpleMonitorService.java
index abd8e3c1c1..900dd1ea38 100644
--- a/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/SimpleMonitorService.java
+++ b/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/SimpleMonitorService.java
@@ -1,399 +1,399 @@
-/*
- * 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.monitor.simple;
-
-import com.alibaba.dubbo.common.Constants;
-import com.alibaba.dubbo.common.URL;
-import com.alibaba.dubbo.common.logger.Logger;
-import com.alibaba.dubbo.common.logger.LoggerFactory;
-import com.alibaba.dubbo.common.utils.ConfigUtils;
-import com.alibaba.dubbo.common.utils.NamedThreadFactory;
-import com.alibaba.dubbo.common.utils.NetUtils;
-import com.alibaba.dubbo.monitor.MonitorService;
-
-import org.jfree.chart.ChartFactory;
-import org.jfree.chart.JFreeChart;
-import org.jfree.chart.axis.DateAxis;
-import org.jfree.chart.plot.XYPlot;
-import org.jfree.data.time.Minute;
-import org.jfree.data.time.TimeSeries;
-import org.jfree.data.time.TimeSeriesCollection;
-
-import javax.imageio.ImageIO;
-import java.awt.*;
-import java.awt.image.BufferedImage;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.text.DecimalFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.Executors;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.ScheduledFuture;
-import java.util.concurrent.TimeUnit;
-
-/**
- * SimpleMonitorService
- */
-public class SimpleMonitorService implements MonitorService {
-
- private static final Logger logger = LoggerFactory.getLogger(SimpleMonitorService.class);
-
- private static final String[] types = {SUCCESS, FAILURE, ELAPSED, CONCURRENT, MAX_ELAPSED, MAX_CONCURRENT};
-
- private static final String POISON_PROTOCOL = "poison";
- private final ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(1, new NamedThreadFactory("DubboMonitorTimer", true));
- private final ScheduledFuture<?> chartFuture;
- private final Thread writeThread;
- private final BlockingQueue<URL> queue;
- private String statisticsDirectory = "statistics";
- private String chartsDirectory = "charts";
- private volatile boolean running = true;
-
- public SimpleMonitorService() {
- queue = new LinkedBlockingQueue<URL>(Integer.parseInt(ConfigUtils.getProperty("dubbo.monitor.queue", "100000")));
- writeThread = new Thread(new Runnable() {
- public void run() {
- while (running) {
- try {
- write(); // write statistics
- } catch (Throwable t) {
- logger.error("Unexpected error occur at write stat log, cause: " + t.getMessage(), t);
- try {
- Thread.sleep(5000); // retry after 5 secs
- } catch (Throwable t2) {
- }
- }
- }
- }
- });
- writeThread.setDaemon(true);
- writeThread.setName("DubboMonitorAsyncWriteLogThread");
- writeThread.start();
- chartFuture = scheduledExecutorService.scheduleWithFixedDelay(new Runnable() {
- public void run() {
- try {
- draw(); // draw chart
- } catch (Throwable t) {
- logger.error("Unexpected error occur at draw stat chart, cause: " + t.getMessage(), t);
- }
- }
- }, 1, 300, TimeUnit.SECONDS);
- statisticsDirectory = ConfigUtils.getProperty("dubbo.statistics.directory");
- chartsDirectory = ConfigUtils.getProperty("dubbo.charts.directory");
- }
-
- private static void createChart(String key, String service, String method, String date, String[] types, Map<String, long[]> data, double[] summary, String path) {
- SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmm");
- DecimalFormat numberFormat = new DecimalFormat("###,##0.##");
- TimeSeriesCollection xydataset = new TimeSeriesCollection();
- for (int i = 0; i < types.length; i++) {
- String type = types[i];
- TimeSeries timeseries = new TimeSeries(type);
- for (Map.Entry<String, long[]> entry : data.entrySet()) {
- try {
- timeseries.add(new Minute(dateFormat.parse(date + entry.getKey())), entry.getValue()[i]);
- } catch (ParseException e) {
- logger.error(e.getMessage(), e);
- }
- }
- xydataset.addSeries(timeseries);
- }
- JFreeChart jfreechart = ChartFactory.createTimeSeriesChart(
- "max: " + numberFormat.format(summary[0]) + (summary[1] >= 0 ? " min: " + numberFormat.format(summary[1]) : "")
- + " avg: " + numberFormat.format(summary[2]) + (summary[3] >= 0 ? " sum: " + numberFormat.format(summary[3]) : ""),
- toDisplayService(service) + " " + method + " " + toDisplayDate(date), key, xydataset, true, true, false);
- jfreechart.setBackgroundPaint(Color.WHITE);
- XYPlot xyplot = (XYPlot) jfreechart.getPlot();
- xyplot.setBackgroundPaint(Color.WHITE);
- xyplot.setDomainGridlinePaint(Color.GRAY);
- xyplot.setRangeGridlinePaint(Color.GRAY);
- xyplot.setDomainGridlinesVisible(true);
- xyplot.setRangeGridlinesVisible(true);
- DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
- dateaxis.setDateFormatOverride(new SimpleDateFormat("HH:mm"));
- BufferedImage image = jfreechart.createBufferedImage(600, 300);
- try {
- if (logger.isInfoEnabled()) {
- logger.info("write chart: " + path);
- }
- File methodChartFile = new File(path);
- File methodChartDir = methodChartFile.getParentFile();
- if (methodChartDir != null && !methodChartDir.exists()) {
- methodChartDir.mkdirs();
- }
- FileOutputStream output = new FileOutputStream(methodChartFile);
- try {
- ImageIO.write(image, "png", output);
- output.flush();
- } finally {
- output.close();
- }
- } catch (IOException e) {
- logger.warn(e.getMessage(), e);
- }
- }
-
- private static String toDisplayService(String service) {
- int i = service.lastIndexOf('.');
- if (i >= 0) {
- return service.substring(i + 1);
- }
- return service;
- }
-
- private static String toDisplayDate(String date) {
- try {
- return new SimpleDateFormat("yyyy-MM-dd").format(new SimpleDateFormat("yyyyMMdd").parse(date));
- } catch (ParseException e) {
- return date;
- }
- }
-
- public void close() {
- try {
- running = false;
- queue.offer(new URL(POISON_PROTOCOL, NetUtils.LOCALHOST, 0));
- } catch (Throwable t) {
- logger.warn(t.getMessage(), t);
- }
- try {
- chartFuture.cancel(true);
- } catch (Throwable t) {
- logger.warn(t.getMessage(), t);
- }
- }
-
- private void write() throws Exception {
- URL statistics = queue.take();
- if (POISON_PROTOCOL.equals(statistics.getProtocol())) {
- return;
- }
- String timestamp = statistics.getParameter(Constants.TIMESTAMP_KEY);
- Date now;
- if (timestamp == null || timestamp.length() == 0) {
- now = new Date();
- } else if (timestamp.length() == "yyyyMMddHHmmss".length()) {
- now = new SimpleDateFormat("yyyyMMddHHmmss").parse(timestamp);
- } else {
- now = new Date(Long.parseLong(timestamp));
- }
- String day = new SimpleDateFormat("yyyyMMdd").format(now);
- SimpleDateFormat format = new SimpleDateFormat("HHmm");
- for (String key : types) {
- try {
- String type;
- String consumer;
- String provider;
- if (statistics.hasParameter(PROVIDER)) {
- type = CONSUMER;
- consumer = statistics.getHost();
- provider = statistics.getParameter(PROVIDER);
- int i = provider.indexOf(':');
- if (i > 0) {
- provider = provider.substring(0, i);
- }
- } else {
- type = PROVIDER;
- consumer = statistics.getParameter(CONSUMER);
- int i = consumer == null ? -1 : consumer.indexOf(':');
- if (i > 0) {
- consumer = consumer.substring(0, i);
- }
- provider = statistics.getHost();
- }
- String filename = statisticsDirectory
- + "/" + day
- + "/" + statistics.getServiceInterface()
- + "/" + statistics.getParameter(METHOD)
- + "/" + consumer
- + "/" + provider
- + "/" + type + "." + key;
- File file = new File(filename);
- File dir = file.getParentFile();
- if (dir != null && !dir.exists()) {
- dir.mkdirs();
- }
- FileWriter writer = new FileWriter(file, true);
- try {
- writer.write(format.format(now) + " " + statistics.getParameter(key, 0) + "\n");
- writer.flush();
- } finally {
- writer.close();
- }
- } catch (Throwable t) {
- logger.error(t.getMessage(), t);
- }
- }
- }
-
- private void draw() {
- File rootDir = new File(statisticsDirectory);
- if (!rootDir.exists()) {
- return;
- }
- File[] dateDirs = rootDir.listFiles();
- for (File dateDir : dateDirs) {
- File[] serviceDirs = dateDir.listFiles();
- for (File serviceDir : serviceDirs) {
- File[] methodDirs = serviceDir.listFiles();
- for (File methodDir : methodDirs) {
- String methodUri = chartsDirectory + "/" + dateDir.getName() + "/" + serviceDir.getName() + "/" + methodDir.getName();
-
- File successFile = new File(methodUri + "/" + SUCCESS + ".png");
- long successModified = successFile.lastModified();
- boolean successChanged = false;
- Map<String, long[]> successData = new HashMap<String, long[]>();
- double[] successSummary = new double[4];
-
- File elapsedFile = new File(methodUri + "/" + ELAPSED + ".png");
- long elapsedModified = elapsedFile.lastModified();
- boolean elapsedChanged = false;
- Map<String, long[]> elapsedData = new HashMap<String, long[]>();
- double[] elapsedSummary = new double[4];
- long elapsedMax = 0;
-
- File[] consumerDirs = methodDir.listFiles();
- for (File consumerDir : consumerDirs) {
- File[] providerDirs = consumerDir.listFiles();
- for (File providerDir : providerDirs) {
- File consumerSuccessFile = new File(providerDir, CONSUMER + "." + SUCCESS);
- File providerSuccessFile = new File(providerDir, PROVIDER + "." + SUCCESS);
- appendData(new File[]{consumerSuccessFile, providerSuccessFile}, successData, successSummary);
- if (consumerSuccessFile.lastModified() > successModified
- || providerSuccessFile.lastModified() > successModified) {
- successChanged = true;
- }
-
- File consumerElapsedFile = new File(providerDir, CONSUMER + "." + ELAPSED);
- File providerElapsedFile = new File(providerDir, PROVIDER + "." + ELAPSED);
- appendData(new File[]{consumerElapsedFile, providerElapsedFile}, elapsedData, elapsedSummary);
- elapsedMax = Math.max(elapsedMax, CountUtils.max(new File(providerDir, CONSUMER + "." + MAX_ELAPSED)));
- elapsedMax = Math.max(elapsedMax, CountUtils.max(new File(providerDir, PROVIDER + "." + MAX_ELAPSED)));
- if (consumerElapsedFile.lastModified() > elapsedModified
- || providerElapsedFile.lastModified() > elapsedModified) {
- elapsedChanged = true;
- }
- }
- }
- if (elapsedChanged) {
- divData(elapsedData, successData);
- elapsedSummary[0] = elapsedMax;
- elapsedSummary[1] = -1;
- elapsedSummary[2] = successSummary[3] == 0 ? 0 : elapsedSummary[3] / successSummary[3];
- elapsedSummary[3] = -1;
- createChart("ms/t", serviceDir.getName(), methodDir.getName(), dateDir.getName(), new String[]{CONSUMER, PROVIDER}, elapsedData, elapsedSummary, elapsedFile.getAbsolutePath());
- }
- if (successChanged) {
- divData(successData, 60);
- successSummary[0] = successSummary[0] / 60;
- successSummary[1] = successSummary[1] / 60;
- successSummary[2] = successSummary[2] / 60;
- createChart("t/s", serviceDir.getName(), methodDir.getName(), dateDir.getName(), new String[]{CONSUMER, PROVIDER}, successData, successSummary, successFile.getAbsolutePath());
- }
- }
- }
- }
- }
-
- private void divData(Map<String, long[]> successMap, long unit) {
- for (long[] success : successMap.values()) {
- for (int i = 0; i < success.length; i++) {
- success[i] = success[i] / unit;
- }
- }
- }
-
- private void divData(Map<String, long[]> elapsedMap, Map<String, long[]> successMap) {
- for (Map.Entry<String, long[]> entry : elapsedMap.entrySet()) {
- long[] elapsed = entry.getValue();
- long[] success = successMap.get(entry.getKey());
- for (int i = 0; i < elapsed.length; i++) {
- elapsed[i] = success[i] == 0 ? 0 : elapsed[i] / success[i];
- }
- }
- }
-
- private void appendData(File[] files, Map<String, long[]> data, double[] summary) {
- for (int i = 0; i < files.length; i++) {
- File file = files[i];
- if (!file.exists()) {
- continue;
- }
- try {
- BufferedReader reader = new BufferedReader(new FileReader(file));
- try {
- int sum = 0;
- int cnt = 0;
- String line;
- while ((line = reader.readLine()) != null) {
- int index = line.indexOf(" ");
- if (index > 0) {
- String key = line.substring(0, index).trim();
- long value = Long.parseLong(line.substring(index + 1).trim());
- long[] values = data.get(key);
- if (values == null) {
- values = new long[files.length];
- data.put(key, values);
- }
- values[i] += value;
- summary[0] = Math.max(summary[0], values[i]);
- summary[1] = summary[1] == 0 ? values[i] : Math.min(summary[1], values[i]);
- sum += value;
- cnt++;
- }
- }
- if (i == 0) {
- summary[3] += sum;
- summary[2] = (summary[2] + (sum / cnt)) / 2;
- }
- } finally {
- reader.close();
- }
- } catch (IOException e) {
- logger.warn(e.getMessage(), e);
- }
- }
- }
-
- public void count(URL statistics) {
- collect(statistics);
- }
-
- public void collect(URL statistics) {
- queue.offer(statistics);
- if (logger.isInfoEnabled()) {
- logger.info("collect statistics: " + statistics);
- }
- }
-
- public List<URL> lookup(URL query) {
- // TODO Auto-generated method stub
- return null;
- }
-
+/*
+ * 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.monitor.simple;
+
+import com.alibaba.dubbo.common.Constants;
+import com.alibaba.dubbo.common.URL;
+import com.alibaba.dubbo.common.logger.Logger;
+import com.alibaba.dubbo.common.logger.LoggerFactory;
+import com.alibaba.dubbo.common.utils.ConfigUtils;
+import com.alibaba.dubbo.common.utils.NamedThreadFactory;
+import com.alibaba.dubbo.common.utils.NetUtils;
+import com.alibaba.dubbo.monitor.MonitorService;
+
+import org.jfree.chart.ChartFactory;
+import org.jfree.chart.JFreeChart;
+import org.jfree.chart.axis.DateAxis;
+import org.jfree.chart.plot.XYPlot;
+import org.jfree.data.time.Minute;
+import org.jfree.data.time.TimeSeries;
+import org.jfree.data.time.TimeSeriesCollection;
+
+import javax.imageio.ImageIO;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.text.DecimalFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.Executors;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * SimpleMonitorService
+ */
+public class SimpleMonitorService implements MonitorService {
+
+ private static final Logger logger = LoggerFactory.getLogger(SimpleMonitorService.class);
+
+ private static final String[] types = {SUCCESS, FAILURE, ELAPSED, CONCURRENT, MAX_ELAPSED, MAX_CONCURRENT};
+
+ private static final String POISON_PROTOCOL = "poison";
+ private final ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(1, new NamedThreadFactory("DubboMonitorTimer", true));
+ private final ScheduledFuture<?> chartFuture;
+ private final Thread writeThread;
+ private final BlockingQueue<URL> queue;
+ private String statisticsDirectory = "statistics";
+ private String chartsDirectory = "charts";
+ private volatile boolean running = true;
+
+ public SimpleMonitorService() {
+ queue = new LinkedBlockingQueue<URL>(Integer.parseInt(ConfigUtils.getProperty("dubbo.monitor.queue", "100000")));
+ writeThread = new Thread(new Runnable() {
+ public void run() {
+ while (running) {
+ try {
+ write(); // write statistics
+ } catch (Throwable t) {
+ logger.error("Unexpected error occur at write stat log, cause: " + t.getMessage(), t);
+ try {
+ Thread.sleep(5000); // retry after 5 secs
+ } catch (Throwable t2) {
+ }
+ }
+ }
+ }
+ });
+ writeThread.setDaemon(true);
+ writeThread.setName("DubboMonitorAsyncWriteLogThread");
+ writeThread.start();
+ chartFuture = scheduledExecutorService.scheduleWithFixedDelay(new Runnable() {
+ public void run() {
+ try {
+ draw(); // draw chart
+ } catch (Throwable t) {
+ logger.error("Unexpected error occur at draw stat chart, cause: " + t.getMessage(), t);
+ }
+ }
+ }, 1, 300, TimeUnit.SECONDS);
+ statisticsDirectory = ConfigUtils.getProperty("dubbo.statistics.directory");
+ chartsDirectory = ConfigUtils.getProperty("dubbo.charts.directory");
+ }
+
+ private static void createChart(String key, String service, String method, String date, String[] types, Map<String, long[]> data, double[] summary, String path) {
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmm");
+ DecimalFormat numberFormat = new DecimalFormat("###,##0.##");
+ TimeSeriesCollection xydataset = new TimeSeriesCollection();
+ for (int i = 0; i < types.length; i++) {
+ String type = types[i];
+ TimeSeries timeseries = new TimeSeries(type);
+ for (Map.Entry<String, long[]> entry : data.entrySet()) {
+ try {
+ timeseries.add(new Minute(dateFormat.parse(date + entry.getKey())), entry.getValue()[i]);
+ } catch (ParseException e) {
+ logger.error(e.getMessage(), e);
+ }
+ }
+ xydataset.addSeries(timeseries);
+ }
+ JFreeChart jfreechart = ChartFactory.createTimeSeriesChart(
+ "max: " + numberFormat.format(summary[0]) + (summary[1] >= 0 ? " min: " + numberFormat.format(summary[1]) : "")
+ + " avg: " + numberFormat.format(summary[2]) + (summary[3] >= 0 ? " sum: " + numberFormat.format(summary[3]) : ""),
+ toDisplayService(service) + " " + method + " " + toDisplayDate(date), key, xydataset, true, true, false);
+ jfreechart.setBackgroundPaint(Color.WHITE);
+ XYPlot xyplot = (XYPlot) jfreechart.getPlot();
+ xyplot.setBackgroundPaint(Color.WHITE);
+ xyplot.setDomainGridlinePaint(Color.GRAY);
+ xyplot.setRangeGridlinePaint(Color.GRAY);
+ xyplot.setDomainGridlinesVisible(true);
+ xyplot.setRangeGridlinesVisible(true);
+ DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
+ dateaxis.setDateFormatOverride(new SimpleDateFormat("HH:mm"));
+ BufferedImage image = jfreechart.createBufferedImage(600, 300);
+ try {
+ if (logger.isInfoEnabled()) {
+ logger.info("write chart: " + path);
+ }
+ File methodChartFile = new File(path);
+ File methodChartDir = methodChartFile.getParentFile();
+ if (methodChartDir != null && !methodChartDir.exists()) {
+ methodChartDir.mkdirs();
+ }
+ FileOutputStream output = new FileOutputStream(methodChartFile);
+ try {
+ ImageIO.write(image, "png", output);
+ output.flush();
+ } finally {
+ output.close();
+ }
+ } catch (IOException e) {
+ logger.warn(e.getMessage(), e);
+ }
+ }
+
+ private static String toDisplayService(String service) {
+ int i = service.lastIndexOf('.');
+ if (i >= 0) {
+ return service.substring(i + 1);
+ }
+ return service;
+ }
+
+ private static String toDisplayDate(String date) {
+ try {
+ return new SimpleDateFormat("yyyy-MM-dd").format(new SimpleDateFormat("yyyyMMdd").parse(date));
+ } catch (ParseException e) {
+ return date;
+ }
+ }
+
+ public void close() {
+ try {
+ running = false;
+ queue.offer(new URL(POISON_PROTOCOL, NetUtils.LOCALHOST, 0));
+ } catch (Throwable t) {
+ logger.warn(t.getMessage(), t);
+ }
+ try {
+ chartFuture.cancel(true);
+ } catch (Throwable t) {
+ logger.warn(t.getMessage(), t);
+ }
+ }
+
+ private void write() throws Exception {
+ URL statistics = queue.take();
+ if (POISON_PROTOCOL.equals(statistics.getProtocol())) {
+ return;
+ }
+ String timestamp = statistics.getParameter(Constants.TIMESTAMP_KEY);
+ Date now;
+ if (timestamp == null || timestamp.length() == 0) {
+ now = new Date();
+ } else if (timestamp.length() == "yyyyMMddHHmmss".length()) {
+ now = new SimpleDateFormat("yyyyMMddHHmmss").parse(timestamp);
+ } else {
+ now = new Date(Long.parseLong(timestamp));
+ }
+ String day = new SimpleDateFormat("yyyyMMdd").format(now);
+ SimpleDateFormat format = new SimpleDateFormat("HHmm");
+ for (String key : types) {
+ try {
+ String type;
+ String consumer;
+ String provider;
+ if (statistics.hasParameter(PROVIDER)) {
+ type = CONSUMER;
+ consumer = statistics.getHost();
+ provider = statistics.getParameter(PROVIDER);
+ int i = provider.indexOf(':');
+ if (i > 0) {
+ provider = provider.substring(0, i);
+ }
+ } else {
+ type = PROVIDER;
+ consumer = statistics.getParameter(CONSUMER);
+ int i = consumer == null ? -1 : consumer.indexOf(':');
+ if (i > 0) {
+ consumer = consumer.substring(0, i);
+ }
+ provider = statistics.getHost();
+ }
+ String filename = statisticsDirectory
+ + "/" + day
+ + "/" + statistics.getServiceInterface()
+ + "/" + statistics.getParameter(METHOD)
+ + "/" + consumer
+ + "/" + provider
+ + "/" + type + "." + key;
+ File file = new File(filename);
+ File dir = file.getParentFile();
+ if (dir != null && !dir.exists()) {
+ dir.mkdirs();
+ }
+ FileWriter writer = new FileWriter(file, true);
+ try {
+ writer.write(format.format(now) + " " + statistics.getParameter(key, 0) + "\n");
+ writer.flush();
+ } finally {
+ writer.close();
+ }
+ } catch (Throwable t) {
+ logger.error(t.getMessage(), t);
+ }
+ }
+ }
+
+ private void draw() {
+ File rootDir = new File(statisticsDirectory);
+ if (!rootDir.exists()) {
+ return;
+ }
+ File[] dateDirs = rootDir.listFiles();
+ for (File dateDir : dateDirs) {
+ File[] serviceDirs = dateDir.listFiles();
+ for (File serviceDir : serviceDirs) {
+ File[] methodDirs = serviceDir.listFiles();
+ for (File methodDir : methodDirs) {
+ String methodUri = chartsDirectory + "/" + dateDir.getName() + "/" + serviceDir.getName() + "/" + methodDir.getName();
+
+ File successFile = new File(methodUri + "/" + SUCCESS + ".png");
+ long successModified = successFile.lastModified();
+ boolean successChanged = false;
+ Map<String, long[]> successData = new HashMap<String, long[]>();
+ double[] successSummary = new double[4];
+
+ File elapsedFile = new File(methodUri + "/" + ELAPSED + ".png");
+ long elapsedModified = elapsedFile.lastModified();
+ boolean elapsedChanged = false;
+ Map<String, long[]> elapsedData = new HashMap<String, long[]>();
+ double[] elapsedSummary = new double[4];
+ long elapsedMax = 0;
+
+ File[] consumerDirs = methodDir.listFiles();
+ for (File consumerDir : consumerDirs) {
+ File[] providerDirs = consumerDir.listFiles();
+ for (File providerDir : providerDirs) {
+ File consumerSuccessFile = new File(providerDir, CONSUMER + "." + SUCCESS);
+ File providerSuccessFile = new File(providerDir, PROVIDER + "." + SUCCESS);
+ appendData(new File[]{consumerSuccessFile, providerSuccessFile}, successData, successSummary);
+ if (consumerSuccessFile.lastModified() > successModified
+ || providerSuccessFile.lastModified() > successModified) {
+ successChanged = true;
+ }
+
+ File consumerElapsedFile = new File(providerDir, CONSUMER + "." + ELAPSED);
+ File providerElapsedFile = new File(providerDir, PROVIDER + "." + ELAPSED);
+ appendData(new File[]{consumerElapsedFile, providerElapsedFile}, elapsedData, elapsedSummary);
+ elapsedMax = Math.max(elapsedMax, CountUtils.max(new File(providerDir, CONSUMER + "." + MAX_ELAPSED)));
+ elapsedMax = Math.max(elapsedMax, CountUtils.max(new File(providerDir, PROVIDER + "." + MAX_ELAPSED)));
+ if (consumerElapsedFile.lastModified() > elapsedModified
+ || providerElapsedFile.lastModified() > elapsedModified) {
+ elapsedChanged = true;
+ }
+ }
+ }
+ if (elapsedChanged) {
+ divData(elapsedData, successData);
+ elapsedSummary[0] = elapsedMax;
+ elapsedSummary[1] = -1;
+ elapsedSummary[2] = successSummary[3] == 0 ? 0 : elapsedSummary[3] / successSummary[3];
+ elapsedSummary[3] = -1;
+ createChart("ms/t", serviceDir.getName(), methodDir.getName(), dateDir.getName(), new String[]{CONSUMER, PROVIDER}, elapsedData, elapsedSummary, elapsedFile.getAbsolutePath());
+ }
+ if (successChanged) {
+ divData(successData, 60);
+ successSummary[0] = successSummary[0] / 60;
+ successSummary[1] = successSummary[1] / 60;
+ successSummary[2] = successSummary[2] / 60;
+ createChart("t/s", serviceDir.getName(), methodDir.getName(), dateDir.getName(), new String[]{CONSUMER, PROVIDER}, successData, successSummary, successFile.getAbsolutePath());
+ }
+ }
+ }
+ }
+ }
+
+ private void divData(Map<String, long[]> successMap, long unit) {
+ for (long[] success : successMap.values()) {
+ for (int i = 0; i < success.length; i++) {
+ success[i] = success[i] / unit;
+ }
+ }
+ }
+
+ private void divData(Map<String, long[]> elapsedMap, Map<String, long[]> successMap) {
+ for (Map.Entry<String, long[]> entry : elapsedMap.entrySet()) {
+ long[] elapsed = entry.getValue();
+ long[] success = successMap.get(entry.getKey());
+ for (int i = 0; i < elapsed.length; i++) {
+ elapsed[i] = success[i] == 0 ? 0 : elapsed[i] / success[i];
+ }
+ }
+ }
+
+ private void appendData(File[] files, Map<String, long[]> data, double[] summary) {
+ for (int i = 0; i < files.length; i++) {
+ File file = files[i];
+ if (!file.exists()) {
+ continue;
+ }
+ try {
+ BufferedReader reader = new BufferedReader(new FileReader(file));
+ try {
+ int sum = 0;
+ int cnt = 0;
+ String line;
+ while ((line = reader.readLine()) != null) {
+ int index = line.indexOf(" ");
+ if (index > 0) {
+ String key = line.substring(0, index).trim();
+ long value = Long.parseLong(line.substring(index + 1).trim());
+ long[] values = data.get(key);
+ if (values == null) {
+ values = new long[files.length];
+ data.put(key, values);
+ }
+ values[i] += value;
+ summary[0] = Math.max(summary[0], values[i]);
+ summary[1] = summary[1] == 0 ? values[i] : Math.min(summary[1], values[i]);
+ sum += value;
+ cnt++;
+ }
+ }
+ if (i == 0) {
+ summary[3] += sum;
+ summary[2] = (summary[2] + (sum / cnt)) / 2;
+ }
+ } finally {
+ reader.close();
+ }
+ } catch (IOException e) {
+ logger.warn(e.getMessage(), e);
+ }
+ }
+ }
+
+ public void count(URL statistics) {
+ collect(statistics);
+ }
+
+ public void collect(URL statistics) {
+ queue.offer(statistics);
+ if (logger.isInfoEnabled()) {
+ logger.info("collect statistics: " + statistics);
+ }
+ }
+
+ public List<URL> lookup(URL query) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
}
\ No newline at end of file
diff --git a/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/pages/ApplicationsPageHandler.java b/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/pages/ApplicationsPageHandler.java
index 52fe67c04a..6cc2fdcce3 100644
--- a/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/pages/ApplicationsPageHandler.java
+++ b/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/pages/ApplicationsPageHandler.java
@@ -1,82 +1,82 @@
-/*
- * 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.monitor.simple.pages;
-
-import com.alibaba.dubbo.common.URL;
-import com.alibaba.dubbo.container.page.Menu;
-import com.alibaba.dubbo.container.page.Page;
-import com.alibaba.dubbo.container.page.PageHandler;
-import com.alibaba.dubbo.monitor.simple.RegistryContainer;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-/**
- * ApplicationsPageHandler
- */
-@Menu(name = "Applications", desc = "Show application dependencies.", order = 1000)
-public class ApplicationsPageHandler implements PageHandler {
-
- public Page handle(URL url) {
- Set<String> applications = RegistryContainer.getInstance().getApplications();
- List<List<String>> rows = new ArrayList<List<String>>();
- int providersCount = 0;
- int consumersCount = 0;
- int efferentCount = 0;
- int afferentCount = 0;
- if (applications != null && applications.size() > 0) {
- for (String application : applications) {
- List<String> row = new ArrayList<String>();
- row.add(application);
-
- List<URL> providers = RegistryContainer.getInstance().getProvidersByApplication(application);
- List<URL> consumers = RegistryContainer.getInstance().getConsumersByApplication(application);
-
- if (providers != null && providers.size() > 0
- || consumers != null && consumers.size() > 0) {
- URL provider = (providers != null && providers.size() > 0 ? providers.iterator().next() : consumers.iterator().next());
- row.add(provider.getParameter("owner", "") + (provider.hasParameter("organization") ? " (" + provider.getParameter("organization") + ")" : ""));
- } else {
- row.add("");
- }
-
- int providersSize = providers == null ? 0 : providers.size();
- providersCount += providersSize;
- row.add(providersSize == 0 ? "<font color=\"blue\">No provider</font>" : "<a href=\"providers.html?application=" + application + "\">Providers(" + providersSize + ")</a>");
-
- int consumersSize = consumers == null ? 0 : consumers.size();
- consumersCount += consumersSize;
- row.add(consumersSize == 0 ? "<font color=\"blue\">No consumer</font>" : "<a href=\"consumers.html?application=" + application + "\">Consumers(" + consumersSize + ")</a>");
-
- Set<String> efferents = RegistryContainer.getInstance().getDependencies(application, false);
- int efferentSize = efferents == null ? 0 : efferents.size();
- efferentCount += efferentSize;
- row.add(efferentSize == 0 ? "<font color=\"blue\">No dependency</font>" : "<a href=\"dependencies.html?application=" + application + "\">Depends On(" + efferentSize + ")</a>");
-
- Set<String> afferents = RegistryContainer.getInstance().getDependencies(application, true);
- int afferentSize = afferents == null ? 0 : afferents.size();
- afferentCount += afferentSize;
- row.add(afferentSize == 0 ? "<font color=\"blue\">No used</font>" : "<a href=\"dependencies.html?application=" + application + "&reverse=true\">Used By(" + afferentSize + ")</a>");
- rows.add(row);
- }
- }
- return new Page("Applications", "Applications (" + rows.size() + ")",
- new String[]{"Application Name:", "Owner", "Providers(" + providersCount + ")", "Consumers(" + consumersCount + ")", "Depends On(" + efferentCount + ")", "Used By(" + afferentCount + ")"}, rows);
- }
-
+/*
+ * 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.monitor.simple.pages;
+
+import com.alibaba.dubbo.common.URL;
+import com.alibaba.dubbo.container.page.Menu;
+import com.alibaba.dubbo.container.page.Page;
+import com.alibaba.dubbo.container.page.PageHandler;
+import com.alibaba.dubbo.monitor.simple.RegistryContainer;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * ApplicationsPageHandler
+ */
+@Menu(name = "Applications", desc = "Show application dependencies.", order = 1000)
+public class ApplicationsPageHandler implements PageHandler {
+
+ public Page handle(URL url) {
+ Set<String> applications = RegistryContainer.getInstance().getApplications();
+ List<List<String>> rows = new ArrayList<List<String>>();
+ int providersCount = 0;
+ int consumersCount = 0;
+ int efferentCount = 0;
+ int afferentCount = 0;
+ if (applications != null && applications.size() > 0) {
+ for (String application : applications) {
+ List<String> row = new ArrayList<String>();
+ row.add(application);
+
+ List<URL> providers = RegistryContainer.getInstance().getProvidersByApplication(application);
+ List<URL> consumers = RegistryContainer.getInstance().getConsumersByApplication(application);
+
+ if (providers != null && providers.size() > 0
+ || consumers != null && consumers.size() > 0) {
+ URL provider = (providers != null && providers.size() > 0 ? providers.iterator().next() : consumers.iterator().next());
+ row.add(provider.getParameter("owner", "") + (provider.hasParameter("organization") ? " (" + provider.getParameter("organization") + ")" : ""));
+ } else {
+ row.add("");
+ }
+
+ int providersSize = providers == null ? 0 : providers.size();
+ providersCount += providersSize;
+ row.add(providersSize == 0 ? "<font color=\"blue\">No provider</font>" : "<a href=\"providers.html?application=" + application + "\">Providers(" + providersSize + ")</a>");
+
+ int consumersSize = consumers == null ? 0 : consumers.size();
+ consumersCount += consumersSize;
+ row.add(consumersSize == 0 ? "<font color=\"blue\">No consumer</font>" : "<a href=\"consumers.html?application=" + application + "\">Consumers(" + consumersSize + ")</a>");
+
+ Set<String> efferents = RegistryContainer.getInstance().getDependencies(application, false);
+ int efferentSize = efferents == null ? 0 : efferents.size();
+ efferentCount += efferentSize;
+ row.add(efferentSize == 0 ? "<font color=\"blue\">No dependency</font>" : "<a href=\"dependencies.html?application=" + application + "\">Depends On(" + efferentSize + ")</a>");
+
+ Set<String> afferents = RegistryContainer.getInstance().getDependencies(application, true);
+ int afferentSize = afferents == null ? 0 : afferents.size();
+ afferentCount += afferentSize;
+ row.add(afferentSize == 0 ? "<font color=\"blue\">No used</font>" : "<a href=\"dependencies.html?application=" + application + "&reverse=true\">Used By(" + afferentSize + ")</a>");
+ rows.add(row);
+ }
+ }
+ return new Page("Applications", "Applications (" + rows.size() + ")",
+ new String[]{"Application Name:", "Owner", "Providers(" + providersCount + ")", "Consumers(" + consumersCount + ")", "Depends On(" + efferentCount + ")", "Used By(" + afferentCount + ")"}, rows);
+ }
+
}
\ No newline at end of file
diff --git a/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/pages/ChartsPageHandler.java b/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/pages/ChartsPageHandler.java
index fab00e0756..cbce72f739 100644
--- a/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/pages/ChartsPageHandler.java
+++ b/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/pages/ChartsPageHandler.java
@@ -1,95 +1,95 @@
-/*
- * 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.monitor.simple.pages;
-
-import com.alibaba.dubbo.common.URL;
-import com.alibaba.dubbo.common.utils.ConfigUtils;
-import com.alibaba.dubbo.container.page.Page;
-import com.alibaba.dubbo.container.page.PageHandler;
-import com.alibaba.dubbo.monitor.MonitorService;
-
-import java.io.File;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-/**
- * ChartsPageHandler
- */
-public class ChartsPageHandler implements PageHandler {
-
- public Page handle(URL url) {
- String service = url.getParameter("service");
- if (service == null || service.length() == 0) {
- throw new IllegalArgumentException("Please input service parameter.");
- }
- String date = url.getParameter("date");
- if (date == null || date.length() == 0) {
- date = new SimpleDateFormat("yyyyMMdd").format(new Date());
- }
- List<List<String>> rows = new ArrayList<List<String>>();
- String directory = ConfigUtils.getProperty("dubbo.charts.directory");
- File chartsDir = new File(directory);
- String filename = directory + "/" + date + "/" + service;
- File serviceDir = new File(filename);
- if (serviceDir.exists()) {
- File[] methodDirs = serviceDir.listFiles();
- for (File methodDir : methodDirs) {
- String methodUri = chartsDir.getName() + "/" + date + "/" + service + "/" + methodDir.getName() + "/";
- rows.add(toRow(methodDir, methodUri));
- }
- }
- StringBuilder nav = new StringBuilder();
- nav.append("<a href=\"services.html\">Services</a> > ");
- nav.append(service);
- nav.append(" > <a href=\"providers.html?service=");
- nav.append(service);
- nav.append("\">Providers</a> | <a href=\"consumers.html?service=");
- nav.append(service);
- nav.append("\">Consumers</a> | <a href=\"statistics.html?service=");
- nav.append(service);
- nav.append("&date=");
- nav.append(date);
- nav.append("\">Statistics</a> | Charts > <input type=\"text\" style=\"width: 65px;\" name=\"date\" value=\"");
- nav.append(date);
- nav.append("\" onkeyup=\"if (event.keyCode == 10 || event.keyCode == 13) {window.location.href='charts.html?service=");
- nav.append(service);
- nav.append("&date=' + this.value;}\" />");
- return new Page(nav.toString(), "Charts (" + rows.size() + ")",
- new String[]{"Method", "Requests per second (QPS)", "Average response time (ms)"}, rows);
- }
-
- private List<String> toRow(File dir, String uri) {
- List<String> row = new ArrayList<String>();
- row.add(dir.getName());
- if (new File(dir, MonitorService.SUCCESS + ".png").exists()) {
- String url = uri + MonitorService.SUCCESS + ".png";
- row.add("<a href=\"" + url + "\" target=\"_blank\"><img src=\"" + url + "\" style=\"width: 100%;\" border=\"0\" /></a>");
- } else {
- row.add("");
- }
- if (new File(dir, MonitorService.ELAPSED + ".png").exists()) {
- String url = uri + MonitorService.ELAPSED + ".png";
- row.add("<a href=\"" + url + "\" target=\"_blank\"><img src=\"" + url + "\" style=\"width: 100%;\" border=\"0\" /></a>");
- } else {
- row.add("");
- }
- return row;
- }
-
+/*
+ * 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.monitor.simple.pages;
+
+import com.alibaba.dubbo.common.URL;
+import com.alibaba.dubbo.common.utils.ConfigUtils;
+import com.alibaba.dubbo.container.page.Page;
+import com.alibaba.dubbo.container.page.PageHandler;
+import com.alibaba.dubbo.monitor.MonitorService;
+
+import java.io.File;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * ChartsPageHandler
+ */
+public class ChartsPageHandler implements PageHandler {
+
+ public Page handle(URL url) {
+ String service = url.getParameter("service");
+ if (service == null || service.length() == 0) {
+ throw new IllegalArgumentException("Please input service parameter.");
+ }
+ String date = url.getParameter("date");
+ if (date == null || date.length() == 0) {
+ date = new SimpleDateFormat("yyyyMMdd").format(new Date());
+ }
+ List<List<String>> rows = new ArrayList<List<String>>();
+ String directory = ConfigUtils.getProperty("dubbo.charts.directory");
+ File chartsDir = new File(directory);
+ String filename = directory + "/" + date + "/" + service;
+ File serviceDir = new File(filename);
+ if (serviceDir.exists()) {
+ File[] methodDirs = serviceDir.listFiles();
+ for (File methodDir : methodDirs) {
+ String methodUri = chartsDir.getName() + "/" + date + "/" + service + "/" + methodDir.getName() + "/";
+ rows.add(toRow(methodDir, methodUri));
+ }
+ }
+ StringBuilder nav = new StringBuilder();
+ nav.append("<a href=\"services.html\">Services</a> > ");
+ nav.append(service);
+ nav.append(" > <a href=\"providers.html?service=");
+ nav.append(service);
+ nav.append("\">Providers</a> | <a href=\"consumers.html?service=");
+ nav.append(service);
+ nav.append("\">Consumers</a> | <a href=\"statistics.html?service=");
+ nav.append(service);
+ nav.append("&date=");
+ nav.append(date);
+ nav.append("\">Statistics</a> | Charts > <input type=\"text\" style=\"width: 65px;\" name=\"date\" value=\"");
+ nav.append(date);
+ nav.append("\" onkeyup=\"if (event.keyCode == 10 || event.keyCode == 13) {window.location.href='charts.html?service=");
+ nav.append(service);
+ nav.append("&date=' + this.value;}\" />");
+ return new Page(nav.toString(), "Charts (" + rows.size() + ")",
+ new String[]{"Method", "Requests per second (QPS)", "Average response time (ms)"}, rows);
+ }
+
+ private List<String> toRow(File dir, String uri) {
+ List<String> row = new ArrayList<String>();
+ row.add(dir.getName());
+ if (new File(dir, MonitorService.SUCCESS + ".png").exists()) {
+ String url = uri + MonitorService.SUCCESS + ".png";
+ row.add("<a href=\"" + url + "\" target=\"_blank\"><img src=\"" + url + "\" style=\"width: 100%;\" border=\"0\" /></a>");
+ } else {
+ row.add("");
+ }
+ if (new File(dir, MonitorService.ELAPSED + ".png").exists()) {
+ String url = uri + MonitorService.ELAPSED + ".png";
+ row.add("<a href=\"" + url + "\" target=\"_blank\"><img src=\"" + url + "\" style=\"width: 100%;\" border=\"0\" /></a>");
+ } else {
+ row.add("");
+ }
+ return row;
+ }
+
}
\ No newline at end of file
diff --git a/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/pages/ConsumersPageHandler.java b/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/pages/ConsumersPageHandler.java
index 31ff7e785b..944d53f6f8 100644
--- a/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/pages/ConsumersPageHandler.java
+++ b/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/pages/ConsumersPageHandler.java
@@ -1,88 +1,88 @@
-/*
- * 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.monitor.simple.pages;
-
-import com.alibaba.dubbo.common.URL;
-import com.alibaba.dubbo.common.utils.NetUtils;
-import com.alibaba.dubbo.container.page.Page;
-import com.alibaba.dubbo.container.page.PageHandler;
-import com.alibaba.dubbo.monitor.simple.RegistryContainer;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * ConsumersPageHandler
- */
-public class ConsumersPageHandler implements PageHandler {
-
- public Page handle(URL url) {
- String service = url.getParameter("service");
- String host = url.getParameter("host");
- String application = url.getParameter("application");
- if (service != null && service.length() > 0) {
- List<List<String>> rows = new ArrayList<List<String>>();
- List<URL> consumers = RegistryContainer.getInstance().getConsumersByService(service);
- if (consumers != null && consumers.size() > 0) {
- for (URL u : consumers) {
- List<String> row = new ArrayList<String>();
- String s = u.toFullString();
- row.add(s.replace("&", "&"));
- row.add("<button onclick=\"if(confirm('Confirm unsubscribe consumer?')){window.location.href='unsubscribe.html?service=" + service + "&consumer=" + URL.encode(s) + "';}\">Unsubscribe</button>");
- rows.add(row);
- }
- }
- return new Page("<a href=\"services.html\">Services</a> > " + service
- + " > <a href=\"providers.html?service=" + service
- + "\">Providers</a> | Consumers | <a href=\"statistics.html?service=" + service
- + "\">Statistics</a> | <a href=\"charts.html?service=" + service
- + "\">Charts</a>", "Consumers (" + rows.size() + ")",
- new String[]{"Consumer URL:", "Unsubscribe"}, rows);
- } else if (host != null && host.length() > 0) {
- List<List<String>> rows = new ArrayList<List<String>>();
- List<URL> consumers = RegistryContainer.getInstance().getConsumersByHost(host);
- if (consumers != null && consumers.size() > 0) {
- for (URL u : consumers) {
- List<String> row = new ArrayList<String>();
- String s = u.toFullString();
- row.add(s.replace("&", "&"));
- row.add("<button onclick=\"if(confirm('Confirm unsubscribe consumer?')){window.location.href='unsubscribe.html?host=" + host + "&consumer=" + URL.encode(s) + "';}\">Unsubscribe</button>");
- rows.add(row);
- }
- }
- return new Page("<a href=\"hosts.html\">Hosts</a> > " + NetUtils.getHostName(host) + "/" + host + " > <a href=\"providers.html?host=" + host + "\">Providers</a> | Consumers", "Consumers (" + rows.size() + ")",
- new String[]{"Consumer URL:", "Unsubscribe"}, rows);
- } else if (application != null && application.length() > 0) {
- List<List<String>> rows = new ArrayList<List<String>>();
- List<URL> consumers = RegistryContainer.getInstance().getConsumersByApplication(application);
- if (consumers != null && consumers.size() > 0) {
- for (URL u : consumers) {
- List<String> row = new ArrayList<String>();
- String s = u.toFullString();
- row.add(s.replace("&", "&"));
- row.add("<button onclick=\"if(confirm('Confirm unsubscribe consumer?')){window.location.href='unsubscribe.html?application=" + application + "&consumer=" + URL.encode(s) + "';}\">Unsubscribe</button>");
- rows.add(row);
- }
- }
- return new Page("<a href=\"applications.html\">Applications</a> > " + application + " > <a href=\"providers.html?application=" + application + "\">Providers</a> | Consumers | <a href=\"dependencies.html?application=" + application + "\">Depends On</a> | <a href=\"dependencies.html?application=" + application + "&reverse=true\">Used By</a>", "Consumers (" + rows.size() + ")",
- new String[]{"Consumer URL:", "Unsubscribe"}, rows);
- } else {
- throw new IllegalArgumentException("Please input service or host or application parameter.");
- }
- }
-
+/*
+ * 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.monitor.simple.pages;
+
+import com.alibaba.dubbo.common.URL;
+import com.alibaba.dubbo.common.utils.NetUtils;
+import com.alibaba.dubbo.container.page.Page;
+import com.alibaba.dubbo.container.page.PageHandler;
+import com.alibaba.dubbo.monitor.simple.RegistryContainer;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * ConsumersPageHandler
+ */
+public class ConsumersPageHandler implements PageHandler {
+
+ public Page handle(URL url) {
+ String service = url.getParameter("service");
+ String host = url.getParameter("host");
+ String application = url.getParameter("application");
+ if (service != null && service.length() > 0) {
+ List<List<String>> rows = new ArrayList<List<String>>();
+ List<URL> consumers = RegistryContainer.getInstance().getConsumersByService(service);
+ if (consumers != null && consumers.size() > 0) {
+ for (URL u : consumers) {
+ List<String> row = new ArrayList<String>();
+ String s = u.toFullString();
+ row.add(s.replace("&", "&"));
+ row.add("<button onclick=\"if(confirm('Confirm unsubscribe consumer?')){window.location.href='unsubscribe.html?service=" + service + "&consumer=" + URL.encode(s) + "';}\">Unsubscribe</button>");
+ rows.add(row);
+ }
+ }
+ return new Page("<a href=\"services.html\">Services</a> > " + service
+ + " > <a href=\"providers.html?service=" + service
+ + "\">Providers</a> | Consumers | <a href=\"statistics.html?service=" + service
+ + "\">Statistics</a> | <a href=\"charts.html?service=" + service
+ + "\">Charts</a>", "Consumers (" + rows.size() + ")",
+ new String[]{"Consumer URL:", "Unsubscribe"}, rows);
+ } else if (host != null && host.length() > 0) {
+ List<List<String>> rows = new ArrayList<List<String>>();
+ List<URL> consumers = RegistryContainer.getInstance().getConsumersByHost(host);
+ if (consumers != null && consumers.size() > 0) {
+ for (URL u : consumers) {
+ List<String> row = new ArrayList<String>();
+ String s = u.toFullString();
+ row.add(s.replace("&", "&"));
+ row.add("<button onclick=\"if(confirm('Confirm unsubscribe consumer?')){window.location.href='unsubscribe.html?host=" + host + "&consumer=" + URL.encode(s) + "';}\">Unsubscribe</button>");
+ rows.add(row);
+ }
+ }
+ return new Page("<a href=\"hosts.html\">Hosts</a> > " + NetUtils.getHostName(host) + "/" + host + " > <a href=\"providers.html?host=" + host + "\">Providers</a> | Consumers", "Consumers (" + rows.size() + ")",
+ new String[]{"Consumer URL:", "Unsubscribe"}, rows);
+ } else if (application != null && application.length() > 0) {
+ List<List<String>> rows = new ArrayList<List<String>>();
+ List<URL> consumers = RegistryContainer.getInstance().getConsumersByApplication(application);
+ if (consumers != null && consumers.size() > 0) {
+ for (URL u : consumers) {
+ List<String> row = new ArrayList<String>();
+ String s = u.toFullString();
+ row.add(s.replace("&", "&"));
+ row.add("<button onclick=\"if(confirm('Confirm unsubscribe consumer?')){window.location.href='unsubscribe.html?application=" + application + "&consumer=" + URL.encode(s) + "';}\">Unsubscribe</button>");
+ rows.add(row);
+ }
+ }
+ return new Page("<a href=\"applications.html\">Applications</a> > " + application + " > <a href=\"providers.html?application=" + application + "\">Providers</a> | Consumers | <a href=\"dependencies.html?application=" + application + "\">Depends On</a> | <a href=\"dependencies.html?application=" + application + "&reverse=true\">Used By</a>", "Consumers (" + rows.size() + ")",
+ new String[]{"Consumer URL:", "Unsubscribe"}, rows);
+ } else {
+ throw new IllegalArgumentException("Please input service or host or application parameter.");
+ }
+ }
+
}
\ No newline at end of file
diff --git a/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/pages/DependenciesPageHandler.java b/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/pages/DependenciesPageHandler.java
index 7d07c72195..9b23c15fe6 100644
--- a/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/pages/DependenciesPageHandler.java
+++ b/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/pages/DependenciesPageHandler.java
@@ -1,88 +1,88 @@
-/*
- * 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.monitor.simple.pages;
-
-import com.alibaba.dubbo.common.URL;
-import com.alibaba.dubbo.container.page.Page;
-import com.alibaba.dubbo.container.page.PageHandler;
-import com.alibaba.dubbo.monitor.simple.RegistryContainer;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-/**
- * DependenciesPageHandler
- */
-public class DependenciesPageHandler implements PageHandler {
-
- public Page handle(URL url) {
- String application = url.getParameter("application");
- if (application == null || application.length() == 0) {
- throw new IllegalArgumentException("Please input application parameter.");
- }
- boolean reverse = url.getParameter("reverse", false);
- List<List<String>> rows = new ArrayList<List<String>>();
- Set<String> directly = RegistryContainer.getInstance().getDependencies(application, reverse);
- Set<String> indirectly = new HashSet<String>();
- appendDependency(rows, reverse, application, 0, new HashSet<String>(), indirectly);
- indirectly.remove(application);
- return new Page("<a href=\"applications.html\">Applications</a> > " + application +
- " > <a href=\"providers.html?application=" + application + "\">Providers</a> | <a href=\"consumers.html?application=" + application + "\">Consumers</a> | " +
- (reverse ? "<a href=\"dependencies.html?application=" + application + "\">Depends On</a> | Used By"
- : "Depends On | <a href=\"dependencies.html?application=" + application + "&reverse=true\">Used By</a>"), (reverse ? "Used By" : "Depends On") + " (" + directly.size() + "/" + indirectly.size() + ")", new String[]{"Application Name:"}, rows);
- }
-
- private void appendDependency(List<List<String>> rows, boolean reverse, String application, int level, Set<String> appended, Set<String> indirectly) {
- List<String> row = new ArrayList<String>();
- StringBuilder buf = new StringBuilder();
- if (level > 0) {
- for (int i = 0; i < level; i++) {
- buf.append(" |");
- }
- buf.append(reverse ? "<-- " : "--> ");
- }
- boolean end = false;
- if (level > 5) {
- buf.append(" <font color=\"blue\">More...</font>");
- end = true;
- } else {
- buf.append(application);
- if (appended.contains(application)) {
- buf.append(" <font color=\"red\">(Cycle)</font>");
- end = true;
- }
- }
- row.add(buf.toString());
- rows.add(row);
- if (end) {
- return;
- }
-
- appended.add(application);
- indirectly.add(application);
- Set<String> dependencies = RegistryContainer.getInstance().getDependencies(application, reverse);
- if (dependencies != null && dependencies.size() > 0) {
- for (String dependency : dependencies) {
- appendDependency(rows, reverse, dependency, level + 1, appended, indirectly);
- }
- }
- appended.remove(application);
- }
-
+/*
+ * 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.monitor.simple.pages;
+
+import com.alibaba.dubbo.common.URL;
+import com.alibaba.dubbo.container.page.Page;
+import com.alibaba.dubbo.container.page.PageHandler;
+import com.alibaba.dubbo.monitor.simple.RegistryContainer;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * DependenciesPageHandler
+ */
+public class DependenciesPageHandler implements PageHandler {
+
+ public Page handle(URL url) {
+ String application = url.getParameter("application");
+ if (application == null || application.length() == 0) {
+ throw new IllegalArgumentException("Please input application parameter.");
+ }
+ boolean reverse = url.getParameter("reverse", false);
+ List<List<String>> rows = new ArrayList<List<String>>();
+ Set<String> directly = RegistryContainer.getInstance().getDependencies(application, reverse);
+ Set<String> indirectly = new HashSet<String>();
+ appendDependency(rows, reverse, application, 0, new HashSet<String>(), indirectly);
+ indirectly.remove(application);
+ return new Page("<a href=\"applications.html\">Applications</a> > " + application +
+ " > <a href=\"providers.html?application=" + application + "\">Providers</a> | <a href=\"consumers.html?application=" + application + "\">Consumers</a> | " +
+ (reverse ? "<a href=\"dependencies.html?application=" + application + "\">Depends On</a> | Used By"
+ : "Depends On | <a href=\"dependencies.html?application=" + application + "&reverse=true\">Used By</a>"), (reverse ? "Used By" : "Depends On") + " (" + directly.size() + "/" + indirectly.size() + ")", new String[]{"Application Name:"}, rows);
+ }
+
+ private void appendDependency(List<List<String>> rows, boolean reverse, String application, int level, Set<String> appended, Set<String> indirectly) {
+ List<String> row = new ArrayList<String>();
+ StringBuilder buf = new StringBuilder();
+ if (level > 0) {
+ for (int i = 0; i < level; i++) {
+ buf.append(" |");
+ }
+ buf.append(reverse ? "<-- " : "--> ");
+ }
+ boolean end = false;
+ if (level > 5) {
+ buf.append(" <font color=\"blue\">More...</font>");
+ end = true;
+ } else {
+ buf.append(application);
+ if (appended.contains(application)) {
+ buf.append(" <font color=\"red\">(Cycle)</font>");
+ end = true;
+ }
+ }
+ row.add(buf.toString());
+ rows.add(row);
+ if (end) {
+ return;
+ }
+
+ appended.add(application);
+ indirectly.add(application);
+ Set<String> dependencies = RegistryContainer.getInstance().getDependencies(application, reverse);
+ if (dependencies != null && dependencies.size() > 0) {
+ for (String dependency : dependencies) {
+ appendDependency(rows, reverse, dependency, level + 1, appended, indirectly);
+ }
+ }
+ appended.remove(application);
+ }
+
}
\ No newline at end of file
diff --git a/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/pages/HostsPageHandler.java b/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/pages/HostsPageHandler.java
index 4d76480b36..38c1312c9b 100644
--- a/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/pages/HostsPageHandler.java
+++ b/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/pages/HostsPageHandler.java
@@ -1,75 +1,75 @@
-/*
- * 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.monitor.simple.pages;
-
-import com.alibaba.dubbo.common.Constants;
-import com.alibaba.dubbo.common.URL;
-import com.alibaba.dubbo.common.utils.NetUtils;
-import com.alibaba.dubbo.container.page.Menu;
-import com.alibaba.dubbo.container.page.Page;
-import com.alibaba.dubbo.container.page.PageHandler;
-import com.alibaba.dubbo.monitor.simple.RegistryContainer;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-/**
- * HostsPageHandler
- */
-@Menu(name = "Hosts", desc = "Show provider and consumer hosts", order = 3000)
-public class HostsPageHandler implements PageHandler {
-
- public Page handle(URL url) {
- List<List<String>> rows = new ArrayList<List<String>>();
- Set<String> hosts = RegistryContainer.getInstance().getHosts();
- int providersCount = 0;
- int consumersCount = 0;
- if (hosts != null && hosts.size() > 0) {
- for (String host : hosts) {
- List<String> row = new ArrayList<String>();
- row.add(NetUtils.getHostName(host) + "/" + host);
-
- List<URL> providers = RegistryContainer.getInstance().getProvidersByHost(host);
- List<URL> consumers = RegistryContainer.getInstance().getConsumersByHost(host);
-
- if (providers != null && providers.size() > 0
- || consumers != null && consumers.size() > 0) {
- URL provider = (providers != null && providers.size() > 0 ? providers.iterator().next() : consumers.iterator().next());
- row.add(provider.getParameter(Constants.APPLICATION_KEY, ""));
- row.add(provider.getParameter("owner", "") + (provider.hasParameter("organization") ? " (" + provider.getParameter("organization") + ")" : ""));
- } else {
- row.add("");
- row.add("");
- }
-
- int proviedSize = providers == null ? 0 : providers.size();
- providersCount += proviedSize;
- row.add(proviedSize == 0 ? "<font color=\"blue\">No provider</font>" : "<a href=\"providers.html?host=" + host + "\">Providers(" + proviedSize + ")</a>");
-
- int consumersSize = consumers == null ? 0 : consumers.size();
- consumersCount += consumersSize;
- row.add(consumersSize == 0 ? "<font color=\"blue\">No consumer</font>" : "<a href=\"consumers.html?host=" + host + "\">Consumers(" + consumersSize + ")</a>");
-
- rows.add(row);
- }
- }
- return new Page("Hosts", "Hosts (" + rows.size() + ")",
- new String[]{"Host Name/IP:", "Application", "Owner", "Providers(" + providersCount + ")", "Consumers(" + consumersCount + ")"}, rows);
- }
-
+/*
+ * 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.monitor.simple.pages;
+
+import com.alibaba.dubbo.common.Constants;
+import com.alibaba.dubbo.common.URL;
+import com.alibaba.dubbo.common.utils.NetUtils;
+import com.alibaba.dubbo.container.page.Menu;
+import com.alibaba.dubbo.container.page.Page;
+import com.alibaba.dubbo.container.page.PageHandler;
+import com.alibaba.dubbo.monitor.simple.RegistryContainer;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * HostsPageHandler
+ */
+@Menu(name = "Hosts", desc = "Show provider and consumer hosts", order = 3000)
+public class HostsPageHandler implements PageHandler {
+
+ public Page handle(URL url) {
+ List<List<String>> rows = new ArrayList<List<String>>();
+ Set<String> hosts = RegistryContainer.getInstance().getHosts();
+ int providersCount = 0;
+ int consumersCount = 0;
+ if (hosts != null && hosts.size() > 0) {
+ for (String host : hosts) {
+ List<String> row = new ArrayList<String>();
+ row.add(NetUtils.getHostName(host) + "/" + host);
+
+ List<URL> providers = RegistryContainer.getInstance().getProvidersByHost(host);
+ List<URL> consumers = RegistryContainer.getInstance().getConsumersByHost(host);
+
+ if (providers != null && providers.size() > 0
+ || consumers != null && consumers.size() > 0) {
+ URL provider = (providers != null && providers.size() > 0 ? providers.iterator().next() : consumers.iterator().next());
+ row.add(provider.getParameter(Constants.APPLICATION_KEY, ""));
+ row.add(provider.getParameter("owner", "") + (provider.hasParameter("organization") ? " (" + provider.getParameter("organization") + ")" : ""));
+ } else {
+ row.add("");
+ row.add("");
+ }
+
+ int proviedSize = providers == null ? 0 : providers.size();
+ providersCount += proviedSize;
+ row.add(proviedSize == 0 ? "<font color=\"blue\">No provider</font>" : "<a href=\"providers.html?host=" + host + "\">Providers(" + proviedSize + ")</a>");
+
+ int consumersSize = consumers == null ? 0 : consumers.size();
+ consumersCount += consumersSize;
+ row.add(consumersSize == 0 ? "<font color=\"blue\">No consumer</font>" : "<a href=\"consumers.html?host=" + host + "\">Consumers(" + consumersSize + ")</a>");
+
+ rows.add(row);
+ }
+ }
+ return new Page("Hosts", "Hosts (" + rows.size() + ")",
+ new String[]{"Host Name/IP:", "Application", "Owner", "Providers(" + providersCount + ")", "Consumers(" + consumersCount + ")"}, rows);
+ }
+
}
\ No newline at end of file
diff --git a/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/pages/ProvidersPageHandler.java b/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/pages/ProvidersPageHandler.java
index 97db933295..a15d3e6cdc 100644
--- a/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/pages/ProvidersPageHandler.java
+++ b/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/pages/ProvidersPageHandler.java
@@ -1,88 +1,88 @@
-/*
- * 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.monitor.simple.pages;
-
-import com.alibaba.dubbo.common.URL;
-import com.alibaba.dubbo.common.utils.NetUtils;
-import com.alibaba.dubbo.container.page.Page;
-import com.alibaba.dubbo.container.page.PageHandler;
-import com.alibaba.dubbo.monitor.simple.RegistryContainer;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * ProvidersPageHandler
- */
-public class ProvidersPageHandler implements PageHandler {
-
- public Page handle(URL url) {
- String service = url.getParameter("service");
- String host = url.getParameter("host");
- String application = url.getParameter("application");
- if (service != null && service.length() > 0) {
- List<List<String>> rows = new ArrayList<List<String>>();
- List<URL> providers = RegistryContainer.getInstance().getProvidersByService(service);
- if (providers != null && providers.size() > 0) {
- for (URL u : providers) {
- List<String> row = new ArrayList<String>();
- String s = u.toFullString();
- row.add(s.replace("&", "&"));
- row.add("<button onclick=\"if(confirm('Confirm unregister provider?')){window.location.href='unregister.html?service=" + service + "&provider=" + URL.encode(s) + "';}\">Unregister</button>");
- rows.add(row);
- }
- }
- return new Page("<a href=\"services.html\">Services</a> > " + service
- + " > Providers | <a href=\"consumers.html?service=" + service
- + "\">Consumers</a> | <a href=\"statistics.html?service=" + service
- + "\">Statistics</a> | <a href=\"charts.html?service=" + service
- + "\">Charts</a>", "Providers (" + rows.size() + ")",
- new String[]{"Provider URL:", "Unregister"}, rows);
- } else if (host != null && host.length() > 0) {
- List<List<String>> rows = new ArrayList<List<String>>();
- List<URL> providers = RegistryContainer.getInstance().getProvidersByHost(host);
- if (providers != null && providers.size() > 0) {
- for (URL u : providers) {
- List<String> row = new ArrayList<String>();
- String s = u.toFullString();
- row.add(s.replace("&", "&"));
- row.add("<button onclick=\"if(confirm('Confirm unregister provider?')){window.location.href='unregister.html?host=" + host + "&provider=" + URL.encode(s) + "';}\">Unregister</button>");
- rows.add(row);
- }
- }
- return new Page("<a href=\"hosts.html\">Hosts</a> > " + NetUtils.getHostName(host) + "/" + host + " > Providers | <a href=\"consumers.html?host=" + host + "\">Consumers</a>", "Providers (" + rows.size() + ")",
- new String[]{"Provider URL:", "Unregister"}, rows);
- } else if (application != null && application.length() > 0) {
- List<List<String>> rows = new ArrayList<List<String>>();
- List<URL> providers = RegistryContainer.getInstance().getProvidersByApplication(application);
- if (providers != null && providers.size() > 0) {
- for (URL u : providers) {
- List<String> row = new ArrayList<String>();
- String s = u.toFullString();
- row.add(s.replace("&", "&"));
- row.add("<button onclick=\"if(confirm('Confirm unregister provider?')){window.location.href='unregister.html?application=" + application + "&provider=" + URL.encode(s) + "';}\">Unregister</button>");
- rows.add(row);
- }
- }
- return new Page("<a href=\"applications.html\">Applications</a> > " + application + " > Providers | <a href=\"consumers.html?application=" + application + "\">Consumers</a> | <a href=\"dependencies.html?application=" + application + "\">Depends On</a> | <a href=\"dependencies.html?application=" + application + "&reverse=true\">Used By</a>", "Providers (" + rows.size() + ")",
- new String[]{"Provider URL:", "Unregister"}, rows);
- } else {
- throw new IllegalArgumentException("Please input service or host or application parameter.");
- }
- }
-
+/*
+ * 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.monitor.simple.pages;
+
+import com.alibaba.dubbo.common.URL;
+import com.alibaba.dubbo.common.utils.NetUtils;
+import com.alibaba.dubbo.container.page.Page;
+import com.alibaba.dubbo.container.page.PageHandler;
+import com.alibaba.dubbo.monitor.simple.RegistryContainer;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * ProvidersPageHandler
+ */
+public class ProvidersPageHandler implements PageHandler {
+
+ public Page handle(URL url) {
+ String service = url.getParameter("service");
+ String host = url.getParameter("host");
+ String application = url.getParameter("application");
+ if (service != null && service.length() > 0) {
+ List<List<String>> rows = new ArrayList<List<String>>();
+ List<URL> providers = RegistryContainer.getInstance().getProvidersByService(service);
+ if (providers != null && providers.size() > 0) {
+ for (URL u : providers) {
+ List<String> row = new ArrayList<String>();
+ String s = u.toFullString();
+ row.add(s.replace("&", "&"));
+ row.add("<button onclick=\"if(confirm('Confirm unregister provider?')){window.location.href='unregister.html?service=" + service + "&provider=" + URL.encode(s) + "';}\">Unregister</button>");
+ rows.add(row);
+ }
+ }
+ return new Page("<a href=\"services.html\">Services</a> > " + service
+ + " > Providers | <a href=\"consumers.html?service=" + service
+ + "\">Consumers</a> | <a href=\"statistics.html?service=" + service
+ + "\">Statistics</a> | <a href=\"charts.html?service=" + service
+ + "\">Charts</a>", "Providers (" + rows.size() + ")",
+ new String[]{"Provider URL:", "Unregister"}, rows);
+ } else if (host != null && host.length() > 0) {
+ List<List<String>> rows = new ArrayList<List<String>>();
+ List<URL> providers = RegistryContainer.getInstance().getProvidersByHost(host);
+ if (providers != null && providers.size() > 0) {
+ for (URL u : providers) {
+ List<String> row = new ArrayList<String>();
+ String s = u.toFullString();
+ row.add(s.replace("&", "&"));
+ row.add("<button onclick=\"if(confirm('Confirm unregister provider?')){window.location.href='unregister.html?host=" + host + "&provider=" + URL.encode(s) + "';}\">Unregister</button>");
+ rows.add(row);
+ }
+ }
+ return new Page("<a href=\"hosts.html\">Hosts</a> > " + NetUtils.getHostName(host) + "/" + host + " > Providers | <a href=\"consumers.html?host=" + host + "\">Consumers</a>", "Providers (" + rows.size() + ")",
+ new String[]{"Provider URL:", "Unregister"}, rows);
+ } else if (application != null && application.length() > 0) {
+ List<List<String>> rows = new ArrayList<List<String>>();
+ List<URL> providers = RegistryContainer.getInstance().getProvidersByApplication(application);
+ if (providers != null && providers.size() > 0) {
+ for (URL u : providers) {
+ List<String> row = new ArrayList<String>();
+ String s = u.toFullString();
+ row.add(s.replace("&", "&"));
+ row.add("<button onclick=\"if(confirm('Confirm unregister provider?')){window.location.href='unregister.html?application=" + application + "&provider=" + URL.encode(s) + "';}\">Unregister</button>");
+ rows.add(row);
+ }
+ }
+ return new Page("<a href=\"applications.html\">Applications</a> > " + application + " > Providers | <a href=\"consumers.html?application=" + application + "\">Consumers</a> | <a href=\"dependencies.html?application=" + application + "\">Depends On</a> | <a href=\"dependencies.html?application=" + application + "&reverse=true\">Used By</a>", "Providers (" + rows.size() + ")",
+ new String[]{"Provider URL:", "Unregister"}, rows);
+ } else {
+ throw new IllegalArgumentException("Please input service or host or application parameter.");
+ }
+ }
+
}
\ No newline at end of file
diff --git a/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/pages/ServicesPageHandler.java b/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/pages/ServicesPageHandler.java
index cdb2ad691d..a22d89ace4 100644
--- a/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/pages/ServicesPageHandler.java
+++ b/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/pages/ServicesPageHandler.java
@@ -1,72 +1,72 @@
-/*
- * 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.monitor.simple.pages;
-
-import com.alibaba.dubbo.common.Constants;
-import com.alibaba.dubbo.common.URL;
-import com.alibaba.dubbo.container.page.Menu;
-import com.alibaba.dubbo.container.page.Page;
-import com.alibaba.dubbo.container.page.PageHandler;
-import com.alibaba.dubbo.monitor.simple.RegistryContainer;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-/**
- * ServicesPageHandler
- */
-@Menu(name = "Services", desc = "Show registered services.", order = 2000)
-public class ServicesPageHandler implements PageHandler {
-
- public Page handle(URL url) {
- Set<String> services = RegistryContainer.getInstance().getServices();
- List<List<String>> rows = new ArrayList<List<String>>();
- int providerCount = 0;
- int consumerCount = 0;
- if (services != null && services.size() > 0) {
- for (String service : services) {
- List<URL> providers = RegistryContainer.getInstance().getProvidersByService(service);
- int providerSize = providers == null ? 0 : providers.size();
- providerCount += providerSize;
- List<URL> consumers = RegistryContainer.getInstance().getConsumersByService(service);
- int consumerSize = consumers == null ? 0 : consumers.size();
- consumerCount += consumerSize;
- List<String> row = new ArrayList<String>();
- row.add(service);
- if (providerSize > 0 || consumerSize > 0) {
- if (providerSize > 0) {
- URL provider = providers.iterator().next();
- row.add(provider.getParameter(Constants.APPLICATION_KEY, ""));
- row.add(provider.getParameter("owner", "") + (provider.hasParameter("organization") ? " (" + provider.getParameter("organization") + ")" : ""));
- } else {
- row.add("");
- row.add("");
- }
- row.add(providerSize == 0 ? "<font color=\"red\">No provider</a>" : "<a href=\"providers.html?service=" + service + "\">Providers(" + providerSize + ")</a>");
- row.add(consumerSize == 0 ? "<font color=\"blue\">No consumer</a>" : "<a href=\"consumers.html?service=" + service + "\">Consumers(" + consumerSize + ")</a>");
- row.add("<a href=\"statistics.html?service=" + service + "\">Statistics</a>");
- row.add("<a href=\"charts.html?service=" + service + "\">Charts</a>");
- rows.add(row);
- }
- }
- }
- return new Page("Services", "Services (" + rows.size() + ")",
- new String[]{"Service Name:", "Application", "Owner", "Providers(" + providerCount + ")", "Consumers(" + consumerCount + ")", "Statistics", "Charts"}, rows);
- }
-
+/*
+ * 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.monitor.simple.pages;
+
+import com.alibaba.dubbo.common.Constants;
+import com.alibaba.dubbo.common.URL;
+import com.alibaba.dubbo.container.page.Menu;
+import com.alibaba.dubbo.container.page.Page;
+import com.alibaba.dubbo.container.page.PageHandler;
+import com.alibaba.dubbo.monitor.simple.RegistryContainer;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * ServicesPageHandler
+ */
+@Menu(name = "Services", desc = "Show registered services.", order = 2000)
+public class ServicesPageHandler implements PageHandler {
+
+ public Page handle(URL url) {
+ Set<String> services = RegistryContainer.getInstance().getServices();
+ List<List<String>> rows = new ArrayList<List<String>>();
+ int providerCount = 0;
+ int consumerCount = 0;
+ if (services != null && services.size() > 0) {
+ for (String service : services) {
+ List<URL> providers = RegistryContainer.getInstance().getProvidersByService(service);
+ int providerSize = providers == null ? 0 : providers.size();
+ providerCount += providerSize;
+ List<URL> consumers = RegistryContainer.getInstance().getConsumersByService(service);
+ int consumerSize = consumers == null ? 0 : consumers.size();
+ consumerCount += consumerSize;
+ List<String> row = new ArrayList<String>();
+ row.add(service);
+ if (providerSize > 0 || consumerSize > 0) {
+ if (providerSize > 0) {
+ URL provider = providers.iterator().next();
+ row.add(provider.getParameter(Constants.APPLICATION_KEY, ""));
+ row.add(provider.getParameter("owner", "") + (provider.hasParameter("organization") ? " (" + provider.getParameter("organization") + ")" : ""));
+ } else {
+ row.add("");
+ row.add("");
+ }
+ row.add(providerSize == 0 ? "<font color=\"red\">No provider</a>" : "<a href=\"providers.html?service=" + service + "\">Providers(" + providerSize + ")</a>");
+ row.add(consumerSize == 0 ? "<font color=\"blue\">No consumer</a>" : "<a href=\"consumers.html?service=" + service + "\">Consumers(" + consumerSize + ")</a>");
+ row.add("<a href=\"statistics.html?service=" + service + "\">Statistics</a>");
+ row.add("<a href=\"charts.html?service=" + service + "\">Charts</a>");
+ rows.add(row);
+ }
+ }
+ }
+ return new Page("Services", "Services (" + rows.size() + ")",
+ new String[]{"Service Name:", "Application", "Owner", "Providers(" + providerCount + ")", "Consumers(" + consumerCount + ")", "Statistics", "Charts"}, rows);
+ }
+
}
\ No newline at end of file
diff --git a/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/pages/StatisticsPageHandler.java b/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/pages/StatisticsPageHandler.java
index eee08968fa..d5ba163148 100644
--- a/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/pages/StatisticsPageHandler.java
+++ b/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/pages/StatisticsPageHandler.java
@@ -1,167 +1,167 @@
-/*
- * 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.monitor.simple.pages;
-
-import com.alibaba.dubbo.common.URL;
-import com.alibaba.dubbo.common.utils.ConfigUtils;
-import com.alibaba.dubbo.container.page.Page;
-import com.alibaba.dubbo.container.page.PageHandler;
-import com.alibaba.dubbo.monitor.MonitorService;
-import com.alibaba.dubbo.monitor.simple.CountUtils;
-
-import java.io.File;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * StatisticsPageHandler
- */
-public class StatisticsPageHandler implements PageHandler {
-
- public Page handle(URL url) {
- String service = url.getParameter("service");
- if (service == null || service.length() == 0) {
- throw new IllegalArgumentException("Please input service parameter.");
- }
- String date = url.getParameter("date");
- if (date == null || date.length() == 0) {
- date = new SimpleDateFormat("yyyyMMdd").format(new Date());
- }
- String expand = url.getParameter("expand");
- List<List<String>> rows = new ArrayList<List<String>>();
- String directory = ConfigUtils.getProperty("dubbo.statistics.directory");
- String filename = directory + "/" + date + "/" + service;
- File serviceDir = new File(filename);
- if (serviceDir.exists()) {
- File[] methodDirs = serviceDir.listFiles();
- for (File methodDir : methodDirs) {
- long[] statistics = newStatistics();
- Map<String, long[]> expandMap = new HashMap<String, long[]>();
- File[] consumerDirs = methodDir.listFiles();
- for (File consumerDir : consumerDirs) {
- long[] expandStatistics = null;
- if (MonitorService.CONSUMER.equals(expand)) {
- expandStatistics = newStatistics();
- expandMap.put(consumerDir.getName(), expandStatistics);
- }
- File[] providerDirs = consumerDir.listFiles();
- for (File providerDir : providerDirs) {
- if (MonitorService.PROVIDER.equals(expand)) {
- expandStatistics = newStatistics();
- expandMap.put(providerDir.getName(), expandStatistics);
- }
- appendStatistics(providerDir, statistics);
- if (expandStatistics != null) {
- appendStatistics(providerDir, expandStatistics);
- }
- }
- }
- rows.add(toRow(methodDir.getName(), statistics));
- if (expandMap != null && expandMap.size() > 0) {
- for (Map.Entry<String, long[]> entry : expandMap.entrySet()) {
- String node = MonitorService.CONSUMER.equals(expand) ? "<--" : "-->";
- rows.add(toRow(" |" + node + " " + entry.getKey(), entry.getValue()));
- }
- }
- }
- }
- StringBuilder nav = new StringBuilder();
- nav.append("<a href=\"services.html\">Services</a> > ");
- nav.append(service);
- nav.append(" > <a href=\"providers.html?service=");
- nav.append(service);
- nav.append("\">Providers</a> | <a href=\"consumers.html?service=");
- nav.append(service);
- nav.append("\">Consumers</a> | Statistics | <a href=\"charts.html?service=");
- nav.append(service);
- nav.append("&date=");
- nav.append(date);
- nav.append("\">Charts</a> > <input type=\"text\" style=\"width: 65px;\" name=\"date\" value=\"");
- nav.append(date);
- nav.append("\" onkeyup=\"if (event.keyCode == 10 || event.keyCode == 13) {window.location.href='statistics.html?service=");
- nav.append(service);
- if (expand != null && expand.length() > 0) {
- nav.append("&expand=");
- nav.append(expand);
- }
- nav.append("&date=' + this.value;}\" /> > ");
- if (!MonitorService.PROVIDER.equals(expand) && !MonitorService.CONSUMER.equals(expand)) {
- nav.append("Summary");
- } else {
- nav.append("<a href=\"statistics.html?service=");
- nav.append(service);
- nav.append("&date=");
- nav.append(date);
- nav.append("\">Summary</a>");
- }
- if (MonitorService.PROVIDER.equals(expand)) {
- nav.append(" | +Provider");
- } else {
- nav.append(" | <a href=\"statistics.html?service=");
- nav.append(service);
- nav.append("&date=");
- nav.append(date);
- nav.append("&expand=provider\">+Provider</a>");
- }
- if (MonitorService.CONSUMER.equals(expand)) {
- nav.append(" | +Consumer");
- } else {
- nav.append(" | <a href=\"statistics.html?service=");
- nav.append(service);
- nav.append("&date=");
- nav.append(date);
- nav.append("&expand=consumer\">+Consumer</a>");
- }
- return new Page(nav.toString(), "Statistics (" + rows.size() + ")",
- new String[]{"Method:", "Success", "Failure", "Avg Elapsed (ms)",
- "Max Elapsed (ms)", "Max Concurrent"}, rows);
- }
-
- private long[] newStatistics() {
- return new long[10];
- }
-
- private void appendStatistics(File providerDir, long[] statistics) {
- statistics[0] += CountUtils.sum(new File(providerDir, MonitorService.CONSUMER + "." + MonitorService.SUCCESS));
- statistics[1] += CountUtils.sum(new File(providerDir, MonitorService.PROVIDER + "." + MonitorService.SUCCESS));
- statistics[2] += CountUtils.sum(new File(providerDir, MonitorService.CONSUMER + "." + MonitorService.FAILURE));
- statistics[3] += CountUtils.sum(new File(providerDir, MonitorService.PROVIDER + "." + MonitorService.FAILURE));
- statistics[4] += CountUtils.sum(new File(providerDir, MonitorService.CONSUMER + "." + MonitorService.ELAPSED));
- statistics[5] += CountUtils.sum(new File(providerDir, MonitorService.PROVIDER + "." + MonitorService.ELAPSED));
- statistics[6] = Math.max(statistics[6], CountUtils.max(new File(providerDir, MonitorService.CONSUMER + "." + MonitorService.MAX_ELAPSED)));
- statistics[7] = Math.max(statistics[7], CountUtils.max(new File(providerDir, MonitorService.PROVIDER + "." + MonitorService.MAX_ELAPSED)));
- statistics[8] = Math.max(statistics[8], CountUtils.max(new File(providerDir, MonitorService.CONSUMER + "." + MonitorService.MAX_CONCURRENT)));
- statistics[9] = Math.max(statistics[9], CountUtils.max(new File(providerDir, MonitorService.PROVIDER + "." + MonitorService.MAX_CONCURRENT)));
- }
-
- private List<String> toRow(String name, long[] statistics) {
- List<String> row = new ArrayList<String>();
- row.add(name);
- row.add(String.valueOf(statistics[0]) + " --> " + String.valueOf(statistics[1]));
- row.add(String.valueOf(statistics[2]) + " --> " + String.valueOf(statistics[3]));
- row.add(String.valueOf(statistics[0] == 0 ? 0 : statistics[4] / statistics[0])
- + " --> " + String.valueOf(statistics[1] == 0 ? 0 : statistics[5] / statistics[1]));
- row.add(String.valueOf(statistics[6]) + " --> " + String.valueOf(statistics[7]));
- row.add(String.valueOf(statistics[8]) + " --> " + String.valueOf(statistics[9]));
- return row;
- }
-
+/*
+ * 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.monitor.simple.pages;
+
+import com.alibaba.dubbo.common.URL;
+import com.alibaba.dubbo.common.utils.ConfigUtils;
+import com.alibaba.dubbo.container.page.Page;
+import com.alibaba.dubbo.container.page.PageHandler;
+import com.alibaba.dubbo.monitor.MonitorService;
+import com.alibaba.dubbo.monitor.simple.CountUtils;
+
+import java.io.File;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * StatisticsPageHandler
+ */
+public class StatisticsPageHandler implements PageHandler {
+
+ public Page handle(URL url) {
+ String service = url.getParameter("service");
+ if (service == null || service.length() == 0) {
+ throw new IllegalArgumentException("Please input service parameter.");
+ }
+ String date = url.getParameter("date");
+ if (date == null || date.length() == 0) {
+ date = new SimpleDateFormat("yyyyMMdd").format(new Date());
+ }
+ String expand = url.getParameter("expand");
+ List<List<String>> rows = new ArrayList<List<String>>();
+ String directory = ConfigUtils.getProperty("dubbo.statistics.directory");
+ String filename = directory + "/" + date + "/" + service;
+ File serviceDir = new File(filename);
+ if (serviceDir.exists()) {
+ File[] methodDirs = serviceDir.listFiles();
+ for (File methodDir : methodDirs) {
+ long[] statistics = newStatistics();
+ Map<String, long[]> expandMap = new HashMap<String, long[]>();
+ File[] consumerDirs = methodDir.listFiles();
+ for (File consumerDir : consumerDirs) {
+ long[] expandStatistics = null;
+ if (MonitorService.CONSUMER.equals(expand)) {
+ expandStatistics = newStatistics();
+ expandMap.put(consumerDir.getName(), expandStatistics);
+ }
+ File[] providerDirs = consumerDir.listFiles();
+ for (File providerDir : providerDirs) {
+ if (MonitorService.PROVIDER.equals(expand)) {
+ expandStatistics = newStatistics();
+ expandMap.put(providerDir.getName(), expandStatistics);
+ }
+ appendStatistics(providerDir, statistics);
+ if (expandStatistics != null) {
+ appendStatistics(providerDir, expandStatistics);
+ }
+ }
+ }
+ rows.add(toRow(methodDir.getName(), statistics));
+ if (expandMap != null && expandMap.size() > 0) {
+ for (Map.Entry<String, long[]> entry : expandMap.entrySet()) {
+ String node = MonitorService.CONSUMER.equals(expand) ? "<--" : "-->";
+ rows.add(toRow(" |" + node + " " + entry.getKey(), entry.getValue()));
+ }
+ }
+ }
+ }
+ StringBuilder nav = new StringBuilder();
+ nav.append("<a href=\"services.html\">Services</a> > ");
+ nav.append(service);
+ nav.append(" > <a href=\"providers.html?service=");
+ nav.append(service);
+ nav.append("\">Providers</a> | <a href=\"consumers.html?service=");
+ nav.append(service);
+ nav.append("\">Consumers</a> | Statistics | <a href=\"charts.html?service=");
+ nav.append(service);
+ nav.append("&date=");
+ nav.append(date);
+ nav.append("\">Charts</a> > <input type=\"text\" style=\"width: 65px;\" name=\"date\" value=\"");
+ nav.append(date);
+ nav.append("\" onkeyup=\"if (event.keyCode == 10 || event.keyCode == 13) {window.location.href='statistics.html?service=");
+ nav.append(service);
+ if (expand != null && expand.length() > 0) {
+ nav.append("&expand=");
+ nav.append(expand);
+ }
+ nav.append("&date=' + this.value;}\" /> > ");
+ if (!MonitorService.PROVIDER.equals(expand) && !MonitorService.CONSUMER.equals(expand)) {
+ nav.append("Summary");
+ } else {
+ nav.append("<a href=\"statistics.html?service=");
+ nav.append(service);
+ nav.append("&date=");
+ nav.append(date);
+ nav.append("\">Summary</a>");
+ }
+ if (MonitorService.PROVIDER.equals(expand)) {
+ nav.append(" | +Provider");
+ } else {
+ nav.append(" | <a href=\"statistics.html?service=");
+ nav.append(service);
+ nav.append("&date=");
+ nav.append(date);
+ nav.append("&expand=provider\">+Provider</a>");
+ }
+ if (MonitorService.CONSUMER.equals(expand)) {
+ nav.append(" | +Consumer");
+ } else {
+ nav.append(" | <a href=\"statistics.html?service=");
+ nav.append(service);
+ nav.append("&date=");
+ nav.append(date);
+ nav.append("&expand=consumer\">+Consumer</a>");
+ }
+ return new Page(nav.toString(), "Statistics (" + rows.size() + ")",
+ new String[]{"Method:", "Success", "Failure", "Avg Elapsed (ms)",
+ "Max Elapsed (ms)", "Max Concurrent"}, rows);
+ }
+
+ private long[] newStatistics() {
+ return new long[10];
+ }
+
+ private void appendStatistics(File providerDir, long[] statistics) {
+ statistics[0] += CountUtils.sum(new File(providerDir, MonitorService.CONSUMER + "." + MonitorService.SUCCESS));
+ statistics[1] += CountUtils.sum(new File(providerDir, MonitorService.PROVIDER + "." + MonitorService.SUCCESS));
+ statistics[2] += CountUtils.sum(new File(providerDir, MonitorService.CONSUMER + "." + MonitorService.FAILURE));
+ statistics[3] += CountUtils.sum(new File(providerDir, MonitorService.PROVIDER + "." + MonitorService.FAILURE));
+ statistics[4] += CountUtils.sum(new File(providerDir, MonitorService.CONSUMER + "." + MonitorService.ELAPSED));
+ statistics[5] += CountUtils.sum(new File(providerDir, MonitorService.PROVIDER + "." + MonitorService.ELAPSED));
+ statistics[6] = Math.max(statistics[6], CountUtils.max(new File(providerDir, MonitorService.CONSUMER + "." + MonitorService.MAX_ELAPSED)));
+ statistics[7] = Math.max(statistics[7], CountUtils.max(new File(providerDir, MonitorService.PROVIDER + "." + MonitorService.MAX_ELAPSED)));
+ statistics[8] = Math.max(statistics[8], CountUtils.max(new File(providerDir, MonitorService.CONSUMER + "." + MonitorService.MAX_CONCURRENT)));
+ statistics[9] = Math.max(statistics[9], CountUtils.max(new File(providerDir, MonitorService.PROVIDER + "." + MonitorService.MAX_CONCURRENT)));
+ }
+
+ private List<String> toRow(String name, long[] statistics) {
+ List<String> row = new ArrayList<String>();
+ row.add(name);
+ row.add(String.valueOf(statistics[0]) + " --> " + String.valueOf(statistics[1]));
+ row.add(String.valueOf(statistics[2]) + " --> " + String.valueOf(statistics[3]));
+ row.add(String.valueOf(statistics[0] == 0 ? 0 : statistics[4] / statistics[0])
+ + " --> " + String.valueOf(statistics[1] == 0 ? 0 : statistics[5] / statistics[1]));
+ row.add(String.valueOf(statistics[6]) + " --> " + String.valueOf(statistics[7]));
+ row.add(String.valueOf(statistics[8]) + " --> " + String.valueOf(statistics[9]));
+ return row;
+ }
+
}
\ No newline at end of file
diff --git a/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/pages/UnregisterPageHandler.java b/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/pages/UnregisterPageHandler.java
index f873a1e3c5..0e466e22d3 100644
--- a/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/pages/UnregisterPageHandler.java
+++ b/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/pages/UnregisterPageHandler.java
@@ -1,49 +1,49 @@
-/*
- * 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.monitor.simple.pages;
-
-import com.alibaba.dubbo.common.URL;
-import com.alibaba.dubbo.container.page.Page;
-import com.alibaba.dubbo.container.page.PageHandler;
-import com.alibaba.dubbo.monitor.simple.RegistryContainer;
-
-/**
- * UnregisterPageHandler
- */
-public class UnregisterPageHandler implements PageHandler {
-
- public Page handle(URL url) {
- String provider = url.getParameterAndDecoded("provider");
- if (provider == null || provider.length() == 0) {
- throw new IllegalArgumentException("Please input provider parameter.");
- }
- URL providerUrl = URL.valueOf(provider);
- RegistryContainer.getInstance().getRegistry().unregister(providerUrl);
- String parameter;
- if (url.hasParameter("service")) {
- parameter = "service=" + url.getParameter("service");
- } else if (url.hasParameter("host")) {
- parameter = "host=" + url.getParameter("host");
- } else if (url.hasParameter("application")) {
- parameter = "application=" + url.getParameter("application");
- } else {
- parameter = "service=" + providerUrl.getServiceInterface();
- }
- return new Page("<script type=\"text/javascript\">window.location.href=\"providers.html?" + parameter + "\";</script>");
- }
-
-}
+/*
+ * 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.monitor.simple.pages;
+
+import com.alibaba.dubbo.common.URL;
+import com.alibaba.dubbo.container.page.Page;
+import com.alibaba.dubbo.container.page.PageHandler;
+import com.alibaba.dubbo.monitor.simple.RegistryContainer;
+
+/**
+ * UnregisterPageHandler
+ */
+public class UnregisterPageHandler implements PageHandler {
+
+ public Page handle(URL url) {
+ String provider = url.getParameterAndDecoded("provider");
+ if (provider == null || provider.length() == 0) {
+ throw new IllegalArgumentException("Please input provider parameter.");
+ }
+ URL providerUrl = URL.valueOf(provider);
+ RegistryContainer.getInstance().getRegistry().unregister(providerUrl);
+ String parameter;
+ if (url.hasParameter("service")) {
+ parameter = "service=" + url.getParameter("service");
+ } else if (url.hasParameter("host")) {
+ parameter = "host=" + url.getParameter("host");
+ } else if (url.hasParameter("application")) {
+ parameter = "application=" + url.getParameter("application");
+ } else {
+ parameter = "service=" + providerUrl.getServiceInterface();
+ }
+ return new Page("<script type=\"text/javascript\">window.location.href=\"providers.html?" + parameter + "\";</script>");
+ }
+
+}
diff --git a/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/pages/UnsubscribePageHandler.java b/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/pages/UnsubscribePageHandler.java
index 6fa1c9561f..a4aab7b360 100644
--- a/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/pages/UnsubscribePageHandler.java
+++ b/dubbo-simple/dubbo-monitor-simple/src/main/java/com/alibaba/dubbo/monitor/simple/pages/UnsubscribePageHandler.java
@@ -1,64 +1,64 @@
-/*
- * 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.monitor.simple.pages;
-
-import com.alibaba.dubbo.common.URL;
-import com.alibaba.dubbo.container.page.Page;
-import com.alibaba.dubbo.container.page.PageHandler;
-import com.alibaba.dubbo.monitor.simple.RegistryContainer;
-import com.alibaba.dubbo.registry.NotifyListener;
-
-import java.util.List;
-
-/**
- * UnsubscribePageHandler
- */
-public class UnsubscribePageHandler implements PageHandler {
-
- public Page handle(URL url) {
- String consumer = url.getParameterAndDecoded("consumer");
- if (consumer == null || consumer.length() == 0) {
- throw new IllegalArgumentException("Please input consumer parameter.");
- }
- URL consumerUrl = URL.valueOf(consumer);
- RegistryContainer.getInstance().getRegistry().unsubscribe(consumerUrl, NotifyListenerAdapter.NOTIFY_LISTENER);
- String parameter;
- if (url.hasParameter("service")) {
- parameter = "service=" + url.getParameter("service");
- } else if (url.hasParameter("host")) {
- parameter = "host=" + url.getParameter("host");
- } else if (url.hasParameter("application")) {
- parameter = "application=" + url.getParameter("application");
- } else {
- parameter = "service=" + consumerUrl.getServiceInterface();
- }
- return new Page("<script type=\"text/javascript\">window.location.href=\"consumers.html?" + parameter + "\";</script>");
- }
-
- private static class NotifyListenerAdapter implements NotifyListener {
-
- public static final NotifyListener NOTIFY_LISTENER = new NotifyListenerAdapter();
-
- private NotifyListenerAdapter() {
- }
-
- public void notify(List<URL> urls) {
- }
-
- }
-
-}
+/*
+ * 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.monitor.simple.pages;
+
+import com.alibaba.dubbo.common.URL;
+import com.alibaba.dubbo.container.page.Page;
+import com.alibaba.dubbo.container.page.PageHandler;
+import com.alibaba.dubbo.monitor.simple.RegistryContainer;
+import com.alibaba.dubbo.registry.NotifyListener;
+
+import java.util.List;
+
+/**
+ * UnsubscribePageHandler
+ */
+public class UnsubscribePageHandler implements PageHandler {
+
+ public Page handle(URL url) {
+ String consumer = url.getParameterAndDecoded("consumer");
+ if (consumer == null || consumer.length() == 0) {
+ throw new IllegalArgumentException("Please input consumer parameter.");
+ }
+ URL consumerUrl = URL.valueOf(consumer);
+ RegistryContainer.getInstance().getRegistry().unsubscribe(consumerUrl, NotifyListenerAdapter.NOTIFY_LISTENER);
+ String parameter;
+ if (url.hasParameter("service")) {
+ parameter = "service=" + url.getParameter("service");
+ } else if (url.hasParameter("host")) {
+ parameter = "host=" + url.getParameter("host");
+ } else if (url.hasParameter("application")) {
+ parameter = "application=" + url.getParameter("application");
+ } else {
+ parameter = "service=" + consumerUrl.getServiceInterface();
+ }
+ return new Page("<script type=\"text/javascript\">window.location.href=\"consumers.html?" + parameter + "\";</script>");
+ }
+
+ private static class NotifyListenerAdapter implements NotifyListener {
+
+ public static final NotifyListener NOTIFY_LISTENER = new NotifyListenerAdapter();
+
+ private NotifyListenerAdapter() {
+ }
+
+ public void notify(List<URL> urls) {
+ }
+
+ }
+
+}
diff --git a/dubbo-simple/dubbo-monitor-simple/src/main/resources/META-INF/dubbo/internal/com.alibaba.dubbo.container.page.PageHandler b/dubbo-simple/dubbo-monitor-simple/src/main/resources/META-INF/dubbo/internal/com.alibaba.dubbo.container.page.PageHandler
index 23404cc3d2..b9024446e4 100644
--- a/dubbo-simple/dubbo-monitor-simple/src/main/resources/META-INF/dubbo/internal/com.alibaba.dubbo.container.page.PageHandler
+++ b/dubbo-simple/dubbo-monitor-simple/src/main/resources/META-INF/dubbo/internal/com.alibaba.dubbo.container.page.PageHandler
@@ -1,10 +1,10 @@
-services=com.alibaba.dubbo.monitor.simple.pages.ServicesPageHandler
-providers=com.alibaba.dubbo.monitor.simple.pages.ProvidersPageHandler
-consumers=com.alibaba.dubbo.monitor.simple.pages.ConsumersPageHandler
-statistics=com.alibaba.dubbo.monitor.simple.pages.StatisticsPageHandler
-charts=com.alibaba.dubbo.monitor.simple.pages.ChartsPageHandler
-applications=com.alibaba.dubbo.monitor.simple.pages.ApplicationsPageHandler
-dependencies=com.alibaba.dubbo.monitor.simple.pages.DependenciesPageHandler
-hosts=com.alibaba.dubbo.monitor.simple.pages.HostsPageHandler
-unregister=com.alibaba.dubbo.monitor.simple.pages.UnregisterPageHandler
+services=com.alibaba.dubbo.monitor.simple.pages.ServicesPageHandler
+providers=com.alibaba.dubbo.monitor.simple.pages.ProvidersPageHandler
+consumers=com.alibaba.dubbo.monitor.simple.pages.ConsumersPageHandler
+statistics=com.alibaba.dubbo.monitor.simple.pages.StatisticsPageHandler
+charts=com.alibaba.dubbo.monitor.simple.pages.ChartsPageHandler
+applications=com.alibaba.dubbo.monitor.simple.pages.ApplicationsPageHandler
+dependencies=com.alibaba.dubbo.monitor.simple.pages.DependenciesPageHandler
+hosts=com.alibaba.dubbo.monitor.simple.pages.HostsPageHandler
+unregister=com.alibaba.dubbo.monitor.simple.pages.UnregisterPageHandler
unsubscribe=com.alibaba.dubbo.monitor.simple.pages.UnsubscribePageHandler
\ No newline at end of file
diff --git a/dubbo-simple/dubbo-monitor-simple/src/main/resources/META-INF/spring/dubbo-monitor-simple.xml b/dubbo-simple/dubbo-monitor-simple/src/main/resources/META-INF/spring/dubbo-monitor-simple.xml
index 985ffebb38..08ed624846 100644
--- a/dubbo-simple/dubbo-monitor-simple/src/main/resources/META-INF/spring/dubbo-monitor-simple.xml
+++ b/dubbo-simple/dubbo-monitor-simple/src/main/resources/META-INF/spring/dubbo-monitor-simple.xml
@@ -1,41 +1,41 @@
-<!--
-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.
--->
-<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
- xmlns="http://www.springframework.org/schema/beans"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
- http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
-
- <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
- <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE"/>
- <property name="location" value="classpath:dubbo.properties"/>
- </bean>
-
- <bean id="monitorService" class="com.alibaba.dubbo.monitor.simple.SimpleMonitorService">
- </bean>
-
- <dubbo:application name="${dubbo.application.name}" owner="${dubbo.application.owner}"/>
-
- <dubbo:registry address="${dubbo.registry.address}"/>
-
- <dubbo:protocol name="dubbo" port="${dubbo.protocol.port}"/>
-
- <dubbo:service interface="com.alibaba.dubbo.monitor.MonitorService" ref="monitorService" delay="-1"/>
-
- <dubbo:reference id="registryService" interface="com.alibaba.dubbo.registry.RegistryService"/>
-
+<!--
+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.
+-->
+<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
+ xmlns="http://www.springframework.org/schema/beans"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
+
+ <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
+ <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE"/>
+ <property name="location" value="classpath:dubbo.properties"/>
+ </bean>
+
+ <bean id="monitorService" class="com.alibaba.dubbo.monitor.simple.SimpleMonitorService">
+ </bean>
+
+ <dubbo:application name="${dubbo.application.name}" owner="${dubbo.application.owner}"/>
+
+ <dubbo:registry address="${dubbo.registry.address}"/>
+
+ <dubbo:protocol name="dubbo" port="${dubbo.protocol.port}"/>
+
+ <dubbo:service interface="com.alibaba.dubbo.monitor.MonitorService" ref="monitorService" delay="-1"/>
+
+ <dubbo:reference id="registryService" interface="com.alibaba.dubbo.registry.RegistryService"/>
+
</beans>
\ No newline at end of file
diff --git a/dubbo-simple/dubbo-monitor-simple/src/test/java/com/alibaba/dubbo/monitor/simple/SimpleMonitor.java b/dubbo-simple/dubbo-monitor-simple/src/test/java/com/alibaba/dubbo/monitor/simple/SimpleMonitor.java
index 0c368a6d24..777e281add 100644
--- a/dubbo-simple/dubbo-monitor-simple/src/test/java/com/alibaba/dubbo/monitor/simple/SimpleMonitor.java
+++ b/dubbo-simple/dubbo-monitor-simple/src/test/java/com/alibaba/dubbo/monitor/simple/SimpleMonitor.java
@@ -1,25 +1,25 @@
-/*
- * 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.monitor.simple;
-
-public class SimpleMonitor {
-
- public static void main(String[] args) {
- com.alibaba.dubbo.container.Main.main(args);
- }
-
+/*
+ * 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.monitor.simple;
+
+public class SimpleMonitor {
+
+ public static void main(String[] args) {
+ com.alibaba.dubbo.container.Main.main(args);
+ }
+
}
\ No newline at end of file
diff --git a/dubbo-simple/dubbo-monitor-simple/src/test/java/com/alibaba/dubbo/monitor/simple/SimpleMonitorServiceTest.java b/dubbo-simple/dubbo-monitor-simple/src/test/java/com/alibaba/dubbo/monitor/simple/SimpleMonitorServiceTest.java
index 2f4cea1a43..58549e0760 100644
--- a/dubbo-simple/dubbo-monitor-simple/src/test/java/com/alibaba/dubbo/monitor/simple/SimpleMonitorServiceTest.java
+++ b/dubbo-simple/dubbo-monitor-simple/src/test/java/com/alibaba/dubbo/monitor/simple/SimpleMonitorServiceTest.java
@@ -1,34 +1,34 @@
-/*
- * 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.monitor.simple;
-
-import com.alibaba.dubbo.common.URL;
-import com.alibaba.dubbo.common.utils.NetUtils;
-
-import org.junit.Test;
-
-/**
- * SimpleMonitorServiceTest
- */
-public class SimpleMonitorServiceTest {
-
- @Test
- public void testMonitor() {
- new SimpleMonitorService().collect(new URL("dubbo", NetUtils.getLocalHost(), 0));
- }
-
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.alibaba.dubbo.monitor.simple;
+
+import com.alibaba.dubbo.common.URL;
+import com.alibaba.dubbo.common.utils.NetUtils;
+
+import org.junit.Test;
+
+/**
+ * SimpleMonitorServiceTest
+ */
+public class SimpleMonitorServiceTest {
+
+ @Test
+ public void testMonitor() {
+ new SimpleMonitorService().collect(new URL("dubbo", NetUtils.getLocalHost(), 0));
+ }
+
}
\ No newline at end of file
diff --git a/dubbo-simple/dubbo-monitor-simple/src/test/resources/dubbo.properties b/dubbo-simple/dubbo-monitor-simple/src/test/resources/dubbo.properties
index 1ceed04365..ffe17639e4 100644
--- a/dubbo-simple/dubbo-monitor-simple/src/test/resources/dubbo.properties
+++ b/dubbo-simple/dubbo-monitor-simple/src/test/resources/dubbo.properties
@@ -1,29 +1,29 @@
-# 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.
-
-dubbo.container=log4j,spring,registry,jetty
-dubbo.application.name=simple-monitor
-dubbo.application.owner=
-dubbo.registry.address=multicast://224.5.6.7:1234
-#dubbo.registry.address=zookeeper://127.0.0.1:2181
-#dubbo.registry.address=redis://127.0.0.1:6379
-#dubbo.registry.address=dubbo://127.0.0.1:9090
-dubbo.protocol.port=7070
-dubbo.jetty.port=8080
-dubbo.jetty.directory=${user.home}/monitor
-dubbo.charts.directory=${dubbo.jetty.directory}/charts
-dubbo.statistics.directory=${user.home}/monitor/statistics
-#dubbo.log4j.file=logs/dubbo-demo-consumer.log
+# 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.
+
+dubbo.container=log4j,spring,registry,jetty
+dubbo.application.name=simple-monitor
+dubbo.application.owner=
+dubbo.registry.address=multicast://224.5.6.7:1234
+#dubbo.registry.address=zookeeper://127.0.0.1:2181
+#dubbo.registry.address=redis://127.0.0.1:6379
+#dubbo.registry.address=dubbo://127.0.0.1:9090
+dubbo.protocol.port=7070
+dubbo.jetty.port=8080
+dubbo.jetty.directory=${user.home}/monitor
+dubbo.charts.directory=${dubbo.jetty.directory}/charts
+dubbo.statistics.directory=${user.home}/monitor/statistics
+#dubbo.log4j.file=logs/dubbo-demo-consumer.log
#dubbo.log4j.level=WARN
\ No newline at end of file
diff --git a/dubbo-simple/dubbo-monitor-simple/src/test/resources/log4j.xml b/dubbo-simple/dubbo-monitor-simple/src/test/resources/log4j.xml
index ca35ef1144..230a0447c4 100644
--- a/dubbo-simple/dubbo-monitor-simple/src/test/resources/log4j.xml
+++ b/dubbo-simple/dubbo-monitor-simple/src/test/resources/log4j.xml
@@ -1,29 +1,29 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-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.
--->
-<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
-<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
- <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
- <layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern" value="[%d{dd/MM/yy hh:mm:ss:sss z}] %t %5p %c{2}: %m%n"/>
- </layout>
- </appender>
- <root>
- <level value="INFO"/>
- <appender-ref ref="CONSOLE"/>
- </root>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+ <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="[%d{dd/MM/yy hh:mm:ss:sss z}] %t %5p %c{2}: %m%n"/>
+ </layout>
+ </appender>
+ <root>
+ <level value="INFO"/>
+ <appender-ref ref="CONSOLE"/>
+ </root>
</log4j:configuration>
\ No newline at end of file
diff --git a/dubbo-simple/dubbo-registry-simple/pom.xml b/dubbo-simple/dubbo-registry-simple/pom.xml
index b72506081e..175d6aa722 100644
--- a/dubbo-simple/dubbo-registry-simple/pom.xml
+++ b/dubbo-simple/dubbo-registry-simple/pom.xml
@@ -1,85 +1,85 @@
-<!--
-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.
--->
-<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>com.alibaba</groupId>
- <artifactId>dubbo-simple</artifactId>
- <version>2.5.10</version>
- </parent>
- <artifactId>dubbo-registry-simple</artifactId>
- <packaging>jar</packaging>
- <name>${project.artifactId}</name>
- <description>The simple registry module of dubbo project</description>
- <properties>
- <skip_maven_deploy>false</skip_maven_deploy>
- </properties>
- <dependencies>
- <dependency>
- <groupId>com.alibaba</groupId>
- <artifactId>dubbo</artifactId>
- <version>${project.parent.version}</version>
- </dependency>
- <dependency>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>jetty</artifactId>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>unpack</id>
- <phase>package</phase>
- <goals>
- <goal>unpack</goal>
- </goals>
- <configuration>
- <artifactItems>
- <artifactItem>
- <groupId>com.alibaba</groupId>
- <artifactId>dubbo</artifactId>
- <version>${project.parent.version}</version>
- <outputDirectory>${project.build.directory}/dubbo</outputDirectory>
- <includes>META-INF/assembly/**</includes>
- </artifactItem>
- </artifactItems>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <configuration>
- <descriptor>src/main/assembly/assembly.xml</descriptor>
- </configuration>
- <executions>
- <execution>
- <id>make-assembly</id>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
+<!--
+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.
+-->
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>com.alibaba</groupId>
+ <artifactId>dubbo-simple</artifactId>
+ <version>2.5.11</version>
+ </parent>
+ <artifactId>dubbo-registry-simple</artifactId>
+ <packaging>jar</packaging>
+ <name>${project.artifactId}</name>
+ <description>The simple registry module of dubbo project</description>
+ <properties>
+ <skip_maven_deploy>false</skip_maven_deploy>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>com.alibaba</groupId>
+ <artifactId>dubbo</artifactId>
+ <version>${project.parent.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty</artifactId>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>unpack</id>
+ <phase>package</phase>
+ <goals>
+ <goal>unpack</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>com.alibaba</groupId>
+ <artifactId>dubbo</artifactId>
+ <version>${project.parent.version}</version>
+ <outputDirectory>${project.build.directory}/dubbo</outputDirectory>
+ <includes>META-INF/assembly/**</includes>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <descriptor>src/main/assembly/assembly.xml</descriptor>
+ </configuration>
+ <executions>
+ <execution>
+ <id>make-assembly</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
</project>
\ No newline at end of file
diff --git a/dubbo-simple/dubbo-registry-simple/src/main/assembly/assembly.xml b/dubbo-simple/dubbo-registry-simple/src/main/assembly/assembly.xml
index 3942e38447..e2b58f1967 100644
--- a/dubbo-simple/dubbo-registry-simple/src/main/assembly/assembly.xml
+++ b/dubbo-simple/dubbo-registry-simple/src/main/assembly/assembly.xml
@@ -1,40 +1,40 @@
-<!--
-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.
--->
-<assembly>
- <id>assembly</id>
- <formats>
- <format>tar.gz</format>
- </formats>
- <includeBaseDirectory>true</includeBaseDirectory>
- <fileSets>
- <fileSet>
- <directory>${project.build.directory}/dubbo/META-INF/assembly/bin</directory>
- <outputDirectory>bin</outputDirectory>
- <fileMode>0755</fileMode>
- </fileSet>
- <fileSet>
- <directory>src/main/assembly/conf</directory>
- <outputDirectory>conf</outputDirectory>
- <fileMode>0644</fileMode>
- </fileSet>
- </fileSets>
- <dependencySets>
- <dependencySet>
- <outputDirectory>lib</outputDirectory>
- </dependencySet>
- </dependencySets>
+<!--
+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.
+-->
+<assembly>
+ <id>assembly</id>
+ <formats>
+ <format>tar.gz</format>
+ </formats>
+ <includeBaseDirectory>true</includeBaseDirectory>
+ <fileSets>
+ <fileSet>
+ <directory>${project.build.directory}/dubbo/META-INF/assembly/bin</directory>
+ <outputDirectory>bin</outputDirectory>
+ <fileMode>0755</fileMode>
+ </fileSet>
+ <fileSet>
+ <directory>src/main/assembly/conf</directory>
+ <outputDirectory>conf</outputDirectory>
+ <fileMode>0644</fileMode>
+ </fileSet>
+ </fileSets>
+ <dependencySets>
+ <dependencySet>
+ <outputDirectory>lib</outputDirectory>
+ </dependencySet>
+ </dependencySets>
</assembly>
\ No newline at end of file
diff --git a/dubbo-simple/dubbo-registry-simple/src/main/assembly/conf/dubbo.properties b/dubbo-simple/dubbo-registry-simple/src/main/assembly/conf/dubbo.properties
index 96f1382ad3..28644fc062 100644
--- a/dubbo-simple/dubbo-registry-simple/src/main/assembly/conf/dubbo.properties
+++ b/dubbo-simple/dubbo-registry-simple/src/main/assembly/conf/dubbo.properties
@@ -1,21 +1,21 @@
-# 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.
-
-dubbo.container=log4j,spring
-dubbo.application.name=simple-registry
-dubbo.application.owner=
-dubbo.protocol.port=9090
-dubbo.log4j.file=logs/dubbo-simple-registry.log
+# 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.
+
+dubbo.container=log4j,spring
+dubbo.application.name=simple-registry
+dubbo.application.owner=
+dubbo.protocol.port=9090
+dubbo.log4j.file=logs/dubbo-simple-registry.log
dubbo.log4j.level=WARN
\ No newline at end of file
diff --git a/dubbo-simple/dubbo-registry-simple/src/main/java/com/alibaba/dubbo/registry/simple/SimpleRegistryService.java b/dubbo-simple/dubbo-registry-simple/src/main/java/com/alibaba/dubbo/registry/simple/SimpleRegistryService.java
index f75415220a..c8e8af9db6 100644
--- a/dubbo-simple/dubbo-registry-simple/src/main/java/com/alibaba/dubbo/registry/simple/SimpleRegistryService.java
+++ b/dubbo-simple/dubbo-registry-simple/src/main/java/com/alibaba/dubbo/registry/simple/SimpleRegistryService.java
@@ -1,209 +1,209 @@
-/*
- * 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.registry.simple;
-
-import com.alibaba.dubbo.common.Constants;
-import com.alibaba.dubbo.common.URL;
-import com.alibaba.dubbo.common.logger.Logger;
-import com.alibaba.dubbo.common.logger.LoggerFactory;
-import com.alibaba.dubbo.common.utils.ConcurrentHashSet;
-import com.alibaba.dubbo.common.utils.NetUtils;
-import com.alibaba.dubbo.common.utils.UrlUtils;
-import com.alibaba.dubbo.registry.NotifyListener;
-import com.alibaba.dubbo.registry.RegistryService;
-import com.alibaba.dubbo.registry.support.AbstractRegistry;
-import com.alibaba.dubbo.rpc.RpcContext;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-/**
- * SimpleRegistryService
- */
-public class SimpleRegistryService extends AbstractRegistry {
-
- private final static Logger logger = LoggerFactory.getLogger(SimpleRegistryService.class);
- private final ConcurrentMap<String, Set<URL>> remoteRegistered = new ConcurrentHashMap<String, Set<URL>>();
- private final ConcurrentMap<String, ConcurrentMap<URL, Set<NotifyListener>>> remoteSubscribed = new ConcurrentHashMap<String, ConcurrentMap<URL, Set<NotifyListener>>>();
-
- public SimpleRegistryService() {
- super(new URL("dubbo", NetUtils.getLocalHost(), 0, RegistryService.class.getName(), "file", "N/A"));
- }
-
- public boolean isAvailable() {
- return true;
- }
-
- public List<URL> lookup(URL url) {
- List<URL> urls = new ArrayList<URL>();
- for (URL u : getRegistered()) {
- if (UrlUtils.isMatch(url, u)) {
- urls.add(u);
- }
- }
- return urls;
- }
-
- public void register(URL url) {
- String client = RpcContext.getContext().getRemoteAddressString();
- Set<URL> urls = remoteRegistered.get(client);
- if (urls == null) {
- remoteRegistered.putIfAbsent(client, new ConcurrentHashSet<URL>());
- urls = remoteRegistered.get(client);
- }
- urls.add(url);
- super.register(url);
- registered(url);
- }
-
- public void unregister(URL url) {
- String client = RpcContext.getContext().getRemoteAddressString();
- Set<URL> urls = remoteRegistered.get(client);
- if (urls != null && urls.size() > 0) {
- urls.remove(url);
- }
- super.unregister(url);
- unregistered(url);
- }
-
- public void subscribe(URL url, NotifyListener listener) {
- if (getUrl().getPort() == 0) {
- URL registryUrl = RpcContext.getContext().getUrl();
- if (registryUrl != null && registryUrl.getPort() > 0
- && RegistryService.class.getName().equals(registryUrl.getPath())) {
- super.setUrl(registryUrl);
- super.register(registryUrl);
- }
- }
- String client = RpcContext.getContext().getRemoteAddressString();
- ConcurrentMap<URL, Set<NotifyListener>> clientListeners = remoteSubscribed.get(client);
- if (clientListeners == null) {
- remoteSubscribed.putIfAbsent(client, new ConcurrentHashMap<URL, Set<NotifyListener>>());
- clientListeners = remoteSubscribed.get(client);
- }
- Set<NotifyListener> listeners = clientListeners.get(url);
- if (listeners == null) {
- clientListeners.putIfAbsent(url, new ConcurrentHashSet<NotifyListener>());
- listeners = clientListeners.get(url);
- }
- listeners.add(listener);
- super.subscribe(url, listener);
- subscribed(url, listener);
- }
-
- public void unsubscribe(URL url, NotifyListener listener) {
- if (!Constants.ANY_VALUE.equals(url.getServiceInterface())
- && url.getParameter(Constants.REGISTER_KEY, true)) {
- unregister(url);
- }
- String client = RpcContext.getContext().getRemoteAddressString();
- Map<URL, Set<NotifyListener>> clientListeners = remoteSubscribed.get(client);
- if (clientListeners != null && clientListeners.size() > 0) {
- Set<NotifyListener> listeners = clientListeners.get(url);
- if (listeners != null && listeners.size() > 0) {
- listeners.remove(listener);
- }
- }
- }
-
- protected void registered(URL url) {
- for (Map.Entry<URL, Set<NotifyListener>> entry : getSubscribed().entrySet()) {
- URL key = entry.getKey();
- if (UrlUtils.isMatch(key, url)) {
- List<URL> list = lookup(key);
- for (NotifyListener listener : entry.getValue()) {
- listener.notify(list);
- }
- }
- }
- }
-
- protected void unregistered(URL url) {
- for (Map.Entry<URL, Set<NotifyListener>> entry : getSubscribed().entrySet()) {
- URL key = entry.getKey();
- if (UrlUtils.isMatch(key, url)) {
- List<URL> list = lookup(key);
- for (NotifyListener listener : entry.getValue()) {
- listener.notify(list);
- }
- }
- }
- }
-
- protected void subscribed(final URL url, final NotifyListener listener) {
- if (Constants.ANY_VALUE.equals(url.getServiceInterface())) {
- new Thread(new Runnable() {
- public void run() {
- Map<String, List<URL>> map = new HashMap<String, List<URL>>();
- for (URL u : getRegistered()) {
- if (UrlUtils.isMatch(url, u)) {
- String service = u.getServiceInterface();
- List<URL> list = map.get(service);
- if (list == null) {
- list = new ArrayList<URL>();
- map.put(service, list);
- }
- list.add(u);
- }
- }
- for (List<URL> list : map.values()) {
- try {
- listener.notify(list);
- } catch (Throwable e) {
- logger.warn("Discard to notify " + url.getServiceKey() + " to listener " + listener);
- }
- }
- }
- }, "DubboMonitorNotifier").start();
- } else {
- List<URL> list = lookup(url);
- try {
- listener.notify(list);
- } catch (Throwable e) {
- logger.warn("Discard to notify " + url.getServiceKey() + " to listener " + listener);
- }
- }
- }
-
- public void disconnect() {
- String client = RpcContext.getContext().getRemoteAddressString();
- if (logger.isInfoEnabled()) {
- logger.info("Disconnected " + client);
- }
- Set<URL> urls = remoteRegistered.get(client);
- if (urls != null && urls.size() > 0) {
- for (URL url : urls) {
- unregister(url);
- }
- }
- Map<URL, Set<NotifyListener>> listeners = remoteSubscribed.get(client);
- if (listeners != null && listeners.size() > 0) {
- for (Map.Entry<URL, Set<NotifyListener>> entry : listeners.entrySet()) {
- URL url = entry.getKey();
- for (NotifyListener listener : entry.getValue()) {
- unsubscribe(url, listener);
- }
- }
- }
- }
-
+/*
+ * 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.registry.simple;
+
+import com.alibaba.dubbo.common.Constants;
+import com.alibaba.dubbo.common.URL;
+import com.alibaba.dubbo.common.logger.Logger;
+import com.alibaba.dubbo.common.logger.LoggerFactory;
+import com.alibaba.dubbo.common.utils.ConcurrentHashSet;
+import com.alibaba.dubbo.common.utils.NetUtils;
+import com.alibaba.dubbo.common.utils.UrlUtils;
+import com.alibaba.dubbo.registry.NotifyListener;
+import com.alibaba.dubbo.registry.RegistryService;
+import com.alibaba.dubbo.registry.support.AbstractRegistry;
+import com.alibaba.dubbo.rpc.RpcContext;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+/**
+ * SimpleRegistryService
+ */
+public class SimpleRegistryService extends AbstractRegistry {
+
+ private final static Logger logger = LoggerFactory.getLogger(SimpleRegistryService.class);
+ private final ConcurrentMap<String, Set<URL>> remoteRegistered = new ConcurrentHashMap<String, Set<URL>>();
+ private final ConcurrentMap<String, ConcurrentMap<URL, Set<NotifyListener>>> remoteSubscribed = new ConcurrentHashMap<String, ConcurrentMap<URL, Set<NotifyListener>>>();
+
+ public SimpleRegistryService() {
+ super(new URL("dubbo", NetUtils.getLocalHost(), 0, RegistryService.class.getName(), "file", "N/A"));
+ }
+
+ public boolean isAvailable() {
+ return true;
+ }
+
+ public List<URL> lookup(URL url) {
+ List<URL> urls = new ArrayList<URL>();
+ for (URL u : getRegistered()) {
+ if (UrlUtils.isMatch(url, u)) {
+ urls.add(u);
+ }
+ }
+ return urls;
+ }
+
+ public void register(URL url) {
+ String client = RpcContext.getContext().getRemoteAddressString();
+ Set<URL> urls = remoteRegistered.get(client);
+ if (urls == null) {
+ remoteRegistered.putIfAbsent(client, new ConcurrentHashSet<URL>());
+ urls = remoteRegistered.get(client);
+ }
+ urls.add(url);
+ super.register(url);
+ registered(url);
+ }
+
+ public void unregister(URL url) {
+ String client = RpcContext.getContext().getRemoteAddressString();
+ Set<URL> urls = remoteRegistered.get(client);
+ if (urls != null && urls.size() > 0) {
+ urls.remove(url);
+ }
+ super.unregister(url);
+ unregistered(url);
+ }
+
+ public void subscribe(URL url, NotifyListener listener) {
+ if (getUrl().getPort() == 0) {
+ URL registryUrl = RpcContext.getContext().getUrl();
+ if (registryUrl != null && registryUrl.getPort() > 0
+ && RegistryService.class.getName().equals(registryUrl.getPath())) {
+ super.setUrl(registryUrl);
+ super.register(registryUrl);
+ }
+ }
+ String client = RpcContext.getContext().getRemoteAddressString();
+ ConcurrentMap<URL, Set<NotifyListener>> clientListeners = remoteSubscribed.get(client);
+ if (clientListeners == null) {
+ remoteSubscribed.putIfAbsent(client, new ConcurrentHashMap<URL, Set<NotifyListener>>());
+ clientListeners = remoteSubscribed.get(client);
+ }
+ Set<NotifyListener> listeners = clientListeners.get(url);
+ if (listeners == null) {
+ clientListeners.putIfAbsent(url, new ConcurrentHashSet<NotifyListener>());
+ listeners = clientListeners.get(url);
+ }
+ listeners.add(listener);
+ super.subscribe(url, listener);
+ subscribed(url, listener);
+ }
+
+ public void unsubscribe(URL url, NotifyListener listener) {
+ if (!Constants.ANY_VALUE.equals(url.getServiceInterface())
+ && url.getParameter(Constants.REGISTER_KEY, true)) {
+ unregister(url);
+ }
+ String client = RpcContext.getContext().getRemoteAddressString();
+ Map<URL, Set<NotifyListener>> clientListeners = remoteSubscribed.get(client);
+ if (clientListeners != null && clientListeners.size() > 0) {
+ Set<NotifyListener> listeners = clientListeners.get(url);
+ if (listeners != null && listeners.size() > 0) {
+ listeners.remove(listener);
+ }
+ }
+ }
+
+ protected void registered(URL url) {
+ for (Map.Entry<URL, Set<NotifyListener>> entry : getSubscribed().entrySet()) {
+ URL key = entry.getKey();
+ if (UrlUtils.isMatch(key, url)) {
+ List<URL> list = lookup(key);
+ for (NotifyListener listener : entry.getValue()) {
+ listener.notify(list);
+ }
+ }
+ }
+ }
+
+ protected void unregistered(URL url) {
+ for (Map.Entry<URL, Set<NotifyListener>> entry : getSubscribed().entrySet()) {
+ URL key = entry.getKey();
+ if (UrlUtils.isMatch(key, url)) {
+ List<URL> list = lookup(key);
+ for (NotifyListener listener : entry.getValue()) {
+ listener.notify(list);
+ }
+ }
+ }
+ }
+
+ protected void subscribed(final URL url, final NotifyListener listener) {
+ if (Constants.ANY_VALUE.equals(url.getServiceInterface())) {
+ new Thread(new Runnable() {
+ public void run() {
+ Map<String, List<URL>> map = new HashMap<String, List<URL>>();
+ for (URL u : getRegistered()) {
+ if (UrlUtils.isMatch(url, u)) {
+ String service = u.getServiceInterface();
+ List<URL> list = map.get(service);
+ if (list == null) {
+ list = new ArrayList<URL>();
+ map.put(service, list);
+ }
+ list.add(u);
+ }
+ }
+ for (List<URL> list : map.values()) {
+ try {
+ listener.notify(list);
+ } catch (Throwable e) {
+ logger.warn("Discard to notify " + url.getServiceKey() + " to listener " + listener);
+ }
+ }
+ }
+ }, "DubboMonitorNotifier").start();
+ } else {
+ List<URL> list = lookup(url);
+ try {
+ listener.notify(list);
+ } catch (Throwable e) {
+ logger.warn("Discard to notify " + url.getServiceKey() + " to listener " + listener);
+ }
+ }
+ }
+
+ public void disconnect() {
+ String client = RpcContext.getContext().getRemoteAddressString();
+ if (logger.isInfoEnabled()) {
+ logger.info("Disconnected " + client);
+ }
+ Set<URL> urls = remoteRegistered.get(client);
+ if (urls != null && urls.size() > 0) {
+ for (URL url : urls) {
+ unregister(url);
+ }
+ }
+ Map<URL, Set<NotifyListener>> listeners = remoteSubscribed.get(client);
+ if (listeners != null && listeners.size() > 0) {
+ for (Map.Entry<URL, Set<NotifyListener>> entry : listeners.entrySet()) {
+ URL url = entry.getKey();
+ for (NotifyListener listener : entry.getValue()) {
+ unsubscribe(url, listener);
+ }
+ }
+ }
+ }
+
}
\ No newline at end of file
diff --git a/dubbo-simple/dubbo-registry-simple/src/main/resources/META-INF/spring/dubbo-registry-simple.xml b/dubbo-simple/dubbo-registry-simple/src/main/resources/META-INF/spring/dubbo-registry-simple.xml
index 3c702f3eb7..8be8861b59 100644
--- a/dubbo-simple/dubbo-registry-simple/src/main/resources/META-INF/spring/dubbo-registry-simple.xml
+++ b/dubbo-simple/dubbo-registry-simple/src/main/resources/META-INF/spring/dubbo-registry-simple.xml
@@ -1,45 +1,45 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-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.
--->
-<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
- xmlns="http://www.springframework.org/schema/beans"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
- http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
-
- <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
- <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE"/>
- <property name="location" value="classpath:dubbo.properties"/>
- </bean>
-
- <dubbo:application name="${dubbo.application.name}" owner="${dubbo.application.owner}"/>
-
- <dubbo:protocol name="dubbo" port="${dubbo.protocol.port}" heartbeat="180000"/>
-
- <dubbo:service id="registryServiceConfig" interface="com.alibaba.dubbo.registry.RegistryService"
- ref="registryService" registry="N/A" ondisconnect="disconnect" callbacks="1000">
- <dubbo:method name="subscribe">
- <dubbo:argument index="1" callback="true"/>
- </dubbo:method>
- <dubbo:method name="unsubscribe">
- <dubbo:argument index="1" callback="false"/>
- </dubbo:method>
- </dubbo:service>
-
- <bean id="registryService" class="com.alibaba.dubbo.registry.simple.SimpleRegistryService"/>
-
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
+ xmlns="http://www.springframework.org/schema/beans"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
+
+ <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
+ <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE"/>
+ <property name="location" value="classpath:dubbo.properties"/>
+ </bean>
+
+ <dubbo:application name="${dubbo.application.name}" owner="${dubbo.application.owner}"/>
+
+ <dubbo:protocol name="dubbo" port="${dubbo.protocol.port}" heartbeat="180000"/>
+
+ <dubbo:service id="registryServiceConfig" interface="com.alibaba.dubbo.registry.RegistryService"
+ ref="registryService" registry="N/A" ondisconnect="disconnect" callbacks="1000">
+ <dubbo:method name="subscribe">
+ <dubbo:argument index="1" callback="true"/>
+ </dubbo:method>
+ <dubbo:method name="unsubscribe">
+ <dubbo:argument index="1" callback="false"/>
+ </dubbo:method>
+ </dubbo:service>
+
+ <bean id="registryService" class="com.alibaba.dubbo.registry.simple.SimpleRegistryService"/>
+
</beans>
\ No newline at end of file
diff --git a/dubbo-simple/dubbo-registry-simple/src/test/java/com/alibaba/dubbo/registry/simple/SimpleRegistry.java b/dubbo-simple/dubbo-registry-simple/src/test/java/com/alibaba/dubbo/registry/simple/SimpleRegistry.java
index 5f123ea225..c7b1d9a533 100644
--- a/dubbo-simple/dubbo-registry-simple/src/test/java/com/alibaba/dubbo/registry/simple/SimpleRegistry.java
+++ b/dubbo-simple/dubbo-registry-simple/src/test/java/com/alibaba/dubbo/registry/simple/SimpleRegistry.java
@@ -1,25 +1,25 @@
-/*
- * 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.registry.simple;
-
-public class SimpleRegistry {
-
- public static void main(String[] args) {
- com.alibaba.dubbo.container.Main.main(args);
- }
-
+/*
+ * 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.registry.simple;
+
+public class SimpleRegistry {
+
+ public static void main(String[] args) {
+ com.alibaba.dubbo.container.Main.main(args);
+ }
+
}
\ No newline at end of file
diff --git a/dubbo-simple/dubbo-registry-simple/src/test/java/com/alibaba/dubbo/registry/simple/SimpleRegistryServiceTest.java b/dubbo-simple/dubbo-registry-simple/src/test/java/com/alibaba/dubbo/registry/simple/SimpleRegistryServiceTest.java
index 88bc5eadf8..f008a7515a 100644
--- a/dubbo-simple/dubbo-registry-simple/src/test/java/com/alibaba/dubbo/registry/simple/SimpleRegistryServiceTest.java
+++ b/dubbo-simple/dubbo-registry-simple/src/test/java/com/alibaba/dubbo/registry/simple/SimpleRegistryServiceTest.java
@@ -1,31 +1,31 @@
-/*
- * 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.registry.simple;
-
-import org.junit.Test;
-
-/**
- * SimpleRegistryServiceTest
- */
-public class SimpleRegistryServiceTest {
-
- @Test
- public void testRegistry() {
- new SimpleRegistryService();
- }
-
+/*
+ * 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.registry.simple;
+
+import org.junit.Test;
+
+/**
+ * SimpleRegistryServiceTest
+ */
+public class SimpleRegistryServiceTest {
+
+ @Test
+ public void testRegistry() {
+ new SimpleRegistryService();
+ }
+
}
\ No newline at end of file
diff --git a/dubbo-simple/dubbo-registry-simple/src/test/resources/dubbo.properties b/dubbo-simple/dubbo-registry-simple/src/test/resources/dubbo.properties
index 7d4fae5828..6add99799a 100644
--- a/dubbo-simple/dubbo-registry-simple/src/test/resources/dubbo.properties
+++ b/dubbo-simple/dubbo-registry-simple/src/test/resources/dubbo.properties
@@ -1,21 +1,21 @@
-# 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.
-
-dubbo.container=log4j,spring
-dubbo.application.name=simple-registry
-dubbo.application.owner=
-dubbo.protocol.port=9090
-#dubbo.log4j.file=logs/dubbo-demo-consumer.log
+# 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.
+
+dubbo.container=log4j,spring
+dubbo.application.name=simple-registry
+dubbo.application.owner=
+dubbo.protocol.port=9090
+#dubbo.log4j.file=logs/dubbo-demo-consumer.log
#dubbo.log4j.level=WARN
\ No newline at end of file
diff --git a/dubbo-simple/dubbo-registry-simple/src/test/resources/log4j.xml b/dubbo-simple/dubbo-registry-simple/src/test/resources/log4j.xml
index ca35ef1144..230a0447c4 100644
--- a/dubbo-simple/dubbo-registry-simple/src/test/resources/log4j.xml
+++ b/dubbo-simple/dubbo-registry-simple/src/test/resources/log4j.xml
@@ -1,29 +1,29 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-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.
--->
-<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
-<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
- <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
- <layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern" value="[%d{dd/MM/yy hh:mm:ss:sss z}] %t %5p %c{2}: %m%n"/>
- </layout>
- </appender>
- <root>
- <level value="INFO"/>
- <appender-ref ref="CONSOLE"/>
- </root>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+ <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="[%d{dd/MM/yy hh:mm:ss:sss z}] %t %5p %c{2}: %m%n"/>
+ </layout>
+ </appender>
+ <root>
+ <level value="INFO"/>
+ <appender-ref ref="CONSOLE"/>
+ </root>
</log4j:configuration>
\ No newline at end of file
diff --git a/dubbo-simple/pom.xml b/dubbo-simple/pom.xml
index 08193e4541..2ab7fc7fea 100644
--- a/dubbo-simple/pom.xml
+++ b/dubbo-simple/pom.xml
@@ -1,36 +1,36 @@
-<!--
-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.
--->
-<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>com.alibaba</groupId>
- <artifactId>dubbo-parent</artifactId>
- <version>2.5.10</version>
- </parent>
- <artifactId>dubbo-simple</artifactId>
- <packaging>pom</packaging>
- <name>${project.artifactId}</name>
- <description>The simple implementation module of dubbo project</description>
- <properties>
- <skip_maven_deploy>true</skip_maven_deploy>
- </properties>
- <modules>
- <module>dubbo-registry-simple</module>
- <module>dubbo-monitor-simple</module>
- </modules>
-</project>
+<!--
+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.
+-->
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>com.alibaba</groupId>
+ <artifactId>dubbo-parent</artifactId>
+ <version>2.5.11</version>
+ </parent>
+ <artifactId>dubbo-simple</artifactId>
+ <packaging>pom</packaging>
+ <name>${project.artifactId}</name>
+ <description>The simple implementation module of dubbo project</description>
+ <properties>
+ <skip_maven_deploy>true</skip_maven_deploy>
+ </properties>
+ <modules>
+ <module>dubbo-registry-simple</module>
+ <module>dubbo-monitor-simple</module>
+ </modules>
+</project>
diff --git a/dubbo-test/dubbo-test-benchmark/pom.xml b/dubbo-test/dubbo-test-benchmark/pom.xml
index fd93559767..b5922c204a 100644
--- a/dubbo-test/dubbo-test-benchmark/pom.xml
+++ b/dubbo-test/dubbo-test-benchmark/pom.xml
@@ -20,7 +20,7 @@ limitations under the License.
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-test</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>dubbo-test-benchmark</artifactId>
<packaging>jar</packaging>
diff --git a/dubbo-test/dubbo-test-benchmark/src/test/backup/Dubbo.java b/dubbo-test/dubbo-test-benchmark/src/test/backup/Dubbo.java
index 3660011f5f..a97ee2e287 100644
--- a/dubbo-test/dubbo-test-benchmark/src/test/backup/Dubbo.java
+++ b/dubbo-test/dubbo-test-benchmark/src/test/backup/Dubbo.java
@@ -1,64 +1,64 @@
-/*
- * 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.dubbo.serialize.benchmark;
-
-import com.alibaba.dubbo.common.io.UnsafeByteArrayOutputStream;
-import com.alibaba.dubbo.common.serialize.support.dubbo.GenericObjectInput;
-import com.alibaba.dubbo.common.serialize.support.dubbo.GenericObjectOutput;
-
-import data.media.MediaContent;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-
-/**
- * Dubbo Seriazition Benchmark
- */
-public class Dubbo {
-
- public static Serializer<Object> GenericSerializer = new Serializer<Object>() {
- public Object deserialize(byte[] array) throws Exception {
- GenericObjectInput objectInput = new GenericObjectInput(new ByteArrayInputStream(array));
- return objectInput.readObject();
- }
-
- public byte[] serialize(Object data) throws java.io.IOException {
- UnsafeByteArrayOutputStream os = new UnsafeByteArrayOutputStream(10240);
- GenericObjectOutput objectOutput = new GenericObjectOutput(os);
- objectOutput.writeObject(data);
- objectOutput.flushBuffer();
- return os.toByteArray();
- }
-
- public String getName() {
- return "dubbo";
- }
- };
-
- public static void register(TestGroups groups) {
- groups.media.add(JavaBuiltIn.MediaTransformer, Dubbo.<MediaContent>GenericSerializer());
- }
-
- // ------------------------------------------------------------
- // Serializer (just one)
-
- public static <T> Serializer<T> GenericSerializer() {
- @SuppressWarnings("unchecked")
- Serializer<T> s = (Serializer<T>) GenericSerializer;
- return s;
- }
-}
+/*
+ * 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.dubbo.serialize.benchmark;
+
+import com.alibaba.dubbo.common.io.UnsafeByteArrayOutputStream;
+import com.alibaba.dubbo.common.serialize.support.dubbo.GenericObjectInput;
+import com.alibaba.dubbo.common.serialize.support.dubbo.GenericObjectOutput;
+
+import data.media.MediaContent;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+
+/**
+ * Dubbo Seriazition Benchmark
+ */
+public class Dubbo {
+
+ public static Serializer<Object> GenericSerializer = new Serializer<Object>() {
+ public Object deserialize(byte[] array) throws Exception {
+ GenericObjectInput objectInput = new GenericObjectInput(new ByteArrayInputStream(array));
+ return objectInput.readObject();
+ }
+
+ public byte[] serialize(Object data) throws java.io.IOException {
+ UnsafeByteArrayOutputStream os = new UnsafeByteArrayOutputStream(10240);
+ GenericObjectOutput objectOutput = new GenericObjectOutput(os);
+ objectOutput.writeObject(data);
+ objectOutput.flushBuffer();
+ return os.toByteArray();
+ }
+
+ public String getName() {
+ return "dubbo";
+ }
+ };
+
+ public static void register(TestGroups groups) {
+ groups.media.add(JavaBuiltIn.MediaTransformer, Dubbo.<MediaContent>GenericSerializer());
+ }
+
+ // ------------------------------------------------------------
+ // Serializer (just one)
+
+ public static <T> Serializer<T> GenericSerializer() {
+ @SuppressWarnings("unchecked")
+ Serializer<T> s = (Serializer<T>) GenericSerializer;
+ return s;
+ }
+}
diff --git a/dubbo-test/dubbo-test-benchmark/src/test/java/com/jingdong/client/DemoBenchmarkClientRunnable.java b/dubbo-test/dubbo-test-benchmark/src/test/java/com/jingdong/client/DemoBenchmarkClientRunnable.java
index 0ce5a2d020..d825ccc589 100644
--- a/dubbo-test/dubbo-test-benchmark/src/test/java/com/jingdong/client/DemoBenchmarkClientRunnable.java
+++ b/dubbo-test/dubbo-test-benchmark/src/test/java/com/jingdong/client/DemoBenchmarkClientRunnable.java
@@ -1,44 +1,44 @@
-/*
- * 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.jingdong.client;
-
-import com.alibaba.dubbo.rpc.benchmark.AbstractClientRunnable;
-import com.alibaba.dubbo.rpc.benchmark.DemoService;
-import com.alibaba.dubbo.rpc.benchmark.ServiceFactory;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.CyclicBarrier;
-
-/**
- * DemoBenchmarkClient.java
- */
-public class DemoBenchmarkClientRunnable extends AbstractClientRunnable {
-
- public DemoBenchmarkClientRunnable(String targetIP, int targetPort, int clientNums, int rpcTimeout,
- CyclicBarrier barrier, CountDownLatch latch, long startTime,
- long endTime) {
- super(targetIP, targetPort, clientNums, rpcTimeout, barrier, latch, startTime, endTime);
- }
-
- @SuppressWarnings({"unchecked", "rawtypes"})
- @Override
- public Object invoke(ServiceFactory serviceFactory) {
- DemoService demoService = (DemoService) serviceFactory.get(DemoService.class);
- return demoService.sendRequest("hello");
- }
-
-}
+/*
+ * 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.jingdong.client;
+
+import com.alibaba.dubbo.rpc.benchmark.AbstractClientRunnable;
+import com.alibaba.dubbo.rpc.benchmark.DemoService;
+import com.alibaba.dubbo.rpc.benchmark.ServiceFactory;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.CyclicBarrier;
+
+/**
+ * DemoBenchmarkClient.java
+ */
+public class DemoBenchmarkClientRunnable extends AbstractClientRunnable {
+
+ public DemoBenchmarkClientRunnable(String targetIP, int targetPort, int clientNums, int rpcTimeout,
+ CyclicBarrier barrier, CountDownLatch latch, long startTime,
+ long endTime) {
+ super(targetIP, targetPort, clientNums, rpcTimeout, barrier, latch, startTime, endTime);
+ }
+
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ @Override
+ public Object invoke(ServiceFactory serviceFactory) {
+ DemoService demoService = (DemoService) serviceFactory.get(DemoService.class);
+ return demoService.sendRequest("hello");
+ }
+
+}
diff --git a/dubbo-test/dubbo-test-compatibility/dubbo-test-spring3/pom.xml b/dubbo-test/dubbo-test-compatibility/dubbo-test-spring3/pom.xml
index 55ec095f12..23013c5ac2 100644
--- a/dubbo-test/dubbo-test-compatibility/dubbo-test-spring3/pom.xml
+++ b/dubbo-test/dubbo-test-compatibility/dubbo-test-spring3/pom.xml
@@ -21,7 +21,7 @@ limitations under the License.
<parent>
<artifactId>dubbo-test-compatibility</artifactId>
<groupId>com.alibaba</groupId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/dubbo-test/dubbo-test-compatibility/pom.xml b/dubbo-test/dubbo-test-compatibility/pom.xml
index 596277ea8e..8946dc4459 100644
--- a/dubbo-test/dubbo-test-compatibility/pom.xml
+++ b/dubbo-test/dubbo-test-compatibility/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-test</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>dubbo-test-compatibility</artifactId>
<packaging>pom</packaging>
diff --git a/dubbo-test/dubbo-test-examples/pom.xml b/dubbo-test/dubbo-test-examples/pom.xml
index 0dceb38589..a228ead217 100644
--- a/dubbo-test/dubbo-test-examples/pom.xml
+++ b/dubbo-test/dubbo-test-examples/pom.xml
@@ -20,7 +20,7 @@ limitations under the License.
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-test</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>dubbo-test-examples</artifactId>
<packaging>jar</packaging>
diff --git a/dubbo-test/dubbo-test-integration/pom.xml b/dubbo-test/dubbo-test-integration/pom.xml
index 67a16a9815..6aea453dce 100644
--- a/dubbo-test/dubbo-test-integration/pom.xml
+++ b/dubbo-test/dubbo-test-integration/pom.xml
@@ -20,7 +20,7 @@ limitations under the License.
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-test</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>dubbo-test-integration</artifactId>
<packaging>jar</packaging>
diff --git a/dubbo-test/pom.xml b/dubbo-test/pom.xml
index bd4166a5b7..d50d644139 100644
--- a/dubbo-test/pom.xml
+++ b/dubbo-test/pom.xml
@@ -20,7 +20,7 @@ limitations under the License.
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-parent</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>dubbo-test</artifactId>
<packaging>pom</packaging>
diff --git a/dubbo/pom.xml b/dubbo/pom.xml
index de7b80499b..f7fb8f79d8 100644
--- a/dubbo/pom.xml
+++ b/dubbo/pom.xml
@@ -20,7 +20,7 @@ limitations under the License.
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-parent</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>dubbo</artifactId>
<packaging>jar</packaging>
diff --git a/hessian-lite/pom.xml b/hessian-lite/pom.xml
index 16888a2138..2170884b62 100644
--- a/hessian-lite/pom.xml
+++ b/hessian-lite/pom.xml
@@ -22,7 +22,7 @@ limitations under the License.
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-parent</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
</parent>
<artifactId>hessian-lite</artifactId>
<packaging>jar</packaging>
diff --git a/pom.xml b/pom.xml
index 5b287c9e72..cd80dab3ab 100644
--- a/pom.xml
+++ b/pom.xml
@@ -14,12 +14,13 @@ 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.
-->
+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-parent</artifactId>
- <version>2.5.10</version>
+ <version>2.5.11</version>
<packaging>pom</packaging>
<name>${project.artifactId}</name>
<description>The parent project of dubbo</description>
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services