├── README.md ├── doc ├── Creating-Keys-Using-Java-Keytool.pdf ├── hetty使用文档_v1.2.3.pdf └── hetty使用文档_v1.2.4.pdf ├── lib ├── bouncycastle │ └── bcprov-jdk15 │ │ └── 140 │ │ ├── _maven.repositories │ │ ├── bcprov-jdk15-140.jar │ │ ├── bcprov-jdk15-140.jar.sha1 │ │ ├── bcprov-jdk15-140.pom │ │ └── bcprov-jdk15-140.pom.sha1 ├── com │ └── esotericsoftware │ │ └── reflectasm │ │ └── reflectasm │ │ └── 1.07 │ │ ├── _maven.repositories │ │ ├── reflectasm-1.07.jar │ │ ├── reflectasm-1.07.jar.sha1 │ │ ├── reflectasm-1.07.pom │ │ └── reflectasm-1.07.pom.sha1 ├── commons-codec │ └── commons-codec │ │ └── 1.7 │ │ ├── _maven.repositories │ │ ├── commons-codec-1.7.jar │ │ ├── commons-codec-1.7.jar.sha1 │ │ ├── commons-codec-1.7.pom │ │ └── commons-codec-1.7.pom.sha1 ├── dom4j │ └── dom4j │ │ └── 1.6.1 │ │ ├── _maven.repositories │ │ ├── dom4j-1.6.1.jar │ │ ├── dom4j-1.6.1.jar.sha1 │ │ ├── dom4j-1.6.1.pom │ │ └── dom4j-1.6.1.pom.sha1 ├── hessian │ └── hessian │ │ └── 4.0.7 │ │ ├── hessian-4.0.7.jar │ │ ├── hessian-4.0.7.jar.lastUpdated │ │ └── hessian-4.0.7.pom.lastUpdated ├── io │ └── netty │ │ ├── netty-parent │ │ └── 4.0.0.Alpha1 │ │ │ ├── _maven.repositories │ │ │ ├── netty-parent-4.0.0.Alpha1.pom │ │ │ └── netty-parent-4.0.0.Alpha1.pom.sha1 │ │ └── netty │ │ ├── 3.5.1.Final │ │ ├── _maven.repositories │ │ ├── netty-3.5.1.Final.jar │ │ ├── netty-3.5.1.Final.jar.sha1 │ │ ├── netty-3.5.1.Final.pom │ │ └── netty-3.5.1.Final.pom.sha1 │ │ ├── 3.5.1 │ │ ├── netty-3.5.1.jar.lastUpdated │ │ └── netty-3.5.1.pom.lastUpdated │ │ └── 4.0.0.Alpha1 │ │ ├── _maven.repositories │ │ ├── netty-4.0.0.Alpha1.jar │ │ ├── netty-4.0.0.Alpha1.jar.sha1 │ │ ├── netty-4.0.0.Alpha1.pom │ │ └── netty-4.0.0.Alpha1.pom.sha1 └── junit │ └── junit │ ├── 3.8.1 │ ├── _maven.repositories │ ├── junit-3.8.1.jar │ ├── junit-3.8.1.jar.sha1 │ ├── junit-3.8.1.pom │ └── junit-3.8.1.pom.sha1 │ ├── 4.10 │ ├── _maven.repositories │ ├── junit-4.10.jar │ ├── junit-4.10.jar.sha1 │ ├── junit-4.10.pom │ └── junit-4.10.pom.sha1 │ ├── 4.7 │ ├── _maven.repositories │ ├── junit-4.7.jar │ ├── junit-4.7.jar.sha1 │ ├── junit-4.7.pom │ └── junit-4.7.pom.sha1 │ └── 4.8.2 │ ├── _maven.repositories │ ├── junit-4.8.2.pom │ └── junit-4.8.2.pom.sha1 ├── pom.xml └── src ├── main └── java │ └── com │ └── hetty │ ├── conf │ ├── ConfigParser.java │ ├── HettyConfig.java │ └── XmlConfigParser.java │ ├── core │ ├── Hetty.java │ ├── HettyChannelPipelineFactory.java │ ├── HettyHandler.java │ ├── HettySecurity.java │ ├── MetadataProcessor.java │ ├── NamedThreadFactory.java │ ├── ServiceHandler.java │ ├── ServiceMetaData.java │ ├── ServiceReporter.java │ └── ssl │ │ ├── PEMKeyManager.java │ │ ├── SslContextFactory.java │ │ ├── SslHettyChannelPipelineFactory.java │ │ └── SslHettyHandler.java │ ├── object │ ├── Application.java │ ├── HettyException.java │ ├── RequestWrapper.java │ ├── Service.java │ ├── ServiceProvider.java │ └── ServiceVersion.java │ ├── plugin │ ├── IPlugin.java │ └── XmlConfigPlugin.java │ └── util │ ├── FileUtil.java │ └── StringUtil.java └── test ├── java └── com │ └── hetty │ ├── ServerTest.java │ ├── Test.java │ ├── TestSSL.java │ └── server │ ├── BasicAPI.java │ ├── BasicService.java │ ├── Hello.java │ ├── Hello2Impl.java │ ├── HelloImpl.java │ ├── Role.java │ └── User.java └── resources ├── config.xml ├── hetty.store ├── logback.xml └── server.properties /README.md: -------------------------------------------------------------------------------- 1 | Hetty 2 | ===== 3 | Hetty是一款构建于Netty和Hessian基础上的高性能的RPC框架.Hessian是一款基于HTTP协议的RPC框架,采用的是二进制RPC协议,非常轻量级 4 | ,且速度较快。Netty是一款基于事件驱动的NIO框架,用以快速开发高性能、高可靠性的网络服务器和客户端程序。Hetty客户端完全由 5 | Hessian实现,只是使用Netty重新实现了服务端。 6 | 使用方法: 7 | 8 | 1.配置Hetty服务器。 9 | 10 | ```xml 11 | server.devmod=false #配置开发模式 12 | server.key=server1 #配置服务器Key,用于认证 13 | server.secret=server1 #配置服务器secret,用于认证 14 | server.port=8081 #配置端口号 15 | 16 | server.thread.corePoolSize=4 #线程池配置 17 | server.thread.maxPoolSize=100 18 | server.thread.keepAliveTime=3000 19 | server.method.timeout=3000 20 | properties.file=config.xml #配置service定义文件 21 | ``` 22 | 23 | 2.service配置 24 | 25 | ```xml 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | ``` 54 | 55 | 配置包括三部分,第一部分applications,配置客户端的user和密码,来做权限认证。第二部分配置service接口,比如: 56 | 57 | ```xml 58 | 59 | 60 | 61 | ``` 62 | 63 | 我们配置了test.BasicAPI接口,接口名字为basic,有一个版本,版本号为1,且为默认版本。 64 | 第三部分配置客户端的调用的版本,比如可以配置client1调用basic接口的1版本。 65 | 66 | 3.客户端调用 67 | ```java 68 | public static void main(String[] args) throws MalformedURLException { 69 | 70 | String url = "http://localhost:8081/apis/hello/"; 71 | 72 | HessianProxyFactory factory = new HessianProxyFactory(); 73 | 74 | factory.setUser("server1"); 75 | 76 | factory.setPassword("server1"); 77 | 78 | factory.setOverloadEnabled(true); 79 | 80 | final Hello basic = (Hello) factory.create(Hello.class, url); 81 | 82 | System.out.println(basic.hello()); 83 | System.out.println(basic.hello("guolei")); 84 | System.out.println(basic.hello("guolei","hetty")); 85 | } 86 | ``` 87 | -------------------------------------------------------------------------------- /doc/Creating-Keys-Using-Java-Keytool.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xishuixixia/Hetty/49919c50e64889af7769d5d30cd00e58852502a6/doc/Creating-Keys-Using-Java-Keytool.pdf -------------------------------------------------------------------------------- /doc/hetty使用文档_v1.2.3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xishuixixia/Hetty/49919c50e64889af7769d5d30cd00e58852502a6/doc/hetty使用文档_v1.2.3.pdf -------------------------------------------------------------------------------- /doc/hetty使用文档_v1.2.4.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xishuixixia/Hetty/49919c50e64889af7769d5d30cd00e58852502a6/doc/hetty使用文档_v1.2.4.pdf -------------------------------------------------------------------------------- /lib/bouncycastle/bcprov-jdk15/140/_maven.repositories: -------------------------------------------------------------------------------- 1 | #NOTE: This is an internal implementation file, its format can be changed without prior notice. 2 | #Thu Nov 22 15:58:28 CST 2012 3 | bcprov-jdk15-140.jar>central= 4 | bcprov-jdk15-140.pom>central= 5 | -------------------------------------------------------------------------------- /lib/bouncycastle/bcprov-jdk15/140/bcprov-jdk15-140.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xishuixixia/Hetty/49919c50e64889af7769d5d30cd00e58852502a6/lib/bouncycastle/bcprov-jdk15/140/bcprov-jdk15-140.jar -------------------------------------------------------------------------------- /lib/bouncycastle/bcprov-jdk15/140/bcprov-jdk15-140.jar.sha1: -------------------------------------------------------------------------------- 1 | 83933f3f3312473afbe42a232392b3feffaadc36 /home/maven/repository-staging/to-ibiblio/maven2/bouncycastle/bcprov-jdk15/140/bcprov-jdk15-140.jar 2 | -------------------------------------------------------------------------------- /lib/bouncycastle/bcprov-jdk15/140/bcprov-jdk15-140.pom: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 4.0.0 9 | bouncycastle 10 | bcprov-jdk15 11 | 140 12 | 13 | Legion of the Bouncy Castle Java Cryptography APIs 14 | 15 | The Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms. The package is organised 16 | so that it contains a light-weight API suitable for use in any environment (including the newly released J2ME) 17 | with the additional infrastructure to conform the algorithms to the JCE framework. 18 | 19 | http://www.bouncycastle.org/java.html 20 | 21 | 22 | 23 | Bouncy Castle License 24 | http://www.bouncycastle.org/licence.html 25 | repo 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /lib/bouncycastle/bcprov-jdk15/140/bcprov-jdk15-140.pom.sha1: -------------------------------------------------------------------------------- 1 | 1fe2ae86d5115b842168f51bea1f9c73d25d9031 /home/maven/repository-staging/to-ibiblio/maven2/bouncycastle/bcprov-jdk15/140/bcprov-jdk15-140.pom 2 | -------------------------------------------------------------------------------- /lib/com/esotericsoftware/reflectasm/reflectasm/1.07/_maven.repositories: -------------------------------------------------------------------------------- 1 | #NOTE: This is an internal implementation file, its format can be changed without prior notice. 2 | #Thu Nov 22 15:49:40 CST 2012 3 | reflectasm-1.07.pom>central= 4 | reflectasm-1.07.jar>central= 5 | -------------------------------------------------------------------------------- /lib/com/esotericsoftware/reflectasm/reflectasm/1.07/reflectasm-1.07.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xishuixixia/Hetty/49919c50e64889af7769d5d30cd00e58852502a6/lib/com/esotericsoftware/reflectasm/reflectasm/1.07/reflectasm-1.07.jar -------------------------------------------------------------------------------- /lib/com/esotericsoftware/reflectasm/reflectasm/1.07/reflectasm-1.07.jar.sha1: -------------------------------------------------------------------------------- 1 | 761028ef46da8ec16a16b25ce942463eb1a9f3d5 -------------------------------------------------------------------------------- /lib/com/esotericsoftware/reflectasm/reflectasm/1.07/reflectasm-1.07.pom: -------------------------------------------------------------------------------- 1 | 5 | 4.0.0 6 | com.esotericsoftware.reflectasm 7 | reflectasm 8 | 1.07 9 | jar 10 | ReflectASM 11 | High performance Java reflection using code generation 12 | http://code.google.com/p/reflectasm/ 13 | 14 | 15 | 16 | New BSD License 17 | http://www.opensource.org/licenses/bsd-license.php 18 | repo 19 | 20 | 21 | 22 | 23 | http://reflectasm.googlecode.com/svn/ 24 | scm:svn:http://reflectasm.googlecode.com/svn/ 25 | 26 | 27 | 28 | 29 | nathan.sweet 30 | Nathan Sweet 31 | nathan.sweet@gmail.com 32 | 33 | 34 | 35 | 36 | UTF-8 37 | 38 | 39 | 40 | 41 | org.ow2.asm 42 | asm 43 | 4.0 44 | 45 | 46 | junit 47 | junit 48 | 4.8.2 49 | test 50 | 51 | 52 | 53 | 54 | 55 | src 56 | test 57 | 58 | 59 | 60 | 61 | maven-resources-plugin 62 | 2.5 63 | 64 | 65 | default-resources 66 | none 67 | 68 | 69 | default-testResources 70 | none 71 | 72 | 73 | 74 | 75 | org.apache.maven.plugins 76 | maven-jar-plugin 77 | 2.4 78 | 79 | 80 | **/.svn/* 81 | 82 | 83 | 84 | 85 | org.apache.maven.plugins 86 | maven-shade-plugin 87 | 1.7 88 | 89 | 90 | package 91 | 92 | shade 93 | 94 | 95 | 96 | true 97 | true 98 | shaded 99 | 100 | 101 | org.objectweb.asm 102 | com.esotericsoftware.reflectasm.shaded.org.objectweb.asm 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /lib/com/esotericsoftware/reflectasm/reflectasm/1.07/reflectasm-1.07.pom.sha1: -------------------------------------------------------------------------------- 1 | c5da38373fa65bd2870ced97ba4d5ccc08be62de -------------------------------------------------------------------------------- /lib/commons-codec/commons-codec/1.7/_maven.repositories: -------------------------------------------------------------------------------- 1 | #NOTE: This is an internal implementation file, its format can be changed without prior notice. 2 | #Thu Nov 22 15:45:06 CST 2012 3 | commons-codec-1.7.jar>central= 4 | commons-codec-1.7.pom>central= 5 | -------------------------------------------------------------------------------- /lib/commons-codec/commons-codec/1.7/commons-codec-1.7.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xishuixixia/Hetty/49919c50e64889af7769d5d30cd00e58852502a6/lib/commons-codec/commons-codec/1.7/commons-codec-1.7.jar -------------------------------------------------------------------------------- /lib/commons-codec/commons-codec/1.7/commons-codec-1.7.jar.sha1: -------------------------------------------------------------------------------- 1 | 9cd61d269c88f9fb0eb36cea1efcd596ab74772f -------------------------------------------------------------------------------- /lib/commons-codec/commons-codec/1.7/commons-codec-1.7.pom: -------------------------------------------------------------------------------- 1 | 2 | 18 | 20 | 21 | org.apache.commons 22 | commons-parent 23 | 26 24 | 25 | 4.0.0 26 | commons-codec 27 | commons-codec 28 | 1.7 29 | Commons Codec 30 | 2002 31 | 32 | The codec package contains simple encoder and decoders for 33 | various formats such as Base64 and Hexadecimal. In addition to these 34 | widely used encoders and decoders, the codec package also maintains a 35 | collection of phonetic encoding utilities. 36 | 37 | http://commons.apache.org/codec/ 38 | 39 | jira 40 | http://issues.apache.org/jira/browse/CODEC 41 | 42 | 43 | scm:svn:http://svn.apache.org/repos/asf/commons/proper/codec/trunk 44 | scm:svn:https://svn.apache.org/repos/asf/commons/proper/codec/trunk 45 | http://svn.apache.org/viewvc/commons/proper/codec/trunk 46 | 47 | 48 | 49 | stagingSite 50 | Apache Staging Website 51 | scp://people.apache.org/www/commons.apache.org/codec/ 52 | 53 | 54 | 55 | 56 | Henri Yandell 57 | bayard 58 | bayard@apache.org 59 | 60 | 61 | Tim OBrien 62 | tobrien 63 | tobrien@apache.org 64 | -6 65 | 66 | 67 | Scott Sanders 68 | sanders 69 | sanders@totalsync.com 70 | 71 | 72 | Rodney Waldhoff 73 | rwaldhoff 74 | rwaldhoff@apache.org 75 | 76 | 77 | Daniel Rall 78 | dlr 79 | dlr@finemaltcoding.com 80 | 81 | 82 | Jon S. Stevens 83 | jon 84 | jon@collab.net 85 | 86 | 87 | Gary Gregory 88 | ggregory 89 | ggregory@apache.org 90 | http://www.garygregory.com 91 | -5 92 | 93 | 94 | David Graham 95 | dgraham 96 | dgraham@apache.org 97 | 98 | 99 | Julius Davies 100 | julius 101 | julius@apache.org 102 | http://juliusdavies.ca/ 103 | -8 104 | 105 | 106 | 107 | 108 | Christopher O'Brien 109 | siege@preoccupied.net 110 | 111 | hex 112 | md5 113 | architecture 114 | 115 | 116 | 117 | Martin Redington 118 | 119 | Representing xml-rpc 120 | 121 | 122 | 123 | Jeffery Dever 124 | 125 | Representing http-client 126 | 127 | 128 | 129 | Steve Zimmermann 130 | steve.zimmermann@heii.com 131 | 132 | Documentation 133 | 134 | 135 | 136 | Benjamin Walstrum 137 | ben@walstrum.com 138 | 139 | 140 | Oleg Kalnichevski 141 | oleg@ural.ru 142 | 143 | Representing http-client 144 | 145 | 146 | 147 | Dave Dribin 148 | apache@dave.dribin.org 149 | 150 | DigestUtil 151 | 152 | 153 | 154 | Alex Karasulu 155 | aok123 at bellsouth.net 156 | 157 | Submitted Binary class and test 158 | 159 | 160 | 161 | Matthew Inger 162 | mattinger at yahoo.com 163 | 164 | Submitted DIFFERENCE algorithm for Soundex and RefinedSoundex 165 | 166 | 167 | 168 | Jochen Wiedmann 169 | jochen@apache.org 170 | 171 | Base64 code [CODEC-69] 172 | 173 | 174 | 175 | Sebastian Bazley 176 | sebb@apache.org 177 | 178 | Streaming Base64 179 | 180 | 181 | 182 | Matthew Pocock 183 | turingatemyhamster@gmail.com 184 | 185 | Beinder-Morse phonetic matching 186 | 187 | 188 | 189 | 190 | 191 | 192 | junit 193 | junit 194 | 4.10 195 | test 196 | 197 | 198 | 199 | 1.6 200 | 1.6 201 | codec 202 | 1.7 203 | 204 | RC1 205 | CODEC 206 | 12310464 207 | 208 | UTF-8 209 | UTF-8 210 | UTF-8 211 | ${basedir}/LICENSE-header.txt 212 | 213 | 214 | 215 | 216 | 217 | org.apache.maven.plugins 218 | maven-site-plugin 219 | 3.1 220 | 221 | 222 | 223 | org.apache.maven.wagon 224 | wagon-ssh 225 | 1.0 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | org.apache.maven.plugins 234 | maven-surefire-plugin 235 | 236 | 237 | **/*AbstractTest.java 238 | 239 | 240 | 241 | 242 | org.apache.maven.plugins 243 | maven-jar-plugin 244 | 2.4 245 | 246 | 247 | 248 | test-jar 249 | 250 | 251 | 252 | 253 | 254 | org.apache.maven.plugins 255 | maven-assembly-plugin 256 | 2.3 257 | 258 | 259 | src/main/assembly/bin.xml 260 | src/main/assembly/src.xml 261 | 262 | gnu 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | org.apache.maven.plugins 271 | maven-checkstyle-plugin 272 | 2.9.1 273 | 274 | ${basedir}/checkstyle.xml 275 | false 276 | ${basedir}/LICENSE-header.txt 277 | 278 | 279 | 280 | org.apache.maven.plugins 281 | maven-pmd-plugin 282 | 2.7.1 283 | 284 | ${maven.compile.target} 285 | 286 | 287 | 288 | org.codehaus.mojo 289 | findbugs-maven-plugin 290 | 2.5.2 291 | 292 | 293 | org.codehaus.mojo 294 | taglist-maven-plugin 295 | 2.4 296 | 297 | 298 | TODO 299 | NOPMD 300 | NOTE 301 | 302 | 303 | 304 | 305 | org.codehaus.mojo 306 | javancss-maven-plugin 307 | 2.0 308 | 309 | 310 | 311 | 312 | -------------------------------------------------------------------------------- /lib/commons-codec/commons-codec/1.7/commons-codec-1.7.pom.sha1: -------------------------------------------------------------------------------- 1 | 6f37ec98cc2dd7ee4e31fb82e9464cbba5e94516 -------------------------------------------------------------------------------- /lib/dom4j/dom4j/1.6.1/_maven.repositories: -------------------------------------------------------------------------------- 1 | #NOTE: This is an internal implementation file, its format can be changed without prior notice. 2 | #Thu Nov 22 15:30:40 CST 2012 3 | dom4j-1.6.1.jar>central= 4 | dom4j-1.6.1.jar>nexusShow= 5 | dom4j-1.6.1.pom>central= 6 | dom4j-1.6.1.pom>nexusShow= 7 | -------------------------------------------------------------------------------- /lib/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xishuixixia/Hetty/49919c50e64889af7769d5d30cd00e58852502a6/lib/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar -------------------------------------------------------------------------------- /lib/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar.sha1: -------------------------------------------------------------------------------- 1 | 5d3ccc056b6f056dbf0dddfdf43894b9065a8f94 -------------------------------------------------------------------------------- /lib/dom4j/dom4j/1.6.1/dom4j-1.6.1.pom: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | dom4j 4 | dom4j 5 | dom4j 6 | 1.6.1 7 | dom4j: the flexible XML framework for Java 8 | http://dom4j.org 9 | 10 | http://sourceforge.net/tracker/?group_id=16035 11 | 12 | 13 | 14 | 15 |
dom4j-dev@lists.sourceforge.net
16 |
17 |
18 |
19 | 2001 20 | 21 | 22 | dom4j user list 23 | http://lists.sourceforge.net/lists/listinfo/dom4j-user 24 | http://lists.sourceforge.net/lists/listinfo/dom4j-user 25 | http://www.mail-archive.com/dom4j-user%40lists.sourceforge.net/ 26 | 27 | 28 | dom4j developer list 29 | http://lists.sourceforge.net/lists/listinfo/dom4j-dev 30 | http://lists.sourceforge.net/lists/listinfo/dom4j-dev 31 | http://www.mail-archive.com/dom4j-dev%40lists.sourceforge.net/ 32 | 33 | 34 | dom4j commits list 35 | http://lists.sourceforge.net/lists/listinfo/dom4j-commits 36 | http://lists.sourceforge.net/lists/listinfo/dom4j-commits 37 | 38 | 39 | 40 | 41 | carnold 42 | Curt Arnold 43 | carnold@users.sourceforge.net 44 | 45 | 46 | ddlucas 47 | David Lucas 48 | ddlucas@users.sourceforge.net 49 | 50 | 51 | drwhite 52 | David White 53 | drwhite@users.sourceforge.net 54 | 55 | 56 | jjenkov 57 | Jakob Jenkov 58 | jjenkov@users.sourceforge.net 59 | 60 | 61 | jstrachan 62 | James Strachan 63 | jstrachan@apache.org 64 | SpiritSoft, Inc. 65 | 66 | 67 | laramiec 68 | Laramie Crocker 69 | laramiec@users.sourceforge.net 70 | 71 | 72 | maartenc 73 | Maarten Coene 74 | maartenc@users.sourceforge.net 75 | Cronos 76 | 77 | 78 | mskells 79 | Michael Skells 80 | mskells@users.sourceforge.net 81 | 82 | 83 | nicksanderson 84 | Nick Sanderson 85 | nicksanderson@users.sourceforge.net 86 | 87 | 88 | slehmann 89 | Steen Lehmann 90 | slehmann@users.sourceforge.net 91 | 92 | 93 | tradem 94 | Tobias Rademacher 95 | tradem@users.sourceforge.net 96 | 97 | 98 | werken 99 | Bob McWhirter 100 | werken@users.sourceforge.net 101 | 102 | 103 | wolfftw 104 | Todd Wolff 105 | wolfftw@users.sourceforge.net 106 | 107 | 108 | yeekee 109 | OuYang Chen 110 | yeekee@users.sourceforge.net 111 | 112 | 113 | yruan2 114 | Yuxin Ruan 115 | yruan2@users.sourceforge.net 116 | 117 | 118 | 119 | scm:cvs:pserver:anonymous@cvs.sourceforge.net:/cvsroot/dom4j:dom4j 120 | scm:cvs:ext:${maven.username}@cvs.sourceforge.net:/cvsroot/dom4j:dom4j 121 | http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/dom4j/dom4j/ 122 | 123 | 124 | MetaStuff Ltd. 125 | http://sourceforge.net/projects/dom4j 126 | 127 | 128 | src/java 129 | src/test 130 | 131 | 132 | maven-surefire-plugin 133 | 134 | 135 | **/*Test.java 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | jaxme 144 | jaxme-api 145 | 0.3 146 | true 147 | 148 | 149 | jaxen 150 | jaxen 151 | 1.1-beta-6 152 | true 153 | 154 | 155 | msv 156 | xsdlib 157 | 20030807 158 | true 159 | 160 | 161 | msv 162 | relaxngDatatype 163 | 20030807 164 | true 165 | 166 | 167 | pull-parser 168 | pull-parser 169 | 2 170 | true 171 | 172 | 173 | xpp3 174 | xpp3 175 | 1.1.3.3 176 | true 177 | 178 | 179 | stax 180 | stax-api 181 | 1.0 182 | true 183 | 184 | 185 | xml-apis 186 | xml-apis 187 | 1.0.b2 188 | 189 | 190 | junitperf 191 | junitperf 192 | 1.8 193 | test 194 | 195 | 196 | stax 197 | stax-ri 198 | 1.0 199 | test 200 | 201 | 202 | xerces 203 | xercesImpl 204 | 2.6.2 205 | test 206 | 207 | 208 | xalan 209 | xalan 210 | 2.5.1 211 | test 212 | 213 | 214 | 215 | 216 | default 217 | Default Site 218 | scp://dom4j.org//home/groups/d/do/dom4j/htdocs 219 | 220 | 221 |
-------------------------------------------------------------------------------- /lib/dom4j/dom4j/1.6.1/dom4j-1.6.1.pom.sha1: -------------------------------------------------------------------------------- 1 | 7ea9ce66f04c02826340f41052fa2883818df602 /home/projects/maven/repository-staging/to-ibiblio/maven2/dom4j/dom4j/1.6.1/dom4j-1.6.1.pom 2 | -------------------------------------------------------------------------------- /lib/hessian/hessian/4.0.7/hessian-4.0.7.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xishuixixia/Hetty/49919c50e64889af7769d5d30cd00e58852502a6/lib/hessian/hessian/4.0.7/hessian-4.0.7.jar -------------------------------------------------------------------------------- /lib/hessian/hessian/4.0.7/hessian-4.0.7.jar.lastUpdated: -------------------------------------------------------------------------------- 1 | #NOTE: This is an internal implementation file, its format can be changed without prior notice. 2 | #Thu Nov 22 15:38:15 CST 2012 3 | http\://repo1.maven.org/maven2/.error= 4 | http\://repo1.maven.org/maven2/.lastUpdated=1353569895039 5 | -------------------------------------------------------------------------------- /lib/hessian/hessian/4.0.7/hessian-4.0.7.pom.lastUpdated: -------------------------------------------------------------------------------- 1 | #NOTE: This is an internal implementation file, its format can be changed without prior notice. 2 | #Thu Nov 22 16:00:44 CST 2012 3 | http\://repo.maven.apache.org/maven2/.lastUpdated=1353571244482 4 | http\://repo1.maven.org/maven2/.error= 5 | http\://repo1.maven.org/maven2/.lastUpdated=1353569894453 6 | http\://repo.maven.apache.org/maven2/.error= 7 | -------------------------------------------------------------------------------- /lib/io/netty/netty-parent/4.0.0.Alpha1/_maven.repositories: -------------------------------------------------------------------------------- 1 | #NOTE: This is an internal implementation file, its format can be changed without prior notice. 2 | #Thu Nov 22 15:31:44 CST 2012 3 | netty-parent-4.0.0.Alpha1.pom>central= 4 | -------------------------------------------------------------------------------- /lib/io/netty/netty-parent/4.0.0.Alpha1/netty-parent-4.0.0.Alpha1.pom: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 4.0.0 20 | 21 | org.sonatype.oss 22 | oss-parent 23 | 7 24 | 25 | 26 | io.netty 27 | netty-parent 28 | pom 29 | 4.0.0.Alpha1 30 | 31 | Netty 32 | http://netty.io/ 33 | 34 | Netty is an asynchronous event-driven network application framework for 35 | rapid development of maintainable high performance protocol servers and 36 | clients. 37 | 38 | 39 | 40 | The Netty Project 41 | http://netty.io/ 42 | 43 | 44 | 45 | 46 | Apache License, Version 2.0 47 | http://www.apache.org/licenses/LICENSE-2.0 48 | 49 | 50 | 2008 51 | 52 | 53 | https://github.com/netty/netty 54 | scm:git:git://github.com/netty/netty.git 55 | scm:git:ssh://git@github.com/netty/netty.git 56 | netty-4.0.0.Alpha1 57 | 58 | 59 | 60 | 61 | netty.io 62 | The Netty Project Contributors 63 | netty@googlegroups.com 64 | http://netty.io/ 65 | The Netty Project 66 | http://netty.io/ 67 | 68 | 69 | 70 | 71 | 1.3.14.GA 72 | 73 | 74 | 75 | common 76 | buffer 77 | codec 78 | codec-http 79 | transport 80 | handler 81 | example 82 | testsuite 83 | all 84 | 85 | 86 | 87 | 88 | 89 | full 90 | 91 | tarball 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | org.jboss.marshalling 101 | jboss-marshalling 102 | ${jboss.marshalling.version} 103 | compile 104 | true 105 | 106 | 107 | 108 | com.google.protobuf 109 | protobuf-java 110 | 2.4.1 111 | 112 | 113 | 114 | org.rxtx 115 | rxtx 116 | 2.1.7 117 | 118 | 119 | 120 | javax.servlet 121 | servlet-api 122 | 2.5 123 | 124 | 125 | 126 | org.osgi 127 | org.osgi.core 128 | 4.3.0 129 | 130 | 131 | org.osgi 132 | org.osgi.compendium 133 | 4.3.0 134 | 135 | 136 | 137 | org.slf4j 138 | slf4j-api 139 | 1.6.5 140 | 141 | 142 | commons-logging 143 | commons-logging 144 | 1.1.1 145 | 146 | 147 | org.jboss.logging 148 | jboss-logging-spi 149 | 2.1.2.GA 150 | 151 | 152 | log4j 153 | log4j 154 | 1.2.17 155 | 156 | 157 | mail 158 | javax.mail 159 | 160 | 161 | jms 162 | javax.jms 163 | 164 | 165 | jmxtools 166 | com.sun.jdmk 167 | 168 | 169 | jmxri 170 | com.sun.jmx 171 | 172 | 173 | true 174 | 175 | 176 | 177 | org.jboss.marshalling 178 | jboss-marshalling-serial 179 | ${jboss.marshalling.version} 180 | test 181 | 182 | 183 | org.jboss.marshalling 184 | jboss-marshalling-river 185 | ${jboss.marshalling.version} 186 | test 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | junit 195 | junit 196 | 4.10 197 | test 198 | 199 | 200 | org.easymock 201 | easymock 202 | 3.1 203 | test 204 | 205 | 206 | org.easymock 207 | easymockclassextension 208 | 3.1 209 | test 210 | 211 | 212 | org.jmock 213 | jmock-junit4 214 | 2.5.1 215 | test 216 | 217 | 218 | org.slf4j 219 | slf4j-simple 220 | 1.6.6 221 | test 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | maven-enforcer-plugin 230 | 1.1 231 | 232 | 233 | enforce-tools 234 | 235 | enforce 236 | 237 | 238 | 239 | 240 | 241 | 242 | [1.7.0,) 243 | 244 | 245 | [3.0.2,) 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | maven-compiler-plugin 254 | 2.5.1 255 | 256 | UTF-8 257 | 1.6 258 | 1.6 259 | true 260 | true 261 | true 262 | true 263 | 264 | 265 | 266 | 268 | org.codehaus.mojo 269 | animal-sniffer-maven-plugin 270 | 1.8 271 | 272 | 273 | org.codehaus.mojo.signature 274 | java16 275 | 1.0 276 | 277 | 278 | sun.misc.Unsafe 279 | java.util.zip.Deflater 280 | 281 | 282 | java.nio.channels.DatagramChannel 283 | java.nio.channels.MembershipKey 284 | java.net.StandardSocketOptions 285 | java.net.StandardProtocolFamily 286 | 287 | 288 | java.nio.channels.AsynchronousChannel 289 | java.nio.channels.AsynchronousSocketChannel 290 | java.nio.channels.AsynchronousServerSocketChannel 291 | java.nio.channels.AsynchronousChannelGroup 292 | java.nio.channels.NetworkChannel 293 | 294 | 295 | 296 | 297 | process-classes 298 | 299 | check 300 | 301 | 302 | 303 | 304 | 305 | maven-checkstyle-plugin 306 | 2.9.1 307 | 308 | 309 | check-style 310 | 311 | check 312 | 313 | validate 314 | 315 | true 316 | true 317 | true 318 | true 319 | io/netty/checkstyle.xml 320 | 321 | 322 | 323 | 324 | 325 | ${project.groupId} 326 | netty-build 327 | 9 328 | 329 | 330 | 331 | 332 | maven-surefire-plugin 333 | 2.12 334 | 335 | once 336 | 337 | **/Abstract* 338 | **/TestUtil* 339 | 340 | random 341 | 342 | 343 | 344 | maven-source-plugin 345 | 2.1.2 346 | 347 | 348 | attach-sources 349 | 350 | jar 351 | 352 | 353 | 354 | 355 | 356 | maven-release-plugin 357 | 2.3.2 358 | 359 | release,full 360 | true 361 | netty-@{project.version} 362 | 363 | 364 | 365 | 366 | 368 | 369 | 370 | 371 | org.eclipse.m2e 372 | lifecycle-mapping 373 | 1.0.0 374 | 375 | 376 | 377 | 378 | 379 | org.apache.maven.plugins 380 | maven-checkstyle-plugin 381 | [1.0,) 382 | 383 | check 384 | 385 | 386 | 387 | 388 | false 389 | 390 | 391 | 392 | 393 | 394 | org.apache.maven.plugins 395 | maven-enforcer-plugin 396 | [1.0,) 397 | 398 | enforce 399 | 400 | 401 | 402 | 403 | false 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | -------------------------------------------------------------------------------- /lib/io/netty/netty-parent/4.0.0.Alpha1/netty-parent-4.0.0.Alpha1.pom.sha1: -------------------------------------------------------------------------------- 1 | 8cb44e031e5b86a14d897ed5b438997092f3b0b0 -------------------------------------------------------------------------------- /lib/io/netty/netty/3.5.1.Final/_maven.repositories: -------------------------------------------------------------------------------- 1 | #NOTE: This is an internal implementation file, its format can be changed without prior notice. 2 | #Thu Nov 22 15:35:10 CST 2012 3 | netty-3.5.1.Final.jar>central= 4 | netty-3.5.1.Final.pom>central= 5 | -------------------------------------------------------------------------------- /lib/io/netty/netty/3.5.1.Final/netty-3.5.1.Final.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xishuixixia/Hetty/49919c50e64889af7769d5d30cd00e58852502a6/lib/io/netty/netty/3.5.1.Final/netty-3.5.1.Final.jar -------------------------------------------------------------------------------- /lib/io/netty/netty/3.5.1.Final/netty-3.5.1.Final.jar.sha1: -------------------------------------------------------------------------------- 1 | 8198f4be595d4479fd045bb58e37462be9a9a06f -------------------------------------------------------------------------------- /lib/io/netty/netty/3.5.1.Final/netty-3.5.1.Final.pom: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 4.0.0 20 | 21 | org.sonatype.oss 22 | oss-parent 23 | 7 24 | 25 | 26 | io.netty 27 | netty 28 | bundle 29 | 3.5.1.Final 30 | 31 | The Netty Project 32 | http://netty.io/ 33 | 34 | The Netty project is an effort to provide an asynchronous event-driven 35 | network application framework and tools for rapid development of 36 | maintainable high performance and high scalability protocol servers and 37 | clients. In other words, Netty is a NIO client server framework which 38 | enables quick and easy development of network applications such as protocol 39 | servers and clients. It greatly simplifies and streamlines network 40 | programming such as TCP and UDP socket server. 41 | 42 | 43 | 44 | The Netty Project 45 | http://netty.io/ 46 | 47 | 48 | 49 | 50 | Apache License, Version 2.0 51 | http://www.apache.org/licenses/LICENSE-2.0 52 | 53 | 54 | 2008 55 | 56 | 57 | https://github.com/netty/netty 58 | scm:git:git://github.com/netty/netty.git 59 | scm:git:ssh://git@github.com/netty/netty.git 60 | 61 | 62 | 63 | 64 | netty.io 65 | The Netty Project Contributors 66 | netty@googlegroups.com 67 | http://netty.io/ 68 | The Netty Project 69 | http://netty.io/ 70 | 71 | 72 | 73 | 74 | 75 | 76 | org.jboss.marshalling 77 | jboss-marshalling 78 | ${jboss.marshalling.version} 79 | compile 80 | true 81 | 82 | 83 | 84 | 85 | com.google.protobuf 86 | protobuf-java 87 | 2.4.1 88 | compile 89 | true 90 | 91 | 92 | 93 | 94 | 95 | javax.servlet 96 | servlet-api 97 | 2.5 98 | compile 99 | true 100 | 101 | 102 | 103 | 104 | javax.activation 105 | activation 106 | 1.1.1 107 | compile 108 | true 109 | 110 | 111 | 112 | 113 | org.apache.felix 114 | org.osgi.core 115 | 1.4.0 116 | compile 117 | true 118 | 119 | 120 | org.apache.felix 121 | org.osgi.compendium 122 | 1.4.0 123 | compile 124 | true 125 | 126 | 127 | org.apache.felix 128 | javax.servlet 129 | 130 | 131 | org.apache.felix 132 | org.osgi.foundation 133 | 134 | 135 | 136 | 137 | 138 | 139 | org.slf4j 140 | slf4j-api 141 | 1.6.4 142 | compile 143 | true 144 | 145 | 146 | commons-logging 147 | commons-logging 148 | 1.1.1 149 | compile 150 | true 151 | 152 | 153 | org.jboss.logging 154 | jboss-logging-spi 155 | 2.1.2.GA 156 | compile 157 | true 158 | 159 | 160 | log4j 161 | log4j 162 | 1.2.16 163 | compile 164 | 165 | 166 | mail 167 | javax.mail 168 | 169 | 170 | jms 171 | javax.jms 172 | 173 | 174 | jmxtools 175 | com.sun.jdmk 176 | 177 | 178 | jmxri 179 | com.sun.jmx 180 | 181 | 182 | true 183 | 184 | 185 | 186 | 187 | junit 188 | junit 189 | 4.10 190 | test 191 | 192 | 193 | org.easymock 194 | easymock 195 | 3.1 196 | test 197 | 198 | 199 | org.easymock 200 | easymockclassextension 201 | 3.1 202 | test 203 | 204 | 205 | org.slf4j 206 | slf4j-simple 207 | 1.6.4 208 | test 209 | 210 | 211 | 212 | org.jboss.marshalling 213 | jboss-marshalling-serial 214 | ${jboss.marshalling.version} 215 | test 216 | 217 | 218 | org.jboss.marshalling 219 | jboss-marshalling-river 220 | ${jboss.marshalling.version} 221 | test 222 | 223 | 224 | 225 | 226 | false 227 | 1.3.14.GA 228 | 229 | 230 | 231 | 232 | 233 | ${basedir}/src/main/resources 234 | 235 | 236 | ${basedir}/target/license 237 | 238 | 239 | 240 | 241 | 242 | 244 | 245 | org.eclipse.m2e 246 | lifecycle-mapping 247 | 1.0.0 248 | 249 | 250 | 251 | 252 | 253 | org.apache.maven.plugins 254 | maven-antrun-plugin 255 | [1.7,) 256 | 257 | run 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | org.apache.maven.plugins 267 | maven-checkstyle-plugin 268 | [2.8,) 269 | 270 | check 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | maven-enforcer-plugin 287 | 1.0.1 288 | 289 | 290 | enforce-tools 291 | 292 | enforce 293 | 294 | 295 | 296 | 297 | 298 | 300 | [1.7.0,) 301 | 302 | 303 | [3.0.2,) 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | maven-compiler-plugin 312 | 2.3.2 313 | 314 | UTF-8 315 | 1.5 316 | 1.5 317 | true 318 | true 319 | true 320 | true 321 | 322 | 323 | 324 | 326 | org.codehaus.mojo 327 | animal-sniffer-maven-plugin 328 | 1.7 329 | 330 | 331 | org.codehaus.mojo.signature 332 | java15 333 | 1.0 334 | 335 | 336 | sun.misc.Unsafe 337 | java.util.zip.Deflater 338 | java.util.concurrent.LinkedTransferQueue 339 | 340 | java.nio.channels.DatagramChannel 341 | java.nio.channels.MembershipKey 342 | java.net.StandardSocketOptions 343 | java.net.StandardProtocolFamily 344 | 345 | 346 | 347 | 348 | process-classes 349 | 350 | check 351 | 352 | 353 | 354 | 355 | 356 | maven-resources-plugin 357 | 2.5 358 | 359 | UTF-8 360 | 361 | 362 | 363 | copy-legal-info 364 | validate 365 | 366 | copy-resources 367 | 368 | 369 | ${basedir}/target/license/META-INF 370 | 371 | 372 | ${basedir} 373 | false 374 | 375 | LICENSE.txt 376 | NOTICE.txt 377 | license/*.txt 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | maven-surefire-plugin 387 | 2.10 388 | 389 | never 390 | 391 | **/Abstract* 392 | **/TestUtil* 393 | 394 | random 395 | 396 | 397 | 398 | org.apache.felix 399 | maven-bundle-plugin 400 | 2.3.4 401 | true 402 | 403 | 404 | org.jboss.netty 405 | ${project.url} 406 | 407 | org.jboss.netty.container.osgi.NettyBundleActivator 408 | 409 | 410 | !org.jboss.netty.example.*, 411 | !org.jboss.netty.util.internal.*, 412 | org.jboss.netty.*;version=${project.version} 413 | 414 | 415 | org.jboss.netty.example.*, 416 | org.jboss.netty.util.internal.*, 417 | 418 | 419 | *;resolution:=optional 420 | 421 | registered 422 | registered 423 | org.jboss.netty.util.Version 424 | 425 | 426 | 427 | 428 | maven-source-plugin 429 | 2.1.2 430 | 431 | 432 | attach-source 433 | package 434 | 435 | jar 436 | 437 | 438 | true 439 | 440 | 441 | 442 | 443 | 444 | maven-antrun-plugin 445 | 1.7 446 | 447 | 448 | write-version 449 | validate 450 | 451 | run 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | Build number: ${buildNumber} 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | remove-examples 479 | package 480 | 481 | run 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | org.apache.ant 527 | ant 528 | 1.8.2 529 | 530 | 531 | org.apache.ant 532 | ant-launcher 533 | 1.8.2 534 | 535 | 536 | ant-contrib 537 | ant-contrib 538 | 1.0b3 539 | 540 | 541 | ant 542 | ant 543 | 544 | 545 | 546 | 547 | 548 | 549 | maven-javadoc-plugin 550 | 2.8 551 | 552 | 553 | attach-javadoc 554 | package 555 | 556 | jar 557 | 558 | 559 | 560 | 561 | org.jboss.apiviz.APIviz 562 | ${basedir}/lib/apiviz-1.3.1-jdk7.jar 563 | true 564 | ${basedir}/src/javadoc 565 | true 566 | true 567 | ${project.build.directory}/api 568 | ${project.build.directory} 569 | api 570 | UTF-8 571 | UTF-8 572 | true 573 | false 574 | false 575 | true 576 | ${basedir}/src/javadoc/overview.html 577 | ${project.name} API Reference (${project.version}) 578 | ${project.name} API Reference (${project.version}) 579 | 580 | -link http://docs.oracle.com/javase/7/docs/api/ 581 | -link http://code.google.com/apis/protocolbuffers/docs/reference/java/ 582 | -link http://docs.oracle.com/javaee/6/api/ 583 | -link http://www.osgi.org/javadoc/r4v43/core/ 584 | -link http://www.slf4j.org/apidocs/ 585 | -link http://commons.apache.org/logging/commons-logging-1.1.1/apidocs/ 586 | -link http://logging.apache.org/log4j/1.2/apidocs/ 587 | 588 | -group "Low-level data representation" org.jboss.netty.buffer* 589 | -group "Central interface for all I/O operations" org.jboss.netty.channel* 590 | -group "Client & Server bootstrapping utilities" org.jboss.netty.bootstrap* 591 | -group "Reusable I/O event interceptors" org.jboss.netty.handler* 592 | -group "Miscellaneous" org.jboss.netty.logging*:org.jboss.netty.util* 593 | 594 | -sourceclasspath ${project.build.outputDirectory} 595 | -nopackagediagram 596 | 597 | UTF-8 598 | en_US 599 | org.jboss.netty.example*:org.jboss.netty.container*:org.jboss.netty.util.internal* 600 | 601 | 602 | 603 | maven-jxr-plugin 604 | 2.2 605 | 606 | 607 | generate-xref 608 | package 609 | 610 | jxr 611 | 612 | 613 | 614 | 615 | UTF-8 616 | UTF-8 617 | true 618 | ${project.build.directory}/xref 619 | ${project.build.directory}/api 620 | ${project.name} Source Xref (${project.version}) 621 | ${project.name} Source Xref (${project.version}) 622 | 623 | 624 | 625 | maven-assembly-plugin 626 | 2.2.1 627 | 628 | 629 | generate-distribution 630 | package 631 | 632 | single 633 | 634 | 635 | 636 | 637 | 638 | ${basedir}/src/assembly/default.xml 639 | 640 | ${attach-distribution} 641 | true 642 | gnu 643 | 644 | 645 | 646 | maven-checkstyle-plugin 647 | 2.8 648 | 649 | 650 | check-style 651 | 652 | check 653 | 654 | validate 655 | 656 | true 657 | true 658 | true 659 | true 660 | io/netty/checkstyle.xml 661 | 662 | 663 | 664 | 665 | 666 | ${project.groupId} 667 | netty-build 668 | 9 669 | 670 | 671 | 672 | 673 | 674 | 675 | 676 | -------------------------------------------------------------------------------- /lib/io/netty/netty/3.5.1.Final/netty-3.5.1.Final.pom.sha1: -------------------------------------------------------------------------------- 1 | b4f7abcf345fb137382820db34186622ab54ef9e -------------------------------------------------------------------------------- /lib/io/netty/netty/3.5.1/netty-3.5.1.jar.lastUpdated: -------------------------------------------------------------------------------- 1 | #NOTE: This is an internal implementation file, its format can be changed without prior notice. 2 | #Thu Nov 22 15:32:16 CST 2012 3 | http\://repo1.maven.org/maven2/.error= 4 | http\://repo1.maven.org/maven2/.lastUpdated=1353569536978 5 | -------------------------------------------------------------------------------- /lib/io/netty/netty/3.5.1/netty-3.5.1.pom.lastUpdated: -------------------------------------------------------------------------------- 1 | #NOTE: This is an internal implementation file, its format can be changed without prior notice. 2 | #Thu Nov 22 15:32:16 CST 2012 3 | http\://repo1.maven.org/maven2/.error= 4 | http\://repo1.maven.org/maven2/.lastUpdated=1353569536249 5 | -------------------------------------------------------------------------------- /lib/io/netty/netty/4.0.0.Alpha1/_maven.repositories: -------------------------------------------------------------------------------- 1 | #NOTE: This is an internal implementation file, its format can be changed without prior notice. 2 | #Thu Nov 22 15:32:14 CST 2012 3 | netty-4.0.0.Alpha1.jar>central= 4 | netty-4.0.0.Alpha1.pom>central= 5 | -------------------------------------------------------------------------------- /lib/io/netty/netty/4.0.0.Alpha1/netty-4.0.0.Alpha1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xishuixixia/Hetty/49919c50e64889af7769d5d30cd00e58852502a6/lib/io/netty/netty/4.0.0.Alpha1/netty-4.0.0.Alpha1.jar -------------------------------------------------------------------------------- /lib/io/netty/netty/4.0.0.Alpha1/netty-4.0.0.Alpha1.jar.sha1: -------------------------------------------------------------------------------- 1 | b4293df72f048b78b02d4e73adc706ca94efad7d -------------------------------------------------------------------------------- /lib/io/netty/netty/4.0.0.Alpha1/netty-4.0.0.Alpha1.pom: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 4.0.0 20 | 21 | io.netty 22 | netty-parent 23 | 4.0.0.Alpha1 24 | 25 | 26 | netty 27 | jar 28 | 29 | Netty/All-in-One 30 | 31 | 32 | 33 | 34 | ${project.groupId} 35 | netty-example 36 | ${project.version} 37 | compile 38 | true 39 | 40 | 41 | 42 | com.google.protobuf 43 | protobuf-java 44 | compile 45 | true 46 | 47 | 48 | org.jboss.marshalling 49 | jboss-marshalling 50 | compile 51 | true 52 | 53 | 54 | org.slf4j 55 | slf4j-api 56 | compile 57 | true 58 | 59 | 60 | commons-logging 61 | commons-logging 62 | compile 63 | true 64 | 65 | 66 | org.jboss.logging 67 | jboss-logging-spi 68 | compile 69 | true 70 | 71 | 72 | log4j 73 | log4j 74 | compile 75 | true 76 | 77 | 78 | org.osgi 79 | org.osgi.core 80 | compile 81 | true 82 | 83 | 84 | org.osgi 85 | org.osgi.compendium 86 | compile 87 | true 88 | 89 | 90 | 91 | 92 | 93 | 94 | maven-clean-plugin 95 | 2.5 96 | 97 | 98 | clean-first 99 | generate-resources 100 | 101 | clean 102 | 103 | 104 | 105 | 106 | 107 | maven-dependency-plugin 108 | 2.4 109 | 110 | 111 | unpack-sources 112 | prepare-package 113 | 114 | unpack-dependencies 115 | 116 | 117 | sources 118 | io/netty/** 119 | ${project.groupId} 120 | ${project.build.directory}/src 121 | 122 | 123 | 124 | unpack-jars 125 | prepare-package 126 | 127 | unpack-dependencies 128 | 129 | 130 | io/netty/** 131 | io/netty/example/** 132 | ${project.build.outputDirectory} 133 | 134 | 135 | 136 | 137 | 138 | org.codehaus.mojo 139 | build-helper-maven-plugin 140 | 1.7 141 | 142 | 143 | add-source 144 | prepare-package 145 | 146 | add-source 147 | 148 | 149 | 150 | target/src 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | org.codehaus.mojo 160 | animal-sniffer-maven-plugin 161 | 162 | 163 | default 164 | none 165 | 166 | 167 | 168 | 169 | 170 | maven-checkstyle-plugin 171 | 172 | 173 | check-style 174 | none 175 | 176 | 177 | 178 | 179 | 180 | maven-resources-plugin 181 | 2.5 182 | 183 | 184 | default-resources 185 | none 186 | 187 | 188 | default-testResources 189 | none 190 | 191 | 192 | 193 | 194 | maven-compiler-plugin 195 | 196 | 197 | default-compile 198 | none 199 | 200 | 201 | default-testCompile 202 | none 203 | 204 | 205 | 206 | 207 | maven-surefire-plugin 208 | 209 | 210 | default-test 211 | none 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | full 221 | 222 | 223 | 224 | maven-jxr-plugin 225 | 2.2 226 | 227 | 228 | generate-xref 229 | package 230 | 231 | jxr 232 | 233 | 234 | 235 | 236 | UTF-8 237 | UTF-8 238 | true 239 | ${project.build.directory}/xref 240 | ${project.build.directory}/api 241 | Netty Source Xref (${project.version}) 242 | Netty Source Xref (${project.version}) 243 | 244 | 245 | 246 | maven-javadoc-plugin 247 | 2.8.1 248 | 249 | 250 | javadoc 251 | package 252 | 253 | jar 254 | 255 | 256 | false 257 | *.internal,*.example 258 | org.jboss.apiviz.APIviz 259 | ${project.basedir}/lib/apiviz-1.3.1-jdk7.jar 260 | true 261 | true 262 | ${project.build.directory}/api 263 | ${project.build.directory} 264 | api 265 | UTF-8 266 | UTF-8 267 | true 268 | false 269 | false 270 | true 271 | ${basedir}/src/javadoc/overview.html 272 | Netty API Reference (${project.version}) 273 | Netty API Reference (${project.version}) 274 | false 275 | 276 | -link http://docs.oracle.com/javase/7/docs/api/ 277 | -link http://code.google.com/apis/protocolbuffers/docs/reference/java/ 278 | -link http://docs.oracle.com/javaee/6/api/ 279 | -link http://www.osgi.org/javadoc/r4v43/core/ 280 | -link http://www.slf4j.org/apidocs/ 281 | -link http://commons.apache.org/logging/commons-logging-1.1.1/apidocs/ 282 | -link http://logging.apache.org/log4j/1.2/apidocs/ 283 | 284 | -group "Low-level data representation" io.netty.buffer* 285 | -group "Central interface for all I/O operations" io.netty.channel* 286 | -group "Client & Server bootstrapping utilities" io.netty.bootstrap* 287 | -group "Reusable I/O event interceptors" io.netty.handler* 288 | -group "Miscellaneous" io.netty.logging*:io.netty.util* 289 | 290 | -sourceclasspath ${project.build.outputDirectory} 291 | -nopackagediagram 292 | 293 | UTF-8 294 | en_US 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | -------------------------------------------------------------------------------- /lib/io/netty/netty/4.0.0.Alpha1/netty-4.0.0.Alpha1.pom.sha1: -------------------------------------------------------------------------------- 1 | 10623c4bb49f070429418c4fb26227d7291645b9 -------------------------------------------------------------------------------- /lib/junit/junit/3.8.1/_maven.repositories: -------------------------------------------------------------------------------- 1 | #NOTE: This is an internal implementation file, its format can be changed without prior notice. 2 | #Thu Nov 22 12:13:07 CST 2012 3 | junit-3.8.1.jar>central= 4 | junit-3.8.1.pom>central= 5 | -------------------------------------------------------------------------------- /lib/junit/junit/3.8.1/junit-3.8.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xishuixixia/Hetty/49919c50e64889af7769d5d30cd00e58852502a6/lib/junit/junit/3.8.1/junit-3.8.1.jar -------------------------------------------------------------------------------- /lib/junit/junit/3.8.1/junit-3.8.1.jar.sha1: -------------------------------------------------------------------------------- 1 | 99129f16442844f6a4a11ae22fbbee40b14d774f -------------------------------------------------------------------------------- /lib/junit/junit/3.8.1/junit-3.8.1.pom: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | junit 7 | junit 8 | 3.8.1 9 | JUnit 10 | http://junit.org 11 | 12 | JUnit is a regression testing framework written by Erich Gamma and Kent Beck. It is used by the developer who implements unit tests in Java. 13 | 14 | 15 | JUnit 16 | http://www.junit.org 17 | 18 | 19 | 20 | Common Public License Version 1.0 21 | http://www.opensource.org/licenses/cpl1.0.txt 22 | 23 | 24 | 25 | http://junit.cvs.sourceforge.net/junit/ 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /lib/junit/junit/3.8.1/junit-3.8.1.pom.sha1: -------------------------------------------------------------------------------- 1 | 16d74791c801c89b0071b1680ea0bc85c93417bb junit-3.8.1.pom 2 | -------------------------------------------------------------------------------- /lib/junit/junit/4.10/_maven.repositories: -------------------------------------------------------------------------------- 1 | #NOTE: This is an internal implementation file, its format can be changed without prior notice. 2 | #Thu Nov 22 15:01:56 CST 2012 3 | junit-4.10.jar>central= 4 | junit-4.10.pom>central= 5 | -------------------------------------------------------------------------------- /lib/junit/junit/4.10/junit-4.10.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xishuixixia/Hetty/49919c50e64889af7769d5d30cd00e58852502a6/lib/junit/junit/4.10/junit-4.10.jar -------------------------------------------------------------------------------- /lib/junit/junit/4.10/junit-4.10.jar.sha1: -------------------------------------------------------------------------------- 1 | e4f1766ce7404a08f45d859fb9c226fc9e41a861 -------------------------------------------------------------------------------- /lib/junit/junit/4.10/junit-4.10.pom: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | junit 6 | junit 7 | 4.10 8 | JUnit 9 | http://junit.org 10 | 11 | JUnit is a regression testing framework written by Erich Gamma and Kent Beck. 12 | It is used by the developer who implements unit tests in Java. 13 | 14 | 15 | JUnit 16 | http://www.junit.org 17 | 18 | 19 | 20 | JUnit Mailing List 21 | junit@yahoogroups.com 22 | 23 | http://tech.groups.yahoo.com/group/junit/ 24 | 25 | 26 | 27 | 28 | 29 | Common Public License Version 1.0 30 | http://www.opensource.org/licenses/cpl1.0.txt 31 | 32 | 33 | 34 | scm:git:git://github.com/KentBeck/junit.git 35 | scm:git:git@github.com:KentBeck/junit.git 36 | http://github.com/KentBeck/junit/tree/master 37 | 38 | 39 | 40 | dsaff 41 | David Saff 42 | david@saff.net 43 | 44 | 45 | 46 | 47 | 48 | maven-compiler-plugin 49 | 50 | ISO-8859-1 51 | ${jdk.version} 52 | ${jdk.version} 53 | 54 | 55 | 56 | 57 | 58 | 59 | org.hamcrest 60 | hamcrest-core 61 | 1.1 62 | compile 63 | 64 | 65 | 66 | 67 | 1.5 68 | 69 | -------------------------------------------------------------------------------- /lib/junit/junit/4.10/junit-4.10.pom.sha1: -------------------------------------------------------------------------------- 1 | 35bef83e80c3431f95d267e19252bddfe965041c -------------------------------------------------------------------------------- /lib/junit/junit/4.7/_maven.repositories: -------------------------------------------------------------------------------- 1 | #NOTE: This is an internal implementation file, its format can be changed without prior notice. 2 | #Thu Nov 22 14:57:47 CST 2012 3 | junit-4.7.jar>central= 4 | junit-4.7.pom>central= 5 | -------------------------------------------------------------------------------- /lib/junit/junit/4.7/junit-4.7.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xishuixixia/Hetty/49919c50e64889af7769d5d30cd00e58852502a6/lib/junit/junit/4.7/junit-4.7.jar -------------------------------------------------------------------------------- /lib/junit/junit/4.7/junit-4.7.jar.sha1: -------------------------------------------------------------------------------- 1 | d9444742a5b897c6280724a49f57a8155517d21f /home/maven/repository-staging/to-ibiblio/maven2/junit/junit/4.7/junit-4.7.jar 2 | -------------------------------------------------------------------------------- /lib/junit/junit/4.7/junit-4.7.pom: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | junit 5 | junit 6 | 4.7 7 | JUnit 8 | http://junit.org 9 | 10 | JUnit is a regression testing framework written by Erich Gamma and Kent Beck. It is used by the developer who implements unit tests in Java. 11 | 12 | 13 | JUnit 14 | http://www.junit.org 15 | 16 | 17 | 18 | Common Public License Version 1.0 19 | http://www.opensource.org/licenses/cpl1.0.txt 20 | 21 | 22 | 23 | http://github.com/KentBeck/junit/tree/master 24 | 25 | 26 | 33 | 34 | -------------------------------------------------------------------------------- /lib/junit/junit/4.7/junit-4.7.pom.sha1: -------------------------------------------------------------------------------- 1 | fe6c5b98240ddc62e326ac27c12c46fd45ba78b0 /home/maven/repository-staging/to-ibiblio/maven2/junit/junit/4.7/junit-4.7.pom 2 | -------------------------------------------------------------------------------- /lib/junit/junit/4.8.2/_maven.repositories: -------------------------------------------------------------------------------- 1 | #NOTE: This is an internal implementation file, its format can be changed without prior notice. 2 | #Thu Nov 22 11:13:10 CST 2012 3 | junit-4.8.2.pom>nexusShow= 4 | -------------------------------------------------------------------------------- /lib/junit/junit/4.8.2/junit-4.8.2.pom: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | junit 5 | junit 6 | 4.8.2 7 | jar 8 | JUnit 9 | http://junit.org 10 | 11 | JUnit is a regression testing framework. It is used by the developer who implements unit tests in Java. 12 | 13 | 14 | JUnit 15 | http://www.junit.org 16 | 17 | 18 | 19 | Common Public License Version 1.0 20 | http://www.opensource.org/licenses/cpl1.0.txt 21 | 22 | 23 | 24 | http://github.com/KentBeck/junit 25 | scm:git:git://github.com/KentBeck/junit.git 26 | 27 | 28 | 35 | 36 | 37 | 38 | Erich Gamma 39 | 40 | 41 | Kent Beck 42 | 43 | 44 | David Saff 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /lib/junit/junit/4.8.2/junit-4.8.2.pom.sha1: -------------------------------------------------------------------------------- 1 | c9c2d21b75368533f8a5ec1fefa2633989e80294 -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | com.hetty 6 | hetty-all 7 | 1.2.4 8 | jar 9 | 10 | hetty-all 11 | http://maven.apache.org 12 | 13 | 14 | UTF-8 15 | 16 | 17 | 18 | 19 | junit 20 | junit 21 | 4.10 22 | test 23 | 24 | 25 | org.slf4j 26 | slf4j-api 27 | 1.6.6 28 | 29 | 30 | dom4j 31 | dom4j 32 | 1.6.1 33 | 34 | 35 | io.netty 36 | netty 37 | 3.5.1.Final 38 | 39 | 40 | hessian 41 | hessian 42 | 4.0.7 43 | 44 | 45 | commons-codec 46 | commons-codec 47 | 1.7 48 | 49 | 50 | com.esotericsoftware.reflectasm 51 | reflectasm 52 | 1.07 53 | 54 | 55 | bouncycastle 56 | bcprov-jdk15 57 | 140 58 | 59 | 60 | 61 | 62 | 63 | maven-compiler-plugin 64 | 65 | 1.6 66 | 1.6 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /src/main/java/com/hetty/conf/ConfigParser.java: -------------------------------------------------------------------------------- 1 | package com.hetty.conf; 2 | 3 | import java.util.List; 4 | 5 | import com.hetty.object.Application; 6 | import com.hetty.object.Service; 7 | import com.hetty.object.ServiceVersion; 8 | 9 | public interface ConfigParser { 10 | List parseService(); 11 | 12 | List parseApplication(); 13 | 14 | List parseSecurity(); 15 | } -------------------------------------------------------------------------------- /src/main/java/com/hetty/conf/HettyConfig.java: -------------------------------------------------------------------------------- 1 | package com.hetty.conf; 2 | 3 | import java.io.FileNotFoundException; 4 | 5 | import java.io.IOException; 6 | import java.io.InputStream; 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | import java.util.Properties; 10 | import java.util.Set; 11 | 12 | import org.slf4j.Logger; 13 | import org.slf4j.LoggerFactory; 14 | 15 | import com.hetty.object.HettyException; 16 | import com.hetty.util.StringUtil; 17 | 18 | 19 | /** 20 | * @author guolei 21 | * 22 | */ 23 | public class HettyConfig { 24 | 25 | private static Logger logger = LoggerFactory.getLogger(HettyConfig.class); 26 | 27 | private static Properties properties = new Properties(); 28 | private static HettyConfig instance = null; 29 | 30 | private HettyConfig(){ 31 | 32 | } 33 | 34 | /** 35 | * return instance 36 | * @return 37 | */ 38 | public static HettyConfig getInstance() { 39 | if (instance == null) { 40 | instance = new HettyConfig(); 41 | } 42 | return instance; 43 | } 44 | /** 45 | * load config file 46 | * Example: loadPropertyFile("server.properties"); 47 | * @param file class path 48 | */ 49 | public void loadPropertyFile(String file) { 50 | if (StringUtil.isEmpty(file)) { 51 | throw new IllegalArgumentException( 52 | "Parameter of file can not be blank"); 53 | } 54 | if (file.contains("..")) { 55 | throw new IllegalArgumentException( 56 | "Parameter of file can not contains \"..\""); 57 | } 58 | InputStream inputStream = null; 59 | try { 60 | inputStream = Thread.currentThread().getContextClassLoader() 61 | .getResourceAsStream(file); 62 | properties.load(inputStream); 63 | } catch (FileNotFoundException e) { 64 | throw new IllegalArgumentException("Properties file not found: " 65 | + file); 66 | } catch (IOException e) { 67 | throw new IllegalArgumentException( 68 | "Properties file can not be loading: " + file); 69 | } finally { 70 | try { 71 | if (inputStream != null) 72 | inputStream.close(); 73 | } catch (IOException e) { 74 | logger.error(e.getMessage(), e); 75 | } 76 | } 77 | if (properties == null) 78 | throw new RuntimeException("Properties file loading failed: "+ file); 79 | } 80 | 81 | public String getProperty(String key) { 82 | return properties.getProperty(key).trim(); 83 | } 84 | 85 | public String getProperty(String key, String defaultValue) { 86 | return properties.getProperty(key, defaultValue.trim()); 87 | } 88 | 89 | public Properties getProperties() { 90 | return properties; 91 | } 92 | 93 | /** 94 | * get server key 95 | * @return server key 96 | */ 97 | public String getServerKey() { 98 | String serverKey = properties.getProperty("server.key"); 99 | if (serverKey == null) { 100 | throw new RuntimeException("we cannot find the server.key,please check and add."); 101 | } 102 | return serverKey.trim(); 103 | } 104 | 105 | /** 106 | * get server secret 107 | * @return server secret 108 | */ 109 | public String getServerSecret() { 110 | String serverSecret = properties.getProperty("server.secret"); 111 | if (serverSecret == null) { 112 | throw new RuntimeException("we cannot find the server.secret,please check and add."); 113 | } 114 | return serverSecret.trim(); 115 | } 116 | 117 | /** 118 | * get the service properties file,default is config.xml 119 | * @return 120 | */ 121 | public String getpropertiesFile() { 122 | String f = properties.getProperty("properties.file", "config.xml"); 123 | return f.trim(); 124 | } 125 | 126 | /** 127 | * get the server's connect timeout,default is 3s 128 | * @return 129 | */ 130 | public int getConnectionTimeout() { 131 | String timeOutStr = properties.getProperty("server.connection.timeout", 132 | "3000"); 133 | return Integer.parseInt(timeOutStr); 134 | } 135 | 136 | /** 137 | * get the method's invoke timeout,default is 3s 138 | * @return 139 | */ 140 | public int getMethodTimeout() { 141 | String timeOutStr = properties.getProperty("server.method.timeout", "3000"); 142 | return Integer.parseInt(timeOutStr); 143 | } 144 | 145 | /** 146 | * get the server's HTTP port,default is -1 147 | * @return 148 | */ 149 | public int getHttpPort() { 150 | String port = properties.getProperty("server.http.port", "-1"); 151 | return Integer.parseInt(port); 152 | } 153 | /** 154 | * get the server's HTTPS port,default is -1 155 | * @return 156 | */ 157 | public int getHttpsPort() { 158 | String port = properties.getProperty("server.https.port", "-1"); 159 | return Integer.parseInt(port); 160 | } 161 | 162 | /** 163 | * get the ssl client auth 164 | * @return 165 | */ 166 | public String getClientAuth() { 167 | return properties.getProperty("ssl.clientAuth", "none").trim(); 168 | } 169 | /** 170 | * get the ssl keystore file path 171 | * @return 172 | */ 173 | public String getKeyStorePath() { 174 | return properties.getProperty("ssl.keystore.file").trim(); 175 | } 176 | /** 177 | * get the ssl keystore password 178 | * @return 179 | */ 180 | public String getKeyStorePassword() { 181 | return properties.getProperty("ssl.keystore.password").trim(); 182 | } 183 | /** 184 | * get the ssl certificate key file path 185 | * @return 186 | */ 187 | public String getCertificateKeyFile() { 188 | return properties.getProperty("ssl.certificate.key.file").trim(); 189 | } 190 | /** 191 | * get the ssl certificate file path 192 | * @return 193 | */ 194 | public String getCertificateFile() { 195 | return properties.getProperty("ssl.certificate.file").trim(); 196 | } 197 | /** 198 | * get the ssl certificate password 199 | * @return 200 | */ 201 | public String getCertificatePassword() { 202 | return properties.getProperty("ssl.certificate.password").trim(); 203 | } 204 | /** 205 | * get the core number of threads 206 | * @return 207 | */ 208 | public int getServerCorePoolSize(){ 209 | String coreSize = properties.getProperty("server.thread.corePoolSize", "4"); 210 | return Integer.parseInt(coreSize); 211 | } 212 | /** 213 | * get the maximum allowed number of threads 214 | * @return 215 | */ 216 | public int getServerMaximumPoolSize(){ 217 | String maxSize = properties.getProperty("server.thread.maxPoolSize","16"); 218 | return Integer.parseInt(maxSize); 219 | } 220 | /** 221 | * get the thread keep-alive time, which is the amount of time that threads in excess of the core pool size may remain idle before being terminated 222 | * @return 223 | */ 224 | public int getServerKeepAliveTime(){ 225 | String aleveTime = properties.getProperty("server.thread.keepAliveTime", "3000"); 226 | return Integer.parseInt(aleveTime); 227 | } 228 | 229 | /** 230 | * get the plugin list which have configured in the server config file 231 | * 232 | * @return config class List 233 | */ 234 | public List> getPluginClassList() { 235 | 236 | Set keySet = properties.stringPropertyNames(); 237 | List> list = new ArrayList>(); 238 | ClassLoader classLoader = Thread.currentThread() 239 | .getContextClassLoader(); 240 | try { 241 | for (String key : keySet) { 242 | if (key.startsWith("server.plugin")) { 243 | String cls = properties.getProperty(key); 244 | Class cls1 = classLoader.loadClass(cls); 245 | list.add(cls1); 246 | } 247 | } 248 | if (list.size() == 0) { 249 | Class defaultClazz = classLoader 250 | .loadClass("com.hetty.plugin.XmlConfigPlugin"); 251 | list.add(defaultClazz); 252 | } 253 | } catch (ClassNotFoundException e) { 254 | e.printStackTrace(); 255 | throw new HettyException( 256 | "load plugin class failed.please check your plugin config."); 257 | } 258 | return list; 259 | } 260 | /** 261 | * get develop mod,default is false 262 | */ 263 | public boolean getDevMod(){ 264 | String dev = properties.getProperty("server.devmod", "false"); 265 | return Boolean.parseBoolean(dev); 266 | } 267 | } 268 | -------------------------------------------------------------------------------- /src/main/java/com/hetty/conf/XmlConfigParser.java: -------------------------------------------------------------------------------- 1 | package com.hetty.conf; 2 | 3 | import java.io.IOException; 4 | 5 | import java.io.InputStream; 6 | import java.util.ArrayList; 7 | import java.util.LinkedList; 8 | import java.util.List; 9 | 10 | import org.dom4j.Document; 11 | import org.dom4j.DocumentException; 12 | import org.dom4j.Element; 13 | import org.dom4j.Node; 14 | import org.dom4j.io.SAXReader; 15 | import org.slf4j.Logger; 16 | import org.slf4j.LoggerFactory; 17 | 18 | import com.hetty.object.Application; 19 | import com.hetty.object.HettyException; 20 | import com.hetty.object.Service; 21 | import com.hetty.object.ServiceProvider; 22 | import com.hetty.object.ServiceVersion; 23 | import com.hetty.util.StringUtil; 24 | 25 | public class XmlConfigParser implements ConfigParser { 26 | 27 | private final static Logger logger = LoggerFactory.getLogger(XmlConfigParser.class); 28 | 29 | private String configFile = null; 30 | private Document document; 31 | private Element root = null; 32 | 33 | public XmlConfigParser(String configFile) { 34 | this.configFile = configFile; 35 | root = getRoot(); 36 | } 37 | 38 | /** 39 | * analyse service configure and return a list,the list is a LocalService and each localService 40 | * corresponding a service 41 | */ 42 | @Override 43 | @SuppressWarnings("unchecked") 44 | public List parseService() { 45 | List slist = new ArrayList(); 46 | 47 | Node serviceRoot = root.selectSingleNode("//services"); 48 | 49 | List serviceList = serviceRoot.selectNodes("//service"); 50 | 51 | int i = 0; 52 | for (Element serviceNode : serviceList) { 53 | String name = serviceNode.attributeValue("name");// service name 54 | String interfaceStr = serviceNode.attributeValue("interface"); 55 | String overloadStr = serviceNode.attributeValue("overload"); 56 | 57 | if (StringUtil.isEmpty(name)) { 58 | logger.warn("you have a wrong config in " + configFile 59 | + ":a service's name is empty."); 60 | continue; 61 | } 62 | if (StringUtil.isEmpty(interfaceStr)) { 63 | logger.warn("you have a wrong config in " + configFile 64 | + ":service[" + name 65 | + "] has an empty interface configure."); 66 | continue; 67 | } 68 | Class type = null; 69 | try { 70 | type = Class.forName(interfaceStr); 71 | } catch (ClassNotFoundException e) { 72 | logger.error(e.getMessage()); 73 | throw new RuntimeException("can't find service Interface:"+interfaceStr); 74 | } 75 | Service service = new Service("" + i, name); 76 | service.setTypeClass(type); 77 | 78 | if (StringUtil.isNotEmpty(overloadStr) && "true".equals(overloadStr.trim())) { 79 | service.setOverload(true); 80 | } 81 | 82 | List versionList = serviceNode.selectNodes("provider"); 83 | for (Element element : versionList) { 84 | String version = element.attributeValue("version"); 85 | String processor = element.attributeValue("class"); 86 | String isDefault = element.attributeValue("default"); 87 | Class providerClass = null; 88 | try { 89 | providerClass = Class.forName(processor); 90 | } catch (ClassNotFoundException e) { 91 | logger.error(e.getMessage()); 92 | throw new RuntimeException("can't find service provider Class:"+processor); 93 | } 94 | ServiceProvider sv = new ServiceProvider(version, providerClass); 95 | if (StringUtil.isNotEmpty(version) && StringUtil.isNotEmpty(isDefault) 96 | && "true".equals(isDefault.trim())) { 97 | service.setDefaultVersion(version); 98 | } 99 | service.addServiceProvider(version,sv); 100 | } 101 | slist.add(service); 102 | i++; 103 | } 104 | return slist; 105 | } 106 | 107 | 108 | /** 109 | * parse application 110 | */ 111 | @Override 112 | @SuppressWarnings("unchecked") 113 | public List parseApplication() { 114 | List appList = new LinkedList(); 115 | Element aroot = getRoot(); 116 | Node root = aroot.selectSingleNode("//applications"); 117 | List elementList = root.selectNodes("application"); 118 | for (Element e : elementList) { 119 | String user = e.attributeValue("user"); 120 | String password = e.attributeValue("password"); 121 | Application app = new Application(); 122 | app.setUser(user); 123 | app.setPassword(password); 124 | appList.add(app); 125 | } 126 | return appList; 127 | } 128 | 129 | 130 | 131 | /** 132 | * get the config xml's security info 133 | */ 134 | @SuppressWarnings("unchecked") 135 | @Override 136 | public List parseSecurity() { 137 | List versionList = new LinkedList(); 138 | Element aroot = getRoot(); 139 | Node root = aroot.selectSingleNode("//security-settings"); 140 | if(root == null){ 141 | return null; 142 | } 143 | List sList = root.selectNodes("security-setting"); 144 | for (Element element : sList) { 145 | String user = element.attributeValue("user"); 146 | String service = element.attributeValue("service"); 147 | if(StringUtil.isEmpty(user) || StringUtil.isEmpty(service)){ 148 | throw new HettyException("In config file's security-settings,user or service cannot't be empty!"); 149 | } 150 | String version = element.attributeValue("version"); 151 | 152 | ServiceVersion serviceVersion = new ServiceVersion(); 153 | serviceVersion.setUser(user); 154 | serviceVersion.setService(service); 155 | serviceVersion.setVersion(version); 156 | versionList.add(serviceVersion); 157 | } 158 | return versionList; 159 | } 160 | 161 | @SuppressWarnings("unchecked") 162 | private Element getRoot() { 163 | try { 164 | Document doc = getDocument(); 165 | List list = doc.selectNodes("//deployment"); 166 | if (list.size() > 0) { 167 | Element aroot = list.get(0); 168 | return aroot; 169 | } 170 | } catch (DocumentException e) { 171 | e.printStackTrace(); 172 | }catch(IOException e1){ 173 | e1.printStackTrace(); 174 | } 175 | return null; 176 | } 177 | 178 | private Document getDocument() throws DocumentException, IOException { 179 | InputStream is = getFileStream(); 180 | try { 181 | if (document == null) { 182 | SAXReader reader = new SAXReader(); 183 | reader.setValidation(false); 184 | if (is == null) { 185 | throw new RuntimeException( 186 | "we can not find the service config file:" 187 | + configFile); 188 | } 189 | document = reader.read(is); 190 | } 191 | } catch (Exception e) { 192 | logger.error(e.getMessage(),e); 193 | throw new RuntimeException("get xml Document failed."); 194 | } finally { 195 | is.close(); 196 | } 197 | return document; 198 | } 199 | 200 | private InputStream getFileStream() { 201 | return getFileStream(configFile); 202 | } 203 | 204 | private InputStream getFileStream(String file) { 205 | InputStream is = Thread.currentThread().getContextClassLoader() 206 | .getResourceAsStream(file); 207 | return is; 208 | } 209 | } -------------------------------------------------------------------------------- /src/main/java/com/hetty/core/Hetty.java: -------------------------------------------------------------------------------- 1 | package com.hetty.core; 2 | 3 | import java.io.IOException; 4 | import java.net.DatagramSocket; 5 | import java.net.InetSocketAddress; 6 | import java.net.ServerSocket; 7 | import java.util.List; 8 | import java.util.concurrent.ExecutorService; 9 | import java.util.concurrent.Executors; 10 | import java.util.concurrent.SynchronousQueue; 11 | import java.util.concurrent.ThreadFactory; 12 | import java.util.concurrent.ThreadPoolExecutor; 13 | import java.util.concurrent.TimeUnit; 14 | 15 | import org.jboss.netty.bootstrap.ServerBootstrap; 16 | import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory; 17 | import org.slf4j.Logger; 18 | import org.slf4j.LoggerFactory; 19 | 20 | import com.hetty.conf.HettyConfig; 21 | import com.hetty.core.ssl.SslHettyChannelPipelineFactory; 22 | import com.hetty.object.Application; 23 | import com.hetty.object.HettyException; 24 | import com.hetty.plugin.IPlugin; 25 | import com.hetty.util.FileUtil; 26 | import com.hetty.util.StringUtil; 27 | 28 | 29 | /** 30 | * @author guolei 31 | * 32 | */ 33 | public final class Hetty { 34 | 35 | private static Logger logger = LoggerFactory.getLogger(Hetty.class); 36 | 37 | private ServerBootstrap httpBootstrap = null; 38 | private ServerBootstrap httpsBootstrap = null; 39 | private HettyConfig hettyConfig = HettyConfig.getInstance(); 40 | private int httpListenPort; 41 | private int httpsListenPort; 42 | 43 | public Hetty(){ 44 | HettyConfig.getInstance().loadPropertyFile("server.properties");//default file is this. 45 | } 46 | public Hetty(String file){ 47 | HettyConfig.getInstance().loadPropertyFile(file); 48 | } 49 | 50 | private void init() { 51 | initServerInfo(); 52 | initHettySecurity(); 53 | initPlugins(); 54 | initServiceMetaData(); 55 | if (httpListenPort == -1 && httpsListenPort == -1) { 56 | httpListenPort = 8081;//default port is 8081 57 | } 58 | if (httpListenPort != -1) { 59 | initHttpBootstrap(); 60 | } 61 | if (httpsListenPort != -1) { 62 | initHttpsBootstrap(); 63 | } 64 | } 65 | /** 66 | * init hetty server info 67 | */ 68 | private void initServerInfo(){ 69 | httpListenPort = hettyConfig.getHttpPort(); 70 | httpsListenPort = hettyConfig.getHttpsPort(); 71 | } 72 | /** 73 | * init http bootstrap 74 | */ 75 | private void initHttpBootstrap(){ 76 | logger.info("init HTTP Bootstrap..........."); 77 | ThreadFactory serverBossTF = new NamedThreadFactory("HETTY-BOSS-"); 78 | ThreadFactory serverWorkerTF = new NamedThreadFactory("HETTY-WORKER-"); 79 | httpBootstrap = new ServerBootstrap(new NioServerSocketChannelFactory( 80 | Executors.newCachedThreadPool(serverBossTF), 81 | Executors.newCachedThreadPool(serverWorkerTF))); 82 | httpBootstrap.setOption("tcpNoDelay", Boolean.parseBoolean(hettyConfig 83 | .getProperty("hetty.tcp.nodelay", "true"))); 84 | httpBootstrap.setOption("reuseAddress", Boolean.parseBoolean(hettyConfig 85 | .getProperty("hetty.tcp.reuseaddress", "true"))); 86 | 87 | int coreSize = hettyConfig.getServerCorePoolSize(); 88 | int maxSize = hettyConfig.getServerMaximumPoolSize(); 89 | int keepAlive = hettyConfig.getServerKeepAliveTime(); 90 | ThreadFactory threadFactory = new NamedThreadFactory("hetty-"); 91 | ExecutorService threadPool = new ThreadPoolExecutor(coreSize, maxSize, keepAlive, 92 | TimeUnit.SECONDS, new SynchronousQueue(), threadFactory); 93 | httpBootstrap.setPipelineFactory(new HettyChannelPipelineFactory(threadPool)); 94 | 95 | if (!checkPortConfig(httpListenPort)) { 96 | throw new IllegalStateException("port: " + httpListenPort + " already in use!"); 97 | } 98 | httpBootstrap.bind(new InetSocketAddress(httpListenPort)); 99 | } 100 | /** 101 | * init https bootstrap 102 | */ 103 | private void initHttpsBootstrap(){ 104 | if(!checkHttpsConfig()){ 105 | return; 106 | } 107 | logger.info("init HTTPS Bootstrap..........."); 108 | ThreadFactory serverBossTF = new NamedThreadFactory("HETTY-BOSS-"); 109 | ThreadFactory serverWorkerTF = new NamedThreadFactory("HETTY-WORKER-"); 110 | httpsBootstrap = new ServerBootstrap(new NioServerSocketChannelFactory( 111 | Executors.newCachedThreadPool(serverBossTF), 112 | Executors.newCachedThreadPool(serverWorkerTF))); 113 | httpsBootstrap.setOption("tcpNoDelay", Boolean.parseBoolean(hettyConfig 114 | .getProperty("hetty.tcp.nodelay", "true"))); 115 | httpsBootstrap.setOption("reuseAddress", Boolean.parseBoolean(hettyConfig 116 | .getProperty("hetty.tcp.reuseaddress", "true"))); 117 | 118 | int coreSize = hettyConfig.getServerCorePoolSize(); 119 | int maxSize = hettyConfig.getServerMaximumPoolSize(); 120 | int keepAlive = hettyConfig.getServerKeepAliveTime(); 121 | ThreadFactory threadFactory = new NamedThreadFactory("hetty-"); 122 | ExecutorService threadPool = new ThreadPoolExecutor(coreSize, maxSize, keepAlive, 123 | TimeUnit.SECONDS, new SynchronousQueue(), threadFactory); 124 | httpsBootstrap.setPipelineFactory(new SslHettyChannelPipelineFactory(threadPool)); 125 | 126 | if (!checkPortConfig(httpsListenPort)) { 127 | throw new IllegalStateException("port: " + httpsListenPort + " already in use!"); 128 | } 129 | httpsBootstrap.bind(new InetSocketAddress(httpsListenPort)); 130 | } 131 | 132 | /** 133 | * init plugins 134 | */ 135 | private void initPlugins() { 136 | logger.info("init plugins..........."); 137 | List> pluginList = hettyConfig.getPluginClassList(); 138 | try { 139 | for (Class cls : pluginList) { 140 | IPlugin p; 141 | p = (IPlugin) cls.newInstance(); 142 | p.start(); 143 | } 144 | } catch (InstantiationException e) { 145 | logger.error("init plugin failed."); 146 | e.printStackTrace(); 147 | } catch (IllegalAccessException e) { 148 | // TODO Auto-generated catch block 149 | logger.error("init plugin failed."); 150 | e.printStackTrace(); 151 | } 152 | } 153 | /** 154 | * init service metaData 155 | */ 156 | private void initServiceMetaData() { 157 | // TODO Auto-generated method stub 158 | logger.info("init service MetaData..........."); 159 | MetadataProcessor.initMetaDataMap(); 160 | } 161 | /** 162 | * init service metaData 163 | */ 164 | private void initHettySecurity() { 165 | // TODO Auto-generated method stub 166 | logger.info("init hetty security..........."); 167 | Application app = new Application(hettyConfig.getServerKey(),hettyConfig.getServerSecret()); 168 | HettySecurity.addToApplicationMap(app); 169 | } 170 | /** 171 | * check the netty listen port 172 | * @param listenPort 173 | * @return 174 | */ 175 | private boolean checkPortConfig(int listenPort) { 176 | if (listenPort < 0 || listenPort > 65536) { 177 | throw new IllegalArgumentException("Invalid start port: " 178 | + listenPort); 179 | } 180 | ServerSocket ss = null; 181 | DatagramSocket ds = null; 182 | try { 183 | ss = new ServerSocket(listenPort); 184 | ss.setReuseAddress(true); 185 | ds = new DatagramSocket(listenPort); 186 | ds.setReuseAddress(true); 187 | return true; 188 | } catch (IOException e) { 189 | } finally { 190 | if (ds != null) { 191 | ds.close(); 192 | } 193 | if (ss != null) { 194 | try { 195 | ss.close(); 196 | } catch (IOException e) { 197 | // should not be thrown, just detect port available. 198 | } 199 | } 200 | } 201 | return false; 202 | } 203 | /** 204 | * check https config 205 | * @return 206 | */ 207 | private boolean checkHttpsConfig(){ 208 | if(StringUtil.isNotEmpty(hettyConfig.getKeyStorePath())){ 209 | if(!FileUtil.getFile(hettyConfig.getKeyStorePath()).exists()){ 210 | throw new HettyException("we can't find the file which you configure:[ssl.keystore.file]"); 211 | } 212 | }else if(StringUtil.isNotEmpty(hettyConfig.getCertificateKeyFile()) && 213 | StringUtil.isNotEmpty(hettyConfig.getCertificateFile())){ 214 | if(!FileUtil.getFile(hettyConfig.getCertificateKeyFile()).exists()){ 215 | throw new HettyException("we can't find the file which you configure:[ssl.certificate.key.file]"); 216 | } 217 | if(!FileUtil.getFile(hettyConfig.getCertificateFile()).exists()){ 218 | throw new HettyException("we can't find the file which you configure:[ssl.certificate.file]"); 219 | } 220 | }else{ 221 | throw new HettyException("please check your ssl's config."); 222 | } 223 | return true; 224 | } 225 | public void serverLog(){ 226 | logger.info("devMod:"+hettyConfig.getDevMod()); 227 | logger.info("server key:"+hettyConfig.getServerKey()); 228 | logger.info("server secret:"+hettyConfig.getServerSecret()); 229 | if(httpListenPort != -1){ 230 | logger.info("Server started,listening for HTTP on port "+httpListenPort); 231 | } 232 | if(httpsListenPort != -1){ 233 | logger.info("Server started,listening for HTTPS on port "+httpsListenPort); 234 | } 235 | } 236 | /** 237 | * start hetty 238 | */ 239 | public void start(){ 240 | init(); 241 | serverLog(); 242 | } 243 | /** 244 | * stop hetty 245 | */ 246 | public void stop(){ 247 | logger.info("Server stop!"); 248 | if(httpBootstrap != null){ 249 | httpBootstrap.releaseExternalResources(); 250 | } 251 | if(httpsBootstrap != null){ 252 | httpsBootstrap.releaseExternalResources(); 253 | } 254 | } 255 | public static void main(String[] args) { 256 | new Hetty().start(); 257 | } 258 | } 259 | -------------------------------------------------------------------------------- /src/main/java/com/hetty/core/HettyChannelPipelineFactory.java: -------------------------------------------------------------------------------- 1 | package com.hetty.core; 2 | 3 | import static org.jboss.netty.channel.Channels.pipeline; 4 | 5 | import java.util.concurrent.ExecutorService; 6 | 7 | import org.jboss.netty.channel.ChannelPipeline; 8 | import org.jboss.netty.channel.ChannelPipelineFactory; 9 | import org.jboss.netty.handler.codec.http.HttpChunkAggregator; 10 | import org.jboss.netty.handler.codec.http.HttpContentCompressor; 11 | import org.jboss.netty.handler.codec.http.HttpRequestDecoder; 12 | import org.jboss.netty.handler.codec.http.HttpResponseEncoder; 13 | 14 | public class HettyChannelPipelineFactory implements ChannelPipelineFactory { 15 | 16 | private ExecutorService threadpool; 17 | 18 | public HettyChannelPipelineFactory(ExecutorService threadpool) { 19 | this.threadpool = threadpool; 20 | } 21 | 22 | @Override 23 | public ChannelPipeline getPipeline() throws Exception { 24 | ChannelPipeline pipeline = pipeline(); 25 | pipeline.addLast("decoder", new HttpRequestDecoder()); 26 | pipeline.addLast("aggregator", new HttpChunkAggregator(1048576)); 27 | pipeline.addLast("encoder", new HttpResponseEncoder()); 28 | pipeline.addLast("deflater", new HttpContentCompressor()); 29 | pipeline.addLast("handler", new HettyHandler(threadpool)); 30 | return pipeline; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/hetty/core/HettyHandler.java: -------------------------------------------------------------------------------- 1 | package com.hetty.core; 2 | 3 | import static org.jboss.netty.handler.codec.http.HttpHeaders.isKeepAlive; 4 | import static org.jboss.netty.handler.codec.http.HttpHeaders.Names.CONTENT_LENGTH; 5 | import static org.jboss.netty.handler.codec.http.HttpHeaders.Names.CONTENT_TYPE; 6 | import static org.jboss.netty.handler.codec.http.HttpResponseStatus.CONTINUE; 7 | import static org.jboss.netty.handler.codec.http.HttpVersion.HTTP_1_1; 8 | 9 | import java.io.ByteArrayInputStream; 10 | import java.io.ByteArrayOutputStream; 11 | import java.io.IOException; 12 | import java.io.InputStream; 13 | import java.io.OutputStream; 14 | import java.lang.reflect.InvocationTargetException; 15 | import java.lang.reflect.Method; 16 | import java.net.SocketAddress; 17 | import java.util.concurrent.ExecutorService; 18 | import java.util.concurrent.RejectedExecutionException; 19 | import java.util.concurrent.ThreadPoolExecutor; 20 | 21 | import org.apache.commons.codec.binary.Base64; 22 | import org.jboss.netty.buffer.ChannelBuffer; 23 | import org.jboss.netty.buffer.ChannelBuffers; 24 | import org.jboss.netty.channel.ChannelFuture; 25 | import org.jboss.netty.channel.ChannelFutureListener; 26 | import org.jboss.netty.channel.ChannelHandlerContext; 27 | import org.jboss.netty.channel.ExceptionEvent; 28 | import org.jboss.netty.channel.MessageEvent; 29 | import org.jboss.netty.channel.SimpleChannelUpstreamHandler; 30 | import org.jboss.netty.handler.codec.http.DefaultHttpResponse; 31 | import org.jboss.netty.handler.codec.http.HttpHeaders; 32 | import org.jboss.netty.handler.codec.http.HttpRequest; 33 | import org.jboss.netty.handler.codec.http.HttpResponse; 34 | import org.jboss.netty.handler.codec.http.HttpResponseStatus; 35 | import org.jboss.netty.util.CharsetUtil; 36 | import org.slf4j.Logger; 37 | import org.slf4j.LoggerFactory; 38 | 39 | import com.caucho.hessian.io.AbstractHessianInput; 40 | import com.caucho.hessian.io.AbstractHessianOutput; 41 | import com.caucho.hessian.io.Hessian2Input; 42 | import com.caucho.hessian.io.HessianFactory; 43 | import com.caucho.hessian.io.HessianInputFactory; 44 | import com.caucho.hessian.io.SerializerFactory; 45 | import com.caucho.services.server.ServiceContext; 46 | import com.hetty.object.RequestWrapper; 47 | 48 | public class HettyHandler extends SimpleChannelUpstreamHandler { 49 | 50 | private final Logger log = LoggerFactory 51 | .getLogger(HettyHandler.class); 52 | private HttpRequest request; 53 | private boolean readingChunks; 54 | private final StringBuilder buf = new StringBuilder(); 55 | private HessianInputFactory _inputFactory = new HessianInputFactory(); 56 | private HessianFactory _hessianFactory = new HessianFactory(); 57 | 58 | private SerializerFactory _serializerFactory; 59 | private ExecutorService threadpool; 60 | 61 | public HettyHandler(ExecutorService threadpool) { 62 | this.threadpool = threadpool; 63 | } 64 | 65 | @Override 66 | public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) 67 | throws Exception { 68 | if(!(e.getCause() instanceof IOException)){ 69 | log.error("catch some exception not IOException",e.getCause()); 70 | } 71 | } 72 | 73 | @Override 74 | public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) 75 | throws Exception { 76 | if (!readingChunks) { 77 | ByteArrayOutputStream os = new ByteArrayOutputStream(); 78 | HttpRequest request = this.request = (HttpRequest) e.getMessage(); 79 | HttpResponse response = new DefaultHttpResponse(HTTP_1_1, 80 | HttpResponseStatus.OK); 81 | 82 | String uri = request.getUri(); 83 | if (!uri.startsWith("/apis/")) { 84 | sendResourceNotFound(ctx, e); 85 | return; 86 | } 87 | if (uri.endsWith("/")) { 88 | uri = uri.substring(0, uri.length() - 1); 89 | } 90 | 91 | String serviceName = uri.substring(uri.lastIndexOf("/") + 1); 92 | 93 | //client ip 94 | SocketAddress remoteAddress = ctx.getChannel().getRemoteAddress(); 95 | String ipAddress = remoteAddress.toString().split(":")[0]; 96 | request.addHeader("Client-IP", ipAddress.substring(1)); 97 | handleService(serviceName, request, response, os, e); 98 | } 99 | } 100 | 101 | private void handleService(final String serviceName, 102 | final HttpRequest request, final HttpResponse response, 103 | final ByteArrayOutputStream os, final MessageEvent e) 104 | throws Exception { 105 | 106 | try { 107 | threadpool.execute(new Runnable() { 108 | @Override 109 | public void run() { 110 | try { 111 | service(serviceName, request, response, os); 112 | } catch (Exception e1) { 113 | log.error(e1.getMessage(), e1); 114 | } 115 | 116 | if (HttpHeaders.is100ContinueExpected(request)) { 117 | send100Continue(e); 118 | } 119 | if (request.isChunked()) { 120 | readingChunks = true; 121 | } else { 122 | writeResponse(e, response, os); 123 | } 124 | 125 | } 126 | }); 127 | } catch (RejectedExecutionException exception) { 128 | log.error("server threadpool full,threadpool maxsize is:" 129 | + ((ThreadPoolExecutor) threadpool).getMaximumPoolSize()); 130 | } 131 | } 132 | 133 | /** 134 | * send response 135 | * @param e 136 | * @param response 137 | * @param os 138 | */ 139 | private void writeResponse(MessageEvent e, HttpResponse response, 140 | ByteArrayOutputStream os) { 141 | 142 | boolean keepAlive = isKeepAlive(request); 143 | ChannelBuffer cb = ChannelBuffers.dynamicBuffer(); 144 | cb.writeBytes(os.toByteArray()); 145 | response.setContent(cb); 146 | 147 | if (keepAlive) { 148 | response.setHeader(CONTENT_LENGTH, response.getContent() 149 | .readableBytes()); 150 | } 151 | 152 | ChannelFuture future = e.getChannel().write(response); 153 | 154 | if (!keepAlive) { 155 | future.addListener(ChannelFutureListener.CLOSE); 156 | } 157 | } 158 | 159 | private void send100Continue(MessageEvent e) { 160 | HttpResponse response = new DefaultHttpResponse(HTTP_1_1, CONTINUE); 161 | ChannelBuffer content1 = request.getContent(); 162 | if (content1.readable()) { 163 | buf.append(content1.toString(CharsetUtil.UTF_8)); 164 | } 165 | ChannelFuture future = e.getChannel().write(response); 166 | boolean keepAlive = isKeepAlive(request); 167 | 168 | if (!keepAlive) { 169 | future.addListener(ChannelFutureListener.CLOSE); 170 | } 171 | } 172 | 173 | /** 174 | * Sets the serializer factory. 175 | */ 176 | public void setSerializerFactory(SerializerFactory factory) { 177 | _serializerFactory = factory; 178 | } 179 | 180 | /** 181 | * Gets the serializer factory. 182 | */ 183 | public SerializerFactory getSerializerFactory() { 184 | if (_serializerFactory == null) 185 | _serializerFactory = new SerializerFactory(); 186 | 187 | return _serializerFactory; 188 | } 189 | 190 | /** 191 | * Execute a request. The path-info of the request selects the bean. Once 192 | * the bean's selected, it will be applied. 193 | */ 194 | public void service(String serviceName, HttpRequest req, HttpResponse res, 195 | ByteArrayOutputStream os) { 196 | byte[] bytes = req.getContent().array();//get request content 197 | InputStream is = new ByteArrayInputStream(bytes); 198 | 199 | SerializerFactory serializerFactory = getSerializerFactory(); 200 | String username = null; 201 | String password = null; 202 | String[] authLink = getUsernameAndPassword(req); 203 | username = authLink[0].equals("")?null:authLink[0]; 204 | password = authLink[1].equals("")?null:authLink[1]; 205 | String clientIP = request.getHeader("Client-IP"); 206 | RequestWrapper rw = new RequestWrapper(username, password, clientIP, serviceName); 207 | 208 | 209 | invoke(rw, is, os, serializerFactory); 210 | } 211 | 212 | private String[] getUsernameAndPassword(HttpRequest req) { 213 | String auths = request.getHeader("Authorization"); 214 | if(auths == null){ 215 | String str[] = {"",""}; 216 | return str; 217 | } 218 | String auth[] = auths.split(" "); 219 | String bauth = auth[1]; 220 | String dauth = new String(Base64.decodeBase64(bauth)); 221 | String authLink[] = dauth.split(":"); 222 | return authLink; 223 | } 224 | 225 | protected void invoke(RequestWrapper rw, InputStream is, OutputStream os, 226 | SerializerFactory serializerFactory) { 227 | AbstractHessianInput in = null; 228 | AbstractHessianOutput out = null; 229 | String username = rw.getUser(); 230 | String password = rw.getPassword(); 231 | try { 232 | 233 | HessianInputFactory.HeaderType header = _inputFactory 234 | .readHeader(is); 235 | 236 | switch (header) { 237 | case CALL_1_REPLY_1: 238 | in = _hessianFactory.createHessianInput(is); 239 | out = _hessianFactory.createHessianOutput(os); 240 | break; 241 | 242 | case CALL_1_REPLY_2: 243 | in = _hessianFactory.createHessianInput(is); 244 | out = _hessianFactory.createHessian2Output(os); 245 | break; 246 | 247 | case HESSIAN_2: 248 | in = _hessianFactory.createHessian2Input(is); 249 | in.readCall(); 250 | out = _hessianFactory.createHessian2Output(os); 251 | break; 252 | 253 | default: 254 | throw new IllegalStateException(header 255 | + " is an unknown Hessian call"); 256 | } 257 | 258 | if (serializerFactory != null) { 259 | in.setSerializerFactory(serializerFactory); 260 | out.setSerializerFactory(serializerFactory); 261 | } 262 | 263 | if (username == null || password == null) { 264 | Exception exception = new RuntimeException( 265 | "the client can't offer the user or password infor,please check."); 266 | out.writeFault("ServiceException", exception.getMessage(), 267 | exception); 268 | log.error("the client can't offer the user or password infor,now we have refused."); 269 | throw exception; 270 | } 271 | invoke(rw, in, out); 272 | } catch (Exception e) { 273 | e.printStackTrace(); 274 | try { 275 | out.writeFault("ServiceException", e.getMessage(), e); 276 | } catch (IOException e1) { 277 | e1.printStackTrace(); 278 | } 279 | } finally { 280 | try { 281 | in.close(); 282 | out.close(); 283 | } catch (IOException e) { 284 | e.printStackTrace(); 285 | } 286 | 287 | } 288 | } 289 | 290 | public void invoke(RequestWrapper rw, 291 | AbstractHessianInput in, AbstractHessianOutput out) 292 | throws Exception { 293 | ServiceContext context = ServiceContext.getContext(); 294 | 295 | String serviceName = rw.getServiceName(); 296 | 297 | // backward compatibility for some frameworks that don't read 298 | // the call type first 299 | in.skipOptionalCall(); 300 | 301 | // Hessian 1.0 backward compatibility 302 | String header; 303 | while ((header = in.readHeader()) != null) { 304 | Object value = in.readObject(); 305 | 306 | context.addHeader(header, value); 307 | } 308 | ServiceMetaData metaData = MetadataProcessor.getServiceMetaData(serviceName); 309 | if (metaData == null) { 310 | log.error("service " + serviceName+ " can't find."); 311 | out.writeFault("NoSuchService","service " + serviceName+ " can't find.", null); 312 | out.close(); 313 | return; 314 | } 315 | String methodName = in.readMethod(); 316 | int argLength = in.readMethodArgLength(); 317 | 318 | Method method = metaData.getMethod(methodName + "__" + argLength); 319 | 320 | if (method == null) { 321 | method = metaData.getMethod(methodName); 322 | } 323 | if (method == null) { 324 | out.writeFault("NoSuchMethod","service["+methodName+"]'s method " + methodName+ " cannot find", null); 325 | out.close(); 326 | return; 327 | } 328 | Class[] argTypes = method.getParameterTypes(); 329 | Object[] argObjs = new Object[argTypes.length]; 330 | for (int i = 0; i < argTypes.length; i++) { 331 | argObjs[i] = in.readObject(argTypes[i]); 332 | } 333 | 334 | //wrap the request to a wapper 335 | rw.setMethodName(method.getName()); 336 | rw.setArgs(argObjs); 337 | rw.setArgsTypes(argTypes); 338 | 339 | if (argLength != argObjs.length && argLength >= 0) { 340 | out.writeFault("NoSuchMethod","service["+methodName+"]'s method " + methodName 341 | + " argument length mismatch, received length=" 342 | + argLength, null); 343 | out.close(); 344 | return; 345 | } 346 | 347 | Object result = null; 348 | 349 | try { 350 | //handle request 351 | result = ServiceHandler.handleRequest(rw); 352 | } catch (Exception e) { 353 | Throwable e1 = e; 354 | if (e1 instanceof InvocationTargetException) 355 | e1 = ((InvocationTargetException) e).getTargetException(); 356 | 357 | log.debug(this + " " + e1.toString(), e1); 358 | result = e; 359 | out.writeFault("ServiceException", e1.getMessage(), e1); 360 | out.close(); 361 | return; 362 | } 363 | 364 | // The complete call needs to be after the invoke to handle a 365 | // trailing InputStream 366 | in.completeCall(); 367 | 368 | out.writeReply(result); 369 | 370 | out.close(); 371 | } 372 | 373 | protected Hessian2Input createHessian2Input(InputStream is) { 374 | return new Hessian2Input(is); 375 | } 376 | 377 | private void sendResourceNotFound(ChannelHandlerContext ctx, MessageEvent e) { 378 | HttpResponse response = new DefaultHttpResponse(HTTP_1_1, 379 | HttpResponseStatus.NOT_FOUND); 380 | response.setContent(ChannelBuffers.copiedBuffer("NOT FOUND!", 381 | CharsetUtil.UTF_8)); 382 | response.setHeader(CONTENT_TYPE, "text/plain; charset=UTF-8"); 383 | 384 | // Close the connection as soon as the error message is sent. 385 | ctx.getChannel().write(response).addListener(ChannelFutureListener.CLOSE); 386 | } 387 | } 388 | -------------------------------------------------------------------------------- /src/main/java/com/hetty/core/HettySecurity.java: -------------------------------------------------------------------------------- 1 | package com.hetty.core; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import com.hetty.object.Application; 7 | import com.hetty.util.StringUtil; 8 | 9 | public class HettySecurity { 10 | 11 | private static final Map applicationMap = new HashMap (); 12 | 13 | public static void addToApplicationMap(Application app){ 14 | applicationMap.put(app.getUser(), app); 15 | } 16 | 17 | /** 18 | * check permission 19 | * @param user 20 | * @param password 21 | */ 22 | public static boolean checkPermission(String user,String password){ 23 | if(StringUtil.isEmpty(user) || StringUtil.isEmpty(password)){ 24 | throw new IllegalArgumentException("user or password is null,please check."); 25 | } 26 | if(applicationMap.containsKey(user) && applicationMap.get(user).getPassword().equals(password)){ 27 | return true; 28 | }else{ 29 | return false; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/hetty/core/MetadataProcessor.java: -------------------------------------------------------------------------------- 1 | package com.hetty.core; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | import java.util.Set; 6 | 7 | import com.hetty.object.Service; 8 | 9 | public class MetadataProcessor { 10 | 11 | private static Map hessianServiceMetaMap = new HashMap(); 12 | 13 | public static void initMetaDataMap() { 14 | Map serviceMap = ServiceHandler.getServiceMap(); 15 | Set serviceNames = serviceMap.keySet(); 16 | for (String name : serviceNames) { 17 | Service service = serviceMap.get(name); 18 | Class clazz = service.getTypeClass(); 19 | ServiceMetaData smd = new ServiceMetaData(clazz,service.isOverload()); 20 | hessianServiceMetaMap.put(name, smd); 21 | } 22 | } 23 | 24 | public static ServiceMetaData getServiceMetaData(String sname) { 25 | return hessianServiceMetaMap.get(sname); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/hetty/core/NamedThreadFactory.java: -------------------------------------------------------------------------------- 1 | package com.hetty.core; 2 | 3 | import java.util.concurrent.ThreadFactory; 4 | import java.util.concurrent.atomic.AtomicInteger; 5 | 6 | /** 7 | * Help for threadpool to set thread name 8 | */ 9 | public class NamedThreadFactory implements ThreadFactory { 10 | 11 | static final AtomicInteger poolNumber = new AtomicInteger(1); 12 | 13 | final AtomicInteger threadNumber = new AtomicInteger(1); 14 | final ThreadGroup group; 15 | final String namePrefix; 16 | final boolean isDaemon; 17 | 18 | public NamedThreadFactory() { 19 | this("pool"); 20 | } 21 | 22 | public NamedThreadFactory(String name) { 23 | this(name, false); 24 | } 25 | 26 | public NamedThreadFactory(String preffix, boolean daemon) { 27 | SecurityManager s = System.getSecurityManager(); 28 | group = (s != null) ? s.getThreadGroup() : Thread.currentThread() 29 | .getThreadGroup(); 30 | namePrefix = preffix + "-" + poolNumber.getAndIncrement() + "-thread-"; 31 | isDaemon = daemon; 32 | } 33 | 34 | public Thread newThread(Runnable r) { 35 | Thread t = new Thread(group, r, namePrefix 36 | + threadNumber.getAndIncrement(), 0); 37 | t.setDaemon(isDaemon); 38 | if (t.getPriority() != Thread.NORM_PRIORITY) { 39 | t.setPriority(Thread.NORM_PRIORITY); 40 | } 41 | return t; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/hetty/core/ServiceHandler.java: -------------------------------------------------------------------------------- 1 | package com.hetty.core; 2 | 3 | import java.util.Collections; 4 | import java.util.HashMap; 5 | import java.util.Iterator; 6 | import java.util.Map; 7 | 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | 11 | import com.esotericsoftware.reflectasm.MethodAccess; 12 | import com.hetty.conf.HettyConfig; 13 | import com.hetty.object.HettyException; 14 | import com.hetty.object.RequestWrapper; 15 | import com.hetty.object.Service; 16 | import com.hetty.object.ServiceProvider; 17 | import com.hetty.object.ServiceVersion; 18 | 19 | /** 20 | * @author guolei 21 | */ 22 | public class ServiceHandler { 23 | 24 | private static Logger logger = LoggerFactory.getLogger(ServiceHandler.class); 25 | //key:service name value:service 26 | public static final Map serviceMap = new HashMap(); 27 | //key:client user # service name value:version 28 | public static final Map versionMap = new HashMap(); 29 | 30 | /** 31 | * 1.if service has a non default version,add 32 | * 2.put service to map 33 | * @param service 34 | */ 35 | public static void addToServiceMap(Service service){ 36 | if(service.getDefaultVersion() == null){ 37 | Iterator iter = service.getServiceProvider().keySet().iterator(); 38 | if(iter.hasNext()){ 39 | String defaultVersion = iter.next(); 40 | service.setDefaultVersion(defaultVersion); 41 | }else{ 42 | throw new HettyException("your have a wrong in service config.check service["+service.getName()+"]'s provider."); 43 | } 44 | } 45 | serviceMap.put(service.getName(), service); 46 | } 47 | /** 48 | * check whether service is exits according service name 49 | * @param serviceName 50 | * @return true exits false not exits 51 | */ 52 | public static boolean isServiceExits(String serviceName){ 53 | return serviceMap.containsKey(serviceName); 54 | } 55 | /** 56 | * put version info to map 57 | * @param version 58 | */ 59 | public static void addToVersionMap(ServiceVersion version){ 60 | if(version.getVersion() == null){ 61 | return; 62 | } 63 | if(!isServiceExits(version.getService())){ 64 | throw new HettyException("please check your configure file,service["+version.getService()+"] can't find."); 65 | } 66 | versionMap.put(version.getUser().append("#").append(version.getService()).toString(), version.getVersion()); 67 | } 68 | /** 69 | * according the request to invoke the method and return the invoke result 70 | * 1.get serviceName,methodName,user,password,version 71 | * 2.get version 72 | * 3.get provider 73 | * 4.invoke 74 | */ 75 | public static Object handleRequest(RequestWrapper request) { 76 | Object result = null; 77 | if(HettyConfig.getInstance().getDevMod()){ 78 | ServiceReporter.reportBeforeInvoke(request); 79 | } 80 | 81 | try { 82 | String serviceName = request.getServiceName(); 83 | String methodName = request.getMethodName(); 84 | String user = request.getUser(); 85 | String password = request.getPassword(); 86 | 87 | boolean isRight = HettySecurity.checkPermission(user, password); 88 | if (!isRight) { 89 | throw new RuntimeException( 90 | "the user or password is wrong,please check your user and password."); 91 | } 92 | StringBuffer serviceKey = new StringBuffer(user).append("#") 93 | .append(serviceName); 94 | String version = versionMap.get(serviceKey.toString()); 95 | Service service = serviceMap.get(serviceName); 96 | if (service == null) { 97 | throw new RuntimeException("we cannot find service[" 98 | + serviceName + "]."); 99 | } 100 | 101 | ServiceProvider serviceProvider = service 102 | .getProviderByVersion(version); 103 | Class processorClass = serviceProvider.getProcessorClass(); 104 | Object processor = processorClass.newInstance(); 105 | Object[] args = request.getArgs(); 106 | 107 | MethodAccess method = serviceProvider.getMethodAccess(); 108 | int methodIndex = method.getIndex(methodName,request.getArgsTypes()); 109 | result = method.invoke(processor, methodIndex, args); 110 | } catch (InstantiationException e) { 111 | logger.error(e.getMessage(), e); 112 | throw new RuntimeException(e); 113 | } catch (IllegalAccessException e) { 114 | logger.error(e.getMessage(), e); 115 | throw new RuntimeException(e); 116 | } catch (IllegalArgumentException e) { 117 | logger.error(e.getMessage(), e); 118 | throw new RuntimeException(e); 119 | } 120 | return result; 121 | } 122 | public static Map getServiceMap(){ 123 | return Collections.unmodifiableMap(serviceMap); 124 | } 125 | public static Service getServiceByName(String serviceName){ 126 | return serviceMap.get(serviceName); 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /src/main/java/com/hetty/core/ServiceMetaData.java: -------------------------------------------------------------------------------- 1 | package com.hetty.core; 2 | 3 | import java.io.InputStream; 4 | import java.lang.reflect.Method; 5 | import java.util.HashMap; 6 | 7 | /** 8 | * Proxy class for Hessian services. 9 | */ 10 | public class ServiceMetaData { 11 | private Class _apiClass; 12 | private Class _objectClass; 13 | 14 | private HashMap _methodMap = new HashMap(); 15 | 16 | /** 17 | * Create a new hessian skeleton. 18 | * 19 | * @param apiClass 20 | * the API interface 21 | */ 22 | public ServiceMetaData(Class apiClass,boolean overloadEnabled) { 23 | _apiClass = apiClass; 24 | 25 | Method[] methodList = apiClass.getMethods(); 26 | 27 | for (int i = 0; i < methodList.length; i++) { 28 | Method method = methodList[i]; 29 | 30 | if (_methodMap.get(method.getName()) == null) 31 | _methodMap.put(method.getName(), methodList[i]); 32 | 33 | Class[] param = method.getParameterTypes(); 34 | String mangledName = method.getName() + "__" + param.length; 35 | _methodMap.put(mangledName, methodList[i]); 36 | 37 | if(overloadEnabled){ 38 | _methodMap.put(mangleName(method, false), methodList[i]); 39 | } 40 | } 41 | } 42 | 43 | /** 44 | * Returns the API class of the current object. 45 | */ 46 | public String getAPIClassName() { 47 | return _apiClass.getName(); 48 | } 49 | 50 | /** 51 | * Returns the API class of the object URLs 52 | */ 53 | public String getObjectClassName() { 54 | if (_objectClass != null) 55 | return _objectClass.getName(); 56 | else 57 | return getAPIClassName(); 58 | } 59 | 60 | /** 61 | * Sets the object API class. 62 | */ 63 | public void setObjectClass(Class objectAPI) { 64 | _objectClass = objectAPI; 65 | } 66 | 67 | /** 68 | * Returns the method by the mangled name. 69 | * 70 | * @param mangledName 71 | * the name passed by the protocol 72 | */ 73 | protected Method getMethod(String mangledName) { 74 | return (Method) _methodMap.get(mangledName); 75 | } 76 | 77 | /** 78 | * Creates a unique mangled method name based on the method name and the 79 | * method parameters. 80 | * 81 | * @param method 82 | * the method to mangle 83 | * @param isFull 84 | * if true, mangle the full classname 85 | * 86 | * @return a mangled string. 87 | */ 88 | public String mangleName(Method method, boolean isFull) { 89 | StringBuffer sb = new StringBuffer(); 90 | 91 | sb.append(method.getName()); 92 | 93 | Class[] params = method.getParameterTypes(); 94 | for (int i = 0; i < params.length; i++) { 95 | sb.append('_'); 96 | sb.append(mangleClass(params[i], isFull)); 97 | } 98 | 99 | return sb.toString(); 100 | } 101 | 102 | /** 103 | * Mangles a classname. 104 | */ 105 | public static String mangleClass(Class cl, boolean isFull) { 106 | String name = cl.getName(); 107 | 108 | if (name.equals("boolean") || name.equals("java.lang.Boolean")) 109 | return "boolean"; 110 | else if (name.equals("int") || name.equals("java.lang.Integer") 111 | || name.equals("short") || name.equals("java.lang.Short") 112 | || name.equals("byte") || name.equals("java.lang.Byte")) 113 | return "int"; 114 | else if (name.equals("long") || name.equals("java.lang.Long")) 115 | return "long"; 116 | else if (name.equals("float") || name.equals("java.lang.Float") 117 | || name.equals("double") || name.equals("java.lang.Double")) 118 | return "double"; 119 | else if (name.equals("java.lang.String") 120 | || name.equals("com.caucho.util.CharBuffer") 121 | || name.equals("char") || name.equals("java.lang.Character") 122 | || name.equals("java.io.Reader")) 123 | return "string"; 124 | else if (name.equals("java.util.Date") 125 | || name.equals("com.caucho.util.QDate")) 126 | return "date"; 127 | else if (InputStream.class.isAssignableFrom(cl) || name.equals("[B")) 128 | return "binary"; 129 | else if (cl.isArray()) { 130 | return "[" + mangleClass(cl.getComponentType(), isFull); 131 | } else if (name.equals("org.w3c.dom.Node") 132 | || name.equals("org.w3c.dom.Element") 133 | || name.equals("org.w3c.dom.Document")) 134 | return "xml"; 135 | else if (isFull) 136 | return name; 137 | else { 138 | int p = name.lastIndexOf('.'); 139 | if (p > 0) 140 | return name.substring(p + 1); 141 | else 142 | return name; 143 | } 144 | } 145 | 146 | public String toString() { 147 | return getClass().getSimpleName() + "[" + _apiClass.getName() + "]"; 148 | } 149 | } -------------------------------------------------------------------------------- /src/main/java/com/hetty/core/ServiceReporter.java: -------------------------------------------------------------------------------- 1 | package com.hetty.core; 2 | 3 | import java.text.SimpleDateFormat; 4 | import java.util.Date; 5 | 6 | import com.hetty.object.RequestWrapper; 7 | 8 | final class ServiceReporter { 9 | 10 | private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 11 | 12 | /** 13 | * Report action before action invoking when the common request coming 14 | */ 15 | static final boolean reportBeforeInvoke(RequestWrapper request) { 16 | doReport(request); 17 | return true; 18 | } 19 | 20 | private static final void doReport(RequestWrapper request) { 21 | StringBuilder tip = new StringBuilder("\nHetty request report -------- ").append(sdf.format(new Date())).append(" ------------------------------\n"); 22 | String serviceName = request.getServiceName(); 23 | String serviceClass = ServiceHandler.getServiceByName(serviceName).getClass().getName(); 24 | tip.append("user : ").append(request.getUser()).append("\n"); 25 | tip.append("password: ").append(request.getPassword()).append("\n"); 26 | tip.append("clientIP: ").append(request.getClientIP()).append("\n"); 27 | tip.append("service : ").append(serviceName).append(".(").append(serviceClass).append(".java)"); 28 | tip.append("method : ").append(request.getMethodName()).append("\n"); 29 | tip.append("--------------------------------------------------------------------------------\n"); 30 | System.out.print(tip.toString()); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/hetty/core/ssl/PEMKeyManager.java: -------------------------------------------------------------------------------- 1 | package com.hetty.core.ssl; 2 | 3 | import java.io.FileReader; 4 | import java.io.IOException; 5 | import java.net.Socket; 6 | import java.security.KeyPair; 7 | import java.security.Principal; 8 | import java.security.PrivateKey; 9 | import java.security.cert.X509Certificate; 10 | import java.util.Vector; 11 | 12 | import javax.net.ssl.SSLEngine; 13 | import javax.net.ssl.X509ExtendedKeyManager; 14 | 15 | import org.bouncycastle.openssl.PEMReader; 16 | import org.bouncycastle.openssl.PasswordFinder; 17 | 18 | import com.hetty.conf.HettyConfig; 19 | import com.hetty.util.FileUtil; 20 | 21 | public class PEMKeyManager extends X509ExtendedKeyManager { 22 | 23 | static PEMKeyManager instance = new PEMKeyManager(); 24 | PrivateKey key; 25 | X509Certificate[] chain; 26 | 27 | private PEMKeyManager() { 28 | 29 | PEMReader reader = null; 30 | try { 31 | final HettyConfig hettyConfig =HettyConfig.getInstance(); 32 | reader = new PEMReader(new FileReader(FileUtil.getFile(hettyConfig.getCertificateKeyFile())), new PasswordFinder() { 33 | public char[] getPassword() { 34 | return hettyConfig.getCertificatePassword().toCharArray(); 35 | } 36 | }); 37 | key = ((KeyPair) reader.readObject()).getPrivate(); 38 | 39 | reader = new PEMReader(new FileReader(FileUtil.getFile(hettyConfig.getCertificateFile()))); 40 | 41 | X509Certificate cert; 42 | Vector chainVector = new Vector(); 43 | 44 | while ((cert = (X509Certificate) reader.readObject()) != null) { 45 | chainVector.add(cert); 46 | } 47 | chain = (X509Certificate[]) chainVector.toArray(new X509Certificate[1]); 48 | } catch (Exception e) { 49 | e.printStackTrace(); 50 | }finally{ 51 | try { 52 | reader.close(); 53 | } catch (IOException e) { 54 | // TODO Auto-generated catch block 55 | e.printStackTrace(); 56 | } 57 | } 58 | } 59 | 60 | public String chooseEngineServerAlias(String s, Principal[] principals, SSLEngine sslEngine) { 61 | return ""; 62 | } 63 | 64 | public String[] getClientAliases(String s, Principal[] principals) { 65 | return new String[] { "" }; 66 | } 67 | 68 | public String chooseClientAlias(String[] strings, Principal[] principals, Socket socket) { 69 | return ""; 70 | } 71 | 72 | public String[] getServerAliases(String s, Principal[] principals) { 73 | return new String[] { "" }; 74 | } 75 | 76 | public String chooseServerAlias(String s, Principal[] principals, Socket socket) { 77 | return ""; 78 | } 79 | 80 | public X509Certificate[] getCertificateChain(String s) { 81 | return chain; 82 | } 83 | 84 | public PrivateKey getPrivateKey(String s) { 85 | return key; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/com/hetty/core/ssl/SslContextFactory.java: -------------------------------------------------------------------------------- 1 | package com.hetty.core.ssl; 2 | 3 | import java.io.FileInputStream; 4 | import java.security.KeyStore; 5 | import java.security.Security; 6 | 7 | import javax.net.ssl.KeyManager; 8 | import javax.net.ssl.KeyManagerFactory; 9 | import javax.net.ssl.SSLContext; 10 | import javax.net.ssl.TrustManagerFactory; 11 | 12 | import org.bouncycastle.jce.provider.BouncyCastleProvider; 13 | 14 | import com.hetty.conf.HettyConfig; 15 | import com.hetty.util.FileUtil; 16 | import com.hetty.util.StringUtil; 17 | 18 | public class SslContextFactory { 19 | private static final String PROTOCOL = "TLS"; 20 | private static final SSLContext SERVER_CONTEXT; 21 | private static final HettyConfig hettyConfig = HettyConfig.getInstance(); 22 | static { 23 | String algorithm = Security.getProperty("ssl.KeyManagerFactory.algorithm"); 24 | if (algorithm == null) { 25 | algorithm = "SunX509"; 26 | } 27 | SSLContext serverContext = null; 28 | try { 29 | if (StringUtil.isNotEmpty(hettyConfig.getCertificateKeyFile())) { 30 | Security.addProvider(new BouncyCastleProvider()); 31 | 32 | // Initialize the SSLContext to work with our key managers. 33 | serverContext = SSLContext.getInstance(PROTOCOL); 34 | TrustManagerFactory tmf = TrustManagerFactory.getInstance(algorithm); 35 | tmf.init(KeyStore.getInstance("JKS")); 36 | serverContext.init(new KeyManager[] { PEMKeyManager.instance }, 37 | tmf.getTrustManagers(), null); 38 | } else { 39 | 40 | KeyStore ks = KeyStore.getInstance("JKS"); 41 | FileInputStream fin = new FileInputStream(FileUtil.getFile(hettyConfig 42 | .getKeyStorePath())); 43 | ks.load(fin, hettyConfig.getKeyStorePassword().toCharArray()); 44 | 45 | // Set up key manager factory to use our key store 46 | KeyManagerFactory kmf = KeyManagerFactory.getInstance(algorithm); 47 | kmf.init(ks, hettyConfig.getKeyStorePassword().toCharArray()); 48 | TrustManagerFactory tmf = TrustManagerFactory.getInstance(algorithm); 49 | tmf.init(ks); 50 | // Initialize the SSLContext to work with our key managers. 51 | serverContext = SSLContext.getInstance(PROTOCOL); 52 | serverContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null); 53 | } 54 | } catch (Exception e) { 55 | throw new Error("Failed to initialize the server-side SSLContext", e); 56 | } 57 | SERVER_CONTEXT = serverContext; 58 | } 59 | 60 | public static SSLContext getServerContext() { 61 | return SERVER_CONTEXT; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/com/hetty/core/ssl/SslHettyChannelPipelineFactory.java: -------------------------------------------------------------------------------- 1 | package com.hetty.core.ssl; 2 | 3 | import static org.jboss.netty.channel.Channels.pipeline; 4 | 5 | import java.util.concurrent.ExecutorService; 6 | 7 | import javax.net.ssl.SSLEngine; 8 | 9 | import org.jboss.netty.channel.ChannelPipeline; 10 | import org.jboss.netty.channel.ChannelPipelineFactory; 11 | import org.jboss.netty.handler.codec.http.HttpChunkAggregator; 12 | import org.jboss.netty.handler.codec.http.HttpContentCompressor; 13 | import org.jboss.netty.handler.codec.http.HttpRequestDecoder; 14 | import org.jboss.netty.handler.codec.http.HttpResponseEncoder; 15 | import org.jboss.netty.handler.ssl.SslHandler; 16 | 17 | import com.hetty.conf.HettyConfig; 18 | 19 | public class SslHettyChannelPipelineFactory implements ChannelPipelineFactory{ 20 | private ExecutorService threadpool; 21 | 22 | public SslHettyChannelPipelineFactory(ExecutorService threadpool) { 23 | this.threadpool = threadpool; 24 | } 25 | 26 | @Override 27 | public ChannelPipeline getPipeline() throws Exception { 28 | 29 | String mode = HettyConfig.getInstance().getClientAuth(); 30 | 31 | ChannelPipeline pipeline = pipeline(); 32 | 33 | // Add SSL handler first to encrypt and decrypt everything. 34 | SSLEngine engine = SslContextFactory.getServerContext().createSSLEngine(); 35 | engine.setUseClientMode(false); 36 | if ("want".equalsIgnoreCase(mode)) { 37 | engine.setWantClientAuth(true); 38 | } else if ("need".equalsIgnoreCase(mode)) { 39 | engine.setNeedClientAuth(true); 40 | } 41 | engine.setEnableSessionCreation(true); 42 | 43 | pipeline.addLast("ssl", new SslHandler(engine)); 44 | pipeline.addLast("decoder", new HttpRequestDecoder()); 45 | pipeline.addLast("aggregator", new HttpChunkAggregator(1048576)); 46 | pipeline.addLast("encoder", new HttpResponseEncoder()); 47 | pipeline.addLast("deflater", new HttpContentCompressor()); 48 | pipeline.addLast("handler", new SslHettyHandler(threadpool)); 49 | return pipeline; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/hetty/core/ssl/SslHettyHandler.java: -------------------------------------------------------------------------------- 1 | package com.hetty.core.ssl; 2 | 3 | import static org.jboss.netty.handler.codec.http.HttpHeaders.Names.LOCATION; 4 | 5 | import java.net.InetSocketAddress; 6 | import java.util.concurrent.ExecutorService; 7 | 8 | import javax.net.ssl.SSLException; 9 | import org.jboss.netty.channel.ChannelFuture; 10 | import org.jboss.netty.channel.ChannelFutureListener; 11 | import org.jboss.netty.channel.ChannelHandlerContext; 12 | import org.jboss.netty.channel.ChannelStateEvent; 13 | import org.jboss.netty.channel.ExceptionEvent; 14 | import org.jboss.netty.handler.codec.http.DefaultHttpResponse; 15 | import org.jboss.netty.handler.codec.http.HttpResponse; 16 | import org.jboss.netty.handler.codec.http.HttpResponseStatus; 17 | import org.jboss.netty.handler.codec.http.HttpVersion; 18 | import org.jboss.netty.handler.ssl.SslHandler; 19 | import org.slf4j.Logger; 20 | import org.slf4j.LoggerFactory; 21 | import com.hetty.conf.HettyConfig; 22 | import com.hetty.core.HettyHandler; 23 | 24 | public class SslHettyHandler extends HettyHandler { 25 | 26 | private static final Logger log = LoggerFactory.getLogger(SslHettyHandler.class); 27 | public SslHettyHandler(ExecutorService threadpool) { 28 | super(threadpool); 29 | } 30 | @Override 31 | public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { 32 | ctx.setAttachment(e.getValue()); 33 | // Get the SslHandler in the current pipeline. 34 | final SslHandler sslHandler = ctx.getPipeline().get(SslHandler.class); 35 | sslHandler.setEnableRenegotiation(false); 36 | // Get notified when SSL handshake is done. 37 | ChannelFuture handshakeFuture = sslHandler.handshake(); 38 | handshakeFuture.addListener(new SslListener()); 39 | } 40 | 41 | private static final class SslListener implements ChannelFutureListener { 42 | 43 | public void operationComplete(ChannelFuture future) throws Exception { 44 | if (!future.isSuccess()) { 45 | // Logger.debug(future.getCause(), "Invalid certificate"); 46 | } 47 | } 48 | } 49 | @Override 50 | public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception { 51 | // We have to redirect to https://, as it was targeting http:// 52 | // Redirect to the root as we don't know the url at that point 53 | if (e.getCause() instanceof SSLException) { 54 | log.error(e.getCause().getMessage(),e.getCause()); 55 | InetSocketAddress inet = ((InetSocketAddress) ctx.getAttachment()); 56 | ctx.getPipeline().remove("ssl"); 57 | HttpResponse nettyResponse = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.TEMPORARY_REDIRECT); 58 | nettyResponse.setHeader(LOCATION, "https://" + inet.getHostName() + ":" + HettyConfig.getInstance().getHttpsPort()+ "/"); 59 | ChannelFuture writeFuture = ctx.getChannel().write(nettyResponse); 60 | writeFuture.addListener(ChannelFutureListener.CLOSE); 61 | } else { 62 | log.error(e.getCause().getMessage(),e.getCause()); 63 | e.getChannel().close(); 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/com/hetty/object/Application.java: -------------------------------------------------------------------------------- 1 | package com.hetty.object; 2 | 3 | import java.io.Serializable; 4 | 5 | public class Application implements Serializable{ 6 | 7 | private static final long serialVersionUID = 2485662854684252982L; 8 | 9 | private String user; 10 | private String password; 11 | 12 | public Application(){ 13 | 14 | } 15 | public Application(String user, String password) { 16 | super(); 17 | this.user = user; 18 | this.password = password; 19 | } 20 | 21 | public String getUser() { 22 | return user; 23 | } 24 | 25 | public void setUser(String user) { 26 | this.user = user; 27 | } 28 | 29 | 30 | public String getPassword() { 31 | return password; 32 | } 33 | 34 | public void setPassword(String password) { 35 | this.password = password; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/hetty/object/HettyException.java: -------------------------------------------------------------------------------- 1 | package com.hetty.object; 2 | 3 | 4 | /** 5 | * Wrapper for protocol exceptions thrown in the proxy. 6 | */ 7 | public class HettyException extends RuntimeException { 8 | 9 | private static final long serialVersionUID = -6857960002342511240L; 10 | private Throwable rootCause; 11 | 12 | /** 13 | * Zero-arg constructor. 14 | */ 15 | public HettyException() { 16 | } 17 | 18 | /** 19 | * Create the exception. 20 | */ 21 | public HettyException(String message) { 22 | super(message); 23 | } 24 | 25 | /** 26 | * Create the exception. 27 | */ 28 | public HettyException(String message, Throwable rootCause) { 29 | super(message); 30 | 31 | this.rootCause = rootCause; 32 | } 33 | 34 | /** 35 | * Create the exception. 36 | */ 37 | public HettyException(Throwable rootCause) { 38 | super(String.valueOf(rootCause)); 39 | 40 | this.rootCause = rootCause; 41 | } 42 | 43 | /** 44 | * Returns the underlying cause. 45 | */ 46 | public Throwable getRootCause() { 47 | return this.rootCause; 48 | } 49 | 50 | /** 51 | * Returns the underlying cause. 52 | */ 53 | public Throwable getCause() { 54 | return getRootCause(); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/hetty/object/RequestWrapper.java: -------------------------------------------------------------------------------- 1 | package com.hetty.object; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * 7 | * @author guolei 8 | * 9 | */ 10 | public class RequestWrapper implements Serializable { 11 | 12 | private static final long serialVersionUID = -6017954186180888313L; 13 | 14 | private String user = null; 15 | 16 | private String password = null; 17 | 18 | private String serviceName; 19 | 20 | private String methodName; 21 | 22 | private Object[] args = null; 23 | 24 | private Class[] argsTypes =null; 25 | 26 | private String clientIP = null; 27 | 28 | public RequestWrapper() { 29 | 30 | } 31 | 32 | public RequestWrapper(String user, String password,String clientIP,String serviceName) { 33 | this.user = user; 34 | this.password = password; 35 | this.clientIP = clientIP; 36 | this.serviceName = serviceName; 37 | } 38 | 39 | 40 | public String getServiceName() { 41 | return serviceName; 42 | } 43 | 44 | public void setServiceName(String serviceName) { 45 | this.serviceName = serviceName; 46 | } 47 | 48 | public String getMethodName() { 49 | return methodName; 50 | } 51 | 52 | public void setMethodName(String methodName) { 53 | this.methodName = methodName; 54 | } 55 | 56 | public Object[] getArgs() { 57 | return args; 58 | } 59 | 60 | public void setArgs(Object[] args) { 61 | this.args = args; 62 | } 63 | 64 | public String getUser() { 65 | return user; 66 | } 67 | 68 | public void setUser(String user) { 69 | this.user = user; 70 | } 71 | 72 | public String getPassword() { 73 | return password; 74 | } 75 | 76 | public void setPassword(String password) { 77 | this.password = password; 78 | } 79 | 80 | public Class[] getArgsTypes() { 81 | return argsTypes; 82 | } 83 | 84 | public void setArgsTypes(Class[] argsTypes) { 85 | this.argsTypes = argsTypes; 86 | } 87 | 88 | public String getClientIP() { 89 | return clientIP; 90 | } 91 | 92 | public void setClientIP(String clientIP) { 93 | this.clientIP = clientIP; 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/main/java/com/hetty/object/Service.java: -------------------------------------------------------------------------------- 1 | package com.hetty.object; 2 | 3 | import java.io.Serializable; 4 | import java.util.Collections; 5 | import java.util.LinkedHashMap; 6 | import java.util.Map; 7 | 8 | public class Service implements Serializable{ 9 | 10 | private static final long serialVersionUID = 2351769180636491630L; 11 | 12 | protected Class typeClass; 13 | 14 | protected String id; 15 | 16 | protected String name; 17 | 18 | protected String defaultVersion = null; 19 | 20 | private Map providerMap = new LinkedHashMap(); 21 | 22 | private boolean overload =false; 23 | 24 | public Service(){ 25 | 26 | } 27 | 28 | public Service(String id,String name){ 29 | this.id=id; 30 | this.name = name; 31 | } 32 | 33 | public Class getTypeClass() { 34 | return typeClass; 35 | } 36 | 37 | public void setTypeClass(Class typeClass) { 38 | this.typeClass = typeClass; 39 | } 40 | 41 | public String getId() { 42 | return id; 43 | } 44 | 45 | public void setId(String id) { 46 | this.id = id; 47 | } 48 | 49 | public String getName() { 50 | return name; 51 | } 52 | 53 | public void setName(String name) { 54 | this.name = name; 55 | } 56 | 57 | public String getDefaultVersion() { 58 | return defaultVersion; 59 | } 60 | 61 | public void setDefaultVersion(String defaultVersion) { 62 | this.defaultVersion = defaultVersion; 63 | } 64 | public void addServiceProvider(String version,ServiceProvider provider){ 65 | providerMap.put(version, provider); 66 | } 67 | public Map getServiceProvider(){ 68 | return Collections.unmodifiableMap(providerMap); 69 | } 70 | 71 | public boolean isOverload() { 72 | return overload; 73 | } 74 | 75 | public void setOverload(boolean overload) { 76 | this.overload = overload; 77 | } 78 | 79 | /** 80 | * return serviceProvider according serviceName 81 | * @param version 82 | * @return 83 | */ 84 | public ServiceProvider getProviderByVersion(String version){ 85 | if(version == null){ 86 | return providerMap.get(defaultVersion); 87 | }else{ 88 | return providerMap.get(version); 89 | } 90 | } 91 | } -------------------------------------------------------------------------------- /src/main/java/com/hetty/object/ServiceProvider.java: -------------------------------------------------------------------------------- 1 | package com.hetty.object; 2 | 3 | import java.io.Serializable; 4 | 5 | import com.esotericsoftware.reflectasm.MethodAccess; 6 | 7 | public class ServiceProvider implements Serializable { 8 | 9 | private static final long serialVersionUID = 2323169647020692097L; 10 | 11 | private String version; 12 | 13 | private Class processorClass; 14 | 15 | private MethodAccess methodAccess; 16 | 17 | 18 | public ServiceProvider() { 19 | 20 | } 21 | 22 | public ServiceProvider(String version, Class processorClass) { 23 | this.version = version; 24 | this.processorClass = processorClass; 25 | this.methodAccess = MethodAccess.get(processorClass); 26 | } 27 | 28 | public String getVersion() { 29 | return version; 30 | } 31 | 32 | public void setVersion(String version) { 33 | this.version = version; 34 | } 35 | 36 | public void setProcessorClass(Class processorClass) { 37 | this.processorClass = processorClass; 38 | } 39 | public Class getProcessorClass(){ 40 | return processorClass; 41 | } 42 | public MethodAccess getMethodAccess(){ 43 | return methodAccess; 44 | } 45 | 46 | } -------------------------------------------------------------------------------- /src/main/java/com/hetty/object/ServiceVersion.java: -------------------------------------------------------------------------------- 1 | package com.hetty.object; 2 | 3 | public class ServiceVersion { 4 | 5 | private String user; 6 | private String service; 7 | private String version; 8 | 9 | public StringBuffer getUser() { 10 | return new StringBuffer(user); 11 | } 12 | public void setUser(String user) { 13 | this.user = user; 14 | } 15 | public String getService() { 16 | return service; 17 | } 18 | public void setService(String service) { 19 | this.service = service; 20 | } 21 | public String getVersion() { 22 | return version; 23 | } 24 | public void setVersion(String version) { 25 | this.version = version; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/hetty/plugin/IPlugin.java: -------------------------------------------------------------------------------- 1 | package com.hetty.plugin; 2 | /** 3 | * IPlugin 4 | */ 5 | public interface IPlugin { 6 | boolean start(); 7 | boolean stop(); 8 | } -------------------------------------------------------------------------------- /src/main/java/com/hetty/plugin/XmlConfigPlugin.java: -------------------------------------------------------------------------------- 1 | package com.hetty.plugin; 2 | 3 | import java.util.List; 4 | 5 | import com.hetty.conf.HettyConfig; 6 | import com.hetty.conf.XmlConfigParser; 7 | import com.hetty.core.HettySecurity; 8 | import com.hetty.core.ServiceHandler; 9 | import com.hetty.object.Application; 10 | import com.hetty.object.Service; 11 | import com.hetty.object.ServiceVersion; 12 | 13 | public class XmlConfigPlugin implements IPlugin{ 14 | 15 | @Override 16 | public boolean start() { 17 | String configFile = HettyConfig.getInstance().getpropertiesFile(); 18 | String[] fileArr = configFile.split(","); 19 | 20 | for(String file:fileArr){ 21 | XmlConfigParser configParser = new XmlConfigParser(file); 22 | 23 | List appList = configParser.parseApplication(); 24 | for(Application app:appList){ 25 | HettySecurity.addToApplicationMap(app); 26 | } 27 | 28 | List serviceList = configParser.parseService(); 29 | for(Service service:serviceList){ 30 | ServiceHandler.addToServiceMap(service); 31 | } 32 | 33 | List versionList = configParser.parseSecurity(); 34 | if(versionList != null){ 35 | for(ServiceVersion version:versionList){ 36 | ServiceHandler.addToVersionMap(version); 37 | } 38 | } 39 | } 40 | return true; 41 | } 42 | 43 | @Override 44 | public boolean stop() { 45 | // TODO Auto-generated method stub 46 | return false; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/hetty/util/FileUtil.java: -------------------------------------------------------------------------------- 1 | package com.hetty.util; 2 | 3 | import java.io.File; 4 | 5 | public class FileUtil { 6 | 7 | public static File getFile(String path) { 8 | String applicationPath = FileUtil.class.getClassLoader().getResource("").getPath(); 9 | return new File(applicationPath, path); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/hetty/util/StringUtil.java: -------------------------------------------------------------------------------- 1 | package com.hetty.util; 2 | 3 | /** 4 | * @author guolei 5 | * 6 | */ 7 | public class StringUtil { 8 | 9 | 10 | /** 11 | * 字符串为 null 或者为 "" 时返回 true 12 | */ 13 | public static boolean isEmpty(String str) { 14 | return str == null || "".equals(str.trim()) ? true : false; 15 | } 16 | 17 | /** 18 | * 字符串不为 null 而且不为 "" 时返回 true 19 | */ 20 | public static boolean isNotEmpty(String str) { 21 | return str == null || "".equals(str.trim()) ? false : true; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/test/java/com/hetty/ServerTest.java: -------------------------------------------------------------------------------- 1 | package com.hetty; 2 | 3 | import com.hetty.core.Hetty; 4 | 5 | public class ServerTest { 6 | 7 | public static void main(String[] args) { 8 | new Hetty().start(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/test/java/com/hetty/Test.java: -------------------------------------------------------------------------------- 1 | package com.hetty; 2 | import java.net.MalformedURLException; 3 | 4 | import com.caucho.hessian.client.HessianProxyFactory; 5 | import com.hetty.server.Hello; 6 | 7 | public class Test { 8 | 9 | public static void main(String[] args) throws MalformedURLException { 10 | 11 | String url = "http://localhost:8081/apis/hello/"; 12 | HessianProxyFactory factory = new HessianProxyFactory(); 13 | factory.setUser("client1"); 14 | 15 | factory.setPassword("client1"); 16 | 17 | factory.setDebug(true); 18 | factory.setOverloadEnabled(true); 19 | // factory.setConnectTimeout(timeout); 20 | 21 | // factory.setReadTimeout(100); 22 | final Hello basic = (Hello) factory.create(Hello.class, url); 23 | 24 | // System.out.println("SayHello:" + basic.hello("guolei")); 25 | // System.out.println("SayHello:" + basic.test()); 26 | // System.out.println(basic.getAppSecret("11")); 27 | // User user = basic.getUser(1); 28 | // System.out.println(user.getRoleList().size()); 29 | // 测试方法重载 30 | System.out.println(basic.hello()); 31 | // System.out.println(basic.hello("guolei")); 32 | // System.out.println(basic.hello("guolei","hetty")); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/test/java/com/hetty/TestSSL.java: -------------------------------------------------------------------------------- 1 | package com.hetty; 2 | 3 | import java.net.MalformedURLException; 4 | 5 | import javax.net.ssl.HostnameVerifier; 6 | import javax.net.ssl.HttpsURLConnection; 7 | import javax.net.ssl.SSLSession; 8 | 9 | import com.caucho.hessian.client.HessianProxyFactory; 10 | import com.hetty.server.Hello; 11 | 12 | public class TestSSL { 13 | 14 | public static void main(String[] args) throws MalformedURLException { 15 | 16 | String url = "https://192.168.1.183:9000/apis/hello/"; 17 | HostnameVerifier hv = new HostnameVerifier() { 18 | public boolean verify(String urlHostName, SSLSession session) { 19 | System.out.println(urlHostName); 20 | System.out.println(session.getPeerHost()); 21 | return urlHostName.equals(session.getPeerHost()); 22 | } 23 | }; 24 | HttpsURLConnection.setDefaultHostnameVerifier(hv); 25 | HessianProxyFactory factory = new HessianProxyFactory(); 26 | factory.setUser("client1"); 27 | factory.setPassword("client1"); 28 | factory.setDebug(true); 29 | factory.setOverloadEnabled(true); 30 | // factory.setReadTimeout(100); 31 | final Hello basic = (Hello) factory.create(Hello.class, url); 32 | // 测试方法重载 33 | System.out.println(basic.hello("郭蕾")); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/com/hetty/server/BasicAPI.java: -------------------------------------------------------------------------------- 1 | package com.hetty.server; 2 | 3 | 4 | public interface BasicAPI { 5 | public User hello(String name); 6 | } 7 | -------------------------------------------------------------------------------- /src/test/java/com/hetty/server/BasicService.java: -------------------------------------------------------------------------------- 1 | package com.hetty.server; 2 | 3 | public class BasicService implements BasicAPI { 4 | 5 | public User hello(String name) { 6 | User u=new User(); 7 | u.setName(name); 8 | u.setAge(11); 9 | System.out.println("call hello method:"+name); 10 | return u; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/test/java/com/hetty/server/Hello.java: -------------------------------------------------------------------------------- 1 | package com.hetty.server; 2 | 3 | public interface Hello { 4 | 5 | public String hello(); 6 | public String hello(String name); 7 | public String hello(String name1,String name2); 8 | public User getUser(int id); 9 | public String getAppSecret(String key); 10 | } 11 | -------------------------------------------------------------------------------- /src/test/java/com/hetty/server/Hello2Impl.java: -------------------------------------------------------------------------------- 1 | package com.hetty.server; 2 | 3 | public class Hello2Impl implements Hello { 4 | 5 | @Override 6 | public String hello(String name) { 7 | return "Hello1, "+name+"!"; 8 | } 9 | 10 | @Override 11 | public User getUser(int id) { 12 | { 13 | User u=new User(); 14 | u.setAge(1); 15 | u.setEmail("zhuzhsh@163.com"); 16 | u.setId(1); 17 | u.setName("zhuzhsh"); 18 | for(int i=0;i<5;i++){ 19 | Role r=new Role(); 20 | r.setName("role"+i); 21 | r.setDescription("role"+i); 22 | u.addRole(r); 23 | } 24 | System.out.println(u); 25 | return u; 26 | } 27 | } 28 | 29 | @Override 30 | public String getAppSecret(String key) { 31 | // TODO Auto-generated method stub 32 | return "111"; 33 | } 34 | 35 | @Override 36 | public String hello() { 37 | // TODO Auto-generated method stub 38 | return "Hello"; 39 | } 40 | 41 | @Override 42 | public String hello(String name1, String name2) { 43 | // TODO Auto-generated method stub 44 | return name1+" say Hello to "+name2; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/test/java/com/hetty/server/HelloImpl.java: -------------------------------------------------------------------------------- 1 | package com.hetty.server; 2 | 3 | public class HelloImpl implements Hello { 4 | 5 | @Override 6 | public String hello() { 7 | System.out.println("revision 2"); 8 | return "revision 2"; 9 | } 10 | 11 | @Override 12 | public String hello(String name) { 13 | // TODO Auto-generated method stub 14 | System.out.println("revision 2:"+name); 15 | return "revision 2"; 16 | } 17 | 18 | @Override 19 | public String hello(String name1, String name2) { 20 | // TODO Auto-generated method stub 21 | System.out.println("revision 2"); 22 | return "revision 2"; 23 | } 24 | 25 | @Override 26 | public User getUser(int id) { 27 | // TODO Auto-generated method stub 28 | System.out.println("revision 2"); 29 | return null; 30 | } 31 | 32 | @Override 33 | public String getAppSecret(String key) { 34 | // TODO Auto-generated method stub 35 | System.out.println("revision 2"); 36 | return "revision 2"; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/test/java/com/hetty/server/Role.java: -------------------------------------------------------------------------------- 1 | package com.hetty.server; 2 | 3 | import java.io.Serializable; 4 | 5 | public class Role implements Serializable{ 6 | /** 7 | * 8 | */ 9 | private static final long serialVersionUID = -4773772817110244399L; 10 | private String name; 11 | private String description; 12 | public String getName() { 13 | return name; 14 | } 15 | public void setName(String name) { 16 | this.name = name; 17 | } 18 | public String getDescription() { 19 | return description; 20 | } 21 | public void setDescription(String description) { 22 | this.description = description; 23 | } 24 | 25 | 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/test/java/com/hetty/server/User.java: -------------------------------------------------------------------------------- 1 | package com.hetty.server; 2 | 3 | import java.io.Serializable; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | public class User implements Serializable { 8 | 9 | /** 10 | * 11 | */ 12 | private static final long serialVersionUID = 3050667812951858045L; 13 | 14 | private int id; 15 | private String name; 16 | private String email; 17 | private int age; 18 | 19 | private List roleList=new ArrayList(); 20 | public int getId() { 21 | return id; 22 | } 23 | public void setId(int id) { 24 | this.id = id; 25 | } 26 | public String getName() { 27 | return name; 28 | } 29 | public void setName(String name) { 30 | this.name = name; 31 | } 32 | public String getEmail() { 33 | return email; 34 | } 35 | public void setEmail(String email) { 36 | this.email = email; 37 | } 38 | public int getAge() { 39 | return age; 40 | } 41 | public void setAge(int age) { 42 | this.age = age; 43 | } 44 | public List getRoleList() { 45 | return roleList; 46 | } 47 | public void setRoleList(List roleList) { 48 | this.roleList = roleList; 49 | } 50 | 51 | public void addRole(Role role){ 52 | roleList.add(role); 53 | } 54 | 55 | 56 | public static void main(String[] args){ 57 | String s=System.getProperty("aa"); 58 | System.out.println(s); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/test/resources/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/test/resources/hetty.store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xishuixixia/Hetty/49919c50e64889af7769d5d30cd00e58852502a6/src/test/resources/hetty.store -------------------------------------------------------------------------------- /src/test/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | %d{HH:mm:ss.SSS} [%thread] [%method] [%line] %-5level %logger{36} - %msg%n 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/test/resources/server.properties: -------------------------------------------------------------------------------- 1 | server.devmod=false 2 | server.key=server1 3 | server.secret=server1 4 | #server.http.port=8081 5 | server.https.port=9000 6 | server.thread.corePoolSize=4 7 | server.thread.maxPoolSize=100 8 | server.thread.keepAliveTime=3000 9 | ssl.clientAuth=none 10 | ssl.keystore.file=hetty.store 11 | ssl.keystore.password=guolei 12 | 13 | #ssl.certificate.key.file=host.key 14 | #ssl.certificate.file=host.cert 15 | #ssl.certificate.password=guolei 16 | --------------------------------------------------------------------------------