diff --git a/.gitignore b/.gitignore index 92605cd9532b671cc28ac45cc21ba6e6530000e7..23cbf5d3f8d1dfef36157c1539d44693441ccef4 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,6 @@ rebel.xml *.classpath .DS_Store *.patch -~$* \ No newline at end of file +~$* +/.project +.settings diff --git a/README-ZH.md b/README-ZH.md index 8b983183c760ace46e9b3747aed19f690770ee97..1b55485c59115acbe6bcce2d9939e655b6d36482 100644 --- a/README-ZH.md +++ b/README-ZH.md @@ -25,23 +25,18 @@ QQ交流群: 601440615 * [x] AOP (基于guice) * 安全控制 * [x] shiro - * [x] jwt * RPC远程调用 * [x] motan - * [x] dubbo * [ ] grpc * [x] zbus * MQ消息队列 - * [x] rabbitmq * [x] redismq - * [x] 阿里云商业MQ * [ ] activemq * [x] zbus * 缓存 * [x] ehcache * [x] redis * [x] 分布式二级缓存ehredis - * [x] J2Cache ([https://gitee.com/ld/J2Cache](https://gitee.com/ld/J2Cache)) * [x] 分布式session * [x] 分布式锁 * 任务调度 @@ -57,7 +52,6 @@ QQ交流群: 601440615 * [x] swagger api * [x] Http客户端(包含了get、post请求,文件上传和下载等) * [x] httpUrlConnection - * [x] okHttp * [ ] httpClient * [x] 分布式下的微信和微信第三方 * [x] 自定义序列化组件 diff --git a/README.md b/README.md deleted file mode 100644 index 49646ed21133b376e955653d75410f385b37c763..0000000000000000000000000000000000000000 --- a/README.md +++ /dev/null @@ -1,106 +0,0 @@ -![](./docs/files/logo.png) - -## [中文文档](./README-ZH.md) -## what is JBoot - -Jboot,she is born for distributed project and micro service. - -QQ-Group: 601440615 - -## Jboot maven dependency - -```xml - - io.jboot - jboot - 1.4.4 - - -``` - -## Jboot core component - -* [x] MVC (base on JFinal) -* [x] ORM (base on JFinal) -* [x] AOP (base on Guice) -* security control - * [x] shiro - * [x] jwt -* RPC (Remote Procedure Call) - * [x] motan - * [x] dubbo - * [ ] grpc - * [x] zbus -* MQ - * [x] rabbitmq - * [x] redismq - * [x] Aliyun MQ - * [ ] activemq - * [x] zbus -* cache - * [x] ehcache - * [x] redis - * [x] ehredis (tow level distributed cache) - * [x] J2Cache ([https://gitee.com/ld/J2Cache](https://gitee.com/ld/J2Cache)) -* [x] distributed session -* [x] distributed lock -* task schedule - * [x] cron4j - * [x] ScheduledThreadPoolExecutor - * [x] distributed task schedule (base on redis) -* [x] component procedure monitor (base on metrics) -* [x] Hystrix control -* [x] Opentracing - * [x] zipkin - * [x] skywalking -* [x] distributed config center -* [x] swagger api -* [x] HttpClient - * [x] httpUrlConnection - * [x] okHttp - * [ ] httpClient -* [x] wechat api -* [x] serialization component -* [x] event mechanism -* [x] code generator - - -## document - -document url : [click here](./DOC.md) - -#### document directories - -- [JBoot core component](./DOC.md#jboot核心组件) -- [MVC](./DOC.md#mvc) -- [security control](./DOC.md#安全控制) -- [ORM](./DOC.md#orm) -- [AOP](./DOC.md#aop) -- [RPC](./DOC.md#rpc远程调用) -- [MQ](./DOC.md#mq消息队列) -- [Cache](./DOC.md#cache缓存) -- [http Client](./DOC.md#http客户端) -- [metrics monitor](./DOC.md#metrics数据监控) -- [Hystrix control](./DOC.md#容错与隔离) -- [Opentracing](./DOC.md#opentracing数据追踪) -- [distributed config center](./DOC.md#统一配置中心) -- [Swagger api](./DOC.md#swagger-api自动生成) -- Other - - [SPI](./DOC.md#spi扩展) - - [JbootEvnet](./DOC.md#jbootEvnet事件机制) - - [properties reader](./DOC.md#配置文件) - - [code generator](./DOC.md#代码生成器) -- [project build](./DOC.md#项目构建) -- [contact author](./DOC.md#联系作者) -- [FAQ](./DOC.md#常见问题) - - -## Contributors -* Michael Yang(EMAIL:fuhai999@gmail.com,GITHUB:[@yangfuhai](https://github.com/yangfuhai)) -* Rlax(EMAIL:popkids@qq.com,GITHUB:[@pkanyue](https://github.com/pkanyue)) -* 徐海峰(EMAIL:xhf6731202@126.com,GITHUB:[@xhf6731202](https://github.com/xhf6731202)) -* 周洛熙 (EMAIL:78793093@qq.com,GITHUB:[@zhoufengjob](https://github.com/zhoufengjob)) -* lsup (EMAIL:egox.vip@gmail.com,GITHUB:[@lsup](https://github.com/lsup)) - - - diff --git a/changes.txt b/changes.txt deleted file mode 100644 index b8a6f2722e076bb1a18b2c46875ff039e0d9850f..0000000000000000000000000000000000000000 --- a/changes.txt +++ /dev/null @@ -1,598 +0,0 @@ -jboot-1.4.4: -新增:MQ 接收消息时可以按顺序同步接收的配置 -优化:response的关闭有容器负责处理,Controller不再进行干涉 -优化:FlashMessage 不再依赖cookie的处理 -修复:ClassKits可能会休闲ConcurrentModificationException异常的问题 -修复:join 系列方法不支持非String类型的主键的bug -修复:由于JFinal render之后会关闭response,导致handler的执行之后无法设置cookie的问题 - - -jboot-1.4.3: -修复:RPC 由于默认排除是Object导致无法暴露的问题 - -jboot-1.4.2: -修复:Inject 和 RPC 接口过滤无效的问题 - -jboot-1.4.1: -修复:分布式session可能存在刷新session无效而造成session数据丢失的问题 -修复:缓存的ttl设置可能造成分布式多节点不同步的问题 -修复:JbootEventListener多个实现会造成Guice错误的问题 -优化:移除NoneCacheImpl -优化:RPC暴露代码逻辑同 - - -jboot-1.4.0: -新增:websocket 相关demo -新增:websocket base path 配置 -优化:调整 @EnableCORS 顺序 - - -jboot-1.3.9: -修复:Dao.use(datasource) 无法使用的问题 -修复:Before注解中拦截器getArgs() 数据不正确的问题 -新增:分库分表的demo和文档 - - -jboot-1.3.8: -新增:@EnableMetricConcurrency 注解,用于通过Metrics监控当前Action的并发量 -新增:JwtShiroBridge接口,用于Jwt和shiro之间的整合,通过Jwt判断其Shiro权限 -修复:@Before注解在AOP中无法获取参数的问题 -修复:上个版本优化cookie代码后无法获取加密cookie的问题 -修复:同一个方法不能使用多个不带参数的Metricx维度监控的问题 -修复:类单词拼写错误,重命名JbootMetricConterAopInterceptor为JbootMetricCounterAopInterceptor - - -jboot-1.3.7: -优化:@EnableMetricCounter 为记录次数而不是并发量 -优化:model.use 可能造成的线程安全问题 -优化:AOP 框架 guice 升级到最新版本, 支持 java9 和 JPMS -优化:重构mq模块,支持客户端不需要配置channel单独使用 -优化:更新undertow到最新版本,和其他依赖更新 - - -jboot-1.3.6: -新增:hikaricp 支持 metrics 监控的功能 -修复:MetricManager 初始化可能出现空指针异常的问题 -优化:Jwt 的相关方法,新增直接创建token在json返回 -更新:undertow 到最新版本 2.0 -更新:JWT 的相关文档 - - -jboot-1.3.5: -修复:Db.use() 总是使用最后一个的问题 -修复:jboot.datasource.table 和 jboot.datasource.extable 配置无效的问题 -修复:sharding-jdbc 使用 hintManager 必须关闭 hystrix,否则无法使用的问题 -文档:新增websocket相关的文档 -其他:更新依赖,升级sharding-jdbc到最新版本 - - - -jboot-1.3.4: -新增:model 查询的时候默认通过hystrix进行管理 -新增:db查询Record的时候,默认通过Hystrix进行管理 -新增:在多数据源的情况下,@Table注解添加DataSource配置的支持,可以指定在哪些数据源下 -修复:jboot.rpc.requestTimeout 对dubbo无效的问题 -修复:swagger页面出现 "Unknown Type : ref" 问题。 -文档:更新aop相关文档 -其他:更新相关依赖,hikariCP->2.7.7;druid->1.1.8;metrics->4.0.2;zipkin-sender->2.3.2 - - -jboot-1.3.3: -新增:流量控制开关,当网站上线的时候不用重启自由开启关闭。 -新增:流量控制设置,当网站上线的时候可以自由设置流量控制大小。 -新增:@EnableConcurrencyLimit注解,用于多并发量的控制和限制。 -新增:数据源DataSource支持druid,同时可以通过SPI进行扩展。 -新增:添加ehcache默认cache的配置 -优化:通过 @Before 注解后,若抛出异常获得不到原始异常。 -优化:修改 geJwtAttrs() 笔误,修改为 getJwtAttrs() -优化:更新依赖:fastjson->1.2.46,j2cache->2.3.8 -优化:重命名流量控制的相关注解,使之更加直观 - - - -jboot-1.3.2: -新增:JbootModelConfig的配置,全局配置是否缓存及缓存时间等 -新增:@Cacheevict 新增允许移除整个cacheName的配置 -新增:@Cacheable 注解添加允许存储 null 数据的配置 nullCacheEnabl -修复:在多数据源的情况下无法使用 sqlite 当中数据源的问题 -修复:修改常量错别字 -优化:重构 Jboot 请求数据验证模块,使用更加灵活自由 -其他:更新 jwt 相关文档 - - -jboot-1.3.1: -新增:自定义 dbProFactory、containerFactory、transactionLevel 等配置的支持 -新增:JWT 的支持,具体查看:https://gitee.com/fuhai/jboot/tree/master/src/test/java/jwt - - -jboot-1.3.0: -新增:注解 @EnableCORS 用于跨域配置的支持 -新增:Sharding-jdbc的注释说明,同时更新Sharding-jdbc到最新版本 -新增:代码生成器生成代码默认添加 FindAll() 方法 -修复:JFinal 的 findByCache、paginateByCache等方法没有走 JbootCache 的问题 -修复:RPC model作为参数,缓存配置没有序列化导致保持的时候无法更新缓存的问题 -修复:当使用auto_copy_model 模式的时候,保持成功无法自动赋值主键的问题 -修复:@Before(Interceptor.class)注解在Controller时,可能会触发两次的问题 -修复:多次调用 getBodyString() 只有第一次能正常获取数据的问题 -修复:文档相关的多处错误信息 -优化:MQ接受消息后,触发监听器改为异步的方式触发 -优化:FixedInvocation新增getInvocation()方法,用于底层自由控制 -其他:更新Jboot相关依赖到最新版本 - - -jboot-1.2.9: -新增:dubbo qos 端口的配置支持 -新增:分布式配置中心可以按应用名获取配置信息 -修复:FlashMessage 修复连续多次redirect ,可能造成FlashMessage丢失的问题 -修复:修复由于ehcache过期造成element被移除后导致 getKeys 数据错误的问题 -修复:baseViewPath 非根目录下 swaggerui 找不到的问题 -修复:JFinal json序列化会导致 swaggerui 报错的问题 -优化:FlashMessage性能,之前访问页面的时候会清空FlashMessage,可能导致高并发清空下有大量无效的清空操作。 -优化:ehredis.getKeys() 可能造成大量访问redis的情况 - - -jboot-1.2.8: -修复:jboot.rpc.proxy 和 jboot.rpc.filter 对 dubbo 或 motan 设置无效的问题 -修复:使用JbootRequestContext获取session的id不正确的问题 -优化:重命名 metrics 为 metric -优化:升级 j2cache 到最新版本 2.2.4 - - -jboot-1.2.7: -新增:dubbo 对 restful 的支持 -修复:当 jbootCache 配置类型为 j2cache 的时候,无法 clear() 的问题 -优化:Redis mq 当断开连接的时候会自动重连 -优化:更新 dubbo 到 2.6.0 最新版本 -优化:更新 j2cache 到 2.2.3 最新版本 - - -jboot-1.2.6: -新增:CaptchaValidate注解,方便验证码验证; -修复:配置cache为ehredis时,某些情况无法获取session的问题。 -优化:系统内置拦截器加载顺序,使之更加合理。 -优化:升级 J2cache 到最新 v2.2.0 版本,支持 cache element 的 ttl 设置。 -优化:支持自定义page的attr,使之更加好用合理。 - - -jboot-1.2.5: -新增:qpid mq 的支持 -新增:Service 代码生成 默认添加 join 系列方法 -优化:注解 Form 的 value 属性修改为 name - - -jboot-1.2.4: -修复:FixedInterceptor 无法被注入的问题 -优化:重命名 HandlerInvocation 为 FixedInvocation -优化:设置 FlashAttr 在页面渲染时,不在使用 #(flash.attr) 而直接使用 #(attr) -优化:增强 EmptyValidate 的用法,支持指定字段的错误信息反馈 -优化:Service 层的代码生成器生成代码 默认使用 单利模式 -优化:移除 ehredis 的默认 channel,修正 demo 的配置信息 -优化:更新 FlashMessage demo 的使用方法 - - -jboot-1.2.3: -新增:JbootCache 新增 J2Cache 的支持 -新增:PropertyConfig 注解新增 file() 的支持,可读取任意 properties 文件 -新增:Jboot 默认新增限流功能 -新增:自定义 FixedInterceptor 功能,FixedInterceptor 在Jfinal体系里是一个不能被 @Clear 的拦截器 -优化:重命名注解 PropertieConfig 为 PropertyConfig -优化:移除 ehredis 缓存的 mq 依赖,默认使用 redis 的发布订阅功能 -优化:重命名 HandlerInterceptor 为 FixedInterceptor -优化:使用 Caffeine 全面替代 Guava Cache - - - -jboot-1.2.2: -新增:ParamType类,方便swagger注解使用 -新增:JbootCache 新增 getTtl() 和 setTtl() 方法,方便对缓存设置过期时间 -新增:添加ActionCache的key生成机制的配置,方便自己对ActionCache的key的管理 -新增:JbootController 新增 getBodyString() 方法,方便接收客户端POST过来的body数据 -新增:添加jetty的支持,需要自行添加jetty的maven依赖 -新增:AOP 添加对 @Bean(name="serviceName") 的支持,方便对一个接口有多个实现类的情况进行注入 -修复:JFinal constants.setError404View 等无效的问题 -修复:分布式下,可能导致不同节点的ehcache缓存过期时间不一致的问题 -修复:由于Jboot不断迭代导致文档多处错误的问题 -修复:在某些情况下 SPILoader 可能出现的空指针异常的问题 -优化:设置 ActionCache 的默认时间为1周,1周后自动缓存过期自动清除 -优化:重构数据源和sharding-jdbc分库分表部分,删除无用设计和代码 -优化:设置 session 自动过期和修改默认的 session 为 —JSID—,之前为JSESSIONID可能会和其他框架冲突 -优化:重命名 UnderTowClassloader 为 JbootServerClassloader,方便今后统一对class的管理 - - -jboot-1.2.1: -修复:JbootModel 的 NullPointerException 异常问题 -修复:Controller rendderXml 和 renderTemplate 的时候,无法使用 ActionCache 的问题 - - -jboot-1.2.0: -新增:新增 JbootShiroCacheManager ,用于 给shiro.ini 进行配置使用 Jboot 默认缓存 -新增:EnableActionCache 和 ActionCacheClear 注解,用于对action进行配置高速页面缓存 -新增:给JbootModel 添加 copyModel 方法,用于rpc对象传输时modifys丢失 无法保存的的问题 -修复:分布式配置文件启用是,读取分布式配置文件错误的问题 -修复:当分布式任务执行间隔小于60秒时,可能存在一个任务在多个系统执行的问题 -修复:ClassScanner有中文路径时,扫描不到class的问题 -修复:修复由于Jboot的自定义session没有实现getAttributeNames,使用Jfinal 的 SessionInViewInterceptor 会报错的问题 -优化:删除 undertow server 对 Jfinal 内部数据的初始化过程 -优化:当传入缓存时间为0 或者 小于0时,默认为永久缓存 -优化:执行package指令时,同步业务jar拷贝到 app 的 lib 目录中 -优化:更新guava、fastjson、opentracing等到最新版本 - - -jboot-1.1.9: -新增:Columns实现序列化,支持RPC直接远程传入Columns。 -修复:JbootRedis的getWithoutSerialize方法返回空数据出现NullPointerException异常的问题。 -修复:JbootModel 通过 fastjson 序列化的时候没有排除某些私有方法而序列化异常的问题。 -优化:重构Swagger模块,移除Jboot自定义Swagger注解,添加Swagger原生注解支持。 -优化:更新sharding-jdbc到2.0.1版本,更新 fastjson 到1.2.43版本。 - - -jboot-1.1.8: -新增:JbootCacheManager 通过配置文件直接获取 JbootCache 的方法,用于不同的场景调用不同的缓存。 -新增:JbootIllegalConfigException 异常类,用于给出配置文件错误的提示。 -新增:JbootRedis 新增 getWithoutSerialize 方法,用于读取一些由redis生成的非序列化数据。 -修复:自定义JFinal指令的时候,可能存在同一个页面下多个相同的指令出现数据污染的问题。 -优化:重构 Jbootmq 模块,移动channel配置到 jboot.mq.channel。 -优化:重构 ehredis 缓存模块,当不配置mq channel的时候不再抛出异常。 - - -jboot-1.1.7: -优化:重构 JbootDirectiveBase 自定义指令,使得 getParam 更加简洁好用 -优化:删除 JbootVoModel 和其相关工具 -优化:完善 fastjson 序列化,新增 kryo 序列化配置的支持 - - -jboot-1.1.6: -修复:JbootAppListenerManager 和 JbootInjectManager初始化相互调用的问题。 -修复:Jfinal renderJson() 由于存放了request对象导致无法正常渲染的问题。 - - -jboot-1.1.5: -新增:自定义DataSource的支持,同时不影响sharding-jdbc的使用。 -新增:默认的sql模板路径,默认路径为classPath。 -新增:onGuiceConfigure配置函数,方便用户自己配置AOP的相关拦截。 -修复:dubbo rpc 无法发现jboot序列化的问题 - - -jboot-1.1.4: -修复:JbootModel.cacheTime(time) 设置缓存失效时间不起作用的问题。 -优化:重构hystrix降级,修改JbootHystrixFallbackFactory为JbootHystrixFallbackLisntener - - -jboot-1.1.3: -新增:rpc 序列化自定义配置 -新增:rpc hystrix 启用开关配置和相关demo测试 -新增:rpc hystrix 超时时间配置和相关demo测试 -新增:添加数据库缓存失效时间的支持,默认失效时间为24小时。 - -修复:Jboot在启动的时候会触发两次onJbootStarted的问题。 -修复:数据库删除一个不存在的id的时候可能存在空指针异常的问题。 - -优化:升级motan到最新版本1.1.0,并修复consul1.0无法注册的问题 -优化:默认使用netty4作为motan的rpc底层框架 -优化:合并JbootKits和ClassNewer为Classkits。 - - -jboot-1.1.2: -优化:重构metrics reporter,支持监控信息输出到 console、csv、jmx、slf4j、influxdb、graphite、ganglia 和 elasticsearch。 -优化:修改代码生成器的生成model的action由baseModelName改为modelName -优化:添加setFlashMap(Map map)方法,flashMessage可以直接设置Map或者Jfinal的Ret -优化:代码生成器的配置信息支持不完善,修改通过jboot.properties获取不到的问题 -优化:重构分库分表的功能,支持shardingjdbc 2.0最新版,并添加jfinal、jboot分库分表的demo -优化:移除因为dubbo而关联依赖的spring-web - - - -jboot-1.1.1: -新增:FlashMessage功能,方便Controller进行redirect的时候可以通知用户。 -新增:websocket的功能和具体使用demo。 -新增:在JbootAppListener里新增onAppStartBefore方法,方便扩展。 -新增:zbus rpc 的实现和支持。 -优化:重构JfinalHandler,可以自由添加Handler的顺序。 -优化:重构hystrix的降级功能,在进行降级回调的时候获取更多的细节。 -优化:重构JbootCache模块,方便获取底层具体对象,方便扩展。 -其他:更新依赖、完善文档。 - - -jboot-1.1.0: -新增:mq 的队列模式(之前只有广播) -新增:redis 和 rabbitmq 对队列的支持。 -新增:zbus的支持,暂时只支持zbus的mq。 -新增:jboot的相关demos(持续完善中)。 -修复:代码生成器生成的代码 tableName 注解错误的问题。(感谢 @Rlax 提交代码) -修复:自定义motan registry但maven打包没有加入spi配置信息导致无法发现的bug。 -优化:重构 hystrix 和 rpc模块,允许用户自己控制rpc服务抛出的异常是否抛出到Controller,方便开发调试。 -其他:更新依赖、完善文档 - - -jboot-1.0: -更新Jfinal到3.3,移除源码依赖(通过maven依赖)。 - -新增:添加分布式下的统一配置中心 -新增:添加dubborpc的相关测试和demo -新增:添加metrics的相关注解功能 -新增:添加Swagger模块 -新增:针对多ip的情况,增加rpchost自定义配置 -新增:dubbo针对多ip的情况,增加rpchost自定义配置 -新增:motanrpctestforconsulregistry -新增:添加了jbootCache保存数据的时候,可以设置超时时间的功能; -新增:添加zookeeper的相关测试和demo -新增:cache注解测试,使用ehredis二级缓存测试 -新增:删除无用的实现,防止错误配置 -新增:http客户端的okhttp实现 -新增:分布式模式下的任务调度功能,基于cron4j和redis - -修复:JbootServiceInterfaceGenerator类的生成的findAll方法返回值被写死了返回List -修复:修复Service代码生成器生成的Service接口导报格式化不正确的bug -修复:修复dubbo直连模式调用失败的bug -修复:修复统一配置中心读取远程配置在app启动之后,可能造成本地文件没有的话获取数据为null的情况。 -修复:修复统一配置中心有可能由于网络问题造成本地配置被清空配置的问题。 -修复:修复当用户使用@clear注解的时候,会造成注入无效的bug -修复:修复dubbo注册中心模式下(非直连模式)配置验证判断错误的问题 -修复:修复maven库路径存在空格情况下,jar扫描不到的情况 -修复:修复consul升级到1.0之后motan无法注册和获取服务的问题(motan的问题,已经给motan提交pr) -修复:修复motanspi名字重复的bug -修复:修复服务注册时候一个BUG,导致agenthost错误超时的问题。 -修复:修复dubbo无法发现关于Opentracing的proxyfactoryspi服务的问题 -修复:修复dubbo配置为注册中心为zookeeper的时候无法自动发现的问题 -修复:修复motan配置为注册中心为zookeeper的时候无法自动发现的问题 -修复:修复当Controller或者Servicerpc错误的时候,页面显示的错误无法明确错位位置的bug。 -修复:修复在使用缓存注解不使用key模版的情况下的,不同方法参数生成相同cachekey的情况。 -修复:修复motanregistry无法识别的问题 -修复:缓存类型ehredis情况下,Jboot.me().getCache().getKeys()永远为ehcache的结果 -修复:修复通过maven命令mvncleanpackageappassembler:generate-daemons打包的后台程序无法执行的bug - -优化:优化jbootapp启动速度 -优化:代码生成器为jfinal3.3的模板生成方 -优化:重构对jfinalinterceptor的注入流程 -优化:重构schedule部分,添加FixedDelay和FixedRate的支持。 -其他:更新依赖、完善文档 - - -jboot-1.0-rc.4: -新增: Opentracing 模块 和 默认的 zipkin 实现,用于对分布式 RPC 的追踪支持。 -新增:注解 EnableTracing ,方便通过 Opentracing 给 Jfinal 的 action 添加数据追踪。 -新增:motan 和 dubbo 默认对 Opentracing 数据追踪的支持。 -新增:Opentracing 的相关文档。 -新增:为JbootModel 默认添加 findAll 方法。 -新增:service代码生成自动添加注解 @Bean ,方便 @Inject后就可以直接使用 。 -优化:给没有JbootModel相关没必要序列化的字段添加 transient 修饰。 -优化:完善 RPC 、opentracing 、hystrix 的相关测试和文档。 -修复:当启用 Opentracing 的同时 启用 Hystrix,会出现 Opentracing 追踪断裂的bug。 -修复:注解 @Before(Tx.class) 应用在类上的时候,事务回滚失败的bug。 -修复:oracle、sqlserver、postgresql的Dialect(方言)的limit数据错误的问题。 -修复:当调用Cache.removeAll()去移除一个不存在的key时,会出现redis错误的bug。 -修复:RPC远程调用在直连模式下无法获取service的bug。 - - - - -jboot-1.0-rc.3: -新增:添加servlet相关的配置,支持之定义servlet。 -新增:新增RPC是否自动走Hystrix的相关配置支持 -新增:新增RPC 代理的配置,jboot.rpc.proxy -新增:findFirstByColumns方法,根据多列和值查询一条数据 -优化:重构Shiro相关的AuthorizeResult,使用不被删除的方法。 -修复:service层代码生成器出现导报错误的bug -修复:http post请求时,请求类型判断错误的bug -修复:通过Jboot.me().getMetrics进行统计后,在浏览器浏览的数据不正确的问题。 - - - -jboot-1.0-rc.2: -新增:hystrix 自动监控和熔断对dubbo的支持 -新增:hystrix 的keys配置,方便RPC调用的时候对方法的监控和熔断 -新增:motan的自定义代理,方便今后扩展对客户端调用的监控 -新增:Jfinal的Plugin和Handler的自动注入功能 -新增:JbootModel的columns查询对AnsiSql、Orcacle、PostgreSql、Sqlite3、SqlServer的支持 -新增:升级dubbo到最新版本2.5.6,支持dubbo通信框架netty4的配置 -优化:重构SPI加载,使代码更加简洁易懂 -优化:完善Jboot SPI 扩展功能的注释和说明 -优化:重构 注解 @EnableHystrixCommand ,不允许其使用在Controller的字段上,造成误解。 -优化:完善Hystrix功能,在客户端(例如:Controller)可以调用 Jboot.hystrix(key,runable) 轻易的通过 hystrix 进行接管。 -优化:web相关拦截器和处理器的注入功能 -优化:重构Jboot的核心类 Jboot.java,把其工具方法全部修改为静态方法。 -优化:重构JbootModel,使Column查询其支持任何的数据库,同时JbootModel代码更加简洁 -优化:参数非空验证的拦截器 ParaValidateInterceptor 代码 -修复:hystrix注解多个key时,其他key的统计失效的问题 -修复:JFinal 指令 Directive 无法进行自动注入的问题 -修复:Shiro相关文档里的指令大小写错误的问题 -修复:Undertow Server在启动的时候出现异常(比如端口号被占用)等,可能出现空指针异常的bug -修复:CDN配置自适应http和https时,出现的重复添加CDN前缀的问题。 -文档:完善分库分表文档 -文档:完善shiro相关文档 -文档:完善MQ消息队列文档 -文档:完善RPC远程调用相关文档 -文档:完善项目构建文档 -文档:完善JbootEvent事件机制文档 -其他:依赖升级 dubbo ->2.5.6;fst->2.54 - - - -jboot-1.0-rc.1: -新增:数据库分表的支持(之前已经完成对多数据源分库的支持),分表支持依赖于sharding-jdbc -新增:分库分表相关的使用文档 -新增:对拦截器自动注入功能的支持 -优化:Cookie的加密工具配置加密key为选配,当没配置的时候不会抛出异常,只是会发出警告。 -优化:优化拦截器注入性能 -优化:重构AOP对jfinal 的 Controller和interceptor 注入工作,代码更加容易理解。 -依赖更新:HikariCP -> 2.7.2 ;fastjson -> 1.2.38 - - - -jboot-1.0-beta9: -修复:cron4j 注解配置会抛出异常的bug。 close #IF5U1:关于cron4j使用注解创建的问题 -修复:在使用JbootServiceBase作为service层的基类时,通过注入的方式初始化会造成初始化失败的问题。 -新增:RPC直连模式调用的支持。 - - - - -jboot-1.0-beta8: -新增:RPC模块支持自定义序列化,可以和Jboot本身的序列化不共享同一个序列化对象。 -修复:在使用redis作为默认缓存的情况下,根据主键查询一个不存在的数据可能会抛出NullPointerException的问题。 -依赖更新:metrics ->3.2.5,HikariCP ->2.7.1 , fastjson -> 1.2.38 ,fst -> 2.53,dubbo->2.5.5。 - - - - -jboot-1.0-beta7: -新增:多数据源情况下,是否添加表映射的配置支持。 -新增:websocket的支持,更新依赖。 -修复:启用分布式session的情况下,在同一个request里setSession又去getSession 得到空值的bug -修复:修改方法名 RedisManager.getReidis() 为 RedisManager.getRedis() -优化:appassembler-maven-plugin插件打包jar存放的目录由lib修改为libs -优化:删除 无用的 JbootSessionManager 类 -更新:分布式session的相关文档。 -更新:dubbo到最新版本2.5.4 -更新:undertow到最新版本1.4.20.Final - - - -jboot-1.0-beta6: -1、添加JbootServiceBase,方便在Jboot APP中对service的编写工作。 -2、添加JbootServiceGenerator用于对Service层的代码生成。 -3、优化Jboot代码生成逻辑,使之代码更加简洁。 -4、优化配置文件读取可以读取没有前缀的配置信息,同时可以不需要@PropertieConfig 注解的配置。 -5、修复:在 JDK9 下编译失败的问题,JDK9 添加新的类java.lang.Module,导致类引入不明。 -6、更新shiro相关的文档内容。 - - -jboot-1.0-beta5: -1、新增:在分库的时候,可以给每个数据源排除表配置的支持。 -2、新增:@Cron4jTask 注解无法使用在ProcessTask和Task类的问题。 -3、新增:http模块支持自动设置multipartFormData的问题,之前是需要手动设置。 -4、新增:EncryptCookieUtils工具类,用于对cookie进行安全加密使用。 -5、新增:dubbo rpc实现的支持,据说dubbo要更新了? -6、优化:RPC模块。 -7、优化:部分代码,提高效率。 -8、修复:无法对jfinal model 进行注入的问题。 -9、修复:ClassNewer创建的实例无法被AOP控制的问题。 -10、修复:RPC模式设置无效的问题。 -11、修复:@JbootrpcService注解的缺省配置无法注入RPC实例的问题。 -12、依赖更新: fst:2.52,undertow:1.4.18.Final,阿里云ons-client:1.6.0.Final,amqp-client:4.2.0 - - - -jboot-1.0-beta4: -1、升级Jfinal到最新版本3.2,支持Controller方法参数化获取页面提交参数,需java8编译并添加-parameters配置 -2、升级新浪RPC框架motan到最新版本0.3.1,并做简单重构功能。 -3、升级fastjson到最新版本1.2.36 -4、新增使用@Cacheable @CacheEvict @CachePut无需再添加@Named配置,需java8编译并添加-parameters配置 -5、新增生成代码的时候,可以排除指定表名的支持。 -6、重构JbootDbManager使之代码更加直观简洁。 -7、重构JbootEhredisCacheImpl二级缓存的实现。 -8、修复部分用户把sql文件放在classes目录下被读取的问题。 -9、修复当没有任何model,全部使用record操作数据库的时候出现空指针异常的问题。 -10、初始化Jboot的使用文档和帮助文档。 - - - -jboot-1.0-beta3: -1、修复使用@Inject自动注入后,再使用JFinal的@Before(Tx.Class)会出现空指针的问题。 -2、修复读取配置文件的时候,同一个Class对于不同的配置信息读取不到的问题。 -3、修复多数据源的时候,读取数据源解析错误的问题。 -4、修复readme文档编写错误的问题。 -5、修复当有JbootAppListener监听器的时候,JbootAppListenerManager无法初始化的问题。 - - - - -jboot-1.0-beta2: -1、修复jboot shiro模块的相关bug,可以愉快的在项目中使用shiro了,而且可能是jfinal的shiro支持中最好用的一个。感谢@zhoujh -2、修复无法实例化JbootDbManager的bug。 -3、修复JbootRedisLock基于Redis的分布式锁release出错的bug。 -4、新增datasource poolName的配置支持。 -5、新增多数据源的支持,非常非常简单的在Jfinal中使用多数据源。 -6、新增CacheEvict和CachePut两个注解,方便通过配置设置缓存。 -7、新增JbootAppListener监听器,方便监听Jboot和Jfinal的启动状态,对自己的程序进行初始化等工作。 -8、新增Jfinal sql template 配置的支持,只需在jboot.properties进行配置,无需一行代码。 - - - - -jboot-1.0-beta1: -1、重构shiro模块,使其支持shiro.ini配置,方便其他项目迁移。 -2、新增JbootRedisLock基于redis的分布式锁。 -3、重构jboot.java 不再支持静态调用,而是通过Jboot.me().xxx这样去调用,方便后续的热加载功能。 -4、新增JbootServer的restart方法,方便后续的热加载。 -5、修复redis密码配置,在没有超时时间配置的时候无效的问题。 -6、修复:redis不能使用blpop命令和brpop命令的bug。 -7、修复:@JbootrpcService注解无法指定远程rpc分组和版本的问题。 -8、完善 jboot 的错误输出,在500错误的时候能够在页面清晰看到错误信息,方便开发排查。 -9、升级 fastjson 到最新版本 1.2.3 -10、完善jboot开发模式设置,新增jboot默认设置为dev,方便日志输出。 -11、修复:motan rpc模块在spi加载的错误问题。 -12、修复:jboot微信模块的access token cache的可能导致的缓存冲突的问题。 -13、更正readme文档,修复其他若干bug,增强稳定性。 - - - -jboot-1.0-alpha5: -1、修复AOP接口自动绑定时不成功的bug,新增了@Bean注解,方便对接口绑定的配置; -2、移除默认的jvm对jmx的设置,因为在docker环境下,设置网络为host模式时可能会产生端口冲突的问题。 -3、移除motan的rpc序列化框架hessian,因为hessian在对bigdecimal序列化出错。 -4、修复在macos下,jboot程序无法在后台启动的问题; -5、添加shiro框架的支持,用于对jboot的安全控制。 -6、添加 @Cacheable 注解,方便对Service进行缓存管理。 -7、修复 使用 @EnableHystrixCommand 使用Hystrix对某些服务进行管理时,某些参数无法注入的问题。 -8、修复 在某些情况下,初始化JbootMotanrpc可能会出现空指针的问题。 -9、移除 ehcache 缓存文件路径的默认设置。 -10.Jbootredis新增对集群环境的支持,Jboot.getRedis() 可以快乐的在集群和非集群环境下使用了。 -11、修复在某些情况下,通过model.getPrimaryKey() 获取不到数据的问题。 -12、依赖框架的升级:HikariCP升级到最新版本2.6.3,undertow升级到最新版本1.4.16.Final,fastjson升级到1.2.33,jsoup升级到1.10.3,shiro升级到最新版本1.4.0... -13、更正readme文档,修复其他若干bug,增强稳定性。 - - - - -jboot-1.0-alpha4: -1、添加SPI扩展方法,方便对Jboot内置模块的扩展实现。 -2、新增自定义序列化的支持,开发者可以选择现有系统已经支持的序列化方法(默认:fst2)。 -3、修复在某些情况下服务无法暴露的问题。 -4、设置jboot的端口号为8080。 -5、新增拦截器的AOP功能。 -6、移除ehcache的scope:provided,也就是说jboot默认内置ehcache。 -7、新增JFinal AOP的兼容,在JBoot通过注入的方式实例化对象的时候,一样可以使用Jfinal的AOP功能。 -8、移除appassembler打包对jvmSettings的默认配置。 -9、修复在某些情况下使用JbootEhredis缓存错误的问题。 -10、更正readme文档,修复其他若干bug,增强稳定性。 - - - -jboot-1.0-alpha3: -1、对jboot代码进行重构,添加component模块,引入flyway、hystrix、metrics、redis、shiro、zuul等开源软件,方便对jboot的监控和管理。 -2、新增:JbootDaoBase,方便jion操作 -3、新增:Jboot启动的服务器信息输出,比如webroot路径,当前服务地址等 -4、新增:序列化组件,方便自由对mq、rpc、cache等序列化。 -5、新增:JFianl 的 sharedMethod、sharedStaticMethod、sharedObject 注解,用于配置模板共享函数和对象 -6、新增:数据源配置 maximumPoolSize,用不配置连接池大小。 -7、新增j:boot启动完成的时候会发现启动完成的事件,方便应用初始化其他数据 -8、新增:jbootdemo项目,方便快速入门。 -9、修复 fst2 反序列化出错的问题 -10、修复 jbootredis读取数据可能出错的问题 -11、修复 jbootredis 接收数据在某些情况下可能无法接收的bug -12、修复 代码生成器 当主键字段不为id时,报错的问题。 -13、修复 代码生成器 当主键字段不为uuid时,报错的问题。 -14、优化:重命名 UrlMapping 为 RequestMapping -15、优化:重命名 UseHystrixCommand 为 EnableHystrixCommand -16、优化:重命名 JbootDirective 为 JFinalDirective -17、优化:移除JbootService -18、优化:log输出移除log4j,修改为slf4j -19、更新 readme文档 - - - - -jboot-1.0-alpha2: -修复:jbootrpcService 无法在类上进行注解的bug -修复:在某些情况下无法实例化jbootredis的bug -修复:jfinal-weixin在集群模式下获取ticket错误的问题 -新增:添加rpc服务调用统计 -新增:@UseHystrixCommand注解,用于controller调用使用Hystrix进行管理(访问隔离、容错隔离、延迟隔离、 熔断) -新增:基于guice的aop功能 -新增:jbootmqConfig的默认配置(之前没有配置会出现异常) -新增:mq监听器的多渠监听功能(multiChannel) -优化:jbootrpcService注解的使用 -优化:ClassNewer的错误信息 -优化:更新jfinal-cos到最新版本"2017.5" -优化:修改JbootEventListner的onMessage为onEvent,防止和mq的onMessage冲突。 \ No newline at end of file diff --git a/docs/en/README.md b/docs/en/README.md deleted file mode 100644 index d7bb3b15d4b92c7c8847e0fea4561611797159af..0000000000000000000000000000000000000000 --- a/docs/en/README.md +++ /dev/null @@ -1 +0,0 @@ -not finished! \ No newline at end of file diff --git a/docs/zh/http_okhttp.md b/docs/zh/http_okhttp.md deleted file mode 100644 index ced5eefe91c7556763e58617431c8bb9bc8c83d7..0000000000000000000000000000000000000000 --- a/docs/zh/http_okhttp.md +++ /dev/null @@ -1 +0,0 @@ -http_okhttp.md \ No newline at end of file diff --git a/docs/zh/mq_aliyun.md b/docs/zh/mq_aliyun.md deleted file mode 100644 index 693da34481d6b868b4e59cf14422bd24cbc79a6a..0000000000000000000000000000000000000000 --- a/docs/zh/mq_aliyun.md +++ /dev/null @@ -1 +0,0 @@ -mq_aliyun.md \ No newline at end of file diff --git a/docs/zh/mq_rabbitmq.md b/docs/zh/mq_rabbitmq.md deleted file mode 100644 index 073bce435df57a4d79ca7a2302021f2e1fe108e7..0000000000000000000000000000000000000000 --- a/docs/zh/mq_rabbitmq.md +++ /dev/null @@ -1 +0,0 @@ -mq_rabbitmq.md \ No newline at end of file diff --git a/docs/zh/rpc_dubbo.md b/docs/zh/rpc_dubbo.md deleted file mode 100644 index b5ad686f18ca024e25c11919ff24f0bc928d41a8..0000000000000000000000000000000000000000 --- a/docs/zh/rpc_dubbo.md +++ /dev/null @@ -1 +0,0 @@ -rpc_dubbo.md \ No newline at end of file diff --git a/pom.xml b/pom.xml index d2881bc5d94ff01c1a9f0c58b67e50ba931ba93e..ef8437557e161b8675071cf411672ab85af12851 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ jboot http://jboot.io - Jboot is a similar SpringCloud project base on JFinal, Dubbo, Hystrix and Undertow. + Jboot is a similar SpringCloud project base on JFinal, Hystrix and Undertow. UTF-8 @@ -121,20 +121,6 @@ 2.0.3.Final - - org.eclipse.jetty - jetty-server - 9.4.8.v20171121 - provided - - - - org.eclipse.jetty - jetty-servlet - 9.4.8.v20171121 - provided - - com.weibo @@ -243,13 +229,6 @@ 2.57 - - com.esotericsoftware - kryo - 4.0.2 - provided - - org.jsoup jsoup @@ -257,20 +236,6 @@ - - com.aliyun.openservices - ons-client - 1.7.1.Final - provided - - - - com.rabbitmq - amqp-client - 5.0.0 - provided - - net.sf.ehcache ehcache @@ -338,66 +303,8 @@ 1.3.2 - - com.alibaba - dubbo - 2.6.1 - - - org.springframework - spring - - - org.springframework - spring-web - - - org.springframework - spring-beans - - - org.springframework - spring-context - - - - - - - org.jboss.resteasy - resteasy-jdk-http - 3.1.4.Final - provided - - - - org.jboss.resteasy - resteasy-jaxrs - 3.1.4.Final - provided - - - - org.jboss.resteasy - resteasy-client - 3.1.4.Final - provided - - - - org.jboss.resteasy - resteasy-netty4 - 3.1.4.Final - provided - - - - org.jboss.resteasy - resteasy-jackson-provider - 3.1.4.Final - provided - - + + com.101tec @@ -429,20 +336,6 @@ 2.4.1 - - io.jsonwebtoken - jjwt - 0.9.0 - - - - - com.squareup.okhttp3 - okhttp - 3.10.0 - provided - - io.zbus zbus @@ -462,13 +355,6 @@ 3.7 - - net.oschina.j2cache - j2cache-core - 2.3.9-release - provided - - org.apache.qpid qpid-client diff --git a/src/main/java/io/jboot/component/jwt/JwtConfig.java b/src/main/java/io/jboot/component/jwt/JwtConfig.java deleted file mode 100644 index caefaf4c85e888f34f4d84d747fe186be337647a..0000000000000000000000000000000000000000 --- a/src/main/java/io/jboot/component/jwt/JwtConfig.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Copyright (c) 2015-2018, Michael Yang 杨福海 (fuhai999@gmail.com). - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.jboot.component.jwt; - -import io.jboot.config.annotation.PropertyConfig; -import io.jboot.utils.StringUtils; - -/** - * @author Michael Yang 杨福海 (fuhai999@gmail.com) - * @version V1.0 - * @Package io.jboot.web.jwt - */ -@PropertyConfig(prefix = "jboot.web.jwt") -public class JwtConfig { - - private String httpHeaderName = "Jwt"; - private String secret; - private long validityPeriod = 0; - private String jwtShiroBridge; - - public String getHttpHeaderName() { - return httpHeaderName; - } - - public void setHttpHeaderName(String httpHeaderName) { - this.httpHeaderName = httpHeaderName; - } - - public String getSecret() { - return secret; - } - - public void setSecret(String secret) { - this.secret = secret; - } - - public long getValidityPeriod() { - return validityPeriod; - } - - public void setValidityPeriod(long validityPeriod) { - this.validityPeriod = validityPeriod; - } - - public boolean isEnable() { - return StringUtils.isNotBlank(secret); - } - - public String getJwtShiroBridge() { - return jwtShiroBridge; - } - - public void setJwtShiroBridge(String jwtShiroBridge) { - this.jwtShiroBridge = jwtShiroBridge; - } - -} diff --git a/src/main/java/io/jboot/component/jwt/JwtInterceptor.java b/src/main/java/io/jboot/component/jwt/JwtInterceptor.java deleted file mode 100644 index 0ee50c94a2d5fe46d5c6e2452ced7f9adab103c1..0000000000000000000000000000000000000000 --- a/src/main/java/io/jboot/component/jwt/JwtInterceptor.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * Copyright (c) 2015-2018, Michael Yang 杨福海 (fuhai999@gmail.com). - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.jboot.component.jwt; - -import io.jboot.utils.StringUtils; -import io.jboot.web.controller.JbootController; -import io.jboot.web.fixedinterceptor.FixedInterceptor; -import io.jboot.web.fixedinterceptor.FixedInvocation; -import org.apache.shiro.subject.Subject; -import org.apache.shiro.util.ThreadContext; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.util.Map; - -/** - * @author Michael Yang 杨福海 (fuhai999@gmail.com) - * @version V1.0 - * @Title: 用于对Jwt的设置 - * @Package io.jboot.web.jwt - */ -public class JwtInterceptor implements FixedInterceptor { - - @Override - public void intercept(FixedInvocation inv) { - if (!JwtManager.me().isEnable()) { - inv.invoke(); - return; - } - - HttpServletRequest request = inv.getController().getRequest(); - String token = request.getHeader(JwtManager.me().getHttpHeaderName()); - - if (StringUtils.isBlank(token)) { - inv.invoke(); - processInvokeAfter(inv); - return; - } - - Map map = JwtManager.me().parseJwtToken(token); - if (map == null) { - inv.invoke(); - processInvokeAfter(inv); - return; - } - - JwtShiroBridge jwtShiroBridge = JwtManager.me().getJwtShiroBridge(); - if (jwtShiroBridge != null) { - Subject subject = jwtShiroBridge.buildSubject(map, inv.getController()); - if (subject != null) { - ThreadContext.bind(subject); - } - } - - try { - JwtManager.me().holdJwts(map); - inv.invoke(); - processInvokeAfter(inv); - } finally { - JwtManager.me().releaseJwts(); - } - } - - - private void processInvokeAfter(FixedInvocation inv) { - if (!(inv.getController() instanceof JbootController)) { - return; - } - - JbootController jbootController = (JbootController) inv.getController(); - Map jwtMap = jbootController.getJwtAttrs(); - - if (jwtMap == null || jwtMap.isEmpty()) { - return; - } - - String token = JwtManager.me().createJwtToken(jwtMap); - HttpServletResponse response = inv.getController().getResponse(); - response.addHeader(JwtManager.me().getHttpHeaderName(), token); - } -} diff --git a/src/main/java/io/jboot/component/jwt/JwtManager.java b/src/main/java/io/jboot/component/jwt/JwtManager.java deleted file mode 100644 index 98edb712ece9838f05931288414d391d09f19273..0000000000000000000000000000000000000000 --- a/src/main/java/io/jboot/component/jwt/JwtManager.java +++ /dev/null @@ -1,148 +0,0 @@ -/** - * Copyright (c) 2015-2018, Michael Yang 杨福海 (fuhai999@gmail.com). - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.jboot.component.jwt; - -import com.jfinal.json.FastJson; -import com.jfinal.kit.Base64Kit; -import io.jboot.Jboot; -import io.jboot.exception.JbootIllegalConfigException; -import io.jboot.utils.ClassKits; -import io.jboot.utils.StringUtils; -import io.jsonwebtoken.*; - -import javax.crypto.SecretKey; -import javax.crypto.spec.SecretKeySpec; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -/** - * @author Michael Yang 杨福海 (fuhai999@gmail.com) - * @version V1.0 - * @Package io.jboot.web.jwt - */ -public class JwtManager { - - private static final JwtManager me = new JwtManager(); - - public static JwtManager me() { - return me; - } - - private JwtConfig jwtConfig = Jboot.config(JwtConfig.class); - private ThreadLocal jwtThreadLocal = new ThreadLocal<>(); - - public void holdJwts(Map map) { - jwtThreadLocal.set(map); - } - - public void releaseJwts() { - jwtThreadLocal.remove(); - } - - public T getPara(String key) { - Map map = jwtThreadLocal.get(); - return map == null ? null : (T) map.get(key); - } - - public Map getParas() { - return jwtThreadLocal.get(); - } - - public boolean isEnable() { - return jwtConfig.isEnable(); - } - - public String getHttpHeaderName() { - return jwtConfig.getHttpHeaderName(); - } - - public Map parseJwtToken(String token) { - SecretKey secretKey = generalKey(); - try { - Claims claims = Jwts.parser() - .setSigningKey(secretKey) - .parseClaimsJws(token).getBody(); - - String subject = claims.getSubject(); - - if (StringUtils.isBlank(subject)) { - return null; - } - - return FastJson.getJson().parse(subject, HashMap.class); - - } catch (SignatureException | MalformedJwtException e) { - // don't trust the JWT! - // jwt 签名错误或解析错误,可能是伪造的,不能相信 - } catch (ExpiredJwtException e) { - // jwt 已经过期 - } catch (Throwable ex) { - //其他错误 - } - - return null; - } - - public String createJwtToken(Map map) { - - String subject = FastJson.getJson().toJson(map); - SecretKey secretKey = generalKey(); - - SignatureAlgorithm signatureAlgorithm = SignatureAlgorithm.HS256; - long nowMillis = System.currentTimeMillis(); - Date now = new Date(nowMillis); - - JwtBuilder builder = Jwts.builder() - .setIssuedAt(now) - .setSubject(subject) - .signWith(signatureAlgorithm, secretKey); - - if (jwtConfig.getValidityPeriod() > 0) { - long expMillis = nowMillis + jwtConfig.getValidityPeriod(); - builder.setExpiration(new Date(expMillis)); - } - - return builder.compact(); - } - - - private SecretKey generalKey() { - byte[] encodedKey = Base64Kit.decode(jwtConfig.getSecret()); - SecretKey key = new SecretKeySpec(encodedKey, 0, encodedKey.length, "AES"); - return key; - } - - - - - private JwtShiroBridge jwtShiroBridge; - - public JwtShiroBridge getJwtShiroBridge() { - if (jwtShiroBridge == null && jwtConfig.getJwtShiroBridge() != null) { - jwtShiroBridge = ClassKits.newInstance(jwtConfig.getJwtShiroBridge()); - - if (jwtShiroBridge == null) { - throw new JbootIllegalConfigException("can not find Class : " + jwtConfig.getJwtShiroBridge() + - " please config jboot.web.jwt.jwtShiroBridge correct. "); - } - } - - return jwtShiroBridge; - } - - -} diff --git a/src/main/java/io/jboot/component/jwt/JwtShiroBridge.java b/src/main/java/io/jboot/component/jwt/JwtShiroBridge.java deleted file mode 100644 index 83154c2f702dea044e0316a521e73fe650402320..0000000000000000000000000000000000000000 --- a/src/main/java/io/jboot/component/jwt/JwtShiroBridge.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Copyright (c) 2015-2018, Michael Yang 杨福海 (fuhai999@gmail.com). - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.jboot.component.jwt; - -import com.jfinal.core.Controller; -import org.apache.shiro.subject.PrincipalCollection; -import org.apache.shiro.subject.SimplePrincipalCollection; -import org.apache.shiro.subject.Subject; -import org.apache.shiro.web.subject.WebSubject; - -import java.util.Map; - -/** - * @author Michael Yang 杨福海 (fuhai999@gmail.com) - * @version V1.0 - * @Title: Jwt 和 shiro 链接的桥梁 - * @Description: 通过 Jwt 获取用户信息,再通过用户信息构建 shiro 的 subject - * @Package io.jboot.component.jwt - */ -public interface JwtShiroBridge { - - public Subject buildSubject(Map jwtParas, Controller controller); - - public static final JwtShiroBridge demo = new JwtShiroBridge() { - @Override - public Subject buildSubject(Map jwtParas, Controller controller) { - - String userId = (String) jwtParas.get("userId"); - Object user = null; // userService.find(userId); - PrincipalCollection principals = new SimplePrincipalCollection(user, "myRealmName"); - Subject.Builder builder = new WebSubject.Builder(controller.getRequest(), controller.getResponse()); - builder.principals(principals); - builder.authenticated(true); - return builder.buildSubject(); - } - }; -} diff --git a/src/main/java/io/jboot/core/cache/JbootCacheManager.java b/src/main/java/io/jboot/core/cache/JbootCacheManager.java index f7479b32c5cc711a5eee45cec2046f844aaf35ad..d7ca5a25be9eadf638d11bd30777aea2c4732c8e 100644 --- a/src/main/java/io/jboot/core/cache/JbootCacheManager.java +++ b/src/main/java/io/jboot/core/cache/JbootCacheManager.java @@ -18,7 +18,6 @@ package io.jboot.core.cache; import io.jboot.Jboot; import io.jboot.core.cache.ehcache.JbootEhcacheImpl; import io.jboot.core.cache.ehredis.JbootEhredisCacheImpl; -import io.jboot.core.cache.j2cache.J2cacheImpl; import io.jboot.core.cache.redis.JbootRedisCacheImpl; import io.jboot.core.spi.JbootSpiLoader; @@ -59,8 +58,6 @@ public class JbootCacheManager { return new JbootRedisCacheImpl(); case JbootCacheConfig.TYPE_EHREDIS: return new JbootEhredisCacheImpl(); - case JbootCacheConfig.TYPE_J2CACHE: - return new J2cacheImpl(); default: return JbootSpiLoader.load(JbootCache.class, config.getType()); } diff --git a/src/main/java/io/jboot/core/cache/j2cache/J2cacheImpl.java b/src/main/java/io/jboot/core/cache/j2cache/J2cacheImpl.java deleted file mode 100644 index fb3825c979d3ea670c7f095bec185639e7a3fdf5..0000000000000000000000000000000000000000 --- a/src/main/java/io/jboot/core/cache/j2cache/J2cacheImpl.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * Copyright (c) 2015-2018, Michael Yang 杨福海 (fuhai999@gmail.com). - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.jboot.core.cache.j2cache; - -import com.jfinal.plugin.ehcache.IDataLoader; -import io.jboot.core.cache.JbootCache; -import io.jboot.exception.JbootException; -import net.oschina.j2cache.CacheObject; -import net.oschina.j2cache.J2Cache; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -/** - * @author Michael Yang 杨福海 (fuhai999@gmail.com) - * @version V1.0 - * @Package io.jboot.core.cache.j2cache - */ -public class J2cacheImpl implements JbootCache { - - @Override - public T get(String cacheName, Object key) { - CacheObject cacheObject = J2Cache.getChannel().get(cacheName, key.toString()); - return cacheObject != null ? (T) cacheObject.getValue() : null; - } - - @Override - public void put(String cacheName, Object key, Object value) { - J2Cache.getChannel().set(cacheName, key.toString(), value); - } - - @Override - public void put(String cacheName, Object key, Object value, int liveSeconds) { - J2Cache.getChannel().set(cacheName, key.toString(), value, liveSeconds); - } - - @Override - public List getKeys(String cacheName) { - Collection keys = J2Cache.getChannel().keys(cacheName); - return keys != null ? new ArrayList(keys) : null; - } - - @Override - public void remove(String cacheName, Object key) { - J2Cache.getChannel().evict(cacheName, key.toString()); - } - - @Override - public void removeAll(String cacheName) { - J2Cache.getChannel().clear(cacheName); - } - - @Override - public T get(String cacheName, Object key, IDataLoader dataLoader) { - Object value = get(cacheName, key); - if (value == null) { - value = dataLoader.load(); - if (value != null) { - put(cacheName, key, value); - } - } - return (T) value; - } - - @Override - public T get(String cacheName, Object key, IDataLoader dataLoader, int liveSeconds) { - if (liveSeconds <= 0) { - return get(cacheName, key, dataLoader); - } - - Object data = get(cacheName, key); - if (data == null) { - data = dataLoader.load(); - put(cacheName, key, data, liveSeconds); - } - return (T) data; - } - - @Override - public Integer getTtl(String cacheName, Object key) { - throw new JbootException("not support in j2cache"); - } - - @Override - public void setTtl(String cacheName, Object key, int seconds) { - throw new JbootException("not support in j2cache"); - } -} diff --git a/src/main/java/io/jboot/core/http/JbootHttpManager.java b/src/main/java/io/jboot/core/http/JbootHttpManager.java index 7c54568f8490c51a0183321eebb6821af7b36319..5d92e9151d230fc86073662d69ed56b4335f4b3b 100644 --- a/src/main/java/io/jboot/core/http/JbootHttpManager.java +++ b/src/main/java/io/jboot/core/http/JbootHttpManager.java @@ -17,7 +17,6 @@ package io.jboot.core.http; import io.jboot.Jboot; import io.jboot.core.http.jboot.JbootHttpImpl; -import io.jboot.core.http.okhttp.OKHttpImpl; import io.jboot.core.spi.JbootSpiLoader; import io.jboot.utils.ClassKits; @@ -50,8 +49,6 @@ public class JbootHttpManager { switch (config.getType()) { case JbootHttpConfig.TYPE_DEFAULT: return new JbootHttpImpl(); - case JbootHttpConfig.TYPE_OKHTTP: - return new OKHttpImpl(); case JbootHttpConfig.TYPE_HTTPCLIENT: throw new RuntimeException("not finished!!!!"); default: diff --git a/src/main/java/io/jboot/core/http/okhttp/OKHttpImpl.java b/src/main/java/io/jboot/core/http/okhttp/OKHttpImpl.java deleted file mode 100644 index 0bc074a0f16acd97c23b20ecd8827f7e3a3d952b..0000000000000000000000000000000000000000 --- a/src/main/java/io/jboot/core/http/okhttp/OKHttpImpl.java +++ /dev/null @@ -1,192 +0,0 @@ -/** - * Copyright (c) 2015-2018, Michael Yang 杨福海 (fuhai999@gmail.com). - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.jboot.core.http.okhttp; - -import com.jfinal.log.Log; -import io.jboot.core.http.JbootHttpBase; -import io.jboot.core.http.JbootHttpRequest; -import io.jboot.core.http.JbootHttpResponse; -import okhttp3.*; - -import javax.net.ssl.*; -import java.io.File; -import java.io.FileInputStream; -import java.security.KeyStore; -import java.security.SecureRandom; -import java.security.cert.X509Certificate; -import java.util.Map; - -/** - * @author Michael Yang 杨福海 (fuhai999@gmail.com) - * @version V1.0 - * @Package io.jboot.core.http.okhttp - */ -public class OKHttpImpl extends JbootHttpBase { - private static final Log LOG = Log.getLog(OKHttpImpl.class); - - public OKHttpImpl() { - - } - - @Override - public JbootHttpResponse handle(JbootHttpRequest request) { - - JbootHttpResponse response = request.getDownloadFile() == null - ? new JbootHttpResponse() - : new JbootHttpResponse(request.getDownloadFile()); - doProcess(request, response); - - return response; - } - - - private void doProcess(JbootHttpRequest request, JbootHttpResponse response) { - try { - if (request.isPostRquest()) { - doProcessPostRequest(request, response); - } - - /** - * get 请求 - */ - else if (request.isGetRquest()) { - buildGetUrlWithParams(request); - doProcessGetRequest(request, response); - } - - } catch (Throwable ex) { - LOG.error(ex.toString(), ex); - response.setError(ex); - } - } - - private void doProcessGetRequest(JbootHttpRequest request, JbootHttpResponse response) throws Exception { - Request okHttpRequest = new Request.Builder() - .url(request.getRequestUrl()) - .build(); - - - doProcessRequest(request, response, okHttpRequest); - } - - private void doProcessPostRequest(final JbootHttpRequest request, JbootHttpResponse response) throws Exception { - RequestBody requestBody = null; - if (request.isMultipartFormData()) { - MultipartBody.Builder builder = new MultipartBody.Builder(); - for (Map.Entry entry : request.getParams().entrySet()) { - if (entry.getValue() instanceof File) { - File file = (File) entry.getValue(); - builder.addFormDataPart(entry.getKey(), file.getName(), RequestBody.create(MediaType.parse("application/octet-stream"), file)); - } else { - builder.addFormDataPart(entry.getKey(), entry.getValue() == null ? "" : entry.getValue().toString()); - } - } - requestBody = builder.build(); - } else { - FormBody.Builder builder = new FormBody.Builder(); - for (Map.Entry entry : request.getParams().entrySet()) { - builder.add(entry.getKey(), entry.getValue() == null ? "" : entry.getValue().toString()); - } - requestBody = builder.build(); - } - - - Request okHttpRequest = new Request.Builder().url(request.getRequestUrl()) - .post(requestBody) - .build(); - - - doProcessRequest(request, response, okHttpRequest); - } - - private void doProcessRequest(JbootHttpRequest request, JbootHttpResponse response, Request okHttpRequest) throws Exception { - OkHttpClient client = getClient(request); - Call call = client.newCall(okHttpRequest); - Response okHttpResponse = call.execute(); - response.setResponseCode(okHttpResponse.code()); - response.setContentType(okHttpResponse.body().contentType().type()); - response.pipe(okHttpResponse.body().byteStream()); - response.finish(); - } - - - private OkHttpClient getClient(JbootHttpRequest request) throws Exception { - if (request.getRequestUrl().toLowerCase().startsWith("https")) { - return getHttpsClient(request); - } - - return new OkHttpClient(); - } - - public OkHttpClient getHttpsClient(JbootHttpRequest request) throws Exception { - OkHttpClient.Builder builder = new OkHttpClient.Builder(); - if (request.getCertPath() != null && request.getCertPass() != null) { - KeyStore clientStore = KeyStore.getInstance("PKCS12"); - clientStore.load(new FileInputStream(request.getCertPath()), request.getCertPass().toCharArray()); - - KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); - keyManagerFactory.init(clientStore, request.getCertPass().toCharArray()); - KeyManager[] keyManagers = keyManagerFactory.getKeyManagers(); - - - TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); - trustManagerFactory.init(clientStore); - - TrustManager[] trustManagers = trustManagerFactory.getTrustManagers(); - - - SSLContext sslContext = SSLContext.getInstance("TLSv1"); - sslContext.init(keyManagers, trustManagers, new SecureRandom()); - - X509TrustManager x509TrustManager = trustAnyTrustManager; - if (trustManagers != null && trustManagers.length > 0 && trustManagers[0] instanceof X509TrustManager) { - x509TrustManager = (X509TrustManager) trustManagers[0]; - } - - builder.sslSocketFactory(sslContext.getSocketFactory(), x509TrustManager); - - } else { - builder.hostnameVerifier(hnv); - SSLContext sslContext = SSLContext.getInstance("SSL", "SunJSSE"); - if (sslContext != null) { - TrustManager[] trustManagers = {trustAnyTrustManager}; - sslContext.init(null, trustManagers, new SecureRandom()); - builder.sslSocketFactory(sslContext.getSocketFactory(), trustAnyTrustManager); - } - } - - return builder.build(); - } - - - private static X509TrustManager trustAnyTrustManager = new X509TrustManager() { - public void checkClientTrusted(X509Certificate[] chain, String authType) { - } - - public void checkServerTrusted(X509Certificate[] chain, String authType) { - } - - public X509Certificate[] getAcceptedIssuers() { - return new X509Certificate[0]; - } - }; - - private static HostnameVerifier hnv = new HostnameVerifier() { - public boolean verify(String hostname, SSLSession session) { - return true; - } - }; -} diff --git a/src/main/java/io/jboot/core/mq/JbootmqManager.java b/src/main/java/io/jboot/core/mq/JbootmqManager.java index 43f4d08b92b0f544740c40d49249ff536e27e3a5..59b172e2c8a140d45f15eb055a808810a4ce0cbf 100644 --- a/src/main/java/io/jboot/core/mq/JbootmqManager.java +++ b/src/main/java/io/jboot/core/mq/JbootmqManager.java @@ -16,9 +16,6 @@ package io.jboot.core.mq; import io.jboot.Jboot; -import io.jboot.core.mq.aliyunmq.JbootAliyunmqImpl; -import io.jboot.core.mq.qpidmq.JbootQpidmqImpl; -import io.jboot.core.mq.rabbitmq.JbootRabbitmqImpl; import io.jboot.core.mq.redismq.JbootRedismqImpl; import io.jboot.core.mq.zbus.JbootZbusmqImpl; import io.jboot.core.spi.JbootSpiLoader; @@ -59,14 +56,8 @@ public class JbootmqManager { switch (config.getType()) { case JbootmqConfig.TYPE_REDIS: return new JbootRedismqImpl(); - case JbootmqConfig.TYPE_ALIYUNMQ: - return new JbootAliyunmqImpl(); - case JbootmqConfig.TYPE_RABBITMQ: - return new JbootRabbitmqImpl(); case JbootmqConfig.TYPE_ZBUS: return new JbootZbusmqImpl(); - case JbootmqConfig.TYPE_QPID: - return new JbootQpidmqImpl(); case JbootmqConfig.TYPE_ACTIVEMQ: throw new RuntimeException("not finished!!!!"); default: diff --git a/src/main/java/io/jboot/core/mq/aliyunmq/JbootAliyunmqConfig.java b/src/main/java/io/jboot/core/mq/aliyunmq/JbootAliyunmqConfig.java deleted file mode 100644 index 6a4c80191c84bbba11a832cc1b133a3a8b16bdc1..0000000000000000000000000000000000000000 --- a/src/main/java/io/jboot/core/mq/aliyunmq/JbootAliyunmqConfig.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Copyright (c) 2015-2018, Michael Yang 杨福海 (fuhai999@gmail.com). - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.jboot.core.mq.aliyunmq; - -import io.jboot.config.annotation.PropertyConfig; - - -@PropertyConfig(prefix = "jboot.mq.aliyun") -public class JbootAliyunmqConfig { - - private String accessKey; - private String secretKey; - private String producerId; - private String addr; - private String sendMsgTimeoutMillis = "3000"; - - public String getAccessKey() { - return accessKey; - } - - public void setAccessKey(String accessKey) { - this.accessKey = accessKey; - } - - public String getSecretKey() { - return secretKey; - } - - public void setSecretKey(String secretKey) { - this.secretKey = secretKey; - } - - public String getProducerId() { - return producerId; - } - - public void setProducerId(String producerId) { - this.producerId = producerId; - } - - public String getAddr() { - return addr; - } - - public void setAddr(String addr) { - this.addr = addr; - } - - public String getSendMsgTimeoutMillis() { - return sendMsgTimeoutMillis; - } - - public void setSendMsgTimeoutMillis(String sendMsgTimeoutMillis) { - this.sendMsgTimeoutMillis = sendMsgTimeoutMillis; - } - -} diff --git a/src/main/java/io/jboot/core/mq/aliyunmq/JbootAliyunmqImpl.java b/src/main/java/io/jboot/core/mq/aliyunmq/JbootAliyunmqImpl.java deleted file mode 100644 index 4be0188d4f6b16727c23159653d10acd366818f5..0000000000000000000000000000000000000000 --- a/src/main/java/io/jboot/core/mq/aliyunmq/JbootAliyunmqImpl.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * Copyright (c) 2015-2018, Michael Yang 杨福海 (fuhai999@gmail.com). - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.jboot.core.mq.aliyunmq; - -import com.aliyun.openservices.ons.api.*; -import io.jboot.Jboot; -import io.jboot.core.mq.Jbootmq; -import io.jboot.core.mq.JbootmqBase; -import io.jboot.utils.ArrayUtils; - -import java.util.Properties; - - -public class JbootAliyunmqImpl extends JbootmqBase implements Jbootmq, MessageListener { - - private Producer producer; - private Consumer consumer; - - public JbootAliyunmqImpl() { - super(); - - JbootAliyunmqConfig aliyunmqConfig = Jboot.config(JbootAliyunmqConfig.class); - - Properties properties = new Properties(); - properties.put(PropertyKeyConst.AccessKey, aliyunmqConfig.getAccessKey());//AccessKey 阿里云身份验证,在阿里云服务器管理控制台创建 - properties.put(PropertyKeyConst.SecretKey, aliyunmqConfig.getSecretKey());//SecretKey 阿里云身份验证,在阿里云服务器管理控制台创建 - properties.put(PropertyKeyConst.ProducerId, aliyunmqConfig.getProducerId());//您在控制台创建的Producer ID - properties.put(PropertyKeyConst.ONSAddr, aliyunmqConfig.getAddr()); - properties.setProperty(PropertyKeyConst.SendMsgTimeoutMillis, aliyunmqConfig.getSendMsgTimeoutMillis());//设置发送超时时间,单位毫秒 - - producer = ONSFactory.createProducer(properties); - producer.start(); - - if (ArrayUtils.isNotEmpty(this.channels)) { - initChannelSubscribe(properties); - } - - - } - - private void initChannelSubscribe(Properties properties) { - consumer = ONSFactory.createConsumer(properties); - for (String c : channels) { - consumer.subscribe(c, "*", this); - } - consumer.start(); - } - - @Override - public void enqueue(Object message, String toChannel) { - throw new RuntimeException("not finished!"); - } - - @Override - public void publish(Object message, String toChannel) { - byte[] bytes = Jboot.me().getSerializer().serialize(message); - Message onsMessage = new Message(toChannel, "*", bytes); - producer.send(onsMessage); - } - - @Override - public Action consume(Message message, ConsumeContext context) { - byte[] bytes = message.getBody(); - Object object = Jboot.me().getSerializer().deserialize(bytes); - notifyListeners(message.getTopic(), object); - return Action.CommitMessage; - } -} diff --git a/src/main/java/io/jboot/core/mq/qpidmq/JbootQpidmqConfig.java b/src/main/java/io/jboot/core/mq/qpidmq/JbootQpidmqConfig.java deleted file mode 100644 index 6c3680b95200997dcb7dda7aba398c47c7c144a8..0000000000000000000000000000000000000000 --- a/src/main/java/io/jboot/core/mq/qpidmq/JbootQpidmqConfig.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * Copyright (c) 2015-2018, Michael Yang 杨福海 (fuhai999@gmail.com). - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.jboot.core.mq.qpidmq; - -import io.jboot.config.annotation.PropertyConfig; - -@PropertyConfig(prefix = "jboot.mq.qpid") -public class JbootQpidmqConfig { - private String username = "admin"; - private String password = "admin"; - - private String host = "127.0.0.1:5672"; - private String virtualHost; - - private boolean serializerEnable = true; - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public String getHost() { - return host; - } - - public void setHost(String host) { - this.host = host; - } - - public String getVirtualHost() { - return virtualHost; - } - - public void setVirtualHost(String virtualHost) { - this.virtualHost = virtualHost; - } - - public boolean isSerializerEnable() { - return serializerEnable; - } - - public void setSerializerEnable(boolean serializerEnable) { - this.serializerEnable = serializerEnable; - } -} diff --git a/src/main/java/io/jboot/core/mq/qpidmq/JbootQpidmqImpl.java b/src/main/java/io/jboot/core/mq/qpidmq/JbootQpidmqImpl.java deleted file mode 100644 index b6e68792a61630c9b1a192bb39415ecefd09bc88..0000000000000000000000000000000000000000 --- a/src/main/java/io/jboot/core/mq/qpidmq/JbootQpidmqImpl.java +++ /dev/null @@ -1,205 +0,0 @@ -/** - * Copyright (c) 2015-2018, Michael Yang 杨福海 (fuhai999@gmail.com). - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.jboot.core.mq.qpidmq; - -import com.jfinal.log.Log; -import io.jboot.Jboot; -import io.jboot.core.mq.Jbootmq; -import io.jboot.core.mq.JbootmqBase; -import io.jboot.exception.JbootException; -import io.jboot.utils.ArrayUtils; -import io.jboot.utils.StringUtils; -import org.apache.qpid.client.AMQAnyDestination; -import org.apache.qpid.client.AMQConnection; -import org.apache.qpid.jms.Connection; - -import javax.jms.*; - -/** - * @author 徐海峰 (27533892@qq.com) - * @version V1.0 - * @Package io.jboot.core.mq.qpid - */ -public class JbootQpidmqImpl extends JbootmqBase implements Jbootmq { - - private static final Log LOG = Log.getLog(JbootQpidmqImpl.class); - - private Connection connection = null; - private boolean serializerEnable = true; - - public JbootQpidmqImpl() { - super(); - - JbootQpidmqConfig qpidConfig = Jboot.config(JbootQpidmqConfig.class); - serializerEnable = qpidConfig.isSerializerEnable(); - - try { - String url = getConnectionUrl(); - connection = new AMQConnection(url); - connection.start(); - - startReceiveMsgThread(); - - } catch (Exception e) { - throw new JbootException("can not connection qpidmq server", e); - } - } - - @Override - public void enqueue(Object message, String toChannel) { - String addr = getQueueAddr(toChannel); - sendMsg(addr, message); - } - - @Override - public void publish(Object message, String toChannel) { - String addr = getTopicAddr(toChannel); - sendMsg(addr, message); - } - - public void sendMsg(String addr, Object message) { - try { - Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - Destination destination = new AMQAnyDestination(addr.toString()); - MessageProducer producer = session.createProducer(destination); - producer.setTimeToLive(30000); - - Message m = null; - if (!serializerEnable) { - m = session.createTextMessage((String) message); - } else { - byte[] data = Jboot.me().getSerializer().serialize(message); - m = session.createBytesMessage(); - m.setIntProperty("data-len", data.length); - ((BytesMessage) m).writeBytes(data); - } - - producer.send(m); - - } catch (Exception e) { - LOG.error(e.toString(), e); - } - } - - private String getConnectionUrl() { - JbootQpidmqConfig qpidConfig = Jboot.config(JbootQpidmqConfig.class); - - StringBuffer url = new StringBuffer(); - url.append("amqp://"); - url.append(qpidConfig.getUsername()); - url.append(":"); - url.append(qpidConfig.getPassword()); - url.append("@"); - url.append("/"); - url.append(qpidConfig.getVirtualHost()); - url.append("?failover='roundrobin'"); - url.append("&brokerlist='"); - - String host = qpidConfig.getHost(); - String[] hosts = host.split(","); - for (String h : hosts) { - if (StringUtils.isBlank(h)) { - continue; - } - url.append("tcp://" + h + ";"); - } - - url.append("'"); - - return url.toString(); - } - - private String getQueueAddr(String channel) { - StringBuffer addr = new StringBuffer(); - addr.append("ADDR:"); - addr.append(channel); - addr.append(";{create:always}"); - - return addr.toString(); - } - - private String getTopicAddr(String channel) { - StringBuffer addr = new StringBuffer(); - addr.append("ADDR:amq.topic/"); - addr.append(channel); - - return addr.toString(); - } - - private void startReceiveMsgThread() throws Exception { - if (ArrayUtils.isNullOrEmpty(this.channels)) { - return; - } - - for (String channel : this.channels) { - Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - - String queueAddr = getQueueAddr(channel); - Destination queue = new AMQAnyDestination(queueAddr); - MessageConsumer queueConsumer = session.createConsumer(queue); - new Thread(new ReceiveMsgThread(queueConsumer, channel, serializerEnable)).start(); - - String topicAddr = getTopicAddr(channel); - Destination topic = new AMQAnyDestination(topicAddr); - MessageConsumer topicConsumer = session.createConsumer(topic); - new Thread(new ReceiveMsgThread(topicConsumer, channel, serializerEnable)).start(); - } - } - - private class ReceiveMsgThread implements Runnable { - private MessageConsumer consumer; - private String channel; - private boolean serializerEnable; - - public ReceiveMsgThread(MessageConsumer consumer, String channel, boolean serializerEnable) { - this.consumer = consumer; - this.channel = channel; - this.serializerEnable = serializerEnable; - } - - @Override - public void run() { - try { - for (; ; ) { - Message message = consumer.receive(); - if (message == null) { - continue; - } - - Object object = null; - if (!serializerEnable) { - TextMessage textMessage = (TextMessage) message; - object = textMessage.getText(); - } else { - BytesMessage bytesMessage = (BytesMessage) message; - int dataLen = bytesMessage.getIntProperty("data-len"); - byte data[] = new byte[dataLen]; - if (dataLen != bytesMessage.readBytes(data)) { - continue; - } - object = Jboot.me().getSerializer().deserialize(data); - } - - if (object != null) { - notifyListeners(channel, object); - } - } - } catch (Exception e) { - LOG.error(e.toString(), e); - } - } - } -} diff --git a/src/main/java/io/jboot/core/mq/rabbitmq/JbootRabbitmqImpl.java b/src/main/java/io/jboot/core/mq/rabbitmq/JbootRabbitmqImpl.java deleted file mode 100644 index db2da37f0783417d3f20a0036ed32d1f8b5f613b..0000000000000000000000000000000000000000 --- a/src/main/java/io/jboot/core/mq/rabbitmq/JbootRabbitmqImpl.java +++ /dev/null @@ -1,159 +0,0 @@ -/** - * Copyright (c) 2015-2018, Michael Yang 杨福海 (fuhai999@gmail.com). - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.jboot.core.mq.rabbitmq; - -import com.google.common.collect.Maps; -import com.jfinal.log.Log; -import com.rabbitmq.client.*; -import io.jboot.Jboot; -import io.jboot.core.mq.Jbootmq; -import io.jboot.core.mq.JbootmqBase; -import io.jboot.exception.JbootException; -import io.jboot.utils.ArrayUtils; -import io.jboot.utils.StringUtils; - -import java.io.IOException; -import java.util.Map; - -/** - * doc : http://www.rabbitmq.com/api-guide.html - */ -public class JbootRabbitmqImpl extends JbootmqBase implements Jbootmq { - - - private static final Log LOG = Log.getLog(JbootRabbitmqImpl.class); - private Connection connection; - private Map channelMap = Maps.newConcurrentMap(); - - public JbootRabbitmqImpl() { - super(); - - JbootmqRabbitmqConfig rabbitmqConfig = Jboot.config(JbootmqRabbitmqConfig.class); - - ConnectionFactory factory = new ConnectionFactory(); - factory.setHost(rabbitmqConfig.getHost()); - factory.setPort(rabbitmqConfig.getPortAsInt()); - - if (StringUtils.isNotBlank(rabbitmqConfig.getVirtualHost())) { - factory.setVirtualHost(rabbitmqConfig.getVirtualHost()); - } - if (StringUtils.isNotBlank(rabbitmqConfig.getUsername())) { - factory.setUsername(rabbitmqConfig.getUsername()); - } - - if (StringUtils.isNotBlank(rabbitmqConfig.getPassword())) { - factory.setPassword(rabbitmqConfig.getPassword()); - } - - try { - connection = factory.newConnection(); - } catch (Exception e) { - throw new JbootException("can not connection rabbitmq server", e); - } - - if (ArrayUtils.isNotEmpty(this.channels)) { - initChannelSubscribe(); - } - - } - - private void initChannelSubscribe() { - for (String toChannel : channels) { - registerListner(getChannel(toChannel), toChannel); - } - } - - private void registerListner(final Channel channel, String toChannel) { - if (channel == null) { - return; - } - try { - - /** - * Broadcast listener - */ - channel.basicConsume("", true, new DefaultConsumer(channel) { - @Override - public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException { - Object o = Jboot.me().getSerializer().deserialize(body); - notifyListeners(envelope.getExchange(), o); - } - }); - - - /** - * Queue listener - */ - channel.basicConsume(toChannel, true, new DefaultConsumer(channel) { - @Override - public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException { - Object o = Jboot.me().getSerializer().deserialize(body); - notifyListeners(envelope.getRoutingKey(), o); - } - }); - - } catch (IOException e) { - e.printStackTrace(); - } - } - - - private Channel getChannel(String toChannel) { - - Channel channel = channelMap.get(toChannel); - if (channel == null) { - try { - channel = connection.createChannel(); - channel.queueDeclare(toChannel, false, false, false, null); - channel.exchangeDeclare(toChannel, BuiltinExchangeType.FANOUT); - String queueName = channel.queueDeclare().getQueue(); - channel.queueBind(queueName, toChannel, toChannel); - } catch (IOException e) { - throw new JbootException("can not createChannel", e); - } - - if (channel != null) { - channelMap.put(toChannel, channel); - } - } - - return channel; - } - - @Override - public void enqueue(Object message, String toChannel) { - Channel channel = getChannel(toChannel); - try { - byte[] bytes = Jboot.me().getSerializer().serialize(message); - channel.basicPublish("", toChannel, MessageProperties.BASIC, bytes); - } catch (IOException e) { - e.printStackTrace(); - } - } - - @Override - public void publish(Object message, String toChannel) { - Channel channel = getChannel(toChannel); - try { - byte[] bytes = Jboot.me().getSerializer().serialize(message); - channel.basicPublish(toChannel, "", MessageProperties.BASIC, bytes); - } catch (IOException e) { - e.printStackTrace(); - } - } - - -} diff --git a/src/main/java/io/jboot/core/mq/rabbitmq/JbootmqRabbitmqConfig.java b/src/main/java/io/jboot/core/mq/rabbitmq/JbootmqRabbitmqConfig.java deleted file mode 100644 index c98a97b2e19e1baf98410ffde142d1cc48f35376..0000000000000000000000000000000000000000 --- a/src/main/java/io/jboot/core/mq/rabbitmq/JbootmqRabbitmqConfig.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Copyright (c) 2015-2018, Michael Yang 杨福海 (fuhai999@gmail.com). - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.jboot.core.mq.rabbitmq; - -import io.jboot.config.annotation.PropertyConfig; - - -@PropertyConfig(prefix = "jboot.mq.rabbitmq") -public class JbootmqRabbitmqConfig { - - - private String username = "guest"; - private String password = "guest"; - - private String host = "127.0.0.1"; - private String port = "5672"; - private String virtualHost; - - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public String getHost() { - return host; - } - - public void setHost(String host) { - this.host = host; - } - - public String getPort() { - return port; - } - - public int getPortAsInt() { - return Integer.valueOf(port); - } - - public void setPort(String port) { - this.port = port; - } - - public String getVirtualHost() { - return virtualHost; - } - - public void setVirtualHost(String virtualHost) { - this.virtualHost = virtualHost; - } - -} diff --git a/src/main/java/io/jboot/core/rpc/JbootrpcManager.java b/src/main/java/io/jboot/core/rpc/JbootrpcManager.java index cfd91600ae9176e93bcdf941fede34dbe9773256..c63c082130e8c101b2c0c081d5d5a428645469dc 100644 --- a/src/main/java/io/jboot/core/rpc/JbootrpcManager.java +++ b/src/main/java/io/jboot/core/rpc/JbootrpcManager.java @@ -15,10 +15,12 @@ */ package io.jboot.core.rpc; +import java.io.Serializable; +import java.util.List; + import io.jboot.Jboot; import io.jboot.core.mq.JbootmqMessageListener; import io.jboot.core.rpc.annotation.JbootrpcService; -import io.jboot.core.rpc.dubbo.JbootDubborpc; import io.jboot.core.rpc.local.JbootLocalrpc; import io.jboot.core.rpc.motan.JbootMotanrpc; import io.jboot.core.rpc.zbus.JbootZbusrpc; @@ -30,9 +32,6 @@ import io.jboot.utils.ClassKits; import io.jboot.utils.ClassScanner; import io.jboot.utils.StringUtils; -import java.io.Serializable; -import java.util.List; - public class JbootrpcManager { @@ -107,8 +106,6 @@ public class JbootrpcManager { return new JbootMotanrpc(); case JbootrpcConfig.TYPE_LOCAL: return new JbootLocalrpc(); - case JbootrpcConfig.TYPE_DUBBO: - return new JbootDubborpc(); case JbootrpcConfig.TYPE_ZBUS: return new JbootZbusrpc(); default: diff --git a/src/main/java/io/jboot/core/rpc/dubbo/JbootDubboConsumerTracingFilter.java b/src/main/java/io/jboot/core/rpc/dubbo/JbootDubboConsumerTracingFilter.java deleted file mode 100644 index 767a40a5d7b9805eb0128e6bc685c0ff357a20e1..0000000000000000000000000000000000000000 --- a/src/main/java/io/jboot/core/rpc/dubbo/JbootDubboConsumerTracingFilter.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Copyright (c) 2015-2018, Michael Yang 杨福海 (fuhai999@gmail.com). - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.jboot.core.rpc.dubbo; - -import com.alibaba.dubbo.common.Constants; -import com.alibaba.dubbo.common.extension.Activate; -import com.alibaba.dubbo.rpc.*; -import io.jboot.component.opentracing.JbootOpentracingManager; -import io.opentracing.Span; -import io.opentracing.Tracer; -import io.opentracing.propagation.Format; -import io.opentracing.propagation.TextMap; - -import java.util.Iterator; -import java.util.Map; - -@Activate(group = Constants.CONSUMER) -public class JbootDubboConsumerTracingFilter implements Filter { - - - @Override - public Result invoke(Invoker invoker, Invocation inv) throws RpcException { - Tracer tracer = JbootOpentracingManager.me().getTracer(); - if (tracer == null) { - return invoker.invoke(inv); - } - - - return processRefererTrace(tracer, invoker, inv); - } - - - protected Result processRefererTrace(Tracer tracer, Invoker invoker, Invocation inv) { - String operationName = JbootDubboTracingFilterKits.buildOperationName(invoker,inv); - Tracer.SpanBuilder spanBuilder = tracer.buildSpan(operationName); - Span activeSpan = JbootDubboTracingFilterKits.getActiveSpan(); - if (activeSpan != null) { - spanBuilder.asChildOf(activeSpan); - } - Span span = spanBuilder.startManual(); -// span.setTag("requestId", request.getRequestId()); - - attachTraceInfo(tracer, span, inv); - return JbootDubboTracingFilterKits.process(invoker, inv, span); - - } - - - protected void attachTraceInfo(Tracer tracer, Span span, final Invocation inv) { - tracer.inject(span.context(), Format.Builtin.TEXT_MAP, new TextMap() { - - @Override - public void put(String key, String value) { - inv.getAttachments().put(key, value); - } - - @Override - public Iterator> iterator() { - throw new UnsupportedOperationException("TextMapInjectAdapter should only be used with Tracer.inject()"); - } - }); - } - - -} diff --git a/src/main/java/io/jboot/core/rpc/dubbo/JbootDubboProviderTracingFilter.java b/src/main/java/io/jboot/core/rpc/dubbo/JbootDubboProviderTracingFilter.java deleted file mode 100644 index b496ff0363d463b4ff165aeae7f96cc2efcbdb96..0000000000000000000000000000000000000000 --- a/src/main/java/io/jboot/core/rpc/dubbo/JbootDubboProviderTracingFilter.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Copyright (c) 2015-2018, Michael Yang 杨福海 (fuhai999@gmail.com). - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.jboot.core.rpc.dubbo; - -import com.alibaba.dubbo.common.Constants; -import com.alibaba.dubbo.common.extension.Activate; -import com.alibaba.dubbo.rpc.*; -import io.jboot.component.opentracing.JbootOpentracingManager; -import io.opentracing.Span; -import io.opentracing.SpanContext; -import io.opentracing.Tracer; -import io.opentracing.propagation.Format; -import io.opentracing.propagation.TextMapExtractAdapter; - -@Activate(group = Constants.PROVIDER) -public class JbootDubboProviderTracingFilter implements Filter { - - - @Override - public Result invoke(Invoker invoker, Invocation inv) throws RpcException { - Tracer tracer = JbootOpentracingManager.me().getTracer(); - if (tracer == null) { - return invoker.invoke(inv); - } - - - return processProviderTrace(tracer, invoker, inv); - } - - - protected Result processProviderTrace(Tracer tracer, Invoker invoker, Invocation inv) { - Span span = extractTraceInfo(tracer, invoker, inv); -// span.setTag("requestId", request.getRequestId()); - JbootDubboTracingFilterKits.setActiveSpan(span); - return JbootDubboTracingFilterKits.process(invoker, inv, span); - } - - protected Span extractTraceInfo(Tracer tracer, Invoker invoker, Invocation inv) { - String operationName = JbootDubboTracingFilterKits.buildOperationName(invoker, inv); - Tracer.SpanBuilder span = tracer.buildSpan(operationName); - try { - SpanContext spanContext = tracer.extract(Format.Builtin.TEXT_MAP, new TextMapExtractAdapter(inv.getAttachments())); - if (spanContext != null) { - span.asChildOf(spanContext); - } - } catch (Exception e) { - span.withTag("Error", "extract from request fail, error msg:" + e.getMessage()); - } - return span.startManual(); - } - - -} diff --git a/src/main/java/io/jboot/core/rpc/dubbo/JbootDubboProxyFactory.java b/src/main/java/io/jboot/core/rpc/dubbo/JbootDubboProxyFactory.java deleted file mode 100644 index d35f0efc5155e5693eec820c2edaf0285fcdaa93..0000000000000000000000000000000000000000 --- a/src/main/java/io/jboot/core/rpc/dubbo/JbootDubboProxyFactory.java +++ /dev/null @@ -1,123 +0,0 @@ -/** - * Copyright (c) 2015-2018, Michael Yang 杨福海 (fuhai999@gmail.com). - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.jboot.core.rpc.dubbo; - -import com.alibaba.dubbo.common.URL; -import com.alibaba.dubbo.rpc.Invoker; -import com.alibaba.dubbo.rpc.RpcException; -import com.alibaba.dubbo.rpc.proxy.AbstractProxyFactory; -import com.alibaba.dubbo.rpc.proxy.AbstractProxyInvoker; -import com.alibaba.dubbo.rpc.proxy.InvokerInvocationHandler; -import io.jboot.Jboot; -import io.jboot.component.hystrix.JbootHystrixCommand; -import io.jboot.component.opentracing.JbootSpanContext; -import io.jboot.core.rpc.JbootrpcConfig; -import io.jboot.core.rpc.JbootrpcManager; -import io.jboot.utils.StringUtils; -import io.opentracing.Span; - -import java.lang.reflect.Method; -import java.lang.reflect.Proxy; - -/** - * 扩展 dubbo 的代理类 - * 用于 Hystrix 的控制和统计 - */ -public class JbootDubboProxyFactory extends AbstractProxyFactory { - - - static JbootrpcConfig rpcConfig = Jboot.config(JbootrpcConfig.class); - - - @Override - public T getProxy(Invoker invoker, Class[] interfaces) { - return (T) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), interfaces, new JbootInvocationHandler(invoker)); - } - - @Override - public Invoker getInvoker(T proxy, Class type, URL url) throws RpcException { - return new AbstractProxyInvoker(proxy, type, url) { - @Override - protected Object doInvoke(T proxy, String methodName, - Class[] parameterTypes, - Object[] arguments) throws Throwable { - Method method = proxy.getClass().getMethod(methodName, parameterTypes); - return method.invoke(proxy, arguments); - } - }; - } - - - /** - * InvocationHandler 的代理类,InvocationHandler在motan内部创建 - * JbootInvocationHandler代理后,可以对某个方法执行之前做些额外的操作:例如通过 Hystrix 包装 - */ - public static class JbootInvocationHandler extends InvokerInvocationHandler { - - public JbootInvocationHandler(Invoker handler) { - super(handler); - } - - - @Override - public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - - if (!rpcConfig.isHystrixEnable()) { - return super.invoke(proxy, method, args); - } - - /** - * 过滤系统方法,不走hystrix - */ - if ("hashCode".equals(method.getName()) - || "toString".equals(method.getName()) - || "equals".equals(method.getName()) - || "getClass".equals(method.getName())) { - - return super.invoke(proxy, method, args); - - } - - String key = rpcConfig.getHystrixKeyByMethod(method.getName()); - if (StringUtils.isBlank(key) && rpcConfig.isHystrixAutoConfig()) { - key = method.getDeclaringClass().getName() + "." + method.getName(); - } - - final Span span = JbootDubboTracingFilterKits.getActiveSpan(); - - return StringUtils.isBlank(key) - ? super.invoke(proxy, method, args) - : Jboot.hystrix(new JbootHystrixCommand(key, rpcConfig.getHystrixTimeout()) { - @Override - public Object run() throws Exception { - try { - JbootSpanContext.add(span); - return JbootInvocationHandler.super.invoke(proxy, method, args); - } catch (Throwable throwable) { - throw (Exception) throwable; - } finally { - JbootSpanContext.release(); - } - } - - @Override - public Object getFallback() { - return JbootrpcManager.me().getHystrixFallbackListener().onFallback(proxy, method, args, this, this.getExecutionException()); - } - }); - } - } -} diff --git a/src/main/java/io/jboot/core/rpc/dubbo/JbootDubboTracingFilterKits.java b/src/main/java/io/jboot/core/rpc/dubbo/JbootDubboTracingFilterKits.java deleted file mode 100644 index 7b60f082ccb6e6d53b0f1f96ce4584af5c5345b2..0000000000000000000000000000000000000000 --- a/src/main/java/io/jboot/core/rpc/dubbo/JbootDubboTracingFilterKits.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * Copyright (c) 2015-2018, Michael Yang 杨福海 (fuhai999@gmail.com). - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.jboot.core.rpc.dubbo; - -import com.alibaba.dubbo.common.Constants; -import com.alibaba.dubbo.rpc.Invocation; -import com.alibaba.dubbo.rpc.Invoker; -import com.alibaba.dubbo.rpc.Result; -import com.alibaba.dubbo.rpc.RpcContext; -import com.jfinal.log.Log; -import io.jboot.component.opentracing.JbootSpanContext; -import io.opentracing.Span; - -public class JbootDubboTracingFilterKits { - - - static Log log = Log.getLog(JbootDubboTracingFilterKits.class); - - public static Result process(Invoker invoker, Invocation inv, Span span) { - Throwable ex = null; - boolean exception = true; - try { - Result response = invoker.invoke(inv); - if (response.getException() != null) { - ex = response.getException(); - } else { - exception = false; - } - return response; - } catch (RuntimeException e) { - ex = e; - throw e; - } finally { - try { - if (exception) { - span.log("request fail." + (ex == null ? "unknown exception" : ex.getMessage())); - } else { - span.log("request success."); - } - span.finish(); - } catch (Exception e) { - log.error("opentracing span finish error!", e); - } - } - } - - public static String buildOperationName(Invoker invoker, Invocation inv) { - String version = invoker.getUrl().getParameter(Constants.VERSION_KEY); - String group = invoker.getUrl().getParameter(Constants.GROUP_KEY); - - StringBuilder sn = new StringBuilder("Dubbo_"); - sn.append(group).append(":").append(version); - sn.append("_"); - sn.append(invoker.getInterface().getName()).append("."); - - sn.append(inv.getMethodName()); - sn.append("("); - Class[] types = inv.getParameterTypes(); - if (types != null && types.length > 0) { - boolean first = true; - for (Class type : types) { - if (first) { - first = false; - } else { - sn.append(","); - } - sn.append(type.getName()); - } - } - sn.append(") "); - - return sn.toString(); - } - - - public static final String ACTIVE_SPAN = "ot_active_span"; - - - public static Span getActiveSpan() { - Object span = RpcContext.getContext().get(ACTIVE_SPAN); - if (span != null && span instanceof Span) { - return (Span) span; - } - - /** - * 当通过 RpcContext 去获取不到的时候,有可能此线程 由于 hystrix 的原因,或其他原因,已经处于和RpcContext不同的线程 - * 所以通过 RpcContext 去获取不到当前的Span信息 - * - * 在程序中,当启动新的线程进行操作的时候,会通过 JbootSpanContext.add(span) 来设置新线程的span内容 - */ - return JbootSpanContext.get(); - } - - public static void setActiveSpan(Span span) { - RpcContext.getContext().set(ACTIVE_SPAN, span); - } - - -} diff --git a/src/main/java/io/jboot/core/rpc/dubbo/JbootDubborpc.java b/src/main/java/io/jboot/core/rpc/dubbo/JbootDubborpc.java deleted file mode 100644 index 1e12e55f32042949953af6e7bbeabc449fd90244..0000000000000000000000000000000000000000 --- a/src/main/java/io/jboot/core/rpc/dubbo/JbootDubborpc.java +++ /dev/null @@ -1,185 +0,0 @@ -/** - * Copyright (c) 2015-2018, Michael Yang 杨福海 (fuhai999@gmail.com). - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.jboot.core.rpc.dubbo; - -import com.alibaba.dubbo.config.*; -import io.jboot.Jboot; -import io.jboot.core.rpc.JbootrpcBase; -import io.jboot.core.rpc.JbootrpcConfig; -import io.jboot.exception.JbootIllegalConfigException; -import io.jboot.utils.StringUtils; - -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -/** - * dubbo 官方宣布开始维护了 - * 开始添加dubbo的支持 - */ -public class JbootDubborpc extends JbootrpcBase { - - private static final Map singletons = new ConcurrentHashMap<>(); - - private JbootrpcConfig jbootrpcConfig; - private ApplicationConfig applicationConfig; - private RegistryConfig registryConfig; - private JbootDubborpcConfig dubboConfig; - - public JbootDubborpc() { - jbootrpcConfig = Jboot.config(JbootrpcConfig.class); - dubboConfig = Jboot.config(JbootDubborpcConfig.class); - - if (StringUtils.isNotBlank(dubboConfig.getQosPort())) { - System.setProperty("dubbo.qos.port", String.valueOf(dubboConfig.getQosPort())); - } - - applicationConfig = new ApplicationConfig(); - applicationConfig.setName("jboot"); - - registryConfig = new RegistryConfig(); - registryConfig.setCheck(jbootrpcConfig.isRegistryCheck()); - - /** - * 注册中心的调用模式 - */ - if (jbootrpcConfig.isRegistryCallMode()) { - - registryConfig.setProtocol(jbootrpcConfig.getRegistryType()); - registryConfig.setAddress(jbootrpcConfig.getRegistryAddress()); - registryConfig.setUsername(jbootrpcConfig.getRegistryUserName()); - registryConfig.setPassword(jbootrpcConfig.getRegistryPassword()); - } - /** - * 直连模式 - */ - else if (jbootrpcConfig.isRedirectCallMode()) { - registryConfig.setAddress(RegistryConfig.NO_AVAILABLE); - } - - - } - - - @Override - public T serviceObtain(Class serviceClass, String group, String version) { - - String key = String.format("%s:%s:%s", serviceClass.getName(), group, version); - - T object = (T) singletons.get(key); - if (object != null) { - return object; - } - - - // 注意:ReferenceConfig为重对象,内部封装了与注册中心的连接,以及与服务提供方的连接 - // 引用远程服务 - // 此实例很重,封装了与注册中心的连接以及与提供者的连接,请自行缓存,否则可能造成内存和连接泄漏 - ReferenceConfig reference = new ReferenceConfig(); - reference.setApplication(applicationConfig); - reference.setInterface(serviceClass); - reference.setVersion(version); - reference.setTimeout(jbootrpcConfig.getRequestTimeOut()); - - if (StringUtils.isNotBlank(jbootrpcConfig.getProxy())) { - reference.setProxy(jbootrpcConfig.getProxy()); - } else { - //设置 jboot 代理,目的是为了方便 Hystrix 的降级控制和统计 - reference.setProxy("jboot"); - } - - if (StringUtils.isNotBlank(jbootrpcConfig.getFilter())) { - reference.setFilter(jbootrpcConfig.getFilter()); - } else { - //默认情况下用于 OpenTracing 的追踪 - reference.setFilter("jbootConsumerOpentracing"); - } - - reference.setCheck(jbootrpcConfig.isConsumerCheck()); - - - /** - * 注册中心的调用模式 - */ - if (jbootrpcConfig.isRegistryCallMode()) { - reference.setRegistry(registryConfig); // 多个注册中心可以用setRegistries() - } - - /** - * 直连调用模式 - */ - else if (jbootrpcConfig.isRedirectCallMode()) { - if (StringUtils.isBlank(jbootrpcConfig.getDirectUrl())) { - throw new JbootIllegalConfigException("directUrl must not be null if you use redirect call mode,please config jboot.rpc.directUrl value"); - } - reference.setUrl(jbootrpcConfig.getDirectUrl()); - } - - // 注意:此代理对象内部封装了所有通讯细节,对象较重,请缓存复用 - object = reference.get(); - - if (object != null) { - singletons.put(key, object); - } - return object; - } - - @Override - public boolean serviceExport(Class interfaceClass, Object object, String group, String version, int port) { - - ProtocolConfig protocolConfig = new ProtocolConfig(); - protocolConfig.setPort(port <= 0 ? jbootrpcConfig.getDefaultPort() : port); - protocolConfig.setThreads(dubboConfig.getProtocolThreads()); - - protocolConfig.setName(dubboConfig.getProtocolName()); - protocolConfig.setServer(dubboConfig.getProtocolServer()); - - if (StringUtils.isNotBlank(dubboConfig.getProtocolContextPath())) { - protocolConfig.setContextpath(dubboConfig.getProtocolContextPath()); - } - - if (StringUtils.isNotBlank(dubboConfig.getProtocolTransporter())) { - protocolConfig.setTransporter(dubboConfig.getProtocolTransporter()); - } - - if (StringUtils.isNotBlank(jbootrpcConfig.getHost())) { - protocolConfig.setHost(jbootrpcConfig.getHost()); - } - - if (StringUtils.isNotBlank(jbootrpcConfig.getSerialization())) { - protocolConfig.setSerialization(jbootrpcConfig.getSerialization()); - } - - - //此实例很重,封装了与注册中心的连接,请自行缓存,否则可能造成内存和连接泄漏 - ServiceConfig service = new ServiceConfig(); - service.setApplication(applicationConfig); - - service.setRegistry(registryConfig); // 多个注册中心可以用setRegistries() - - service.setProtocol(protocolConfig); // 多个协议可以用setProtocols() - service.setInterface(interfaceClass); - service.setRef((T) object); - service.setVersion(version); - service.setProxy(jbootrpcConfig.getProxy()); - service.setFilter("jbootProviderOpentracing"); - - - // 暴露及注册服务 - service.export(); - - return true; - } -} diff --git a/src/main/java/io/jboot/core/rpc/dubbo/JbootDubborpcConfig.java b/src/main/java/io/jboot/core/rpc/dubbo/JbootDubborpcConfig.java deleted file mode 100644 index f0dcbc6d6d180d2efb34eeb2db1e0f50687816e8..0000000000000000000000000000000000000000 --- a/src/main/java/io/jboot/core/rpc/dubbo/JbootDubborpcConfig.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * Copyright (c) 2015-2018, Michael Yang 杨福海 (fuhai999@gmail.com). - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.jboot.core.rpc.dubbo; - -import io.jboot.config.annotation.PropertyConfig; - - -@PropertyConfig(prefix = "jboot.rpc.dubbo") -public class JbootDubborpcConfig { - - - private String protocolName = "dubbo"; //default is dubbo - private String protocolServer = "netty"; //default is netty - private String protocolContextPath; - private String protocolTransporter; - private int protocolThreads = 200; - - private int qosPort; - - public String getProtocolName() { - return protocolName; - } - - public void setProtocolName(String protocolName) { - this.protocolName = protocolName; - } - - public String getProtocolServer() { - return protocolServer; - } - - public void setProtocolServer(String protocolServer) { - this.protocolServer = protocolServer; - } - - public String getProtocolContextPath() { - return protocolContextPath; - } - - public void setProtocolContextPath(String protocolContextPath) { - this.protocolContextPath = protocolContextPath; - } - - public String getProtocolTransporter() { - return protocolTransporter; - } - - public void setProtocolTransporter(String protocolTransporter) { - this.protocolTransporter = protocolTransporter; - } - - public int getProtocolThreads() { - return protocolThreads; - } - - public void setProtocolThreads(int protocolThreads) { - this.protocolThreads = protocolThreads; - } - - public int getQosPort() { - return qosPort; - } - - public void setQosPort(int qosPort) { - this.qosPort = qosPort; - } -} diff --git a/src/main/java/io/jboot/core/serializer/KryoSerializer.java b/src/main/java/io/jboot/core/serializer/KryoSerializer.java deleted file mode 100644 index 7af0441f7dcc9c25cba0de50c358a37cc894ed0b..0000000000000000000000000000000000000000 --- a/src/main/java/io/jboot/core/serializer/KryoSerializer.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Copyright (c) 2015-2018, Michael Yang 杨福海 (fuhai999@gmail.com). - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.jboot.core.serializer; - -import com.esotericsoftware.kryo.Kryo; -import com.esotericsoftware.kryo.io.ByteBufferInput; -import com.esotericsoftware.kryo.io.Output; -import com.esotericsoftware.kryo.pool.KryoFactory; -import com.esotericsoftware.kryo.pool.KryoPool; - -import java.io.ByteArrayOutputStream; - -/** - * @author Michael Yang 杨福海 (fuhai999@gmail.com) - * @version V1.0 - * @Title: Kryo 序列化 - * @Description: 性能和 fst一样 - * @Package io.jboot.core.serializer - */ -public class KryoSerializer implements ISerializer { - - - private KryoFactory kryoFactory = new KryoFactory() { - public Kryo create() { - return new Kryo(); - } - }; - - private KryoPool kryoPool = new KryoPool.Builder(kryoFactory). - softReferences() - .build(); - - @Override - public byte[] serialize(Object obj) { - if (obj == null) return null; - Output output = null; - Kryo kryo = kryoPool.borrow(); - try { - output = new Output(new ByteArrayOutputStream()); - kryo.writeClassAndObject(output, obj); - return output.toBytes(); - } finally { - if (output != null) { - output.close(); - } - kryoPool.release(kryo); - } - } - - @Override - public Object deserialize(byte[] bytes) { - if (bytes == null || bytes.length == 0) return null; - ByteBufferInput input = null; - Kryo kryo = kryoPool.borrow(); - try { - input = new ByteBufferInput(bytes); - return kryo.readClassAndObject(input); - } finally { - if (input != null) { - input.close(); - } - kryoPool.release(kryo); - } - } -} diff --git a/src/main/java/io/jboot/core/serializer/SerializerManager.java b/src/main/java/io/jboot/core/serializer/SerializerManager.java index aab76336582643f438e081b7f8450e5e64774cdb..80d9724d27b58d7621623eeebc00540f11b95847 100644 --- a/src/main/java/io/jboot/core/serializer/SerializerManager.java +++ b/src/main/java/io/jboot/core/serializer/SerializerManager.java @@ -15,14 +15,14 @@ */ package io.jboot.core.serializer; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + import io.jboot.Jboot; import io.jboot.core.spi.JbootSpiLoader; import io.jboot.exception.JbootAssert; import io.jboot.utils.ClassKits; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - public class SerializerManager { @@ -75,8 +75,6 @@ public class SerializerManager { switch (serializerString) { - case JbootSerializerConfig.KRYO: - return new KryoSerializer(); case JbootSerializerConfig.FST: return new FstSerializer(); case JbootSerializerConfig.FASTJSON: diff --git a/src/main/java/io/jboot/server/JbootServerFactory.java b/src/main/java/io/jboot/server/JbootServerFactory.java index 6536f2617b59868c57fdc473fe20038e472e5dcb..95becba1a6893ae57026c21aa0c601d6c50b3122 100644 --- a/src/main/java/io/jboot/server/JbootServerFactory.java +++ b/src/main/java/io/jboot/server/JbootServerFactory.java @@ -16,8 +16,6 @@ package io.jboot.server; import io.jboot.Jboot; -import io.jboot.server.jetty.JettyServer; -import io.jboot.server.tomcat.TomcatServer; import io.jboot.server.undertow.UnderTowServer; @@ -39,10 +37,6 @@ public class JbootServerFactory { switch (jbootServerConfig.getType()) { case JbootServerConfig.TYPE_UNDERTOW: return new UnderTowServer(); - case JbootServerConfig.TYPE_TOMCAT: - return new TomcatServer(); - case JbootServerConfig.TYPE_JETTY: - return new JettyServer(); default: return new UnderTowServer(); } diff --git a/src/main/java/io/jboot/server/jetty/JettyServer.java b/src/main/java/io/jboot/server/jetty/JettyServer.java deleted file mode 100644 index 135684f448976c2c9dd5e9e3cca8ca1ad9690134..0000000000000000000000000000000000000000 --- a/src/main/java/io/jboot/server/jetty/JettyServer.java +++ /dev/null @@ -1,172 +0,0 @@ -/** - * Copyright (c) 2015-2018, Michael Yang 杨福海 (fuhai999@gmail.com). - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.jboot.server.jetty; - - -import com.codahale.metrics.servlets.AdminServlet; -import com.jfinal.core.JFinalFilter; -import com.jfinal.log.Log; -import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet; -import io.jboot.Jboot; -import io.jboot.component.hystrix.JbootHystrixConfig; -import io.jboot.component.metric.JbootHealthCheckServletContextListener; -import io.jboot.component.metric.JbootMetricConfig; -import io.jboot.component.metric.JbootMetricServletContextListener; -import io.jboot.component.shiro.JbootShiroConfig; -import io.jboot.server.ContextListeners; -import io.jboot.server.JbootServer; -import io.jboot.server.JbootServerConfig; -import io.jboot.server.JbootServerClassloader; -import io.jboot.server.listener.JbootAppListenerManager; -import io.jboot.utils.ClassKits; -import io.jboot.utils.StringUtils; -import io.jboot.web.JbootWebConfig; -import org.apache.shiro.web.env.EnvironmentLoaderListener; -import org.apache.shiro.web.servlet.ShiroFilter; -import org.eclipse.jetty.server.Server; -import org.eclipse.jetty.servlet.FilterHolder; -import org.eclipse.jetty.servlet.ServletContextHandler; - -import javax.servlet.DispatcherType; -import javax.servlet.ServletContextListener; -import java.io.File; -import java.net.InetSocketAddress; -import java.net.URISyntaxException; -import java.util.EnumSet; -import java.util.Map; - -public class JettyServer extends JbootServer { - - private static Log log = Log.getLog(JettyServer.class); - - private JbootServerConfig config; - private JbootWebConfig webConfig; - - private Server jettyServer; - private ServletContextHandler handler; - - public JettyServer() { - config = Jboot.config(JbootServerConfig.class); - webConfig = Jboot.config(JbootWebConfig.class); - } - - @Override - public boolean start() { - try { - initJettyServer(); - JbootAppListenerManager.me().onAppStartBefore(this); - jettyServer.start(); - } catch (Throwable ex) { - log.error(ex.toString(), ex); - stop(); - return false; - } - return true; - } - - private void initJettyServer() { - InetSocketAddress address = new InetSocketAddress(config.getHost(), config.getPort()); - jettyServer = new Server(address); - - handler = new ServletContextHandler(); - handler.setContextPath(config.getContextPath()); - handler.setClassLoader(new JbootServerClassloader(JettyServer.class.getClassLoader())); - handler.setResourceBase(getRootClassPath()); - - JbootShiroConfig shiroConfig = Jboot.config(JbootShiroConfig.class); - if (shiroConfig.isConfigOK()) { - handler.addEventListener(new EnvironmentLoaderListener()); - handler.addFilter(ShiroFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST)); - } - - //JFinal - FilterHolder jfinalFilter = handler.addFilter(JFinalFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST)); - jfinalFilter.setInitParameter("configClass", Jboot.me().getJbootConfig().getJfinalConfig()); - - JbootHystrixConfig hystrixConfig = Jboot.config(JbootHystrixConfig.class); - if (StringUtils.isNotBlank(hystrixConfig.getUrl())) { - handler.addServlet(HystrixMetricsStreamServlet.class, hystrixConfig.getUrl()); - } - - - JbootMetricConfig metricsConfig = Jboot.config(JbootMetricConfig.class); - if (StringUtils.isNotBlank(metricsConfig.getUrl())) { - handler.addEventListener(new JbootMetricServletContextListener()); - handler.addEventListener(new JbootHealthCheckServletContextListener()); - handler.addServlet(AdminServlet.class, metricsConfig.getUrl()); - } - - io.jboot.server.Servlets jbootServlets = new io.jboot.server.Servlets(); - ContextListeners listeners = new ContextListeners(); - - JbootAppListenerManager.me().onJbootDeploy(jbootServlets, listeners); - - - for (Map.Entry entry : jbootServlets.getServlets().entrySet()) { - for (String path : entry.getValue().getUrlMapping()) { - handler.addServlet(entry.getValue().getServletClass(), path); - } - } - - - for (Class listenerClass : listeners.getListeners()) { - handler.addEventListener(ClassKits.newInstance(listenerClass)); - } - - jettyServer.setHandler(handler); - } - - private static String getRootClassPath() { - String path = null; - try { - path = JettyServer.class.getClassLoader().getResource("").toURI().getPath(); - return new File(path).getAbsolutePath(); - } catch (URISyntaxException e) { - e.printStackTrace(); - } - return path; - } - - @Override - public boolean restart() { - stop(); - start(); - return true; - } - - @Override - public boolean stop() { - try { - jettyServer.stop(); - return true; - } catch (Exception ex) { - log.error("can not start jetty with port:" + config.getPort(), ex); - } - return false; - } - - - public Server getJettyServer() { - return jettyServer; - } - - - public ServletContextHandler getHandler() { - return handler; - } - - -} diff --git a/src/main/java/io/jboot/server/tomcat/TomcatServer.java b/src/main/java/io/jboot/server/tomcat/TomcatServer.java deleted file mode 100644 index 596ecf93233224b9500384f55eaf8ce1ae30d347..0000000000000000000000000000000000000000 --- a/src/main/java/io/jboot/server/tomcat/TomcatServer.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright (c) 2015-2018, Michael Yang 杨福海 (fuhai999@gmail.com). - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.jboot.server.tomcat; - - -import io.jboot.exception.JbootException; -import io.jboot.server.JbootServer; - -public class TomcatServer extends JbootServer { - - - @Override - public boolean start() { - new JbootException("tomcat server not finish!!!"); - return false; - } - - @Override - public boolean restart() { - return false; - } - - @Override - public boolean stop() { - return false; - } -} diff --git a/src/main/java/io/jboot/web/controller/JbootController.java b/src/main/java/io/jboot/web/controller/JbootController.java index 6b5d1034fdbafcad68d22d5915027fc58a4d7d0e..7c74118c23cb7c5df9e6478d0cba336969a6a14a 100644 --- a/src/main/java/io/jboot/web/controller/JbootController.java +++ b/src/main/java/io/jboot/web/controller/JbootController.java @@ -15,19 +15,20 @@ */ package io.jboot.web.controller; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; + import com.jfinal.aop.Before; import com.jfinal.core.Controller; import com.jfinal.ext.interceptor.NotAction; import com.jfinal.kit.HttpKit; import com.jfinal.upload.UploadFile; + import io.jboot.utils.ArrayUtils; import io.jboot.utils.RequestUtils; -import io.jboot.component.jwt.JwtManager; - -import javax.servlet.http.HttpServletRequest; -import java.util.HashMap; -import java.util.List; -import java.util.Map; public class JbootController extends Controller { @@ -195,23 +196,6 @@ public class JbootController extends Controller { return jwtMap; } - @Before(NotAction.class) - public T getJwtPara(String name) { - return JwtManager.me().getPara(name); - } - - @Before(NotAction.class) - public Map getJwtParas() { - return JwtManager.me().getParas(); - } - - @Before(NotAction.class) - public String createJwtToken() { - if (jwtMap == null) { - throw new NullPointerException("jwt attrs is null"); - } - return JwtManager.me().createJwtToken(jwtMap); - } /** * 获取当前网址 diff --git a/src/main/java/io/jboot/web/fixedinterceptor/FixedInterceptors.java b/src/main/java/io/jboot/web/fixedinterceptor/FixedInterceptors.java index 027a47a59b850883937a91da828f3a49b434e505..0e148c15b788eed0de6729671de9b3ceff683b95 100644 --- a/src/main/java/io/jboot/web/fixedinterceptor/FixedInterceptors.java +++ b/src/main/java/io/jboot/web/fixedinterceptor/FixedInterceptors.java @@ -15,8 +15,10 @@ */ package io.jboot.web.fixedinterceptor; +import java.util.ArrayList; +import java.util.List; + import io.jboot.Jboot; -import io.jboot.component.jwt.JwtInterceptor; import io.jboot.component.metric.JbootMetricInterceptor; import io.jboot.component.opentracing.OpentracingInterceptor; import io.jboot.component.shiro.JbootShiroInterceptor; @@ -24,9 +26,6 @@ import io.jboot.web.controller.validate.ParaValidateInterceptor; import io.jboot.web.cors.CORSInterceptor; import io.jboot.web.limitation.LimitationInterceptor; -import java.util.ArrayList; -import java.util.List; - /** * @author Michael Yang 杨福海 (fuhai999@gmail.com) * @version V1.0 @@ -48,7 +47,6 @@ public class FixedInterceptors { new CORSInterceptor(), new LimitationInterceptor(), new ParaValidateInterceptor(), - new JwtInterceptor(), new JbootShiroInterceptor(), new OpentracingInterceptor(), new JbootMetricInterceptor()}; diff --git a/src/test/java/dubborestful/DubboRestfulDemo.java b/src/test/java/dubborestful/DubboRestfulDemo.java deleted file mode 100644 index e07dff3db21a526a4e2c6b7f13e320ff2e8907d8..0000000000000000000000000000000000000000 --- a/src/test/java/dubborestful/DubboRestfulDemo.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Copyright (c) 2015-2018, Michael Yang 杨福海 (fuhai999@gmail.com). - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package dubborestful; - -import io.jboot.Jboot; -import io.jboot.core.rpc.Jbootrpc; - - -public class DubboRestfulDemo { - - - /** - * 使用 dubbo 的 restful ,请配置 jboot.rpc.dubbo.protocolName 为 rest - * 具体文档:http://dangdangdotcom.github.io/dubbox/rest.html - *

- * 针对某个Service 单独暴露 restful 的配置晚点支持,目前针对单个 Service, - * 目前可以通过 父子系统的方式来实现,父子系统通信走RPC,子系统对外暴露 restful - *

- * 运行 main() 方法后,访问: http://127.0.0.1:8002/users/get 来查看效果 - *

- * 具体代码在: UserServiceImpl 里 - * - * @param args - */ - public static void main(String[] args) { - - - Jboot.setBootArg("jboot.rpc.type", "dubbo"); - Jboot.setBootArg("jboot.rpc.callMode", "redirect");//直连模式,默认为注册中心 - Jboot.setBootArg("jboot.rpc.directUrl", "localhost:8002");//直连模式的url地址 - - Jboot.setBootArg("jboot.rpc.dubbo.protocolName", "rest"); -// Jboot.setBootArg("jboot.rpc.dubbo.protocolServer","netty"); //netty tomcat jetty -// Jboot.setBootArg("jboot.rpc.dubbo.protocolContextPath","/mypath"); - - - Jboot.run(args); - - Jbootrpc factory = Jboot.me().getRpc(); - - factory.serviceExport(UserService.class, new UserServiceImpl(), "jboot", "1.0", 8002); - - - System.out.println("server started..."); - - - } -} diff --git a/src/test/java/dubborestful/UserService.java b/src/test/java/dubborestful/UserService.java deleted file mode 100644 index 6db53dfa0cf0a908bab813ab8f66f2f4516ca3c5..0000000000000000000000000000000000000000 --- a/src/test/java/dubborestful/UserService.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright (c) 2015-2018, Michael Yang 杨福海 (fuhai999@gmail.com). - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package dubborestful; - - -public interface UserService { - - - public String test(String name); - - public String get(); - -} diff --git a/src/test/java/dubborestful/UserServiceImpl.java b/src/test/java/dubborestful/UserServiceImpl.java deleted file mode 100644 index 175ea19f62d3b82398a9cf33b9996f1019ba5874..0000000000000000000000000000000000000000 --- a/src/test/java/dubborestful/UserServiceImpl.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Copyright (c) 2015-2018, Michael Yang 杨福海 (fuhai999@gmail.com). - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package dubborestful; - - -import com.jfinal.kit.Ret; - -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; - -@Path("users") -public class UserServiceImpl implements UserService { - - - @Override - @GET - @Path("hello") - @Consumes({MediaType.APPLICATION_JSON}) - public String test(@QueryParam("name") String name) { - - System.out.println("UserServiceImpl test() invoked!!!"); - return Ret.ok().set("name",name).toJson(); - } - - @Override - @GET - @Path("get") - @Consumes({MediaType.TEXT_PLAIN}) - public String get() { - - System.out.println("UserServiceImpl get() invoked!!!"); - - return "hello , dubbo restful"; - } - - - - -} diff --git a/src/test/java/jwt/JwtDemo.java b/src/test/java/jwt/JwtDemo.java deleted file mode 100644 index 733e5d4ea4b965741372569996ab63a06658ce36..0000000000000000000000000000000000000000 --- a/src/test/java/jwt/JwtDemo.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Copyright (c) 2015-2018, Michael Yang 杨福海 (fuhai999@gmail.com). - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package jwt; - -import io.jboot.Jboot; -import io.jboot.web.controller.JbootController; -import io.jboot.web.controller.annotation.RequestMapping; - - -@RequestMapping("/jwt") -public class JwtDemo extends JbootController { - - - public static void main(String[] args) { - Jboot.setBootArg("jboot.web.jwt.secret", "mySecret"); - Jboot.setBootArg("jboot.server.port", "8888"); - Jboot.run(args); - } - - - public void index() { - setJwtAttr("key1", "test111"); - setJwtAttr("key2", "test"); - setJwtAttr("key3", "test"); - - String token = createJwtToken(); - renderText(token); - } - - public void show() { - String value = getJwtPara("key1"); - renderText("jwt value : " + value); - } - - -}