├── jim-framework-cache ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── jim │ │ │ └── framework │ │ │ └── cache │ │ │ ├── redis │ │ │ ├── InvocationRegistry.java │ │ │ ├── CacheSupport.java │ │ │ ├── CacheItemConfig.java │ │ │ └── CachedInvocation.java │ │ │ ├── Application.java │ │ │ └── helper │ │ │ ├── ApplicationContextHelper.java │ │ │ └── ThreadTaskHelper.java │ └── test │ │ └── java │ │ └── com │ │ └── jim │ │ └── framework │ │ └── cache │ │ └── ApplicationTests.java ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties └── .gitignore ├── jim-framework-rpc-api ├── src │ └── main │ │ ├── resources │ │ └── application.properties │ │ └── java │ │ └── com │ │ └── jim │ │ └── framework │ │ └── rpc │ │ └── api │ │ ├── service │ │ ├── ProductService.java │ │ └── CommentService.java │ │ ├── RpcApiApplication.java │ │ └── model │ │ ├── Product.java │ │ └── Comment.java ├── .gitignore └── pom.xml ├── jim-framework-rpc ├── src │ └── main │ │ ├── resources │ │ └── application.properties │ │ └── java │ │ ├── com │ │ └── jim │ │ │ └── framework │ │ │ └── rpc │ │ │ ├── common │ │ │ ├── RpcInvoker.java │ │ │ ├── RpcFilter.java │ │ │ ├── RpcInvocation.java │ │ │ ├── RpcResponse.java │ │ │ ├── RpcURL.java │ │ │ └── RpcRequest.java │ │ │ ├── loadbalance │ │ │ ├── LoadbalanceService.java │ │ │ └── RoundRobinLoadbalanceService.java │ │ │ ├── threadpool │ │ │ ├── RpcThreadPool.java │ │ │ ├── RpcThreadPoolFactory.java │ │ │ └── FixedRpcThreadPool.java │ │ │ ├── client │ │ │ ├── ResponseCallback.java │ │ │ ├── RpcReference.java │ │ │ ├── RpcClientInitializer.java │ │ │ └── RpcClient.java │ │ │ ├── registry │ │ │ ├── RegistryService.java │ │ │ ├── DiscoveryService.java │ │ │ ├── AbstractConsulService.java │ │ │ └── ConsulRegistryService.java │ │ │ ├── filter │ │ │ ├── AccessLimitService.java │ │ │ ├── ActiveFilter.java │ │ │ ├── AccessLogFilter.java │ │ │ ├── FutureFilter.java │ │ │ ├── ServerContextFilter.java │ │ │ ├── ClientContextFilter.java │ │ │ └── AccessLimitFilter.java │ │ │ ├── RpcApplication.java │ │ │ ├── config │ │ │ ├── ConstantConfig.java │ │ │ ├── RpcConfiguration.java │ │ │ ├── ServiceConfig.java │ │ │ └── ReferenceConfig.java │ │ │ ├── exception │ │ │ ├── TimeoutRpcException.java │ │ │ └── RpcException.java │ │ │ ├── keepalive │ │ │ ├── ClientHeartbeatHandler.java │ │ │ └── ServerHeartbeatHandler.java │ │ │ ├── server │ │ │ └── RpcService.java │ │ │ ├── constants │ │ │ └── Constants.java │ │ │ ├── protocol │ │ │ ├── RpcMessageHeader.java │ │ │ └── RpcMessage.java │ │ │ ├── utils │ │ │ └── ApplicationContextUtils.java │ │ │ ├── proxy │ │ │ └── RpcProxy.java │ │ │ ├── codec │ │ │ ├── RpcEncoder.java │ │ │ └── RpcDecoder.java │ │ │ └── context │ │ │ └── RpcContext.java │ │ └── test │ │ └── com │ │ └── jim │ │ └── framework │ │ └── rpc │ │ └── registry │ │ └── impl │ │ ├── RegistryServiceConfig.java │ │ └── ConsulRegistryServiceImplTest.java ├── README-Future.md ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties └── .gitignore ├── jim-framework-dubbo-core ├── src │ ├── main │ │ ├── resources │ │ │ ├── application.properties │ │ │ └── META-INF │ │ │ │ ├── spring.provides │ │ │ │ ├── spring.factories │ │ │ │ └── dubbo │ │ │ │ └── com.alibaba.dubbo.rpc.Filter │ │ └── java │ │ │ └── com │ │ │ └── jim │ │ │ └── framework │ │ │ └── dubbo │ │ │ └── core │ │ │ ├── service │ │ │ ├── ProductService.java │ │ │ └── CommentService.java │ │ │ ├── Application.java │ │ │ ├── context │ │ │ ├── AbstractContext.java │ │ │ ├── HttpZipkinCollectorConfiguration.java │ │ │ ├── KafkaZipkinCollectorConfiguration.java │ │ │ ├── ZipkinCollectorConfigurationFactory.java │ │ │ ├── AbstractZipkinCollectorConfiguration.java │ │ │ └── RpcTraceContext.java │ │ │ ├── annotation │ │ │ └── EnableTraceAutoConfigurationProperties.java │ │ │ ├── utils │ │ │ └── SpringContextUtils.java │ │ │ ├── model │ │ │ ├── Product.java │ │ │ └── Comment.java │ │ │ └── trace │ │ │ └── config │ │ │ └── EnableTraceAutoConfiguration.java │ └── test │ │ └── java │ │ └── com │ │ └── jim │ │ └── framework │ │ └── dubbo │ │ └── core │ │ └── ApplicationTests.java ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties └── .gitignore ├── jim-framework-rpc-provider ├── src │ └── main │ │ ├── resources │ │ └── application.properties │ │ └── java │ │ └── com │ │ └── jim │ │ └── framework │ │ └── rpc │ │ └── provider │ │ ├── JimRpcProviderApplication.java │ │ ├── service │ │ └── impl │ │ │ └── ProductServiceImpl.java │ │ └── config │ │ └── ProviderConfiguration.java ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.properties │ │ └── maven-wrapper.jar ├── .gitignore └── pom.xml ├── jim-framework-rpc-consumer ├── src │ ├── main │ │ ├── resources │ │ │ ├── application.properties │ │ │ └── META-INF │ │ │ │ └── spring.factories │ │ └── java │ │ │ └── com │ │ │ └── jim │ │ │ └── framework │ │ │ └── rpc │ │ │ └── consumer │ │ │ ├── service │ │ │ ├── ProductCommentMockService.java │ │ │ ├── ProductCommentService.java │ │ │ └── impl │ │ │ │ ├── ProductCommentMockServiceImpl.java │ │ │ │ └── AccessLimitServiceImpl.java │ │ │ ├── JimRpcConsumerApplication.java │ │ │ ├── controller │ │ │ └── ProductController.java │ │ │ └── config │ │ │ └── ConsumerConfiguration.java │ └── test │ │ └── java │ │ └── com │ │ └── jim │ │ └── framework │ │ └── rpc │ │ └── consumer │ │ └── JimConsumerApplication2Test.java ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.properties │ │ └── maven-wrapper.jar ├── .gitignore └── pom.xml ├── jim-framework-cloud-config ├── src │ ├── main │ │ ├── resources │ │ │ ├── config │ │ │ │ └── jim-cloud-config-test.properties │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── jim │ │ │ └── framework │ │ │ └── cloud │ │ │ └── config │ │ │ └── ConfigApplication.java │ └── test │ │ └── java │ │ └── com │ │ └── jim │ │ └── framework │ │ └── cloud │ │ └── config │ │ └── ApplicationTests.java ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties └── .gitignore ├── jim-framework-cloud-consumer ├── src │ ├── main │ │ ├── resources │ │ │ ├── bootstrap.yml │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── jim │ │ │ └── framework │ │ │ └── cloud │ │ │ └── consumer │ │ │ ├── service │ │ │ ├── ProductServiceHystrix.java │ │ │ └── ProductService.java │ │ │ ├── ConsumerApplication.java │ │ │ └── controller │ │ │ └── ProductController.java │ └── test │ │ └── java │ │ └── com │ │ └── jim │ │ └── framework │ │ └── cloud │ │ └── consumer │ │ └── ApplicationTests.java ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties └── .gitignore ├── jim-framework-doc └── images │ ├── zipkin.jpg │ ├── configCenter.jpg │ ├── dubbo-zipkin.jpg │ ├── zipkin-call.jpg │ ├── firefox-network.jpg │ ├── trace_auto_config.jpg │ ├── zipkin-call-detail.jpg │ └── zipkin-call-dependency.jpg ├── jim-framework-web ├── hs_err_pid124160.log ├── hs_err_pid128948.log ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── src │ └── main │ │ ├── resources │ │ ├── config-center.properties │ │ ├── generator │ │ │ ├── generator.properties │ │ │ └── generatorConfig.xml │ │ ├── mapper │ │ │ └── ProductMapper.xml │ │ ├── application.properties │ │ └── logback.xml │ │ └── java │ │ └── com │ │ └── jim │ │ └── framework │ │ └── web │ │ ├── service │ │ ├── TestDataService.java │ │ ├── BaseService.java │ │ ├── ProductService.java │ │ ├── impl │ │ │ ├── TestDataServiceImpl.java │ │ │ └── StudentServiceImpl.java │ │ └── StudentService.java │ │ ├── dao │ │ └── generated │ │ │ ├── mapper │ │ │ └── ProductMapper.java │ │ │ └── entity │ │ │ └── Product.java │ │ ├── repository │ │ └── StudentRepository.java │ │ ├── common │ │ ├── ValueResult.java │ │ ├── Result.java │ │ ├── ErrorDef.java │ │ └── ErrorInfo.java │ │ ├── WebApplication.java │ │ ├── utils │ │ ├── FastjsonSerialize.java │ │ └── JacksonSerialize.java │ │ ├── interceptor │ │ └── PermissionInterceptor.java │ │ ├── controller │ │ ├── RequestLockController.java │ │ └── ProductController.java │ │ ├── filter │ │ └── TimeFilter.java │ │ └── config │ │ └── MyBatisMapperScannerConfig.java ├── docker │ ├── Dockerfile │ └── Docker.md └── .gitignore ├── jim-framework-lock ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── .gitignore ├── src │ └── main │ │ └── java │ │ └── com │ │ └── jim │ │ └── framework │ │ └── annotationlock │ │ ├── AnnotationLockApplication.java │ │ ├── annotation │ │ └── RequestLockable.java │ │ ├── redis │ │ └── RedissonContext.java │ │ └── interceptor │ │ └── RedisRequestLockInterceptor.java └── pom.xml ├── jim-framework-activemq ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── jim │ │ │ └── framework │ │ │ └── activemq │ │ │ ├── producer │ │ │ ├── ProductSendMessage.java │ │ │ ├── ProductProducer.java │ │ │ └── JimPooledConnectionFactory.java │ │ │ ├── ActivemqApplication.java │ │ │ ├── model │ │ │ └── Product.java │ │ │ ├── consumer │ │ │ ├── ProductConsumerC.java │ │ │ ├── ProductConsumerA.java │ │ │ └── ProductConsumerB.java │ │ │ └── config │ │ │ ├── ConsumerConfig.java │ │ │ └── QueueJmsTemplateContainer.java │ └── test │ │ └── java │ │ └── com │ │ └── framework │ │ └── activemq │ │ └── ActivemqApplicationTests.java └── .gitignore ├── jim-framework-cloud-zipkin ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── .gitignore └── src │ ├── test │ └── java │ │ └── com │ │ └── jim │ │ └── framework │ │ └── cloud │ │ └── zipkin │ │ └── ApplicationTests.java │ └── main │ ├── java │ └── com │ │ └── jim │ │ └── framework │ │ └── cloud │ │ └── zipkin │ │ └── ZipkinApplication.java │ └── resources │ └── application.properties ├── jim-framework-configcenter ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── .gitignore └── src │ └── main │ └── java │ └── com │ └── jim │ └── framework │ └── configcenter │ ├── model │ ├── DefaultOptions.java │ └── ConfigOption.java │ ├── ConfigcenterApplication.java │ ├── service │ ├── ConfigCenterService.java │ └── impl │ │ └── AbstractConfigCenterService.java │ ├── event │ └── DataChangeEvent.java │ ├── spring │ └── SpringPropertyInjectSupport.java │ └── utils │ └── ZKUtil.java ├── jim-framework-cloud-provider ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── src │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── jim │ │ │ │ └── framework │ │ │ │ └── cloud │ │ │ │ └── provider │ │ │ │ ├── service │ │ │ │ ├── ProductService.java │ │ │ │ └── impl │ │ │ │ │ └── ProductServiceImpl.java │ │ │ │ ├── model │ │ │ │ └── Product.java │ │ │ │ ├── ProviderApplication.java │ │ │ │ └── controller │ │ │ │ └── ProductController.java │ │ └── resources │ │ │ └── application.properties │ └── test │ │ └── java │ │ └── com │ │ └── jim │ │ └── framework │ │ └── cloud │ │ └── provider │ │ └── ApplicationTests.java └── .gitignore ├── jim-framework-cloud-registry ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── .gitignore └── src │ ├── main │ ├── resources │ │ ├── bootstrap.yml │ │ └── application.properties │ └── java │ │ └── com │ │ └── jim │ │ └── framework │ │ └── cloud │ │ └── registry │ │ └── RegistryApplication.java │ └── test │ └── java │ └── com │ └── jim │ └── framework │ └── cloud │ └── registry │ └── JimFrameworkCloudRegistryApplicationTests.java ├── jim-framework-dubbo-consumer ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── .gitignore ├── src │ ├── main │ │ ├── resources │ │ │ ├── application.properties │ │ │ └── applicationContext-dubbo-consumer.xml │ │ └── java │ │ │ └── com │ │ │ └── jim │ │ │ └── framework │ │ │ └── dubbo │ │ │ └── consumer │ │ │ ├── DubboConsumerApplication.java │ │ │ └── controller │ │ │ └── ProductController.java │ └── test │ │ └── java │ │ └── com │ │ └── jim │ │ └── framework │ │ └── dubbo │ │ └── consumer │ │ └── ApplicationTests.java └── pom.xml ├── jim-framework-dubbo-provider ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── .gitignore ├── src │ ├── main │ │ ├── resources │ │ │ ├── application.properties │ │ │ ├── applicationContext-dubbo-consumer.xml │ │ │ └── applicationContext-dubbo-provider.xml │ │ └── java │ │ │ └── com │ │ │ └── jim │ │ │ └── framework │ │ │ └── dubbo │ │ │ └── provider │ │ │ ├── service │ │ │ └── ProductServiceImpl.java │ │ │ ├── DubboProviderApplication.java │ │ │ └── config │ │ │ └── DubboProviderConfig.java │ └── test │ │ └── java │ │ └── com │ │ └── jim │ │ └── framework │ │ └── dubbo │ │ └── provider │ │ └── ApplicationTests.java └── pom.xml ├── jim-framework-dubbo-provider2 ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.properties │ │ └── maven-wrapper.jar ├── .gitignore ├── src │ ├── main │ │ ├── resources │ │ │ ├── application.properties │ │ │ └── applicationContext-dubbo-provider.xml │ │ └── java │ │ │ └── com │ │ │ └── jim │ │ │ └── framework │ │ │ └── dubbo │ │ │ └── provider2 │ │ │ ├── service │ │ │ └── CommentServiceImpl.java │ │ │ └── DubboProviderApplication2.java │ └── test │ │ └── java │ │ └── com │ │ └── jim │ │ └── framework │ │ └── dubbo │ │ └── provider2 │ │ └── ApplicationTests.java └── pom.xml ├── .gitignore └── pom.xml /jim-framework-cache/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /jim-framework-rpc-api/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /jim-framework-rpc/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /jim-framework-dubbo-core/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /jim-framework-rpc-provider/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /jim-framework-rpc-consumer/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=3333 -------------------------------------------------------------------------------- /jim-framework-rpc/README-Future.md: -------------------------------------------------------------------------------- 1 | # RPC具备异步回调功能 2 | RPC大多数情况都是同步调用,特殊场景需求也支持异步调用。 3 | 4 | 5 | -------------------------------------------------------------------------------- /jim-framework-cloud-config/src/main/resources/config/jim-cloud-config-test.properties: -------------------------------------------------------------------------------- 1 | test.key=abcde -------------------------------------------------------------------------------- /jim-framework-dubbo-core/src/main/resources/META-INF/spring.provides: -------------------------------------------------------------------------------- 1 | provides: spring-boot-starter-dubbo -------------------------------------------------------------------------------- /jim-framework-cloud-consumer/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | #feign: 2 | # hystrix: 3 | # enabled: true 4 | -------------------------------------------------------------------------------- /jim-framework-doc/images/zipkin.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiangmin168168/jim-framework/HEAD/jim-framework-doc/images/zipkin.jpg -------------------------------------------------------------------------------- /jim-framework-web/hs_err_pid124160.log: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiangmin168168/jim-framework/HEAD/jim-framework-web/hs_err_pid124160.log -------------------------------------------------------------------------------- /jim-framework-web/hs_err_pid128948.log: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiangmin168168/jim-framework/HEAD/jim-framework-web/hs_err_pid128948.log -------------------------------------------------------------------------------- /jim-framework-doc/images/configCenter.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiangmin168168/jim-framework/HEAD/jim-framework-doc/images/configCenter.jpg -------------------------------------------------------------------------------- /jim-framework-doc/images/dubbo-zipkin.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiangmin168168/jim-framework/HEAD/jim-framework-doc/images/dubbo-zipkin.jpg -------------------------------------------------------------------------------- /jim-framework-doc/images/zipkin-call.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiangmin168168/jim-framework/HEAD/jim-framework-doc/images/zipkin-call.jpg -------------------------------------------------------------------------------- /jim-framework-doc/images/firefox-network.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiangmin168168/jim-framework/HEAD/jim-framework-doc/images/firefox-network.jpg -------------------------------------------------------------------------------- /jim-framework-doc/images/trace_auto_config.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiangmin168168/jim-framework/HEAD/jim-framework-doc/images/trace_auto_config.jpg -------------------------------------------------------------------------------- /jim-framework-doc/images/zipkin-call-detail.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiangmin168168/jim-framework/HEAD/jim-framework-doc/images/zipkin-call-detail.jpg -------------------------------------------------------------------------------- /jim-framework-lock/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiangmin168168/jim-framework/HEAD/jim-framework-lock/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /jim-framework-rpc/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiangmin168168/jim-framework/HEAD/jim-framework-rpc/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /jim-framework-web/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiangmin168168/jim-framework/HEAD/jim-framework-web/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /jim-framework-activemq/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=3336 2 | server.context-path=/api 3 | 4 | #logging.level.org.apache.activemq=debug 5 | -------------------------------------------------------------------------------- /jim-framework-cache/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiangmin168168/jim-framework/HEAD/jim-framework-cache/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /jim-framework-doc/images/zipkin-call-dependency.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiangmin168168/jim-framework/HEAD/jim-framework-doc/images/zipkin-call-dependency.jpg -------------------------------------------------------------------------------- /jim-framework-rpc/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip -------------------------------------------------------------------------------- /jim-framework-cache/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip 2 | -------------------------------------------------------------------------------- /jim-framework-lock/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip 2 | -------------------------------------------------------------------------------- /jim-framework-rpc-consumer/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip -------------------------------------------------------------------------------- /jim-framework-rpc-provider/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip -------------------------------------------------------------------------------- /jim-framework-web/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip 2 | -------------------------------------------------------------------------------- /jim-framework-cloud-config/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiangmin168168/jim-framework/HEAD/jim-framework-cloud-config/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /jim-framework-cloud-config/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip 2 | -------------------------------------------------------------------------------- /jim-framework-cloud-zipkin/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiangmin168168/jim-framework/HEAD/jim-framework-cloud-zipkin/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /jim-framework-cloud-zipkin/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip 2 | -------------------------------------------------------------------------------- /jim-framework-configcenter/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiangmin168168/jim-framework/HEAD/jim-framework-configcenter/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /jim-framework-configcenter/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip 2 | -------------------------------------------------------------------------------- /jim-framework-dubbo-core/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiangmin168168/jim-framework/HEAD/jim-framework-dubbo-core/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /jim-framework-dubbo-core/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip 2 | -------------------------------------------------------------------------------- /jim-framework-rpc-consumer/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiangmin168168/jim-framework/HEAD/jim-framework-rpc-consumer/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /jim-framework-rpc-provider/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiangmin168168/jim-framework/HEAD/jim-framework-rpc-provider/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /jim-framework-cloud-consumer/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiangmin168168/jim-framework/HEAD/jim-framework-cloud-consumer/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /jim-framework-cloud-consumer/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip 2 | -------------------------------------------------------------------------------- /jim-framework-cloud-provider/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiangmin168168/jim-framework/HEAD/jim-framework-cloud-provider/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /jim-framework-cloud-provider/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip 2 | -------------------------------------------------------------------------------- /jim-framework-cloud-registry/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiangmin168168/jim-framework/HEAD/jim-framework-cloud-registry/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /jim-framework-cloud-registry/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip 2 | -------------------------------------------------------------------------------- /jim-framework-dubbo-consumer/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiangmin168168/jim-framework/HEAD/jim-framework-dubbo-consumer/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /jim-framework-dubbo-consumer/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip 2 | -------------------------------------------------------------------------------- /jim-framework-dubbo-provider/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiangmin168168/jim-framework/HEAD/jim-framework-dubbo-provider/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /jim-framework-dubbo-provider/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip 2 | -------------------------------------------------------------------------------- /jim-framework-dubbo-provider2/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip 2 | -------------------------------------------------------------------------------- /jim-framework-dubbo-provider2/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiangmin168168/jim-framework/HEAD/jim-framework-dubbo-provider2/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /jim-framework-rpc-consumer/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | com.jim.framework.rpc.filter.AccessLimitService=com.jim.framework.rpc.consumer.service.impl.AccessLimitServiceImpl -------------------------------------------------------------------------------- /jim-framework-web/src/main/resources/config-center.properties: -------------------------------------------------------------------------------- 1 | dev.zk=192.168.2.141:2181 2 | test.zk=192.168.2.141:2181 3 | sim.zk=192.168.2.141:2181 4 | online.zk=192.168.2.141:2181 5 | -------------------------------------------------------------------------------- /jim-framework-dubbo-core/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.jim.framework.dubbo.core.trace.config.EnableTraceAutoConfiguration 2 | -------------------------------------------------------------------------------- /jim-framework-dubbo-core/src/main/resources/META-INF/dubbo/com.alibaba.dubbo.rpc.Filter: -------------------------------------------------------------------------------- 1 | traceProviderFilter=com.jim.framework.dubbo.core.filter.TraceProviderFilter 2 | traceConsumerFilter=com.jim.framework.dubbo.core.filter.TraceConsumerFilter -------------------------------------------------------------------------------- /jim-framework-web/src/main/java/com/jim/framework/web/service/TestDataService.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.web.service; 2 | 3 | /** 4 | * Created by jiang on 2016/12/22. 5 | */ 6 | public interface TestDataService { 7 | int get(int i); 8 | } 9 | -------------------------------------------------------------------------------- /jim-framework-rpc/src/main/java/com/jim/framework/rpc/common/RpcInvoker.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.common; 2 | 3 | /** 4 | * Created by jiang on 2017/5/14. 5 | */ 6 | public interface RpcInvoker { 7 | Object invoke(RpcInvocation invocation); 8 | } 9 | -------------------------------------------------------------------------------- /jim-framework-rpc-api/src/main/java/com/jim/framework/rpc/api/service/ProductService.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.api.service; 2 | 3 | import com.jim.framework.rpc.api.model.Product; 4 | 5 | public interface ProductService { 6 | Product getById(Long id); 7 | } 8 | -------------------------------------------------------------------------------- /jim-framework-rpc/src/main/java/com/jim/framework/rpc/loadbalance/LoadbalanceService.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.loadbalance; 2 | 3 | /** 4 | * Created by jiang on 2017/5/22. 5 | */ 6 | public interface LoadbalanceService { 7 | int index(int size); 8 | } 9 | -------------------------------------------------------------------------------- /jim-framework-web/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM java:8 2 | 3 | MAINTAINER jim 4 | 5 | WORKDIR /var/app/elasticsearch-2.4.2/bin 6 | 7 | ADD elasticsearch-2.4.2 /var/app 8 | 9 | ENTRYPOINT ./elasticsearch -d 10 | 11 | EXPOSE 9200 12 | EXPOSE 9300 13 | -------------------------------------------------------------------------------- /jim-framework-rpc/src/main/java/com/jim/framework/rpc/common/RpcFilter.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.common; 2 | 3 | /** 4 | * Created by jiang on 2017/5/14. 5 | */ 6 | public interface RpcFilter { 7 | T invoke(RpcInvoker invoker, RpcInvocation invocation); 8 | } 9 | -------------------------------------------------------------------------------- /jim-framework-activemq/src/main/java/com/jim/framework/activemq/producer/ProductSendMessage.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.activemq.producer; 2 | 3 | /** 4 | * Created by jiangmin on 2018/1/1. 5 | */ 6 | public interface ProductSendMessage { 7 | 8 | void sendMessage(Object message); 9 | } 10 | -------------------------------------------------------------------------------- /jim-framework-web/src/main/java/com/jim/framework/web/dao/generated/mapper/ProductMapper.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.web.dao.generated.mapper; 2 | 3 | import com.jim.framework.web.dao.generated.entity.Product; 4 | import tk.mybatis.mapper.common.Mapper; 5 | 6 | public interface ProductMapper extends Mapper { 7 | } -------------------------------------------------------------------------------- /jim-framework-rpc/src/main/java/com/jim/framework/rpc/threadpool/RpcThreadPool.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.threadpool; 2 | 3 | import java.util.concurrent.Executor; 4 | 5 | /** 6 | * Created by jim on 2017/7/2/002. 7 | */ 8 | public interface RpcThreadPool { 9 | Executor getExecutor(int threadSize,int queues); 10 | } 11 | -------------------------------------------------------------------------------- /jim-framework-rpc/src/main/java/com/jim/framework/rpc/client/ResponseCallback.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.client; 2 | 3 | /** 4 | * Created by jiang on 2017/5/16. 5 | */ 6 | public interface ResponseCallback { 7 | 8 | void onSuccess(Object response); 9 | 10 | void onException(RuntimeException ex); 11 | } 12 | -------------------------------------------------------------------------------- /jim-framework-web/docker/Docker.md: -------------------------------------------------------------------------------- 1 | # How to build the docker image 2 | 3 | ```make build``` 4 | 5 | # How to publish the docker image 6 | 7 | ```make publish``` 8 | 9 | # Run the container 10 | 11 | ``run.sh``` 12 | 13 | # Run within Docker Compose 14 | 15 | ``` 16 | zkui: 17 | image: zkui 18 | ports: 19 | - "9090:9090" 20 | ``` -------------------------------------------------------------------------------- /jim-framework-rpc-api/src/main/java/com/jim/framework/rpc/api/service/CommentService.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.api.service; 2 | 3 | import com.jim.framework.rpc.api.model.Comment; 4 | 5 | /** 6 | * Created by jiang on 2017/5/9. 7 | */ 8 | public interface CommentService { 9 | Comment getCommentByProductId(Long productId); 10 | } 11 | -------------------------------------------------------------------------------- /jim-framework-rpc/src/main/java/com/jim/framework/rpc/registry/RegistryService.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.registry; 2 | 3 | import com.jim.framework.rpc.common.RpcURL; 4 | 5 | /** 6 | * Created by jiang on 2017/5/19. 7 | */ 8 | public interface RegistryService { 9 | void register(RpcURL url); 10 | void unregister(RpcURL url); 11 | } 12 | -------------------------------------------------------------------------------- /jim-framework-rpc-consumer/src/main/java/com/jim/framework/rpc/consumer/service/ProductCommentMockService.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.consumer.service; 2 | 3 | import com.jim.framework.rpc.api.model.Product; 4 | 5 | /** 6 | * Created by jiang on 2017/5/10. 7 | */ 8 | public interface ProductCommentMockService { 9 | Product getById(Long productId); 10 | } 11 | -------------------------------------------------------------------------------- /jim-framework-rpc-consumer/src/main/java/com/jim/framework/rpc/consumer/service/ProductCommentService.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.consumer.service; 2 | 3 | import com.jim.framework.rpc.api.model.Product; 4 | 5 | /** 6 | * Created by jiang on 2017/5/10. 7 | */ 8 | public interface ProductCommentService { 9 | Product getById(Long productId); 10 | } 11 | -------------------------------------------------------------------------------- /jim-framework-rpc/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ -------------------------------------------------------------------------------- /jim-framework-rpc/src/main/java/com/jim/framework/rpc/filter/AccessLimitService.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.filter; 2 | 3 | import com.jim.framework.rpc.common.RpcInvocation; 4 | 5 | /** 6 | * 限流接口 7 | * 调用端自定义实现 8 | * Created by jiangmin on 2018/5/19. 9 | */ 10 | public interface AccessLimitService { 11 | 12 | void acquire(RpcInvocation invocation); 13 | } 14 | -------------------------------------------------------------------------------- /jim-framework-web/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ -------------------------------------------------------------------------------- /jim-framework-web/src/main/java/com/jim/framework/web/service/BaseService.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.web.service; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | /** 7 | * Created by jiang on 2016/12/22. 8 | */ 9 | public class BaseService { 10 | protected Logger logger = LoggerFactory.getLogger(getClass().getName()); 11 | } 12 | -------------------------------------------------------------------------------- /jim-framework-web/src/main/java/com/jim/framework/web/service/ProductService.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.web.service; 2 | 3 | import com.jim.framework.web.dao.generated.entity.Product; 4 | 5 | /** 6 | * Created by jiang on 2016/12/22. 7 | */ 8 | public interface ProductService { 9 | Product getById(Long id); 10 | void save(Product product); 11 | } 12 | -------------------------------------------------------------------------------- /jim-framework-activemq/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ -------------------------------------------------------------------------------- /jim-framework-cache/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ -------------------------------------------------------------------------------- /jim-framework-lock/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ -------------------------------------------------------------------------------- /jim-framework-rpc-api/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ -------------------------------------------------------------------------------- /jim-framework-web/src/main/resources/generator/generator.properties: -------------------------------------------------------------------------------- 1 | # MBG begin 2 | mapper.plugin=tk.mybatis.mapper.generator.MapperPlugin 3 | mapper.Mapper=tk.mybatis.mapper.common.Mapper 4 | # MBG end 5 | 6 | dbcp.driver=org.postgresql.Driver 7 | 8 | dbcp.username=postgres 9 | dbcp.password=postgres 10 | dbcp.url=jdbc:postgresql://192.168.21.128:5432/jim 11 | 12 | 13 | -------------------------------------------------------------------------------- /jim-framework-cloud-config/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ -------------------------------------------------------------------------------- /jim-framework-cloud-provider/src/main/java/com/jim/framework/cloud/provider/service/ProductService.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.cloud.provider.service; 2 | 3 | import com.jim.framework.cloud.provider.model.Product; 4 | 5 | /** 6 | * Created by jiang on 2017/3/28. 7 | */ 8 | public interface ProductService { 9 | 10 | Product getProductById(Long id); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /jim-framework-cloud-zipkin/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ -------------------------------------------------------------------------------- /jim-framework-configcenter/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ -------------------------------------------------------------------------------- /jim-framework-dubbo-core/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ -------------------------------------------------------------------------------- /jim-framework-rpc-consumer/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ -------------------------------------------------------------------------------- /jim-framework-rpc-provider/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ -------------------------------------------------------------------------------- /jim-framework-cloud-consumer/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ -------------------------------------------------------------------------------- /jim-framework-cloud-provider/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ -------------------------------------------------------------------------------- /jim-framework-cloud-registry/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ -------------------------------------------------------------------------------- /jim-framework-dubbo-consumer/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ -------------------------------------------------------------------------------- /jim-framework-dubbo-provider/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ -------------------------------------------------------------------------------- /jim-framework-dubbo-provider2/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ -------------------------------------------------------------------------------- /jim-framework-rpc/src/main/java/com/jim/framework/rpc/RpcApplication.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | 5 | //@SpringBootApplication 6 | public class RpcApplication { 7 | 8 | public static void main(String[] args) throws InterruptedException { 9 | 10 | SpringApplication.run(RpcApplication.class, args); 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /jim-framework-rpc/src/main/java/com/jim/framework/rpc/registry/DiscoveryService.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.registry; 2 | 3 | import com.jim.framework.rpc.common.RpcURL; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Created by jiang on 2017/5/19. 9 | */ 10 | public interface DiscoveryService { 11 | 12 | List getUrls(String registryHost, int registryPort); 13 | } 14 | -------------------------------------------------------------------------------- /jim-framework-cache/src/main/java/com/jim/framework/cache/redis/InvocationRegistry.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.cache.redis; 2 | 3 | import java.lang.reflect.Method; 4 | import java.util.Set; 5 | 6 | /** 7 | * 缓存方法注册接口 8 | */ 9 | public interface InvocationRegistry { 10 | 11 | void registerInvocation(Object invokedBean, Method invokedMethod, Object[] invocationArguments, Set cacheNames); 12 | 13 | } -------------------------------------------------------------------------------- /jim-framework-dubbo-core/src/main/java/com/jim/framework/dubbo/core/service/ProductService.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.dubbo.core.service; 2 | 3 | import com.jim.framework.dubbo.core.model.Product; 4 | 5 | /* 6 | * 产品接口 7 | * 作者:姜敏 8 | * 版本:V1.0 9 | * 创建日期:2017/4/13 10 | * 修改日期:2017/4/13 11 | */ 12 | public interface ProductService { 13 | 14 | Product getByid(Long id); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /jim-framework-rpc-api/src/main/java/com/jim/framework/rpc/api/RpcApiApplication.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.api; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | 5 | //@SpringBootApplication 6 | public class RpcApiApplication { 7 | 8 | public static void main(String[] args) throws InterruptedException { 9 | 10 | SpringApplication.run(RpcApiApplication.class, args); 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /jim-framework-cache/src/main/java/com/jim/framework/cache/Application.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.cache; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /jim-framework-dubbo-provider2/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=7777 2 | spring.application.name=comment-dubbo-provider 3 | 4 | dubbo.trace.enabled=true 5 | dubbo.trace.connectTimeout=1000 6 | dubbo.trace.readTimeout=1000 7 | #dubbo.trace.zipkinUrl=http://localhost:9411 8 | dubbo.trace.zipkinUrl=127.0.0.1:9092 9 | dubbo.trace.zipkinKafkaTopic=zipkin 10 | dubbo.trace.zipkinSendType=kafka 11 | -------------------------------------------------------------------------------- /jim-framework-dubbo-provider/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=9999 2 | spring.application.name=product-dubbo-provider 3 | 4 | dubbo.trace.enabled=true 5 | dubbo.trace.connectTimeout=1000 6 | dubbo.trace.readTimeout=1000 7 | #dubbo.trace.zipkinUrl=http://localhost:9411 8 | dubbo.trace.zipkinUrl=127.0.0.1:9092 9 | dubbo.trace.zipkinKafkaTopic=zipkin 10 | dubbo.trace.zipkinSendType=kafka 11 | 12 | -------------------------------------------------------------------------------- /jim-framework-rpc/src/main/java/com/jim/framework/rpc/config/ConstantConfig.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.config; 2 | 3 | /** 4 | * Created by jiang on 2017/5/14. 5 | */ 6 | public class ConstantConfig { 7 | 8 | public static final String PROVIDER="provider"; 9 | public static final String CONSUMER="consumer"; 10 | public static final String DEFAULT_THREAD_POOL_NAME="fixedRpcThreadPool"; 11 | } 12 | -------------------------------------------------------------------------------- /jim-framework-dubbo-core/src/main/java/com/jim/framework/dubbo/core/Application.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.dubbo.core; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /jim-framework-cloud-provider/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | registry.server.port=1111 2 | server.port=2222 3 | eureka.instance.hostname=localhost 4 | 5 | spring.application.name=jim-cloud-provider-server 6 | 7 | spring.zipkin.base-url=http://localhost:9411 8 | spring.zipkin.enabled=true 9 | spring.zipkin.flush-interval=1 10 | 11 | eureka.client.serviceUrl.defaultZone=http://${eureka.instance.hostname}:${registry.server.port}/eureka/ -------------------------------------------------------------------------------- /jim-framework-dubbo-consumer/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8888 2 | dubbo.provider.port=9999 3 | spring.application.name=product-dubbo-consumer 4 | 5 | dubbo.trace.enabled=true 6 | dubbo.trace.connectTimeout=1000 7 | dubbo.trace.readTimeout=1000 8 | #dubbo.trace.zipkinUrl=http://localhost:9411 9 | dubbo.trace.zipkinUrl=127.0.0.1:9092 10 | dubbo.trace.zipkinKafkaTopic=zipkin 11 | dubbo.trace.zipkinSendType=kafka 12 | -------------------------------------------------------------------------------- /jim-framework-rpc/src/main/java/com/jim/framework/rpc/exception/TimeoutRpcException.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.exception; 2 | 3 | /** 4 | * Created by jiang on 2017/5/17. 5 | */ 6 | public class TimeoutRpcException extends RpcException { 7 | 8 | public TimeoutRpcException(){ 9 | super("time out exception"); 10 | } 11 | 12 | public TimeoutRpcException(String message){ 13 | super(message); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /jim-framework-rpc/src/main/java/com/jim/framework/rpc/keepalive/ClientHeartbeatHandler.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.keepalive; 2 | 3 | import io.netty.channel.ChannelHandlerContext; 4 | 5 | /** 6 | * Created by jim on 2017/9/27. 7 | */ 8 | public class ClientHeartbeatHandler extends AbstractHeartbeatHandler { 9 | 10 | @Override 11 | protected void handleAllIdle(ChannelHandlerContext ctx) { 12 | this.sendPing(ctx); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | *.bak 18 | *.html 19 | *.log 20 | *.mdj 21 | *.jar 22 | 23 | ### NetBeans ### 24 | nbproject/private/ 25 | build/ 26 | nbbuild/ 27 | dist/ 28 | nbdist/ 29 | .nb-gradle/ 30 | 31 | ### other 32 | .mvn/ 33 | *.swp 34 | -------------------------------------------------------------------------------- /jim-framework-configcenter/src/main/java/com/jim/framework/configcenter/model/DefaultOptions.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.configcenter.model; 2 | 3 | public class DefaultOptions { 4 | 5 | public final static boolean USE_REMOTE_CONFIG=true; 6 | 7 | public final static int CHECK_ZK_LIVE_INTERVAL_MINUTES=1; 8 | public final static String CONFIG_NAME="config-center.properties"; 9 | public final static String CONFIG_ZK_URLS_KEY="zk"; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /jim-framework-dubbo-core/src/main/java/com/jim/framework/dubbo/core/context/AbstractContext.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.dubbo.core.context; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | /* 7 | * 上下文基类 8 | * 作者:姜敏 9 | * 版本:V1.0 10 | * 创建日期:2017/4/13 11 | * 修改日期:2017/4/13 12 | */ 13 | public abstract class AbstractContext { 14 | 15 | @Getter 16 | @Setter 17 | private String applicationName; 18 | 19 | 20 | } 21 | -------------------------------------------------------------------------------- /jim-framework-dubbo-core/src/main/java/com/jim/framework/dubbo/core/service/CommentService.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.dubbo.core.service; 2 | 3 | import com.jim.framework.dubbo.core.model.Comment; 4 | 5 | import java.util.List; 6 | 7 | /* 8 | * 评论服务 9 | * 作者:姜敏 10 | * 版本:V1.0 11 | * 创建日期:2017/4/14 12 | * 修改日期:2017/4/14 13 | */ 14 | public interface CommentService { 15 | 16 | List getCommentsByProductId(Long productId); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /jim-framework-cache/src/main/java/com/jim/framework/cache/redis/CacheSupport.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.cache.redis; 2 | 3 | /** 4 | * 主动刷新缓存接口 5 | */ 6 | public interface CacheSupport { 7 | 8 | /** 9 | * 刷新容器中所有值 10 | * @param cacheName 11 | */ 12 | void refreshCache(String cacheName); 13 | 14 | /** 15 | * 按容器以及指定键更新缓存 16 | * @param cacheName 17 | * @param cacheKey 18 | */ 19 | void refreshCacheByKey(String cacheName,String cacheKey); 20 | 21 | } -------------------------------------------------------------------------------- /jim-framework-cache/src/test/java/com/jim/framework/cache/ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.cache; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class ApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /jim-framework-configcenter/src/main/java/com/jim/framework/configcenter/ConfigcenterApplication.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.configcenter; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class ConfigcenterApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(ConfigcenterApplication.class, args); 11 | } 12 | } 13 | 14 | -------------------------------------------------------------------------------- /jim-framework-lock/src/main/java/com/jim/framework/annotationlock/AnnotationLockApplication.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.annotationlock; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class AnnotationLockApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(AnnotationLockApplication.class, args); 11 | } 12 | } 13 | 14 | -------------------------------------------------------------------------------- /jim-framework-rpc/src/main/java/test/com/jim/framework/rpc/registry/impl/RegistryServiceConfig.java: -------------------------------------------------------------------------------- 1 | package test.com.jim.framework.rpc.registry.impl; 2 | 3 | import org.springframework.context.annotation.ComponentScan; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | /** 7 | * Created by jiang on 2017/5/19. 8 | */ 9 | @Configuration 10 | @ComponentScan(basePackages = {"com.jim.framework.rpc"}) 11 | public class RegistryServiceConfig { 12 | } 13 | -------------------------------------------------------------------------------- /jim-framework-cloud-config/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | registry.server.port=1111 2 | server.port=8888 3 | eureka.instance.hostname=localhost 4 | spring.application.name=jim-cloud-config-server 5 | 6 | spring.profiles.active=native 7 | spring.cloud.config.server.native.searchLocations=classpath:/config 8 | 9 | eureka.client.serviceUrl.defaultZone=http://${eureka.instance.hostname}:${registry.server.port}/eureka/ 10 | 11 | #spring.cloud.config.uri=http://localhost:8888 -------------------------------------------------------------------------------- /jim-framework-activemq/src/test/java/com/framework/activemq/ActivemqApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.framework.activemq; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class ActivemqApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /jim-framework-dubbo-core/src/main/java/com/jim/framework/dubbo/core/annotation/EnableTraceAutoConfigurationProperties.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.dubbo.core.annotation; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /* 6 | * 日志追踪是否启用的注解 7 | * 作者:姜敏 8 | * 版本:V1.0 9 | * 创建日期:2017/4/13 10 | * 修改日期:2017/4/13 11 | */ 12 | @Target({ElementType.TYPE}) 13 | @Retention(RetentionPolicy.RUNTIME) 14 | @Documented 15 | public @interface EnableTraceAutoConfigurationProperties { 16 | } 17 | -------------------------------------------------------------------------------- /jim-framework-dubbo-core/src/test/java/com/jim/framework/dubbo/core/ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.dubbo.core; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class ApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /jim-framework-rpc/src/main/java/com/jim/framework/rpc/server/RpcService.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.server; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | import java.lang.annotation.ElementType; 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.RetentionPolicy; 8 | import java.lang.annotation.Target; 9 | 10 | @Target({ElementType.TYPE}) 11 | @Retention(RetentionPolicy.RUNTIME) 12 | @Component 13 | public @interface RpcService { 14 | 15 | } 16 | -------------------------------------------------------------------------------- /jim-framework-web/src/main/java/com/jim/framework/web/service/impl/TestDataServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.web.service.impl; 2 | 3 | import com.jim.framework.web.service.TestDataService; 4 | import org.springframework.stereotype.Service; 5 | 6 | /** 7 | * Created by jiang on 2016/12/22. 8 | */ 9 | @Service 10 | public class TestDataServiceImpl implements TestDataService { 11 | @Override 12 | public int get(int i) { 13 | return i; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /jim-framework-cloud-config/src/test/java/com/jim/framework/cloud/config/ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.cloud.config; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class ApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /jim-framework-cloud-zipkin/src/test/java/com/jim/framework/cloud/zipkin/ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.cloud.zipkin; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class ApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /jim-framework-activemq/src/main/java/com/jim/framework/activemq/ActivemqApplication.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.activemq; 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication; 4 | import org.springframework.boot.builder.SpringApplicationBuilder; 5 | 6 | 7 | @SpringBootApplication 8 | public class ActivemqApplication { 9 | 10 | public static void main(String[] args) { 11 | 12 | new SpringApplicationBuilder(ActivemqApplication.class).web(true).run(args); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /jim-framework-cloud-consumer/src/test/java/com/jim/framework/cloud/consumer/ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.cloud.consumer; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class ApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /jim-framework-cloud-provider/src/test/java/com/jim/framework/cloud/provider/ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.cloud.provider; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class ApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /jim-framework-dubbo-consumer/src/test/java/com/jim/framework/dubbo/consumer/ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.dubbo.consumer; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class ApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /jim-framework-dubbo-provider/src/test/java/com/jim/framework/dubbo/provider/ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.dubbo.provider; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class ApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /jim-framework-rpc/src/main/java/com/jim/framework/rpc/exception/RpcException.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.exception; 2 | 3 | /** 4 | * Created by jiang on 2017/5/14. 5 | */ 6 | public class RpcException extends RuntimeException { 7 | public RpcException(String errorMsg){ 8 | super(errorMsg); 9 | } 10 | public RpcException(Exception ex){ 11 | super(ex); 12 | } 13 | public RpcException(){ 14 | super("rpc exception"); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /jim-framework-dubbo-provider2/src/test/java/com/jim/framework/dubbo/provider2/ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.dubbo.provider2; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class ApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /jim-framework-rpc/src/main/java/com/jim/framework/rpc/constants/Constants.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.constants; 2 | 3 | /** 4 | * Created by jim on 2017/9/28. 5 | */ 6 | public class Constants { 7 | 8 | public static final int MESSAGE_TYPE_HEARTBEAT_PING=1; 9 | public static final int MESSAGE_TYPE_HEARTBEAT_PONG=2; 10 | public static final int ALLIDLE_TIME_SECONDS=5; 11 | public static final int READER_TIME_SECONDS=10; 12 | public static final int RECONNECT_TIME_SECONDS=5; 13 | } 14 | -------------------------------------------------------------------------------- /jim-framework-web/src/main/java/com/jim/framework/web/service/StudentService.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.web.service; 2 | 3 | import com.jim.framework.web.model.Student; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Created by jiang on 2016/12/11. 9 | */ 10 | public interface StudentService { 11 | 12 | Student getById(Long id); 13 | 14 | Student save(Student student); 15 | 16 | List search(String name, int page, int size); 17 | 18 | Long getCount(); 19 | } 20 | -------------------------------------------------------------------------------- /jim-framework-rpc-provider/src/main/java/com/jim/framework/rpc/provider/JimRpcProviderApplication.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.provider; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class JimRpcProviderApplication { 8 | 9 | public static void main(String[] args) throws InterruptedException { 10 | SpringApplication.run(JimRpcProviderApplication.class, args); 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /jim-framework-cloud-zipkin/src/main/java/com/jim/framework/cloud/zipkin/ZipkinApplication.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.cloud.zipkin; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import zipkin2.server.internal.EnableZipkinServer; 6 | 7 | @SpringBootApplication 8 | @EnableZipkinServer 9 | public class ZipkinApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(ZipkinApplication.class, args); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /jim-framework-web/src/main/java/com/jim/framework/web/repository/StudentRepository.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.web.repository; 2 | 3 | import com.jim.framework.web.model.Student; 4 | import org.springframework.data.domain.Page; 5 | import org.springframework.data.domain.Pageable; 6 | 7 | /** 8 | * Created by jiang on 2016/12/11. 9 | */ 10 | public interface StudentRepository 11 | //extends ElasticsearchRepository 12 | { 13 | 14 | Page findByName(String name, Pageable pageable); 15 | } 16 | -------------------------------------------------------------------------------- /jim-framework-cloud-registry/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | #server: 2 | # port: 1111 3 | #spring: 4 | ## cloud: 5 | ## zookeeper: 6 | ## connect-string: 192.168.21.128:2181 7 | ## discovery: 8 | ## instance-host: 127.0.0.1 9 | ## instance-port: ${server.port} 10 | # application: 11 | # name: jim-cloud-server 12 | #eureka: 13 | # client: 14 | # register-with-eureka: false 15 | # fetch-registry: false 16 | # service-url: 17 | # default-zone:http://localhost:${server.port}/eureka/ 18 | -------------------------------------------------------------------------------- /jim-framework-cloud-registry/src/test/java/com/jim/framework/cloud/registry/JimFrameworkCloudRegistryApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.cloud.registry; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class JimFrameworkCloudRegistryApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /jim-framework-rpc-consumer/src/main/java/com/jim/framework/rpc/consumer/JimRpcConsumerApplication.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.consumer; 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication; 4 | import org.springframework.boot.builder.SpringApplicationBuilder; 5 | 6 | @SpringBootApplication 7 | public class JimRpcConsumerApplication { 8 | 9 | public static void main(String[] args) throws InterruptedException { 10 | 11 | new SpringApplicationBuilder(JimRpcConsumerApplication.class).web(true).run(args); 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /jim-framework-rpc/src/main/java/com/jim/framework/rpc/keepalive/ServerHeartbeatHandler.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.keepalive; 2 | 3 | import io.netty.channel.ChannelHandlerContext; 4 | 5 | /** 6 | * Created by jim on 2017/9/27. 7 | */ 8 | public class ServerHeartbeatHandler extends AbstractHeartbeatHandler { 9 | 10 | @Override 11 | protected void handleReaderIdle(ChannelHandlerContext ctx) { 12 | logger.info("ServerHeartbeatHandler.handleReaderIdle reader timeout ,close channel"); 13 | ctx.close(); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /jim-framework-web/src/main/java/com/jim/framework/web/common/ValueResult.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.web.common; 2 | 3 | import java.io.Serializable; 4 | 5 | public class ValueResult extends Result implements Serializable { 6 | 7 | private static final long serialVersionUID = 1L; 8 | 9 | private ValueType value; 10 | 11 | 12 | public ValueType getValue() { 13 | return value; 14 | } 15 | 16 | public void setValue(ValueType value) { 17 | this.value = value; 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /jim-framework-activemq/src/main/java/com/jim/framework/activemq/model/Product.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.activemq.model; 2 | 3 | import com.google.common.collect.Lists; 4 | 5 | import java.util.List; 6 | import java.util.concurrent.ConcurrentHashMap; 7 | 8 | /** 9 | * Created by jiangmin on 2018/1/5. 10 | */ 11 | public class Product { 12 | 13 | public static final ConcurrentHashMap> transportResult=new ConcurrentHashMap<>(); 14 | 15 | public static final List consumerMessageResult= Lists.newArrayList(); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /jim-framework-rpc/src/main/java/com/jim/framework/rpc/common/RpcInvocation.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.common; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | * Created by jiang on 2017/5/14. 7 | */ 8 | public interface RpcInvocation { 9 | 10 | String getMethodName(); 11 | 12 | String getClassName(); 13 | 14 | String getRequestId(); 15 | 16 | Class[] getParameterTypes(); 17 | 18 | Object[] getParameters(); 19 | 20 | int getMaxExecutesCount(); 21 | 22 | Map getContextParameters(); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /jim-framework-rpc/src/main/java/com/jim/framework/rpc/config/RpcConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.config; 2 | 3 | import com.jim.framework.rpc.utils.ApplicationContextUtils; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | /** 8 | * Created by Administrator on 2017/7/2/002. 9 | */ 10 | @Configuration 11 | public class RpcConfiguration { 12 | @Bean 13 | public ApplicationContextUtils applicationContextUtils(){ 14 | return new ApplicationContextUtils(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /jim-framework-rpc/src/main/java/com/jim/framework/rpc/filter/ActiveFilter.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.filter; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | import java.lang.annotation.ElementType; 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.RetentionPolicy; 8 | import java.lang.annotation.Target; 9 | 10 | @Target({ElementType.TYPE}) 11 | @Retention(RetentionPolicy.RUNTIME) 12 | @Component 13 | public @interface ActiveFilter { 14 | String[] group() default {}; 15 | String[] value() default {}; 16 | int order() default 999999999; 17 | } 18 | -------------------------------------------------------------------------------- /jim-framework-cloud-registry/src/main/java/com/jim/framework/cloud/registry/RegistryApplication.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.cloud.registry; 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication; 4 | import org.springframework.boot.builder.SpringApplicationBuilder; 5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; 6 | 7 | @SpringBootApplication 8 | @EnableEurekaServer 9 | public class RegistryApplication { 10 | 11 | public static void main(String[] args) { 12 | new SpringApplicationBuilder(RegistryApplication.class).web(true).run(args); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /jim-framework-cloud-registry/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=1111 2 | spring.application.name=jim-cloud-registry-server 3 | 4 | #spring.cloud.zookeeper.connect-string=192.168.21.128:2181 5 | #spring.cloud.zookeeper.discovery.instance-host=127.0.0.1 6 | #spring.cloud.zookeeper.discovery.instance-port=${server.port} 7 | #spring.cloud.zookeeper.discovery.enabled=true 8 | eureka.instance.hostname=localhost 9 | eureka.client.register-with-eureka=false 10 | eureka.client.fetch-registry=false 11 | eureka.client.serviceUrl.defaultZone=http://${eureka.instance.hostname}:${server.port}/eureka/ -------------------------------------------------------------------------------- /jim-framework-cloud-consumer/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | registry.server.port=1111 2 | server.port=3333 3 | eureka.instance.hostname=localhost 4 | spring.application.name=jim-cloud-consumer-server 5 | feign.hystrix.enabled=true 6 | 7 | spring.zipkin.base-url=http://localhost:9411 8 | spring.zipkin.enabled=true 9 | spring.zipkin.flush-interval=1 10 | 11 | eureka.client.serviceUrl.defaultZone=http://${eureka.instance.hostname}:${registry.server.port}/eureka/ 12 | 13 | spring.cloud.config.uri=http://localhost:8888 14 | spring.cloud.config.name=jim-cloud-config 15 | spring.cloud.config.profile=test -------------------------------------------------------------------------------- /jim-framework-cloud-consumer/src/main/java/com/jim/framework/cloud/consumer/service/ProductServiceHystrix.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.cloud.consumer.service; 2 | 3 | import org.springframework.stereotype.Component; 4 | import org.springframework.web.bind.annotation.PathVariable; 5 | 6 | /* 7 | * 产品服务hystrix服务 8 | * 作者:姜敏 9 | * 版本:V1.0 10 | * 创建日期:2017/4/1 11 | * 修改日期:2017/4/1 12 | */ 13 | @Component 14 | public class ProductServiceHystrix implements ProductService { 15 | @Override 16 | public String getById(@PathVariable("productId") long productId) { 17 | return "product is null"; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /jim-framework-cloud-zipkin/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=9411 2 | spring.application.name=zipkin-server 3 | 4 | #zipkin.storage.type=elasticsearch 5 | #zipkin.storage.elasticsearch.hosts=http://192.168.2.141:9200 6 | #zipkin.storage.elasticsearch.cluster=zipkin-es 7 | #zipkin.storage.elasticsearch.index=zipkin 8 | #zipkin.storage.elasticsearch.index-shards=3 9 | #zipkin.storage.elasticsearch.index-replicas=1 10 | 11 | zipkin.collector.kafka.bootstrap-servers=127.0.0.1:9092 12 | zipkin.collector.kafka.zookeeper=127.0.0.1:2181 13 | zipkin.collector.kafka.topic=zipkin 14 | 15 | management.metrics.web.server.auto-time-requests=false -------------------------------------------------------------------------------- /jim-framework-rpc/src/main/java/com/jim/framework/rpc/threadpool/RpcThreadPoolFactory.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.threadpool; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Component; 5 | 6 | import java.util.Map; 7 | 8 | /** 9 | * Created by Administrator on 2017/7/2/002. 10 | */ 11 | @Component 12 | public class RpcThreadPoolFactory { 13 | 14 | @Autowired 15 | private Map rpcThreadPoolMap; 16 | 17 | public RpcThreadPool getThreadPool(String threadPoolName){ 18 | return this.rpcThreadPoolMap.get(threadPoolName); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /jim-framework-dubbo-core/src/main/java/com/jim/framework/dubbo/core/context/HttpZipkinCollectorConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.dubbo.core.context; 2 | 3 | import zipkin2.reporter.Sender; 4 | import zipkin2.reporter.okhttp3.OkHttpSender; 5 | 6 | public class HttpZipkinCollectorConfiguration extends AbstractZipkinCollectorConfiguration { 7 | 8 | public HttpZipkinCollectorConfiguration(String serviceName,String zipkinUrl) { 9 | super(serviceName,zipkinUrl,null); 10 | } 11 | 12 | @Override 13 | public Sender getSender() { 14 | return OkHttpSender.create(super.getZipkinUrl()+"/api/v2/spans"); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /jim-framework-web/src/main/java/com/jim/framework/web/WebApplication.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.web; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.annotation.ComponentScan; 6 | 7 | @SpringBootApplication 8 | @ComponentScan(basePackages = {"com.jim"}) 9 | //@EnableElasticsearchRepositories(basePackages = "com.jim.repository") 10 | public class WebApplication { 11 | 12 | public static void main(String[] args) { 13 | System.setProperty("env","test"); 14 | SpringApplication.run(WebApplication.class, args); 15 | } 16 | } 17 | 18 | -------------------------------------------------------------------------------- /jim-framework-configcenter/src/main/java/com/jim/framework/configcenter/service/ConfigCenterService.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.configcenter.service; 2 | 3 | import com.jim.framework.configcenter.event.DataChangeEvent; 4 | 5 | import java.util.Map; 6 | 7 | public interface ConfigCenterService { 8 | public Map getConfig(); 9 | public String get(String key); 10 | public Long getLongValue(String key); 11 | public Integer getIntegerValue(String key); 12 | public Double getDoubleValue(String key); 13 | public Boolean getBooleanValue(String key); 14 | public void notify(DataChangeEvent event); 15 | public void colse(); 16 | } 17 | -------------------------------------------------------------------------------- /jim-framework-rpc-api/src/main/java/com/jim/framework/rpc/api/model/Product.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.api.model; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Created by jiang on 2017/5/10. 7 | */ 8 | public class Product implements Serializable { 9 | 10 | private Long id; 11 | private String name; 12 | 13 | public Long getId() { 14 | return id; 15 | } 16 | 17 | public void setId(Long id) { 18 | this.id = id; 19 | } 20 | 21 | public String getName() { 22 | return name; 23 | } 24 | 25 | public void setName(String name) { 26 | this.name = name; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /jim-framework-rpc/src/main/java/com/jim/framework/rpc/protocol/RpcMessageHeader.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.protocol; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Created by jim on 2017/9/24. 7 | */ 8 | public class RpcMessageHeader implements Serializable { 9 | private int length; 10 | 11 | private int type; 12 | 13 | public int getType() { 14 | return type; 15 | } 16 | 17 | public void setType(int type) { 18 | this.type = type; 19 | } 20 | 21 | public int getLength() { 22 | return length; 23 | } 24 | 25 | public void setLength(int length) { 26 | this.length = length; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /jim-framework-web/src/main/resources/mapper/ProductMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /jim-framework-cloud-provider/src/main/java/com/jim/framework/cloud/provider/model/Product.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.cloud.provider.model; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Created by jiang on 2017/3/28. 7 | */ 8 | public class Product implements Serializable { 9 | 10 | private Long id; 11 | 12 | private String name; 13 | 14 | public Long getId() { 15 | return id; 16 | } 17 | 18 | public void setId(Long id) { 19 | this.id = id; 20 | } 21 | 22 | public String getName() { 23 | return name; 24 | } 25 | 26 | public void setName(String name) { 27 | this.name = name; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /jim-framework-rpc/src/main/java/com/jim/framework/rpc/utils/ApplicationContextUtils.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.utils; 2 | 3 | import org.springframework.beans.BeansException; 4 | import org.springframework.context.ApplicationContext; 5 | import org.springframework.context.ApplicationContextAware; 6 | 7 | public class ApplicationContextUtils implements ApplicationContextAware { 8 | 9 | private static ApplicationContext ctx; 10 | 11 | @Override 12 | synchronized public void setApplicationContext(ApplicationContext appContext) 13 | throws BeansException { 14 | ctx = appContext; 15 | 16 | } 17 | 18 | public static ApplicationContext getApplicationContext() { 19 | return ctx; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /jim-framework-cache/src/main/java/com/jim/framework/cache/helper/ApplicationContextHelper.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.cache.helper; 2 | 3 | import org.springframework.beans.BeansException; 4 | import org.springframework.context.ApplicationContext; 5 | import org.springframework.context.ApplicationContextAware; 6 | 7 | public class ApplicationContextHelper implements ApplicationContextAware { 8 | 9 | private static ApplicationContext ctx; 10 | 11 | @Override 12 | synchronized public void setApplicationContext(ApplicationContext appContext) 13 | throws BeansException { 14 | ctx = appContext; 15 | 16 | } 17 | 18 | public static ApplicationContext getApplicationContext() { 19 | return ctx; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /jim-framework-web/src/main/java/com/jim/framework/web/common/Result.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.web.common; 2 | 3 | import java.io.Serializable; 4 | 5 | public class Result implements Serializable { 6 | 7 | private static final long serialVersionUID = 1L; 8 | 9 | private boolean result; 10 | 11 | private ErrorInfo error; 12 | 13 | public ErrorInfo getError() { 14 | return error; 15 | } 16 | 17 | public void setError(ErrorInfo error) { 18 | this.error = error; 19 | } 20 | 21 | public boolean getResult() { 22 | return result; 23 | } 24 | 25 | public void setResult(boolean result) { 26 | this.result = result; 27 | } 28 | 29 | } 30 | 31 | -------------------------------------------------------------------------------- /jim-framework-cloud-config/src/main/java/com/jim/framework/cloud/config/ConfigApplication.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.cloud.config; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | import org.springframework.cloud.config.server.EnableConfigServer; 7 | import org.springframework.context.annotation.ComponentScan; 8 | 9 | @SpringBootApplication 10 | @EnableDiscoveryClient 11 | @EnableConfigServer 12 | @ComponentScan("com.jim") 13 | public class ConfigApplication { 14 | 15 | public static void main(String[] args) { 16 | SpringApplication.run(ConfigApplication.class, args); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /jim-framework-activemq/src/main/java/com/jim/framework/activemq/producer/ProductProducer.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.activemq.producer; 2 | 3 | import com.jim.framework.activemq.config.Constans; 4 | import com.jim.framework.activemq.config.QueueJmsTemplateContainer; 5 | import org.springframework.jms.core.JmsTemplate; 6 | import org.springframework.stereotype.Service; 7 | 8 | /** 9 | * Created by jiangmin on 2018/1/1. 10 | */ 11 | @Service 12 | public class ProductProducer implements ProductSendMessage { 13 | 14 | @Override 15 | public void sendMessage(Object message) { 16 | 17 | JmsTemplate jmsTemplate= QueueJmsTemplateContainer.getJmsTemplateByQueue(Constans.QUEUE_NAME); 18 | jmsTemplate.convertAndSend(Constans.QUEUE_NAME,message); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /jim-framework-rpc-consumer/src/main/java/com/jim/framework/rpc/consumer/service/impl/ProductCommentMockServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.consumer.service.impl; 2 | 3 | import com.jim.framework.rpc.api.model.Product; 4 | import com.jim.framework.rpc.consumer.service.ProductCommentMockService; 5 | import org.springframework.stereotype.Service; 6 | 7 | /** 8 | * Created by jiangmin on 2017/12/2. 9 | */ 10 | @Service 11 | public class ProductCommentMockServiceImpl implements ProductCommentMockService { 12 | @Override 13 | public Product getById(Long productId) { 14 | 15 | Product mockProduct=new Product(); 16 | mockProduct.setId(0L); 17 | mockProduct.setName("mock product name"); 18 | 19 | return mockProduct; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /jim-framework-activemq/src/main/java/com/jim/framework/activemq/consumer/ProductConsumerC.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.activemq.consumer; 2 | 3 | import com.jim.framework.activemq.config.ConsumerConfig; 4 | import com.jim.framework.activemq.model.Product; 5 | import org.springframework.stereotype.Service; 6 | 7 | /** 8 | * Created by jiangmin on 2018/1/11. 9 | */ 10 | @Service 11 | public class ProductConsumerC extends AbstractConsumer { 12 | 13 | 14 | public ProductConsumerC(ConsumerConfig consumerConfig) { 15 | super(consumerConfig); 16 | } 17 | 18 | @Override 19 | public void execute(Object message) throws Exception { 20 | Product.consumerMessageResult.add(message+""); 21 | System.out.println("Consumer,productId:" + message); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /jim-framework-rpc/src/main/java/com/jim/framework/rpc/client/RpcReference.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.client; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | import java.lang.annotation.ElementType; 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.RetentionPolicy; 8 | import java.lang.annotation.Target; 9 | 10 | @Target({ElementType.TYPE,ElementType.FIELD}) 11 | @Retention(RetentionPolicy.RUNTIME) 12 | @Component 13 | public @interface RpcReference { 14 | boolean isSync() default true; 15 | 16 | /** 17 | * 客户端最大并发数 18 | * @return 19 | */ 20 | int maxExecutesCount() default 10; 21 | 22 | /** 23 | * 服务降级的伪装者类对象 24 | * @return 25 | */ 26 | Class fallbackServiceClazz() default Object.class; 27 | } 28 | -------------------------------------------------------------------------------- /jim-framework-rpc/src/main/java/com/jim/framework/rpc/protocol/RpcMessage.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.protocol; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Created by jim on 2017/9/24. 7 | */ 8 | public class RpcMessage implements Serializable { 9 | 10 | private RpcMessageHeader messageHeader; 11 | 12 | private Object messageBody; 13 | 14 | public RpcMessageHeader getMessageHeader() { 15 | return messageHeader; 16 | } 17 | 18 | public void setMessageHeader(RpcMessageHeader messageHeader) { 19 | this.messageHeader = messageHeader; 20 | } 21 | 22 | public Object getMessageBody() { 23 | return messageBody; 24 | } 25 | 26 | public void setMessageBody(Object messageBody) { 27 | this.messageBody = messageBody; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /jim-framework-lock/src/main/java/com/jim/framework/annotationlock/annotation/RequestLockable.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.annotationlock.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | import java.util.concurrent.TimeUnit; 8 | 9 | /** 10 | * 基于注解的锁 11 | * key支持SPEL表达式 12 | * Created by jiang on 2017/1/19. 13 | */ 14 | @Retention(RetentionPolicy.RUNTIME) 15 | @Target(ElementType.METHOD) 16 | public @interface RequestLockable { 17 | 18 | String[] key() default ""; 19 | 20 | long maximumWaiteTime() default 2000; 21 | 22 | long expirationTime() default 1000; 23 | 24 | TimeUnit timeUnit() default TimeUnit.MILLISECONDS; 25 | } 26 | -------------------------------------------------------------------------------- /jim-framework-cloud-consumer/src/main/java/com/jim/framework/cloud/consumer/service/ProductService.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.cloud.consumer.service; 2 | 3 | import org.springframework.cloud.netflix.feign.FeignClient; 4 | import org.springframework.web.bind.annotation.PathVariable; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | import org.springframework.web.bind.annotation.RequestMethod; 7 | 8 | /* 9 | * 产品服务 10 | * 作者:姜敏 11 | * 版本:V1.0 12 | * 创建日期:2017/4/1 13 | * 修改日期:2017/4/1 14 | */ 15 | @FeignClient(value = "JIM-CLOUD-PROVIDER-SERVER",fallback = ProductServiceHystrix.class) 16 | public interface ProductService { 17 | @RequestMapping(value = "/product/{productId}",method = RequestMethod.GET) 18 | String getById(@PathVariable("productId") final long productId); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /jim-framework-dubbo-core/src/main/java/com/jim/framework/dubbo/core/utils/SpringContextUtils.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.dubbo.core.utils; 2 | 3 | import org.springframework.beans.BeansException; 4 | import org.springframework.context.ApplicationContext; 5 | import org.springframework.context.ApplicationContextAware; 6 | import org.springframework.stereotype.Component; 7 | 8 | @Component 9 | public class SpringContextUtils implements ApplicationContextAware { 10 | 11 | private static ApplicationContext applicationContext = null; 12 | 13 | 14 | public void setApplicationContext(ApplicationContext context) throws BeansException { 15 | applicationContext = context; 16 | } 17 | 18 | public static ApplicationContext getApplicationContext() { 19 | return applicationContext; 20 | } 21 | 22 | 23 | } 24 | -------------------------------------------------------------------------------- /jim-framework-dubbo-consumer/src/main/java/com/jim/framework/dubbo/consumer/DubboConsumerApplication.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.dubbo.consumer; 2 | 3 | import com.jim.framework.dubbo.core.annotation.EnableTraceAutoConfigurationProperties; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.context.annotation.ComponentScan; 7 | import org.springframework.context.annotation.ImportResource; 8 | 9 | @SpringBootApplication 10 | @EnableTraceAutoConfigurationProperties 11 | @ImportResource("classpath:applicationContext-dubbo-consumer.xml") 12 | @ComponentScan("com.jim") 13 | public class DubboConsumerApplication { 14 | 15 | public static void main(String[] args) { 16 | SpringApplication.run(DubboConsumerApplication.class, args); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /jim-framework-rpc/src/main/java/com/jim/framework/rpc/loadbalance/RoundRobinLoadbalanceService.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.loadbalance; 2 | 3 | import java.util.concurrent.atomic.AtomicInteger; 4 | 5 | /** 6 | * Created by jiang on 2017/5/22. 7 | */ 8 | public class RoundRobinLoadbalanceService implements LoadbalanceService { 9 | 10 | private AtomicInteger roundRobin = new AtomicInteger(0); 11 | private static final int MAX_VALUE=1000; 12 | private static final int MIN_VALUE=1; 13 | 14 | private AtomicInteger getRoundRobinValue(){ 15 | if(this.roundRobin.getAndAdd(1)>MAX_VALUE){ 16 | this.roundRobin.set(MIN_VALUE); 17 | } 18 | return this.roundRobin; 19 | } 20 | 21 | @Override 22 | public int index(int size) { 23 | return (this.getRoundRobinValue().get() + size) % size; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /jim-framework-web/src/main/java/com/jim/framework/web/utils/FastjsonSerialize.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.web.utils; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import org.apache.commons.lang3.StringUtils; 5 | 6 | /** 7 | * Created by jiang on 2017/3/29. 8 | */ 9 | public class FastjsonSerialize { 10 | 11 | private final static String DEFAULT_STRING=""; 12 | 13 | public static String serialize(T obj) { 14 | if (obj == null) { 15 | throw new RuntimeException("FastjsonSerialize.serialize: obj is null"); 16 | } 17 | return JSON.toJSONString(obj); 18 | } 19 | 20 | public static T deserialize(String jsonString,Class targetClass) { 21 | 22 | if(StringUtils.isBlank(jsonString)){ 23 | return null; 24 | } 25 | return JSON.parseObject(jsonString, targetClass); 26 | 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /jim-framework-cloud-provider/src/main/java/com/jim/framework/cloud/provider/ProviderApplication.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.cloud.provider; 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication; 4 | import org.springframework.boot.builder.SpringApplicationBuilder; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | import org.springframework.cloud.sleuth.sampler.AlwaysSampler; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.ComponentScan; 9 | 10 | @SpringBootApplication 11 | @EnableDiscoveryClient 12 | @ComponentScan("com.jim") 13 | public class ProviderApplication { 14 | 15 | public static void main(String[] args) { 16 | new SpringApplicationBuilder(ProviderApplication.class).web(true).run(args); 17 | } 18 | 19 | @Bean 20 | public AlwaysSampler defaultSampler() { 21 | return new AlwaysSampler(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /jim-framework-rpc-api/src/main/java/com/jim/framework/rpc/api/model/Comment.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.api.model; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Created by jiang on 2017/5/9. 7 | */ 8 | public class Comment implements Serializable { 9 | 10 | private Long productId; 11 | private Long id; 12 | private String content; 13 | 14 | public Long getProductId() { 15 | return productId; 16 | } 17 | 18 | public void setProductId(Long productId) { 19 | this.productId = productId; 20 | } 21 | 22 | public Long getId() { 23 | return id; 24 | } 25 | 26 | public void setId(Long id) { 27 | this.id = id; 28 | } 29 | 30 | public String getContent() { 31 | return content; 32 | } 33 | 34 | public void setContent(String content) { 35 | this.content = content; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /jim-framework-dubbo-core/src/main/java/com/jim/framework/dubbo/core/context/KafkaZipkinCollectorConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.dubbo.core.context; 2 | 3 | import zipkin2.codec.Encoding; 4 | import zipkin2.reporter.Sender; 5 | import zipkin2.reporter.kafka11.KafkaSender; 6 | 7 | /** 8 | * Created by jiangmin on 2018/10/7. 9 | */ 10 | public class KafkaZipkinCollectorConfiguration extends AbstractZipkinCollectorConfiguration { 11 | 12 | public KafkaZipkinCollectorConfiguration(String serviceName,String zipkinUrl,String topic) { 13 | super(serviceName,zipkinUrl,topic); 14 | } 15 | 16 | @Override 17 | public Sender getSender() { 18 | 19 | return KafkaSender 20 | .newBuilder() 21 | .bootstrapServers(super.getZipkinUrl()) 22 | .topic(super.getTopic()) 23 | .encoding(Encoding.JSON) 24 | .build(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /jim-framework-web/src/main/java/com/jim/framework/web/interceptor/PermissionInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.web.interceptor; 2 | 3 | import org.springframework.util.StringUtils; 4 | import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; 5 | 6 | import javax.security.sasl.AuthenticationException; 7 | import javax.servlet.http.HttpServletRequest; 8 | import javax.servlet.http.HttpServletResponse; 9 | 10 | /** 11 | * Created by jiang on 2016/12/23. 12 | */ 13 | public class PermissionInterceptor extends HandlerInterceptorAdapter { 14 | @Override 15 | public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o) throws Exception { 16 | if(StringUtils.isEmpty(httpServletRequest.getHeader("token"))){ 17 | throw new AuthenticationException("未授权用户不允许操作"); 18 | } 19 | return true; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /jim-framework-cloud-provider/src/main/java/com/jim/framework/cloud/provider/service/impl/ProductServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.cloud.provider.service.impl; 2 | 3 | import com.jim.framework.cloud.provider.model.Product; 4 | import com.jim.framework.cloud.provider.service.ProductService; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | * Created by jiang on 2017/3/28. 11 | */ 12 | @Service 13 | public class ProductServiceImpl implements ProductService { 14 | 15 | private final static Logger logger = LoggerFactory.getLogger(ProductServiceImpl.class); 16 | 17 | @Override 18 | public Product getProductById(Long id) { 19 | logger.info("getProductById is called"); 20 | Product product=new Product(); 21 | product.setId(id); 22 | product.setName("apple"+id); 23 | return product; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /jim-framework-rpc/src/main/java/com/jim/framework/rpc/common/RpcResponse.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.common; 2 | 3 | /** 4 | 响应对象 5 | * Created by jiang on 2017/5/10. 6 | */ 7 | public class RpcResponse { 8 | 9 | private String requestId; 10 | private Throwable error; 11 | private Object result; 12 | 13 | public boolean isError() { 14 | return error != null; 15 | } 16 | 17 | public String getRequestId() { 18 | return requestId; 19 | } 20 | 21 | public void setRequestId(String requestId) { 22 | this.requestId = requestId; 23 | } 24 | 25 | public Throwable getError() { 26 | return error; 27 | } 28 | 29 | public void setError(Throwable error) { 30 | this.error = error; 31 | } 32 | 33 | public Object getResult() { 34 | return result; 35 | } 36 | 37 | public void setResult(Object result) { 38 | this.result = result; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /jim-framework-rpc/src/main/java/com/jim/framework/rpc/filter/AccessLogFilter.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.filter; 2 | 3 | import com.jim.framework.rpc.common.RpcFilter; 4 | import com.jim.framework.rpc.common.RpcInvocation; 5 | import com.jim.framework.rpc.common.RpcInvoker; 6 | import com.jim.framework.rpc.config.ConstantConfig; 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | 10 | /** 11 | * Created by jiang on 2017/5/14. 12 | */ 13 | @ActiveFilter(group = {ConstantConfig.PROVIDER,ConstantConfig.CONSUMER}) 14 | public class AccessLogFilter implements RpcFilter { 15 | 16 | private final static Logger logger = LoggerFactory.getLogger(AccessLogFilter.class); 17 | 18 | @Override 19 | public Object invoke(RpcInvoker invoker, RpcInvocation invocation) { 20 | logger.info("before call"); 21 | Object rpcResponse=invoker.invoke(invocation); 22 | logger.info("after call"); 23 | return rpcResponse; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /jim-framework-dubbo-core/src/main/java/com/jim/framework/dubbo/core/model/Product.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.dubbo.core.model; 2 | 3 | import java.io.Serializable; 4 | import java.util.List; 5 | 6 | /* 7 | * 产品对象 8 | * 作者:姜敏 9 | * 版本:V1.0 10 | * 创建日期:2017/4/13 11 | * 修改日期:2017/4/13 12 | */ 13 | public class Product implements Serializable { 14 | private Long id; 15 | 16 | private String name; 17 | 18 | private List comments; 19 | 20 | public List getComments() { 21 | return comments; 22 | } 23 | 24 | public void setComments(List comments) { 25 | this.comments = comments; 26 | } 27 | 28 | public Long getId() { 29 | return id; 30 | } 31 | 32 | public void setId(Long id) { 33 | this.id = id; 34 | } 35 | 36 | public String getName() { 37 | return name; 38 | } 39 | 40 | public void setName(String name) { 41 | this.name = name; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /jim-framework-web/src/main/java/com/jim/framework/web/common/ErrorDef.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.web.common; 2 | 3 | public enum ErrorDef { 4 | 5 | /** 6 | * OK 7 | */ 8 | OK(000000, "OK"), 9 | 10 | /** 11 | * 参数校验错误 12 | */ 13 | InvalidParameters(1001, "参数校验错误"), 14 | 15 | /** 16 | * 服务器错误 17 | */ 18 | ServerError(1003, "服务器错误"); 19 | 20 | private String msg; 21 | private int code; 22 | 23 | private ErrorDef(int code, String msg) { 24 | this.msg = msg; 25 | this.code = code; 26 | } 27 | 28 | public static String getName(int index) { 29 | for (ErrorDef c : ErrorDef.values()) { 30 | if (c.getCode() == index) { 31 | return c.msg; 32 | } 33 | } 34 | return null; 35 | } 36 | 37 | public String getMsg() { 38 | return msg; 39 | } 40 | 41 | public int getCode() { 42 | return code; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /jim-framework-rpc/src/main/java/com/jim/framework/rpc/filter/FutureFilter.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.filter; 2 | 3 | import com.jim.framework.rpc.common.RpcFilter; 4 | import com.jim.framework.rpc.common.RpcInvocation; 5 | import com.jim.framework.rpc.common.RpcInvoker; 6 | import com.jim.framework.rpc.config.ConstantConfig; 7 | import com.jim.framework.rpc.context.RpcContext; 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | 11 | /** 12 | * Created by jiang on 2017/5/14. 13 | */ 14 | @ActiveFilter(group = {ConstantConfig.CONSUMER,ConstantConfig.PROVIDER}) 15 | public class FutureFilter implements RpcFilter { 16 | 17 | private final static Logger logger = LoggerFactory.getLogger(FutureFilter.class); 18 | 19 | @Override 20 | public Object invoke(RpcInvoker invoker, RpcInvocation invocation) { 21 | Object rpcResponse=invoker.invoke(invocation); 22 | logger.info("clear future"); 23 | RpcContext.removeContext(); 24 | return rpcResponse; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /jim-framework-dubbo-provider/src/main/resources/applicationContext-dubbo-consumer.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /jim-framework-cloud-consumer/src/main/java/com/jim/framework/cloud/consumer/ConsumerApplication.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.cloud.consumer; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | import org.springframework.cloud.netflix.feign.EnableFeignClients; 7 | import org.springframework.cloud.netflix.hystrix.EnableHystrix; 8 | import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard; 9 | import org.springframework.context.annotation.ComponentScan; 10 | 11 | @SpringBootApplication 12 | @EnableDiscoveryClient 13 | @EnableFeignClients 14 | @EnableHystrix 15 | @EnableHystrixDashboard 16 | @ComponentScan("com.jim") 17 | public class ConsumerApplication { 18 | 19 | public static void main(String[] args) { 20 | SpringApplication.run(ConsumerApplication.class, args); 21 | } 22 | 23 | // @Bean 24 | // public AlwaysSampler defaultSampler() { 25 | // return new AlwaysSampler(); 26 | // } 27 | } 28 | -------------------------------------------------------------------------------- /jim-framework-dubbo-provider2/src/main/java/com/jim/framework/dubbo/provider2/service/CommentServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.dubbo.provider2.service; 2 | 3 | import com.google.common.collect.Lists; 4 | import com.jim.framework.dubbo.core.model.Comment; 5 | import com.jim.framework.dubbo.core.service.CommentService; 6 | 7 | import java.util.List; 8 | 9 | /* 10 | * 产品评论服务 11 | * 作者:姜敏 12 | * 版本:V1.0 13 | * 创建日期:2017/4/14 14 | * 修改日期:2017/4/14 15 | */ 16 | public class CommentServiceImpl implements CommentService { 17 | 18 | @Override 19 | public List getCommentsByProductId(Long productId) { 20 | List comments= Lists.newArrayList(); 21 | int count=10; 22 | for(int i=0;i jimConnectionsPool; 15 | 16 | public GenericKeyedObjectPool getJimConnectionsPool() { 17 | return jimConnectionsPool; 18 | } 19 | 20 | public JimPooledConnectionFactory() { 21 | } 22 | 23 | public JimPooledConnectionFactory(ActiveMQConnectionFactory activeMQConnectionFactory) { 24 | super(activeMQConnectionFactory); 25 | this.jimConnectionsPool= this.getConnectionsPool(); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /jim-framework-rpc/src/main/java/com/jim/framework/rpc/common/RpcURL.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.common; 2 | 3 | /** 4 | * Created by jiang on 2017/5/19. 5 | */ 6 | public class RpcURL { 7 | 8 | private String host; 9 | private int port; 10 | 11 | private String registryHost; 12 | private int registryPort; 13 | 14 | public String getRegistryHost() { 15 | return registryHost; 16 | } 17 | 18 | public void setRegistryHost(String registryHost) { 19 | this.registryHost = registryHost; 20 | } 21 | 22 | public int getRegistryPort() { 23 | return registryPort; 24 | } 25 | 26 | public void setRegistryPort(int registryPort) { 27 | this.registryPort = registryPort; 28 | } 29 | 30 | public String getHost() { 31 | return host; 32 | } 33 | 34 | public void setHost(String host) { 35 | this.host = host; 36 | } 37 | 38 | public int getPort() { 39 | return port; 40 | } 41 | 42 | public void setPort(int port) { 43 | this.port = port; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /jim-framework-rpc/src/main/java/com/jim/framework/rpc/config/ServiceConfig.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.config; 2 | 3 | /** 4 | 服务端配置 5 | * Created by jiang on 2017/5/10. 6 | */ 7 | public class ServiceConfig { 8 | private String host; 9 | private int port; 10 | 11 | private String registryHost; 12 | private int registryPort; 13 | 14 | public String getRegistryHost() { 15 | return registryHost; 16 | } 17 | 18 | public void setRegistryHost(String registryHost) { 19 | this.registryHost = registryHost; 20 | } 21 | 22 | public int getRegistryPort() { 23 | return registryPort; 24 | } 25 | 26 | public void setRegistryPort(int registryPort) { 27 | this.registryPort = registryPort; 28 | } 29 | 30 | public String getHost() { 31 | return host; 32 | } 33 | 34 | public void setHost(String host) { 35 | this.host = host; 36 | } 37 | 38 | public int getPort() { 39 | return port; 40 | } 41 | 42 | public void setPort(int port) { 43 | this.port = port; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /jim-framework-rpc/src/main/java/com/jim/framework/rpc/registry/AbstractConsulService.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.registry; 2 | 3 | import com.google.common.net.HostAndPort; 4 | import com.orbitz.consul.Consul; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | 8 | /** 9 | * Created by jiang on 2017/5/21. 10 | */ 11 | public class AbstractConsulService { 12 | private static final Logger logger = LoggerFactory.getLogger(AbstractConsulService.class); 13 | 14 | protected final static String CONSUL_NAME="consul_node_jim"; 15 | protected final static String CONSUL_ID="consul_node_id"; 16 | protected final static String CONSUL_TAGS="v3"; 17 | protected final static String CONSUL_HEALTH_INTERVAL="1s"; 18 | 19 | protected Consul buildConsul(String registryHost, int registryPort){ 20 | return Consul.builder() 21 | .withConnectTimeoutMillis(20*1000) 22 | .withReadTimeoutMillis(20*1000) 23 | .withHostAndPort(HostAndPort.fromString(registryHost+":"+registryPort)) 24 | .build() 25 | ; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /jim-framework-rpc/src/main/java/com/jim/framework/rpc/proxy/RpcProxy.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.proxy; 2 | 3 | import com.jim.framework.rpc.client.RpcReference; 4 | import com.jim.framework.rpc.config.ReferenceConfig; 5 | 6 | import java.lang.reflect.InvocationHandler; 7 | import java.lang.reflect.Method; 8 | 9 | public class RpcProxy implements InvocationHandler { 10 | 11 | private Class clazz; 12 | 13 | private boolean isSync=true; 14 | 15 | private ReferenceConfig referenceConfig; 16 | 17 | private RpcReference reference; 18 | 19 | public RpcProxy(Class clazz,ReferenceConfig referenceConfig,RpcReference reference) { 20 | this.clazz = clazz; 21 | this.referenceConfig=referenceConfig; 22 | this.reference=reference; 23 | this.isSync=reference.isSync(); 24 | } 25 | 26 | @Override 27 | public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { 28 | 29 | RpcHystrixCommand rpcHystrixCommand=new RpcHystrixCommand(proxy,method,args,this.reference,this.referenceConfig); 30 | return rpcHystrixCommand.execute(); 31 | 32 | 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /jim-framework-configcenter/src/main/java/com/jim/framework/configcenter/event/DataChangeEvent.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.configcenter.event; 2 | 3 | import java.util.Map; 4 | 5 | public class DataChangeEvent { 6 | 7 | private Map changedData; 8 | 9 | private ChangeType changeType; 10 | 11 | public DataChangeEvent(Map changedData) { 12 | this.changedData=changedData; 13 | this.changeType=ChangeType.MODIFY; 14 | } 15 | 16 | public DataChangeEvent(Map changedData,ChangeType changeType) { 17 | this.changedData=changedData; 18 | this.changeType=changeType; 19 | } 20 | public Map getChangedData() { 21 | return changedData; 22 | } 23 | 24 | public ChangeType getChangeType() { 25 | return changeType; 26 | } 27 | 28 | 29 | public enum ChangeType{ 30 | DELETE(1),CREATE(2),MODIFY(3); 31 | private int type; 32 | public int getType(){ 33 | return this.type; 34 | } 35 | private ChangeType(int type){ 36 | this.type=type; 37 | } 38 | } 39 | } 40 | 41 | -------------------------------------------------------------------------------- /jim-framework-cache/src/main/java/com/jim/framework/cache/redis/CacheItemConfig.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.cache.redis; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Created by jiangmin on 2018/4/7. 7 | */ 8 | public class CacheItemConfig implements Serializable { 9 | 10 | /** 11 | * 缓存容器名称 12 | */ 13 | private String name; 14 | /** 15 | * 缓存失效时间 16 | */ 17 | private long expiryTimeSecond; 18 | /** 19 | * 当缓存存活时间达到此值时,主动刷新缓存 20 | */ 21 | private long preLoadTimeSecond; 22 | 23 | public String getName() { 24 | return name; 25 | } 26 | 27 | public void setName(String name) { 28 | this.name = name; 29 | } 30 | 31 | public long getExpiryTimeSecond() { 32 | return expiryTimeSecond; 33 | } 34 | 35 | public void setExpiryTimeSecond(long expiryTimeSecond) { 36 | this.expiryTimeSecond = expiryTimeSecond; 37 | } 38 | 39 | public long getPreLoadTimeSecond() { 40 | return preLoadTimeSecond; 41 | } 42 | 43 | public void setPreLoadTimeSecond(long preLoadTimeSecond) { 44 | this.preLoadTimeSecond = preLoadTimeSecond; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /jim-framework-dubbo-provider/src/main/java/com/jim/framework/dubbo/provider/service/ProductServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.dubbo.provider.service; 2 | 3 | import com.jim.framework.dubbo.core.model.Comment; 4 | import com.jim.framework.dubbo.core.model.Product; 5 | import com.jim.framework.dubbo.core.service.CommentService; 6 | import com.jim.framework.dubbo.core.service.ProductService; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Service; 9 | 10 | import java.util.List; 11 | 12 | /* 13 | * 产品服务实现 14 | * 作者:姜敏 15 | * 版本:V1.0 16 | * 创建日期:2017/4/13 17 | * 修改日期:2017/4/13 18 | */ 19 | @Service 20 | public class ProductServiceImpl implements ProductService { 21 | 22 | @Autowired 23 | private CommentService commentService; 24 | 25 | @Override 26 | public Product getByid(Long id) { 27 | Product product=new Product(); 28 | product.setId(id); 29 | product.setName(id.toString()); 30 | List comments=this.commentService.getCommentsByProductId(id); 31 | product.setComments(comments); 32 | return product; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /jim-framework-rpc/src/main/java/com/jim/framework/rpc/codec/RpcEncoder.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.codec; 2 | 3 | import com.jim.framework.rpc.exception.RpcException; 4 | import com.jim.framework.rpc.protocol.RpcMessage; 5 | import com.jim.framework.rpc.utils.ProtoStuffSerializeUtil; 6 | import io.netty.buffer.ByteBuf; 7 | import io.netty.channel.ChannelHandlerContext; 8 | import io.netty.handler.codec.MessageToByteEncoder; 9 | 10 | /** 11 | 编码器 12 | * Created by jiang on 2017/5/10. 13 | */ 14 | public class RpcEncoder extends MessageToByteEncoder { 15 | 16 | private Class genericClass; 17 | 18 | public RpcEncoder(Class genericClass) { 19 | this.genericClass = genericClass; 20 | } 21 | 22 | @Override 23 | public void encode(ChannelHandlerContext ctx, RpcMessage in, ByteBuf out) throws Exception { 24 | if(null==in){ 25 | throw new RpcException("RpcMessage is null"); 26 | } 27 | if (genericClass.isInstance(in.getMessageBody())) { 28 | byte[] data = ProtoStuffSerializeUtil.serialize(in); 29 | out.writeInt(data.length); 30 | out.writeBytes(data); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /jim-framework-rpc/src/main/java/com/jim/framework/rpc/filter/ServerContextFilter.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.filter; 2 | 3 | import com.jim.framework.rpc.common.RpcFilter; 4 | import com.jim.framework.rpc.common.RpcInvocation; 5 | import com.jim.framework.rpc.common.RpcInvoker; 6 | import com.jim.framework.rpc.config.ConstantConfig; 7 | import com.jim.framework.rpc.context.RpcContext; 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | 11 | import java.util.Map; 12 | 13 | /** 14 | * Created by jiang on 2017/5/14. 15 | */ 16 | @ActiveFilter(group = {ConstantConfig.PROVIDER},order = -1000) 17 | public class ServerContextFilter implements RpcFilter { 18 | 19 | private final static Logger logger = LoggerFactory.getLogger(ServerContextFilter.class); 20 | 21 | @Override 22 | public Object invoke(RpcInvoker invoker, RpcInvocation invocation) { 23 | Map contextParameters=invocation.getContextParameters(); 24 | RpcContext.getContext().setContextParameters(contextParameters); 25 | Object rpcResponse=invoker.invoke(invocation); 26 | logger.info("ServerContextFilter.invoke end"); 27 | return rpcResponse; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /jim-framework-dubbo-core/src/main/java/com/jim/framework/dubbo/core/model/Comment.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.dubbo.core.model; 2 | 3 | import java.io.Serializable; 4 | 5 | /* 6 | * 评论实体 7 | * 作者:姜敏 8 | * 版本:V1.0 9 | * 创建日期:2017/4/14 10 | * 修改日期:2017/4/14 11 | */ 12 | public class Comment implements Serializable { 13 | private Long id; 14 | 15 | private String content; 16 | 17 | private Long userId; 18 | 19 | private Long productId; 20 | 21 | public Long getId() { 22 | return id; 23 | } 24 | 25 | public void setId(Long id) { 26 | this.id = id; 27 | } 28 | 29 | public String getContent() { 30 | return content; 31 | } 32 | 33 | public void setContent(String content) { 34 | this.content = content; 35 | } 36 | 37 | public Long getUserId() { 38 | return userId; 39 | } 40 | 41 | public void setUserId(Long userId) { 42 | this.userId = userId; 43 | } 44 | 45 | public Long getProductId() { 46 | return productId; 47 | } 48 | 49 | public void setProductId(Long productId) { 50 | this.productId = productId; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /jim-framework-rpc-consumer/src/test/java/com/jim/framework/rpc/consumer/JimConsumerApplication2Test.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.consumer; 2 | 3 | import com.jim.framework.rpc.api.model.Product; 4 | import com.jim.framework.rpc.consumer.config.ConsumerConfiguration; 5 | import com.jim.framework.rpc.consumer.service.ProductCommentService; 6 | import org.junit.Assert; 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.boot.SpringBootConfiguration; 11 | import org.springframework.boot.test.context.SpringBootTest; 12 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 13 | 14 | @RunWith(SpringJUnit4ClassRunner.class) 15 | @SpringBootConfiguration 16 | @SpringBootTest(classes = {ConsumerConfiguration.class}) 17 | public class JimConsumerApplication2Test { 18 | 19 | @Autowired 20 | private ProductCommentService productCommentService; 21 | 22 | @Test 23 | public void testProductService() throws Exception { 24 | Long productId=2L; 25 | Product result=this.productCommentService.getById(productId); 26 | Assert.assertTrue(null!=result&&result.getId().equals(productId)); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /jim-framework-web/src/main/java/com/jim/framework/web/controller/RequestLockController.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.web.controller; 2 | 3 | import com.jim.framework.web.common.ValueResult; 4 | import com.jim.framework.annotationlock.annotation.RequestLockable; 5 | import com.jim.framework.web.service.TestDataService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.web.bind.annotation.PathVariable; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | import org.springframework.web.bind.annotation.RestController; 10 | 11 | import java.net.UnknownHostException; 12 | 13 | /** 14 | * 注解式锁的测试 15 | * Created by jiang on 2016/12/5. 16 | */ 17 | @RestController 18 | @RequestMapping("/lock") 19 | public class RequestLockController extends BaseController { 20 | 21 | @Autowired 22 | private TestDataService testDataService; 23 | 24 | @RequestLockable(key = {"#id"},expirationTime = 3000) 25 | @RequestMapping("/{id}") 26 | public ValueResult getById( @PathVariable final int id) throws UnknownHostException { 27 | return this.returnValueSuccess(Integer.valueOf(this.testDataService.get(id))); 28 | 29 | } 30 | 31 | 32 | } 33 | -------------------------------------------------------------------------------- /jim-framework-rpc-consumer/src/main/java/com/jim/framework/rpc/consumer/controller/ProductController.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.consumer.controller; 2 | 3 | import com.jim.framework.rpc.api.model.Product; 4 | import com.jim.framework.rpc.consumer.service.ProductCommentService; 5 | import com.jim.framework.rpc.context.RpcContext; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.web.bind.annotation.PathVariable; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | import org.springframework.web.bind.annotation.RestController; 10 | 11 | import java.net.UnknownHostException; 12 | 13 | /** 14 | * Created by jiang on 2016/12/5. 15 | */ 16 | @RestController 17 | @RequestMapping("/product") 18 | public class ProductController{ 19 | 20 | @Autowired 21 | private ProductCommentService productCommentService; 22 | 23 | @RequestMapping("/{productId}") 24 | public Product getById(@PathVariable final long productId) throws UnknownHostException { 25 | RpcContext.getContext().addContextParameter("rpc-version","1.0"); 26 | Product result= this.productCommentService.getById(productId); 27 | 28 | return result; 29 | } 30 | 31 | 32 | } 33 | -------------------------------------------------------------------------------- /jim-framework-dubbo-provider2/src/main/resources/applicationContext-dubbo-provider.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /jim-framework-web/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=1234 2 | 3 | logging.level.root=info 4 | 5 | spring.data.elasticsearch.cluster-name=jim-application 6 | spring.data.elasticsearch.cluster-nodes=192.168.21.128:9300 7 | spring.data.elasticsearch.repositories.enabled=true 8 | 9 | spring.dubbo.application.name=provider 10 | spring.dubbo.registry.address=zookeeper://192.168.2.141:2181 11 | spring.dubbo.protocol.name=dubbo 12 | spring.dubbo.protocol.port=20880 13 | spring.dubbo.scan=com.jim.service 14 | 15 | spring.datasource.name=jim 16 | spring.datasource.username=postgres 17 | spring.datasource.password=postgres 18 | spring.datasource.url=jdbc:postgresql://192.168.2.141:5432/jim 19 | spring.datasource.type=org.apache.commons.dbcp.BasicDataSource 20 | spring.datasource.driver-class-name=org.postgresql.Driver 21 | spring.datasource.dbcp.test-while-idle=true 22 | spring.datasource.dbcp.test-on-borrow=false 23 | spring.datasource.dbcp.test-on-return=false 24 | 25 | spring.redis.host=192.168.2.141 26 | spring.redis.password= 27 | spring.redis.port=6379 28 | 29 | 30 | mq.rabbit.host=192.168.21.128 31 | mq.rabbit.port=5672 32 | mq.rabbit.virtualHost=/ 33 | mq.rabbit.username=root 34 | mq.rabbit.password=root 35 | 36 | configcenter.test.foo=aaaa -------------------------------------------------------------------------------- /jim-framework-web/src/main/java/com/jim/framework/web/common/ErrorInfo.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.web.common; 2 | 3 | import java.io.Serializable; 4 | 5 | public class ErrorInfo implements Serializable { 6 | 7 | private static final long serialVersionUID = 1L; 8 | 9 | private int code; 10 | private String msg; 11 | private String hint; 12 | 13 | public ErrorInfo() { 14 | this.code = 0; 15 | this.msg = ""; 16 | } 17 | 18 | public ErrorInfo(ErrorDef errDef) { 19 | this.setCode(errDef.getCode()); 20 | this.setMsg(errDef.getMsg()); 21 | } 22 | 23 | public ErrorInfo(int code, String msg) { 24 | this.setCode(code); 25 | this.setMsg(msg); 26 | } 27 | 28 | public int getCode() { 29 | return code; 30 | } 31 | 32 | public void setCode(int code) { 33 | this.code = code; 34 | } 35 | 36 | public String getMsg() { 37 | return msg; 38 | } 39 | 40 | public void setMsg(String msg) { 41 | this.msg = msg; 42 | } 43 | 44 | public String getHint() { 45 | return hint; 46 | } 47 | 48 | public void setHint(String hint) { 49 | this.hint = hint; 50 | } 51 | 52 | 53 | } 54 | -------------------------------------------------------------------------------- /jim-framework-web/src/main/java/com/jim/framework/web/filter/TimeFilter.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.web.filter; 2 | 3 | import com.google.common.base.Stopwatch; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | 7 | import javax.servlet.*; 8 | import javax.servlet.annotation.WebFilter; 9 | import java.io.IOException; 10 | import java.util.concurrent.TimeUnit; 11 | 12 | /** 13 | * Created by jiang on 2016/12/22. 14 | */ 15 | @WebFilter(filterName="timeFilter",urlPatterns="/*") 16 | public class TimeFilter implements Filter { 17 | 18 | private Logger logger = LoggerFactory.getLogger(getClass().getName()); 19 | 20 | @Override 21 | public void init(FilterConfig filterConfig) throws ServletException { 22 | 23 | } 24 | 25 | @Override 26 | public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { 27 | Stopwatch stopwatch=Stopwatch.createStarted(); 28 | filterChain.doFilter(servletRequest, servletResponse); 29 | stopwatch.stop(); 30 | this.logger.info("time(ns):"+stopwatch.elapsed(TimeUnit.NANOSECONDS)); 31 | } 32 | 33 | @Override 34 | public void destroy() { 35 | 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /jim-framework-cache/src/main/java/com/jim/framework/cache/redis/CachedInvocation.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.cache.redis; 2 | 3 | 4 | import java.lang.reflect.Method; 5 | import java.util.Arrays; 6 | 7 | /** 8 | * 标记了缓存注解的方法类信息 9 | * 用于主动刷新缓存时调用原始方法加载数据 10 | * Created by jiang on 2017/3/6. 11 | */ 12 | public final class CachedInvocation { 13 | 14 | private Object key; 15 | private final Object targetBean; 16 | private final Method targetMethod; 17 | private Object[] arguments; 18 | 19 | public CachedInvocation(Object key, Object targetBean, Method targetMethod, Object[] arguments) { 20 | this.key = key; 21 | this.targetBean = targetBean; 22 | this.targetMethod = targetMethod; 23 | if (arguments != null && arguments.length != 0) { 24 | this.arguments = Arrays.copyOf(arguments, arguments.length); 25 | } 26 | } 27 | 28 | public Object[] getArguments() { 29 | return arguments; 30 | } 31 | 32 | public Object getTargetBean() { 33 | return targetBean; 34 | } 35 | 36 | public Method getTargetMethod() { 37 | return targetMethod; 38 | } 39 | 40 | public Object getKey() { 41 | return key; 42 | } 43 | 44 | } 45 | 46 | -------------------------------------------------------------------------------- /jim-framework-cloud-provider/src/main/java/com/jim/framework/cloud/provider/controller/ProductController.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.cloud.provider.controller; 2 | 3 | import com.jim.framework.cloud.provider.model.Product; 4 | import com.jim.framework.cloud.provider.service.ProductService; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.web.bind.annotation.PathVariable; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | import org.springframework.web.bind.annotation.RestController; 11 | 12 | import java.net.UnknownHostException; 13 | 14 | /** 15 | * Created by jiang on 2017/3/28. 16 | */ 17 | @RestController 18 | @RequestMapping("/product") 19 | public class ProductController { 20 | 21 | private final static Logger logger = LoggerFactory.getLogger(ProductController.class); 22 | 23 | @Autowired 24 | private ProductService productService; 25 | 26 | @RequestMapping("/{productId}") 27 | public Product getById(@PathVariable final long productId) throws UnknownHostException { 28 | logger.info("ProductController.getById"); 29 | return this.productService.getProductById(productId); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /jim-framework-rpc-consumer/src/main/java/com/jim/framework/rpc/consumer/config/ConsumerConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.consumer.config; 2 | 3 | import com.jim.framework.rpc.beans.BeanPostPrcessorReference; 4 | import com.jim.framework.rpc.config.ReferenceConfig; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.ComponentScan; 8 | import org.springframework.context.annotation.Configuration; 9 | 10 | @ComponentScan(basePackages = {"com.jim.framework.rpc.consumer","com.jim.framework.rpc"}) 11 | @Configuration 12 | public class ConsumerConfiguration { 13 | 14 | @Bean 15 | @Autowired 16 | public BeanPostPrcessorReference beanPostPrcessorReference(ReferenceConfig referenceConfig){ 17 | return new BeanPostPrcessorReference(referenceConfig); 18 | } 19 | 20 | @Bean 21 | public ReferenceConfig referenceConfig(){ 22 | ReferenceConfig referenceConfig=new ReferenceConfig(); 23 | referenceConfig.setRegistryHost("127.0.0.1"); 24 | //referenceConfig.setRegistryHost("192.168.237.128"); 25 | referenceConfig.setRegistryPort(8500); 26 | return referenceConfig; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /jim-framework-web/src/main/java/com/jim/framework/web/dao/generated/entity/Product.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.web.dao.generated.entity; 2 | 3 | import javax.persistence.*; 4 | import java.io.Serializable; 5 | 6 | public class Product implements Serializable { 7 | @Id 8 | private Long id; 9 | 10 | private String name; 11 | 12 | @Column(name = "product_image") 13 | private Object productImage; 14 | 15 | /** 16 | * @return id 17 | */ 18 | public Long getId() { 19 | return id; 20 | } 21 | 22 | /** 23 | * @param id 24 | */ 25 | public void setId(Long id) { 26 | this.id = id; 27 | } 28 | 29 | /** 30 | * @return name 31 | */ 32 | public String getName() { 33 | return name; 34 | } 35 | 36 | /** 37 | * @param name 38 | */ 39 | public void setName(String name) { 40 | this.name = name; 41 | } 42 | 43 | /** 44 | * @return product_image 45 | */ 46 | public Object getProductImage() { 47 | return productImage; 48 | } 49 | 50 | /** 51 | * @param productImage 52 | */ 53 | public void setProductImage(Object productImage) { 54 | this.productImage = productImage; 55 | } 56 | } -------------------------------------------------------------------------------- /jim-framework-lock/src/main/java/com/jim/framework/annotationlock/redis/RedissonContext.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.annotationlock.redis; 2 | 3 | import org.redisson.Redisson; 4 | import org.redisson.api.RedissonClient; 5 | import org.redisson.config.Config; 6 | import org.springframework.beans.factory.annotation.Value; 7 | import org.springframework.stereotype.Service; 8 | 9 | import javax.annotation.PostConstruct; 10 | 11 | /** 12 | * Created by jiang on 2017/2/19. 13 | */ 14 | @Service 15 | public class RedissonContext { 16 | @Value("${spring.redis.host}") 17 | private String host; 18 | 19 | @Value("${spring.redis.port}") 20 | private String port; 21 | 22 | @Value("${spring.redis.password}") 23 | private String pass; 24 | 25 | private RedissonClient redisson; 26 | 27 | @PostConstruct 28 | public void init() { 29 | Config config = new Config(); 30 | config.useSingleServer() 31 | .setAddress(this.host + ":" + this.port) 32 | // .setPassword(this.pass) 33 | .setConnectionPoolSize(10) 34 | .setConnectTimeout(10000) 35 | ; 36 | redisson = Redisson.create(config); 37 | } 38 | 39 | public RedissonClient getRedisson() { 40 | return redisson; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /jim-framework-dubbo-provider/src/main/resources/applicationContext-dubbo-provider.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /jim-framework-lock/src/main/java/com/jim/framework/annotationlock/interceptor/RedisRequestLockInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.annotationlock.interceptor; 2 | 3 | import com.jim.framework.annotationlock.redis.RedissonContext; 4 | import org.aspectj.lang.annotation.Aspect; 5 | import org.redisson.api.RLock; 6 | import org.redisson.api.RedissonClient; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Component; 9 | 10 | import java.util.concurrent.TimeUnit; 11 | import java.util.concurrent.locks.Lock; 12 | 13 | /** 14 | * Redis分布式锁实现 15 | * Created by jiang on 2017/1/19. 16 | */ 17 | @Aspect 18 | @Component 19 | public class RedisRequestLockInterceptor extends AbstractRequestLockInterceptor { 20 | 21 | @Autowired 22 | private RedissonContext redissonContext; 23 | 24 | private RedissonClient getRedissonClient(){ 25 | return this.redissonContext.getRedisson(); 26 | } 27 | 28 | @Override 29 | protected Lock getLock(String key) { 30 | return this.getRedissonClient().getLock(key); 31 | } 32 | 33 | @Override 34 | protected boolean tryLock(long waitTime, long leaseTime, TimeUnit unit,Lock lock) throws InterruptedException { 35 | return ((RLock)lock).tryLock(waitTime,leaseTime,unit); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /jim-framework-rpc/src/main/java/com/jim/framework/rpc/registry/ConsulRegistryService.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.registry; 2 | 3 | import com.jim.framework.rpc.common.RpcURL; 4 | import com.orbitz.consul.AgentClient; 5 | import com.orbitz.consul.Consul; 6 | import com.orbitz.consul.model.agent.ImmutableRegCheck; 7 | import com.orbitz.consul.model.agent.ImmutableRegistration; 8 | 9 | /** 10 | * Created by jiang on 2017/5/19. 11 | */ 12 | public class ConsulRegistryService extends AbstractConsulService implements RegistryService { 13 | 14 | private final static int CONSUL_CONNECT_PERIOD=1*1000; 15 | 16 | @Override 17 | public void register(RpcURL url) { 18 | Consul consul = this.buildConsul(url.getRegistryHost(),url.getRegistryPort()); 19 | AgentClient agent = consul.agentClient(); 20 | 21 | ImmutableRegCheck check = ImmutableRegCheck.builder().tcp(url.getHost()+":"+url.getPort()).interval(CONSUL_HEALTH_INTERVAL).build(); 22 | ImmutableRegistration.Builder builder = ImmutableRegistration.builder(); 23 | builder.id(CONSUL_ID).name(CONSUL_NAME).addTags(CONSUL_TAGS).address(url.getHost()).port(url.getPort()).addChecks(check); 24 | 25 | agent.register(builder.build()); 26 | 27 | } 28 | 29 | @Override 30 | public void unregister(RpcURL url) { 31 | 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /jim-framework-dubbo-provider2/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.jim.framework 7 | dubbo.provider2 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | com.jim.framework.dubbo.provider2 12 | Demo project for Spring Boot 13 | 14 | 15 | com.jim.framework 16 | jim-framework-parent 17 | 1.0.0-SNAPSHOT 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | org.springframework.boot 27 | spring-boot-starter-aop 28 | 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-starter-test 33 | test 34 | 35 | 36 | 37 | com.jim.framework 38 | dubbo.core 39 | 0.0.1-SNAPSHOT 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /jim-framework-dubbo-consumer/src/main/resources/applicationContext-dubbo-consumer.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 21 | 22 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /jim-framework-dubbo-core/src/main/java/com/jim/framework/dubbo/core/trace/config/EnableTraceAutoConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.dubbo.core.trace.config; 2 | 3 | import com.jim.framework.dubbo.core.annotation.EnableTraceAutoConfigurationProperties; 4 | import com.jim.framework.dubbo.core.context.RpcTraceContext; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.boot.SpringBootConfiguration; 7 | import org.springframework.boot.autoconfigure.AutoConfigureAfter; 8 | import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; 9 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 10 | import org.springframework.context.annotation.Configuration; 11 | 12 | import javax.annotation.PostConstruct; 13 | 14 | /* 15 | * 日志追踪自动配置开关 16 | * 作者:姜敏 17 | * 版本:V1.0 18 | * 创建日期:2017/4/13 19 | * 修改日期:2017/4/13 20 | */ 21 | @Configuration 22 | @ConditionalOnBean(annotation = EnableTraceAutoConfigurationProperties.class) 23 | @AutoConfigureAfter(SpringBootConfiguration.class) 24 | @EnableConfigurationProperties(TraceConfig.class) 25 | public class EnableTraceAutoConfiguration { 26 | 27 | @Autowired 28 | private TraceConfig traceConfig; 29 | 30 | @PostConstruct 31 | public void init() throws Exception { 32 | RpcTraceContext.init(this.traceConfig); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /jim-framework-cache/src/main/java/com/jim/framework/cache/helper/ThreadTaskHelper.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.cache.helper; 2 | 3 | import com.google.common.collect.Maps; 4 | 5 | import java.util.Map; 6 | import java.util.concurrent.ExecutorService; 7 | import java.util.concurrent.Executors; 8 | 9 | /** 10 | * Created by jiang on 2017/3/6. 11 | */ 12 | public class ThreadTaskHelper { 13 | 14 | private static ExecutorService executorService= Executors.newFixedThreadPool(20); 15 | 16 | private static Map RUNNING_REFRESH_CACHE= Maps.newConcurrentMap(); 17 | 18 | public static Map getRunningRefreshCache(){ 19 | return RUNNING_REFRESH_CACHE; 20 | } 21 | 22 | public static void putRefreshCacheTask(String cacheKey){ 23 | if(!hasRunningRefreshCacheTask(cacheKey)){ 24 | RUNNING_REFRESH_CACHE.put(cacheKey,cacheKey); 25 | } 26 | } 27 | 28 | public static void removeRefreshCacheTask(String cacheKey){ 29 | if(hasRunningRefreshCacheTask(cacheKey)){ 30 | RUNNING_REFRESH_CACHE.remove(cacheKey); 31 | } 32 | } 33 | 34 | public static boolean hasRunningRefreshCacheTask(String cacheKey){ 35 | return RUNNING_REFRESH_CACHE.containsKey(cacheKey); 36 | } 37 | 38 | public static void run(Runnable runnable){ 39 | executorService.execute(runnable); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /jim-framework-cloud-consumer/src/main/java/com/jim/framework/cloud/consumer/controller/ProductController.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.cloud.consumer.controller; 2 | 3 | import com.jim.framework.cloud.consumer.service.ProductService; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.beans.factory.annotation.Value; 8 | import org.springframework.web.bind.annotation.PathVariable; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | import org.springframework.web.bind.annotation.RestController; 11 | 12 | import java.net.UnknownHostException; 13 | 14 | /** 15 | * Created by jiang on 2017/3/28. 16 | */ 17 | @RestController 18 | @RequestMapping("/product") 19 | public class ProductController { 20 | 21 | private final static Logger logger = LoggerFactory.getLogger(ProductController.class); 22 | 23 | @Value("${test.key}") 24 | private String eurekaInstanceHostname; 25 | 26 | @Autowired 27 | private ProductService productService; 28 | 29 | @RequestMapping("/{productId}") 30 | public String getById(@PathVariable final long productId) throws UnknownHostException { 31 | logger.info("Consumer ProductController.getById"+productId+this.eurekaInstanceHostname); 32 | return this.productService.getById(productId); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /jim-framework-dubbo-core/src/main/java/com/jim/framework/dubbo/core/context/ZipkinCollectorConfigurationFactory.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.dubbo.core.context; 2 | 3 | import brave.Tracing; 4 | import com.google.common.base.Objects; 5 | import com.jim.framework.dubbo.core.trace.config.TraceConfig; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Component; 8 | 9 | /** 10 | * Created by jiangmin on 2018/10/7. 11 | */ 12 | @Component 13 | public class ZipkinCollectorConfigurationFactory { 14 | 15 | private final AbstractZipkinCollectorConfiguration zipkinCollectorConfiguration; 16 | 17 | @Autowired 18 | public ZipkinCollectorConfigurationFactory(TraceConfig traceConfig){ 19 | if(Objects.equal("kafka", traceConfig.getZipkinSendType())){ 20 | zipkinCollectorConfiguration=new KafkaZipkinCollectorConfiguration( 21 | traceConfig.getApplicationName(), 22 | traceConfig.getZipkinUrl(), 23 | traceConfig.getZipkinKafkaTopic()); 24 | } 25 | else { 26 | zipkinCollectorConfiguration = new HttpZipkinCollectorConfiguration( 27 | traceConfig.getApplicationName(), 28 | traceConfig.getZipkinUrl()); 29 | } 30 | } 31 | 32 | public Tracing getTracing(){ 33 | return this.zipkinCollectorConfiguration.getTracing(); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /jim-framework-rpc/src/main/java/com/jim/framework/rpc/config/ReferenceConfig.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.config; 2 | 3 | /** 4 | 消费端配置 5 | * Created by jiang on 2017/5/10. 6 | */ 7 | public class ReferenceConfig { 8 | private String host; 9 | private int port; 10 | 11 | private String registryHost; 12 | private int registryPort; 13 | 14 | public String getRegistryHost() { 15 | return registryHost; 16 | } 17 | 18 | public void setRegistryHost(String registryHost) { 19 | this.registryHost = registryHost; 20 | } 21 | 22 | public int getRegistryPort() { 23 | return registryPort; 24 | } 25 | 26 | public void setRegistryPort(int registryPort) { 27 | this.registryPort = registryPort; 28 | } 29 | 30 | protected long connectTimeoutMillis = 6000; 31 | 32 | public String getHost() { 33 | return host; 34 | } 35 | 36 | public void setHost(String host) { 37 | this.host = host; 38 | } 39 | 40 | public int getPort() { 41 | return port; 42 | } 43 | 44 | public void setPort(int port) { 45 | this.port = port; 46 | } 47 | 48 | public long getConnectTimeoutMillis() { 49 | return connectTimeoutMillis; 50 | } 51 | 52 | public void setConnectTimeoutMillis(long connectTimeoutMillis) { 53 | this.connectTimeoutMillis = connectTimeoutMillis; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /jim-framework-rpc/src/main/java/com/jim/framework/rpc/codec/RpcDecoder.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.codec; 2 | 3 | import com.jim.framework.rpc.protocol.RpcMessage; 4 | import com.jim.framework.rpc.utils.ProtoStuffSerializeUtil; 5 | import io.netty.buffer.ByteBuf; 6 | import io.netty.channel.ChannelHandlerContext; 7 | import io.netty.handler.codec.LengthFieldBasedFrameDecoder; 8 | 9 | /** 10 | 解码器 11 | * Created by jiang on 2017/5/10. 12 | */ 13 | public class RpcDecoder extends LengthFieldBasedFrameDecoder { 14 | 15 | private Class genericClass; 16 | 17 | private static final int HEADER_SIZE = 4; 18 | 19 | private static final int LENGTH_FIELD_OFFSET=0; 20 | 21 | private static final int LENGTH_FIELD_LENGTH=4; 22 | 23 | private static final int MAX_FRAME_LENGTH=Integer.MAX_VALUE; 24 | 25 | public RpcDecoder(Class genericClass) { 26 | super(MAX_FRAME_LENGTH,LENGTH_FIELD_OFFSET,LENGTH_FIELD_LENGTH); 27 | this.genericClass = genericClass; 28 | } 29 | 30 | @Override 31 | public Object decode(ChannelHandlerContext ctx, ByteBuf in) throws Exception { 32 | ByteBuf frame=(ByteBuf)super.decode(ctx,in); 33 | if(null==frame){ 34 | return null; 35 | } 36 | byte[] data = new byte[frame.readInt()]; 37 | frame.readBytes(data); 38 | 39 | RpcMessage message = ProtoStuffSerializeUtil.deserialize(data, RpcMessage.class); 40 | return message; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /jim-framework-rpc-api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.jim.framework 7 | rpc.api 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | com.jim.framework.rpc.api 12 | Demo project for Spring Boot 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 2.0.0.RELEASE 18 | 19 | 20 | 21 | 22 | UTF-8 23 | UTF-8 24 | 1.8 25 | 26 | 27 | 28 | 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-starter-test 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | org.springframework.boot 41 | spring-boot-maven-plugin 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /jim-framework-rpc/src/main/java/com/jim/framework/rpc/filter/ClientContextFilter.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.filter; 2 | 3 | import com.google.common.collect.Maps; 4 | import com.jim.framework.rpc.common.RpcFilter; 5 | import com.jim.framework.rpc.common.RpcInvocation; 6 | import com.jim.framework.rpc.common.RpcInvoker; 7 | import com.jim.framework.rpc.config.ConstantConfig; 8 | import com.jim.framework.rpc.context.RpcContext; 9 | import org.slf4j.Logger; 10 | import org.slf4j.LoggerFactory; 11 | 12 | import java.util.Map; 13 | 14 | /** 15 | * Created by jiang on 2017/5/14. 16 | */ 17 | @ActiveFilter(group = {ConstantConfig.CONSUMER},order = -1000) 18 | public class ClientContextFilter implements RpcFilter { 19 | 20 | private final static Logger logger = LoggerFactory.getLogger(ClientContextFilter.class); 21 | 22 | @Override 23 | public Object invoke(RpcInvoker invoker, RpcInvocation invocation) { 24 | Map contextParameters=invocation.getContextParameters(); 25 | if(null==contextParameters){ 26 | contextParameters= Maps.newHashMap(); 27 | } 28 | Map contextParametersFromRpcContext= RpcContext.getContext().getContextParameters(); 29 | if(null!=contextParametersFromRpcContext) { 30 | contextParameters.putAll(contextParametersFromRpcContext); 31 | } 32 | Object rpcResponse=invoker.invoke(invocation); 33 | logger.info("ClientContextFilter.invoke end"); 34 | return rpcResponse; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /jim-framework-dubbo-provider/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.jim.framework 7 | dubbo.provider 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | com.jim.framework.dubbo.provider 12 | Demo project for Spring Boot 13 | 14 | 15 | com.jim.framework 16 | jim-framework-parent 17 | 1.0.0-SNAPSHOT 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | org.springframework.boot 27 | spring-boot-starter-aop 28 | 29 | 30 | 31 | org.projectlombok 32 | lombok 33 | true 34 | 35 | 36 | org.springframework.boot 37 | spring-boot-starter-test 38 | test 39 | 40 | 41 | 42 | com.jim.framework 43 | dubbo.core 44 | 0.0.1-SNAPSHOT 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /jim-framework-dubbo-provider2/src/main/java/com/jim/framework/dubbo/provider2/DubboProviderApplication2.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.dubbo.provider2; 2 | 3 | import com.jim.framework.dubbo.core.annotation.EnableTraceAutoConfigurationProperties; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | import org.springframework.boot.autoconfigure.SpringBootApplication; 7 | import org.springframework.boot.builder.SpringApplicationBuilder; 8 | import org.springframework.context.ApplicationContext; 9 | import org.springframework.context.annotation.Bean; 10 | import org.springframework.context.annotation.ComponentScan; 11 | import org.springframework.context.annotation.ImportResource; 12 | 13 | import java.util.concurrent.CountDownLatch; 14 | 15 | @SpringBootApplication 16 | @EnableTraceAutoConfigurationProperties 17 | @ComponentScan(basePackages = {"com.jim.framework.dubbo.core"}) 18 | @ImportResource("classpath:applicationContext-dubbo-provider.xml") 19 | public class DubboProviderApplication2 { 20 | 21 | private static final Logger logger = LoggerFactory.getLogger(DubboProviderApplication2.class); 22 | 23 | @Bean 24 | public CountDownLatch closeLatch() { 25 | return new CountDownLatch(1); 26 | } 27 | 28 | public static void main(String[] args) throws InterruptedException { 29 | 30 | ApplicationContext ctx = new SpringApplicationBuilder() 31 | .sources(DubboProviderApplication2.class) 32 | .web(false) 33 | .run(args); 34 | 35 | CountDownLatch closeLatch = ctx.getBean(CountDownLatch.class); 36 | closeLatch.await(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /jim-framework-rpc/src/main/java/com/jim/framework/rpc/filter/AccessLimitFilter.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.filter; 2 | 3 | import com.jim.framework.rpc.common.RpcFilter; 4 | import com.jim.framework.rpc.common.RpcInvocation; 5 | import com.jim.framework.rpc.common.RpcInvoker; 6 | import com.jim.framework.rpc.config.ConstantConfig; 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | import org.springframework.core.io.support.SpringFactoriesLoader; 10 | import org.springframework.util.CollectionUtils; 11 | 12 | import java.util.Date; 13 | import java.util.List; 14 | 15 | /** 16 | * Created by jiang on 2017/5/14. 17 | */ 18 | @ActiveFilter(group = {ConstantConfig.CONSUMER}) 19 | public class AccessLimitFilter implements RpcFilter { 20 | 21 | private final static Logger logger = LoggerFactory.getLogger(AccessLimitFilter.class); 22 | 23 | @Override 24 | public Object invoke(RpcInvoker invoker, RpcInvocation invocation) { 25 | logger.info("before acquire,"+new Date()); 26 | List accessLimitServiceLoader = SpringFactoriesLoader.loadFactories(AccessLimitService.class, null); 27 | if(!CollectionUtils.isEmpty(accessLimitServiceLoader)){ 28 | AccessLimitService accessLimitService=accessLimitServiceLoader.get(0); 29 | accessLimitService.acquire(invocation); 30 | } 31 | 32 | Object rpcResponse=invoker.invoke(invocation); 33 | logger.info("after acquire,"+new Date()); 34 | return rpcResponse; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /jim-framework-dubbo-provider/src/main/java/com/jim/framework/dubbo/provider/DubboProviderApplication.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.dubbo.provider; 2 | 3 | import com.jim.framework.dubbo.core.annotation.EnableTraceAutoConfigurationProperties; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | import org.springframework.boot.autoconfigure.SpringBootApplication; 7 | import org.springframework.boot.builder.SpringApplicationBuilder; 8 | import org.springframework.context.ApplicationContext; 9 | import org.springframework.context.annotation.Bean; 10 | import org.springframework.context.annotation.ComponentScan; 11 | import org.springframework.context.annotation.ImportResource; 12 | 13 | import java.util.concurrent.CountDownLatch; 14 | 15 | @SpringBootApplication 16 | @EnableTraceAutoConfigurationProperties 17 | @ComponentScan(basePackages = {"com.jim.framework.dubbo.core"}) 18 | @ImportResource({"classpath:applicationContext-dubbo-consumer.xml","classpath:applicationContext-dubbo-provider.xml"}) 19 | public class DubboProviderApplication { 20 | 21 | private static final Logger logger = LoggerFactory.getLogger(DubboProviderApplication.class); 22 | 23 | @Bean 24 | public CountDownLatch closeLatch() { 25 | return new CountDownLatch(1); 26 | } 27 | 28 | public static void main(String[] args) throws InterruptedException { 29 | 30 | ApplicationContext ctx = new SpringApplicationBuilder() 31 | .sources(DubboProviderApplication.class) 32 | .web(false) 33 | .run(args); 34 | 35 | CountDownLatch closeLatch = ctx.getBean(CountDownLatch.class); 36 | closeLatch.await(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /jim-framework-rpc-provider/src/main/java/com/jim/framework/rpc/provider/service/impl/ProductServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.provider.service.impl; 2 | 3 | import com.jim.framework.rpc.api.model.Comment; 4 | import com.jim.framework.rpc.api.model.Product; 5 | import com.jim.framework.rpc.api.service.CommentService; 6 | import com.jim.framework.rpc.context.RpcContext; 7 | import com.jim.framework.rpc.server.RpcService; 8 | import com.jim.framework.rpc.api.service.ProductService; 9 | import org.slf4j.Logger; 10 | import org.slf4j.LoggerFactory; 11 | 12 | @RpcService 13 | public class ProductServiceImpl implements ProductService,CommentService { 14 | 15 | Logger logger= LoggerFactory.getLogger(ProductServiceImpl.class); 16 | 17 | @Override 18 | public Product getById(Long id) { 19 | // try { 20 | // Thread.sleep(10000); 21 | // } catch (InterruptedException e) { 22 | // e.printStackTrace(); 23 | // } 24 | Product product=new Product(); 25 | product.setId(id); 26 | product.setName(id+"name"); 27 | logger.info("get context parameter from server,rpc-version={}",String.valueOf(RpcContext.getContext().getContextParameter("rpc-version"))); 28 | return product; 29 | } 30 | 31 | @Override 32 | public Comment getCommentByProductId(Long productId) { 33 | Comment comment=new Comment(); 34 | comment.setProductId(productId); 35 | comment.setId(productId); 36 | comment.setContent(productId+"comment"); 37 | return comment; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /jim-framework-activemq/src/main/java/com/jim/framework/activemq/consumer/ProductConsumerA.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.activemq.consumer; 2 | 3 | import com.jim.framework.activemq.model.Product; 4 | import org.apache.activemq.ActiveMQConnection; 5 | import org.apache.activemq.command.ActiveMQObjectMessage; 6 | import org.springframework.stereotype.Component; 7 | 8 | import javax.jms.JMSException; 9 | import javax.jms.Message; 10 | import javax.jms.MessageListener; 11 | import java.util.ArrayList; 12 | import java.util.List; 13 | 14 | /** 15 | * Created by jiangmin on 2017/12/31. 16 | */ 17 | @Component 18 | public class ProductConsumerA implements MessageListener { 19 | 20 | //@JmsListener(destination = Constans.QUEUE_NAME,containerFactory = Constans.LISTENER_A_CONTAINER_QUEUE_NAME) 21 | @Override 22 | public void onMessage(Message message) { 23 | 24 | String transport= ((ActiveMQConnection)((ActiveMQObjectMessage)message).getConnection()).getTransport().toString(); 25 | 26 | String text= ""; 27 | try { 28 | text = ((ActiveMQObjectMessage)message).getObject().toString(); 29 | } catch (JMSException e) { 30 | e.printStackTrace(); 31 | } 32 | 33 | if(Product.transportResult.containsKey(transport)){ 34 | Product.transportResult.get(transport).add(text); 35 | } 36 | else { 37 | List productList=new ArrayList<>(); 38 | productList.add(text); 39 | Product.transportResult.put(transport,productList); 40 | } 41 | System.out.println("Consumer,productId:"+text+"transport:"+transport); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /jim-framework-activemq/src/main/java/com/jim/framework/activemq/consumer/ProductConsumerB.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.activemq.consumer; 2 | 3 | import com.jim.framework.activemq.model.Product; 4 | import org.apache.activemq.ActiveMQConnection; 5 | import org.apache.activemq.command.ActiveMQObjectMessage; 6 | import org.springframework.stereotype.Component; 7 | 8 | import javax.jms.JMSException; 9 | import javax.jms.Message; 10 | import javax.jms.MessageListener; 11 | import java.util.ArrayList; 12 | import java.util.List; 13 | 14 | /** 15 | * Created by jiangmin on 2017/12/31. 16 | */ 17 | @Component 18 | public class ProductConsumerB implements MessageListener { 19 | 20 | //@JmsListener(destination = Constans.QUEUE_NAME,containerFactory = Constans.LISTENER_CONTAINER_QUEUE_NAME) 21 | @Override 22 | public void onMessage(Message message) { 23 | 24 | String transport= ((ActiveMQConnection)((ActiveMQObjectMessage)message).getConnection()).getTransport().toString(); 25 | 26 | String text= ""; 27 | try { 28 | text = ((ActiveMQObjectMessage)message).getObject().toString(); 29 | } catch (JMSException e) { 30 | e.printStackTrace(); 31 | } 32 | 33 | if(Product.transportResult.containsKey(transport)){ 34 | Product.transportResult.get(transport).add(text); 35 | } 36 | else { 37 | List productList=new ArrayList<>(); 38 | productList.add(text); 39 | Product.transportResult.put(transport,productList); 40 | } 41 | 42 | System.out.println("Consumer,productId:"+text+"transport:"+transport); 43 | 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /jim-framework-rpc-consumer/src/main/java/com/jim/framework/rpc/consumer/service/impl/AccessLimitServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.consumer.service.impl; 2 | 3 | import com.google.common.collect.Maps; 4 | import com.google.common.util.concurrent.RateLimiter; 5 | import com.jim.framework.rpc.common.RpcInvocation; 6 | import com.jim.framework.rpc.filter.AccessLimitService; 7 | import org.springframework.stereotype.Service; 8 | 9 | import java.util.Map; 10 | 11 | /** 12 | * Created by jiangmin on 2018/5/19. 13 | */ 14 | @Service 15 | public class AccessLimitServiceImpl implements AccessLimitService { 16 | 17 | @Override 18 | public void acquire(RpcInvocation invocation) { 19 | AccessLimitManager.acquire(invocation); 20 | } 21 | 22 | 23 | static class AccessLimitManager{ 24 | 25 | private final static Object lock=new Object(); 26 | 27 | private final static Map rateLimiterMap= Maps.newHashMap(); 28 | 29 | public static void acquire(RpcInvocation invocation){ 30 | if(!rateLimiterMap.containsKey(invocation.getClassName())) { 31 | synchronized (lock) { 32 | if(!rateLimiterMap.containsKey(invocation.getClassName())) { 33 | final RateLimiter rateLimiter = RateLimiter.create(invocation.getMaxExecutesCount()); 34 | rateLimiterMap.put(invocation.getClassName(), rateLimiter); 35 | } 36 | } 37 | } 38 | else { 39 | RateLimiter rateLimiter=rateLimiterMap.get(invocation.getClassName()); 40 | rateLimiter.acquire(); 41 | } 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /jim-framework-web/src/main/java/com/jim/framework/web/utils/JacksonSerialize.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.web.utils; 2 | 3 | 4 | import com.fasterxml.jackson.annotation.JsonAutoDetect; 5 | import com.fasterxml.jackson.annotation.PropertyAccessor; 6 | import com.fasterxml.jackson.databind.DeserializationFeature; 7 | import com.fasterxml.jackson.databind.ObjectMapper; 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | 11 | public class JacksonSerialize { 12 | 13 | private static ObjectMapper objectMapper = new ObjectMapper(); 14 | 15 | private final static byte[] DEFAULT_BYTE=new byte[0]; 16 | 17 | private final static Logger logger = LoggerFactory.getLogger(JacksonSerialize.class); 18 | 19 | static { 20 | objectMapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY); 21 | objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); 22 | } 23 | 24 | public static byte[] serialize(Object obj){ 25 | if(null==obj){ 26 | throw new RuntimeException("FastjsonSerialize.serialize: obj is null"); 27 | } 28 | try { 29 | return objectMapper.writeValueAsBytes(obj); 30 | } catch (Exception e) { 31 | logger.error("JacksonSerialize error:",e); 32 | } 33 | return DEFAULT_BYTE; 34 | } 35 | 36 | public static T deserialize(byte[] bytes, Class beanClass) { 37 | if (null==bytes||bytes.length==0){ 38 | return null; 39 | } 40 | try { 41 | return objectMapper.readValue(bytes, beanClass); 42 | } catch (Exception e) { 43 | logger.error("JacksonSerialize error:",e); 44 | } 45 | return null; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /jim-framework-web/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | ${logHome}/default.%d{yyyy-MM-dd}.log 9 | 3 10 | 11 | 12 | ${logpattern} 13 | true 14 | utf8 15 | 16 | 17 | 18 | 19 | 20 | ${logpattern} 21 | utf8 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /jim-framework-configcenter/src/main/java/com/jim/framework/configcenter/service/impl/AbstractConfigCenterService.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.configcenter.service.impl; 2 | 3 | import org.apache.commons.lang3.StringUtils; 4 | 5 | public abstract class AbstractConfigCenterService { 6 | 7 | public Long getLongValue(String key){ 8 | Object value=getObjectValue(key); 9 | if(value!=null){ 10 | return Long.valueOf(String.valueOf(value)); 11 | } 12 | return null; 13 | } 14 | public Integer getIntegerValue(String key){ 15 | Object value=getObjectValue(key); 16 | if(value!=null){ 17 | return Integer.valueOf(String.valueOf(value)); 18 | } 19 | return null; 20 | } 21 | public Double getDoubleValue(String key){ 22 | Object value=getObjectValue(key); 23 | if(value!=null){ 24 | return Double.valueOf(String.valueOf(value)); 25 | } 26 | return null; 27 | } 28 | public Boolean getBooleanValue(String key){ 29 | Object value=getObjectValue(key); 30 | if(value!=null){ 31 | return Boolean.parseBoolean(String.valueOf(value)); 32 | } 33 | return null; 34 | } 35 | public String get(String key){ 36 | Object value=getObjectValue(key); 37 | if(value!=null){ 38 | return String.valueOf(value); 39 | } 40 | return null; 41 | } 42 | protected String checkKeyPrefix(String key){ 43 | if(StringUtils.isEmpty(key)){ 44 | return key; 45 | } 46 | if(key.startsWith(".")){ 47 | return key; 48 | } 49 | return "."+key; 50 | } 51 | abstract public Object getObjectValue(String key); 52 | 53 | } 54 | -------------------------------------------------------------------------------- /jim-framework-rpc/src/main/java/com/jim/framework/rpc/client/RpcClientInitializer.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.client; 2 | 3 | import com.jim.framework.rpc.codec.RpcDecoder; 4 | import com.jim.framework.rpc.codec.RpcEncoder; 5 | import com.jim.framework.rpc.common.RpcFilter; 6 | import com.jim.framework.rpc.common.RpcRequest; 7 | import com.jim.framework.rpc.common.RpcResponse; 8 | import com.jim.framework.rpc.constants.Constants; 9 | import com.jim.framework.rpc.keepalive.ClientHeartbeatHandler; 10 | import com.jim.framework.rpc.utils.ActiveFilterUtil; 11 | import io.netty.channel.ChannelInitializer; 12 | import io.netty.channel.ChannelPipeline; 13 | import io.netty.channel.socket.SocketChannel; 14 | import io.netty.handler.timeout.IdleStateHandler; 15 | import org.slf4j.Logger; 16 | import org.slf4j.LoggerFactory; 17 | 18 | import java.util.Map; 19 | 20 | public class RpcClientInitializer extends ChannelInitializer { 21 | 22 | private final static Logger logger = LoggerFactory.getLogger(RpcClientInitializer.class); 23 | 24 | private Map getFilterMap(){ 25 | logger.info("RpcClientInitializer.setApplicationContext"); 26 | 27 | return ActiveFilterUtil.getFilterMap(false); 28 | } 29 | 30 | @Override 31 | protected void initChannel(SocketChannel socketChannel) throws Exception { 32 | ChannelPipeline cp = socketChannel.pipeline(); 33 | 34 | cp.addLast(new RpcEncoder(RpcRequest.class)); 35 | cp.addLast(new RpcDecoder(RpcResponse.class)); 36 | cp.addLast(new IdleStateHandler(0, 0, Constants.ALLIDLE_TIME_SECONDS)); 37 | cp.addLast(new ClientHeartbeatHandler()); 38 | cp.addLast(new RpcClientInvoker(this.getFilterMap())); 39 | 40 | } 41 | } -------------------------------------------------------------------------------- /jim-framework-rpc/src/main/java/test/com/jim/framework/rpc/registry/impl/ConsulRegistryServiceImplTest.java: -------------------------------------------------------------------------------- 1 | package test.com.jim.framework.rpc.registry.impl; 2 | 3 | import org.junit.After; 4 | import org.junit.Before; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.springframework.boot.SpringBootConfiguration; 8 | import org.springframework.boot.test.context.SpringBootTest; 9 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 10 | 11 | /** 12 | * ConsulRegistryService Tester. 13 | * 14 | * @author 15 | * @version 1.0 16 | * @since
���� 19, 2017
17 | */ 18 | @RunWith(SpringJUnit4ClassRunner.class) 19 | @SpringBootConfiguration 20 | @SpringBootTest(classes = {RegistryServiceConfig.class}) 21 | public class ConsulRegistryServiceImplTest { 22 | 23 | 24 | 25 | @Before 26 | public void before() throws Exception { 27 | } 28 | 29 | @After 30 | public void after() throws Exception { 31 | } 32 | 33 | /** 34 | * Method: register(RpcURL url) 35 | */ 36 | // @Test 37 | // public void testRegister() throws Exception { 38 | ////TODO: Test goes here... 39 | // ConsulRegistryService consulRegistryService=new ConsulRegistryService(); 40 | // consulRegistryService.register(null); 41 | // List urls=consulRegistryService.getUrls("192.168.21.128",8500); 42 | // Assert.assertTrue(null!=urls); 43 | // } 44 | 45 | /** 46 | * Method: unregister(RpcURL url) 47 | */ 48 | @Test 49 | public void testUnregister() throws Exception { 50 | //TODO: Test goes here... 51 | } 52 | 53 | /** 54 | * Method: getUrls() 55 | */ 56 | @Test 57 | public void testGetUrls() throws Exception { 58 | //TODO: Test goes here... 59 | } 60 | 61 | 62 | } 63 | -------------------------------------------------------------------------------- /jim-framework-dubbo-consumer/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.jim.framework 7 | dubbo.consumer 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | com.jim.framework.dubbo.consumer 12 | Demo project for Spring Boot 13 | 14 | 15 | com.jim.framework 16 | jim-framework-parent 17 | 1.0.0-SNAPSHOT 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | org.springframework.boot 27 | spring-boot-starter-aop 28 | 29 | 30 | org.springframework.boot 31 | spring-boot-starter-cache 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-web 36 | 37 | 38 | 39 | org.projectlombok 40 | lombok 41 | true 42 | 43 | 44 | org.springframework.boot 45 | spring-boot-starter-test 46 | test 47 | 48 | 49 | com.jim.framework 50 | dubbo.core 51 | 0.0.1-SNAPSHOT 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /jim-framework-web/src/main/resources/generator/generatorConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 25 | 26 | 27 | 29 | 30 | 31 | 32 | 35 | 36 | 37 | 38 | 39 | 40 | 41 |
42 | 43 | 44 | 45 |
46 | 47 | 48 |
-------------------------------------------------------------------------------- /jim-framework-activemq/src/main/java/com/jim/framework/activemq/config/ConsumerConfig.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.activemq.config; 2 | 3 | import org.springframework.jms.listener.DefaultMessageListenerContainer; 4 | 5 | import javax.jms.Session; 6 | import java.util.List; 7 | 8 | /** 9 | * Created by jiangmin on 2018/1/11. 10 | */ 11 | public class ConsumerConfig { 12 | 13 | private int concurrentConsumers = 10; 14 | private final int cacheLevel = DefaultMessageListenerContainer.CACHE_CONNECTION; 15 | private boolean useAsyncSend = true; 16 | private List brokerUrlList; 17 | private int acknowledgemode = Session.AUTO_ACKNOWLEDGE; 18 | private String queueName; 19 | 20 | public int getConcurrentConsumers() { 21 | return concurrentConsumers; 22 | } 23 | 24 | public void setConcurrentConsumers(int concurrentConsumers) { 25 | this.concurrentConsumers = concurrentConsumers; 26 | } 27 | 28 | public int getCacheLevel() { 29 | return cacheLevel; 30 | } 31 | 32 | public boolean isUseAsyncSend() { 33 | return useAsyncSend; 34 | } 35 | 36 | public void setUseAsyncSend(boolean useAsyncSend) { 37 | this.useAsyncSend = useAsyncSend; 38 | } 39 | 40 | public List getBrokerUrlList() { 41 | return brokerUrlList; 42 | } 43 | 44 | public void setBrokerUrlList(List brokerUrlList) { 45 | this.brokerUrlList = brokerUrlList; 46 | } 47 | 48 | public int getAcknowledgemode() { 49 | return acknowledgemode; 50 | } 51 | 52 | public void setAcknowledgemode(int acknowledgemode) { 53 | this.acknowledgemode = acknowledgemode; 54 | } 55 | 56 | public String getQueueName() { 57 | return queueName; 58 | } 59 | 60 | public void setQueueName(String queueName) { 61 | this.queueName = queueName; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /jim-framework-configcenter/src/main/java/com/jim/framework/configcenter/spring/SpringPropertyInjectSupport.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.configcenter.spring; 2 | 3 | import com.jim.framework.configcenter.factory.ConfigCenterFactory; 4 | import com.jim.framework.configcenter.service.ConfigCenterService; 5 | import org.apache.commons.lang3.StringUtils; 6 | 7 | import java.util.Map; 8 | 9 | public class SpringPropertyInjectSupport { 10 | 11 | private String configNameSpaces = null; 12 | 13 | public String getConfigNameSpaces() { 14 | return configNameSpaces; 15 | } 16 | 17 | public void setConfigNameSpaces(String configNameSpaces) { 18 | this.configNameSpaces = configNameSpaces; 19 | } 20 | 21 | private void setSystemPropertiesFromConfigCenter() { 22 | if (StringUtils.isBlank(this.configNameSpaces)) { 23 | return; 24 | } 25 | ConfigCenterFactory.getInstance().setSystemNameSpace(this.configNameSpaces); 26 | ConfigCenterService cc = ConfigCenterFactory.getInstance().getConfigCenterService(this.configNameSpaces); 27 | Map config = cc.getConfig(); 28 | setSystemProperys(cc, config); 29 | 30 | } 31 | 32 | private void setSystemProperys(ConfigCenterService cc, Map config) { 33 | for (String key : config.keySet()) { 34 | String value = cc.get(key); 35 | if (key.contains(".")) { 36 | key = key.substring(1); 37 | } 38 | if (value == null) { 39 | value = ""; 40 | } 41 | System.setProperty(key, value); 42 | } 43 | } 44 | 45 | public void init() { 46 | if (this.configNameSpaces != null) { 47 | this.setSystemPropertiesFromConfigCenter(); 48 | } 49 | } 50 | 51 | 52 | 53 | 54 | } 55 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.jim.framework 8 | jim-framework-parent 9 | pom 10 | 1.0.0-SNAPSHOT 11 | 12 | jim-framework-dubbo-core 13 | jim-framework-dubbo-provider 14 | jim-framework-dubbo-provider2 15 | jim-framework-dubbo-consumer 16 | 17 | 18 | 19 | org.springframework.boot 20 | spring-boot-starter-parent 21 | 2.0.0.RELEASE 22 | 23 | 24 | 25 | 26 | UTF-8 27 | UTF-8 28 | 1.8 29 | 30 | 31 | 32 | 33 | 34 | com.alibaba 35 | fastjson 36 | 1.2.28 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | org.springframework.boot 45 | spring-boot-maven-plugin 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /jim-framework-dubbo-core/src/main/java/com/jim/framework/dubbo/core/context/AbstractZipkinCollectorConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.dubbo.core.context; 2 | 3 | import brave.Tracing; 4 | import brave.sampler.Sampler; 5 | import zipkin2.Span; 6 | import zipkin2.codec.SpanBytesEncoder; 7 | import zipkin2.reporter.AsyncReporter; 8 | import zipkin2.reporter.Sender; 9 | 10 | import java.util.concurrent.TimeUnit; 11 | 12 | /* 13 | * zipkin收集器配置基类 14 | * 作者:姜敏 15 | * 版本:V1.0 16 | * 创建日期:2017/4/13 17 | * 修改日期:2017/4/13 18 | */ 19 | public abstract class AbstractZipkinCollectorConfiguration { 20 | 21 | private Tracing tracing; 22 | 23 | private String zipkinUrl; 24 | 25 | private String serviceName; 26 | 27 | private String topic; 28 | 29 | public String getTopic() { 30 | return topic; 31 | } 32 | 33 | protected String getZipkinUrl() { 34 | return zipkinUrl; 35 | } 36 | 37 | public AbstractZipkinCollectorConfiguration(String serviceName,String zipkinUrl,String topic){ 38 | this.zipkinUrl=zipkinUrl; 39 | this.serviceName=serviceName; 40 | this.topic=topic; 41 | this.tracing=this.tracing(); 42 | } 43 | 44 | public abstract Sender getSender(); 45 | 46 | protected AsyncReporter spanReporter() { 47 | return AsyncReporter 48 | .builder(getSender()) 49 | .closeTimeout(500, TimeUnit.MILLISECONDS) 50 | .build(SpanBytesEncoder.JSON_V2); 51 | } 52 | 53 | protected Tracing tracing() { 54 | this.tracing= Tracing 55 | .newBuilder() 56 | .localServiceName(this.serviceName) 57 | .sampler(Sampler.ALWAYS_SAMPLE) 58 | .spanReporter(spanReporter()) 59 | .build(); 60 | return this.tracing; 61 | } 62 | 63 | protected Tracing getTracing(){ 64 | return this.tracing; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /jim-framework-dubbo-core/src/main/java/com/jim/framework/dubbo/core/context/RpcTraceContext.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.dubbo.core.context; 2 | 3 | import com.jim.framework.dubbo.core.trace.config.TraceConfig; 4 | 5 | /* 6 | * 日志追踪上下文 7 | * 主要结合zipken 8 | * 作者:姜敏 9 | * 版本:V1.0 10 | * 创建日期:2017/4/13 11 | * 修改日期:2017/4/13 12 | */ 13 | public class RpcTraceContext { 14 | 15 | private static ThreadLocal TRACE_ID = new InheritableThreadLocal<>(); 16 | 17 | private static ThreadLocal SPAN_ID = new InheritableThreadLocal<>(); 18 | 19 | private static ThreadLocal PARENT_ID = new InheritableThreadLocal<>(); 20 | 21 | public static final String TRACE_ID_KEY = "traceId"; 22 | 23 | public static final String SPAN_ID_KEY = "spanId"; 24 | 25 | private static TraceConfig traceConfig; 26 | 27 | public static TraceConfig getTraceConfig(){ 28 | return traceConfig; 29 | } 30 | 31 | public static void setTraceConfig(TraceConfig config){ 32 | traceConfig=config; 33 | } 34 | 35 | private RpcTraceContext(){} 36 | 37 | public static void setTraceId(Long traceId){ 38 | TRACE_ID.set(traceId); 39 | } 40 | 41 | public static Long getTraceId(){ 42 | return TRACE_ID.get(); 43 | } 44 | 45 | public static Long getSpanId() { 46 | return SPAN_ID.get(); 47 | } 48 | 49 | public static void setSpanId(Long spanId) { 50 | SPAN_ID.set(spanId); 51 | } 52 | 53 | public static Long getParentId() { 54 | return PARENT_ID.get(); 55 | } 56 | 57 | public static void setParentId(Long parentId) { 58 | PARENT_ID.set(parentId); 59 | } 60 | 61 | 62 | public static void clear(){ 63 | TRACE_ID.remove(); 64 | SPAN_ID.remove(); 65 | } 66 | 67 | public static void init(TraceConfig traceConfig) { 68 | setTraceConfig(traceConfig); 69 | } 70 | 71 | public static void start(){ 72 | clear(); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /jim-framework-rpc/src/main/java/com/jim/framework/rpc/context/RpcContext.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.context; 2 | 3 | import com.google.common.collect.Maps; 4 | import com.jim.framework.rpc.proxy.ResponseFuture; 5 | 6 | import java.util.Map; 7 | 8 | /** 9 | * Created by jiang on 2017/5/15. 10 | */ 11 | public class RpcContext { 12 | 13 | private ResponseFuture responseFuture; 14 | 15 | private Map contextParameters; 16 | 17 | public ResponseFuture getResponseFuture() { 18 | return responseFuture; 19 | } 20 | 21 | public void addContextParameter(String key,Object value){ 22 | this.getContextParameters().put(key,value); 23 | } 24 | 25 | public Object getContextParameter(String key){ 26 | return this.getContextParameters().get(key); 27 | } 28 | 29 | public void setResponseFuture(ResponseFuture responseFuture) { 30 | System.out.println("current thread id:"+Thread.currentThread().getId()); 31 | this.responseFuture = responseFuture; 32 | } 33 | 34 | public Map getContextParameters() { 35 | return contextParameters; 36 | } 37 | 38 | public void setContextParameters(Map contextParameters) { 39 | this.contextParameters = contextParameters; 40 | } 41 | 42 | private static final ThreadLocal rpcContextThreadLocal=new ThreadLocal(){ 43 | @Override 44 | protected RpcContext initialValue() { 45 | RpcContext context= new RpcContext(); 46 | context.setContextParameters(Maps.newHashMap()); 47 | return context; 48 | } 49 | }; 50 | 51 | public static RpcContext getContext() { 52 | return rpcContextThreadLocal.get(); 53 | } 54 | 55 | public static void removeContext() { 56 | rpcContextThreadLocal.remove(); 57 | } 58 | 59 | private RpcContext() { 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /jim-framework-rpc-provider/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.jim.framework 7 | rpc.provider 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | com.jim.framework.rpc.provider 12 | Demo project for Spring Boot 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 2.0.0.RELEASE 18 | 19 | 20 | 21 | 22 | UTF-8 23 | UTF-8 24 | 1.8 25 | 26 | 27 | 28 | 29 | 30 | 31 | com.jim.framework 32 | rpc 33 | 0.0.1-SNAPSHOT 34 | 35 | 36 | 37 | com.jim.framework 38 | rpc.api 39 | 0.0.1-SNAPSHOT 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | org.springframework.boot 49 | spring-boot-maven-plugin 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | spring-milestones 59 | Spring Milestones 60 | https://repo.spring.io/milestone 61 | 62 | false 63 | 64 | 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /jim-framework-dubbo-provider/src/main/java/com/jim/framework/dubbo/provider/config/DubboProviderConfig.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.dubbo.provider.config; 2 | 3 | import com.alibaba.dubbo.config.*; 4 | import org.springframework.context.annotation.Bean; 5 | 6 | /* 7 | * DBUBBO配置文件 8 | * 作者:姜敏 9 | * 版本:V1.0 10 | * 创建日期:2017/4/13 11 | * 修改日期:2017/4/13 12 | */ 13 | //@Configuration 14 | public class DubboProviderConfig { 15 | 16 | @Bean 17 | public RegistryConfig registryConfig(){ 18 | RegistryConfig config=new RegistryConfig(); 19 | config.setAddress("N/A"); 20 | return config; 21 | } 22 | 23 | @Bean 24 | public ApplicationConfig applicationConfig(){ 25 | ApplicationConfig config=new ApplicationConfig(); 26 | config.setName("dubbo-provider"); 27 | config.setLogger("slf4j"); 28 | return config; 29 | 30 | } 31 | 32 | @Bean 33 | public ReferenceConfig referenceConfig(){ 34 | ReferenceConfig config=new ReferenceConfig(); 35 | return config; 36 | } 37 | 38 | @Bean 39 | public ProtocolConfig protocolConfig(){ 40 | ProtocolConfig config=new ProtocolConfig(); 41 | config.setPort(9999); 42 | config.setName("dubbo"); 43 | config.setAccesslog("true"); 44 | return config; 45 | } 46 | 47 | @Bean 48 | public ProviderConfig providerConfig(){ 49 | ProviderConfig config=new ProviderConfig(); 50 | config.setFilter("traceProviderFilter"); 51 | return config; 52 | } 53 | 54 | // @Bean 55 | // public ServiceBean productServiceServiceBean(ProductService productService){ 56 | // ServiceBean productServiceServiceBean=new ServiceBean<>(); 57 | // productServiceServiceBean.setInterface(ProductService.class); 58 | // productServiceServiceBean.setRef(productService); 59 | // return productServiceServiceBean; 60 | // 61 | // } 62 | } 63 | -------------------------------------------------------------------------------- /jim-framework-configcenter/src/main/java/com/jim/framework/configcenter/model/ConfigOption.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.configcenter.model; 2 | 3 | import com.google.common.base.Objects; 4 | import com.google.common.base.Preconditions; 5 | import com.google.common.eventbus.EventBus; 6 | import com.netflix.curator.RetryPolicy; 7 | import com.netflix.curator.retry.ExponentialBackoffRetry; 8 | 9 | public class ConfigOption { 10 | 11 | private String nameSpace; 12 | private String zkUrls; 13 | private RetryPolicy retryPolicy; 14 | private boolean useRemote; 15 | private EventBus enventBus; 16 | 17 | public ConfigOption(String nameSpace,String zkUrls,RetryPolicy retryPolicy,boolean useRemote){ 18 | this.nameSpace= Preconditions.checkNotNull(nameSpace); 19 | this.zkUrls=Preconditions.checkNotNull(zkUrls); 20 | this.retryPolicy=Preconditions.checkNotNull(retryPolicy); 21 | this.useRemote=useRemote; 22 | this.enventBus=new EventBus(); 23 | 24 | } 25 | public ConfigOption(String nameSpace,String zkUrls){ 26 | this( 27 | nameSpace, 28 | zkUrls, 29 | new ExponentialBackoffRetry(60000, 3), 30 | DefaultOptions.USE_REMOTE_CONFIG); 31 | } 32 | 33 | public String getNameSpace() { 34 | return this.nameSpace; 35 | } 36 | public String getPath(){ 37 | return this.nameSpace.replace(".","/"); 38 | } 39 | 40 | public String getZkUrls() { 41 | return this.zkUrls; 42 | } 43 | 44 | public RetryPolicy getRetryPolicy() { 45 | return this.retryPolicy; 46 | } 47 | 48 | public boolean isUseRemote() { 49 | return this.useRemote; 50 | } 51 | 52 | public EventBus getEnventBus() { 53 | return this.enventBus; 54 | } 55 | 56 | @Override 57 | public String toString() { 58 | return Objects.toStringHelper(this).add("connectStr", zkUrls).add("namespace", nameSpace).add("retryPolicy", retryPolicy).toString(); 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /jim-framework-configcenter/src/main/java/com/jim/framework/configcenter/utils/ZKUtil.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.configcenter.utils; 2 | 3 | import com.jim.framework.configcenter.model.DefaultOptions; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | 7 | import java.io.IOException; 8 | import java.io.InputStream; 9 | import java.util.HashSet; 10 | import java.util.Properties; 11 | 12 | public class ZKUtil { 13 | 14 | private final static Logger logger= LoggerFactory.getLogger(ZKUtil.class); 15 | 16 | private static InputStream getInputStreamFromClassPath() { 17 | return Thread.currentThread().getContextClassLoader().getResourceAsStream(DefaultOptions.CONFIG_NAME); 18 | } 19 | 20 | public static synchronized String getZkurl(){ 21 | InputStream inputStream= getInputStreamFromClassPath(); 22 | 23 | if(inputStream!=null) { 24 | Properties properties=new Properties(); 25 | 26 | try { 27 | properties.load(inputStream); 28 | String env = System.getProperty("evn"); 29 | System.out.print("env:"+env); 30 | HashSet envs = new HashSet(); 31 | envs.add("dev"); 32 | envs.add("test"); 33 | envs.add("sim"); 34 | envs.add("online"); 35 | 36 | if(!envs.contains(env)) { 37 | env ="test"; 38 | } 39 | String zkurlKey=env+"."+ DefaultOptions.CONFIG_ZK_URLS_KEY; 40 | Object value=properties.get(zkurlKey); 41 | if(value!=null){ 42 | logger.info("zkurl:{}",value); 43 | return String.valueOf(value); 44 | } 45 | } catch (IOException e) { 46 | logger.error("load config center zk url error", e); 47 | throw new RuntimeException("load config error"); 48 | } 49 | } 50 | 51 | return null; 52 | } 53 | 54 | 55 | } 56 | -------------------------------------------------------------------------------- /jim-framework-rpc/src/main/java/com/jim/framework/rpc/common/RpcRequest.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.common; 2 | 3 | 4 | import java.util.Map; 5 | 6 | /** 7 | 请求对象 8 | * Created by jiang on 2017/5/10. 9 | */ 10 | public class RpcRequest { 11 | 12 | private String requestId; 13 | private String className; 14 | private String methodName; 15 | private Class[] parameterTypes; 16 | private Object[] parameters; 17 | private int maxExecutesCount; 18 | private Map contextParameters; 19 | 20 | public String getRequestId() { 21 | return requestId; 22 | } 23 | 24 | public void setRequestId(String requestId) { 25 | this.requestId = requestId; 26 | } 27 | 28 | public String getClassName() { 29 | return className; 30 | } 31 | 32 | public void setClassName(String className) { 33 | this.className = className; 34 | } 35 | 36 | public String getMethodName() { 37 | return methodName; 38 | } 39 | 40 | public void setMethodName(String methodName) { 41 | this.methodName = methodName; 42 | } 43 | 44 | public Class[] getParameterTypes() { 45 | return parameterTypes; 46 | } 47 | 48 | public void setParameterTypes(Class[] parameterTypes) { 49 | this.parameterTypes = parameterTypes; 50 | } 51 | 52 | public Object[] getParameters() { 53 | return parameters; 54 | } 55 | 56 | public void setParameters(Object[] parameters) { 57 | this.parameters = parameters; 58 | } 59 | 60 | public int getMaxExecutesCount() { 61 | return maxExecutesCount; 62 | } 63 | 64 | public void setMaxExecutesCount(int maxExecutesCount) { 65 | this.maxExecutesCount = maxExecutesCount; 66 | } 67 | 68 | public Map getContextParameters() { 69 | return contextParameters; 70 | } 71 | 72 | public void setContextParameters(Map contextParameters) { 73 | this.contextParameters = contextParameters; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /jim-framework-rpc/src/main/java/com/jim/framework/rpc/client/RpcClient.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.client; 2 | 3 | import com.jim.framework.rpc.common.RpcURL; 4 | import com.jim.framework.rpc.config.ReferenceConfig; 5 | import com.jim.framework.rpc.loadbalance.LoadbalanceService; 6 | import com.jim.framework.rpc.loadbalance.RoundRobinLoadbalanceService; 7 | import com.jim.framework.rpc.proxy.RpcProxy; 8 | import com.jim.framework.rpc.registry.ConsulDiscoveryService; 9 | import com.jim.framework.rpc.registry.DiscoveryService; 10 | import org.slf4j.Logger; 11 | import org.slf4j.LoggerFactory; 12 | 13 | import java.lang.reflect.Proxy; 14 | import java.util.List; 15 | 16 | /** 17 | RPC 客户端 18 | 目前只是简单的获取远程接口代理 19 | 后续扩展更多功能 TODO 20 | * Created by jiang on 2017/5/10. 21 | */ 22 | public class RpcClient { 23 | 24 | private static final Logger logger = LoggerFactory.getLogger(RpcClient.class); 25 | 26 | private ReferenceConfig referenceConfig; 27 | 28 | private static LoadbalanceService loadbalanceService=new RoundRobinLoadbalanceService(); 29 | 30 | public RpcClient(ReferenceConfig referenceConfig) { 31 | this.referenceConfig=referenceConfig; 32 | DiscoveryService discoveryService=new ConsulDiscoveryService(); 33 | List urls=discoveryService.getUrls(referenceConfig.getRegistryHost(),referenceConfig.getRegistryPort()); 34 | int size=urls.size(); 35 | int index = loadbalanceService.index(size); 36 | logger.info("RpcClient init"); 37 | RpcURL url= urls.get(index); 38 | this.referenceConfig.setHost(url.getHost()); 39 | this.referenceConfig.setPort(url.getPort()); 40 | 41 | } 42 | 43 | @SuppressWarnings("unchecked") 44 | public T createProxy(Class interfaceClass,RpcReference reference) { 45 | return (T) Proxy.newProxyInstance( 46 | interfaceClass.getClassLoader(), 47 | new Class[]{interfaceClass}, 48 | new RpcProxy(interfaceClass,this.referenceConfig,reference) 49 | ); 50 | } 51 | } 52 | 53 | -------------------------------------------------------------------------------- /jim-framework-web/src/main/java/com/jim/framework/web/controller/ProductController.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.web.controller; 2 | 3 | import com.jim.framework.configcenter.factory.ConfigCenterFactory; 4 | import com.jim.framework.web.common.ValueResult; 5 | import com.jim.framework.web.dao.generated.entity.Product; 6 | import com.jim.framework.web.service.ProductService; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.beans.factory.annotation.Value; 9 | import org.springframework.web.bind.annotation.PathVariable; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RestController; 12 | 13 | import java.net.UnknownHostException; 14 | 15 | /** 16 | * Created by jiang on 2016/12/5. 17 | */ 18 | @RestController 19 | @RequestMapping("/product") 20 | public class ProductController extends BaseController { 21 | 22 | @Autowired 23 | private ProductService productService; 24 | 25 | @Value("${mq.rabbit.host}") 26 | private String rabbitHost; 27 | 28 | 29 | @RequestMapping("/config") 30 | public ValueResult config(){ 31 | String testConfig= ConfigCenterFactory.getInstance().getConfig().get("foo"); 32 | return this.returnValueSuccess(testConfig+this.rabbitHost); 33 | } 34 | 35 | @RequestMapping("/{productId}") 36 | public ValueResult getById(@PathVariable final long productId) throws UnknownHostException { 37 | Product result= this.productService.getById(productId); 38 | return this.returnValueSuccess(result); 39 | 40 | } 41 | @RequestMapping("/save/{productId}") 42 | public ValueResult save(@PathVariable final long productId) throws UnknownHostException { 43 | 44 | Product product=new Product(); 45 | product.setId(productId); 46 | product.setName("jim-product-"+productId); 47 | this.productService.save(product); 48 | return this.returnValueSuccess("success"); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /jim-framework-dubbo-consumer/src/main/java/com/jim/framework/dubbo/consumer/controller/ProductController.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.dubbo.consumer.controller; 2 | 3 | import com.alibaba.dubbo.rpc.RpcContext; 4 | import com.google.common.base.Stopwatch; 5 | import com.jim.framework.dubbo.core.model.Product; 6 | import com.jim.framework.dubbo.core.service.ProductService; 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.web.bind.annotation.PathVariable; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | import org.springframework.web.bind.annotation.RestController; 13 | 14 | import java.net.UnknownHostException; 15 | import java.util.concurrent.ExecutionException; 16 | import java.util.concurrent.TimeUnit; 17 | 18 | /** 19 | * Created by jiang on 2017/3/28. 20 | */ 21 | @RestController 22 | @RequestMapping("/product") 23 | public class ProductController { 24 | 25 | private final static Logger logger = LoggerFactory.getLogger(ProductController.class); 26 | 27 | @Autowired 28 | private ProductService productService; 29 | 30 | @RequestMapping("/{productId}") 31 | public Product getById(@PathVariable final long productId) throws UnknownHostException { 32 | logger.info("ProductController.getById"); 33 | Stopwatch stopwatch=Stopwatch.createStarted(); 34 | Product product= this.productService.getByid(productId); 35 | stopwatch.stop(); 36 | logger.info("time:"+String.valueOf(stopwatch.elapsed(TimeUnit.MILLISECONDS))); 37 | // Product product2= this.productService.getByid(productId*2); 38 | // try { 39 | // Product product3= (Product) RpcContext.getContext().getFuture().get(); 40 | // System.out.println();product3.getId(); 41 | // return product3; 42 | // } catch (InterruptedException e) { 43 | // e.printStackTrace(); 44 | // } catch (ExecutionException e) { 45 | // e.printStackTrace(); 46 | // } 47 | 48 | return product; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /jim-framework-rpc-provider/src/main/java/com/jim/framework/rpc/provider/config/ProviderConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.provider.config; 2 | 3 | import com.jim.framework.rpc.config.ServiceConfig; 4 | import com.jim.framework.rpc.server.RpcServer; 5 | import com.jim.framework.rpc.server.RpcServerInitializer; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.context.annotation.Bean; 10 | import org.springframework.context.annotation.ComponentScan; 11 | import org.springframework.context.annotation.Configuration; 12 | 13 | import java.net.InetAddress; 14 | import java.net.UnknownHostException; 15 | 16 | @ComponentScan(basePackages = {"com.jim.framework.rpc.provider","com.jim.framework.rpc"}) 17 | @Configuration 18 | public class ProviderConfiguration { 19 | 20 | private final static Logger logger = LoggerFactory.getLogger(ProviderConfiguration.class); 21 | 22 | @Bean 23 | @Autowired 24 | public RpcServer rpcServer(RpcServerInitializer rpcServerInitializer){ 25 | logger.info("begin to start"); 26 | ServiceConfig serviceConfig=new ServiceConfig(); 27 | InetAddress address=null; 28 | try { 29 | address = InetAddress.getLocalHost(); 30 | } catch (UnknownHostException e) { 31 | e.printStackTrace(); 32 | } 33 | String host="127.0.0.1"; 34 | if(null!=address){ 35 | host=address.getHostAddress(); 36 | } 37 | serviceConfig.setHost(host); 38 | serviceConfig.setPort(9988); 39 | //serviceConfig.setRegistryHost("192.168.237.128"); 40 | serviceConfig.setRegistryHost("127.0.0.1"); 41 | serviceConfig.setRegistryPort(8500); 42 | RpcServer rpcServer= new RpcServer(serviceConfig,rpcServerInitializer); 43 | logger.info("service is started"); 44 | return rpcServer; 45 | } 46 | 47 | @Bean 48 | public RpcServerInitializer rpcServerInitializer(){ 49 | return new RpcServerInitializer(); 50 | } 51 | 52 | 53 | 54 | } 55 | -------------------------------------------------------------------------------- /jim-framework-web/src/main/java/com/jim/framework/web/config/MyBatisMapperScannerConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014-2016 abel533@gmail.com 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | package com.jim.framework.web.config; 26 | 27 | import org.springframework.boot.autoconfigure.AutoConfigureAfter; 28 | import org.springframework.context.annotation.Bean; 29 | import org.springframework.context.annotation.Configuration; 30 | import tk.mybatis.spring.mapper.MapperScannerConfigurer; 31 | 32 | @Configuration 33 | @AutoConfigureAfter(MyBatisConfig.class) 34 | public class MyBatisMapperScannerConfig { 35 | 36 | @Bean 37 | public MapperScannerConfigurer mapperScannerConfigurer() { 38 | MapperScannerConfigurer mapperScannerConfigurer = new MapperScannerConfigurer(); 39 | mapperScannerConfigurer.setSqlSessionFactoryBeanName("sqlSessionFactory"); 40 | mapperScannerConfigurer.setBasePackage("com.jim.framework.web.dao.generated.mapper"); 41 | 42 | return mapperScannerConfigurer; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /jim-framework-web/src/main/java/com/jim/framework/web/service/impl/StudentServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.web.service.impl; 2 | 3 | import com.google.common.collect.Lists; 4 | import com.jim.framework.web.model.Student; 5 | import com.jim.framework.web.service.BaseService; 6 | import com.jim.framework.web.service.StudentService; 7 | import org.springframework.cache.annotation.Cacheable; 8 | import org.springframework.stereotype.Service; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * Created by jiang on 2016/12/11. 14 | */ 15 | @Service 16 | public class StudentServiceImpl extends BaseService implements StudentService { 17 | 18 | //@Autowired 19 | //private StudentRepository studentRepository; 20 | 21 | @Cacheable(value = "StudentService.getById") 22 | @Override 23 | public Student getById(Long id) { 24 | return this.getByIdCache(id); 25 | } 26 | 27 | //@Cacheable(value = "StudentService.getById") 28 | public Student getByIdCache(Long id) { 29 | this.logger.info("get student from es"); 30 | //return studentRepository.findOne(id); 31 | return new Student(); 32 | } 33 | 34 | @Override 35 | public Student save(Student student) { 36 | //return studentRepository.save(student); 37 | return new Student(); 38 | } 39 | 40 | public List search(String name,int page, int size){ 41 | 42 | // BoolQueryBuilder keyQueryBuilder= QueryBuilders.boolQuery(); 43 | // MatchQueryBuilder idQueryBuild=QueryBuilders.matchQuery("title",name); 44 | // MatchQueryBuilder nameQueryBuild=QueryBuilders.matchQuery("name",name); 45 | // keyQueryBuilder.should(idQueryBuild); 46 | // keyQueryBuilder.should(nameQueryBuild); 47 | 48 | // Page students=this.studentRepository.search(keyQueryBuilder,new PageRequest(page,size)); 49 | // 50 | // return students.getContent(); 51 | 52 | return Lists.newArrayList(); 53 | } 54 | 55 | @Override 56 | public Long getCount() { 57 | //return this.studentRepository.count(); 58 | return 0L; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /jim-framework-rpc/src/main/java/com/jim/framework/rpc/threadpool/FixedRpcThreadPool.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.rpc.threadpool; 2 | 3 | import com.jim.framework.rpc.exception.RpcException; 4 | import org.springframework.beans.factory.annotation.Qualifier; 5 | import org.springframework.stereotype.Component; 6 | 7 | import java.util.concurrent.*; 8 | 9 | /** 10 | * Created by Administrator on 2017/7/2/002. 11 | */ 12 | @Qualifier("fixedRpcThreadPool") 13 | @Component 14 | public class FixedRpcThreadPool implements RpcThreadPool { 15 | 16 | private Executor executor; 17 | 18 | @Override 19 | public Executor getExecutor(int threadSize,int queues) { 20 | if(null==executor) { 21 | synchronized (this) { 22 | if(null==executor) { 23 | executor= new ThreadPoolExecutor(threadSize, threadSize, 0L, TimeUnit.MILLISECONDS, 24 | queues == 0 ? new SynchronousQueue() : 25 | (queues < 0 ? new LinkedBlockingQueue() 26 | : new LinkedBlockingQueue(queues)), 27 | new RejectedExecutionHandler() { 28 | @Override 29 | public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) { 30 | String msg = String.format("Thread pool is rejected!" + 31 | " Thread Name: %s, Pool Size: %d (active: %d, core: %d, max: %d, largest: %d), Task: %d (completed: %d),", 32 | Thread.currentThread().getName(), executor.getPoolSize(), executor.getActiveCount(), executor.getCorePoolSize(), executor.getMaximumPoolSize(), executor.getLargestPoolSize(), 33 | executor.getTaskCount(), executor.getCompletedTaskCount()); 34 | throw new RpcException(msg); 35 | } 36 | }); 37 | } 38 | } 39 | } 40 | return executor; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /jim-framework-lock/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.jim.framework 7 | annotationlock 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | com.jim.framework.annotationlock 12 | AnnotationLock 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 2.0.0.RELEASE 18 | 19 | 20 | 21 | 22 | UTF-8 23 | UTF-8 24 | 1.8 25 | 26 | 18.0 27 | 3.2.1 28 | 29 | 30 | 31 | 32 | org.springframework.boot 33 | spring-boot-starter-aop 34 | 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-starter-test 39 | test 40 | 41 | 42 | 43 | com.google.guava 44 | guava 45 | ${guava.version} 46 | 47 | 48 | org.apache.commons 49 | commons-lang3 50 | ${commons.lang.version} 51 | 52 | 53 | org.redisson 54 | redisson 55 | 3.2.3 56 | 57 | 58 | 59 | 60 | 61 | 62 | org.springframework.boot 63 | spring-boot-maven-plugin 64 | 65 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /jim-framework-activemq/src/main/java/com/jim/framework/activemq/config/QueueJmsTemplateContainer.java: -------------------------------------------------------------------------------- 1 | package com.jim.framework.activemq.config; 2 | 3 | import org.springframework.jms.core.JmsTemplate; 4 | 5 | import java.util.Map; 6 | import java.util.concurrent.ConcurrentHashMap; 7 | 8 | /** 9 | * Created by jiangmin on 2018/1/27. 10 | */ 11 | public class QueueJmsTemplateContainer { 12 | 13 | private static volatile boolean needToRefresh; 14 | 15 | private static Map queJmsTemplateMap=new ConcurrentHashMap<>(); 16 | 17 | public static void setNeedToRefresh(boolean needToRefresh){ 18 | QueueJmsTemplateContainer.needToRefresh=needToRefresh; 19 | } 20 | 21 | public static JmsTemplate getJmsTemplateByQueue(String queueName){ 22 | while (QueueJmsTemplateContainer.needToRefresh){ 23 | try { 24 | Thread.sleep(50); 25 | //System.out.println("peeding to refresh"); 26 | } catch (Exception e) { 27 | e.printStackTrace(); 28 | } 29 | } 30 | 31 | if(queJmsTemplateMap.containsKey(queueName)){ 32 | return queJmsTemplateMap.get(queueName); 33 | } 34 | return null; 35 | } 36 | 37 | public static void setQueJmsTemplateMap(String queueName,JmsTemplate jmsTemplate){ 38 | setQueJmsTemplateMap(queueName,jmsTemplate,false); 39 | } 40 | 41 | public static void setQueJmsTemplateMap(String queueName,JmsTemplate jmsTemplate,boolean needToRefresh){ 42 | QueueJmsTemplateContainer.needToRefresh=needToRefresh; 43 | if(!queJmsTemplateMap.containsKey(queueName)){ 44 | queJmsTemplateMap.put(queueName,jmsTemplate); 45 | QueueJmsTemplateContainer.needToRefresh=false; 46 | } 47 | else { 48 | JmsTemplate jmsTemplateOld=queJmsTemplateMap.get(queueName); 49 | if(QueueJmsTemplateContainer.needToRefresh&& null!=jmsTemplateOld){ 50 | //ConnectionFactoryContainer.stopProducerConnectionFactory(); 51 | queJmsTemplateMap.clear(); 52 | queJmsTemplateMap.put(queueName,jmsTemplate); 53 | QueueJmsTemplateContainer.needToRefresh=false; 54 | } 55 | } 56 | 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /jim-framework-rpc-consumer/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.jim.framework 7 | rpc.consumer 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | com.jim.framework.rpc.consumer 12 | Demo project for Spring Boot 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 2.0.0.RELEASE 18 | 19 | 20 | 21 | 22 | UTF-8 23 | UTF-8 24 | 1.8 25 | 26 | 27 | 28 | 29 | 30 | 31 | com.jim.framework 32 | rpc 33 | 0.0.1-SNAPSHOT 34 | 35 | 36 | 37 | com.jim.framework 38 | rpc.api 39 | 0.0.1-SNAPSHOT 40 | 41 | 42 | 43 | org.springframework.boot 44 | spring-boot-starter-web 45 | 46 | 47 | 48 | org.springframework.boot 49 | spring-boot-starter-test 50 | test 51 | 52 | 53 | 54 | 55 | 56 | 57 | org.springframework.boot 58 | spring-boot-maven-plugin 59 | 60 | 61 | 62 | 63 | 64 | 65 | spring-milestones 66 | Spring Milestones 67 | https://repo.spring.io/milestone 68 | 69 | false 70 | 71 | 72 | 73 | 74 | 75 | 76 | --------------------------------------------------------------------------------