├── jeesuite-common ├── README.md ├── .gitignore ├── src │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── jeesuite │ │ │ └── common │ │ │ ├── packagescan │ │ │ ├── SimpleWildcardPatternFactory.java │ │ │ ├── PatternFactory.java │ │ │ ├── CompiledPattern.java │ │ │ └── SimpleWildcardPattern.java │ │ │ ├── serializer │ │ │ ├── Serializer.java │ │ │ ├── SerializeUtils.java │ │ │ ├── KryoSerializer.java │ │ │ ├── JavaSerializer.java │ │ │ └── FSTSerializer.java │ │ │ ├── model │ │ │ └── SelectOption.java │ │ │ ├── JeesuiteBaseException.java │ │ │ ├── util │ │ │ ├── NodeNameHolder.java │ │ │ ├── SimpleCryptUtils.java │ │ │ ├── WhoUseMeReporter.java │ │ │ ├── AssertUtil.java │ │ │ ├── HashUtils.java │ │ │ └── StringCharsetUtils.java │ │ │ ├── json │ │ │ ├── serializer │ │ │ │ ├── DateTimeConvertSerializer.java │ │ │ │ └── DateConvertSerializer.java │ │ │ └── deserializer │ │ │ │ ├── DateTimeConvertDeserializer.java │ │ │ │ └── DateConvertDeserializer.java │ │ │ ├── http │ │ │ └── HttpResponseEntity.java │ │ │ └── crypt │ │ │ ├── AES.java │ │ │ └── SHA1.java │ └── test │ │ └── java │ │ └── test │ │ ├── BeanUtilTest.java │ │ ├── serlalize │ │ └── SerliazePerfTest.java │ │ └── BaseUser.java └── jeesuite-common.iml ├── jeesuite-common2 ├── README.md ├── .gitignore └── src │ ├── test │ ├── java │ │ └── test │ │ │ ├── lock │ │ │ ├── ShareResource.java │ │ │ ├── ZkDistributeLockTest.java │ │ │ └── RedisDistributeLockTest.java │ │ │ ├── sequence │ │ │ └── IdGenerateTest.java │ │ │ └── excel │ │ │ ├── ExcelTest.java │ │ │ └── SimpleSalaryInfo.java │ └── resources │ │ ├── config.properties │ │ └── log4j2.xml │ └── main │ └── java │ └── com │ └── jeesuite │ └── common2 │ ├── sequence │ └── IdGenerator.java │ ├── excel │ ├── ResultProcessor.java │ ├── ExcelOperBaseException.java │ ├── annotation │ │ └── TitleCell.java │ └── helper │ │ └── ExcelValidator.java │ └── lock │ ├── LockCaller.java │ ├── LockException.java │ └── DistributeLockTemplate.java ├── jeesuite-rest ├── .gitignore ├── .settings │ ├── org.eclipse.wst.validation.prefs │ ├── org.eclipse.m2e.core.prefs │ ├── org.eclipse.wst.common.project.facet.core.xml │ ├── org.eclipse.core.resources.prefs │ ├── org.eclipse.wst.common.component │ └── org.eclipse.jdt.core.prefs └── src │ └── main │ └── java │ └── com │ └── jeesuite │ └── rest │ ├── response │ ├── HttpCodeType.java │ └── ResponseCode.java │ ├── RequestHeader.java │ ├── filter │ ├── annotation │ │ ├── AuthIgnore.java │ │ ├── LogIgnore.java │ │ └── ResponseFormat.java │ ├── FilterHandler.java │ ├── RequestHeaderHolder.java │ ├── FilterConfig.java │ ├── DefaultFilterDynamicFeature.java │ └── handler │ │ ├── CorsHandler.java │ │ └── ResponseWrapperHandler.java │ ├── excetion │ └── ExcetionWrapper.java │ ├── CustomConfig.java │ ├── resolver │ └── ObjectMapperResolver.java │ └── BaseApplicaionConfig.java ├── jeesuite-cache ├── .gitignore ├── src │ ├── test │ │ ├── resources │ │ │ ├── redis.properties │ │ │ ├── log4j2.xml │ │ │ └── ehcache.xml │ │ └── java │ │ │ └── com │ │ │ └── jeesuite │ │ │ └── test │ │ │ └── cache │ │ │ └── SentinelFailOverTest.java │ └── main │ │ └── java │ │ └── com │ │ └── jeesuite │ │ └── cache │ │ ├── redis │ │ └── JedisProvider.java │ │ ├── local │ │ └── Level1CacheProvider.java │ │ ├── CacheExpires.java │ │ └── command │ │ └── RedisBinaryCollection.java ├── jeesuite-cache.iml └── pom.xml ├── jeesuite-kafka ├── .gitignore └── src │ ├── main │ └── java │ │ └── com │ │ └── jeesuite │ │ └── kafka │ │ ├── consumer │ │ ├── TopicConsumer.java │ │ └── hanlder │ │ │ ├── RetryErrorMessageHandler.java │ │ │ └── OffsetLogHanlder.java │ │ ├── monitor │ │ └── model │ │ │ ├── ConsumerNodeInfo.java │ │ │ └── BrokerInfo.java │ │ ├── serializer │ │ ├── ZKStringSerializer.java │ │ ├── JdkMessageDeserializer.java │ │ ├── KyroMessageDeserializer.java │ │ ├── MessageDecoder.java │ │ ├── JdkMessageSerializer.java │ │ ├── KyroMessageSerializer.java │ │ └── JsonMessageDeserializer.java │ │ ├── producer │ │ ├── handler │ │ │ └── ProducerEventHandler.java │ │ ├── TopicProducer.java │ │ └── ConsumerAckWatcher.java │ │ ├── annotation │ │ └── ConsumerHandler.java │ │ ├── handler │ │ └── MessageHandler.java │ │ └── KafkaConst.java │ └── test │ ├── resources │ ├── kafka.properties │ ├── log4j2.xml │ └── test-kafka-producer.xml │ └── java │ ├── com │ └── jeesuite │ │ └── test │ │ ├── MysqlOffsetLogHanlder.java │ │ ├── Demo2MessageHandler.java │ │ ├── ConsumerServer2.java │ │ ├── DemoMessageHandler.java │ │ ├── RunClass.java │ │ ├── ZkClientTest.java │ │ ├── ConsumerServer.java │ │ └── SimpleComsumer.java │ └── test │ └── StandardThreadExecutorTest.java ├── jeesuite-log ├── .gitignore ├── src │ └── main │ │ └── java │ │ └── com │ │ └── jeesuite │ │ └── log │ │ ├── Log.java │ │ ├── log4j2 │ │ └── LogConfigLookup.java │ │ └── LogFactory.java └── pom.xml ├── jeesuite-mybatis ├── .gitignore ├── src │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── jeesuite │ │ │ │ └── mybatis │ │ │ │ ├── datasource │ │ │ │ ├── DataSourceType.java │ │ │ │ └── builder │ │ │ │ │ └── HikariCPDataSourceBuilder.java │ │ │ │ ├── package-info.java │ │ │ │ ├── exception │ │ │ │ └── MybatisHanlerInitException.java │ │ │ │ ├── crud │ │ │ │ ├── CrudMethodDefine.java │ │ │ │ ├── helper │ │ │ │ │ ├── TableMapper.java │ │ │ │ │ └── ColumnMapper.java │ │ │ │ ├── name │ │ │ │ │ ├── DefaultCrudMethodDefine.java │ │ │ │ │ └── Mapper3CrudMethodDefine.java │ │ │ │ └── builder │ │ │ │ │ └── SqlTemplate.java │ │ │ │ ├── core │ │ │ │ ├── BaseEntity.java │ │ │ │ ├── InterceptorHandler.java │ │ │ │ └── BaseMapper.java │ │ │ │ ├── plugin │ │ │ │ ├── shard │ │ │ │ │ ├── annotation │ │ │ │ │ │ └── DbShardKey.java │ │ │ │ │ ├── ShardStrategy.java │ │ │ │ │ └── TableRouteHandler.java │ │ │ │ ├── pagination │ │ │ │ │ ├── annotation │ │ │ │ │ │ └── Pageable.java │ │ │ │ │ ├── PageParams.java │ │ │ │ │ ├── Page.java │ │ │ │ │ └── PageExecutor.java │ │ │ │ ├── cache │ │ │ │ │ ├── CacheProvider.java │ │ │ │ │ ├── provider │ │ │ │ │ │ └── AbstractCacheProvider.java │ │ │ │ │ └── annotation │ │ │ │ │ │ └── Cache.java │ │ │ │ └── rwseparate │ │ │ │ │ └── UseMaster.java │ │ │ │ ├── kit │ │ │ │ └── SqlParseUtils.java │ │ │ │ └── spring │ │ │ │ └── MybatisPluginBaseSpringInterceptor.java │ │ └── resources │ │ │ └── mybatis-configuration.xml │ └── test │ │ ├── resources │ │ ├── redis.properties │ │ ├── log4j2.xml │ │ └── mysql.properties │ │ └── java │ │ └── com │ │ └── jeesuite │ │ └── mybatis │ │ └── test │ │ └── mapper │ │ └── SnsAccounyBindingEntityMapper.java └── jeesuite-mybatis.iml ├── jeesuite-spring ├── .gitignore └── src │ └── main │ └── java │ └── com │ └── jeesuite │ └── spring │ ├── ApplicationStartedListener.java │ ├── InstanceFactoryConfiguration.java │ └── web │ └── ContextLoaderListener.java ├── jeesuite-filesystem ├── .gitignore ├── src │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── jeesuite │ │ │ └── filesystem │ │ │ ├── provider │ │ │ ├── qiniu │ │ │ │ └── UploadResult.java │ │ │ ├── FSOperErrorException.java │ │ │ └── AbstractProvider.java │ │ │ ├── utils │ │ │ ├── HttpDownloader.java │ │ │ ├── FilePathHelper.java │ │ │ └── MimeTypeFileExtensionConvert.java │ │ │ └── FSProvider.java │ └── test │ │ ├── java │ │ └── test │ │ │ └── FileSystemClientTest.java │ │ └── resources │ │ ├── log4j2.xml │ │ └── fs.properties └── jeesuite-filesystem.iml ├── jeesuite-scheduler ├── .gitignore └── src │ ├── main │ └── java │ │ └── com │ │ └── jeesuite │ │ └── scheduler │ │ ├── JobLogPersistHandler.java │ │ ├── ConfigPersistHandler.java │ │ ├── annotation │ │ └── ScheduleConf.java │ │ ├── model │ │ └── JobGroupInfo.java │ │ ├── JobRegistry.java │ │ └── monitor │ │ └── MonitorCommond.java │ └── test │ ├── resources │ └── log4j2.xml │ └── java │ └── com │ └── jeesuite │ └── test │ └── sch │ ├── DbConfigPersistHandler.java │ ├── DemoTask2.java │ ├── JobInterceptor.java │ ├── DemoParallelTask.java │ ├── DemoTask.java │ ├── TaskServerNode1.java │ └── TaskServerNode2.java ├── jeesuite-springboot-starter ├── .gitignore └── src │ └── main │ ├── resources │ └── META-INF │ │ ├── spring.provides │ │ └── spring.factories │ └── java │ └── com │ └── jeesuite │ └── springboot │ └── starter │ ├── cache │ └── EnableJeesuiteCache.java │ ├── scheduler │ ├── EnableJeesuiteSchedule.java │ └── SchedulerProperties.java │ ├── kafka │ ├── EnableJeesuiteKafkaConsumer.java │ ├── EnableJeesuiteKafkaProducer.java │ └── DelegateKafkaProducerConfiguration.java │ └── mybatis │ ├── EnableJeesuiteMybatis.java │ └── JeesuiteDataSourceConfiguration.java ├── jeesuite-security ├── src │ └── main │ │ └── java │ │ └── com │ │ └── jeesuite │ │ └── security │ │ ├── Cache.java │ │ ├── exception │ │ ├── UserNotFoundException.java │ │ └── UserPasswordWrongException.java │ │ ├── model │ │ ├── AccessToken.java │ │ └── BaseUserInfo.java │ │ ├── SecurityTicketManager.java │ │ ├── util │ │ └── SecurityCryptUtils.java │ │ └── cache │ │ └── LocalCache.java └── pom.xml ├── jeesuite-springweb ├── src │ └── main │ │ └── java │ │ └── com │ │ └── jeesuite │ │ └── springweb │ │ ├── annotation │ │ └── ResponsePolicy.java │ │ ├── exception │ │ ├── UnauthorizedException.java │ │ └── ForbiddenAccessException.java │ │ ├── model │ │ ├── WrapperResponseEntity.java │ │ └── WrapperResponse.java │ │ ├── client │ │ ├── RestTemplateAutoHeaderInterceptor.java │ │ └── SimpleRestTemplateBuilder.java │ │ ├── WebConstants.java │ │ ├── base │ │ └── CustomServletInputStreamWrapper.java │ │ └── RequestContextHelper.java └── pom.xml ├── jeesuite-search └── src │ └── main │ └── java │ └── test │ └── User.java ├── jeesuite-event ├── pom.xml ├── src │ └── main │ │ └── java │ │ └── com │ │ └── jeesuite │ │ └── event │ │ ├── EventPublisher.java │ │ └── EventSubscriber.java └── jeesuite-event.iml └── CHANGE-LOG.md /jeesuite-common/README.md: -------------------------------------------------------------------------------- 1 | 待续 -------------------------------------------------------------------------------- /jeesuite-common2/README.md: -------------------------------------------------------------------------------- 1 | 待续 -------------------------------------------------------------------------------- /jeesuite-rest/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /jeesuite-cache/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | .DS_Store 3 | /.settings/ 4 | .project 5 | .classpath 6 | -------------------------------------------------------------------------------- /jeesuite-common/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | .DS_Store 3 | /.settings/ 4 | .project 5 | .classpath 6 | -------------------------------------------------------------------------------- /jeesuite-common2/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | .DS_Store 3 | /.settings/ 4 | .project 5 | .classpath 6 | -------------------------------------------------------------------------------- /jeesuite-kafka/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | .DS_Store 3 | /.settings/ 4 | .project 5 | .classpath 6 | -------------------------------------------------------------------------------- /jeesuite-log/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | .DS_Store 3 | /.settings/ 4 | .project 5 | .classpath 6 | -------------------------------------------------------------------------------- /jeesuite-mybatis/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | .DS_Store 3 | /.settings/ 4 | .project 5 | .classpath 6 | -------------------------------------------------------------------------------- /jeesuite-spring/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | .DS_Store 3 | /.settings/ 4 | .project 5 | .classpath 6 | -------------------------------------------------------------------------------- /jeesuite-filesystem/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | .DS_Store 3 | /.settings/ 4 | .project 5 | .classpath 6 | -------------------------------------------------------------------------------- /jeesuite-scheduler/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | .DS_Store 3 | /.settings/ 4 | .project 5 | .classpath 6 | -------------------------------------------------------------------------------- /jeesuite-rest/.settings/org.eclipse.wst.validation.prefs: -------------------------------------------------------------------------------- 1 | disabled=06target 2 | eclipse.preferences.version=1 3 | -------------------------------------------------------------------------------- /jeesuite-springboot-starter/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | .DS_Store 3 | /.settings/ 4 | .project 5 | .classpath 6 | -------------------------------------------------------------------------------- /jeesuite-springboot-starter/src/main/resources/META-INF/spring.provides: -------------------------------------------------------------------------------- 1 | provides: mybatis-spring-boot-autoconfigure,mybatis,mybatis-spring 2 | -------------------------------------------------------------------------------- /jeesuite-rest/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /jeesuite-mybatis/src/main/java/com/jeesuite/mybatis/datasource/DataSourceType.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.mybatis.datasource; 2 | 3 | public enum DataSourceType { 4 | 5 | Druid,HikariCP 6 | } 7 | -------------------------------------------------------------------------------- /jeesuite-kafka/src/main/java/com/jeesuite/kafka/consumer/TopicConsumer.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.kafka.consumer; 2 | 3 | public interface TopicConsumer { 4 | 5 | void start() ; 6 | 7 | void close(); 8 | } 9 | -------------------------------------------------------------------------------- /jeesuite-common2/src/test/java/test/lock/ShareResource.java: -------------------------------------------------------------------------------- 1 | package test.lock; 2 | 3 | public class ShareResource { 4 | 5 | static int count = 0; 6 | public static int add(){ 7 | count++; 8 | return count; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /jeesuite-mybatis/src/main/java/com/jeesuite/mybatis/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | /** 5 | * @description
6 | * @author vakin 7 | * @date 2016年7月4日 8 | */ 9 | package com.jeesuite.mybatis; -------------------------------------------------------------------------------- /jeesuite-rest/.settings/org.eclipse.wst.common.project.facet.core.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /jeesuite-rest/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=utf-8 3 | encoding//src/main/resources=UTF-8 4 | encoding//src/test/java=utf-8 5 | encoding//src/test/resources=UTF-8 6 | encoding/=UTF-8 7 | -------------------------------------------------------------------------------- /jeesuite-springboot-starter/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | # Auto Configure 2 | #org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ 3 | #com.jeesuite.springboot.starter.mybatis.JeesuiteMybatisConfiguration,\ 4 | #com.jeesuite.springboot.starter.cache.DelegateCacheConfiguration 5 | -------------------------------------------------------------------------------- /jeesuite-common2/src/test/resources/config.properties: -------------------------------------------------------------------------------- 1 | jeesuite.lock.redis.mode=standalone 2 | jeesuite.lock.redis.servers=127.0.0.1:6379 3 | jeesuite.lock.redis.maxPoolSize=10 4 | jeesuite.lock.redis.maxPoolIdle=2 5 | jeesuite.lock.redis.minPoolIdle=1 6 | jeesuite.lock.redis.maxPoolWaitMillis=30000 7 | jeesuite.lock.redis.password=123456 -------------------------------------------------------------------------------- /jeesuite-kafka/src/main/java/com/jeesuite/kafka/monitor/model/ConsumerNodeInfo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.kafka.monitor.model; 5 | 6 | /** 7 | * @description
8 | * @author vakin 9 | * @date 2016年10月28日 10 | */ 11 | public class ConsumerNodeInfo { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /jeesuite-rest/src/main/java/com/jeesuite/rest/response/HttpCodeType.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.rest.response; 2 | 3 | public interface HttpCodeType { 4 | 5 | /** 6 | * 获取异常代码 7 | * 8 | * @return 9 | */ 10 | public int getCode(); 11 | 12 | /** 13 | * 获取异常信息 14 | * 15 | * @return 16 | */ 17 | public String getMsg(); 18 | } 19 | -------------------------------------------------------------------------------- /jeesuite-cache/src/test/resources/redis.properties: -------------------------------------------------------------------------------- 1 | #mode(standalone,sentinel,cluster,shard) 2 | redis.mode=standalone 3 | redis.servers=127.0.0.1:7369 4 | redis.conn.timeout=3000 5 | #redis.password=123456 6 | redis.database= 7 | redis.clientName= 8 | redis.masterName=master6379 9 | 10 | #pool 11 | redis.pool.maxTotal=20 12 | redis.pool.maxIdle=5 13 | redis.pool.minIdle=1 14 | -------------------------------------------------------------------------------- /jeesuite-mybatis/src/test/resources/redis.properties: -------------------------------------------------------------------------------- 1 | #mode(standalone,sentinel,cluster,shard) 2 | redis.mode=standalone 3 | redis.servers=127.0.0.1:6379 4 | redis.conn.timeout=3000 5 | redis.password=123456 6 | redis.database= 7 | redis.clientName= 8 | redis.masterName=master6379 9 | 10 | #pool 11 | redis.pool.maxTotal=20 12 | redis.pool.maxIdle=5 13 | redis.pool.minIdle=1 14 | -------------------------------------------------------------------------------- /jeesuite-common2/src/main/java/com/jeesuite/common2/sequence/IdGenerator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.common2.sequence; 5 | 6 | /** 7 | * @description
8 | * @author vakin 9 | * @date 2016年11月18日 10 | */ 11 | public interface IdGenerator { 12 | 13 | public long nextId(); 14 | 15 | public void close(); 16 | } 17 | -------------------------------------------------------------------------------- /jeesuite-rest/.settings/org.eclipse.wst.common.component: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /jeesuite-mybatis/src/main/java/com/jeesuite/mybatis/exception/MybatisHanlerInitException.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.mybatis.exception; 2 | 3 | public class MybatisHanlerInitException extends RuntimeException { 4 | 5 | private static final long serialVersionUID = 7823413453457349529L; 6 | 7 | public MybatisHanlerInitException(String message) { 8 | super(message); 9 | } 10 | 11 | 12 | } 13 | -------------------------------------------------------------------------------- /jeesuite-security/src/main/java/com/jeesuite/security/Cache.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.security; 2 | 3 | public interface Cache { 4 | 5 | void setString(String key,String value); 6 | String getString(String key); 7 | void setObject(String key,Object value); 8 | T getObject(String key); 9 | void remove(String key); 10 | void removeAll(); 11 | boolean exists(String key); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /jeesuite-common/src/main/java/com/jeesuite/common/packagescan/SimpleWildcardPatternFactory.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.common.packagescan; 2 | 3 | /** 4 | * Compiles simple wildcard patterns 5 | */ 6 | public class SimpleWildcardPatternFactory implements PatternFactory { 7 | public CompiledPattern compile(String pattern) { 8 | return new SimpleWildcardPattern(pattern); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /jeesuite-kafka/src/test/resources/kafka.properties: -------------------------------------------------------------------------------- 1 | kafka.servers=127.0.0.1:9092 2 | kafka.zkServers=127.0.0.1:2181 3 | kafka.monitor.enable=false 4 | #producer 5 | producer.sync.send=true 6 | producer.acks=1 7 | producer.retries=1 8 | producer.compression.type=gzip 9 | #consumer 10 | consumer.auto.offset.reset=smallest 11 | consumer.poll.timeout.ms=1500 12 | consumer.retries.max=3 13 | consumer.retries.period.seconds=15 -------------------------------------------------------------------------------- /jeesuite-rest/src/main/java/com/jeesuite/rest/RequestHeader.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.rest; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * @description
10 | * @author vakin 11 | * @date 2016年2月25日 12 | */ 13 | public class RequestHeader implements Serializable { 14 | 15 | private static final long serialVersionUID = 1L; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /jeesuite-common2/src/main/java/com/jeesuite/common2/excel/ResultProcessor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.common2.excel; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @description
10 | * @author vakin 11 | * @date 2017年1月18日 12 | */ 13 | public interface ResultProcessor { 14 | 15 | int batchSize(); 16 | void process(List datas); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /jeesuite-common/src/main/java/com/jeesuite/common/packagescan/PatternFactory.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.common.packagescan; 2 | 3 | /** 4 | * Compiles wildcard patterns 5 | */ 6 | public interface PatternFactory { 7 | 8 | /** 9 | * Compiles a wildcard pattern 10 | * @param pattern The original pattern 11 | * @return The compiled pattern 12 | */ 13 | CompiledPattern compile(String pattern); 14 | } 15 | -------------------------------------------------------------------------------- /jeesuite-rest/src/main/java/com/jeesuite/rest/filter/annotation/AuthIgnore.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.rest.filter.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 | 8 | @Target(ElementType.METHOD) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface AuthIgnore { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /jeesuite-rest/src/main/java/com/jeesuite/rest/filter/annotation/LogIgnore.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.rest.filter.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 | 8 | @Target(ElementType.METHOD) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface LogIgnore { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /jeesuite-rest/src/main/java/com/jeesuite/rest/excetion/ExcetionWrapper.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.rest.excetion; 5 | 6 | import com.jeesuite.rest.response.WrapperResponseEntity; 7 | 8 | /** 9 | * @description
10 | * @author vakin 11 | * @date 2016年12月23日 12 | */ 13 | public interface ExcetionWrapper { 14 | 15 | WrapperResponseEntity toResponse(Exception e); 16 | } 17 | -------------------------------------------------------------------------------- /jeesuite-common2/src/main/java/com/jeesuite/common2/lock/LockCaller.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.common2.lock; 5 | 6 | /** 7 | * @description
8 | * @author vakin 9 | * @date 2016年7月22日 10 | */ 11 | public interface LockCaller { 12 | 13 | /** 14 | * 持有锁的操作 15 | * @return 16 | */ 17 | T onHolder(); 18 | 19 | /** 20 | * 等待锁的操作 21 | * @return 22 | */ 23 | T onWait(); 24 | } 25 | -------------------------------------------------------------------------------- /jeesuite-spring/src/main/java/com/jeesuite/spring/ApplicationStartedListener.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.spring; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | 5 | /** 6 | * 应用启动完成监听器接口 7 | * @description
8 | * @author vakin 9 | * @date 2017年11月20日 10 | */ 11 | public interface ApplicationStartedListener { 12 | 13 | void onApplicationStarted(ApplicationContext applicationContext); 14 | } 15 | -------------------------------------------------------------------------------- /jeesuite-springweb/src/main/java/com/jeesuite/springweb/annotation/ResponsePolicy.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.springweb.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 | 8 | @Target({ElementType.METHOD}) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface ResponsePolicy { 11 | String[] value(); 12 | } 13 | -------------------------------------------------------------------------------- /jeesuite-filesystem/src/main/java/com/jeesuite/filesystem/provider/qiniu/UploadResult.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.filesystem.provider.qiniu; 5 | 6 | /** 7 | * 8 | * @description
9 | * @author vakin 10 | * @date 2017年1月5日 11 | */ 12 | public class UploadResult { 13 | public long fsize; 14 | public String key; 15 | public String hash; 16 | public int width; 17 | public int height; 18 | } 19 | -------------------------------------------------------------------------------- /jeesuite-security/src/main/java/com/jeesuite/security/exception/UserNotFoundException.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.security.exception; 2 | 3 | import com.jeesuite.common.JeesuiteBaseException; 4 | 5 | public class UserNotFoundException extends JeesuiteBaseException { 6 | 7 | private static final long serialVersionUID = 1L; 8 | 9 | private static final String MSG = "用户不存在"; 10 | 11 | public UserNotFoundException() { 12 | super(4001,MSG); 13 | } 14 | 15 | 16 | 17 | } 18 | -------------------------------------------------------------------------------- /jeesuite-common2/src/main/java/com/jeesuite/common2/lock/LockException.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.common2.lock; 2 | 3 | import com.jeesuite.common.JeesuiteBaseException; 4 | 5 | public class LockException extends JeesuiteBaseException { 6 | private static final long serialVersionUID = 1L; 7 | 8 | public LockException(String e) { 9 | super(9999,e); 10 | } 11 | 12 | public LockException(Throwable cause) { 13 | super(9999, cause.getMessage(), cause); 14 | } 15 | 16 | 17 | } 18 | -------------------------------------------------------------------------------- /jeesuite-rest/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 4 | org.eclipse.jdt.core.compiler.compliance=1.8 5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 7 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 8 | org.eclipse.jdt.core.compiler.source=1.8 9 | -------------------------------------------------------------------------------- /jeesuite-security/src/main/java/com/jeesuite/security/exception/UserPasswordWrongException.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.security.exception; 2 | 3 | import com.jeesuite.common.JeesuiteBaseException; 4 | 5 | public class UserPasswordWrongException extends JeesuiteBaseException { 6 | 7 | private static final long serialVersionUID = 1L; 8 | 9 | private static final String MSG = "密码错误"; 10 | 11 | public UserPasswordWrongException() { 12 | super(4001,MSG); 13 | } 14 | 15 | 16 | 17 | } 18 | -------------------------------------------------------------------------------- /jeesuite-springweb/src/main/java/com/jeesuite/springweb/exception/UnauthorizedException.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.springweb.exception; 2 | 3 | import com.jeesuite.common.JeesuiteBaseException; 4 | 5 | public class UnauthorizedException extends JeesuiteBaseException { 6 | 7 | private static final long serialVersionUID = 1L; 8 | 9 | private static final String MSG = "401 Unauthorized"; 10 | 11 | public UnauthorizedException() { 12 | super(401,MSG); 13 | } 14 | 15 | 16 | 17 | } 18 | -------------------------------------------------------------------------------- /jeesuite-springweb/src/main/java/com/jeesuite/springweb/exception/ForbiddenAccessException.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.springweb.exception; 2 | 3 | import com.jeesuite.common.JeesuiteBaseException; 4 | 5 | public class ForbiddenAccessException extends JeesuiteBaseException { 6 | 7 | private static final long serialVersionUID = 1L; 8 | 9 | private static final String MSG = "403 forbidden"; 10 | 11 | public ForbiddenAccessException() { 12 | super(403,MSG); 13 | } 14 | 15 | 16 | 17 | } 18 | -------------------------------------------------------------------------------- /jeesuite-kafka/src/main/java/com/jeesuite/kafka/consumer/hanlder/RetryErrorMessageHandler.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.kafka.consumer.hanlder; 2 | 3 | import com.jeesuite.kafka.message.DefaultMessage; 4 | 5 | /** 6 | * 消费错误消息处理接口(自动重试后失败则触发) 7 | * @description
8 | * @author vakin 9 | * @date 2017年11月27日 10 | */ 11 | public interface RetryErrorMessageHandler { 12 | 13 | public void process(String group,String topic,DefaultMessage message); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /jeesuite-mybatis/src/main/java/com/jeesuite/mybatis/crud/CrudMethodDefine.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.mybatis.crud; 5 | 6 | /** 7 | * 定义按主键增删改查的方法名 8 | * @description
9 | * @author vakin 10 | * @date 2016年9月16日 11 | */ 12 | public interface CrudMethodDefine { 13 | 14 | String selectName(); 15 | 16 | String insertName(); 17 | 18 | String updateName(); 19 | 20 | String deleteName(); 21 | 22 | String selectAllName(); 23 | } 24 | -------------------------------------------------------------------------------- /jeesuite-mybatis/src/main/java/com/jeesuite/mybatis/crud/helper/TableMapper.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.mybatis.crud.helper; 2 | 3 | /** 4 | * @description
5 | * @author vakin 6 | * @date 2015年12月2日 7 | * @Copyright (c) 2015, jwww 8 | */ 9 | public class TableMapper { 10 | 11 | // 表名 12 | private String name; 13 | 14 | public String getName() { 15 | return name; 16 | } 17 | 18 | public void setName(String name) { 19 | this.name = name; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /jeesuite-common/src/main/java/com/jeesuite/common/serializer/Serializer.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.common.serializer; 2 | 3 | import java.io.IOException; 4 | 5 | /** 6 | * 对象序列化接口 7 | * @description
8 | * @author vakin 9 | * @date 2016年12月28日 10 | */ 11 | public interface Serializer { 12 | 13 | public String name(); 14 | 15 | public byte[] serialize(Object obj) throws IOException ; 16 | 17 | public Object deserialize(byte[] bytes) throws IOException ; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /jeesuite-common/src/main/java/com/jeesuite/common/packagescan/CompiledPattern.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.common.packagescan; 2 | 3 | /** 4 | * A wildcard pattern that has been compiled 5 | */ 6 | public interface CompiledPattern { 7 | 8 | /** 9 | * @return The original pattern 10 | */ 11 | String getOriginal(); 12 | 13 | /** 14 | * Tries to match a value 15 | * @param value The value to match 16 | * @return True if fully matched 17 | */ 18 | boolean matches(String value); 19 | } 20 | -------------------------------------------------------------------------------- /jeesuite-common/src/test/java/test/BeanUtilTest.java: -------------------------------------------------------------------------------- 1 | package test; 2 | 3 | import com.jeesuite.common.json.JsonUtils; 4 | import com.jeesuite.common.util.BeanUtils; 5 | 6 | public class BeanUtilTest { 7 | 8 | public static void main(String[] args) { 9 | User user = new User(); 10 | user.setName("小伙子"); 11 | user.setMobile("13800138000"); 12 | user.setFather(new User(1000, "你爹")); 13 | 14 | BaseUser user2 = BeanUtils.copy(user, BaseUser.class); 15 | System.out.println(JsonUtils.toPrettyJson(user2)); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /jeesuite-mybatis/src/main/java/com/jeesuite/mybatis/core/BaseEntity.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.mybatis.core; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * @description
10 | * @author vakin 11 | * @date 2015年12月7日 12 | * @Copyright (c) 2015, jwww 13 | */ 14 | public abstract class BaseEntity implements Serializable{ 15 | 16 | 17 | private static final long serialVersionUID = -607752621362896528L; 18 | 19 | public abstract Serializable getId(); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /jeesuite-filesystem/src/test/java/test/FileSystemClientTest.java: -------------------------------------------------------------------------------- 1 | package test; 2 | 3 | import java.io.File; 4 | import java.util.Map; 5 | 6 | import com.jeesuite.filesystem.FileSystemClient; 7 | import com.jeesuite.filesystem.UploadTokenParam; 8 | 9 | public class FileSystemClientTest { 10 | 11 | public static void main(String[] args) { 12 | UploadTokenParam param = new UploadTokenParam(); 13 | Map token = FileSystemClient.getClient("xxxx2").createUploadToken(param); 14 | 15 | System.out.println(token); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /jeesuite-rest/src/main/java/com/jeesuite/rest/CustomConfig.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.rest; 5 | 6 | import com.jeesuite.rest.excetion.ExcetionWrapper; 7 | 8 | /** 9 | * @description
10 | * @author vakin 11 | * @date 2016年12月23日 12 | */ 13 | public interface CustomConfig { 14 | 15 | /** 16 | * 对异常包装返回给前端 17 | * @return 18 | */ 19 | ExcetionWrapper createExcetionWrapper(); 20 | 21 | /** 22 | * 返回要扫描的包(rest接口) 23 | * @return 24 | */ 25 | String packages(); 26 | } 27 | -------------------------------------------------------------------------------- /jeesuite-cache/src/main/java/com/jeesuite/cache/redis/JedisProvider.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.cache.redis; 5 | 6 | import org.springframework.beans.factory.DisposableBean; 7 | 8 | /** 9 | * @description
10 | * @author vakin 11 | * @date 2015年04月23日 12 | */ 13 | public interface JedisProvider extends DisposableBean{ 14 | 15 | public S get(); 16 | 17 | public B getBinary(); 18 | 19 | public void release(); 20 | 21 | public String mode(); 22 | 23 | public String groupName(); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /jeesuite-scheduler/src/main/java/com/jeesuite/scheduler/JobLogPersistHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.scheduler; 5 | 6 | import java.util.Date; 7 | 8 | import com.jeesuite.scheduler.model.JobConfig; 9 | 10 | /** 11 | * 任务运行日志持久化接口 12 | * @description
13 | * @author vakin 14 | * @date 2016年12月30日 15 | */ 16 | public interface JobLogPersistHandler { 17 | 18 | public void onSucess(JobConfig conf, Date nextFireTime); 19 | 20 | public void onError(JobConfig conf, Date nextFireTime,Exception e); 21 | } 22 | -------------------------------------------------------------------------------- /jeesuite-springweb/src/main/java/com/jeesuite/springweb/model/WrapperResponseEntity.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.springweb.model; 2 | 3 | public class WrapperResponseEntity extends WrapperResponse { 4 | 5 | public WrapperResponseEntity() { 6 | super(); 7 | } 8 | 9 | public WrapperResponseEntity(int code, String msg, Object data) { 10 | super(code, msg, data); 11 | } 12 | 13 | public WrapperResponseEntity(int code, String msg) { 14 | super(code, msg); 15 | } 16 | 17 | public WrapperResponseEntity(Object data) { 18 | super(data); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /jeesuite-cache/src/test/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /jeesuite-common2/src/test/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /jeesuite-scheduler/src/test/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /jeesuite-mybatis/src/test/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /jeesuite-common2/src/main/java/com/jeesuite/common2/excel/ExcelOperBaseException.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.common2.excel; 2 | 3 | public class ExcelOperBaseException extends RuntimeException { 4 | 5 | private static final long serialVersionUID = 1L; 6 | 7 | public ExcelOperBaseException() {} 8 | 9 | public ExcelOperBaseException(String message) { 10 | super(message); 11 | } 12 | 13 | public ExcelOperBaseException(Throwable cause) { 14 | super(cause); 15 | } 16 | 17 | public ExcelOperBaseException(String message, Throwable cause) { 18 | super(message, cause); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /jeesuite-kafka/src/main/java/com/jeesuite/kafka/serializer/ZKStringSerializer.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.kafka.serializer; 2 | 3 | import org.I0Itec.zkclient.exception.ZkMarshallingError; 4 | import org.I0Itec.zkclient.serialize.ZkSerializer; 5 | 6 | public class ZKStringSerializer implements ZkSerializer{ 7 | 8 | private String encoding = "UTF8"; 9 | @Override 10 | public byte[] serialize(Object data) throws ZkMarshallingError { 11 | return data.toString().getBytes(); 12 | } 13 | 14 | @Override 15 | public Object deserialize(byte[] bytes) throws ZkMarshallingError { 16 | return new String(bytes); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /jeesuite-mybatis/src/main/java/com/jeesuite/mybatis/plugin/shard/annotation/DbShardKey.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.mybatis.plugin.shard.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 | 8 | 9 | /** 10 | * 标识用于分库的字段 11 | * @description
12 | * @author vakin 13 | * @date 2016年1月31日 14 | * @Copyright (c) 2015, jwww 15 | */ 16 | @Retention(RetentionPolicy.RUNTIME) 17 | @Target(ElementType.PARAMETER) 18 | public @interface DbShardKey { 19 | 20 | } 21 | -------------------------------------------------------------------------------- /jeesuite-scheduler/src/main/java/com/jeesuite/scheduler/ConfigPersistHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.scheduler; 5 | 6 | import com.jeesuite.scheduler.model.JobConfig; 7 | 8 | /** 9 | * 配置持久化处理器 10 | * @description
11 | * @author vakin 12 | * @date 2016年12月16日 13 | */ 14 | public interface ConfigPersistHandler { 15 | 16 | /** 17 | * 启动时合并配置 18 | * @param groupName 19 | * @param jobName 20 | * @return 21 | */ 22 | void merge(JobConfig config); 23 | 24 | /** 25 | * 持久化配置 26 | * @param config 27 | */ 28 | void persist(JobConfig config); 29 | } 30 | -------------------------------------------------------------------------------- /jeesuite-cache/src/main/java/com/jeesuite/cache/local/Level1CacheProvider.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.cache.local; 5 | 6 | import java.io.Closeable; 7 | 8 | /** 9 | * @description
10 | * @author vakin 11 | * @date 2016年12月4日 12 | */ 13 | public interface Level1CacheProvider extends Closeable{ 14 | 15 | void start(); 16 | boolean set(String cacheName,String key,Object value); 17 | 18 | T get(String cacheName,String key); 19 | 20 | void remove(String cacheName,String key); 21 | 22 | void remove(String cacheName); 23 | 24 | void clearAll(); 25 | 26 | } 27 | -------------------------------------------------------------------------------- /jeesuite-common/src/main/java/com/jeesuite/common/model/SelectOption.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.common.model; 2 | 3 | public class SelectOption { 4 | 5 | private String value; 6 | private String text; 7 | 8 | public SelectOption() {} 9 | 10 | public SelectOption(String value, String text) { 11 | super(); 12 | this.value = value; 13 | this.text = text; 14 | } 15 | 16 | public String getValue() { 17 | return value; 18 | } 19 | public void setValue(String value) { 20 | this.value = value; 21 | } 22 | public String getText() { 23 | return text; 24 | } 25 | public void setText(String text) { 26 | this.text = text; 27 | } 28 | 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /jeesuite-search/src/main/java/test/User.java: -------------------------------------------------------------------------------- 1 | package test; 2 | 3 | public class User { 4 | 5 | private int userId; 6 | private String username; 7 | private String description; 8 | 9 | public int getUserId() { 10 | return userId; 11 | } 12 | public void setUserId(int userId) { 13 | this.userId = userId; 14 | } 15 | public String getUsername() { 16 | return username; 17 | } 18 | public void setUsername(String username) { 19 | this.username = username; 20 | } 21 | public String getDescription() { 22 | return description; 23 | } 24 | public void setDescription(String description) { 25 | this.description = description; 26 | } 27 | 28 | 29 | } 30 | -------------------------------------------------------------------------------- /jeesuite-kafka/src/main/java/com/jeesuite/kafka/producer/handler/ProducerEventHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.kafka.producer.handler; 5 | 6 | import java.io.Closeable; 7 | 8 | import org.apache.kafka.clients.producer.RecordMetadata; 9 | 10 | import com.jeesuite.kafka.message.DefaultMessage; 11 | 12 | /** 13 | * @description
14 | * @author vakin 15 | * @date 2016年12月10日 16 | */ 17 | public interface ProducerEventHandler extends Closeable{ 18 | 19 | public void onSuccessed(String topicName, RecordMetadata metadata); 20 | 21 | public void onError(String topicName, DefaultMessage message); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /jeesuite-log/src/main/java/com/jeesuite/log/Log.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.log; 2 | 3 | public interface Log { 4 | 5 | boolean isDebugEnabled(); 6 | 7 | void error(String msg, Throwable e); 8 | 9 | void error(String msg); 10 | 11 | boolean isInfoEnabled(); 12 | 13 | void info(String msg); 14 | 15 | void debug(String msg); 16 | 17 | void debug(String msg, Throwable e); 18 | 19 | boolean isWarnEnabled(); 20 | 21 | void warn(String msg); 22 | 23 | void warn(String msg, Throwable e); 24 | 25 | int getErrorCount(); 26 | 27 | int getWarnCount(); 28 | 29 | int getInfoCount(); 30 | 31 | int getDebugCount(); 32 | 33 | void resetStat(); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /jeesuite-kafka/src/main/java/com/jeesuite/kafka/producer/TopicProducer.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.kafka.producer; 2 | 3 | import com.jeesuite.kafka.message.DefaultMessage; 4 | import com.jeesuite.kafka.producer.handler.ProducerEventHandler; 5 | 6 | /** 7 | * @description
8 | * @author vakin 9 | * @date 2016年6月14日 10 | */ 11 | public interface TopicProducer { 12 | 13 | void addEventHandler(ProducerEventHandler eventHandler); 14 | /** 15 | * 发送消息(可选择发送模式) 16 | * @param topic 17 | * @param message 18 | * @param asynSend 是否异步发送 19 | * @return 20 | */ 21 | boolean publish(final String topic, final DefaultMessage message,boolean asynSend); 22 | 23 | void close(); 24 | } 25 | -------------------------------------------------------------------------------- /jeesuite-kafka/src/test/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /jeesuite-rest/src/main/java/com/jeesuite/rest/filter/annotation/ResponseFormat.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.rest.filter.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 | 8 | @Target(ElementType.METHOD) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface ResponseFormat { 11 | 12 | /** 13 | * 默认需要事务 14 | * 15 | * @return 16 | */ 17 | FormatType type(); 18 | 19 | /** 20 | * JSON是否自动包装 21 | * 22 | * @author vakinge 23 | * @return 24 | */ 25 | boolean jsonWrapper() default true; 26 | 27 | public static enum FormatType { 28 | JSON, XML, NONE 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /jeesuite-filesystem/src/test/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /jeesuite-mybatis/src/main/java/com/jeesuite/mybatis/plugin/pagination/annotation/Pageable.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.mybatis.plugin.pagination.annotation; 5 | 6 | import java.lang.annotation.Documented; 7 | import java.lang.annotation.ElementType; 8 | import java.lang.annotation.Inherited; 9 | import java.lang.annotation.Retention; 10 | import java.lang.annotation.RetentionPolicy; 11 | import java.lang.annotation.Target; 12 | 13 | /** 14 | * 分页标注 15 | * @description
16 | * @author vakin 17 | * @date 2017年6月22日 18 | */ 19 | @Target({ ElementType.METHOD }) 20 | @Retention(RetentionPolicy.RUNTIME) 21 | @Inherited 22 | @Documented 23 | public @interface Pageable { 24 | 25 | } 26 | -------------------------------------------------------------------------------- /jeesuite-mybatis/src/main/resources/mybatis-configuration.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /jeesuite-mybatis/src/main/java/com/jeesuite/mybatis/core/InterceptorHandler.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.mybatis.core; 2 | 3 | import org.apache.ibatis.plugin.Invocation; 4 | 5 | import com.jeesuite.mybatis.plugin.JeesuiteMybatisInterceptor; 6 | 7 | /** 8 | * mybatis插件拦截处理器接口 9 | * @description
10 | * @author vakin 11 | * @date 2015年12月7日 12 | * @Copyright (c) 2015, jwww 13 | */ 14 | public interface InterceptorHandler { 15 | 16 | void start(JeesuiteMybatisInterceptor context); 17 | 18 | void close(); 19 | 20 | Object onInterceptor(Invocation invocation) throws Throwable; 21 | 22 | void onFinished(Invocation invocation,Object result); 23 | 24 | int interceptorOrder(); 25 | 26 | 27 | } 28 | -------------------------------------------------------------------------------- /jeesuite-rest/src/main/java/com/jeesuite/rest/resolver/ObjectMapperResolver.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.rest.resolver; 2 | 3 | import javax.ws.rs.ext.ContextResolver; 4 | import javax.ws.rs.ext.Provider; 5 | 6 | import com.fasterxml.jackson.databind.ObjectMapper; 7 | import com.jeesuite.common.json.JsonMapper; 8 | 9 | /** 10 | * Jackson ObjectMapper 解析器 11 | * 12 | * 用于设置ObjectMapper 13 | * 14 | * @author LinHaobin 15 | * 16 | */ 17 | @Provider 18 | public class ObjectMapperResolver implements ContextResolver { 19 | 20 | static JsonMapper jsonMapper = JsonMapper.nonNullMapper().dateAndTimestampConvert(true); 21 | 22 | @Override 23 | public ObjectMapper getContext(Class type) { 24 | return jsonMapper.getMapper(); 25 | } 26 | } -------------------------------------------------------------------------------- /jeesuite-kafka/src/main/java/com/jeesuite/kafka/annotation/ConsumerHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.kafka.annotation; 5 | 6 | import java.lang.annotation.Documented; 7 | import java.lang.annotation.ElementType; 8 | import java.lang.annotation.Inherited; 9 | import java.lang.annotation.Retention; 10 | import java.lang.annotation.RetentionPolicy; 11 | import java.lang.annotation.Target; 12 | 13 | /** 14 | * @description
15 | * @author vakin 16 | * @date 2015年12月10日 17 | * @Copyright (c) 2015, jwww 18 | */ 19 | @Target({ElementType.TYPE }) 20 | @Retention(RetentionPolicy.RUNTIME) 21 | @Inherited 22 | @Documented 23 | public @interface ConsumerHandler { 24 | String topic(); 25 | 26 | } 27 | -------------------------------------------------------------------------------- /jeesuite-common/src/main/java/com/jeesuite/common/JeesuiteBaseException.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.common; 2 | 3 | public class JeesuiteBaseException extends RuntimeException { 4 | 5 | private static final long serialVersionUID = 1L; 6 | 7 | private int code; 8 | 9 | public JeesuiteBaseException() { 10 | super(); 11 | } 12 | 13 | public JeesuiteBaseException(int code,String message) { 14 | super(message); 15 | this.code = code; 16 | } 17 | 18 | public JeesuiteBaseException(int code,String message, Throwable cause) { 19 | super(message, cause); 20 | this.code = code; 21 | } 22 | 23 | public int getCode() { 24 | return code; 25 | } 26 | 27 | public void setCode(int code) { 28 | this.code = code; 29 | } 30 | 31 | 32 | 33 | } 34 | -------------------------------------------------------------------------------- /jeesuite-event/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | com.jeesuite 6 | jeesuite-libs 7 | 1.3.4-SNAPSHOT 8 | 9 | jeesuite-event 10 | 11 | 12 | 13 | 14 | org.apache.maven.plugins 15 | maven-deploy-plugin 16 | 17 | true 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /jeesuite-scheduler/src/test/java/com/jeesuite/test/sch/DbConfigPersistHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.test.sch; 5 | 6 | import com.jeesuite.scheduler.ConfigPersistHandler; 7 | import com.jeesuite.scheduler.model.JobConfig; 8 | 9 | /** 10 | * @description
11 | * @author vakin 12 | * @date 2016年12月16日 13 | */ 14 | public class DbConfigPersistHandler implements ConfigPersistHandler { 15 | 16 | 17 | @Override 18 | public void merge(JobConfig config) { 19 | // load config from db 20 | System.out.println("========>>假装从数据库load一下配置"); 21 | } 22 | 23 | @Override 24 | public void persist(JobConfig config) { 25 | // save config to db 26 | System.out.println("========>>假装保存配置到数据库"); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /jeesuite-springboot-starter/src/main/java/com/jeesuite/springboot/starter/cache/EnableJeesuiteCache.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.springboot.starter.cache; 5 | 6 | import java.lang.annotation.Documented; 7 | import java.lang.annotation.ElementType; 8 | import java.lang.annotation.Retention; 9 | import java.lang.annotation.RetentionPolicy; 10 | import java.lang.annotation.Target; 11 | 12 | import org.springframework.context.annotation.Import; 13 | 14 | /** 15 | * @description
16 | * @author vakin 17 | * @date 2017年3月28日 18 | */ 19 | @Target(ElementType.TYPE) 20 | @Retention(RetentionPolicy.RUNTIME) 21 | @Documented 22 | @Import(DelegateCacheConfiguration.class) 23 | public @interface EnableJeesuiteCache { 24 | 25 | } 26 | -------------------------------------------------------------------------------- /jeesuite-springboot-starter/src/main/java/com/jeesuite/springboot/starter/scheduler/EnableJeesuiteSchedule.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.springboot.starter.scheduler; 5 | 6 | import java.lang.annotation.Documented; 7 | import java.lang.annotation.ElementType; 8 | import java.lang.annotation.Retention; 9 | import java.lang.annotation.RetentionPolicy; 10 | import java.lang.annotation.Target; 11 | 12 | import org.springframework.context.annotation.Import; 13 | 14 | /** 15 | * @description
16 | * @author vakin 17 | * @date 2017年3月28日 18 | */ 19 | @Target(ElementType.TYPE) 20 | @Retention(RetentionPolicy.RUNTIME) 21 | @Documented 22 | @Import(DelegateScheConfiguration.class) 23 | public @interface EnableJeesuiteSchedule { 24 | 25 | } 26 | -------------------------------------------------------------------------------- /jeesuite-log/src/main/java/com/jeesuite/log/log4j2/LogConfigLookup.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.log.log4j2; 2 | 3 | import org.apache.logging.log4j.core.LogEvent; 4 | import org.apache.logging.log4j.core.config.Order; 5 | import org.apache.logging.log4j.core.config.plugins.Plugin; 6 | import org.apache.logging.log4j.core.lookup.AbstractLookup; 7 | import org.apache.logging.log4j.core.lookup.StrLookup; 8 | 9 | import com.jeesuite.common.util.ResourceUtils; 10 | 11 | @Plugin(name = "context", category = StrLookup.CATEGORY) 12 | @Order(value=-1) 13 | public class LogConfigLookup extends AbstractLookup { 14 | 15 | public LogConfigLookup() { 16 | super(); 17 | } 18 | 19 | @Override 20 | public String lookup(LogEvent event, String key) { 21 | return ResourceUtils.getProperty(key); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /jeesuite-springboot-starter/src/main/java/com/jeesuite/springboot/starter/kafka/EnableJeesuiteKafkaConsumer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.springboot.starter.kafka; 5 | 6 | import java.lang.annotation.Documented; 7 | import java.lang.annotation.ElementType; 8 | import java.lang.annotation.Retention; 9 | import java.lang.annotation.RetentionPolicy; 10 | import java.lang.annotation.Target; 11 | 12 | import org.springframework.context.annotation.Import; 13 | 14 | /** 15 | * @description
16 | * @author vakin 17 | * @date 2017年3月28日 18 | */ 19 | @Target(ElementType.TYPE) 20 | @Retention(RetentionPolicy.RUNTIME) 21 | @Documented 22 | @Import(DelegateKafkaConsumerConfiguration.class) 23 | public @interface EnableJeesuiteKafkaConsumer { 24 | 25 | } 26 | -------------------------------------------------------------------------------- /jeesuite-springboot-starter/src/main/java/com/jeesuite/springboot/starter/kafka/EnableJeesuiteKafkaProducer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.springboot.starter.kafka; 5 | 6 | import java.lang.annotation.Documented; 7 | import java.lang.annotation.ElementType; 8 | import java.lang.annotation.Retention; 9 | import java.lang.annotation.RetentionPolicy; 10 | import java.lang.annotation.Target; 11 | 12 | import org.springframework.context.annotation.Import; 13 | 14 | /** 15 | * @description
16 | * @author vakin 17 | * @date 2017年3月28日 18 | */ 19 | @Target(ElementType.TYPE) 20 | @Retention(RetentionPolicy.RUNTIME) 21 | @Documented 22 | @Import(DelegateKafkaProducerConfiguration.class) 23 | public @interface EnableJeesuiteKafkaProducer { 24 | 25 | } 26 | -------------------------------------------------------------------------------- /jeesuite-common/jeesuite-common.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /jeesuite-common/src/main/java/com/jeesuite/common/util/NodeNameHolder.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.common.util; 5 | 6 | import java.net.InetAddress; 7 | import java.util.UUID; 8 | 9 | import org.apache.commons.lang3.RandomStringUtils; 10 | 11 | /** 12 | * @description
13 | * @author vakin 14 | * @date 2016年11月3日 15 | */ 16 | public class NodeNameHolder { 17 | 18 | private static String nodeId; 19 | 20 | public static String getNodeId() { 21 | if(nodeId != null)return nodeId; 22 | try { 23 | nodeId = InetAddress.getLocalHost().getHostAddress() + "_" + RandomStringUtils.random(3, true, true).toLowerCase(); 24 | } catch (Exception e) { 25 | nodeId = UUID.randomUUID().toString(); 26 | } 27 | return nodeId; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /jeesuite-kafka/src/main/java/com/jeesuite/kafka/handler/MessageHandler.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.kafka.handler; 2 | 3 | import com.jeesuite.kafka.message.DefaultMessage; 4 | 5 | /** 6 | * 消息处理器接口 7 | * @description
8 | * @author vakin 9 | * @date 2016年6月15日 10 | */ 11 | public interface MessageHandler { 12 | 13 | /** 14 | * 第一阶段处理
15 | * 第一阶段是同步处理,保证实时性(如:写缓存后保证实时读取) 16 | * @param message 17 | */ 18 | void p1Process(DefaultMessage message); 19 | 20 | /** 21 | * 第二阶段处理
22 | * 第二阶段为异步处理,为后台任务 23 | * @param message 24 | */ 25 | void p2Process(DefaultMessage message); 26 | 27 | /** 28 | * 处理失败的消息 29 | * @param message 30 | * @return true 表示业务系统自己已经做了处理,false 由底层框架执行重新处理 31 | */ 32 | boolean onProcessError(DefaultMessage message); 33 | } 34 | -------------------------------------------------------------------------------- /jeesuite-springboot-starter/src/main/java/com/jeesuite/springboot/starter/mybatis/EnableJeesuiteMybatis.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.springboot.starter.mybatis; 5 | 6 | import java.lang.annotation.Documented; 7 | import java.lang.annotation.ElementType; 8 | import java.lang.annotation.Retention; 9 | import java.lang.annotation.RetentionPolicy; 10 | import java.lang.annotation.Target; 11 | 12 | import org.springframework.context.annotation.Import; 13 | 14 | /** 15 | * @description
16 | * @author vakin 17 | * @date 2017年3月28日 18 | */ 19 | @Target(ElementType.TYPE) 20 | @Retention(RetentionPolicy.RUNTIME) 21 | @Documented 22 | @Import({JeesuiteMybatisConfiguration.class,JeesuiteDataSourceConfiguration.class}) 23 | public @interface EnableJeesuiteMybatis { 24 | 25 | } 26 | -------------------------------------------------------------------------------- /jeesuite-rest/src/main/java/com/jeesuite/rest/filter/FilterHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.rest.filter; 5 | 6 | import javax.servlet.http.HttpServletRequest; 7 | import javax.ws.rs.container.ContainerRequestContext; 8 | import javax.ws.rs.container.ContainerResponseContext; 9 | import javax.ws.rs.container.ResourceInfo; 10 | 11 | /** 12 | * @description
13 | * @author vakin 14 | * @date 2016年12月28日 15 | */ 16 | public interface FilterHandler { 17 | 18 | void processRequest(ContainerRequestContext requestContext, HttpServletRequest request, 19 | ResourceInfo resourceInfo); 20 | 21 | void processResponse(ContainerRequestContext requestContext, ContainerResponseContext responseContext, 22 | ResourceInfo resourceInfo) ; 23 | 24 | int getPriority(); 25 | } 26 | -------------------------------------------------------------------------------- /jeesuite-filesystem/src/main/java/com/jeesuite/filesystem/utils/HttpDownloader.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.filesystem.utils; 5 | 6 | import java.io.IOException; 7 | 8 | import com.jeesuite.filesystem.UploadObject; 9 | 10 | import okhttp3.OkHttpClient; 11 | import okhttp3.Request; 12 | import okhttp3.Response; 13 | 14 | 15 | public class HttpDownloader { 16 | 17 | private static OkHttpClient httpClient = new OkHttpClient(); 18 | 19 | public static UploadObject read(String url) throws IOException{ 20 | 21 | Request.Builder requestBuilder = new Request.Builder().url(url); 22 | Response response = httpClient.newCall(requestBuilder.build()).execute(); 23 | 24 | UploadObject item = new UploadObject(FilePathHelper.parseFileName(url), response.body().bytes()); 25 | return item; 26 | } 27 | 28 | 29 | } 30 | -------------------------------------------------------------------------------- /CHANGE-LOG.md: -------------------------------------------------------------------------------- 1 | ### 1.3.2 2 | #### jeesuite-event 3 | 4 | #### jeesuite-kafka 5 | - 动态消息 6 | 7 | ### 1.3.1 8 | #### jeesuite-security 9 | `jeesuite-security`是新增模块:可替代shiro或spring-security等安全框架,可以理解是shiro的轻量级版本,配置更简单,更加贴近我们业务场景。 10 | - 配置简单(初始化一个类即可) 11 | - 满足认证授权基本需求 12 | - 更加贴近日常使用业务场景 13 | - 可选本地session和共享session 14 | - 可选是否支持多端同时登录 15 | - dubbo、springboot跨服务登录状态传递支持 16 | 17 | #### jeesuite-mybaits 18 | - 重构mybaits增强插件注册逻辑简化配置 19 | - 开放自定义mybatis插件hander接口 20 | - 增加敏感操作拦截mybatis插件hander 21 | - 支持无缝集成CRUD增强框架mapper 22 | - 升级mybatis版本去掉自动CRUD过期代码 23 | 24 | #### jeesuite-kafka 25 | - 修复json消息反序列化漏处理header字段 26 | 27 | #### jeesuite-scheduler 28 | - 新增单机模式任务监控支持 29 | 30 | #### jeesuite-springboot-starter 31 | - 重构mybaits模块注册逻辑 32 | - scheduler模块注册兼容springboot2.x 33 | 34 | #### jeesuite-springweb 35 | - 日志拦截器请求内容过长截取输出 36 | 37 | -------------------------------------------------------------------------------- /jeesuite-kafka/src/main/java/com/jeesuite/kafka/KafkaConst.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.kafka; 5 | 6 | /** 7 | * 常量定义 8 | * @description
9 | * @author vakin 10 | * @date 2016年5月1日 11 | */ 12 | public class KafkaConst { 13 | 14 | public final static String HEARTBEAT_TOPIC = "_kafka_heartBeat"; 15 | 16 | public final static String ZK_CONSUMER_PATH = "/consumers/"; 17 | 18 | public final static String ZK_PRODUCER_STAT_PATH = "/producers/statistics"; 19 | 20 | public final static String COMMAND_GET_STATISTICS = "get_statistics"; 21 | 22 | public final static String PROP_TOPIC_LAT_THRESHOLD = "topic.lat.threshold"; 23 | 24 | public final static String PROP_ENV_ROUTE = "topic.route.env"; 25 | 26 | public static String ZK_PRODUCER_ACK_PATH = "/producers/watcher/"; 27 | } 28 | -------------------------------------------------------------------------------- /jeesuite-common2/src/main/java/com/jeesuite/common2/excel/annotation/TitleCell.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.common2.excel.annotation; 2 | 3 | import java.lang.annotation.*; 4 | 5 | 6 | @Target(ElementType.FIELD) 7 | @Retention(RetentionPolicy.RUNTIME) 8 | @Documented 9 | public @interface TitleCell { 10 | 11 | /** 12 | * 在excel文件中某列数据的名称 13 | * 14 | * @return 名称 15 | */ 16 | String name(); 17 | 18 | /** 19 | * 列序列 20 | * 21 | * @return 顺序 22 | */ 23 | int column(); 24 | 25 | int row() default 1; 26 | 27 | boolean notNull() default false; 28 | 29 | String format() default ""; 30 | 31 | int width() default 15; 32 | 33 | /** 34 | * 嵌套父级列名称 35 | */ 36 | String parentName() default ""; 37 | 38 | Class type() default String.class; 39 | } 40 | -------------------------------------------------------------------------------- /jeesuite-rest/src/main/java/com/jeesuite/rest/filter/RequestHeaderHolder.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.rest.filter; 5 | 6 | import com.jeesuite.rest.RequestHeader; 7 | 8 | /** 9 | * @description
10 | * @author vakin 11 | * @date 2016年1月19日 12 | * @Copyright (c) 2015, vakinge@github 13 | */ 14 | public class RequestHeaderHolder { 15 | 16 | private static ThreadLocal holder = new ThreadLocal<>(); 17 | 18 | 19 | public static void set(RequestHeader rh){ 20 | holder.set(rh); 21 | } 22 | 23 | public static void clear(){ 24 | holder.remove(); 25 | } 26 | 27 | public static RequestHeader get(){ 28 | RequestHeader header = holder.get(); 29 | if(header == null){ 30 | header = new RequestHeader(); 31 | holder.set(header); 32 | } 33 | return header; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /jeesuite-kafka/src/test/java/com/jeesuite/test/MysqlOffsetLogHanlder.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.test; 2 | 3 | import com.jeesuite.kafka.consumer.hanlder.OffsetLogHanlder; 4 | 5 | public class MysqlOffsetLogHanlder implements OffsetLogHanlder { 6 | 7 | @Override 8 | public long getLatestProcessedOffsets(String group, String topic, int partition) { 9 | return -1; 10 | } 11 | 12 | @Override 13 | public void saveOffsetsBeforeProcessed(String group, String topic, int partition, long offset) { 14 | System.out.println(String.format("saveOffsetsBeforeProcessed:topic:%s,partition:%s,offset:%s", topic,partition,offset)); 15 | } 16 | 17 | @Override 18 | public void saveOffsetsAfterProcessed(String group, String topic, int partition, long offset) { 19 | System.out.println(String.format("saveOffsetsAfterProcessed:topic:%s,partition:%s,offset:%s", topic,partition,offset)); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /jeesuite-common/src/main/java/com/jeesuite/common/packagescan/SimpleWildcardPattern.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.common.packagescan; 2 | 3 | import java.util.regex.Pattern; 4 | 5 | /** 6 | * A simple wildcard pattern that uses the '*' character to match everything. 7 | */ 8 | public class SimpleWildcardPattern implements CompiledPattern { 9 | private Pattern pattern; 10 | private String original; 11 | 12 | public SimpleWildcardPattern(String pattern) { 13 | 14 | this.original = pattern; 15 | 16 | String ptn = pattern; 17 | ptn = ptn.replace(".", "\\."); 18 | ptn = ptn.replace("*", ".*"); 19 | this.pattern = Pattern.compile(ptn); 20 | } 21 | 22 | 23 | public String getOriginal() { 24 | return original; 25 | } 26 | 27 | public boolean matches(String value) { 28 | return pattern.matcher(value).matches(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /jeesuite-cache/jeesuite-cache.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /jeesuite-filesystem/jeesuite-filesystem.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /jeesuite-rest/src/main/java/com/jeesuite/rest/filter/FilterConfig.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.rest.filter; 5 | 6 | import com.jeesuite.common.util.ResourceUtils; 7 | 8 | /** 9 | * @description
10 | * @author vakin 11 | * @date 2016年12月25日 12 | */ 13 | public class FilterConfig { 14 | 15 | public static boolean corsEnabled(){ 16 | return Boolean.parseBoolean(ResourceUtils.getProperty("cors.enabled", "false")); 17 | } 18 | 19 | public static String getCorsAllowOrgin(){ 20 | return ResourceUtils.getProperty("cors.allow.origin", "*"); 21 | } 22 | 23 | public static boolean reqRspLogEnabled(){ 24 | return Boolean.parseBoolean(ResourceUtils.getProperty("reqres.log.enabled", "false")); 25 | } 26 | 27 | public static boolean apiDocEnabled(){ 28 | return Boolean.parseBoolean(ResourceUtils.getProperty("apidoc.enabled", "true")); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /jeesuite-kafka/src/main/java/com/jeesuite/kafka/serializer/JdkMessageDeserializer.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.kafka.serializer; 2 | 3 | import java.util.Map; 4 | 5 | import org.apache.commons.lang3.SerializationUtils; 6 | import org.apache.kafka.common.serialization.Deserializer; 7 | 8 | /** 9 | * 10 | * @description
11 | * @author vakin 12 | * @date 2016年6月14日 13 | */ 14 | public class JdkMessageDeserializer implements Deserializer { 15 | 16 | @Override 17 | public void configure(Map configs, boolean isKey) {} 18 | 19 | @Override 20 | public Object deserialize(String topic, byte[] data) { 21 | if (data == null) 22 | return null; 23 | else 24 | return SerializationUtils.deserialize(data); 25 | } 26 | 27 | @Override 28 | public void close() { 29 | // nothing to do 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /jeesuite-kafka/src/main/java/com/jeesuite/kafka/serializer/KyroMessageDeserializer.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.kafka.serializer; 2 | 3 | import java.util.Map; 4 | 5 | import org.apache.kafka.common.serialization.Deserializer; 6 | 7 | import com.jeesuite.common.serializer.SerializeUtils; 8 | 9 | /** 10 | * 11 | * @description
12 | * @author vakin 13 | * @date 2016年6月14日 14 | */ 15 | public class KyroMessageDeserializer implements Deserializer { 16 | 17 | @Override 18 | public void configure(Map configs, boolean isKey) {} 19 | 20 | @Override 21 | public Object deserialize(String topic, byte[] data) { 22 | if (data == null) 23 | return null; 24 | else 25 | return SerializeUtils.deserialize(data); 26 | } 27 | 28 | @Override 29 | public void close() { 30 | // nothing to do 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /jeesuite-mybatis/src/main/java/com/jeesuite/mybatis/plugin/shard/ShardStrategy.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.mybatis.plugin.shard; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * 数据库分库策略接口 10 | * @description
11 | * @author vakin 12 | * @date 2016年2月2日 13 | * @Copyright (c) 2015, jwww 14 | */ 15 | public interface ShardStrategy { 16 | 17 | /** 18 | * 分库字段 19 | * @return 20 | */ 21 | public String shardDbField(); 22 | 23 | /** 24 | * 分库字段对应实体属性名 25 | * @return 26 | */ 27 | public String shardEntityField(); 28 | 29 | 30 | 31 | /** 32 | * 分配逻辑 33 | * @param value 34 | * @return 数据库index 35 | */ 36 | public int assigned(Object value); 37 | 38 | /** 39 | * 忽略分库表名列表 40 | * @return 41 | */ 42 | public List ignoreTables(); 43 | 44 | /** 45 | * 是否全局 46 | * @return 47 | */ 48 | public boolean isGlobal(); 49 | } 50 | -------------------------------------------------------------------------------- /jeesuite-event/src/main/java/com/jeesuite/event/EventPublisher.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2018 www.jeesuite.com. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jeesuite.event; 17 | 18 | /** 19 | * @description
20 | * @author vakin 21 | * @date 2018年12月29日 22 | */ 23 | public interface EventPublisher { 24 | 25 | } 26 | -------------------------------------------------------------------------------- /jeesuite-common/src/main/java/com/jeesuite/common/util/SimpleCryptUtils.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.common.util; 2 | 3 | import java.nio.charset.StandardCharsets; 4 | 5 | import com.jeesuite.common.crypt.Base64; 6 | import com.jeesuite.common.crypt.DES; 7 | 8 | public class SimpleCryptUtils { 9 | 10 | private static final String KEY_TAIL = "j@"; 11 | 12 | public static String encrypt(String key,String data) { 13 | key = DigestUtils.md5Short(key) + KEY_TAIL; 14 | String encode = DES.encrypt(key, data); 15 | byte[] bytes = Base64.encodeToByte(encode.getBytes(StandardCharsets.UTF_8), false); 16 | return new String(bytes, StandardCharsets.UTF_8); 17 | } 18 | 19 | public static String decrypt(String key,String data) { 20 | key = DigestUtils.md5Short(key) + KEY_TAIL; 21 | byte[] bytes = Base64.decode(data); 22 | data = new String(bytes, StandardCharsets.UTF_8); 23 | return DES.decrypt(key, data); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /jeesuite-event/src/main/java/com/jeesuite/event/EventSubscriber.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2018 www.jeesuite.com. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jeesuite.event; 17 | 18 | /** 19 | * @description
20 | * @author vakin 21 | * @date 2018年12月29日 22 | */ 23 | public interface EventSubscriber { 24 | 25 | } 26 | -------------------------------------------------------------------------------- /jeesuite-filesystem/src/main/java/com/jeesuite/filesystem/FSProvider.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.filesystem; 5 | 6 | import java.io.Closeable; 7 | import java.util.Map; 8 | 9 | /** 10 | * 上传接口 11 | * @description
12 | * @author vakin 13 | * @date 2017年1月5日 14 | */ 15 | public interface FSProvider extends Closeable { 16 | 17 | String name(); 18 | /** 19 | * 文件上传 20 | * @param object 21 | * @return 22 | */ 23 | public String upload(UploadObject object); 24 | /** 25 | * 获取文件下载地址 26 | * @param file 文件(全路径或者fileKey) 27 | * @return 28 | */ 29 | public String getDownloadUrl(String fileKey); 30 | 31 | /** 32 | * 删除图片 33 | * @return 34 | */ 35 | public boolean delete(String fileKey); 36 | 37 | public String downloadAndSaveAs(String fileKey,String localSaveDir); 38 | 39 | public Map createUploadToken(UploadTokenParam param); 40 | } 41 | -------------------------------------------------------------------------------- /jeesuite-kafka/src/main/java/com/jeesuite/kafka/serializer/MessageDecoder.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.kafka.serializer; 2 | 3 | import org.apache.kafka.common.serialization.Deserializer; 4 | 5 | import com.jeesuite.common.serializer.SerializeUtils; 6 | 7 | import kafka.serializer.Decoder; 8 | 9 | 10 | /** 11 | * 12 | * @description
13 | * @author vakin 14 | * @date 2016年6月14日 15 | */ 16 | public class MessageDecoder implements Decoder { 17 | 18 | private Deserializer deserializer; 19 | 20 | public MessageDecoder() {} 21 | 22 | public MessageDecoder(Deserializer deserializer) { 23 | super(); 24 | this.deserializer = deserializer; 25 | } 26 | 27 | @Override 28 | public Object fromBytes(byte[] bytes) { 29 | if(deserializer != null)return deserializer.deserialize(null, bytes); 30 | return SerializeUtils.deserialize(bytes); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /jeesuite-mybatis/src/main/java/com/jeesuite/mybatis/crud/name/DefaultCrudMethodDefine.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.mybatis.crud.name; 5 | 6 | import com.jeesuite.mybatis.crud.CrudMethodDefine; 7 | 8 | /** 9 | * @description
10 | * @author vakin 11 | * @date 2016年9月16日 12 | */ 13 | public class DefaultCrudMethodDefine implements CrudMethodDefine { 14 | 15 | @Override 16 | public String selectName() { 17 | return "selectByPrimaryKey"; 18 | } 19 | 20 | @Override 21 | public String insertName() { 22 | return "insert,insertSelective"; 23 | } 24 | 25 | @Override 26 | public String updateName() { 27 | return "updateByPrimaryKey,updateByPrimaryKeySelective"; 28 | } 29 | 30 | @Override 31 | public String deleteName() { 32 | return "deleteByPrimaryKey"; 33 | } 34 | 35 | @Override 36 | public String selectAllName() { 37 | return "selectAll"; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /jeesuite-springboot-starter/src/main/java/com/jeesuite/springboot/starter/mybatis/JeesuiteDataSourceConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.springboot.starter.mybatis; 2 | 3 | import javax.sql.DataSource; 4 | 5 | import org.springframework.boot.autoconfigure.AutoConfigureBefore; 6 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; 7 | import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.context.annotation.Configuration; 10 | 11 | import com.jeesuite.mybatis.datasource.MutiRouteDataSource; 12 | 13 | 14 | @Configuration 15 | @ConditionalOnClass(MutiRouteDataSource.class) 16 | @AutoConfigureBefore(DataSourceAutoConfiguration.class) 17 | public class JeesuiteDataSourceConfiguration { 18 | 19 | @Bean("dataSource") 20 | public DataSource dataSourceBean(){ 21 | return new MutiRouteDataSource(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /jeesuite-mybatis/src/main/java/com/jeesuite/mybatis/crud/name/Mapper3CrudMethodDefine.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.mybatis.crud.name; 5 | 6 | import com.jeesuite.mybatis.crud.CrudMethodDefine; 7 | 8 | /** 9 | * Mapper3 框架方法定义 10 | * @description
11 | * @author vakin 12 | * @date 2016年9月16日 13 | */ 14 | public class Mapper3CrudMethodDefine implements CrudMethodDefine { 15 | 16 | @Override 17 | public String selectName() { 18 | return "selectByPrimaryKey"; 19 | } 20 | 21 | @Override 22 | public String insertName() { 23 | return "insert,insertSelective"; 24 | } 25 | 26 | @Override 27 | public String updateName() { 28 | return "updateByPrimaryKey,updateByPrimaryKeySelective"; 29 | } 30 | 31 | @Override 32 | public String deleteName() { 33 | return "deleteByPrimaryKey"; 34 | } 35 | 36 | @Override 37 | public String selectAllName() { 38 | return "selectAll"; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /jeesuite-scheduler/src/test/java/com/jeesuite/test/sch/DemoTask2.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.test.sch; 5 | 6 | import java.util.Date; 7 | 8 | import org.apache.commons.lang3.RandomUtils; 9 | 10 | import com.jeesuite.common.util.DateUtils; 11 | import com.jeesuite.scheduler.AbstractJob; 12 | import com.jeesuite.scheduler.JobContext; 13 | 14 | /** 15 | * @description
16 | * @author vakin 17 | * @date 2016年1月28日 18 | * @Copyright (c) 2015, lifesense.com 19 | */ 20 | public class DemoTask2 extends AbstractJob{ 21 | 22 | @Override 23 | public void doJob(JobContext context) throws Exception { 24 | System.out.println("\n=============\nDemoTask_2=====>"+context.getNodeId()+"--"+DateUtils.format(new Date())+"\n===============\n"); 25 | Thread.sleep(RandomUtils.nextLong(1000, 2000)); 26 | } 27 | 28 | @Override 29 | public boolean parallelEnabled() { 30 | return false; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /jeesuite-common/src/main/java/com/jeesuite/common/util/WhoUseMeReporter.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.common.util; 2 | 3 | import com.jeesuite.common.http.HttpUtils; 4 | 5 | /** 6 | * 这个一个上报工具:仅仅是为了知道谁在用我们 7 | * @description
8 | * @author vakin 9 | * @website vakin 10 | * @date 2019年6月18日 11 | */ 12 | public class WhoUseMeReporter { 13 | 14 | private static volatile boolean done = false; 15 | 16 | /** 17 | * 18 | * @param domain 域名 19 | * @param product 我们的产品名称 20 | */ 21 | public static void post(String domain,String product){ 22 | if(done)return; 23 | done = true; 24 | new Thread(new Runnable() { 25 | @Override 26 | public void run() { 27 | try { 28 | String url = String.format("http://www.jeesuite.com/whoami?domain=%s&product=%s", domain,product); 29 | HttpUtils.get(url); 30 | } catch (Exception e) {} 31 | } 32 | }).start(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /jeesuite-security/src/main/java/com/jeesuite/security/model/AccessToken.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.security.model; 2 | 3 | public class AccessToken { 4 | 5 | private String access_token; 6 | private String refresh_token; 7 | private int expires_in; 8 | private String payload; 9 | 10 | public String getAccess_token() { 11 | return access_token; 12 | } 13 | public void setAccess_token(String access_token) { 14 | this.access_token = access_token; 15 | } 16 | public String getRefresh_token() { 17 | return refresh_token; 18 | } 19 | public void setRefresh_token(String refresh_token) { 20 | this.refresh_token = refresh_token; 21 | } 22 | public int getExpires_in() { 23 | return expires_in; 24 | } 25 | public void setExpires_in(int expires_in) { 26 | this.expires_in = expires_in; 27 | } 28 | public String getPayload() { 29 | return payload; 30 | } 31 | public void setPayload(String payload) { 32 | this.payload = payload; 33 | } 34 | 35 | 36 | } 37 | -------------------------------------------------------------------------------- /jeesuite-mybatis/src/main/java/com/jeesuite/mybatis/plugin/pagination/PageParams.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.mybatis.plugin.pagination; 2 | 3 | public class PageParams { 4 | 5 | //当前页 6 | private int pageNo = 1; 7 | //每页的数量 8 | private int pageSize = 10; 9 | 10 | 11 | public PageParams() {} 12 | 13 | public PageParams(int pageNo, int pageSize) { 14 | super(); 15 | this.pageNo = pageNo; 16 | this.pageSize = pageSize; 17 | } 18 | 19 | public int getPageNo() { 20 | return pageNo; 21 | } 22 | public void setPageNo(int pageNo) { 23 | this.pageNo = pageNo; 24 | } 25 | public int getPageSize() { 26 | return pageSize; 27 | } 28 | public void setPageSize(int pageSize) { 29 | this.pageSize = pageSize; 30 | } 31 | 32 | public int offset() { 33 | return (pageNo - 1) * pageSize; 34 | } 35 | 36 | @Override 37 | public String toString() { 38 | return "PageParams [pageNo=" + pageNo + ", pageSize=" + pageSize + "]"; 39 | } 40 | 41 | 42 | } 43 | -------------------------------------------------------------------------------- /jeesuite-scheduler/src/test/java/com/jeesuite/test/sch/JobInterceptor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.test.sch; 5 | 6 | import org.aspectj.lang.ProceedingJoinPoint; 7 | import org.aspectj.lang.annotation.Around; 8 | import org.aspectj.lang.annotation.Aspect; 9 | import org.aspectj.lang.annotation.Pointcut; 10 | import org.slf4j.Logger; 11 | import org.slf4j.LoggerFactory; 12 | import org.springframework.core.annotation.Order; 13 | import org.springframework.stereotype.Service; 14 | 15 | @Aspect 16 | @Service 17 | @Order(0) 18 | public class JobInterceptor{ 19 | 20 | protected static final Logger logger = LoggerFactory.getLogger(JobInterceptor.class); 21 | 22 | //定义拦截切面 23 | @Pointcut("execution(* com.jeesuite.test.sch..*.*(..))") 24 | public void pointcut(){} 25 | 26 | @Around("pointcut()") 27 | public Object around(ProceedingJoinPoint pjp) throws Throwable{ 28 | System.out.println("并没什么卵用,只是测试cglib生成代理类"); 29 | return pjp.proceed(); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /jeesuite-security/src/main/java/com/jeesuite/security/SecurityTicketManager.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.security; 2 | 3 | import com.jeesuite.common.util.TokenGenerator; 4 | import com.jeesuite.security.SecurityConstants.CacheType; 5 | import com.jeesuite.security.cache.LocalCache; 6 | import com.jeesuite.security.cache.RedisCache; 7 | 8 | public class SecurityTicketManager { 9 | 10 | private Cache cache; 11 | 12 | public SecurityTicketManager(SecurityDecisionProvider decisionProvider) { 13 | if(CacheType.redis == decisionProvider.cacheType()){ 14 | this.cache = new RedisCache("security.ticket:", 180); 15 | }else{ 16 | this.cache = new LocalCache(180); 17 | } 18 | } 19 | 20 | public String setTicketObject(Object ticketObject){ 21 | String ticket = TokenGenerator.generate(); 22 | cache.setObject(ticket, ticketObject); 23 | return ticket; 24 | } 25 | 26 | public T getTicketObject(String ticket){ 27 | return cache.getObject(ticket); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /jeesuite-mybatis/jeesuite-mybatis.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /jeesuite-kafka/src/main/java/com/jeesuite/kafka/consumer/hanlder/OffsetLogHanlder.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.kafka.consumer.hanlder; 5 | 6 | /** 7 | * 消息消费偏移量记录器 8 | * @description
9 | * @author vakin 10 | * @date 2017年2月10日 11 | */ 12 | public interface OffsetLogHanlder { 13 | 14 | /** 15 | * 获取上一次记录的已经处理的偏移量 16 | * @param group 17 | * @param topic 18 | * @param partition 19 | * @return 20 | */ 21 | long getLatestProcessedOffsets(String group,String topic,int partition); 22 | 23 | /** 24 | * 处理前记录偏移量 25 | * @param group 26 | * @param topic 27 | * @param partition 28 | * @param offset 29 | */ 30 | void saveOffsetsBeforeProcessed(String group,String topic,int partition,long offset); 31 | 32 | /** 33 | * 处理后记录偏移量 34 | * @param group 35 | * @param topic 36 | * @param partition 37 | * @param offset 38 | */ 39 | void saveOffsetsAfterProcessed(String group,String topic,int partition,long offset); 40 | } 41 | -------------------------------------------------------------------------------- /jeesuite-mybatis/src/main/java/com/jeesuite/mybatis/kit/SqlParseUtils.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.mybatis.kit; 2 | 3 | import java.util.List; 4 | 5 | import com.alibaba.druid.sql.ast.SQLStatement; 6 | import com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser; 7 | import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlSchemaStatVisitor; 8 | 9 | public class SqlParseUtils { 10 | 11 | public static void main(String[] args) { 12 | String sql = "DELETE a1, a2 FROM t1 AS a1 INNER JOIN t2 AS a2 WHERE a1.id=a2.id;"; 13 | 14 | MySqlStatementParser parser = new MySqlStatementParser(sql); 15 | List statementList = parser.parseStatementList(); 16 | SQLStatement statemen = statementList.get(0); 17 | 18 | MySqlSchemaStatVisitor visitor = new MySqlSchemaStatVisitor(); 19 | statemen.accept(visitor); 20 | 21 | System.out.println(visitor.getTables()); 22 | 23 | System.out.println(visitor.getColumns()); 24 | 25 | System.out.println(visitor.getConditions()); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /jeesuite-common2/src/test/java/test/sequence/IdGenerateTest.java: -------------------------------------------------------------------------------- 1 | package test.sequence; 2 | 3 | import java.util.concurrent.ExecutorService; 4 | import java.util.concurrent.Executors; 5 | import java.util.concurrent.atomic.AtomicInteger; 6 | 7 | import com.jeesuite.common2.sequence.SnowflakeGenerator; 8 | 9 | public class IdGenerateTest { 10 | 11 | public static void main(String[] args) { 12 | 13 | long start = System.currentTimeMillis(); 14 | 15 | SnowflakeGenerator generator = new SnowflakeGenerator(1,1); 16 | 17 | AtomicInteger count = new AtomicInteger(0); 18 | 19 | ExecutorService service = Executors.newFixedThreadPool(100); 20 | 21 | while(true){ 22 | if(System.currentTimeMillis() - start > 1000){ 23 | System.out.println(count.get()); 24 | break; 25 | } 26 | service.execute(new Runnable() { 27 | 28 | @Override 29 | public void run() { 30 | generator.nextId(); 31 | count.incrementAndGet(); 32 | } 33 | }); 34 | } 35 | 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /jeesuite-mybatis/src/main/java/com/jeesuite/mybatis/plugin/cache/CacheProvider.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.mybatis.plugin.cache; 5 | 6 | import java.io.Closeable; 7 | 8 | /** 9 | * @description
10 | * @author vakin 11 | * @date 2016年3月23日 12 | * @Copyright (c) 2015, jwww 13 | */ 14 | public interface CacheProvider extends Closeable{ 15 | 16 | T get(String key); 17 | 18 | String getStr(String key); 19 | 20 | boolean set(String key,Object value,long expireSeconds); 21 | 22 | boolean setStr(String key,Object value,long expireSeconds); 23 | 24 | boolean remove(String key); 25 | 26 | boolean exists(String key); 27 | 28 | void addZsetValue(String key,String value,double score); 29 | boolean existZsetValue(String key,String value); 30 | boolean removeZsetValue(String key,String value); 31 | boolean removeZsetValues(String key,double minScore, double maxScore); 32 | 33 | boolean setnx(String key,String value,long expireSeconds); 34 | } 35 | -------------------------------------------------------------------------------- /jeesuite-scheduler/src/main/java/com/jeesuite/scheduler/annotation/ScheduleConf.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.scheduler.annotation; 5 | 6 | import java.lang.annotation.Documented; 7 | import java.lang.annotation.ElementType; 8 | import java.lang.annotation.Inherited; 9 | import java.lang.annotation.Retention; 10 | import java.lang.annotation.RetentionPolicy; 11 | import java.lang.annotation.Target; 12 | 13 | /** 14 | * @description
15 | * @author vakin 16 | * @date 2015年12月10日 17 | * @Copyright (c) 2015, jwww 18 | */ 19 | @Target({ElementType.TYPE }) 20 | @Retention(RetentionPolicy.RUNTIME) 21 | @Inherited 22 | @Documented 23 | public @interface ScheduleConf { 24 | /** 25 | * 任务名称 26 | * @return 27 | */ 28 | String jobName(); 29 | 30 | /** 31 | * 重试次数 32 | * @return 33 | */ 34 | int retries() default 0; 35 | 36 | String cronExpr(); 37 | /** 38 | * 是否启动立即执行一次 39 | * @return 40 | */ 41 | boolean executeOnStarted() default false; 42 | } 43 | -------------------------------------------------------------------------------- /jeesuite-scheduler/src/main/java/com/jeesuite/scheduler/model/JobGroupInfo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.scheduler.model; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | /** 10 | * @description
11 | * @author vakin 12 | * @date 2016年10月30日 13 | */ 14 | public class JobGroupInfo { 15 | 16 | private String name; 17 | 18 | List jobs = new ArrayList<>(); 19 | 20 | ListclusterNodes = new ArrayList<>(); 21 | 22 | public String getName() { 23 | return name; 24 | } 25 | 26 | public void setName(String name) { 27 | this.name = name; 28 | } 29 | 30 | public List getJobs() { 31 | return jobs; 32 | } 33 | 34 | public void setJobs(List jobs) { 35 | this.jobs = jobs; 36 | } 37 | 38 | public List getClusterNodes() { 39 | return clusterNodes; 40 | } 41 | 42 | public void setClusterNodes(List clusterNodes) { 43 | this.clusterNodes = clusterNodes; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /jeesuite-springweb/src/main/java/com/jeesuite/springweb/client/RestTemplateAutoHeaderInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.springweb.client; 2 | 3 | import java.io.IOException; 4 | import java.util.Map; 5 | 6 | import org.springframework.http.HttpRequest; 7 | import org.springframework.http.client.ClientHttpRequestExecution; 8 | import org.springframework.http.client.ClientHttpRequestInterceptor; 9 | import org.springframework.http.client.ClientHttpResponse; 10 | 11 | import com.jeesuite.springweb.utils.WebUtils; 12 | 13 | public class RestTemplateAutoHeaderInterceptor implements ClientHttpRequestInterceptor { 14 | 15 | 16 | @Override 17 | public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) 18 | throws IOException { 19 | try { 20 | Map customHeaders = WebUtils.getCustomHeaders(); 21 | request.getHeaders().setAll(customHeaders); 22 | } catch (Exception e) {} 23 | return execution.execute(request, body); 24 | } 25 | 26 | 27 | 28 | 29 | } 30 | -------------------------------------------------------------------------------- /jeesuite-common/src/main/java/com/jeesuite/common/serializer/SerializeUtils.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.common.serializer; 2 | 3 | import java.io.IOException; 4 | 5 | /** 6 | * @description
7 | * @author vakin 8 | * @date 2016年12月28日 9 | */ 10 | public class SerializeUtils { 11 | 12 | static KryoPoolSerializer serializer = new KryoPoolSerializer(); 13 | /** 14 | * 序列化 15 | * 16 | * @param object 需要序列化的对象 17 | * @return 18 | */ 19 | public static byte[] serialize(Object object) { 20 | try { 21 | return serializer.serialize(object); 22 | } catch (IOException e) { 23 | throw new RuntimeException(e); 24 | } 25 | } 26 | 27 | /** 28 | * 反序列化 29 | * 30 | * @param bytes 需要被反序列化的数据 31 | * @return 32 | */ 33 | public static Object deserialize(byte[] bytes) { 34 | try { 35 | return serializer.deserialize(bytes); 36 | } catch (IOException e) { 37 | throw new RuntimeException(e); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /jeesuite-common/src/main/java/com/jeesuite/common/json/serializer/DateTimeConvertSerializer.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.common.json.serializer; 2 | 3 | import java.io.IOException; 4 | import java.text.DateFormat; 5 | import java.text.SimpleDateFormat; 6 | import java.util.Date; 7 | 8 | import com.fasterxml.jackson.core.JsonGenerator; 9 | import com.fasterxml.jackson.core.JsonProcessingException; 10 | import com.fasterxml.jackson.databind.JsonSerializer; 11 | import com.fasterxml.jackson.databind.SerializerProvider; 12 | 13 | 14 | public class DateTimeConvertSerializer extends JsonSerializer { 15 | 16 | private static final String pattern = "yyyy-MM-dd HH:mm:ss"; 17 | 18 | @Override 19 | public void serialize(Date date, JsonGenerator jgen, SerializerProvider provider) throws JsonProcessingException { 20 | try { 21 | DateFormat dateFormat = new SimpleDateFormat(pattern); 22 | jgen.writeString(dateFormat.format(date)); 23 | } catch (IOException e) { 24 | throw new RuntimeException("Date转换json异常,格式:" + pattern); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /jeesuite-mybatis/src/test/java/com/jeesuite/mybatis/test/mapper/SnsAccounyBindingEntityMapper.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.mybatis.test.mapper; 2 | 3 | import java.util.List; 4 | 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import com.jeesuite.mybatis.core.BaseMapper; 8 | import com.jeesuite.mybatis.plugin.cache.annotation.Cache; 9 | import com.jeesuite.mybatis.test.entity.SnsAccounyBindingEntity; 10 | 11 | public interface SnsAccounyBindingEntityMapper extends BaseMapper{ 12 | 13 | @Cache 14 | SnsAccounyBindingEntity findBySnsOpenId(@Param("snsType") String snsType,@Param("openId") String openId); 15 | 16 | @Cache 17 | SnsAccounyBindingEntity findByWxUnionIdAndOpenId(@Param("unionId") String unionId,@Param("openId") String openId); 18 | 19 | @Cache 20 | List findByUnionId(@Param("unionId") String unionId); 21 | 22 | @Cache 23 | List findByUserId(@Param("userId") int userId); 24 | 25 | @Cache 26 | String findWxUnionIdByUserId(@Param("userId") int userId); 27 | } -------------------------------------------------------------------------------- /jeesuite-scheduler/src/test/java/com/jeesuite/test/sch/DemoParallelTask.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.test.sch; 5 | 6 | import java.util.ArrayList; 7 | import java.util.Arrays; 8 | import java.util.List; 9 | 10 | import com.jeesuite.scheduler.AbstractJob; 11 | import com.jeesuite.scheduler.JobContext; 12 | 13 | 14 | public class DemoParallelTask extends AbstractJob{ 15 | 16 | int count = 1; 17 | @Override 18 | public void doJob(JobContext context) throws Exception { 19 | //首先加载所有要处理的数据,譬如所有需要处理的用户 20 | List userids = new ArrayList(Arrays.asList(1001L,2001L,1002L,2002L,1003L,2003L));//load all 21 | for (Long userId : userids) { 22 | //判断是否分配到当前节点执行 23 | if(!context.matchCurrentNode(userId)){ 24 | System.out.println(">>>>>>not matchCurrentNode --ignore"); 25 | continue; 26 | } 27 | // 处理具体业务逻辑 28 | System.out.println("<<<<<<"+count); 29 | } 30 | count++; 31 | } 32 | 33 | @Override 34 | public boolean parallelEnabled() { 35 | //开启并行计算 36 | return true; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /jeesuite-common/src/main/java/com/jeesuite/common/json/serializer/DateConvertSerializer.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.common.json.serializer; 2 | 3 | import java.io.IOException; 4 | import java.text.DateFormat; 5 | import java.text.SimpleDateFormat; 6 | import java.util.Date; 7 | 8 | import com.fasterxml.jackson.core.JsonGenerator; 9 | import com.fasterxml.jackson.core.JsonProcessingException; 10 | import com.fasterxml.jackson.databind.JsonSerializer; 11 | import com.fasterxml.jackson.databind.SerializerProvider; 12 | 13 | 14 | public class DateConvertSerializer extends JsonSerializer { 15 | 16 | private static final String pattern = "yyyy-MM-dd"; 17 | 18 | @Override 19 | public void serialize(Date date, JsonGenerator jgen, SerializerProvider provider) throws JsonProcessingException { 20 | try { 21 | DateFormat dateFormat = new SimpleDateFormat(pattern); 22 | jgen.writeString(dateFormat.format(date)); 23 | } catch (IOException e) { 24 | throw new RuntimeException("Date转换json异常,格式:" + pattern); 25 | } 26 | // log.debug("日期类型序列化"); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /jeesuite-cache/src/main/java/com/jeesuite/cache/CacheExpires.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.cache; 5 | 6 | import java.util.Date; 7 | 8 | import com.jeesuite.common.util.DateUtils; 9 | 10 | /** 11 | * 12 | * @description
13 | * @author vakin 14 | * @date 2015年4月28日 15 | */ 16 | public class CacheExpires { 17 | 18 | public final static long IN_1MIN = 60; 19 | 20 | public final static long IN_3MINS = 60 * 3; 21 | 22 | public final static long IN_5MINS = 60 * 5; 23 | 24 | public final static long IN_1HOUR = 60 * 60; 25 | 26 | public final static long IN_HALF_HOUR = 60 * 30; 27 | 28 | public final static long IN_1DAY = IN_1HOUR * 24; 29 | 30 | public final static long IN_1WEEK = IN_1DAY * 7; 31 | 32 | public final static long IN_1MONTH = IN_1DAY * 30; 33 | 34 | /** 35 | * 当前时间到今天结束相隔的秒 36 | * @return 37 | */ 38 | public static long todayEndSeconds(){ 39 | Date curTime = new Date(); 40 | return DateUtils.getDiffSeconds(DateUtils.getDayEnd(curTime), curTime); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /jeesuite-kafka/src/test/java/com/jeesuite/test/Demo2MessageHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.test; 5 | 6 | import java.io.Serializable; 7 | 8 | import com.jeesuite.kafka.handler.MessageHandler; 9 | import com.jeesuite.kafka.message.DefaultMessage; 10 | 11 | /** 12 | * @description
13 | * @author vakin 14 | * @date 2016年6月25日 15 | */ 16 | public class Demo2MessageHandler implements MessageHandler { 17 | 18 | 19 | @Override 20 | public void p1Process(DefaultMessage message) { 21 | //TODO 第一阶段处理,譬如一些需要及时 22 | } 23 | 24 | @Override 25 | public void p2Process(DefaultMessage message) { 26 | //第二阶段处理一些耗时操作,如:最终入库 27 | Serializable body = message.getBody(); 28 | System.out.println(String.format("Demo2MessageHandler process messageId:%s,body:%s", message.getMsgId(),body)); 29 | try {Thread.sleep(500);} catch (Exception e) {} 30 | } 31 | 32 | 33 | @Override 34 | public boolean onProcessError(DefaultMessage message) { 35 | //如果业务自己处理消费错误的消息,再这里实现并return false; 36 | return false; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /jeesuite-rest/src/main/java/com/jeesuite/rest/response/ResponseCode.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.rest.response; 2 | 3 | public enum ResponseCode implements HttpCodeType { 4 | 5 | OK(200, "成功"), 6 | 7 | BAD_REQUEST(400, "错误请求"), 8 | 9 | UNAUTHORIZED(401, "未授权"), 10 | 11 | FORBIDDEN(403, "禁止访问"), 12 | 13 | NOT_FOUND(404, "找不到路径"), 14 | 15 | METHOD_NOT_ALLOWED(405, "不允许此方法"), 16 | 17 | UNSUPPORTED_MEDIA_TYPE(415, "不支持的媒体类型"), 18 | 19 | NOT_ALLOW_NULL(418,"不允许为空"), 20 | 21 | NOT_ALLOWED_REPEAT(419,"不允许重复"), 22 | 23 | NO_RESOURCES(420,"资源不存在"), 24 | 25 | ERROR_JSON(499, "错误JSON"), 26 | 27 | INTERNAL_SERVER_ERROR(500, "服务器异常"); 28 | 29 | private int code; 30 | 31 | private String msg; 32 | 33 | ResponseCode(int code, String msg) { 34 | this.code = code; 35 | this.msg = msg; 36 | } 37 | 38 | public int getCode() { 39 | return code; 40 | } 41 | 42 | public void setCode(int code) { 43 | this.code = code; 44 | } 45 | 46 | public String getMsg() { 47 | return msg; 48 | } 49 | 50 | public void setMsg(String msg) { 51 | this.msg = msg; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /jeesuite-common/src/test/java/test/serlalize/SerliazePerfTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package test.serlalize; 5 | 6 | import java.io.IOException; 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | import com.jeesuite.common.json.JsonUtils; 11 | import com.jeesuite.common.serializer.JavaSerializer; 12 | import com.jeesuite.common.serializer.SerializeUtils; 13 | 14 | import test.User; 15 | 16 | /** 17 | * @description
18 | * @author vakin 19 | * @date 2016年12月28日 20 | */ 21 | public class SerliazePerfTest { 22 | 23 | public static void main(String[] args) throws IOException { 24 | JavaSerializer javaSerializer = new JavaSerializer(); 25 | List users = new ArrayList<>(); 26 | for (int i = 0; i < 10; i++) { 27 | users.add(new User(i+1000, "user"+i)); 28 | } 29 | 30 | byte[] bytes = javaSerializer.serialize(users); 31 | System.out.println(bytes.length); 32 | System.out.println(SerializeUtils.serialize(users).length); 33 | System.out.println(JsonUtils.toJson(users).getBytes().length); 34 | 35 | 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /jeesuite-scheduler/src/main/java/com/jeesuite/scheduler/JobRegistry.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.scheduler; 5 | 6 | import java.util.Date; 7 | import java.util.List; 8 | 9 | import com.jeesuite.scheduler.model.JobConfig; 10 | 11 | /** 12 | * 类 名:ControlHandler.java
13 | * 14 | * 功能描述:  定时任务执行控制接口
15 | * 16 | * 创建日期:2012-11-22下午04:44:06
17 | * 18 | * 版本信息:v 1.0
19 | * 20 | * 版权信息:Copyright (c) 2011 Csair All Rights Reserved
21 | * 22 | * 作 者:vakin jiang
23 | * 24 | * 修改记录:
25 | * 修 改 者 修改日期 文件版本 修改说明 26 | */ 27 | public interface JobRegistry { 28 | 29 | void register(JobConfig conf); 30 | 31 | void updateJobConfig(JobConfig conf); 32 | 33 | void setRuning(String jobName,Date fireTime); 34 | 35 | void setStoping(String jobName,Date nextFireTime,Exception e); 36 | 37 | JobConfig getConf(String jobName,boolean forceRemote); 38 | 39 | void unregister(String jobName); 40 | 41 | List getAllJobs(); 42 | 43 | void onRegistered(); 44 | } 45 | -------------------------------------------------------------------------------- /jeesuite-kafka/src/test/java/com/jeesuite/test/ConsumerServer2.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.test; 2 | 3 | import java.util.Scanner; 4 | 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | import org.springframework.context.support.ClassPathXmlApplicationContext; 8 | 9 | 10 | public class ConsumerServer2 { 11 | 12 | private static Logger logger = LoggerFactory.getLogger(ConsumerServer2.class); 13 | public static void main(String[] args) throws InterruptedException{ 14 | 15 | final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("test-kafka-consumer.xml"); 16 | 17 | logger.info("Kafka Consumer started...."); 18 | Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { 19 | 20 | @Override 21 | public void run() { 22 | logger.info("Kafka Consumer Stoped...."); 23 | context.close(); 24 | } 25 | })); 26 | 27 | Scanner scan=new Scanner(System.in); 28 | String cmd=scan.next(); 29 | if("q".equalsIgnoreCase(cmd)){ 30 | context.close(); 31 | scan.close(); 32 | } 33 | 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /jeesuite-kafka/src/test/java/com/jeesuite/test/DemoMessageHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.test; 5 | 6 | import java.io.Serializable; 7 | 8 | import org.apache.commons.lang3.StringUtils; 9 | 10 | import com.jeesuite.kafka.handler.MessageHandler; 11 | import com.jeesuite.kafka.message.DefaultMessage; 12 | 13 | /** 14 | * @description
15 | * @author vakin 16 | * @date 2016年6月25日 17 | */ 18 | public class DemoMessageHandler implements MessageHandler { 19 | 20 | 21 | @Override 22 | public void p1Process(DefaultMessage message) { 23 | //TODO 24 | } 25 | 26 | @Override 27 | public void p2Process(DefaultMessage message) { 28 | Serializable body = message.getBody(); 29 | System.out.println(String.format("DemoMessageHandler process messageId:%s,body:%s", message.getMsgId(),body)); 30 | try {Thread.sleep(100);} catch (Exception e) {} 31 | } 32 | 33 | 34 | @Override 35 | public boolean onProcessError(DefaultMessage message) { 36 | System.out.println("ignore error message : "+message); 37 | return true; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /jeesuite-common2/src/test/java/test/excel/ExcelTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package test.excel; 5 | 6 | import java.io.IOException; 7 | import java.util.List; 8 | 9 | import org.apache.poi.openxml4j.exceptions.InvalidFormatException; 10 | 11 | import com.jeesuite.common.json.JsonUtils; 12 | import com.jeesuite.common2.excel.ExcelPerfModeReader; 13 | import com.jeesuite.common2.excel.ExcelReader; 14 | import com.jeesuite.common2.excel.ExcelWriter; 15 | 16 | /** 17 | * @description
18 | * @author vakin 19 | * @date 2017年1月3日 20 | */ 21 | public class ExcelTest { 22 | 23 | /** 24 | * @param args 25 | * @throws IOException 26 | * @throws InvalidFormatException 27 | */ 28 | public static void main(String[] args) throws InvalidFormatException, IOException { 29 | //普通方式读取 30 | String excelFilePath = "/Users/jiangwei/Desktop/invorderdet_template.xlsx"; 31 | 32 | //大文件读取防止内存溢出 33 | List list = new ExcelPerfModeReader(excelFilePath).read(SimpleSalaryInfo.class); 34 | 35 | System.out.println(JsonUtils.toPrettyJson(list)); 36 | 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /jeesuite-kafka/src/test/java/com/jeesuite/test/RunClass.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.test; 5 | 6 | import java.io.IOException; 7 | 8 | import kafka.admin.ConsumerGroupCommand; 9 | 10 | /** 11 | * @description
12 | * @author vakin 13 | * @date 2016年12月7日 14 | */ 15 | public class RunClass { 16 | 17 | /** 18 | * @param args 19 | * @throws IOException 20 | */ 21 | public static void main(String[] args) throws IOException { 22 | //group-1是消费者的group名称,可以在zk中 23 | //args = new String[]{"--zookeeper=127.0.0.1:2181","--group=kafka-demo2"}; 24 | //ConsumerOffsetChecker.main(arr); 25 | args = new String[]{"--bootstrap-server=127.0.0.1:9092","--group=kafka-demo2","--new-consumer","--describe"}; 26 | 27 | // File f=new File("/Users/ayg/Desktop/out.txt"); 28 | // f.createNewFile(); 29 | // FileOutputStream fileOutputStream = new FileOutputStream(f); 30 | // PrintStream printStream = new PrintStream(fileOutputStream); 31 | // System.setOut(printStream); 32 | ConsumerGroupCommand.main(args); 33 | 34 | 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /jeesuite-kafka/src/test/java/com/jeesuite/test/ZkClientTest.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.test; 2 | 3 | import java.util.concurrent.ExecutorService; 4 | import java.util.concurrent.Executors; 5 | 6 | import org.I0Itec.zkclient.ZkClient; 7 | import org.apache.commons.lang3.RandomStringUtils; 8 | 9 | import com.jeesuite.kafka.KafkaConst; 10 | import com.jeesuite.kafka.serializer.ZKStringSerializer; 11 | 12 | public class ZkClientTest { 13 | 14 | 15 | public static void main(String[] args) throws Exception { 16 | ZkClient zkClient = new ZkClient("127.0.0.1:2181", 10000, 5000, new ZKStringSerializer()); 17 | 18 | ExecutorService service = Executors.newFixedThreadPool(5); 19 | 20 | for (int i = 0; i < 100; i++) { 21 | service.execute(new Runnable() { 22 | @Override 23 | public void run() { 24 | String path = KafkaConst.ZK_PRODUCER_ACK_PATH + RandomStringUtils.random(5, true, true); 25 | zkClient.createEphemeral(path); 26 | System.out.println(path); 27 | } 28 | }); 29 | if(i % 5 == 0){ 30 | Thread.sleep(500); 31 | System.out.println("Sleep"); 32 | } 33 | } 34 | 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /jeesuite-filesystem/src/main/java/com/jeesuite/filesystem/provider/FSOperErrorException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.filesystem.provider; 5 | 6 | import com.jeesuite.common.JeesuiteBaseException; 7 | 8 | /** 9 | * @description
10 | * @author vakin 11 | * @date 2017年1月7日 12 | */ 13 | public class FSOperErrorException extends JeesuiteBaseException { 14 | 15 | 16 | private static final long serialVersionUID = 1L; 17 | 18 | private int code; 19 | 20 | public FSOperErrorException() { 21 | } 22 | 23 | public FSOperErrorException(String privoderName,Throwable cause) { 24 | super(9999, privoderName, cause); 25 | } 26 | 27 | public FSOperErrorException(String privoderName,String message) { 28 | this(privoderName, 500, message); 29 | } 30 | 31 | public FSOperErrorException(String privoderName,int code,String message) { 32 | super(9999,privoderName + "[" + message + "]"); 33 | this.code = code; 34 | } 35 | 36 | public int getCode() { 37 | return code; 38 | } 39 | 40 | public void setCode(int code) { 41 | this.code = code; 42 | } 43 | 44 | 45 | } 46 | -------------------------------------------------------------------------------- /jeesuite-mybatis/src/main/java/com/jeesuite/mybatis/crud/builder/SqlTemplate.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.mybatis.crud.builder; 5 | 6 | /** 7 | * @description
8 | * @author vakin 9 | * @date 2016年10月25日 10 | */ 11 | public class SqlTemplate { 12 | 13 | public static final String IF_TAG_TEAMPLATE = "%s,"; 14 | public static final String SCRIPT_TEMAPLATE = ""; 15 | public static final String TRIM_PREFIX = "\n"; 16 | public static final String TRIM_SUFFIX = ""; 17 | 18 | public static final String INSERT = "INSERT INTO %s \n %s \n VALUES \n %s"; 19 | public static final String UPDATE_BY_KEY = "UPDATE %s %s \n WHERE %s = #{%s}"; 20 | public static final String BATCH_INSERT = "INSERT INTO %s \n %s \n VALUES \n %s"; 21 | 22 | public static String wrapIfTag(String fieldName,String expr,boolean skip){ 23 | if(skip)return expr; 24 | return String.format(IF_TAG_TEAMPLATE, fieldName,expr); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /jeesuite-rest/src/main/java/com/jeesuite/rest/filter/DefaultFilterDynamicFeature.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.rest.filter; 2 | 3 | import java.lang.reflect.Method; 4 | 5 | import javax.ws.rs.container.DynamicFeature; 6 | import javax.ws.rs.container.ResourceInfo; 7 | import javax.ws.rs.core.FeatureContext; 8 | 9 | import com.jeesuite.rest.filter.annotation.ResponseFormat; 10 | import com.jeesuite.rest.filter.annotation.ResponseFormat.FormatType; 11 | 12 | /** 13 | * 14 | * @description
15 | * @author vakin 16 | * @date 2016年2月25日 17 | */ 18 | public class DefaultFilterDynamicFeature implements DynamicFeature { 19 | 20 | @Override 21 | public void configure(ResourceInfo resourceInfo, FeatureContext context) { 22 | // 获取资源方法 23 | Method resourceMethod = resourceInfo.getResourceMethod(); 24 | 25 | if (resourceMethod != null) { 26 | 27 | // 获取FormatJson注解 28 | ResponseFormat formatJson = resourceMethod.getAnnotation(ResponseFormat.class); 29 | 30 | if(formatJson == null || formatJson.type().equals(FormatType.JSON)){ 31 | context.register(DefaultWebFilter.class); 32 | } 33 | 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /jeesuite-scheduler/src/test/java/com/jeesuite/test/sch/DemoTask.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.test.sch; 5 | 6 | import java.util.Date; 7 | 8 | import org.apache.commons.lang3.RandomUtils; 9 | import org.springframework.stereotype.Service; 10 | 11 | import com.jeesuite.common.util.DateUtils; 12 | import com.jeesuite.scheduler.AbstractJob; 13 | import com.jeesuite.scheduler.JobContext; 14 | import com.jeesuite.scheduler.annotation.ScheduleConf; 15 | 16 | /** 17 | * @description
18 | * @author vakin 19 | * @date 2016年1月28日 20 | * @Copyright (c) 2015, lifesense.com 21 | */ 22 | @Service 23 | @ScheduleConf(cronExpr="0/30 * * * * ?",jobName="demoTask",executeOnStarted = true) 24 | public class DemoTask extends AbstractJob{ 25 | 26 | @Override 27 | public void doJob(JobContext context) throws Exception { 28 | System.out.println("\n=============\nDemoTask_1=====>"+context.getNodeId()+"--"+DateUtils.format(new Date())+"\n===============\n"); 29 | Thread.sleep(RandomUtils.nextLong(1000, 2000)); 30 | } 31 | 32 | @Override 33 | public boolean parallelEnabled() { 34 | return false; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /jeesuite-filesystem/src/main/java/com/jeesuite/filesystem/provider/AbstractProvider.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.filesystem.provider; 5 | 6 | import com.jeesuite.common.http.HttpUtils; 7 | import com.jeesuite.filesystem.FSProvider; 8 | 9 | /** 10 | * @description
11 | * @author vakin 12 | * @date 2017年1月7日 13 | */ 14 | public abstract class AbstractProvider implements FSProvider{ 15 | 16 | protected static final String URL_PREFIX_PATTERN = "(http).*\\.(com|cn)\\/"; 17 | protected static final String HTTP_PREFIX = "http://"; 18 | protected static final String HTTPS_PREFIX = "https://"; 19 | 20 | protected static final String DIR_SPLITER = "/"; 21 | 22 | protected String urlprefix; 23 | 24 | protected String bucketName; 25 | 26 | protected String getFullPath(String file) { 27 | if(file.startsWith(HTTP_PREFIX) || file.startsWith(HTTPS_PREFIX)){ 28 | return file; 29 | } 30 | return urlprefix + file; 31 | } 32 | 33 | 34 | @Override 35 | public String downloadAndSaveAs(String file, String localSaveDir) { 36 | return HttpUtils.downloadFile(getDownloadUrl(file), localSaveDir); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /jeesuite-common2/src/main/java/com/jeesuite/common2/lock/DistributeLockTemplate.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.common2.lock; 5 | 6 | import com.jeesuite.common2.lock.redis.RedisDistributeLock; 7 | 8 | /** 9 | * @description
10 | * @author vakin 11 | * @date 2016年7月22日 12 | */ 13 | public class DistributeLockTemplate { 14 | 15 | private static final int _DEFAULT_LOCK_HOLD_MILLS = 30; 16 | 17 | 18 | public static T execute(String lockId,LockCaller caller){ 19 | return execute(lockId, caller, _DEFAULT_LOCK_HOLD_MILLS); 20 | } 21 | 22 | /** 23 | * @param lockId 要确保不和其他业务冲突(不能用随机生成) 24 | * @param caller 业务处理器 25 | * @param timeout 超时时间(秒) 26 | * @return 27 | */ 28 | public static T execute(String lockId,LockCaller caller,int timeout){ 29 | RedisDistributeLock dLock = new RedisDistributeLock(lockId,(int)timeout/1000); 30 | 31 | boolean getLock = false; 32 | try { 33 | if(dLock.tryLock()){ 34 | getLock = true; 35 | return caller.onHolder(); 36 | }else{ 37 | return caller.onWait(); 38 | } 39 | } finally { 40 | if(getLock)dLock.unlock(); 41 | } 42 | 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /jeesuite-kafka/src/main/java/com/jeesuite/kafka/monitor/model/BrokerInfo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.kafka.monitor.model; 5 | 6 | /** 7 | * @description
8 | * @author vakin 9 | * @date 2016年10月28日 10 | */ 11 | public class BrokerInfo { 12 | 13 | private String id; 14 | private String host; 15 | private int port; 16 | private int version; 17 | 18 | public BrokerInfo() {} 19 | 20 | public BrokerInfo(String id, String host, int port) { 21 | super(); 22 | this.id = id; 23 | this.host = host; 24 | this.port = port; 25 | } 26 | 27 | public String getId() { 28 | return id; 29 | } 30 | 31 | public void setId(String id) { 32 | this.id = id; 33 | } 34 | 35 | public String getHost() { 36 | return host; 37 | } 38 | 39 | public void setHost(String host) { 40 | this.host = host; 41 | } 42 | 43 | public int getPort() { 44 | return port; 45 | } 46 | 47 | public void setPort(int port) { 48 | this.port = port; 49 | } 50 | 51 | public int getVersion() { 52 | return version; 53 | } 54 | 55 | public void setVersion(int version) { 56 | this.version = version; 57 | } 58 | 59 | 60 | 61 | } 62 | -------------------------------------------------------------------------------- /jeesuite-kafka/src/test/java/test/StandardThreadExecutorTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package test; 5 | 6 | import org.apache.commons.lang3.RandomUtils; 7 | 8 | import com.jeesuite.kafka.thread.StandardThreadExecutor; 9 | 10 | /** 11 | * @description
12 | * @author vakin 13 | * @date 2016年10月21日 14 | */ 15 | public class StandardThreadExecutorTest { 16 | 17 | /** 18 | * @param args 19 | */ 20 | public static void main(String[] args) { 21 | StandardThreadExecutor executor = new StandardThreadExecutor(1, 20, 10000); 22 | for (int i = 0; i < 5000; i++) { 23 | executor.submit(new Runnable() { 24 | @Override 25 | public void run() { 26 | System.out.println(Thread.currentThread().getName() + ":" + Thread.currentThread().getId() + "---->>>>>"); 27 | try {Thread.sleep(RandomUtils.nextLong(100, 1000));} catch (Exception e) {} 28 | } 29 | }); 30 | } 31 | 32 | while(true){ 33 | try {Thread.sleep(100);} catch (Exception e) {} 34 | System.out.println("poolSize:" +executor.getPoolSize() + ",ActiveCount:" + executor.getActiveCount() + ",queueSize:" + executor.getQueue().size()); 35 | } 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /jeesuite-common/src/main/java/com/jeesuite/common/json/deserializer/DateTimeConvertDeserializer.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.common.json.deserializer; 2 | 3 | import java.io.IOException; 4 | import java.text.DateFormat; 5 | import java.text.ParseException; 6 | import java.text.SimpleDateFormat; 7 | import java.util.Date; 8 | 9 | import com.fasterxml.jackson.core.JsonParser; 10 | import com.fasterxml.jackson.core.JsonProcessingException; 11 | import com.fasterxml.jackson.databind.DeserializationContext; 12 | import com.fasterxml.jackson.databind.JsonDeserializer; 13 | 14 | 15 | public class DateTimeConvertDeserializer extends JsonDeserializer { 16 | 17 | private static String pattern = "yyyy-MM-dd HH:mm:ss"; 18 | 19 | @Override 20 | public Date deserialize(JsonParser jsonParser, DeserializationContext dc) throws JsonProcessingException { 21 | Date date = null; 22 | DateFormat dateFormat = new SimpleDateFormat(pattern); 23 | try { 24 | String val = jsonParser.getText(); 25 | 26 | date = dateFormat.parse(val); 27 | } catch (ParseException | IOException pex) { 28 | throw new RuntimeException("json转换Date异常,格式:" + pattern); 29 | } 30 | 31 | return date; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /jeesuite-security/src/main/java/com/jeesuite/security/util/SecurityCryptUtils.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.security.util; 2 | 3 | import java.nio.charset.StandardCharsets; 4 | 5 | import com.jeesuite.common.crypt.Base64; 6 | import com.jeesuite.common.crypt.DES; 7 | import com.jeesuite.common.util.DigestUtils; 8 | import com.jeesuite.common.util.ResourceUtils; 9 | 10 | public class SecurityCryptUtils { 11 | 12 | private static String cryptKey; 13 | 14 | static{ 15 | String base = ResourceUtils.getProperty("auth.crypt.key",SecurityCryptUtils.class.getName()); 16 | cryptKey = base.substring(0, 2) + DigestUtils.md5Short(base); 17 | } 18 | 19 | public static String getCryptKey() { 20 | return cryptKey; 21 | } 22 | 23 | public static String encrypt(String data) { 24 | String encode = DES.encrypt(cryptKey, data); 25 | byte[] bytes = Base64.encodeToByte(encode.getBytes(StandardCharsets.UTF_8), false); 26 | return new String(bytes, StandardCharsets.UTF_8); 27 | } 28 | 29 | public static String decrypt(String data) { 30 | byte[] bytes = Base64.decode(data); 31 | data = new String(bytes, StandardCharsets.UTF_8); 32 | return DES.decrypt(cryptKey, data); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /jeesuite-mybatis/src/main/java/com/jeesuite/mybatis/plugin/pagination/Page.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.mybatis.plugin.pagination; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class Page extends PageParams{ 7 | 8 | //总记录数 9 | private long total; 10 | //总页数 11 | private int pages; 12 | //结果集 13 | private List data; 14 | 15 | public Page() {} 16 | 17 | public Page(PageParams pageParams,long total, List data) { 18 | setPageNo(pageParams.getPageNo()); 19 | setPageSize(pageParams.getPageSize()); 20 | this.total = total; 21 | this.data = data; 22 | this.pages = (int) ((this.total / this.getPageSize()) + (this.total % this.getPageSize() == 0 ? 0 : 1)); 23 | } 24 | 25 | 26 | 27 | public long getTotal() { 28 | return total; 29 | } 30 | public void setTotal(long total) { 31 | this.total = total; 32 | } 33 | public int getPages() { 34 | return pages; 35 | } 36 | public void setPages(int pages) { 37 | this.pages = pages; 38 | } 39 | public List getData() { 40 | return data == null ? (data = new ArrayList<>()) : data; 41 | } 42 | public void setData(List data) { 43 | this.data = data; 44 | } 45 | 46 | 47 | } 48 | -------------------------------------------------------------------------------- /jeesuite-mybatis/src/main/java/com/jeesuite/mybatis/core/BaseMapper.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.mybatis.core; 5 | 6 | import java.io.Serializable; 7 | import java.util.List; 8 | 9 | /** 10 | * @description
11 | * @author vakin 12 | * @date 2015年12月2日 13 | * @Copyright (c) 2015, jwww 14 | */ 15 | public abstract interface BaseMapper { 16 | 17 | /** 18 | * 保存(持久化)对象 19 | * @param entity 要持久化的对象 20 | */ 21 | public void insert(T entity); 22 | 23 | public void insertSelective(T entity); 24 | 25 | /** 26 | * @param entity 27 | */ 28 | public void updateByPrimaryKey(T entity); 29 | 30 | /** 31 | * @param entity 32 | */ 33 | public void updateByPrimaryKeySelective(T entity); 34 | 35 | 36 | /** 37 | * 获取指定的唯一标识符对应的持久化对象 38 | * 39 | * @param id 指定的唯一标识符 40 | * @return 指定的唯一标识符对应的持久化对象,如果没有对应的持久化对象,则返回null。 41 | */ 42 | public T selectByPrimaryKey(ID id); 43 | 44 | public List selectAll(); 45 | 46 | void deleteByPrimaryKey(ID id); 47 | 48 | /** 49 | * 批量插入 50 | * @param entities 51 | */ 52 | public void insertList(List entities); 53 | } 54 | 55 | -------------------------------------------------------------------------------- /jeesuite-common/src/main/java/com/jeesuite/common/json/deserializer/DateConvertDeserializer.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.common.json.deserializer; 2 | 3 | import java.io.IOException; 4 | import java.text.DateFormat; 5 | import java.text.ParseException; 6 | import java.text.SimpleDateFormat; 7 | import java.util.Date; 8 | 9 | import com.fasterxml.jackson.core.JsonParser; 10 | import com.fasterxml.jackson.core.JsonProcessingException; 11 | import com.fasterxml.jackson.databind.DeserializationContext; 12 | import com.fasterxml.jackson.databind.JsonDeserializer; 13 | 14 | 15 | public class DateConvertDeserializer extends JsonDeserializer { 16 | 17 | // private static LoggerAdapter log = LoggerAdapterFacory.getLogger(JsonToDateDeserializer.class); 18 | 19 | private static final String pattern = "yyyy-MM-dd"; 20 | 21 | @Override 22 | public Date deserialize(JsonParser jsonParser, DeserializationContext dc) throws JsonProcessingException { 23 | Date date = null; 24 | try { 25 | DateFormat dateFormat = new SimpleDateFormat(pattern); 26 | String val = jsonParser.getText(); 27 | date = dateFormat.parse(val); 28 | } catch (ParseException | IOException pex) { 29 | throw new RuntimeException("json转换Date异常,格式:" + pattern); 30 | } 31 | return date; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /jeesuite-kafka/src/test/java/com/jeesuite/test/ConsumerServer.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.test; 2 | 3 | import java.util.Scanner; 4 | 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | import org.springframework.context.support.ClassPathXmlApplicationContext; 8 | 9 | import com.jeesuite.kafka.consumer.ConsumerContext; 10 | 11 | 12 | public class ConsumerServer { 13 | 14 | private static Logger logger = LoggerFactory.getLogger(ConsumerServer.class); 15 | public static void main(String[] args) throws InterruptedException{ 16 | 17 | final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("test-kafka-consumer.xml"); 18 | 19 | logger.info("Kafka Consumer started...."); 20 | Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { 21 | 22 | @Override 23 | public void run() { 24 | logger.info("Kafka Consumer Stoped...."); 25 | context.close(); 26 | } 27 | })); 28 | 29 | 30 | Scanner scan=new Scanner(System.in); 31 | String cmd=scan.next(); 32 | if("q".equalsIgnoreCase(cmd)){ 33 | context.close(); 34 | scan.close(); 35 | }else if("stopfetch".equalsIgnoreCase(cmd)){ 36 | ConsumerContext.getInstance().switchFetch(true); 37 | } 38 | 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /jeesuite-kafka/src/main/java/com/jeesuite/kafka/serializer/JdkMessageSerializer.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.kafka.serializer; 2 | 3 | import java.io.Serializable; 4 | import java.util.Map; 5 | 6 | import org.apache.commons.lang3.SerializationUtils; 7 | import org.apache.kafka.common.serialization.Serializer; 8 | 9 | 10 | /** 11 | * 12 | * @description
13 | * @author vakin 14 | * @date 2016年6月14日 15 | */ 16 | public class JdkMessageSerializer implements Serializer { 17 | 18 | /** 19 | * Configure this class. 20 | * 21 | * @param configs configs in key/value pairs 22 | * @param isKey whether is for key or value 23 | */ 24 | @Override 25 | public void configure(Map configs, boolean isKey) { 26 | 27 | } 28 | 29 | /** 30 | * serialize 31 | * 32 | * @param topic topic associated with data 33 | * @param data typed data 34 | * @return serialized bytes 35 | */ 36 | @Override 37 | public byte[] serialize(String topic, Serializable data) { 38 | return SerializationUtils.serialize(data); 39 | } 40 | 41 | /** 42 | * Close this serializer 43 | */ 44 | @Override 45 | public void close() { 46 | 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /jeesuite-kafka/src/main/java/com/jeesuite/kafka/serializer/KyroMessageSerializer.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.kafka.serializer; 2 | 3 | import java.io.Serializable; 4 | import java.util.Map; 5 | 6 | import org.apache.kafka.common.serialization.Serializer; 7 | 8 | import com.jeesuite.common.serializer.SerializeUtils; 9 | 10 | 11 | /** 12 | * 13 | * @description
14 | * @author vakin 15 | * @date 2016年6月14日 16 | */ 17 | public class KyroMessageSerializer implements Serializer { 18 | 19 | /** 20 | * Configure this class. 21 | * 22 | * @param configs configs in key/value pairs 23 | * @param isKey whether is for key or value 24 | */ 25 | @Override 26 | public void configure(Map configs, boolean isKey) { 27 | 28 | } 29 | 30 | /** 31 | * serialize 32 | * 33 | * @param topic topic associated with data 34 | * @param data typed data 35 | * @return serialized bytes 36 | */ 37 | @Override 38 | public byte[] serialize(String topic, Serializable data) { 39 | return SerializeUtils.serialize(data); 40 | } 41 | 42 | /** 43 | * Close this serializer 44 | */ 45 | @Override 46 | public void close() { 47 | 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /jeesuite-scheduler/src/test/java/com/jeesuite/test/sch/TaskServerNode1.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.test.sch; 2 | 3 | import java.util.Scanner; 4 | 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | import org.springframework.context.support.ClassPathXmlApplicationContext; 8 | 9 | import com.jeesuite.spring.InstanceFactory; 10 | import com.jeesuite.spring.SpringInstanceProvider; 11 | 12 | 13 | public class TaskServerNode1 { 14 | 15 | private static Logger logger = LoggerFactory.getLogger(TaskServerNode1.class); 16 | public static void main(String[] args) throws InterruptedException{ 17 | 18 | final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("test-schduler.xml"); 19 | 20 | InstanceFactory.setInstanceProvider(new SpringInstanceProvider(context)); 21 | 22 | logger.info("TASK started...."); 23 | Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { 24 | 25 | @Override 26 | public void run() { 27 | logger.info("TASK Stoped...."); 28 | context.close(); 29 | } 30 | })); 31 | 32 | Scanner scan=new Scanner(System.in); 33 | String cmd=scan.next(); 34 | if("q".equals(cmd)){ 35 | scan.close(); 36 | context.close(); 37 | } 38 | 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /jeesuite-scheduler/src/test/java/com/jeesuite/test/sch/TaskServerNode2.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.test.sch; 2 | 3 | import java.util.Scanner; 4 | 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | import org.springframework.context.support.ClassPathXmlApplicationContext; 8 | 9 | import com.jeesuite.spring.InstanceFactory; 10 | import com.jeesuite.spring.SpringInstanceProvider; 11 | 12 | 13 | public class TaskServerNode2 { 14 | 15 | private static Logger logger = LoggerFactory.getLogger(TaskServerNode2.class); 16 | public static void main(String[] args) throws InterruptedException{ 17 | 18 | final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("test-schduler.xml"); 19 | 20 | InstanceFactory.setInstanceProvider(new SpringInstanceProvider(context)); 21 | 22 | logger.info("TASK started...."); 23 | Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { 24 | 25 | @Override 26 | public void run() { 27 | logger.info("TASK Stoped...."); 28 | context.close(); 29 | } 30 | })); 31 | 32 | Scanner scan=new Scanner(System.in); 33 | String cmd=scan.next(); 34 | if("q".equals(cmd)){ 35 | scan.close(); 36 | context.close(); 37 | } 38 | 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /jeesuite-common/src/test/java/test/BaseUser.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package test; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * @description
10 | * @author vakin 11 | * @date 2016年11月4日 12 | */ 13 | public class BaseUser implements Serializable { 14 | 15 | private static final long serialVersionUID = 1L; 16 | 17 | private Integer id; 18 | 19 | private String name; 20 | 21 | private String mobile = "13800138000"; 22 | 23 | private String email; 24 | 25 | private BaseUser father; 26 | 27 | public Integer getId() { 28 | return id; 29 | } 30 | 31 | public void setId(Integer id) { 32 | this.id = id; 33 | } 34 | 35 | public String getName() { 36 | return name; 37 | } 38 | 39 | public void setName(String name) { 40 | this.name = name; 41 | } 42 | 43 | public String getMobile() { 44 | return mobile; 45 | } 46 | 47 | public void setMobile(String mobile) { 48 | this.mobile = mobile; 49 | } 50 | 51 | public String getEmail() { 52 | return email; 53 | } 54 | 55 | public void setEmail(String email) { 56 | this.email = email; 57 | } 58 | 59 | public BaseUser getFather() { 60 | return father; 61 | } 62 | 63 | public void setFather(BaseUser father) { 64 | this.father = father; 65 | } 66 | 67 | 68 | } 69 | -------------------------------------------------------------------------------- /jeesuite-springweb/src/main/java/com/jeesuite/springweb/WebConstants.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.springweb; 2 | 3 | public class WebConstants { 4 | // header 5 | public static final String HEADER_PREFIX = "x-"; 6 | public static final String HEADER_REAL_IP = "x-real-ip"; 7 | public static final String HEADER_FROWARDED_FOR = "x-forwarded-for"; 8 | public static final String HEADER_AUTH_TOKEN = "x-auth-token"; 9 | public static final String HEADER_AUTH_USER = "x-auth-user"; 10 | public static final String HEADER_FORWARDED_BASE_URL = "x-forwarded-base-url"; 11 | public static final String HEADER_FORWARDED_PROTO = "x-forwarded-proto"; 12 | public static final String HEADER_FORWARDED_ORIGN_PROTO = "x-forwarded-orign-proto"; 13 | public static final String HEADER_FORWARDED_HOST = "x-forwarded-host"; 14 | public static final String HEADER_FORWARDED_PORT = "x-forwarded-port"; 15 | public static final String HEADER_FORWARDED_PRIFIX = "x-forwarded-prefix"; 16 | public static final String HEADER_SESSION_ID = "x-session-id"; 17 | public static final String HEADER_SESSION_EXPIRE_IN = "x-session-expire-in"; 18 | public static final String HEADER_INVOKER_IP = "x-invoker-ip"; 19 | public static final String HEADER_REQUESTED_WITH = "x-requested-with"; 20 | public static final String HEADER_INTERNAL_REQUEST = "x-internal-request"; 21 | } 22 | -------------------------------------------------------------------------------- /jeesuite-common2/src/test/java/test/excel/SimpleSalaryInfo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package test.excel; 5 | 6 | import com.jeesuite.common2.excel.annotation.TitleCell; 7 | 8 | /** 9 | * 个人工资数据 10 | * 11 | * @description
12 | * @author vakin 13 | * @date 2016年11月21日 14 | */ 15 | public class SimpleSalaryInfo { 16 | 17 | // 姓名 身份证号 手机 税后工资 18 | @TitleCell(name = "姓名", column = 1) 19 | private String name; 20 | @TitleCell(name = "身份证号", column = 2) 21 | private String idCard; 22 | @TitleCell(name = "手机", column = 3) 23 | private String mobileNo;// 社保基数 24 | @TitleCell(name = "税后工资", column = 4, notNull = true, type = Float.class) 25 | private float salary; 26 | 27 | public String getName() { 28 | return name; 29 | } 30 | 31 | public void setName(String name) { 32 | this.name = name; 33 | } 34 | 35 | public String getIdCard() { 36 | return idCard; 37 | } 38 | 39 | public void setIdCard(String idCard) { 40 | this.idCard = idCard; 41 | } 42 | 43 | public String getMobileNo() { 44 | return mobileNo; 45 | } 46 | 47 | public void setMobileNo(String mobileNo) { 48 | this.mobileNo = mobileNo; 49 | } 50 | 51 | public float getSalary() { 52 | return salary; 53 | } 54 | 55 | public void setSalary(float salary) { 56 | this.salary = salary; 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /jeesuite-springweb/src/main/java/com/jeesuite/springweb/base/CustomServletInputStreamWrapper.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.springweb.base; 2 | 3 | import java.io.IOException; 4 | 5 | import javax.servlet.ReadListener; 6 | import javax.servlet.ServletInputStream; 7 | 8 | /** 9 | * 10 | * @description
11 | * @author vakin 12 | * @date 2018年3月7日 13 | */ 14 | public class CustomServletInputStreamWrapper extends ServletInputStream { 15 | 16 | private byte[] data; 17 | private int idx = 0; 18 | 19 | /** 20 | * Creates a new CumtomServletInputStreamWrapper instance. 21 | * 22 | * @param data a byte[] value 23 | */ 24 | public CustomServletInputStreamWrapper(byte[] data) { 25 | if (data == null) 26 | data = new byte[0]; 27 | this.data = data; 28 | } 29 | 30 | @Override 31 | public int read() throws IOException { 32 | if (idx == data.length) 33 | return -1; 34 | return data[idx++] & 0xff; 35 | } 36 | 37 | @Override 38 | public boolean isFinished() { 39 | return idx == data.length; 40 | } 41 | 42 | @Override 43 | public boolean isReady() { 44 | return true; 45 | } 46 | 47 | @Override 48 | public void setReadListener(ReadListener listener) { 49 | 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /jeesuite-springweb/src/main/java/com/jeesuite/springweb/RequestContextHelper.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.springweb; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | import javax.servlet.http.HttpServletResponse; 5 | 6 | import org.springframework.web.context.request.RequestContextHolder; 7 | import org.springframework.web.context.request.ServletRequestAttributes; 8 | 9 | public class RequestContextHelper { 10 | 11 | private static final ThreadLocal holder = new ThreadLocal<>(); 12 | 13 | 14 | public static void set(HttpServletRequest request, HttpServletResponse response){ 15 | holder.set(new RequestResponsePair(request, response)); 16 | } 17 | 18 | public static HttpServletRequest getRequest() { 19 | return holder.get() == null ? ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest() : holder.get().request; 20 | } 21 | 22 | public static HttpServletResponse getResponse() { 23 | return holder.get() == null ? null : holder.get().response; 24 | } 25 | 26 | private static class RequestResponsePair{ 27 | HttpServletRequest request; 28 | HttpServletResponse response; 29 | 30 | 31 | public RequestResponsePair(HttpServletRequest request, HttpServletResponse response) { 32 | super(); 33 | this.request = request; 34 | this.response = response; 35 | } 36 | 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /jeesuite-springweb/src/main/java/com/jeesuite/springweb/client/SimpleRestTemplateBuilder.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.springweb.client; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.springframework.http.client.ClientHttpRequestInterceptor; 7 | import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; 8 | import org.springframework.web.client.RestTemplate; 9 | 10 | import com.jeesuite.springweb.interceptor.LoggingRequestInterceptor; 11 | 12 | public class SimpleRestTemplateBuilder { 13 | 14 | 15 | public RestTemplate build(){ 16 | return build(30000); 17 | } 18 | 19 | public RestTemplate build(int readTimeout){ 20 | 21 | HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory(); 22 | factory.setReadTimeout(readTimeout);//ms 23 | factory.setConnectTimeout(3000);//ms 24 | 25 | RestTemplate restTemplate = new RestTemplate(factory); 26 | List interceptors = new ArrayList<>(); 27 | interceptors.add(new RestTemplateAutoHeaderInterceptor()); 28 | interceptors.add(new LoggingRequestInterceptor()); 29 | restTemplate.setInterceptors(interceptors); 30 | // 31 | restTemplate.setErrorHandler(new CustomResponseErrorHandler()); 32 | return restTemplate; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /jeesuite-cache/src/main/java/com/jeesuite/cache/command/RedisBinaryCollection.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.cache.command; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | /** 10 | * 集合操作基类 11 | * @description
12 | * @author vakin 13 | * @date 2015年12月7日 14 | */ 15 | public abstract class RedisBinaryCollection extends RedisBase { 16 | 17 | protected long expireTime;//过期时间(秒) 18 | 19 | public RedisBinaryCollection(String key) { 20 | this(key,RedisBase.getDefaultExpireSeconds()); 21 | } 22 | 23 | /** 24 | * 指定组名 25 | * @param key 26 | * @param groupName 27 | */ 28 | public RedisBinaryCollection(String key,String groupName) { 29 | this(key,groupName,RedisBase.getDefaultExpireSeconds()); 30 | } 31 | 32 | public RedisBinaryCollection(String key,long expireTime) { 33 | super(key); 34 | this.expireTime = expireTime; 35 | } 36 | 37 | public RedisBinaryCollection(String key,String groupName,long expireTime) { 38 | super(key,groupName,true); 39 | this.expireTime = expireTime; 40 | } 41 | 42 | protected List toObjectList(List datas) { 43 | List result = new ArrayList<>(); 44 | if(datas == null)return result; 45 | for (byte[] data : datas) { 46 | result.add((T)valueDerialize(data)); 47 | } 48 | return result; 49 | } 50 | 51 | 52 | } 53 | -------------------------------------------------------------------------------- /jeesuite-common/src/main/java/com/jeesuite/common/util/AssertUtil.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.common.util; 2 | 3 | import com.jeesuite.common.JeesuiteBaseException; 4 | 5 | public class AssertUtil { 6 | 7 | public static void isTrue(boolean expression, int code,String message) { 8 | if (!expression) { 9 | throw new JeesuiteBaseException(code, message); 10 | } 11 | } 12 | 13 | 14 | public static void isNull(Object object, String message) { 15 | if (object != null) { 16 | throw new JeesuiteBaseException(ResourceUtils.getInt("errorcode:record.existed", 500), message); 17 | } 18 | } 19 | 20 | public static void isNull(Object object) { 21 | isNull(object, "记录已存在"); 22 | } 23 | 24 | public static void notNull(Object object, String message) { 25 | if (object == null) { 26 | throw new JeesuiteBaseException(ResourceUtils.getInt("errorcode:record.not-exist", 500), message); 27 | } 28 | } 29 | 30 | public static void notNull(Object object) { 31 | notNull(object, "记录不存在"); 32 | } 33 | 34 | 35 | public static void notBlank(String expression, String message) { 36 | if (expression == null ||"".equals(expression.trim())) { 37 | throw new JeesuiteBaseException(ResourceUtils.getInt("errorcode:param.required", 400), message); 38 | } 39 | } 40 | 41 | public static void notBlank(String expression){ 42 | notBlank(expression, "参数不能为空"); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /jeesuite-common2/src/test/java/test/lock/ZkDistributeLockTest.java: -------------------------------------------------------------------------------- 1 | package test.lock; 2 | 3 | import java.util.concurrent.CountDownLatch; 4 | import java.util.concurrent.ExecutorService; 5 | import java.util.concurrent.Executors; 6 | 7 | import com.jeesuite.common2.lock.zk.ZkDistributeLock; 8 | 9 | public class ZkDistributeLockTest { 10 | 11 | private static CountDownLatch latch; 12 | 13 | public static void main(String[] args) throws Exception { 14 | 15 | int taskcount = 5; 16 | latch = new CountDownLatch(taskcount); 17 | ExecutorService threadPool = Executors.newFixedThreadPool(taskcount); 18 | 19 | for (int i = 0; i < taskcount; i++) { 20 | threadPool.submit(new LockWorker("worker-" + i)); 21 | } 22 | 23 | latch.await(); 24 | threadPool.shutdown(); 25 | } 26 | 27 | static class LockWorker implements Runnable { 28 | 29 | private String id; 30 | 31 | public LockWorker(String id) { 32 | super(); 33 | this.id = id; 34 | } 35 | 36 | @Override 37 | public void run() { 38 | ZkDistributeLock lock = new ZkDistributeLock("test"); 39 | lock.lock(); 40 | System.out.println("LockWorker[" + id + "] get lock,doing"); 41 | try { 42 | Thread.sleep(2000); 43 | } catch (Exception e) { 44 | } 45 | lock.unlock(); 46 | latch.countDown(); 47 | System.out.println("LockWorker[" + id + "] release lock,done"); 48 | } 49 | 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /jeesuite-mybatis/src/test/resources/mysql.properties: -------------------------------------------------------------------------------- 1 | jeesuite.mybatis.crudDriver=default 2 | jeesuite.mybatis.dbType=Mysql 3 | jeesuite.mybatis.cacheEnabled=true 4 | jeesuite.mybatis.nullValueCache=false 5 | jeesuite.mybatis.cacheExpireSeconds=300 6 | jeesuite.mybatis.dynamicExpire=false 7 | jeesuite.mybatis.rwRouteEnabled=false 8 | jeesuite.mybatis.paginationEnabled=true 9 | 10 | #mysql global config 11 | db.driverClass=com.mysql.jdbc.Driver 12 | db.initialSize=2 13 | db.minIdle=1 14 | db.maxActive=10 15 | #\u83b7\u53d6\u8fde\u63a5\u7b49\u5f85\u65f6\u95f4\uff08\u6beb\u79d2\uff09 16 | db.maxWait=60000 17 | #\u68c0\u6d4b\u9700\u8981\u5173\u95ed\u7684\u7a7a\u95f2\u8fde\u63a5\u65f6\u95f4\u95f4\u9694(\u6beb\u79d2) 18 | db.timeBetweenEvictionRunsMillis=60000 19 | #\u4e00\u4e2a\u8fde\u63a5\u5728\u6c60\u4e2d\u6700\u5c0f\u751f\u5b58\u7684\u65f6\u95f4(\u6beb\u79d2) 20 | db.minEvictableIdleTimeMillis=300000 21 | db.testOnBorrow=false 22 | db.testOnReturn=false 23 | 24 | #master 25 | master.db.url=jdbc:mysql://localhost:3306/demo_db?seUnicode=true&characterEncoding=UTF-8 26 | master.db.username=root 27 | master.db.password=123456 28 | master.db.initialSize=2 29 | master.db.minIdle=2 30 | master.db.maxActive=20 31 | 32 | #slave .... 33 | slave1.db.url=jdbc:mysql://localhost:3306/demo_db?seUnicode=true&characterEncoding=UTF-8 34 | slave1.db.username=root 35 | slave1.db.password=123456 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /jeesuite-security/src/main/java/com/jeesuite/security/cache/LocalCache.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.security.cache; 2 | 3 | import java.util.Objects; 4 | import java.util.concurrent.TimeUnit; 5 | 6 | import com.google.common.cache.CacheBuilder; 7 | import com.jeesuite.security.Cache; 8 | 9 | public class LocalCache implements Cache{ 10 | 11 | private com.google.common.cache.Cache cache; 12 | 13 | public LocalCache(int timeToLiveSeconds) { 14 | cache = CacheBuilder 15 | .newBuilder() 16 | .maximumSize(10000) 17 | .expireAfterWrite(timeToLiveSeconds, TimeUnit.SECONDS) 18 | .build(); 19 | } 20 | 21 | @Override 22 | public void setString(String key, String value) { 23 | cache.put(key, value); 24 | } 25 | 26 | @Override 27 | public String getString(String key) { 28 | return Objects.toString(getObject(key), null); 29 | } 30 | 31 | @Override 32 | public void setObject(String key, Object value) { 33 | cache.put(key, value); 34 | } 35 | 36 | @Override 37 | public T getObject(String key) { 38 | return (T) cache.getIfPresent(key); 39 | } 40 | 41 | @Override 42 | public void remove(String key) { 43 | cache.invalidate(key); 44 | } 45 | 46 | @Override 47 | public boolean exists(String key) { 48 | return cache.getIfPresent(key) != null; 49 | } 50 | 51 | @Override 52 | public void removeAll() { 53 | cache.invalidateAll(); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /jeesuite-common/src/main/java/com/jeesuite/common/http/HttpResponseEntity.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.common.http; 2 | 3 | import java.net.HttpURLConnection; 4 | 5 | public class HttpResponseEntity { 6 | 7 | private int statusCode; 8 | private String body; 9 | private Exception exception; 10 | 11 | 12 | 13 | public HttpResponseEntity() {} 14 | 15 | public HttpResponseEntity(int statusCode, String body) { 16 | super(); 17 | this.statusCode = statusCode; 18 | this.body = body; 19 | } 20 | 21 | public HttpResponseEntity(int statusCode, Exception exception) { 22 | this.statusCode = statusCode; 23 | this.exception = exception; 24 | } 25 | 26 | public int getStatusCode() { 27 | return statusCode; 28 | } 29 | public void setStatusCode(int statusCode) { 30 | this.statusCode = statusCode; 31 | } 32 | public String getBody() { 33 | return body; 34 | } 35 | public void setBody(String body) { 36 | this.body = body; 37 | } 38 | 39 | public boolean isSuccessed(){ 40 | return statusCode == HttpURLConnection.HTTP_OK; 41 | } 42 | 43 | public Exception getException() { 44 | return exception; 45 | } 46 | 47 | public void setException(Exception exception) { 48 | this.exception = exception; 49 | } 50 | 51 | @Override 52 | public String toString() { 53 | return "HttpResponseEntity [statusCode=" + statusCode + ", body=" + body + "]"; 54 | } 55 | 56 | 57 | 58 | } 59 | -------------------------------------------------------------------------------- /jeesuite-common2/src/main/java/com/jeesuite/common2/excel/helper/ExcelValidator.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.common2.excel.helper; 2 | 3 | import java.io.IOException; 4 | import java.util.regex.Pattern; 5 | 6 | import org.apache.commons.lang3.StringUtils; 7 | import org.apache.poi.openxml4j.exceptions.OLE2NotOfficeXmlFileException; 8 | import org.apache.poi.openxml4j.opc.OPCPackage; 9 | import org.apache.poi.openxml4j.opc.PackageAccess; 10 | 11 | public class ExcelValidator { 12 | 13 | public static final String XLS_SIFFIX = "xls"; 14 | public static final String XLSX_SIFFIX = "xlsx"; 15 | 16 | public static final String FIELD_SPLIT = "-@-"; 17 | 18 | public final static String BLANK = ""; 19 | 20 | public final static String SHEET_NAME_PREFIX = "{sheet}:"; 21 | 22 | private static Pattern blankPattern = Pattern.compile("^["+FIELD_SPLIT+"|\"]+$"); 23 | 24 | public static boolean isBlankCSVRow(String line){ 25 | if(StringUtils.isBlank(line))return true; 26 | return blankPattern.matcher(line).matches(); 27 | } 28 | 29 | 30 | public static boolean isHSSF(String path){ 31 | OPCPackage p = null; 32 | try { 33 | p = OPCPackage.open(path, PackageAccess.READ); 34 | return true; 35 | } catch (OLE2NotOfficeXmlFileException e) { 36 | return false; 37 | } catch (Exception e) { 38 | return false; 39 | }finally{ 40 | try {p.close();} catch (IOException e) {} 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /jeesuite-common/src/main/java/com/jeesuite/common/util/HashUtils.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.common.util; 5 | 6 | import java.nio.ByteBuffer; 7 | import java.nio.ByteOrder; 8 | 9 | /** 10 | * @description
11 | * @author vakin 12 | * @date 2016年12月29日 13 | */ 14 | public class HashUtils { 15 | 16 | /** 17 | * MurMurHash算法,是非加密HASH算法,性能很高, 18 | * 比传统的CRC32,MD5,SHA-1(这两个算法都是加密HASH算法,复杂度本身就很高,带来的性能上的损害也不可避免) 19 | * 等HASH算法要快很多,而且据说这个算法的碰撞率很低. http://murmurhash.googlepages.com/ 20 | */ 21 | public static Long hash(String key) { 22 | if(key == null)return 0L; 23 | ByteBuffer buf = ByteBuffer.wrap(key.getBytes()); 24 | int seed = 0x1234ABCD; 25 | 26 | ByteOrder byteOrder = buf.order(); 27 | buf.order(ByteOrder.LITTLE_ENDIAN); 28 | 29 | long m = 0xc6a4a7935bd1e995L; 30 | int r = 47; 31 | 32 | long h = seed ^ (buf.remaining() * m); 33 | 34 | long k; 35 | while (buf.remaining() >= 8) { 36 | k = buf.getLong(); 37 | 38 | k *= m; 39 | k ^= k >>> r; 40 | k *= m; 41 | 42 | h ^= k; 43 | h *= m; 44 | } 45 | 46 | if (buf.remaining() > 0) { 47 | ByteBuffer finish = ByteBuffer.allocate(8).order(ByteOrder.LITTLE_ENDIAN); 48 | finish.put(buf).rewind(); 49 | h ^= finish.getLong(); 50 | h *= m; 51 | } 52 | 53 | h ^= h >>> r; 54 | h *= m; 55 | h ^= h >>> r; 56 | 57 | buf.order(byteOrder); 58 | return Math.abs(h); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /jeesuite-mybatis/src/main/java/com/jeesuite/mybatis/plugin/cache/provider/AbstractCacheProvider.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.mybatis.plugin.cache.provider; 5 | 6 | import java.math.BigDecimal; 7 | 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | 11 | import com.jeesuite.mybatis.plugin.cache.CacheProvider; 12 | 13 | /** 14 | * @description
15 | * @author vakin 16 | * @date 2017年1月13日 17 | */ 18 | public abstract class AbstractCacheProvider implements CacheProvider { 19 | 20 | protected static final Logger logger = LoggerFactory.getLogger(AbstractCacheProvider.class); 21 | 22 | protected static final char[] ID_PREFIX_CHARS = ("123456789".toCharArray()); 23 | 24 | protected boolean isStoreAsString(Object o) { 25 | Class clazz = o.getClass(); 26 | return 27 | ( 28 | clazz.equals(String.class) || 29 | clazz.equals(Integer.class)|| 30 | clazz.equals(Byte.class) || 31 | clazz.equals(Long.class) || 32 | clazz.equals(Double.class) || 33 | clazz.equals(Float.class) || 34 | clazz.equals(Character.class) || 35 | clazz.equals(Short.class) || 36 | clazz.equals(BigDecimal.class) || 37 | clazz.equals(Boolean.class) || 38 | clazz.isPrimitive() 39 | ); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /jeesuite-filesystem/src/main/java/com/jeesuite/filesystem/utils/FilePathHelper.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.filesystem.utils; 5 | 6 | /** 7 | * 8 | * @description
9 | * @author vakin 10 | * @date 2017年1月5日 11 | */ 12 | public class FilePathHelper { 13 | 14 | public static final String HTTP_PREFIX = "http://"; 15 | public static final String HTTPS_PREFIX = "https://"; 16 | public static final String DIR_SPLITER = "/"; 17 | 18 | public static String parseFileExtension(String filePath){ 19 | if(filePath.contains("/")){ 20 | filePath = filePath.substring(filePath.lastIndexOf("/")); 21 | } 22 | filePath = filePath.split("\\?")[0]; 23 | if(filePath.contains(".")){ 24 | return filePath.substring(filePath.lastIndexOf(".") + 1); 25 | } 26 | return null; 27 | } 28 | 29 | public static String parseFileName(String filePath){ 30 | filePath = filePath.split("\\?")[0]; 31 | int index = filePath.lastIndexOf("/") + 1; 32 | if(index > 0){ 33 | return filePath.substring(index); 34 | } 35 | return filePath; 36 | } 37 | 38 | public static void main(String[] args) { 39 | System.out.println(parseFileExtension("http:www.ssss.com/cccc/123.png?xxx")); 40 | System.out.println(parseFileExtension("123.png")); 41 | System.out.println(parseFileExtension("http:www.ssss.com/cccc/dtgh4r4tt/")); 42 | 43 | System.out.println(parseFileName("http:www.ssss.com/cccc/123.png?cfg")); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /jeesuite-kafka/src/test/java/com/jeesuite/test/SimpleComsumer.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.test; 2 | 3 | import java.util.Arrays; 4 | import java.util.Properties; 5 | 6 | import org.apache.kafka.clients.consumer.ConsumerRecord; 7 | import org.apache.kafka.clients.consumer.ConsumerRecords; 8 | import org.apache.kafka.clients.consumer.KafkaConsumer; 9 | 10 | public class SimpleComsumer { 11 | 12 | public static void main(String[] args) { 13 | Properties props = new Properties(); 14 | props.put("bootstrap.servers", "localhost:9092"); 15 | props.put("group.id", "simpleComsumer2"); 16 | props.put("enable.auto.commit", "true"); 17 | props.put("auto.commit.interval.ms", "1000"); 18 | props.put("session.timeout.ms", "30000"); 19 | props.put("auto.offset.reset", "earliest"); 20 | props.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer"); 21 | props.put("value.deserializer", "org.apache.kafka.common.serialization.LongDeserializer"); 22 | KafkaConsumer consumer = new KafkaConsumer<>(props); 23 | /* 消费者订阅的topic, 可同时订阅多个 */ 24 | consumer.subscribe(Arrays.asList("streams-wordcount-output")); 25 | 26 | /* 读取数据,读取超时时间为100ms */ 27 | while (true) { 28 | ConsumerRecords records = consumer.poll(1000); 29 | for (ConsumerRecord record : records) 30 | System.out.printf("offset = %d, key = %s, value = %s \n", record.offset(), record.key(), record.value()); 31 | } 32 | 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /jeesuite-mybatis/src/main/java/com/jeesuite/mybatis/plugin/rwseparate/UseMaster.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.jeesuite.mybatis.plugin.rwseparate; 18 | 19 | import static java.lang.annotation.ElementType.METHOD; 20 | 21 | import java.lang.annotation.Documented; 22 | import java.lang.annotation.Retention; 23 | import java.lang.annotation.RetentionPolicy; 24 | import java.lang.annotation.Target; 25 | 26 | @Documented 27 | @Retention(RetentionPolicy.RUNTIME) 28 | @Target(METHOD) 29 | /** 30 | * @description
31 | * @author vakin 32 | * @date 2018年4月27日 33 | */ 34 | public @interface UseMaster { 35 | 36 | } 37 | -------------------------------------------------------------------------------- /jeesuite-mybatis/src/main/java/com/jeesuite/mybatis/plugin/pagination/PageExecutor.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.mybatis.plugin.pagination; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class PageExecutor { 7 | 8 | private static ThreadLocal pageParamsHolder = new ThreadLocal<>(); 9 | 10 | public static interface PageDataLoader { 11 | List load(); 12 | } 13 | 14 | public static interface ConvertPageDataLoader extends PageDataLoader{ 15 | V convert(E e); 16 | } 17 | 18 | @SuppressWarnings("unchecked") 19 | public static Page pagination(PageParams pageParams,PageDataLoader dataLoader ){ 20 | pageParamsHolder.set(pageParams); 21 | List list = dataLoader.load(); 22 | return (Page) list.get(0); 23 | } 24 | 25 | @SuppressWarnings("unchecked") 26 | public static Page pagination(PageParams pageParams,ConvertPageDataLoader dataLoader ){ 27 | pageParamsHolder.set(pageParams); 28 | List list = dataLoader.load(); 29 | Page page = (Page) list.get(0); 30 | List convertDatas = new ArrayList<>(page.getData().size()); 31 | for (E e : page.getData()) { 32 | convertDatas.add(dataLoader.convert(e)); 33 | } 34 | return new Page<>(pageParams, page.getTotal(), convertDatas); 35 | } 36 | 37 | public static PageParams getPageParams(){ 38 | return pageParamsHolder.get(); 39 | } 40 | 41 | public static void clearPageParams(){ 42 | pageParamsHolder.remove(); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /jeesuite-mybatis/src/main/java/com/jeesuite/mybatis/plugin/cache/annotation/Cache.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.mybatis.plugin.cache.annotation; 5 | 6 | import java.lang.annotation.Documented; 7 | import java.lang.annotation.ElementType; 8 | import java.lang.annotation.Inherited; 9 | import java.lang.annotation.Retention; 10 | import java.lang.annotation.RetentionPolicy; 11 | import java.lang.annotation.Target; 12 | 13 | /** 14 | * @description
15 | * @author vakin 16 | * @date 2015年12月10日 17 | * @Copyright (c) 2015, jwww 18 | */ 19 | @Target({ ElementType.METHOD, ElementType.TYPE }) 20 | @Retention(RetentionPolicy.RUNTIME) 21 | @Inherited 22 | @Documented 23 | public @interface Cache { 24 | /** 25 | * 过期时间(单位:秒) 26 | * @return 27 | */ 28 | long expire() default 0; 29 | 30 | /** 31 | * 是否业务上唯一索引 32 | * @return 33 | */ 34 | boolean uniqueIndex() default false; 35 | 36 | /** 37 | * 是否允许并发查询db 38 | * @return 39 | */ 40 | boolean concurrency() default true; 41 | /** 42 | * 缓存范围是否当前登录用户 43 | * @return 44 | */ 45 | boolean userScope() default false; 46 | 47 | /** 48 | * 缓存范围: 49 | * @return 50 | */ 51 | String[] scopeContext() default {}; 52 | 53 | /** 54 | * 配置在那些方法执行后自动清除缓存
55 | * 支持通配符。like:[UserEntityMapper.updateType,AccountEntityMapper.*] 56 | * @return 57 | */ 58 | String[] evictOnMethods() default {}; 59 | 60 | /** 61 | * 引用缓存key 62 | * @return 63 | */ 64 | String[] refKey() default {}; 65 | } 66 | -------------------------------------------------------------------------------- /jeesuite-springweb/src/main/java/com/jeesuite/springweb/model/WrapperResponse.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.springweb.model; 2 | 3 | 4 | import com.fasterxml.jackson.annotation.JsonInclude; 5 | import com.fasterxml.jackson.annotation.JsonInclude.Include; 6 | import com.jeesuite.common.json.JsonUtils; 7 | 8 | 9 | public class WrapperResponse { 10 | 11 | // 状态 12 | private int code = 200; 13 | 14 | // 返回信息 15 | @JsonInclude(Include.NON_NULL) 16 | private String msg; 17 | 18 | // 响应数据 19 | @JsonInclude(Include.NON_NULL) 20 | private T data; 21 | 22 | public WrapperResponse(){} 23 | 24 | public WrapperResponse(int code, String msg) { 25 | super(); 26 | this.code = code; 27 | this.msg = msg; 28 | } 29 | 30 | public WrapperResponse(int code, String msg, T data) { 31 | this.code = code; 32 | this.msg = msg; 33 | this.data = data; 34 | } 35 | 36 | 37 | public WrapperResponse(T data) { 38 | this.data = data; 39 | } 40 | 41 | public int getCode() { 42 | return code; 43 | } 44 | 45 | public void setCode(int code) { 46 | this.code = code; 47 | } 48 | 49 | public String getMsg() { 50 | return msg; 51 | } 52 | 53 | public void setMsg(String msg) { 54 | this.msg = msg; 55 | } 56 | 57 | public T getData() { 58 | return data; 59 | } 60 | 61 | public void setData(T data) { 62 | this.data = data; 63 | } 64 | 65 | public boolean successed(){ 66 | return code == 200; 67 | } 68 | 69 | @Override 70 | public String toString() { 71 | return JsonUtils.toJson(this); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /jeesuite-rest/src/main/java/com/jeesuite/rest/filter/handler/CorsHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.rest.filter.handler; 5 | 6 | import javax.servlet.http.HttpServletRequest; 7 | import javax.ws.rs.container.ContainerRequestContext; 8 | import javax.ws.rs.container.ContainerResponseContext; 9 | import javax.ws.rs.container.ResourceInfo; 10 | 11 | import com.jeesuite.rest.RestConst; 12 | import com.jeesuite.rest.filter.FilterConfig; 13 | import com.jeesuite.rest.filter.FilterHandler; 14 | 15 | /** 16 | * @description
17 | * @author vakin 18 | * @date 2016年12月28日 19 | */ 20 | public class CorsHandler implements FilterHandler { 21 | 22 | 23 | @Override 24 | public void processRequest(ContainerRequestContext requestContext, HttpServletRequest request, 25 | ResourceInfo resourceInfo) {} 26 | 27 | @Override 28 | public void processResponse(ContainerRequestContext requestContext, ContainerResponseContext responseContext, 29 | ResourceInfo resourceInfo) { 30 | responseContext.getHeaders().add(RestConst.ACCESS_CONTROL_ALLOW_ORIGIN, FilterConfig.getCorsAllowOrgin()); 31 | responseContext.getHeaders().add(RestConst.ACCESS_CONTROL_ALLOW_METHODS_TITLE, RestConst.ACCESS_CONTROL_ALLOW_METHODS); 32 | responseContext.getHeaders().add(RestConst.ACCESS_CONTROL_ALLOW_HEADERS, RestConst.ALLOW_HEADERS); 33 | responseContext.getHeaders().add("Access-Control-Allow-Credentials", "true"); 34 | } 35 | 36 | @Override 37 | public int getPriority() { 38 | return 10; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /jeesuite-common/src/main/java/com/jeesuite/common/serializer/KryoSerializer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.common.serializer; 5 | 6 | import com.esotericsoftware.kryo.Kryo; 7 | import com.esotericsoftware.kryo.io.Input; 8 | import com.esotericsoftware.kryo.io.Output; 9 | 10 | import java.io.ByteArrayInputStream; 11 | import java.io.ByteArrayOutputStream; 12 | import java.io.IOException; 13 | 14 | /** 15 | * @description
16 | * @author vakin 17 | * @date 2016年12月28日 18 | */ 19 | public class KryoSerializer implements Serializer { 20 | 21 | private final static Kryo kryo = new Kryo(); 22 | 23 | 24 | @Override 25 | public String name() { 26 | return "kryo"; 27 | } 28 | 29 | @Override 30 | public byte[] serialize(Object obj) throws IOException { 31 | Output output = null; 32 | try { 33 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); 34 | output = new Output(baos); 35 | kryo.writeClassAndObject(output, obj); 36 | output.flush(); 37 | return baos.toByteArray(); 38 | }finally{ 39 | if(output != null) 40 | output.close(); 41 | } 42 | } 43 | 44 | @Override 45 | public Object deserialize(byte[] bits) throws IOException { 46 | if(bits == null || bits.length == 0) 47 | return null; 48 | Input ois = null; 49 | try { 50 | ByteArrayInputStream bais = new ByteArrayInputStream(bits); 51 | ois = new Input(bais); 52 | return kryo.readClassAndObject(ois); 53 | } finally { 54 | if(ois != null) 55 | ois.close(); 56 | } 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /jeesuite-security/src/main/java/com/jeesuite/security/model/BaseUserInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2018 www.jeesuite.com. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jeesuite.security.model; 17 | 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | 21 | /** 22 | * @description
23 | * @author vakin 24 | * @date 2018年11月30日 25 | */ 26 | public class BaseUserInfo { 27 | 28 | private String id; 29 | private String userName; 30 | private List scopes = new ArrayList<>(); 31 | 32 | public String getId() { 33 | return id; 34 | } 35 | public void setId(String id) { 36 | this.id = id; 37 | } 38 | public String getUserName() { 39 | return userName; 40 | } 41 | public void setUserName(String userName) { 42 | this.userName = userName; 43 | } 44 | public List getScopes() { 45 | return scopes; 46 | } 47 | public void setScopes(List scopes) { 48 | this.scopes = scopes; 49 | } 50 | 51 | 52 | } 53 | -------------------------------------------------------------------------------- /jeesuite-kafka/src/main/java/com/jeesuite/kafka/serializer/JsonMessageDeserializer.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.kafka.serializer; 2 | 3 | import java.io.UnsupportedEncodingException; 4 | import java.nio.charset.StandardCharsets; 5 | import java.util.Map; 6 | 7 | import org.apache.kafka.common.errors.SerializationException; 8 | import org.apache.kafka.common.serialization.Deserializer; 9 | 10 | import com.jeesuite.common.json.JsonUtils; 11 | import com.jeesuite.kafka.message.DefaultMessage; 12 | 13 | /** 14 | * 15 | * @description
16 | * @author vakin 17 | * @date 2018年3月11日 18 | */ 19 | public class JsonMessageDeserializer implements Deserializer { 20 | 21 | @Override 22 | public void configure(Map configs, boolean isKey) {} 23 | 24 | @Override 25 | public Object deserialize(String topic, byte[] data) { 26 | try { 27 | if (data == null) 28 | return null; 29 | else{ 30 | String jsonString = new String(data, StandardCharsets.UTF_8.name()); 31 | try { 32 | return JsonUtils.toObject(jsonString, DefaultMessage.class); 33 | } catch (Exception e) { 34 | return jsonString; 35 | } 36 | } 37 | } catch (UnsupportedEncodingException e) { 38 | throw new SerializationException("Error when deserializing byte[] to string due to unsupported encoding UTF-8"); 39 | } 40 | } 41 | 42 | @Override 43 | public void close() { 44 | // nothing to do 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /jeesuite-mybatis/src/main/java/com/jeesuite/mybatis/spring/MybatisPluginBaseSpringInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.mybatis.spring; 2 | 3 | import java.lang.reflect.Method; 4 | 5 | import org.aspectj.lang.ProceedingJoinPoint; 6 | import org.aspectj.lang.annotation.Around; 7 | import org.aspectj.lang.reflect.MethodSignature; 8 | import org.springframework.transaction.annotation.Transactional; 9 | 10 | import com.jeesuite.mybatis.MybatisRuntimeContext; 11 | import com.jeesuite.mybatis.datasource.MuitDataSourceManager; 12 | import com.jeesuite.mybatis.plugin.cache.CacheHandler; 13 | import com.jeesuite.mybatis.plugin.rwseparate.UseMaster; 14 | 15 | /** 16 | * AOP拦截器基类 17 | * @description
18 | * @author vakin 19 | * @date 2018年5月1日 20 | */ 21 | public abstract class MybatisPluginBaseSpringInterceptor { 22 | 23 | public abstract void pointcut(); 24 | 25 | @Around("pointcut()") 26 | public Object around(ProceedingJoinPoint pjp) throws Throwable { 27 | try { 28 | MethodSignature methodSignature = (MethodSignature)pjp.getSignature(); 29 | Method method = methodSignature.getMethod(); 30 | 31 | if(method.isAnnotationPresent(Transactional.class)){ 32 | MybatisRuntimeContext.setTransactionalMode(true); 33 | } 34 | if(method.isAnnotationPresent(UseMaster.class)){ 35 | MuitDataSourceManager.get().forceMaster(); 36 | } 37 | return pjp.proceed(); 38 | } catch (Exception e) { 39 | CacheHandler.rollbackCache(); 40 | throw e; 41 | }finally { 42 | MybatisRuntimeContext.unset(); 43 | } 44 | 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /jeesuite-common/src/main/java/com/jeesuite/common/serializer/JavaSerializer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.common.serializer; 5 | 6 | import java.io.ByteArrayInputStream; 7 | import java.io.ByteArrayOutputStream; 8 | import java.io.IOException; 9 | import java.io.ObjectInputStream; 10 | import java.io.ObjectOutputStream; 11 | 12 | /** 13 | * @description
14 | * @author vakin 15 | * @date 2016年12月28日 16 | */ 17 | public class JavaSerializer implements Serializer { 18 | 19 | @Override 20 | public String name() { 21 | return "java"; 22 | } 23 | 24 | @Override 25 | public byte[] serialize(Object obj) throws IOException { 26 | ObjectOutputStream oos = null; 27 | try { 28 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); 29 | oos = new ObjectOutputStream(baos); 30 | oos.writeObject(obj); 31 | return baos.toByteArray(); 32 | } finally { 33 | if(oos != null) 34 | try { 35 | oos.close(); 36 | } catch (IOException e) {} 37 | } 38 | } 39 | 40 | @Override 41 | public Object deserialize(byte[] bits) throws IOException { 42 | if(bits == null || bits.length == 0) 43 | return null; 44 | ObjectInputStream ois = null; 45 | try { 46 | ByteArrayInputStream bais = new ByteArrayInputStream(bits); 47 | ois = new ObjectInputStream(bais); 48 | return ois.readObject(); 49 | } catch (ClassNotFoundException e) { 50 | throw new RuntimeException(e); 51 | } finally { 52 | if(ois != null) 53 | try { 54 | ois.close(); 55 | } catch (IOException e) {} 56 | } 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /jeesuite-springboot-starter/src/main/java/com/jeesuite/springboot/starter/scheduler/SchedulerProperties.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.springboot.starter.scheduler; 5 | 6 | import org.springframework.boot.context.properties.ConfigurationProperties; 7 | 8 | /** 9 | * @description
10 | * @author vakin 11 | * @date 2016年12月31日 12 | */ 13 | @ConfigurationProperties(prefix="jeesuite.task") 14 | public class SchedulerProperties { 15 | 16 | 17 | private String registryType = "zookeeper"; 18 | private String registryServers; 19 | private String groupName; 20 | private String scanPackages; 21 | private int threadPoolSize; 22 | 23 | public String getRegistryType() { 24 | return registryType; 25 | } 26 | public void setRegistryType(String registryType) { 27 | this.registryType = registryType; 28 | } 29 | public String getRegistryServers() { 30 | return registryServers; 31 | } 32 | public void setRegistryServers(String registryServers) { 33 | this.registryServers = registryServers; 34 | } 35 | public String getGroupName() { 36 | return groupName; 37 | } 38 | public void setGroupName(String groupName) { 39 | this.groupName = groupName; 40 | } 41 | public String getScanPackages() { 42 | return scanPackages; 43 | } 44 | public void setScanPackages(String scanPackages) { 45 | this.scanPackages = scanPackages; 46 | } 47 | public int getThreadPoolSize() { 48 | return threadPoolSize; 49 | } 50 | public void setThreadPoolSize(int threadPoolSize) { 51 | this.threadPoolSize = threadPoolSize; 52 | } 53 | 54 | 55 | } 56 | -------------------------------------------------------------------------------- /jeesuite-common/src/main/java/com/jeesuite/common/util/StringCharsetUtils.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.common.util; 2 | 3 | import java.nio.charset.Charset; 4 | 5 | /** 6 | * @description
7 | * @author vakin 8 | * @date 2019年08月29日 9 | */ 10 | public class StringCharsetUtils { 11 | 12 | public static final Charset ISO_8859_1 = Charset.forName("ISO-8859-1"); 13 | public static final Charset UTF_8 = Charset.forName("UTF-8"); 14 | public static final Charset GBK = Charset.forName("GBK"); 15 | public static final Charset UTF_16BE = Charset.forName("UTF-16BE"); 16 | public static final Charset UTF_16LE = Charset.forName("UTF-16LE"); 17 | 18 | public static boolean isCharset(String str, Charset charset) { 19 | try { 20 | return str.equals(new String(str.getBytes(charset), charset)); 21 | } catch (Exception e) { 22 | return false; 23 | } 24 | } 25 | 26 | public static String convertCharset(String str, Charset toCharset) { 27 | if(isCharset(str, toCharset))return str; 28 | if(isCharset(str, UTF_8)){ 29 | return convertCharset(str, UTF_8, toCharset); 30 | } 31 | if(isCharset(str, GBK)){ 32 | return convertCharset(str, UTF_8, toCharset); 33 | } 34 | if(isCharset(str, ISO_8859_1)){ 35 | return convertCharset(str, UTF_8, toCharset); 36 | } 37 | return str; 38 | } 39 | 40 | public static String convertCharset(String str, Charset fromCharset, Charset toCharset) { 41 | if (str != null) { 42 | byte[] bs = str.getBytes(fromCharset); 43 | return new String(bs, toCharset); 44 | } 45 | return null; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /jeesuite-spring/src/main/java/com/jeesuite/spring/InstanceFactoryConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2018 www.jeesuite.com. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jeesuite.spring; 17 | 18 | import org.springframework.beans.BeansException; 19 | import org.springframework.context.ApplicationContext; 20 | import org.springframework.context.ApplicationContextAware; 21 | import org.springframework.core.Ordered; 22 | import org.springframework.core.PriorityOrdered; 23 | 24 | /** 25 | * @description
26 | * @author vakin 27 | * @date 2018年12月20日 28 | */ 29 | public class InstanceFactoryConfiguration implements ApplicationContextAware,PriorityOrdered{ 30 | 31 | @Override 32 | public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { 33 | InstanceFactory.setInstanceProvider(new SpringInstanceProvider(applicationContext)); 34 | } 35 | 36 | @Override 37 | public int getOrder() { 38 | return Ordered.HIGHEST_PRECEDENCE; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /jeesuite-filesystem/src/main/java/com/jeesuite/filesystem/utils/MimeTypeFileExtensionConvert.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.filesystem.utils; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | public class MimeTypeFileExtensionConvert { 7 | 8 | private static Map maps = new HashMap<>(); 9 | 10 | static{ 11 | maps.put("image/jpeg",".jpg"); 12 | maps.put("image/gif",".gif" ); 13 | maps.put("image/png",".png" ); 14 | maps.put("image/bmp",".bmp" ); 15 | maps.put("text/plain",".txt"); 16 | maps.put("application/zip",".zip" ); 17 | maps.put("application/x-zip-compressed",".zip" ); 18 | maps.put("multipart/x-zip",".zip" ); 19 | maps.put("application/x-compressed",".zip" ); 20 | maps.put("audio/mpeg3",".mp3" ); 21 | maps.put("video/avi",".avi" ); 22 | maps.put("audio/wav",".wav" ); 23 | maps.put("application/x-gzip",".gzip" ); 24 | maps.put("application/x-gzip",".gz"); 25 | maps.put("text/html",".html"); 26 | maps.put("application/x-shockwave-flash",".svg"); 27 | maps.put("application/pdf",".pdf" ); 28 | maps.put("application/msword",".doc" ); 29 | maps.put("application/vnd.openxmlformats-officedocument.wordprocessingml.document",".docx" ); 30 | maps.put("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",".xlsx" ); 31 | maps.put("application/vnd.ms-excel",".xls" ); 32 | maps.put("application/vnd.ms-powerpoint",".ppt" ); 33 | maps.put("application/vnd.openxmlformats-officedocument.presentationml.presentation",".pptx" ); 34 | } 35 | 36 | public static String getFileExtension(String mimeType){ 37 | return maps.get(mimeType); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /jeesuite-common/src/main/java/com/jeesuite/common/serializer/FSTSerializer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.common.serializer; 5 | 6 | import java.io.ByteArrayInputStream; 7 | import java.io.ByteArrayOutputStream; 8 | import java.io.IOException; 9 | 10 | import de.ruedigermoeller.serialization.FSTObjectInput; 11 | import de.ruedigermoeller.serialization.FSTObjectOutput; 12 | 13 | /** 14 | * @description
15 | * @author vakin 16 | * @date 2016年12月28日 17 | */ 18 | public class FSTSerializer implements Serializer{ 19 | 20 | @Override 21 | public String name() { 22 | return "fst"; 23 | } 24 | 25 | @Override 26 | public byte[] serialize(Object obj) throws IOException { 27 | ByteArrayOutputStream out = null; 28 | FSTObjectOutput fout = null; 29 | try { 30 | out = new ByteArrayOutputStream(); 31 | fout = new FSTObjectOutput(out); 32 | fout.writeObject(obj); 33 | fout.flush(); 34 | return out.toByteArray(); 35 | } finally { 36 | if(fout != null) 37 | try { 38 | fout.close(); 39 | } catch (IOException e) {} 40 | } 41 | } 42 | 43 | @Override 44 | public Object deserialize(byte[] bytes) throws IOException { 45 | if(bytes == null || bytes.length == 0) 46 | return null; 47 | FSTObjectInput in = null; 48 | try { 49 | in = new FSTObjectInput(new ByteArrayInputStream(bytes)); 50 | return in.readObject(); 51 | } catch (ClassNotFoundException e) { 52 | throw new RuntimeException(e); 53 | } finally { 54 | if(in != null) 55 | try { 56 | in.close(); 57 | } catch (IOException e) {} 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /jeesuite-common/src/main/java/com/jeesuite/common/crypt/AES.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.common.crypt; 5 | 6 | import javax.crypto.Cipher; 7 | import javax.crypto.KeyGenerator; 8 | import javax.crypto.SecretKey; 9 | import javax.crypto.spec.SecretKeySpec; 10 | 11 | /** 12 | * @description
13 | * @author vakin 14 | * @date 2017年1月14日 15 | */ 16 | public class AES { 17 | /** 18 | * 生成密钥 19 | * @throws Exception 20 | */ 21 | public static byte[] initKey() throws Exception{ 22 | //密钥生成器 23 | KeyGenerator keyGen = KeyGenerator.getInstance("AES"); 24 | //初始化密钥生成器 25 | keyGen.init(128); //默认128,获得无政策权限后可用192或256 26 | //生成密钥 27 | SecretKey secretKey = keyGen.generateKey(); 28 | return secretKey.getEncoded(); 29 | } 30 | 31 | /** 32 | * 加密 33 | * @throws Exception 34 | */ 35 | public static byte[] encrypt(byte[] data, byte[] key) throws Exception{ 36 | //恢复密钥 37 | SecretKey secretKey = new SecretKeySpec(key, "AES"); 38 | //Cipher完成加密 39 | Cipher cipher = Cipher.getInstance("AES"); 40 | //根据密钥对cipher进行初始化 41 | cipher.init(Cipher.ENCRYPT_MODE, secretKey); 42 | //加密 43 | byte[] encrypt = cipher.doFinal(data); 44 | 45 | return encrypt; 46 | } 47 | /** 48 | * 解密 49 | */ 50 | public static byte[] decrypt(byte[] data, byte[] key) throws Exception{ 51 | //恢复密钥生成器 52 | SecretKey secretKey = new SecretKeySpec(key, "AES"); 53 | //Cipher完成解密 54 | Cipher cipher = Cipher.getInstance("AES"); 55 | //根据密钥对cipher进行初始化 56 | cipher.init(Cipher.DECRYPT_MODE, secretKey); 57 | byte[] plain = cipher.doFinal(data); 58 | return plain; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /jeesuite-log/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | com.jeesuite 6 | jeesuite-libs 7 | 1.3.4-SNAPSHOT 8 | 9 | jeesuite-log 10 | 11 | 12 | 13 | com.jeesuite 14 | jeesuite-common 15 | ${project.parent.version} 16 | true 17 | 18 | 19 | log4j 20 | log4j 21 | 1.2.17 22 | provided 23 | 24 | 25 | org.slf4j 26 | slf4j-api 27 | 1.7.25 28 | provided 29 | 30 | 31 | org.slf4j 32 | slf4j-log4j12 33 | 1.7.25 34 | provided 35 | 36 | 37 | 38 | org.apache.logging.log4j 39 | log4j-api 40 | 2.7 41 | provided 42 | 43 | 44 | org.apache.logging.log4j 45 | log4j-core 46 | 2.7 47 | provided 48 | 49 | 50 | -------------------------------------------------------------------------------- /jeesuite-mybatis/src/main/java/com/jeesuite/mybatis/datasource/builder/HikariCPDataSourceBuilder.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.mybatis.datasource.builder; 2 | 3 | import java.util.Properties; 4 | 5 | import org.springframework.beans.factory.support.BeanDefinitionBuilder; 6 | 7 | import com.zaxxer.hikari.HikariDataSource; 8 | 9 | public class HikariCPDataSourceBuilder { 10 | 11 | public static BeanDefinitionBuilder builder(Properties props){ 12 | 13 | BeanDefinitionBuilder beanDefinitionBuilder = BeanDefinitionBuilder.genericBeanDefinition(HikariDataSource.class); 14 | if(props.containsKey("driverClassName"))beanDefinitionBuilder.addPropertyValue("driverClassName", props.getProperty("driverClassName")); 15 | beanDefinitionBuilder.addPropertyValue("jdbcUrl", props.getProperty("jdbcUrl")); 16 | beanDefinitionBuilder.addPropertyValue("username", props.getProperty("username")); 17 | beanDefinitionBuilder.addPropertyValue("password", props.getProperty("password")); 18 | beanDefinitionBuilder.addPropertyValue("connectionTestQuery", props.getProperty("connectionTestQuery","SELECT 'x'")); 19 | beanDefinitionBuilder.addPropertyValue("connectionTimeout", Long.parseLong(props.getProperty("connectionTimeout","10000"))); 20 | beanDefinitionBuilder.addPropertyValue("idleTimeout", Long.parseLong(props.getProperty("idleTimeout","600000"))); 21 | beanDefinitionBuilder.addPropertyValue("maximumPoolSize", Integer.parseInt(props.getProperty("maximumPoolSize","10"))); 22 | beanDefinitionBuilder.addPropertyValue("maxLifetime", Long.parseLong(props.getProperty("maxLifetime","900000"))); 23 | return beanDefinitionBuilder; 24 | 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /jeesuite-filesystem/src/test/resources/fs.properties: -------------------------------------------------------------------------------- 1 | public.filesystem.id=public 2 | private.filesystem.id=private 3 | 4 | public.filesystem.provider=qiniu 5 | public.filesystem.bucketName=test112233 6 | public.filesystem.urlprefix=http://owep828p6.bkt.clouddn.com 7 | public.filesystem.accessKey=iqq3aa-ncqfdGGubCcS-N8EUV-qale2ezndnrtKS 8 | public.filesystem.secretKey=1RmdaMVjrjXkyRVPOmyMa6BzcdG5VDdF-SH_HUTe 9 | public.filesystem.private=false 10 | 11 | private.filesystem.provider=qiniu 12 | private.filesystem.bucketName=testa1b2c3 13 | private.filesystem.urlprefix=http://ovjjqjpmp.bkt.clouddn.com 14 | private.filesystem.accessKey=iqq3aa-ncqfdGGubCcS-N8EUV-qale2ezndnrtKS 15 | private.filesystem.secretKey=1RmdaMVjrjXkyRVPOmyMa6BzcdG5VDdF-SH_HUTe 16 | private.filesystem.private=true 17 | 18 | report.filesystem.provider=qiniu 19 | report.filesystem.bucketName=report123 20 | report.filesystem.urlprefix=http://rtjjqrrpmp.bkt.clouddn.com 21 | report.filesystem.accessKey=iqq3aa-ncqfdGGubCcS-N8EUV-qale2ezndnrtKS 22 | report.filesystem.secretKey=1RmdaMVjrjXkyRVPOmyMa6BzcdG5VDdF-SH_HUTe 23 | report.filesystem.private=true 24 | 25 | xxxx1.filesystem.provider=fastDFS 26 | xxxx1.filesystem.servers=120.24.185.19:22122 27 | xxxx1.filesystem.urlprefix=http://120.24.185.19:81 28 | xxxx1.filesystem.connectTimeout=3000 29 | xxxx1.filesystem.maxThreads=100 30 | 31 | xxxx2.filesystem.provider=aliyun 32 | xxxx2.filesystem.bucketName=cwd-file 33 | xxxx2.filesystem.endpoint=http://oss-cn-beijing.aliyuncs.com 34 | xxxx2.filesystem.accessKey=LTAIhDhFnPZ8TG0iq3 35 | xxxx2.filesystem.secretKey=oa6IT6oNcJgxRzAuhVNvzjGuctO0sc3 36 | xxxx2.filesystem.urlprefix=http://res.flyfun.site 37 | xxxx2.filesystem.private=true 38 | 39 | -------------------------------------------------------------------------------- /jeesuite-spring/src/main/java/com/jeesuite/spring/web/ContextLoaderListener.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.spring.web; 2 | 3 | import java.util.Map; 4 | 5 | import javax.servlet.ServletContextEvent; 6 | 7 | import org.springframework.web.context.WebApplicationContext; 8 | import org.springframework.web.context.support.WebApplicationContextUtils; 9 | 10 | import com.jeesuite.spring.ApplicationStartedListener; 11 | import com.jeesuite.spring.InstanceFactory; 12 | import com.jeesuite.spring.SpringInstanceProvider; 13 | 14 | 15 | 16 | public class ContextLoaderListener extends org.springframework.web.context.ContextLoaderListener { 17 | 18 | @Override 19 | public void contextInitialized(ServletContextEvent event) { 20 | String serviceName = event.getServletContext().getInitParameter("appName"); 21 | System.setProperty("serviceName", serviceName == null ? "undefined" : serviceName); 22 | super.contextInitialized(event); 23 | WebApplicationContext applicationContext = WebApplicationContextUtils.getRequiredWebApplicationContext(event.getServletContext()); 24 | SpringInstanceProvider provider = new SpringInstanceProvider(applicationContext); 25 | InstanceFactory.loadFinished(provider); 26 | 27 | Map interfaces = applicationContext.getBeansOfType(ApplicationStartedListener.class); 28 | if(interfaces != null){ 29 | for (ApplicationStartedListener listener : interfaces.values()) { 30 | System.out.println(">>>begin to execute listener:"+listener.getClass().getName()); 31 | listener.onApplicationStarted(applicationContext); 32 | System.out.println("<<< 3 | 4.0.0 4 | 5 | com.jeesuite 6 | jeesuite-libs 7 | 1.3.4 8 | 9 | jeesuite-cache 10 | 1.3.5-SNAPSHOT 11 | 12 | 13 | 14 | com.jeesuite 15 | jeesuite-common 16 | ${project.parent.version} 17 | 18 | 19 | 20 | com.jeesuite 21 | jeesuite-spring 22 | ${project.parent.version} 23 | 24 | 25 | 26 | redis.clients 27 | jedis 28 | ${jedis.version} 29 | 30 | 31 | 32 | com.google.guava 33 | guava 34 | 19.0 35 | 36 | 37 | 38 | net.sf.ehcache 39 | ehcache-core 40 | 2.6.11 41 | true 42 | 43 | 44 | 45 | 46 | 47 | 48 | org.apache.maven.plugins 49 | maven-deploy-plugin 50 | 51 | false 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /jeesuite-cache/src/test/resources/ehcache.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 19 | 20 | 21 | 22 | 31 | 32 | -------------------------------------------------------------------------------- /jeesuite-event/jeesuite-event.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /jeesuite-common2/src/test/java/test/lock/RedisDistributeLockTest.java: -------------------------------------------------------------------------------- 1 | package test.lock; 2 | 3 | import java.util.concurrent.CountDownLatch; 4 | import java.util.concurrent.ExecutorService; 5 | import java.util.concurrent.Executors; 6 | import java.util.concurrent.locks.Lock; 7 | 8 | import org.apache.commons.lang3.RandomUtils; 9 | 10 | import com.jeesuite.common2.lock.redis.RedisDistributeLock; 11 | 12 | public class RedisDistributeLockTest { 13 | 14 | private static CountDownLatch latch; 15 | 16 | public static void main(String[] args) throws Exception { 17 | 18 | 19 | int taskcount = 21; 20 | latch = new CountDownLatch(taskcount); 21 | ExecutorService threadPool = Executors.newFixedThreadPool(taskcount); 22 | 23 | for (int i = 0; i < taskcount; i++) { 24 | threadPool.submit(new LockWorker("worker-"+i)); 25 | } 26 | 27 | latch.await(); 28 | threadPool.shutdown(); 29 | } 30 | 31 | static class LockWorker implements Runnable{ 32 | 33 | private String id; 34 | 35 | public LockWorker(String id) { 36 | super(); 37 | this.id = id; 38 | } 39 | 40 | @Override 41 | public void run() { 42 | Lock lock = new RedisDistributeLock("test",60); 43 | try { 44 | lock.lock(); 45 | } catch (Exception e) { 46 | latch.countDown(); 47 | System.out.println("LockWorker[" + id + "] get lock error->"+e.getMessage()); 48 | return; 49 | } 50 | System.out.println("LockWorker[" + id + "] get lock,doing-----" + ShareResource.add()); 51 | try {Thread.sleep(RandomUtils.nextLong(100, 1000));} catch (Exception e) {} 52 | lock.unlock(); 53 | latch.countDown(); 54 | System.out.println("LockWorker[" + id + "] release lock,done"); 55 | } 56 | 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /jeesuite-springweb/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | com.jeesuite 6 | jeesuite-libs 7 | 1.3.4-SNAPSHOT 8 | 9 | jeesuite-springweb 10 | 11 | 12 | 13 | com.jeesuite 14 | jeesuite-common 15 | ${project.parent.version} 16 | true 17 | 18 | 19 | org.springframework 20 | spring-web 21 | ${spring.version} 22 | 23 | 24 | 25 | org.springframework 26 | spring-webmvc 27 | ${spring.version} 28 | 29 | 30 | 31 | javax.servlet 32 | javax.servlet-api 33 | 3.1.0 34 | provided 35 | 36 | 37 | 38 | com.google.guava 39 | guava 40 | 19.0 41 | 42 | 43 | 44 | 45 | 46 | 47 | org.apache.maven.plugins 48 | maven-deploy-plugin 49 | 50 | false 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /jeesuite-springboot-starter/src/main/java/com/jeesuite/springboot/starter/kafka/DelegateKafkaProducerConfiguration.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.springboot.starter.kafka; 5 | 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; 8 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 9 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 10 | import org.springframework.context.annotation.Bean; 11 | import org.springframework.context.annotation.Configuration; 12 | 13 | import com.jeesuite.kafka.spring.TopicProducerSpringProvider; 14 | 15 | /** 16 | * @description
17 | * @author vakin 18 | * @date 2017年3月28日 19 | */ 20 | @Configuration 21 | @EnableConfigurationProperties(KafkaProducerProperties.class) 22 | @ConditionalOnClass(TopicProducerSpringProvider.class) 23 | @ConditionalOnProperty(name="kafka.bootstrap.servers") 24 | public class DelegateKafkaProducerConfiguration { 25 | 26 | @Autowired 27 | private KafkaProducerProperties producerProperties; 28 | 29 | @Bean 30 | public TopicProducerSpringProvider producerProvider() { 31 | 32 | TopicProducerSpringProvider bean = new TopicProducerSpringProvider(); 33 | bean.setConfigs(producerProperties.getConfigs()); 34 | bean.setDefaultAsynSend(producerProperties.isDefaultAsynSend()); 35 | bean.setDelayRetries(producerProperties.getDelayRetries()); 36 | bean.setProducerGroup(producerProperties.getProducerGroup()); 37 | bean.setMonitorEnabled(producerProperties.isMonitorEnabled()); 38 | bean.setConsumerAckEnabled(producerProperties.isConsumerAckEnabled()); 39 | return bean; 40 | } 41 | 42 | 43 | 44 | } 45 | -------------------------------------------------------------------------------- /jeesuite-scheduler/src/main/java/com/jeesuite/scheduler/monitor/MonitorCommond.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.scheduler.monitor; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * @description
10 | * @author vakin 11 | * @date 2016年10月31日 12 | */ 13 | public class MonitorCommond implements Serializable { 14 | 15 | private static final long serialVersionUID = 1L; 16 | 17 | 18 | public final static byte TYPE_EXEC = 0x01; //执行定时任务 19 | public final static byte TYPE_STATUS_MOD = 0x02;//开停状态修改 20 | public final static byte TYPE_CRON_MOD = 0x03;//执行时间策略修改 21 | 22 | 23 | private byte cmdType; 24 | private String jobGroup; 25 | private String jobName; 26 | private Object body; 27 | 28 | public MonitorCommond() {} 29 | 30 | public MonitorCommond(byte cmdType, String jobGroup, String jobName, Object body) { 31 | super(); 32 | this.cmdType = cmdType; 33 | this.jobGroup = jobGroup; 34 | this.jobName = jobName; 35 | this.body = body; 36 | } 37 | public byte getCmdType() { 38 | return cmdType; 39 | } 40 | public void setCmdType(byte cmdType) { 41 | this.cmdType = cmdType; 42 | } 43 | public String getJobGroup() { 44 | return jobGroup; 45 | } 46 | public void setJobGroup(String jobGroup) { 47 | this.jobGroup = jobGroup; 48 | } 49 | public String getJobName() { 50 | return jobName; 51 | } 52 | public void setJobName(String jobName) { 53 | this.jobName = jobName; 54 | } 55 | 56 | public Object getBody() { 57 | return body; 58 | } 59 | 60 | public void setBody(Object body) { 61 | this.body = body; 62 | } 63 | 64 | @Override 65 | public String toString() { 66 | return "MonitorCommond [cmdType=" + cmdType + ", jobGroup=" + jobGroup + ", jobName=" + jobName + "]"; 67 | } 68 | 69 | 70 | } 71 | -------------------------------------------------------------------------------- /jeesuite-common/src/main/java/com/jeesuite/common/crypt/SHA1.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.common.crypt; 2 | 3 | import java.security.MessageDigest; 4 | import java.util.Arrays; 5 | 6 | import com.jeesuite.common.JeesuiteBaseException; 7 | 8 | 9 | public class SHA1 { 10 | 11 | /** 12 | *

13 | * 用SHA1算法生成安全签名 14 | *

15 | * 16 | * @param token 17 | * 票据 18 | * @param timestamp 19 | * 时间戳 20 | * @param nonce 21 | * 随机字符串 22 | * @param encrypt 23 | * 密文 24 | * @return 安全签名 25 | * 26 | * @throws AESException {@link AESException} 27 | */ 28 | public static String getSHA1(String token, String timestamp, String nonce, String encrypt) { 29 | try { 30 | String[] array = new String[]{token, timestamp, nonce, encrypt}; 31 | StringBuffer sb = new StringBuffer(); 32 | 33 | /* 字符串排序 */ 34 | Arrays.sort(array); 35 | for (int i = 0; i < 4; i++) { 36 | sb.append(array[i]); 37 | } 38 | 39 | /* SHA1签名生成 */ 40 | MessageDigest md = MessageDigest.getInstance("SHA-1"); 41 | md.update(sb.toString().getBytes()); 42 | byte[] digest = md.digest(); 43 | 44 | StringBuffer hexstr = new StringBuffer(); 45 | String shaHex = ""; 46 | for (int i = 0; i < digest.length; i++) { 47 | shaHex = Integer.toHexString(digest[i] & 0xFF); 48 | if (shaHex.length() < 2) { 49 | hexstr.append(0); 50 | } 51 | hexstr.append(shaHex); 52 | } 53 | 54 | return hexstr.toString(); 55 | } catch (Exception e) { 56 | throw new JeesuiteBaseException(500, "error", e); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /jeesuite-kafka/src/main/java/com/jeesuite/kafka/producer/ConsumerAckWatcher.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.kafka.producer; 2 | 3 | import java.util.Objects; 4 | import java.util.concurrent.CountDownLatch; 5 | import java.util.concurrent.TimeUnit; 6 | 7 | import org.I0Itec.zkclient.IZkDataListener; 8 | import org.I0Itec.zkclient.ZkClient; 9 | import org.slf4j.Logger; 10 | import org.slf4j.LoggerFactory; 11 | 12 | import com.jeesuite.kafka.KafkaConst; 13 | 14 | /** 15 | * 消费回执观察者 16 | * @description
17 | * @author vakin 18 | * @date 2017年11月27日 19 | */ 20 | public class ConsumerAckWatcher { 21 | 22 | private static final Logger log = LoggerFactory.getLogger(ConsumerAckWatcher.class); 23 | 24 | private CountDownLatch latch; 25 | private String consumerGroup; 26 | 27 | public ConsumerAckWatcher(String messageId, ZkClient zkClient) { 28 | this.latch = new CountDownLatch(1); 29 | 30 | String path = KafkaConst.ZK_PRODUCER_ACK_PATH + messageId; 31 | zkClient.createEphemeral(path); 32 | 33 | zkClient.subscribeDataChanges(path, new IZkDataListener() { 34 | @Override 35 | public void handleDataDeleted(String dataPath) throws Exception {} 36 | @Override 37 | public void handleDataChange(String dataPath, Object data) throws Exception { 38 | latch.countDown(); 39 | consumerGroup = Objects.toString(data); 40 | log.debug("recv_consumer_ack messageId:{},from group:{}",messageId,consumerGroup); 41 | try {zkClient.delete(dataPath);} catch (Exception e) {} 42 | } 43 | }); 44 | } 45 | 46 | 47 | /** 48 | * 等待应答 49 | * @return 返回消费者groupName 50 | */ 51 | public String waitAck(){ 52 | try { 53 | this.latch.await(5000, TimeUnit.MILLISECONDS); 54 | return consumerGroup; 55 | } catch (Exception e) {} 56 | return null; 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /jeesuite-rest/src/main/java/com/jeesuite/rest/BaseApplicaionConfig.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.rest; 5 | 6 | import org.glassfish.jersey.jackson.JacksonFeature; 7 | import org.glassfish.jersey.server.ResourceConfig; 8 | import org.glassfish.jersey.server.ServerProperties; 9 | import org.springframework.web.filter.RequestContextFilter; 10 | 11 | import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; 12 | import com.jeesuite.rest.excetion.BaseExceptionMapper; 13 | import com.jeesuite.rest.filter.DefaultWebFilter; 14 | import com.jeesuite.rest.filter.FilterConfig; 15 | import com.jeesuite.rest.resolver.ObjectMapperResolver; 16 | import com.jeesuite.rest.resolver.ValidationContextResolver; 17 | 18 | import io.swagger.jaxrs.listing.SwaggerSerializers; 19 | 20 | /** 21 | * @description
22 | * @author vakin 23 | * @date 2016年1月16日 24 | * @Copyright (c) 2015, vakinge@github 25 | */ 26 | public abstract class BaseApplicaionConfig extends ResourceConfig implements CustomConfig { 27 | 28 | public BaseApplicaionConfig() { 29 | //设置默认时区 30 | System.setProperty("user.timezone","Asia/Shanghai"); 31 | 32 | register(ValidationContextResolver.class); 33 | property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true); 34 | property(ServerProperties.BV_DISABLE_VALIDATE_ON_EXECUTABLE_OVERRIDE_CHECK, true); 35 | 36 | this.packages(packages()); 37 | 38 | register(ObjectMapperResolver.class); 39 | register(JacksonFeature.class); 40 | register(JacksonJsonProvider.class); 41 | register(new BaseExceptionMapper(createExcetionWrapper())); 42 | register(RequestContextFilter.class); 43 | 44 | register(DefaultWebFilter.class); 45 | // 46 | if(FilterConfig.apiDocEnabled()){ 47 | register(SwaggerSerializers.class); 48 | } 49 | } 50 | 51 | 52 | } 53 | -------------------------------------------------------------------------------- /jeesuite-rest/src/main/java/com/jeesuite/rest/filter/handler/ResponseWrapperHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.jeesuite.rest.filter.handler; 5 | 6 | import javax.servlet.http.HttpServletRequest; 7 | import javax.ws.rs.container.ContainerRequestContext; 8 | import javax.ws.rs.container.ContainerResponseContext; 9 | import javax.ws.rs.container.ResourceInfo; 10 | import javax.ws.rs.core.MediaType; 11 | 12 | import com.jeesuite.rest.filter.FilterHandler; 13 | import com.jeesuite.rest.response.ResponseCode; 14 | import com.jeesuite.rest.response.WrapperResponseEntity; 15 | 16 | /** 17 | * @description
18 | * @author vakin 19 | * @date 2017年1月2日 20 | */ 21 | public class ResponseWrapperHandler implements FilterHandler { 22 | 23 | 24 | @Override 25 | public void processRequest(ContainerRequestContext requestContext, HttpServletRequest request, 26 | ResourceInfo resourceInfo) {} 27 | 28 | @Override 29 | public void processResponse(ContainerRequestContext requestContext, ContainerResponseContext responseContext, 30 | ResourceInfo resourceInfo) { 31 | MediaType mediaType = responseContext.getMediaType(); 32 | if (mediaType != null && MediaType.APPLICATION_JSON_TYPE.equals(mediaType)) { 33 | Object responseData = responseContext.getEntity(); 34 | WrapperResponseEntity jsonResponse; 35 | 36 | if (responseData instanceof WrapperResponseEntity) { 37 | jsonResponse = (WrapperResponseEntity) responseData; 38 | } else { 39 | jsonResponse = new WrapperResponseEntity(ResponseCode.OK); 40 | jsonResponse.setData(responseData); 41 | } 42 | responseContext.setStatus(ResponseCode.OK.getCode()); 43 | 44 | responseContext.setEntity(jsonResponse); 45 | 46 | } 47 | } 48 | 49 | @Override 50 | public int getPriority() { 51 | return 9; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /jeesuite-mybatis/src/main/java/com/jeesuite/mybatis/plugin/shard/TableRouteHandler.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.mybatis.plugin.shard; 2 | 3 | import org.apache.ibatis.plugin.Invocation; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | import org.springframework.beans.factory.InitializingBean; 7 | 8 | import com.jeesuite.mybatis.core.InterceptorHandler; 9 | import com.jeesuite.mybatis.plugin.JeesuiteMybatisInterceptor; 10 | 11 | /** 12 | * 分库自动路由处理 13 | * 14 | * @description
15 | * @author vakin 16 | * @date 2015年12月7日 17 | * @Copyright (c) 2015, jwww 18 | */ 19 | public class TableRouteHandler implements InterceptorHandler,InitializingBean { 20 | 21 | 22 | protected static final Logger logger = LoggerFactory.getLogger(TableRouteHandler.class); 23 | 24 | 25 | @Override 26 | public void afterPropertiesSet() throws Exception { 27 | // TODO Auto-generated method stub 28 | 29 | } 30 | 31 | @Override 32 | public Object onInterceptor(Invocation invocation) throws Throwable { 33 | // TODO Auto-generated method stub 34 | return null; 35 | } 36 | 37 | @Override 38 | public void onFinished(Invocation invocation, Object result) { 39 | // TODO Auto-generated method stub 40 | 41 | } 42 | 43 | 44 | /* (non-Javadoc) 45 | * @see com.jeesuite.mybatis.core.InterceptorHandler#onStart() 46 | */ 47 | @Override 48 | public void start(JeesuiteMybatisInterceptor context) { 49 | // TODO Auto-generated method stub 50 | 51 | } 52 | 53 | /* (non-Javadoc) 54 | * @see com.jeesuite.mybatis.core.InterceptorHandler#onClose() 55 | */ 56 | @Override 57 | public void close() { 58 | // TODO Auto-generated method stub 59 | 60 | } 61 | 62 | @Override 63 | public int interceptorOrder() { 64 | // TODO Auto-generated method stub 65 | return 0; 66 | } 67 | } 68 | 69 | -------------------------------------------------------------------------------- /jeesuite-log/src/main/java/com/jeesuite/log/LogFactory.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.log; 2 | 3 | import java.lang.reflect.Constructor; 4 | 5 | public class LogFactory { 6 | 7 | private static Constructor logConstructor; 8 | 9 | static{ 10 | Class implClass = null; 11 | try { 12 | classForName("org.apache.log4j.Logger"); 13 | implClass = classForName("com.ayg.openapi.log.Log4jImpl"); 14 | } catch (Throwable t) {} 15 | 16 | if(implClass == null){ 17 | try { 18 | classForName("org.apache.logging.log4j.Logger"); 19 | implClass = classForName("com.ayg.openapi.log.Log4j2Impl"); 20 | } catch (Throwable t) {} 21 | } 22 | 23 | if(implClass == null){ 24 | try { 25 | classForName("org.slf4j.Logger"); 26 | implClass = classForName("com.ayg.openapi.log.SLF4JImpl"); 27 | } catch (Throwable t) {} 28 | } 29 | 30 | try { 31 | logConstructor = implClass.getConstructor(new Class[] { String.class }); 32 | } catch (Throwable e) {} 33 | } 34 | 35 | public static Log getLog(String loggerName) { 36 | try { 37 | return (Log) logConstructor.newInstance(loggerName); 38 | } catch (Throwable t) { 39 | throw new RuntimeException("Error creating logger for logger '" + loggerName + "'. Cause: " + t, t); 40 | } 41 | } 42 | 43 | private static Class classForName(String className) throws ClassNotFoundException { 44 | Class clazz = null; 45 | try { 46 | clazz = Thread.currentThread().getContextClassLoader().loadClass(className); 47 | } catch (Exception e) { 48 | // Ignore. Failsafe below. 49 | } 50 | if (clazz == null) { 51 | clazz = Class.forName(className); 52 | } 53 | return clazz; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /jeesuite-security/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | com.jeesuite 6 | jeesuite-libs 7 | 1.3.4-SNAPSHOT 8 | 9 | jeesuite-security 10 | 11 | 12 | 13 | com.jeesuite 14 | jeesuite-common 15 | ${project.parent.version} 16 | 17 | 18 | 19 | com.jeesuite 20 | jeesuite-spring 21 | ${project.parent.version} 22 | 23 | 24 | 25 | com.jeesuite 26 | jeesuite-cache 27 | ${project.parent.version} 28 | true 29 | 30 | 31 | 32 | com.jeesuite 33 | jeesuite-springweb 34 | ${project.parent.version} 35 | 36 | 37 | 38 | javax.servlet 39 | javax.servlet-api 40 | 3.1.0 41 | provided 42 | 43 | 44 | 45 | com.google.guava 46 | guava 47 | 19.0 48 | 49 | 50 | 51 | 52 | 53 | 54 | org.apache.maven.plugins 55 | maven-deploy-plugin 56 | 57 | false 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /jeesuite-mybatis/src/main/java/com/jeesuite/mybatis/crud/helper/ColumnMapper.java: -------------------------------------------------------------------------------- 1 | package com.jeesuite.mybatis.crud.helper; 2 | 3 | import org.apache.ibatis.type.JdbcType; 4 | import org.apache.ibatis.type.TypeHandler; 5 | 6 | public class ColumnMapper { 7 | 8 | private String property; 9 | private String column; 10 | private Class javaType; 11 | private JdbcType jdbcType; 12 | private Class> typeHandler; 13 | private boolean id = false; 14 | private boolean insertable = true; 15 | private boolean updatable = true; 16 | 17 | public String getProperty() { 18 | return property; 19 | } 20 | 21 | public void setProperty(String property) { 22 | this.property = property; 23 | } 24 | 25 | public String getColumn() { 26 | return column; 27 | } 28 | 29 | public void setColumn(String column) { 30 | this.column = column; 31 | } 32 | 33 | public Class getJavaType() { 34 | return javaType; 35 | } 36 | 37 | public void setJavaType(Class javaType) { 38 | this.javaType = javaType; 39 | } 40 | 41 | public boolean isId() { 42 | return id; 43 | } 44 | 45 | public void setId(boolean id) { 46 | this.id = id; 47 | } 48 | 49 | public boolean isInsertable() { 50 | return insertable; 51 | } 52 | 53 | public void setInsertable(boolean insertable) { 54 | this.insertable = insertable; 55 | } 56 | 57 | public boolean isUpdatable() { 58 | return updatable; 59 | } 60 | 61 | public void setUpdatable(boolean updatable) { 62 | this.updatable = updatable; 63 | } 64 | 65 | public JdbcType getJdbcType() { 66 | return jdbcType; 67 | } 68 | 69 | public void setJdbcType(JdbcType jdbcType) { 70 | this.jdbcType = jdbcType; 71 | } 72 | 73 | public Class> getTypeHandler() { 74 | return typeHandler; 75 | } 76 | 77 | public void setTypeHandler(Class> typeHandler) { 78 | this.typeHandler = typeHandler; 79 | } 80 | 81 | 82 | } 83 | -------------------------------------------------------------------------------- /jeesuite-kafka/src/test/resources/test-kafka-producer.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 25 | 26 | 27 | 28 | 29 | 30 | ${kafka.servers} 31 | 1 32 | 1 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | --------------------------------------------------------------------------------