├── src ├── main │ ├── resources │ │ └── META-INF │ │ │ └── services │ │ │ ├── org.redkale.util.YamlProvider │ │ │ ├── org.redkale.mq.spi.MessageAgentProvider │ │ │ ├── org.redkale.scheduled.spi.ScheduledManagerProvider │ │ │ ├── org.redkale.source.spi.DataNativeSqlParserProvider │ │ │ ├── org.redkale.cluster.spi.ClusterAgentProvider │ │ │ ├── org.redkale.source.spi.CacheSourceProvider │ │ │ ├── org.redkale.props.spi.PropertiesAgentProvider │ │ │ └── org.redkale.source.spi.DataSourceProvider │ └── java │ │ ├── org │ │ └── redkalex │ │ │ ├── source │ │ │ ├── pgsql │ │ │ │ ├── PgColumnEncodeable.java │ │ │ │ ├── PgColumnDecodeable.java │ │ │ │ ├── PgReqPing.java │ │ │ │ ├── PgRespDecoder.java │ │ │ │ ├── PgReqInsert.java │ │ │ │ ├── PgRowDesc.java │ │ │ │ ├── PgReqClose.java │ │ │ │ ├── PgReqQuery.java │ │ │ │ ├── PgRespReadyDecoder.java │ │ │ │ ├── PgsqlDataSourceProvider.java │ │ │ │ ├── PgRespParamDescDecoder.java │ │ │ │ ├── PgRespCountDecoder.java │ │ │ │ ├── PgRespAuthResultSet.java │ │ │ │ ├── PgReqAuthentication.java │ │ │ │ ├── PgRespRowDescDecoder.java │ │ │ │ ├── PgReqAuthScramSaslContinueResult.java │ │ │ │ ├── PgRowData.java │ │ │ │ ├── PgReqAuthMd5Password.java │ │ │ │ ├── PgReqBatch.java │ │ │ │ ├── PgRespRowDataDecoder.java │ │ │ │ └── PgsqlOid.java │ │ │ ├── mysql │ │ │ │ ├── MyRespAuthResultSet.java │ │ │ │ ├── MyReqPing.java │ │ │ │ ├── MyReqVirtual.java │ │ │ │ ├── MyPrepareDesc.java │ │ │ │ ├── MyRespOK.java │ │ │ │ ├── MyRespPrepare.java │ │ │ │ ├── MyRespHandshakeResultSet.java │ │ │ │ ├── MyRowDesc.java │ │ │ │ ├── MyReqClose.java │ │ │ │ ├── MysqlDataSourceProvider.java │ │ │ │ ├── MyReqQuery.java │ │ │ │ ├── MyReqBatch.java │ │ │ │ ├── MyRespPrepareDecoder.java │ │ │ │ ├── MyClientRequest.java │ │ │ │ ├── MyRespRowColumnDecoder.java │ │ │ │ ├── MyRowData.java │ │ │ │ ├── MyReqUpdate.java │ │ │ │ ├── MyRespDecoder.java │ │ │ │ └── MyClientConnection.java │ │ │ ├── search │ │ │ │ ├── FindResult.java │ │ │ │ ├── ShardResult.java │ │ │ │ ├── HitEntity.java │ │ │ │ ├── BaseBean.java │ │ │ │ ├── ActionResult.java │ │ │ │ ├── OpenSearchSourceProvider.java │ │ │ │ ├── BulkResult.java │ │ │ │ ├── HitResult.java │ │ │ │ ├── SearchMapping.java │ │ │ │ └── SearchResult.java │ │ │ ├── parser │ │ │ │ ├── NativeSqlFragment.java │ │ │ │ ├── DataNativeJsqlParserProvider.java │ │ │ │ ├── CustomDeleteDeParser.java │ │ │ │ ├── CustomUpdateDeParser.java │ │ │ │ ├── NativeSqlTemplet.java │ │ │ │ ├── CustomStatementDeParser.java │ │ │ │ ├── NativeCountDeParser.java │ │ │ │ └── DataNativeJsqlParser.java │ │ │ ├── mongo │ │ │ │ ├── MongodbDriverDataSourceProvider.java │ │ │ │ └── MongodbDataSource.java │ │ │ └── vertx │ │ │ │ └── VertxSqlDataSourceProvider.java │ │ │ ├── yaml │ │ │ ├── SnakeYamlProvider.java │ │ │ └── SnakeYamlLoader.java │ │ │ ├── cluster │ │ │ ├── nacos │ │ │ │ └── NacosClusterAgentProvider.java │ │ │ └── consul │ │ │ │ └── ConsulClusterAgentProvider.java │ │ │ ├── scheduled │ │ │ └── xxljob │ │ │ │ ├── KillParam.java │ │ │ │ ├── IdleBeatParam.java │ │ │ │ ├── XxljobScheduledProvider.java │ │ │ │ ├── LogParam.java │ │ │ │ ├── RegistryParam.java │ │ │ │ ├── LogResult.java │ │ │ │ ├── ReturnT.java │ │ │ │ ├── HandleCallbackParam.java │ │ │ │ └── XxljobConfig.java │ │ │ ├── pay │ │ │ ├── DIYPayService.java │ │ │ ├── PayRefundQryReq.java │ │ │ ├── PayRefundQueryResponse.java │ │ │ ├── PayRefundResponse.java │ │ │ ├── PayCreatResponse.java │ │ │ ├── PayPreResponse.java │ │ │ ├── PayRetCodes.java │ │ │ ├── PayQueryResponse.java │ │ │ └── PayResponse.java │ │ │ ├── properties │ │ │ ├── nacos │ │ │ │ ├── NacosPropertiesAgentProvider.java │ │ │ │ └── NacosClientPropertiesAgentProvider.java │ │ │ └── apollo │ │ │ │ ├── ApolloPropertiesAgentProvider.java │ │ │ │ └── ApolloClientPropertiesAgentProvider.java │ │ │ ├── cache │ │ │ └── redis │ │ │ │ ├── RedisCacheSourceProvider.java │ │ │ │ ├── RedisVertxCacheSourceProvider.java │ │ │ │ ├── RedisCryptor.java │ │ │ │ ├── RedissonCacheSourceProvider.java │ │ │ │ ├── RedisCacheReqPing.java │ │ │ │ ├── RedisCacheReqDB.java │ │ │ │ ├── RedisCacheReqClose.java │ │ │ │ ├── RedisCacheReqAuth.java │ │ │ │ ├── RedisCacheReqClientName.java │ │ │ │ └── RedisCacheConnection.java │ │ │ ├── htel │ │ │ ├── HttpTemplateRender.java │ │ │ └── FreemarkerTemplateRender.java │ │ │ ├── mq │ │ │ └── kafka │ │ │ │ └── KafkaMessageAgentProvider.java │ │ │ └── apns │ │ │ └── ApnsMessage.java │ │ ├── module-info.java.bak │ │ └── config-template.properties └── test │ └── java │ └── org │ └── redkalex │ ├── source │ ├── mapper │ │ ├── BaseMapper.java │ │ ├── BaseEntity.java │ │ ├── ForumResult.java │ │ ├── ForumBean.java │ │ ├── MapperTest.java │ │ ├── ForumInfoMapper.java │ │ └── DynForumInfoMapperImpl.java │ ├── parser2 │ │ ├── BaseMapper.java │ │ ├── BaseEntity.java │ │ ├── ForumResult.java │ │ ├── DataSqlMapperTest.java │ │ ├── ForumBean.java │ │ └── ForumInfoService.java │ ├── base │ │ ├── IncreWorld.java │ │ └── TestWorld.java │ ├── mysql │ │ ├── World.java │ │ └── MySourceTest.java │ ├── vertx │ │ └── TestRecord.java │ ├── pgsql │ │ ├── PgSourceTest.java │ │ └── PgSQLJdbcTest.java │ ├── mongo │ │ ├── TestRecord.java │ │ └── TestCodecProvider.java │ └── search │ │ ├── TestPostBean.java │ │ └── TestComment.java │ ├── convert │ └── pb │ │ ├── PSimpleBean.proto │ │ ├── AnyValueBean.proto │ │ ├── PTestBean.proto │ │ ├── UserTest.java │ │ ├── ArrayBean.java │ │ ├── User.java │ │ ├── PTestBeanSelf.java │ │ └── AnyValueBeanTest.java │ ├── cache │ └── redis │ │ ├── RedisMemorySourceTest.java │ │ ├── RedisVertxCacheSourceTest.java │ │ ├── RedissonCacheSourceTest.java │ │ └── PubSubRedisTest.java │ ├── apns │ └── ApnsServiceTest.java │ └── pay │ └── UnionPayServiceTest.java ├── my └── gitrun.sh ├── .gitignore ├── .github └── workflows │ ├── maven.yml │ └── maven-snapshot.yml └── README.md /src/main/resources/META-INF/services/org.redkale.util.YamlProvider: -------------------------------------------------------------------------------- 1 | org.redkalex.yaml.SnakeYamlProvider 2 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/services/org.redkale.mq.spi.MessageAgentProvider: -------------------------------------------------------------------------------- 1 | org.redkalex.mq.kafka.KafkaMessageAgentProvider 2 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/services/org.redkale.scheduled.spi.ScheduledManagerProvider: -------------------------------------------------------------------------------- 1 | org.redkalex.scheduled.xxljob.XxljobScheduledProvider 2 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/services/org.redkale.source.spi.DataNativeSqlParserProvider: -------------------------------------------------------------------------------- 1 | org.redkalex.source.parser.DataNativeJsqlParserProvider 2 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/services/org.redkale.cluster.spi.ClusterAgentProvider: -------------------------------------------------------------------------------- 1 | org.redkalex.cluster.nacos.NacosClusterAgentProvider 2 | org.redkalex.cluster.consul.ConsulClusterAgentProvider 3 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/services/org.redkale.source.spi.CacheSourceProvider: -------------------------------------------------------------------------------- 1 | org.redkalex.cache.redis.RedisVertxCacheSourceProvider 2 | org.redkalex.cache.redis.RedissonCacheSourceProvider 3 | org.redkalex.cache.redis.RedisCacheSourceProvider 4 | -------------------------------------------------------------------------------- /my/gitrun.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export LC_ALL="zh_CN.UTF-8" 4 | 5 | rm -fr redkale-plugins 6 | 7 | rm -fr src 8 | 9 | git clone https://github.com/redkale/redkale-plugins.git 10 | 11 | cp -fr redkale-plugins/src ./ 12 | 13 | mvn clean 14 | mvn deploy 15 | -------------------------------------------------------------------------------- /src/test/java/org/redkalex/source/mapper/BaseMapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | */ 4 | package org.redkalex.source.mapper; 5 | 6 | import org.redkale.source.DataSqlMapper; 7 | 8 | /** @author zhangjx */ 9 | public interface BaseMapper extends DataSqlMapper {} 10 | -------------------------------------------------------------------------------- /src/test/java/org/redkalex/source/parser2/BaseMapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | */ 4 | package org.redkalex.source.parser2; 5 | 6 | import org.redkale.source.DataSqlMapper; 7 | 8 | /** @author zhangjx */ 9 | public interface BaseMapper extends DataSqlMapper {} 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | 3 | # Mobile Tools for Java (J2ME) 4 | .mtj.tmp/ 5 | 6 | # Package Files # 7 | *.jar 8 | *.war 9 | *.ear 10 | 11 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 12 | hs_err_pid* 13 | /target/ 14 | /protoc.exe 15 | /nb-configuration.xml 16 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/services/org.redkale.props.spi.PropertiesAgentProvider: -------------------------------------------------------------------------------- 1 | org.redkalex.properties.apollo.ApolloClientPropertiesAgentProvider 2 | org.redkalex.properties.apollo.ApolloPropertiesAgentProvider 3 | org.redkalex.properties.nacos.NacosClientPropertiesAgentProvider 4 | org.redkalex.properties.nacos.NacosPropertiesAgentProvider 5 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/services/org.redkale.source.spi.DataSourceProvider: -------------------------------------------------------------------------------- 1 | org.redkalex.source.vertx.VertxSqlDataSourceProvider 2 | org.redkalex.source.mysql.MysqlDataSourceProvider 3 | org.redkalex.source.pgsql.PgsqlDataSourceProvider 4 | org.redkalex.source.mongo.MongodbDriverDataSourceProvider 5 | org.redkalex.source.search.OpenSearchSourceProvider 6 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/pgsql/PgColumnEncodeable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | */ 4 | package org.redkalex.source.pgsql; 5 | 6 | import java.io.Serializable; 7 | import org.redkale.annotation.Nullable; 8 | import org.redkale.util.*; 9 | 10 | /** @author zhangjx */ 11 | public interface PgColumnEncodeable { 12 | 13 | // attr可能会为null 14 | public void encode(ByteArray array, @Nullable Attribute attr, Serializable value); 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/pgsql/PgColumnDecodeable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | */ 4 | package org.redkalex.source.pgsql; 5 | 6 | import java.io.Serializable; 7 | import java.nio.ByteBuffer; 8 | import org.redkale.annotation.Nullable; 9 | import org.redkale.util.*; 10 | 11 | /** @author zhangjx */ 12 | public interface PgColumnDecodeable { 13 | 14 | // attr可能会为null 15 | Serializable decode(ByteBuffer buffer, ByteArray array, @Nullable Attribute attr, int len); 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/mysql/MyRespAuthResultSet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.mysql; 7 | 8 | /** @author zhangjx */ 9 | public class MyRespAuthResultSet extends MyResultSet { 10 | 11 | protected boolean authOK; 12 | 13 | protected MyReqAuthentication.MyReqAuthSwitch authSwitch; 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/search/FindResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.search; 7 | 8 | /** 9 | * @author zhangjx 10 | * @param T 11 | */ 12 | public class FindResult extends BaseBean { 13 | 14 | public boolean found; 15 | 16 | public int _version; 17 | 18 | public T _source; 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/search/ShardResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.search; 7 | 8 | /** @author zhangjx */ 9 | public class ShardResult extends BaseBean { 10 | 11 | public int totoal; 12 | 13 | public int successful; 14 | 15 | public int failed; 16 | 17 | public int skipped; 18 | } 19 | -------------------------------------------------------------------------------- /src/test/java/org/redkalex/convert/pb/PSimpleBean.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | // 生成类的包名 4 | option java_package = "org.redkalex.convert.pb"; 5 | 6 | message PSimpleBean { 7 | 8 | message PSimpleEntry { 9 | sint32 id = 1; 10 | string name = 2; 11 | string email = 3; 12 | } 13 | 14 | message PTwoEntry { 15 | sint32 status = 1; 16 | sint64 createtime = 2; 17 | } 18 | PSimpleEntry simple = 1; 19 | PTwoEntry two = 2; 20 | string strings = 3 ; 21 | } 22 | -------------------------------------------------------------------------------- /src/test/java/org/redkalex/convert/pb/AnyValueBean.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | // 生成类的包名 4 | option java_package = "org.redkalex.convert.pb"; 5 | 6 | message AnyValueBean { 7 | 8 | message StringEntry { 9 | string name = 1; 10 | string value = 2; 11 | } 12 | 13 | message AnyValueEntry { 14 | string name = 1; 15 | AnyValueBean value = 2; 16 | } 17 | 18 | bool ignoreCase = 1; 19 | 20 | repeated StringEntry stringEntrys = 2; 21 | 22 | repeated AnyValueEntry anyEntrys = 3; 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/yaml/SnakeYamlProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | */ 4 | 5 | package org.redkalex.yaml; 6 | 7 | import org.redkale.util.YamlProvider; 8 | 9 | /** 10 | * 11 | * @author zhangjx 12 | */ 13 | public class SnakeYamlProvider implements YamlProvider { 14 | 15 | @Override 16 | public YamlLoader createLoader() { 17 | try { 18 | // 尝试加载snakeyaml 19 | org.yaml.snakeyaml.Yaml.class.isAssignableFrom(Object.class); 20 | return new SnakeYamlLoader(); 21 | } catch (Throwable t) { 22 | return null; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/search/HitEntity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.search; 7 | 8 | import java.util.Map; 9 | 10 | /** 11 | * @author zhangjx 12 | * @param T 13 | */ 14 | public class HitEntity extends BaseBean { 15 | 16 | public String _index; 17 | 18 | public String _id; 19 | 20 | public float _score; 21 | 22 | public T _source; 23 | 24 | public Map highlight; 25 | } 26 | -------------------------------------------------------------------------------- /src/test/java/org/redkalex/source/mapper/BaseEntity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.mapper; 7 | 8 | import java.io.*; 9 | import org.redkale.convert.json.*; 10 | import org.redkale.persistence.*; 11 | 12 | /** @author zhangjx */ 13 | @Entity 14 | public abstract class BaseEntity implements Serializable { 15 | 16 | @Override 17 | public String toString() { 18 | return JsonConvert.root().convertTo(this); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/test/java/org/redkalex/source/parser2/BaseEntity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.parser2; 7 | 8 | import java.io.*; 9 | import org.redkale.convert.json.*; 10 | import org.redkale.persistence.*; 11 | 12 | /** @author zhangjx */ 13 | @Entity 14 | public abstract class BaseEntity implements Serializable { 15 | 16 | @Override 17 | public String toString() { 18 | return JsonConvert.root().convertTo(this); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/search/BaseBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.search; 7 | 8 | import java.io.Serializable; 9 | import org.redkale.convert.json.JsonConvert; 10 | import org.redkale.annotation.Serial; 11 | 12 | /** @author zhangjx */ 13 | @Serial 14 | abstract class BaseBean implements Serializable { 15 | 16 | @Override 17 | public String toString() { 18 | return JsonConvert.root().convertTo(this); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/test/java/org/redkalex/cache/redis/RedisMemorySourceTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | */ 4 | package org.redkalex.cache.redis; 5 | 6 | import static org.redkalex.cache.redis.RedisAbstractTest.run; 7 | 8 | import org.redkale.source.CacheMemorySource; 9 | 10 | /** @author zhangjx */ 11 | public class RedisMemorySourceTest extends RedisAbstractTest { 12 | 13 | public static void main(String[] args) throws Exception { 14 | 15 | CacheMemorySource source = new CacheMemorySource(""); 16 | source.init(null); 17 | try { 18 | run(source, true); 19 | } finally { 20 | source.close(); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/mysql/MyReqPing.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.mysql; 7 | 8 | import java.util.Objects; 9 | 10 | /** @author zhangjx */ 11 | public class MyReqPing extends MyReqQuery { 12 | 13 | @SuppressWarnings("OverridableMethodCallInConstructor") 14 | public MyReqPing() { 15 | prepare("SELECT 1"); 16 | } 17 | 18 | @Override 19 | public String toString() { 20 | return "MyReqPing_" + Objects.hashCode(this) + "{sql=" + sql + "}"; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/pgsql/PgReqPing.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.pgsql; 7 | 8 | import java.util.Objects; 9 | 10 | /** @author zhangjx */ 11 | public class PgReqPing extends PgReqQuery { 12 | 13 | @SuppressWarnings("OverridableMethodCallInConstructor") 14 | public PgReqPing() { 15 | prepare("SELECT 1"); 16 | } 17 | 18 | @Override 19 | public String toString() { 20 | return "PgReqPing_" + Objects.hashCode(this) + "{sql=" + sql + "}"; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/cluster/nacos/NacosClusterAgentProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | */ 3 | package org.redkalex.cluster.nacos; 4 | 5 | import org.redkale.annotation.Priority; 6 | import org.redkale.cluster.spi.ClusterAgent; 7 | import org.redkale.cluster.spi.ClusterAgentProvider; 8 | import org.redkale.util.*; 9 | 10 | /** @author zhangjx */ 11 | @Priority(-800) 12 | public class NacosClusterAgentProvider implements ClusterAgentProvider { 13 | 14 | @Override 15 | public boolean acceptsConf(AnyValue config) { 16 | return new NacosClusterAgent().acceptsConf(config); 17 | } 18 | 19 | @Override 20 | public ClusterAgent createInstance() { 21 | return new NacosClusterAgent(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/search/ActionResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.search; 7 | 8 | /** @author zhangjx */ 9 | public class ActionResult extends BaseBean { 10 | 11 | public String _index; 12 | 13 | public String _id; 14 | 15 | public int _version; 16 | 17 | public String result; 18 | 19 | public ShardResult _shards; 20 | 21 | public int status; 22 | 23 | public int _primary_term; 24 | 25 | public int successCount() { 26 | return _shards == null ? 0 : _shards.successful; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/mysql/MyReqVirtual.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | */ 4 | package org.redkalex.source.mysql; 5 | 6 | import java.util.Objects; 7 | import org.redkale.net.client.ClientConnection; 8 | import org.redkale.util.ByteArray; 9 | 10 | /** @author zhangjx */ 11 | public class MyReqVirtual extends MyClientRequest { 12 | 13 | @Override 14 | public void writeTo(ClientConnection conn, ByteArray array) {} 15 | 16 | @Override 17 | public int getType() { 18 | return 0; 19 | } 20 | 21 | @Override 22 | public boolean isVirtualType() { 23 | return true; 24 | } 25 | 26 | @Override 27 | public String toString() { 28 | return getClass().getSimpleName() + "_" + Objects.hash(this) + "{virtual}"; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/pgsql/PgRespDecoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.pgsql; 7 | 8 | import java.nio.ByteBuffer; 9 | import org.redkale.util.*; 10 | 11 | /** 12 | * @author zhangjx 13 | * @param 泛型 14 | */ 15 | public abstract class PgRespDecoder { 16 | 17 | public abstract byte messageid(); 18 | 19 | public abstract T read( 20 | PgClientConnection conn, 21 | ByteBuffer buffer, 22 | int length, 23 | ByteArray array, 24 | PgClientRequest request, 25 | PgResultSet dataset); 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/scheduled/xxljob/KillParam.java: -------------------------------------------------------------------------------- 1 | package org.redkalex.scheduled.xxljob; 2 | 3 | import java.io.Serializable; 4 | import org.redkale.convert.json.JsonConvert; 5 | 6 | /** @author xuxueli 2020-04-11 22:27 */ 7 | public class KillParam implements Serializable { 8 | 9 | private static final long serialVersionUID = 42L; 10 | 11 | private int jobId; 12 | 13 | public KillParam() {} 14 | 15 | public KillParam(int jobId) { 16 | this.jobId = jobId; 17 | } 18 | 19 | public int getJobId() { 20 | return jobId; 21 | } 22 | 23 | public void setJobId(int jobId) { 24 | this.jobId = jobId; 25 | } 26 | 27 | @Override 28 | public String toString() { 29 | return JsonConvert.root().convertTo(this); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/parser/NativeSqlFragment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | */ 4 | package org.redkalex.source.parser; 5 | 6 | /** @author zhangjx */ 7 | public class NativeSqlFragment { 8 | 9 | // 是否是${xx.xx}参数 10 | private final boolean dollarable; 11 | 12 | // sql语句片段或者${}参数名或者:jdbcNamedParameter 13 | private final String text; 14 | 15 | public NativeSqlFragment(boolean signable, String text) { 16 | this.dollarable = signable; 17 | this.text = text; 18 | } 19 | 20 | public boolean isDollarable() { 21 | return dollarable; 22 | } 23 | 24 | public String getText() { 25 | return text; 26 | } 27 | 28 | @Override 29 | public String toString() { 30 | return dollarable ? ("${" + text + "}") : text; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/pgsql/PgReqInsert.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.pgsql; 7 | 8 | import java.util.Objects; 9 | import org.redkale.convert.json.JsonConvert; 10 | 11 | /** @author zhangjx */ 12 | public class PgReqInsert extends PgReqUpdate { 13 | 14 | @Override 15 | public int getType() { 16 | return REQ_TYPE_INSERT; 17 | } 18 | 19 | @Override 20 | public String toString() { 21 | return "PgReqInsert" + Objects.hashCode(this) + "{sql=" + sql + ", paramValues=" 22 | + JsonConvert.root().convertTo(paramValues) + "}"; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/pay/DIYPayService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.pay; 7 | 8 | import static java.lang.annotation.ElementType.TYPE; 9 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 10 | 11 | import java.lang.annotation.*; 12 | 13 | /** 14 | * 本注解只能标注在AbstractPayService的子类上。 15 | * 16 | *

详情见: https://redkale.org 17 | * 18 | * @author zhangjx 19 | */ 20 | @Inherited 21 | @Documented 22 | @Target({TYPE}) 23 | @Retention(RUNTIME) 24 | public @interface DIYPayService { 25 | 26 | /** 27 | * 支付类型, 必须大于50 28 | * 29 | * @return short 30 | */ 31 | short payType(); 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/scheduled/xxljob/IdleBeatParam.java: -------------------------------------------------------------------------------- 1 | package org.redkalex.scheduled.xxljob; 2 | 3 | import java.io.Serializable; 4 | import org.redkale.convert.json.JsonConvert; 5 | 6 | /** @author xuxueli 2020-04-11 22:27 */ 7 | public class IdleBeatParam implements Serializable { 8 | 9 | private static final long serialVersionUID = 42L; 10 | 11 | private int jobId; 12 | 13 | public IdleBeatParam() {} 14 | 15 | public IdleBeatParam(int jobId) { 16 | this.jobId = jobId; 17 | } 18 | 19 | public int getJobId() { 20 | return jobId; 21 | } 22 | 23 | public void setJobId(int jobId) { 24 | this.jobId = jobId; 25 | } 26 | 27 | @Override 28 | public String toString() { 29 | return JsonConvert.root().convertTo(this); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/cluster/consul/ConsulClusterAgentProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.cluster.consul; 7 | 8 | import org.redkale.annotation.Priority; 9 | import org.redkale.cluster.spi.*; 10 | import org.redkale.util.*; 11 | 12 | /** @author zhangjx */ 13 | @Priority(-800) 14 | public class ConsulClusterAgentProvider implements ClusterAgentProvider { 15 | 16 | @Override 17 | public boolean acceptsConf(AnyValue config) { 18 | return new ConsulClusterAgent().acceptsConf(config); 19 | } 20 | 21 | @Override 22 | public ClusterAgent createInstance() { 23 | return new ConsulClusterAgent(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/properties/nacos/NacosPropertiesAgentProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | */ 3 | package org.redkalex.properties.nacos; 4 | 5 | import org.redkale.annotation.Priority; 6 | import org.redkale.props.spi.PropertiesAgent; 7 | import org.redkale.props.spi.PropertiesAgentProvider; 8 | import org.redkale.util.AnyValue; 9 | 10 | /** @author zhangjx */ 11 | @Priority(-900) 12 | public class NacosPropertiesAgentProvider implements PropertiesAgentProvider { 13 | 14 | @Override 15 | public boolean acceptsConf(AnyValue config) { 16 | try { 17 | return new NacosPropertiesAgent().acceptsConf(config); 18 | } catch (Throwable t) { 19 | return false; 20 | } 21 | } 22 | 23 | @Override 24 | public PropertiesAgent createInstance() { 25 | return new NacosPropertiesAgent(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/properties/apollo/ApolloPropertiesAgentProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | */ 3 | package org.redkalex.properties.apollo; 4 | 5 | import org.redkale.annotation.Priority; 6 | import org.redkale.props.spi.PropertiesAgent; 7 | import org.redkale.props.spi.PropertiesAgentProvider; 8 | import org.redkale.util.AnyValue; 9 | 10 | /** @author zhangjx */ 11 | @Priority(-900) 12 | public class ApolloPropertiesAgentProvider implements PropertiesAgentProvider { 13 | 14 | @Override 15 | public boolean acceptsConf(AnyValue config) { 16 | try { 17 | return new ApolloPropertiesAgent().acceptsConf(config); 18 | } catch (Throwable t) { 19 | return false; 20 | } 21 | } 22 | 23 | @Override 24 | public PropertiesAgent createInstance() { 25 | return new ApolloPropertiesAgent(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/mysql/MyPrepareDesc.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.mysql; 7 | 8 | /** @author zhangjx */ 9 | public class MyPrepareDesc { 10 | 11 | public final int numberOfParameters; // 先param后column 12 | 13 | public final int numberOfColumns; 14 | 15 | public final MyRowDesc paramDescs; 16 | 17 | public final MyRowDesc columnDescs; 18 | 19 | public MyPrepareDesc(MyRespPrepare prepare) { 20 | this.numberOfParameters = prepare.numberOfParameters; 21 | this.numberOfColumns = prepare.numberOfColumns; 22 | this.paramDescs = prepare.paramDescs; 23 | this.columnDescs = prepare.columnDescs; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/cache/redis/RedisCacheSourceProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.cache.redis; 7 | 8 | import org.redkale.annotation.Priority; 9 | import org.redkale.source.*; 10 | import org.redkale.source.spi.CacheSourceProvider; 11 | import org.redkale.util.AnyValue; 12 | 13 | /** @author zhangjx */ 14 | @Priority(-900) 15 | public class RedisCacheSourceProvider implements CacheSourceProvider { 16 | 17 | @Override 18 | public boolean acceptsConf(AnyValue config) { 19 | return new RedisCacheSource().acceptsConf(config); 20 | } 21 | 22 | @Override 23 | public CacheSource createInstance() { 24 | return new RedisCacheSource(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/test/java/org/redkalex/source/base/IncreWorld.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | */ 4 | package org.redkalex.source.base; 5 | 6 | import org.redkale.convert.json.JsonConvert; 7 | import org.redkale.persistence.*; 8 | 9 | /** @author zhangjx */ 10 | @Entity 11 | public class IncreWorld { 12 | 13 | @Id 14 | @GeneratedValue 15 | protected int id; 16 | 17 | protected Integer randomNumber; 18 | 19 | public int getId() { 20 | return id; 21 | } 22 | 23 | public void setId(int id) { 24 | this.id = id; 25 | } 26 | 27 | public Integer getRandomNumber() { 28 | return randomNumber; 29 | } 30 | 31 | public void setRandomNumber(Integer randomNumber) { 32 | this.randomNumber = randomNumber; 33 | } 34 | 35 | @Override 36 | public String toString() { 37 | return JsonConvert.root().convertTo(this); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/pay/PayRefundQryReq.java: -------------------------------------------------------------------------------- 1 | /* 2 | */ 3 | package org.redkalex.pay; 4 | 5 | import org.redkale.util.RedkaleException; 6 | 7 | /** 8 | * 详情见: https://redkale.org 9 | * 10 | * @author zhangjx 11 | */ 12 | public class PayRefundQryReq extends PayRequest { 13 | 14 | // 微信支付: 商户系统内部唯一,同一退款单号多次请求只退一笔 15 | // 支付宝: 标识一次退款请求,同一笔交易多次退款需要保证唯一,如需部分退款,则此参数必传 16 | protected String refundno = ""; // 退款编号 商户系统内部的退款单号。 17 | 18 | @Override 19 | public void checkVaild() { 20 | super.checkVaild(); 21 | if (this.refundno == null || this.refundno.isEmpty()) { 22 | throw new RedkaleException("refundno is illegal"); 23 | } 24 | } 25 | 26 | public String getRefundno() { 27 | return refundno; 28 | } 29 | 30 | public void setRefundno(String refundno) { 31 | this.refundno = refundno; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/test/java/org/redkalex/source/mapper/ForumResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | */ 4 | package org.redkalex.source.mapper; 5 | 6 | import org.redkale.convert.json.JsonConvert; 7 | 8 | /** @author zhangjx */ 9 | public class ForumResult { 10 | 11 | private String forumGroupid; 12 | 13 | private String forumSectionColor; 14 | 15 | public String getForumGroupid() { 16 | return forumGroupid; 17 | } 18 | 19 | public void setForumGroupid(String forumGroupid) { 20 | this.forumGroupid = forumGroupid; 21 | } 22 | 23 | public String getForumSectionColor() { 24 | return forumSectionColor; 25 | } 26 | 27 | public void setForumSectionColor(String forumSectionColor) { 28 | this.forumSectionColor = forumSectionColor; 29 | } 30 | 31 | @Override 32 | public String toString() { 33 | return JsonConvert.root().convertTo(this); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/org/redkalex/source/parser2/ForumResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | */ 4 | package org.redkalex.source.parser2; 5 | 6 | import org.redkale.convert.json.JsonConvert; 7 | 8 | /** @author zhangjx */ 9 | public class ForumResult { 10 | 11 | private String forumGroupid; 12 | 13 | private String forumSectionColor; 14 | 15 | public String getForumGroupid() { 16 | return forumGroupid; 17 | } 18 | 19 | public void setForumGroupid(String forumGroupid) { 20 | this.forumGroupid = forumGroupid; 21 | } 22 | 23 | public String getForumSectionColor() { 24 | return forumSectionColor; 25 | } 26 | 27 | public void setForumSectionColor(String forumSectionColor) { 28 | this.forumSectionColor = forumSectionColor; 29 | } 30 | 31 | @Override 32 | public String toString() { 33 | return JsonConvert.root().convertTo(this); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/cache/redis/RedisVertxCacheSourceProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | */ 3 | package org.redkalex.cache.redis; 4 | 5 | import org.redkale.annotation.Priority; 6 | import org.redkale.source.*; 7 | import org.redkale.source.spi.CacheSourceProvider; 8 | import org.redkale.util.AnyValue; 9 | 10 | /** @author zhangjx */ 11 | @Priority(-300) 12 | public class RedisVertxCacheSourceProvider implements CacheSourceProvider { 13 | 14 | @Override 15 | public boolean acceptsConf(AnyValue config) { 16 | try { 17 | Object.class.isAssignableFrom(io.vertx.redis.client.RedisOptions.class); // 试图加载vertx-redis相关类 18 | return new RedisVertxCacheSource().acceptsConf(config); 19 | } catch (Throwable e) { 20 | return false; 21 | } 22 | } 23 | 24 | @Override 25 | public CacheSource createInstance() { 26 | return new RedisVertxCacheSource(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/mysql/MyRespOK.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.mysql; 7 | 8 | import org.redkale.convert.json.JsonConvert; 9 | 10 | /** @author zhangjx */ 11 | public class MyRespOK { 12 | 13 | public static final byte[] OK = new byte[] {7, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0}; 14 | 15 | public static final byte[] AC_OFF = new byte[] {7, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0}; 16 | 17 | public long affectedRows = -1; 18 | 19 | public long lastInsertId = -1; 20 | 21 | public int serverStatusFlags; 22 | 23 | public int warningCount; 24 | 25 | public String info; 26 | 27 | @Override 28 | public String toString() { 29 | return JsonConvert.root().convertTo(this); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/mysql/MyRespPrepare.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.mysql; 7 | 8 | import org.redkale.convert.json.JsonConvert; 9 | 10 | /** @author zhangjx */ 11 | public class MyRespPrepare { 12 | 13 | public Long statementId; 14 | 15 | public int numberOfParameters; // 先param后column 16 | 17 | public int numberOfColumns; 18 | 19 | public int numberOfWarnings; 20 | 21 | MyRowDesc paramDescs; // STATUS_PREPARE_PARAM时赋值 22 | 23 | int paramDecodeIndex = -1; 24 | 25 | MyRowDesc columnDescs; // STATUS_PREPARE_PARAM时赋值 26 | 27 | int columnDecodeIndex = -1; 28 | 29 | @Override 30 | public String toString() { 31 | return JsonConvert.root().convertTo(this); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/mysql/MyRespHandshakeResultSet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.mysql; 7 | 8 | import org.redkale.convert.json.JsonConvert; 9 | 10 | /** @author zhangjx */ 11 | public class MyRespHandshakeResultSet extends MyResultSet { 12 | 13 | public int protocolVersion; 14 | 15 | public String serverVersion; 16 | 17 | public String authPluginName; 18 | 19 | public long threadId; 20 | 21 | public byte[] seed; 22 | 23 | public int serverCapabilities; 24 | 25 | public int serverCharsetIndex; 26 | 27 | public int serverStatus; 28 | 29 | public byte[] seed2; 30 | 31 | @Override 32 | public String toString() { 33 | return JsonConvert.root().convertTo(this); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/org/redkalex/convert/pb/PTestBean.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | // 生成类的包名 4 | option java_package = "org.redkalex.convert.pb"; 5 | 6 | message PTestBean { 7 | 8 | message PTestEntry { 9 | repeated bool bools = 1; 10 | repeated bytes bytes = 2; 11 | repeated sint32 chars = 3; 12 | repeated sint32 shorts = 4; 13 | } 14 | 15 | repeated bool bools = 1; 16 | repeated bytes bytes = 2; 17 | repeated sint32 chars = 3; 18 | repeated PTestEntry entrys = 4; 19 | repeated sint32 ints = 5; 20 | repeated float floats = 6; 21 | repeated sint64 longs = 7; 22 | repeated double doubles = 8; 23 | repeated string strings = 9; 24 | sint32 id = 10; 25 | string name = 11; 26 | string email = 12; 27 | Kind kind = 13; 28 | map map = 14; 29 | string end = 15; 30 | 31 | enum Kind { 32 | ONE =0; 33 | TWO =1; 34 | THREE =2; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/scheduled/xxljob/XxljobScheduledProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | */ 4 | package org.redkalex.scheduled.xxljob; 5 | 6 | import org.redkale.util.AnyValue; 7 | import org.redkale.scheduled.ScheduledManager; 8 | import org.redkale.scheduled.spi.ScheduledManagerProvider; 9 | 10 | /** @author zhangjx */ 11 | public class XxljobScheduledProvider implements ScheduledManagerProvider { 12 | 13 | /** 14 | * <xxljob addresses="http://localhost:8080/xxl-job-admin" executorName="xxx" ip="127.0.0.1" port="5678" 15 | * accessToken="default_token" /> 16 | * 17 | * @param config 参数 18 | * @return 是否适配xxljob 19 | */ 20 | @Override 21 | public boolean acceptsConf(AnyValue config) { 22 | return config != null && config.getAnyValue("xxljob") != null; 23 | } 24 | 25 | @Override 26 | public ScheduledManager createInstance() { 27 | return new XxljobScheduledManager(null); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/parser/DataNativeJsqlParserProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | */ 4 | package org.redkalex.source.parser; 5 | 6 | import net.sf.jsqlparser.parser.*; 7 | import org.redkale.annotation.Priority; 8 | import org.redkale.source.*; 9 | import org.redkale.source.spi.DataNativeSqlParserProvider; 10 | import org.redkale.util.AnyValue; 11 | 12 | /** @author zhangjx */ 13 | @Priority(-800) 14 | public class DataNativeJsqlParserProvider implements DataNativeSqlParserProvider { 15 | 16 | @Override 17 | public boolean acceptsConf(AnyValue config) { 18 | try { 19 | // 加载jsqlparser类 20 | AbstractJSqlParser.class.isAssignableFrom(CCJSqlParser.class); 21 | return true; 22 | } catch (Throwable t) { 23 | return false; 24 | } 25 | } 26 | 27 | @Override 28 | public DataNativeSqlParser createInstance() { 29 | return new DataNativeJsqlParser(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/properties/nacos/NacosClientPropertiesAgentProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | */ 3 | package org.redkalex.properties.nacos; 4 | 5 | import org.redkale.annotation.Priority; 6 | import org.redkale.props.spi.PropertiesAgent; 7 | import org.redkale.props.spi.PropertiesAgentProvider; 8 | import org.redkale.util.*; 9 | 10 | /** @author zhangjx */ 11 | @Priority(-800) 12 | public class NacosClientPropertiesAgentProvider implements PropertiesAgentProvider { 13 | 14 | @Override 15 | public boolean acceptsConf(AnyValue config) { 16 | try { 17 | Object.class.isAssignableFrom(com.alibaba.nacos.api.config.ConfigService.class); // 试图加载相关类 18 | return new NacosClientPropertiesAgent().acceptsConf(config); 19 | } catch (Throwable t) { 20 | return false; 21 | } 22 | } 23 | 24 | @Override 25 | public PropertiesAgent createInstance() { 26 | return new NacosClientPropertiesAgent(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/test/java/org/redkalex/apns/ApnsServiceTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.apns; 7 | 8 | /** @author zhangjx */ 9 | public class ApnsServiceTest { 10 | 11 | public static void main(String[] args) throws Exception { 12 | ApnsService service = new ApnsService(); 13 | service.apnspushaddr = "gateway.push.apple.com"; // 正式环境 14 | service.apnscertpwd = "1"; 15 | service.apnscertpath = "D:/apns.xxx.release.p12"; 16 | service.init(null); 17 | 18 | final String token = "3ce04256758126f0e8240bed658120b51f78824c2c63b6fb717aa26bc50b28f3"; 19 | ApnsPayload payload = new ApnsPayload("您有新的消息", "这是消息内容", 0); 20 | System.out.println(payload); 21 | service.pushApnsMessage(new ApnsMessage(token, payload)); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/test/java/org/redkalex/cache/redis/RedisVertxCacheSourceTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | */ 3 | package org.redkalex.cache.redis; 4 | 5 | import static org.redkale.source.AbstractCacheSource.*; 6 | 7 | import org.redkale.inject.ResourceFactory; 8 | import org.redkale.util.*; 9 | 10 | /** @author zhangjx */ 11 | public class RedisVertxCacheSourceTest extends RedisAbstractTest { 12 | 13 | public static void main(String[] args) throws Exception { 14 | AnyValueWriter conf = new AnyValueWriter() 15 | .addValue(CACHE_SOURCE_MAXCONNS, "1") 16 | .addValue(CACHE_SOURCE_NODES, "redis://127.0.0.1:6363"); 17 | final ResourceFactory factory = ResourceFactory.create(); 18 | 19 | RedisVertxCacheSource source = new RedisVertxCacheSource(); 20 | factory.inject(source); 21 | source.init(conf); 22 | try { 23 | run(source, true); 24 | } finally { 25 | source.close(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/test/java/org/redkalex/convert/pb/UserTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016-2116 Redkale 3 | * All rights reserved. 4 | */ 5 | package org.redkalex.convert.pb; 6 | 7 | import org.junit.jupiter.api.Assertions; 8 | import org.junit.jupiter.api.Test; 9 | import org.redkale.convert.pb.ProtobufConvert; 10 | 11 | /** 12 | * 13 | * @author zhangjx 14 | */ 15 | public class UserTest { 16 | 17 | public static void main(String[] args) throws Throwable { 18 | UserTest test = new UserTest(); 19 | test.run(); 20 | } 21 | 22 | @Test 23 | public void run() throws Exception { 24 | User user = User.create(); 25 | ProtobufConvert convert = ProtobufConvert.root(); 26 | byte[] bytes = convert.convertTo(user); 27 | User user2 = convert.convertFrom(User.class, bytes); 28 | System.out.println(user); 29 | System.out.println(user2); 30 | Assertions.assertEquals(user.toString(), user2.toString()); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/properties/apollo/ApolloClientPropertiesAgentProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | */ 3 | package org.redkalex.properties.apollo; 4 | 5 | import org.redkale.annotation.Priority; 6 | import org.redkale.props.spi.PropertiesAgent; 7 | import org.redkale.props.spi.PropertiesAgentProvider; 8 | import org.redkale.util.*; 9 | 10 | /** @author zhangjx */ 11 | @Priority(-800) 12 | public class ApolloClientPropertiesAgentProvider implements PropertiesAgentProvider { 13 | 14 | @Override 15 | public boolean acceptsConf(AnyValue config) { 16 | try { 17 | Object.class.isAssignableFrom(com.ctrip.framework.apollo.core.ConfigConsts.class); // 试图加载相关类 18 | return new ApolloClientPropertiesAgent().acceptsConf(config); 19 | } catch (Throwable t) { 20 | return false; 21 | } 22 | } 23 | 24 | @Override 25 | public PropertiesAgent createInstance() { 26 | return new ApolloClientPropertiesAgent(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/mysql/MyRowDesc.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.mysql; 7 | 8 | import java.util.Arrays; 9 | 10 | /** @author zhangjx */ 11 | public class MyRowDesc { 12 | 13 | final MyRowColumn[] columns; 14 | 15 | public MyRowDesc(MyRowColumn[] columns) { 16 | this.columns = columns; 17 | } 18 | 19 | public MyRowColumn[] getColumns() { 20 | return columns; 21 | } 22 | 23 | public MyRowColumn getColumn(int i) { 24 | return columns[i]; 25 | } 26 | 27 | public int length() { 28 | if (columns == null) { 29 | return -1; 30 | } 31 | return columns.length; 32 | } 33 | 34 | @Override 35 | public String toString() { 36 | return Arrays.toString(columns); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/test/java/org/redkalex/source/parser2/DataSqlMapperTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | */ 4 | package org.redkalex.source.parser2; 5 | 6 | import static org.redkale.source.spi.DataSqlMapperBuilder.createMapper; 7 | 8 | import org.junit.jupiter.api.Test; 9 | import org.redkale.source.DataJdbcSource; 10 | import org.redkale.source.DataNativeSqlParser; 11 | import org.redkale.source.DataSqlSource; 12 | 13 | /** @author zhangjx */ 14 | public class DataSqlMapperTest { 15 | 16 | private static DataNativeSqlParser parser = DataNativeSqlParser.loadFirst(); 17 | 18 | private static DataSqlSource source = new DataJdbcSource(); 19 | 20 | public static void main(String[] args) throws Throwable { 21 | DataSqlMapperTest test = new DataSqlMapperTest(); 22 | test.run(); 23 | } 24 | 25 | @Test 26 | public void run() throws Exception { 27 | ForumInfoMapper mapper = createMapper(parser, source, ForumInfoMapper.class); 28 | System.out.println(mapper); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/test/java/org/redkalex/cache/redis/RedissonCacheSourceTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.cache.redis; 7 | 8 | import static org.redkale.source.AbstractCacheSource.*; 9 | 10 | import org.redkale.util.AnyValueWriter; 11 | 12 | /** @author zhangjx */ 13 | public class RedissonCacheSourceTest extends RedisAbstractTest { 14 | 15 | public static void main(String[] args) throws Exception { 16 | AnyValueWriter conf = new AnyValueWriter() 17 | .addValue(CACHE_SOURCE_MAXCONNS, "1") 18 | .addValue(CACHE_SOURCE_NODES, "redis://127.0.0.1:6363"); 19 | 20 | RedissonCacheSource source = new RedissonCacheSource(); 21 | source.init(conf); 22 | try { 23 | run(source, true); 24 | } finally { 25 | source.close(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/test/java/org/redkalex/source/mapper/ForumBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | */ 4 | package org.redkalex.source.mapper; 5 | 6 | import java.io.Serializable; 7 | 8 | /** @author zhangjx */ 9 | public class ForumBean implements Serializable { 10 | 11 | private String forumSectionid; 12 | 13 | private String forumSectionColor; 14 | 15 | private String forumid; 16 | 17 | public String getForumSectionid() { 18 | return forumSectionid; 19 | } 20 | 21 | public void setForumSectionid(String forumSectionid) { 22 | this.forumSectionid = forumSectionid; 23 | } 24 | 25 | public String getForumSectionColor() { 26 | return forumSectionColor; 27 | } 28 | 29 | public void setForumSectionColor(String forumSectionColor) { 30 | this.forumSectionColor = forumSectionColor; 31 | } 32 | 33 | public String getForumid() { 34 | return forumid; 35 | } 36 | 37 | public void setForumid(String forumid) { 38 | this.forumid = forumid; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/test/java/org/redkalex/source/parser2/ForumBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | */ 4 | package org.redkalex.source.parser2; 5 | 6 | import java.io.Serializable; 7 | 8 | /** @author zhangjx */ 9 | public class ForumBean implements Serializable { 10 | 11 | private String forumSectionid; 12 | 13 | private String forumSectionColor; 14 | 15 | private String forumid; 16 | 17 | public String getForumSectionid() { 18 | return forumSectionid; 19 | } 20 | 21 | public void setForumSectionid(String forumSectionid) { 22 | this.forumSectionid = forumSectionid; 23 | } 24 | 25 | public String getForumSectionColor() { 26 | return forumSectionColor; 27 | } 28 | 29 | public void setForumSectionColor(String forumSectionColor) { 30 | this.forumSectionColor = forumSectionColor; 31 | } 32 | 33 | public String getForumid() { 34 | return forumid; 35 | } 36 | 37 | public void setForumid(String forumid) { 38 | this.forumid = forumid; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/pay/PayRefundQueryResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.pay; 7 | 8 | import java.util.Map; 9 | 10 | /** 11 | * 详情见: https://redkale.org 12 | * 13 | * @author zhangjx 14 | */ 15 | public class PayRefundQueryResponse extends PayResponse { 16 | 17 | @Override 18 | public PayRefundQueryResponse retcode(int retcode) { 19 | this.retcode = retcode; 20 | this.retinfo = PayRetCodes.retInfo(retcode); 21 | return this; 22 | } 23 | 24 | @Override 25 | public PayRefundQueryResponse retinfo(String retinfo) { 26 | if (retinfo != null) this.retinfo = retinfo; 27 | return this; 28 | } 29 | 30 | @Override 31 | public PayRefundQueryResponse result(Map result) { 32 | this.setResult(result); 33 | return this; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/htel/HttpTemplateRender.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this referid file, choose Tools | Templates 4 | * and open the referid in the editor. 5 | */ 6 | package org.redkalex.htel; 7 | 8 | import java.io.*; 9 | import org.redkale.annotation.Resource; 10 | import org.redkale.convert.Convert; 11 | import org.redkale.net.http.*; 12 | import org.redkale.util.AnyValue; 13 | 14 | /** 15 | * Http Template Express Language 16 | * 17 | *

尚未实现 18 | * 19 | * @author zhangjx 20 | */ 21 | public class HttpTemplateRender implements org.redkale.net.http.HttpRender { 22 | 23 | @Resource(name = "APP_HOME") 24 | protected File home; 25 | 26 | @Override 27 | public void init(HttpContext context, AnyValue config) {} 28 | 29 | @Override 30 | public void renderTo(HttpRequest request, HttpResponse response, Convert convert, HttpScope scope) { 31 | throw new UnsupportedOperationException("Not supported yet."); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/cache/redis/RedisCryptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.cache.redis; 7 | 8 | import org.redkale.util.AnyValue; 9 | 10 | /** @author zhangjx */ 11 | public interface RedisCryptor { 12 | 13 | /** 14 | * 初始化 15 | * 16 | * @param conf 配置 17 | */ 18 | public void init(AnyValue conf); 19 | 20 | /** 21 | * 加密, 无需加密的key对应的值需要直接返回value 22 | * 23 | * @param key key 24 | * @param value 明文 25 | * @return 密文 26 | */ 27 | public String encrypt(String key, String value); 28 | 29 | /** 30 | * 解密, 无需解密的key对应的值需要直接返回value 31 | * 32 | * @param key key 33 | * @param value 密文 34 | * @return 明文 35 | */ 36 | public String decrypt(String key, String value); 37 | 38 | /** 39 | * 销毁 40 | * 41 | * @param conf 配置 42 | */ 43 | public void destroy(AnyValue conf); 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/cache/redis/RedissonCacheSourceProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.cache.redis; 7 | 8 | import org.redkale.annotation.Priority; 9 | import org.redkale.source.*; 10 | import org.redkale.source.spi.CacheSourceProvider; 11 | import org.redkale.util.AnyValue; 12 | 13 | /** @author zhangjx */ 14 | @Priority(-500) 15 | public class RedissonCacheSourceProvider implements CacheSourceProvider { 16 | 17 | @Override 18 | public boolean acceptsConf(AnyValue config) { 19 | try { 20 | Object.class.isAssignableFrom(org.redisson.config.Config.class); // 试图加载Redisson相关类 21 | return new RedissonCacheSource().acceptsConf(config); 22 | } catch (Throwable e) { 23 | return false; 24 | } 25 | } 26 | 27 | @Override 28 | public CacheSource createInstance() { 29 | return new RedissonCacheSource(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/mq/kafka/KafkaMessageAgentProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.mq.kafka; 7 | 8 | import org.redkale.annotation.Priority; 9 | import org.redkale.mq.spi.MessageAgent; 10 | import org.redkale.mq.spi.MessageAgentProvider; 11 | import org.redkale.util.*; 12 | 13 | /** @author zhangjx */ 14 | @Priority(-800) 15 | public class KafkaMessageAgentProvider implements MessageAgentProvider { 16 | 17 | @Override 18 | public boolean acceptsConf(AnyValue config) { 19 | try { 20 | Object.class.isAssignableFrom(org.apache.kafka.clients.CommonClientConfigs.class); // 试图加载相关类 21 | return new KafkaMessageAgent().acceptsConf(config); 22 | } catch (Throwable t) { 23 | return false; 24 | } 25 | } 26 | 27 | @Override 28 | public MessageAgent createInstance() { 29 | return new KafkaMessageAgent(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/test/java/org/redkalex/source/mapper/MapperTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | */ 4 | 5 | package org.redkalex.source.mapper; 6 | 7 | import org.junit.jupiter.api.BeforeAll; 8 | import org.junit.jupiter.api.Test; 9 | import org.redkale.source.DataJdbcSource; 10 | import org.redkale.source.DataNativeSqlParser; 11 | import org.redkale.source.DataSqlSource; 12 | import org.redkale.source.spi.DataSqlMapperBuilder; 13 | 14 | /** 15 | * 16 | * @author zhangjx 17 | */ 18 | public class MapperTest { 19 | 20 | private static DataSqlSource source = new DataJdbcSource(); 21 | 22 | public static void main(String[] args) throws Throwable { 23 | MapperTest test = new MapperTest(); 24 | test.init(); 25 | test.run(); 26 | } 27 | 28 | @BeforeAll 29 | public static void init() throws Exception { 30 | // do 31 | } 32 | 33 | @Test 34 | public void run() throws Exception { 35 | DataNativeSqlParser nativeSqlParser = DataNativeSqlParser.loadFirst(); 36 | DataSqlMapperBuilder.createMapper(nativeSqlParser, source, ForumInfoMapper.class); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/pgsql/PgRowDesc.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.pgsql; 7 | 8 | import org.redkale.convert.json.JsonConvert; 9 | 10 | /** @author zhangjx */ 11 | public class PgRowDesc { 12 | 13 | final PgRowColumn[] columns; 14 | 15 | final PgColumnFormat[] formats; 16 | 17 | public PgRowDesc(PgRowColumn[] columns, PgColumnFormat[] formats) { 18 | this.columns = columns; 19 | this.formats = formats; 20 | } 21 | 22 | public PgRowColumn[] getColumns() { 23 | return columns; 24 | } 25 | 26 | public PgRowColumn getColumn(int i) { 27 | return columns[i]; 28 | } 29 | 30 | public int length() { 31 | if (columns == null) { 32 | return -1; 33 | } 34 | return columns.length; 35 | } 36 | 37 | @Override 38 | public String toString() { 39 | return JsonConvert.root().convertTo(this); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/parser/CustomDeleteDeParser.java: -------------------------------------------------------------------------------- 1 | /* - 2 | * #%L 3 | * JSQLParser library 4 | * %% 5 | * Copyright (C) 2004 - 2019 JSQLParser 6 | * %% 7 | * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 8 | * #L% 9 | * 10 | */ 11 | package org.redkalex.source.parser; 12 | 13 | import net.sf.jsqlparser.expression.ExpressionVisitor; 14 | import net.sf.jsqlparser.statement.delete.Delete; 15 | import net.sf.jsqlparser.util.deparser.DeleteDeParser; 16 | 17 | public class CustomDeleteDeParser extends DeleteDeParser { 18 | 19 | public CustomDeleteDeParser(ExpressionVisitor expressionVisitor, StringBuilder buffer) { 20 | super(expressionVisitor, buffer); 21 | } 22 | 23 | @Override 24 | protected void deparseWhereClause(Delete delete) { 25 | if (delete.getWhere() != null) { 26 | buffer.append(" WHERE "); 27 | int len = buffer.length(); 28 | delete.getWhere().accept(getExpressionVisitor()); 29 | if (buffer.length() == len) { 30 | buffer.delete(len - " WHERE ".length(), len); 31 | } 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/parser/CustomUpdateDeParser.java: -------------------------------------------------------------------------------- 1 | /* - 2 | * #%L 3 | * JSQLParser library 4 | * %% 5 | * Copyright (C) 2004 - 2019 JSQLParser 6 | * %% 7 | * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 8 | * #L% 9 | * 10 | */ 11 | package org.redkalex.source.parser; 12 | 13 | import net.sf.jsqlparser.expression.ExpressionVisitor; 14 | import net.sf.jsqlparser.statement.update.Update; 15 | import net.sf.jsqlparser.util.deparser.UpdateDeParser; 16 | 17 | public class CustomUpdateDeParser extends UpdateDeParser { 18 | 19 | public CustomUpdateDeParser(ExpressionVisitor expressionVisitor, StringBuilder buffer) { 20 | super(expressionVisitor, buffer); 21 | } 22 | 23 | @Override 24 | protected void deparseWhereClause(Update update) { 25 | if (update.getWhere() != null) { 26 | buffer.append(" WHERE "); 27 | int len = buffer.length(); 28 | update.getWhere().accept(getExpressionVisitor()); 29 | if (buffer.length() == len) { 30 | buffer.delete(len - " WHERE ".length(), len); 31 | } 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/pgsql/PgReqClose.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.pgsql; 7 | 8 | import static org.redkalex.source.pgsql.PgClientRequest.REQ_TYPE_UPDATE; 9 | 10 | import java.util.Objects; 11 | import org.redkale.net.client.ClientConnection; 12 | import org.redkale.util.ByteArray; 13 | 14 | /** @author zhangjx */ 15 | public class PgReqClose extends PgClientRequest { 16 | 17 | public PgReqClose() {} 18 | 19 | @Override 20 | public int getType() { 21 | return REQ_TYPE_UPDATE; 22 | } 23 | 24 | @Override 25 | public final boolean isCloseType() { 26 | return true; 27 | } 28 | 29 | @Override 30 | public String toString() { 31 | return "PgReqClose_" + Objects.hashCode(this) + "{type=" + getType() + "}"; 32 | } 33 | 34 | @Override 35 | public void writeTo(ClientConnection conn, ByteArray array) { 36 | array.putByte('X'); 37 | array.putInt(4); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/parser/NativeSqlTemplet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | */ 4 | package org.redkalex.source.parser; 5 | 6 | import java.util.Map; 7 | import org.redkale.convert.json.JsonConvert; 8 | 9 | /** @author zhangjx */ 10 | public class NativeSqlTemplet { 11 | 12 | private String jdbcSql; 13 | 14 | private Map templetParams; 15 | 16 | public NativeSqlTemplet() { 17 | // do nothing 18 | } 19 | 20 | public NativeSqlTemplet(String templetSql, Map templetParams) { 21 | this.jdbcSql = templetSql; 22 | this.templetParams = templetParams; 23 | } 24 | 25 | public String getJdbcSql() { 26 | return jdbcSql; 27 | } 28 | 29 | public void setJdbcSql(String jdbcSql) { 30 | this.jdbcSql = jdbcSql; 31 | } 32 | 33 | public Map getTempletParams() { 34 | return templetParams; 35 | } 36 | 37 | public void setTempletParams(Map templetParams) { 38 | this.templetParams = templetParams; 39 | } 40 | 41 | @Override 42 | public String toString() { 43 | return JsonConvert.root().convertTo(this); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/mysql/MyReqClose.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.mysql; 7 | 8 | import static org.redkalex.source.mysql.MyClientRequest.REQ_TYPE_UPDATE; 9 | 10 | import java.util.Objects; 11 | import org.redkale.net.client.ClientConnection; 12 | import org.redkale.util.ByteArray; 13 | 14 | /** @author zhangjx */ 15 | public class MyReqClose extends MyClientRequest { 16 | 17 | public MyReqClose() {} 18 | 19 | @Override 20 | public int getType() { 21 | return REQ_TYPE_UPDATE; 22 | } 23 | 24 | @Override 25 | public final boolean isCloseType() { 26 | return true; 27 | } 28 | 29 | @Override 30 | public String toString() { 31 | return "MyReqClose_" + Objects.hashCode(this) + "{type=" + getType() + "}"; 32 | } 33 | 34 | @Override 35 | public void writeTo(ClientConnection conn, ByteArray array) { 36 | Mysqls.writeUB3(array, 1); 37 | array.put(packetIndex); 38 | array.put(Mysqls.COM_QUIT); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/pgsql/PgReqQuery.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.pgsql; 7 | 8 | import java.util.Objects; 9 | import org.redkale.net.client.ClientConnection; 10 | import org.redkale.util.ByteArray; 11 | 12 | /** @author zhangjx */ 13 | public class PgReqQuery extends PgClientRequest { 14 | 15 | protected String sql; 16 | 17 | public void prepare(String sql) { 18 | super.prepare(); 19 | this.sql = sql; 20 | } 21 | 22 | @Override 23 | public int getType() { 24 | return REQ_TYPE_QUERY; 25 | } 26 | 27 | @Override 28 | public String toString() { 29 | return "PgReqQuery_" + Objects.hashCode(this) + "{sql=" + sql + "}"; 30 | } 31 | 32 | @Override 33 | public void writeTo(ClientConnection conn, ByteArray array) { 34 | array.putByte('Q'); 35 | int start = array.length(); 36 | array.putInt(0); 37 | writeUTF8String(array, sql); 38 | array.putInt(start, array.length() - start); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/mysql/MysqlDataSourceProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.mysql; 7 | 8 | import static org.redkale.source.DataSources.*; 9 | 10 | import org.redkale.annotation.Priority; 11 | import org.redkale.source.*; 12 | import org.redkale.source.spi.DataSourceProvider; 13 | import org.redkale.util.AnyValue; 14 | 15 | /** @author zhangjx */ 16 | @Priority(-900) 17 | public class MysqlDataSourceProvider implements DataSourceProvider { 18 | 19 | @Override 20 | public boolean acceptsConf(AnyValue config) { 21 | String dbtype = config.getValue("dbtype"); 22 | if (dbtype == null) { 23 | AnyValue read = config.getAnyValue("read"); 24 | AnyValue node = read == null ? config : read; 25 | dbtype = parseDbtype(node.getValue(DATA_SOURCE_URL)); 26 | } 27 | return "mysql".equalsIgnoreCase(dbtype); 28 | } 29 | 30 | @Override 31 | public DataSource createInstance() { 32 | return new MysqlDataSource(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/pgsql/PgRespReadyDecoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.pgsql; 7 | 8 | import static org.redkalex.source.pgsql.PgClientCodec.*; 9 | 10 | import java.nio.ByteBuffer; 11 | import org.redkale.util.ByteArray; 12 | 13 | /** @author zhangjx */ 14 | public class PgRespReadyDecoder extends PgRespDecoder { 15 | 16 | public static final PgRespReadyDecoder instance = new PgRespReadyDecoder(); 17 | 18 | private PgRespReadyDecoder() {} 19 | 20 | @Override 21 | public byte messageid() { 22 | return MESSAGE_TYPE_READY_FOR_QUERY; // 'Z' 23 | } 24 | 25 | @Override 26 | public Boolean read( 27 | PgClientConnection conn, 28 | ByteBuffer buffer, 29 | int length, 30 | ByteArray array, 31 | PgClientRequest request, 32 | PgResultSet dataset) { 33 | if (length > 4) { 34 | buffer.position(buffer.position() + length - 4); 35 | } 36 | return true; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/cache/redis/RedisCacheReqPing.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.cache.redis; 7 | 8 | import java.nio.charset.StandardCharsets; 9 | import org.redkale.net.client.ClientConnection; 10 | import org.redkale.util.ByteArray; 11 | 12 | /** @author zhangjx */ 13 | public class RedisCacheReqPing extends RedisCacheRequest { 14 | 15 | private static final byte[] BYTES = new ByteArray() 16 | .put((byte) '*') 17 | .put((byte) '1') 18 | .put((byte) '\r', (byte) '\n') 19 | .put((byte) '$') 20 | .put((byte) '4') 21 | .put((byte) '\r', (byte) '\n') 22 | .put("PING".getBytes(StandardCharsets.UTF_8)) 23 | .put((byte) '\r', (byte) '\n') 24 | .getBytes(); 25 | 26 | @Override 27 | public void writeTo(ClientConnection conn, ByteArray writer) { 28 | writer.put(BYTES); 29 | } 30 | 31 | @Override 32 | public String toString() { 33 | return getClass().getSimpleName() + "{PING}"; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/pgsql/PgsqlDataSourceProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.pgsql; 7 | 8 | import static org.redkale.source.DataSources.*; 9 | 10 | import org.redkale.annotation.Priority; 11 | import org.redkale.source.*; 12 | import org.redkale.source.spi.DataSourceProvider; 13 | import org.redkale.util.AnyValue; 14 | 15 | /** @author zhangjx */ 16 | @Priority(-900) 17 | public class PgsqlDataSourceProvider implements DataSourceProvider { 18 | 19 | @Override 20 | public boolean acceptsConf(AnyValue config) { 21 | String dbtype = config.getValue("dbtype"); 22 | if (dbtype == null) { 23 | AnyValue read = config.getAnyValue("read"); 24 | AnyValue node = read == null ? config : read; 25 | dbtype = parseDbtype(node.getValue(DATA_SOURCE_URL)); 26 | } 27 | return "postgresql".equalsIgnoreCase(dbtype); 28 | } 29 | 30 | @Override 31 | public DataSource createInstance() { 32 | return new PgsqlDataSource(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/search/OpenSearchSourceProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.search; 7 | 8 | import static org.redkale.source.DataSources.*; 9 | 10 | import org.redkale.annotation.Priority; 11 | import org.redkale.source.*; 12 | import org.redkale.source.spi.DataSourceProvider; 13 | import org.redkale.util.AnyValue; 14 | 15 | /** @author zhangjx */ 16 | @Priority(-900) 17 | public class OpenSearchSourceProvider implements DataSourceProvider { 18 | 19 | @Override 20 | public boolean acceptsConf(AnyValue config) { 21 | String dbtype = config.getValue("dbtype"); 22 | if (dbtype == null) { 23 | AnyValue read = config.getAnyValue("read"); 24 | AnyValue node = read == null ? config : read; 25 | dbtype = parseDbtype(node.getValue(DATA_SOURCE_URL)); 26 | } 27 | return "search".equalsIgnoreCase(dbtype); 28 | } 29 | 30 | @Override 31 | public DataSource createInstance() { 32 | return new OpenSearchSource(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /.github/workflows/maven.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time 2 | # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven 3 | 4 | # This workflow uses actions that are not certified by GitHub. 5 | # They are provided by a third-party and are governed by 6 | # separate terms of service, privacy policy, and support 7 | # documentation. 8 | 9 | name: Maven CI 10 | 11 | on: 12 | workflow_dispatch: 13 | 14 | jobs: 15 | build: 16 | 17 | runs-on: ubuntu-latest 18 | 19 | steps: 20 | - uses: actions/checkout@v4 21 | - name: Set up JDK 11 22 | uses: actions/setup-java@v3 23 | with: 24 | java-version: '11' 25 | distribution: 'temurin' 26 | cache: maven 27 | - name: Build with Maven 28 | run: mvn -B package --file pom.xml 29 | 30 | # Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive 31 | - name: Update dependency graph 32 | uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6 33 | -------------------------------------------------------------------------------- /src/test/java/org/redkalex/source/mysql/World.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.mysql; 7 | 8 | import org.redkale.convert.json.JsonConvert; 9 | import org.redkale.persistence.*; 10 | 11 | /** @author zhangjx */ 12 | @Entity 13 | public class World implements Comparable { 14 | 15 | @Id 16 | protected int id; 17 | 18 | protected int randomNumber; 19 | 20 | public World randomNumber(int randomNumber) { 21 | this.randomNumber = randomNumber; 22 | return this; 23 | } 24 | 25 | public int getId() { 26 | return id; 27 | } 28 | 29 | public void setId(int id) { 30 | this.id = id; 31 | } 32 | 33 | public int getRandomNumber() { 34 | return randomNumber; 35 | } 36 | 37 | public void setRandomNumber(int randomNumber) { 38 | this.randomNumber = randomNumber; 39 | } 40 | 41 | @Override 42 | public int compareTo(World o) { 43 | return Integer.compare(id, o.id); 44 | } 45 | 46 | @Override 47 | public String toString() { 48 | return JsonConvert.root().convertTo(this); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/cache/redis/RedisCacheReqDB.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.cache.redis; 7 | 8 | import java.nio.charset.StandardCharsets; 9 | import org.redkale.net.client.ClientConnection; 10 | import org.redkale.util.ByteArray; 11 | 12 | /** @author zhangjx */ 13 | public class RedisCacheReqDB extends RedisCacheRequest { 14 | 15 | protected int db; 16 | 17 | public RedisCacheReqDB(int db) { 18 | this.db = db; 19 | } 20 | 21 | public int getDb() { 22 | return db; 23 | } 24 | 25 | @Override 26 | public void writeTo(ClientConnection conn, ByteArray writer) { 27 | writer.put(mutliLengthBytes(2)); 28 | writer.put(bulkLengthBytes(6)); 29 | writer.put("SELECT\r\n".getBytes(StandardCharsets.UTF_8)); 30 | 31 | byte[] dbs = String.valueOf(db).getBytes(StandardCharsets.UTF_8); 32 | writer.put(bulkLengthBytes(dbs.length)); 33 | writer.put(dbs); 34 | writer.put(CRLF); 35 | } 36 | 37 | @Override 38 | public String toString() { 39 | return getClass().getSimpleName() + "{SELECT " + db + "}"; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/parser/CustomStatementDeParser.java: -------------------------------------------------------------------------------- 1 | /* - 2 | * #%L 3 | * JSQLParser library 4 | * %% 5 | * Copyright (C) 2004 - 2019 JSQLParser 6 | * %% 7 | * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 8 | * #L% 9 | */ 10 | package org.redkalex.source.parser; 11 | 12 | import net.sf.jsqlparser.statement.delete.Delete; 13 | import net.sf.jsqlparser.statement.update.Update; 14 | import net.sf.jsqlparser.util.deparser.ExpressionDeParser; 15 | import net.sf.jsqlparser.util.deparser.SelectDeParser; 16 | import net.sf.jsqlparser.util.deparser.StatementDeParser; 17 | 18 | public class CustomStatementDeParser extends StatementDeParser { 19 | 20 | public CustomStatementDeParser( 21 | ExpressionDeParser expressionDeParser, SelectDeParser selectDeParser, StringBuilder buffer) { 22 | super(expressionDeParser, selectDeParser, buffer); 23 | } 24 | 25 | @Override 26 | public StringBuilder visit(Delete delete, S context) { 27 | new CustomDeleteDeParser(getExpressionDeParser(), buffer).deParse(delete); 28 | return buffer; 29 | } 30 | 31 | @Override 32 | public StringBuilder visit(Update update, S context) { 33 | new CustomUpdateDeParser(getExpressionDeParser(), buffer).deParse(update); 34 | return buffer; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/search/BulkResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.search; 7 | 8 | /** @author zhangjx */ 9 | public class BulkResult extends BaseBean { 10 | 11 | public long took; 12 | 13 | public boolean errors; 14 | 15 | public BulkItem[] items; 16 | 17 | public int successCount() { 18 | int count = 0; 19 | if (items == null) return count; 20 | for (BulkItem item : items) { 21 | ActionResult ar = item.action(); 22 | if (ar == null) continue; 23 | count += ar.successCount(); 24 | } 25 | return count; 26 | } 27 | 28 | public static class BulkItem extends BaseBean { 29 | 30 | public ActionResult index; 31 | 32 | public ActionResult create; 33 | 34 | public ActionResult update; 35 | 36 | public ActionResult delete; 37 | 38 | public ActionResult action() { 39 | if (create != null) return create; 40 | if (update != null) return update; 41 | if (delete != null) return delete; 42 | return index; 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/cache/redis/RedisCacheReqClose.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.cache.redis; 7 | 8 | import java.nio.charset.StandardCharsets; 9 | import org.redkale.net.client.ClientConnection; 10 | import org.redkale.util.ByteArray; 11 | 12 | /** @author zhangjx */ 13 | public class RedisCacheReqClose extends RedisCacheRequest { 14 | 15 | private static final byte[] BYTES = new ByteArray() 16 | .put((byte) '*') 17 | .put((byte) '1') 18 | .put((byte) '\r', (byte) '\n') 19 | .put((byte) '$') 20 | .put((byte) '4') 21 | .put((byte) '\r', (byte) '\n') 22 | .put("QUIT".getBytes(StandardCharsets.UTF_8)) 23 | .put((byte) '\r', (byte) '\n') 24 | .getBytes(); 25 | 26 | @Override 27 | public final boolean isCloseType() { 28 | return true; 29 | } 30 | 31 | @Override 32 | public void writeTo(ClientConnection conn, ByteArray writer) { 33 | writer.put(BYTES); 34 | } 35 | 36 | @Override 37 | public String toString() { 38 | return getClass().getSimpleName() + "{QUIT}"; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/mysql/MyReqQuery.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.mysql; 7 | 8 | import static org.redkalex.source.mysql.Mysqls.*; 9 | 10 | import java.nio.charset.StandardCharsets; 11 | import java.util.Objects; 12 | import org.redkale.net.client.ClientConnection; 13 | import org.redkale.util.*; 14 | 15 | /** @author zhangjx */ 16 | public class MyReqQuery extends MyClientRequest { 17 | 18 | protected String sql; 19 | 20 | public void prepare(String sql) { 21 | super.prepare(); 22 | this.sql = sql; 23 | } 24 | 25 | @Override 26 | public int getType() { 27 | return REQ_TYPE_QUERY; 28 | } 29 | 30 | @Override 31 | public String toString() { 32 | return "MyReqQuery_" + Objects.hashCode(this) + "{sql=" + sql + "}"; 33 | } 34 | 35 | @Override 36 | public void writeTo(ClientConnection conn, ByteArray array) { 37 | byte[] sqlbytes = sql.getBytes(StandardCharsets.UTF_8); 38 | Mysqls.writeUB3(array, 1 + sqlbytes.length); 39 | array.put(packetIndex); 40 | array.put(COM_QUERY); 41 | array.put(sqlbytes); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/cache/redis/RedisCacheReqAuth.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.cache.redis; 7 | 8 | import java.nio.charset.StandardCharsets; 9 | import org.redkale.net.client.ClientConnection; 10 | import org.redkale.util.ByteArray; 11 | 12 | /** @author zhangjx */ 13 | public class RedisCacheReqAuth extends RedisCacheRequest { 14 | 15 | private static final byte[] PS = "AUTH\r\n".getBytes(StandardCharsets.UTF_8); 16 | 17 | protected String password; 18 | 19 | public RedisCacheReqAuth(String password) { 20 | this.password = password; 21 | } 22 | 23 | public String getPassword() { 24 | return password; 25 | } 26 | 27 | @Override 28 | public void writeTo(ClientConnection conn, ByteArray writer) { 29 | byte[] pwd = password.getBytes(); 30 | writer.put(mutliLengthBytes(2)); 31 | writer.put(bulkLengthBytes(4)); 32 | writer.put(PS); 33 | 34 | writer.put(bulkLengthBytes(pwd.length)); 35 | writer.put(pwd); 36 | writer.put(CRLF); 37 | } 38 | 39 | @Override 40 | public String toString() { 41 | return getClass().getSimpleName() + "{AUTH " + password + "}"; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/scheduled/xxljob/LogParam.java: -------------------------------------------------------------------------------- 1 | package org.redkalex.scheduled.xxljob; 2 | 3 | import java.io.Serializable; 4 | import org.redkale.convert.json.JsonConvert; 5 | 6 | /** @author xuxueli 2020-04-11 22:27 */ 7 | public class LogParam implements Serializable { 8 | 9 | private static final long serialVersionUID = 42L; 10 | 11 | private long logDateTim; 12 | 13 | private long logId; 14 | 15 | private int fromLineNum; 16 | 17 | public LogParam() {} 18 | 19 | public LogParam(long logDateTim, long logId, int fromLineNum) { 20 | this.logDateTim = logDateTim; 21 | this.logId = logId; 22 | this.fromLineNum = fromLineNum; 23 | } 24 | 25 | public long getLogDateTim() { 26 | return logDateTim; 27 | } 28 | 29 | public void setLogDateTim(long logDateTim) { 30 | this.logDateTim = logDateTim; 31 | } 32 | 33 | public long getLogId() { 34 | return logId; 35 | } 36 | 37 | public void setLogId(long logId) { 38 | this.logId = logId; 39 | } 40 | 41 | public int getFromLineNum() { 42 | return fromLineNum; 43 | } 44 | 45 | public void setFromLineNum(int fromLineNum) { 46 | this.fromLineNum = fromLineNum; 47 | } 48 | 49 | @Override 50 | public String toString() { 51 | return JsonConvert.root().convertTo(this); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /.github/workflows/maven-snapshot.yml: -------------------------------------------------------------------------------- 1 | name: Maven Snapshot 2 | 3 | on: 4 | workflow_dispatch: 5 | 6 | jobs: 7 | deploy: 8 | 9 | runs-on: ubuntu-latest 10 | strategy: 11 | matrix: 12 | java: [21] 13 | name: Java ${{ matrix.java }} build 14 | 15 | steps: 16 | - uses: actions/checkout@v4 17 | 18 | - name: Setup Java ${{ matrix.java }} 19 | uses: actions/setup-java@v4 20 | with: 21 | java-version: ${{ matrix.java }} 22 | distribution: 'temurin' 23 | cache: maven 24 | server-id: central 25 | server-username: CENTRAL_USERNAME 26 | server-password: CENTRAL_PASSWORD 27 | gpg-passphrase: GPG_PASSPHRASE 28 | 29 | - name: Import GPG key 30 | uses: crazy-max/ghaction-import-gpg@v6 31 | with: 32 | passphrase: ${{ secrets.GPG_PASSPHRASE }} 33 | gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} 34 | git_config_global: true 35 | git_user_signingkey: true 36 | git_commit_gpgsign: true 37 | 38 | - name: Build with Maven 39 | run: | 40 | cp -fr my/pom.xml pom.xml 41 | mvn --batch-mode clean deploy -DskipTests=true 42 | env: 43 | CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }} 44 | CENTRAL_PASSWORD: ${{ secrets.CENTRAL_PASSWORD }} 45 | GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} 46 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/cache/redis/RedisCacheReqClientName.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | */ 4 | package org.redkalex.cache.redis; 5 | 6 | import java.nio.charset.StandardCharsets; 7 | import org.redkale.net.client.ClientConnection; 8 | import org.redkale.util.*; 9 | 10 | /** @author zhangjx */ 11 | public class RedisCacheReqClientName extends RedisCacheRequest { 12 | 13 | private final String clientName; 14 | 15 | public RedisCacheReqClientName(String appName, String resourceName) { 16 | this.clientName = "redkalex" + (Utility.isEmpty(appName) ? "" : ("-" + appName)) 17 | + (Utility.isEmpty(resourceName) ? "" : (":" + resourceName)); 18 | } 19 | 20 | @Override 21 | public void writeTo(ClientConnection conn, ByteArray writer) { 22 | writer.put(mutliLengthBytes(3)); 23 | 24 | writer.put(bulkLengthBytes(6)); 25 | writer.put("CLIENT\r\n".getBytes(StandardCharsets.UTF_8)); 26 | 27 | writer.put(bulkLengthBytes(7)); 28 | writer.put("SETNAME\r\n".getBytes(StandardCharsets.UTF_8)); 29 | 30 | byte[] ns = clientName.getBytes(StandardCharsets.UTF_8); 31 | writer.put(bulkLengthBytes(ns.length)); 32 | writer.put(ns); 33 | writer.put(CRLF); 34 | } 35 | 36 | @Override 37 | public String toString() { 38 | return getClass().getSimpleName() + "{CLIENT SETNAME " + clientName + "}"; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/module-info.java.bak: -------------------------------------------------------------------------------- 1 | /** 2 | * see: https://redkale.org 3 | * 4 | * @author zhangjx 5 | */ 6 | /** 7 | * module redkalex.plugins { 8 | * 9 | *

requires java.base; requires java.logging; requires java.net.http; requires java.sql; 10 | * 11 | *

requires redkale; 12 | * 13 | *

requires kafka.clients; requires lettuce.core; requires redisson; requires enjoy; requires freemarker; 14 | * 15 | *

requires org.reactivestreams; requires org.mongodb.bson; requires org.mongodb.driver.core; requires 16 | * org.mongodb.driver.reactivestreams; 17 | * 18 | *

//vertx 3.9.x //requires vertx.core; //requires vertx.sql.client; //requires vertx.pg.client; //requires 19 | * vertx.mysql.client; 20 | * 21 | *

//vertx 4.1.x requires io.vertx.core; requires io.vertx.client.sql; requires io.vertx.client.sql.pg; requires 22 | * io.vertx.client.sql.mysql; 23 | * 24 | *

exports org.redkalex.apns; exports org.redkalex.cache.redis; exports org.redkalex.cluster.consul; exports 25 | * org.redkalex.htel; exports org.redkalex.mq.kafka; exports org.redkalex.net.mqtt; exports org.redkalex.oidc; exports 26 | * org.redkalex.pay; exports org.redkalex.source.mongo; exports org.redkalex.source.mysql; exports 27 | * org.redkalex.source.pgsql; exports org.redkalex.source.search; exports org.redkalex.source.vertx; exports 28 | * org.redkalex.weixin; 29 | * 30 | *

} 31 | */ 32 | -------------------------------------------------------------------------------- /src/test/java/org/redkalex/source/base/TestWorld.java: -------------------------------------------------------------------------------- 1 | /* 2 | */ 3 | package org.redkalex.source.base; 4 | 5 | import org.redkale.convert.json.JsonConvert; 6 | import org.redkale.persistence.*; 7 | 8 | /** @author zhangjx */ 9 | @Entity 10 | public class TestWorld implements Comparable { 11 | 12 | @Id 13 | protected int id; 14 | 15 | protected int randomNumber; 16 | 17 | @Column(nullable = false) 18 | protected int[] citys; 19 | 20 | public TestWorld() {} 21 | 22 | public TestWorld(int id, int randomNumber) { 23 | this.id = id; 24 | this.randomNumber = randomNumber; 25 | } 26 | 27 | public int getId() { 28 | return id; 29 | } 30 | 31 | public void setId(int id) { 32 | this.id = id; 33 | } 34 | 35 | public int getRandomNumber() { 36 | return randomNumber; 37 | } 38 | 39 | public void setRandomNumber(int randomNumber) { 40 | this.randomNumber = randomNumber; 41 | } 42 | 43 | @Override 44 | public int compareTo(TestWorld o) { 45 | return Integer.compare(id, o.id); 46 | } 47 | 48 | public int[] getCitys() { 49 | return citys; 50 | } 51 | 52 | public void setCitys(int[] citys) { 53 | this.citys = citys; 54 | } 55 | 56 | @Override 57 | public String toString() { 58 | return JsonConvert.root().convertTo(this); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/pgsql/PgRespParamDescDecoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | */ 4 | package org.redkalex.source.pgsql; 5 | 6 | import static org.redkalex.source.pgsql.PgClientCodec.*; 7 | 8 | import java.nio.ByteBuffer; 9 | import org.redkale.source.SourceException; 10 | import org.redkale.util.ByteArray; 11 | 12 | /** @author zhangjx */ 13 | public class PgRespParamDescDecoder extends PgRespDecoder { 14 | 15 | public static final PgRespParamDescDecoder instance = new PgRespParamDescDecoder(); 16 | 17 | private PgRespParamDescDecoder() {} 18 | 19 | @Override 20 | public byte messageid() { 21 | return MESSAGE_TYPE_PARAMETER_DESCRIPTION; // 't' 22 | } 23 | 24 | @Override 25 | public PgColumnFormat[] read( 26 | PgClientConnection conn, 27 | ByteBuffer buffer, 28 | final int length, 29 | ByteArray array, 30 | PgClientRequest request, 31 | PgResultSet dataset) { 32 | PgColumnFormat[] formats = new PgColumnFormat[buffer.getShort() & 0xFFFF]; 33 | for (int i = 0; i < formats.length; i++) { 34 | int oid = buffer.getInt(); 35 | formats[i] = PgColumnFormat.valueOf(oid); 36 | if (formats[i].encoder() == null) { 37 | throw new SourceException("Unsupported data encode ColumnFormat: " + formats[i]); 38 | } 39 | } 40 | return formats; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/mongo/MongodbDriverDataSourceProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.mongo; 7 | 8 | import static org.redkale.source.DataSources.*; 9 | 10 | import org.redkale.annotation.Priority; 11 | import org.redkale.source.*; 12 | import org.redkale.source.spi.DataSourceProvider; 13 | import org.redkale.util.*; 14 | 15 | /** @author zhangjx */ 16 | @Priority(-700) 17 | public class MongodbDriverDataSourceProvider implements DataSourceProvider { 18 | 19 | @Override 20 | public boolean acceptsConf(AnyValue config) { 21 | try { 22 | Object.class.isAssignableFrom(com.mongodb.reactivestreams.client.MongoClient.class); // 试图加载MongoClient相关类 23 | String dbtype = config.getValue("dbtype"); 24 | if (dbtype == null) { 25 | AnyValue read = config.getAnyValue("read"); 26 | AnyValue node = read == null ? config : read; 27 | dbtype = parseDbtype(node.getValue(DATA_SOURCE_URL)); 28 | } 29 | return "mongodb".equalsIgnoreCase(dbtype); 30 | } catch (Throwable e) { 31 | return false; 32 | } 33 | } 34 | 35 | @Override 36 | public DataSource createInstance() { 37 | return new MongodbDriverDataSource(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/mysql/MyReqBatch.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.mysql; 7 | 8 | import static org.redkalex.source.mysql.Mysqls.COM_QUERY; 9 | 10 | import java.nio.charset.StandardCharsets; 11 | import java.util.*; 12 | import org.redkale.net.client.ClientConnection; 13 | import org.redkale.util.ByteArray; 14 | 15 | /** @author zhangjx */ 16 | public class MyReqBatch extends MyClientRequest { 17 | 18 | protected String[] sqls; 19 | 20 | @Override 21 | public int getType() { 22 | return REQ_TYPE_BATCH; 23 | } 24 | 25 | public MyReqBatch prepare(String... sqls) { 26 | super.prepare(); 27 | this.sqls = sqls; 28 | return this; 29 | } 30 | 31 | @Override 32 | public String toString() { 33 | return "MyReqBatch_" + Objects.hashCode(this) + "{sqls=" + Arrays.toString(sqls) + "}"; 34 | } 35 | 36 | @Override 37 | public void writeTo(ClientConnection conn, ByteArray array) { 38 | for (String sql : sqls) { 39 | byte[] sqlbytes = sql.getBytes(StandardCharsets.UTF_8); 40 | Mysqls.writeUB3(array, 1 + sqlbytes.length); 41 | array.put(packetIndex); 42 | array.put(COM_QUERY); 43 | array.put(sqlbytes); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## 项目介绍 2 |   RedKale的扩展插件库。 3 | 4 | ## 版本 5 | ```xml 6 | 7 | org.redkalex 8 | redkale-plugins 9 | 2.8.0 10 | 11 | ``` 12 | 13 | ## 功能说明 14 | |组件|说明|依赖| 15 | | --- | --- | --- | 16 | |RedisCacheSource|基于redkale-client的CacheSource实现|无| 17 | |RedisVertxCacheSource|基于vertx-redis的CacheSource实现|vertx-redis-client:v4.5.8| 18 | |RedissonCacheSource|基于redisson的CacheSource实现|redisson:v3.31.0| 19 | | | | 20 | |VertxSqlDataSource|基于vertx-sql-client的DataSource实现|vertx-sql-client:v4.5.8| 21 | |MongodbDriverDataSource|基于mongodb的DataSource实现|mongodb-driver-reactivestreams:v5.1.0| 22 | |OpenSearchSource|基于openSearch的SearchSource实现|无| 23 | | | | 24 | |ConsulClusterAgent|基于consul的ClusterAgent实现|无| 25 | |NacosClusterAgent|基于nacos的ClusterAgent实现|无| 26 | | | | 27 | |ApolloClientPropertiesAgent|基于apollo-client的PropertiesAgent实现|apollo-client:v2.2.0 28 | |ApolloPropertiesAgent|基于apollo的PropertiesAgent实现|无| 29 | |NacosClientPropertiesAgent|基于nacos-client的PropertiesAgent实现|nacos-client:v2.2.4 30 | |NacosPropertiesAgent|基于nacos的PropertiesAgent实现|无| 31 | | | | 32 | |XxljobScheduledManager|基于xxl-job的ScheduledManager实现|无| 33 | | | | 34 | |DataNativeJsqlParser|基于jsqlparser的DataNativeSqlParser实现|jsqlparser:v4.10| 35 | | | | 36 | |KafkaMessageAgent|基于kafka的MessageAgent实现|kafka-clients:v3.7.0| 37 | 38 | 39 | 详情请访问:    http://redkale.org 40 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/scheduled/xxljob/RegistryParam.java: -------------------------------------------------------------------------------- 1 | package org.redkalex.scheduled.xxljob; 2 | 3 | import java.io.Serializable; 4 | import org.redkale.convert.json.JsonConvert; 5 | 6 | /** Created by xuxueli on 2017-05-10 20:22:42 */ 7 | public class RegistryParam implements Serializable { 8 | 9 | private static final long serialVersionUID = 42L; 10 | 11 | private String registryGroup; 12 | 13 | private String registryKey; 14 | 15 | private String registryValue; 16 | 17 | public RegistryParam() {} 18 | 19 | public RegistryParam(String registryGroup, String registryKey, String registryValue) { 20 | this.registryGroup = registryGroup; 21 | this.registryKey = registryKey; 22 | this.registryValue = registryValue; 23 | } 24 | 25 | public String getRegistryGroup() { 26 | return registryGroup; 27 | } 28 | 29 | public void setRegistryGroup(String registryGroup) { 30 | this.registryGroup = registryGroup; 31 | } 32 | 33 | public String getRegistryKey() { 34 | return registryKey; 35 | } 36 | 37 | public void setRegistryKey(String registryKey) { 38 | this.registryKey = registryKey; 39 | } 40 | 41 | public String getRegistryValue() { 42 | return registryValue; 43 | } 44 | 45 | public void setRegistryValue(String registryValue) { 46 | this.registryValue = registryValue; 47 | } 48 | 49 | @Override 50 | public String toString() { 51 | return JsonConvert.root().convertTo(this); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/pgsql/PgRespCountDecoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.pgsql; 7 | 8 | import java.nio.ByteBuffer; 9 | import org.redkale.util.ByteArray; 10 | 11 | /** @author zhangjx */ 12 | public class PgRespCountDecoder extends PgRespDecoder { 13 | 14 | public static final PgRespCountDecoder instance = new PgRespCountDecoder(); 15 | 16 | private PgRespCountDecoder() {} 17 | 18 | @Override 19 | public byte messageid() { 20 | return 'C'; 21 | } 22 | 23 | @Override 24 | public Integer read( 25 | PgClientConnection conn, 26 | ByteBuffer buffer, 27 | int length, 28 | ByteArray array, 29 | PgClientRequest request, 30 | PgResultSet dataset) { 31 | int len = length - 5; // 最后字节是(byte)0 32 | byte b; 33 | int rows = -1; 34 | boolean debug = PgsqlDataSource.debug; 35 | if (debug) { 36 | array.clear(); 37 | } 38 | for (int i = 0; i < len; i++) { 39 | b = buffer.get(); 40 | if (rows != -1) { 41 | rows = rows * 10 + (b - '0'); 42 | } else if (b == ' ') { 43 | rows = 0; 44 | } 45 | if (debug) { 46 | array.put(b); 47 | } 48 | } 49 | buffer.get(); 50 | return rows; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/pgsql/PgRespAuthResultSet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.pgsql; 7 | 8 | import java.util.List; 9 | 10 | /** @author zhangjx */ 11 | public class PgRespAuthResultSet extends PgResultSet { 12 | 13 | protected boolean authOK; 14 | 15 | protected byte[] authSalt; 16 | 17 | protected List authMechanisms; 18 | 19 | protected PgReqAuthScramSaslContinueResult authSaslContinueResult; 20 | 21 | public PgRespAuthResultSet() {} 22 | 23 | public boolean isAuthOK() { 24 | return authOK; 25 | } 26 | 27 | public void setAuthOK(boolean authOK) { 28 | this.authOK = authOK; 29 | } 30 | 31 | public byte[] getAuthSalt() { 32 | return authSalt; 33 | } 34 | 35 | public void setAuthSalt(byte[] authSalt) { 36 | this.authSalt = authSalt; 37 | } 38 | 39 | public List getAuthMechanisms() { 40 | return authMechanisms; 41 | } 42 | 43 | public void setAuthMechanisms(List authMechanisms) { 44 | this.authMechanisms = authMechanisms; 45 | } 46 | 47 | public PgReqAuthScramSaslContinueResult getAuthSaslContinueResult() { 48 | return authSaslContinueResult; 49 | } 50 | 51 | public void setAuthSaslContinueResult(PgReqAuthScramSaslContinueResult authSaslContinueResult) { 52 | this.authSaslContinueResult = authSaslContinueResult; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/pay/PayRefundResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.pay; 7 | 8 | import java.util.Map; 9 | import org.redkale.convert.ConvertDisabled; 10 | 11 | /** 12 | * 详情见: https://redkale.org 13 | * 14 | * @author zhangjx 15 | */ 16 | public class PayRefundResponse extends PayResponse { 17 | 18 | protected long refundedMoney; // 已退款金额。 单位:分 19 | 20 | @Override 21 | public PayRefundResponse retcode(int retcode) { 22 | this.retcode = retcode; 23 | this.retinfo = PayRetCodes.retInfo(retcode); 24 | return this; 25 | } 26 | 27 | @Override 28 | public PayRefundResponse retinfo(String retinfo) { 29 | if (retinfo != null) this.retinfo = retinfo; 30 | return this; 31 | } 32 | 33 | @Override 34 | public PayRefundResponse result(Map result) { 35 | this.setResult(result); 36 | return this; 37 | } 38 | 39 | public long getRefundedMoney() { 40 | return refundedMoney; 41 | } 42 | 43 | public void setRefundedMoney(long refundedMoney) { 44 | this.refundedMoney = refundedMoney; 45 | } 46 | 47 | @Deprecated 48 | @ConvertDisabled 49 | public long getRefundedmoney() { 50 | return refundedMoney; 51 | } 52 | 53 | @Deprecated 54 | @ConvertDisabled 55 | public void setRefundedmoney(long refundedMoney) { 56 | this.refundedMoney = refundedMoney; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/mysql/MyRespPrepareDecoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.mysql; 7 | 8 | import java.nio.ByteBuffer; 9 | import org.redkale.util.ByteArray; 10 | 11 | /** @author zhangjx */ 12 | public class MyRespPrepareDecoder extends MyRespDecoder { 13 | 14 | public static final MyRespPrepareDecoder instance = new MyRespPrepareDecoder(); 15 | 16 | @Override 17 | public MyRespPrepare read( 18 | MyClientConnection conn, 19 | ByteBuffer buffer, 20 | int length, 21 | byte index, 22 | ByteArray array, 23 | MyClientRequest request, 24 | MyResultSet dataset) { 25 | MyRespPrepare rs = new MyRespPrepare(); 26 | rs.statementId = Mysqls.readUB4(buffer); 27 | rs.numberOfColumns = Mysqls.readUB2(buffer); 28 | rs.numberOfParameters = Mysqls.readUB2(buffer); 29 | buffer.get(); // [00] filler 30 | rs.numberOfWarnings = Mysqls.readUB2(buffer); 31 | if (rs.numberOfParameters > 0) { 32 | rs.paramDescs = new MyRowDesc(new MyRowColumn[rs.numberOfParameters]); 33 | rs.paramDecodeIndex = 0; 34 | } 35 | if (rs.numberOfColumns > 0) { 36 | rs.columnDescs = new MyRowDesc(new MyRowColumn[rs.numberOfColumns]); 37 | if (rs.paramDecodeIndex < 0) rs.columnDecodeIndex = 0; 38 | } 39 | return rs; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/test/java/org/redkalex/source/vertx/TestRecord.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.vertx; 7 | 8 | import org.redkale.convert.json.JsonConvert; 9 | import org.redkale.persistence.*; 10 | 11 | /** @author zhangjx */ 12 | @Entity 13 | public class TestRecord { 14 | 15 | @Id 16 | private String recordid; 17 | 18 | private String name; 19 | 20 | private short status; 21 | 22 | private int score; 23 | 24 | private long createTime; 25 | 26 | public String getRecordid() { 27 | return recordid; 28 | } 29 | 30 | public void setRecordid(String recordid) { 31 | this.recordid = recordid; 32 | } 33 | 34 | public String getName() { 35 | return name; 36 | } 37 | 38 | public void setName(String name) { 39 | this.name = name; 40 | } 41 | 42 | public short getStatus() { 43 | return status; 44 | } 45 | 46 | public void setStatus(short status) { 47 | this.status = status; 48 | } 49 | 50 | public int getScore() { 51 | return score; 52 | } 53 | 54 | public void setScore(int score) { 55 | this.score = score; 56 | } 57 | 58 | public long getCreateTime() { 59 | return createTime; 60 | } 61 | 62 | public void setCreateTime(long createTime) { 63 | this.createTime = createTime; 64 | } 65 | 66 | @Override 67 | public String toString() { 68 | return JsonConvert.root().convertTo(this); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/scheduled/xxljob/LogResult.java: -------------------------------------------------------------------------------- 1 | package org.redkalex.scheduled.xxljob; 2 | 3 | import java.io.Serializable; 4 | import org.redkale.convert.json.JsonConvert; 5 | 6 | /** Created by xuxueli on 17/3/23. */ 7 | public class LogResult implements Serializable { 8 | 9 | private static final long serialVersionUID = 42L; 10 | 11 | private int fromLineNum; 12 | 13 | private int toLineNum; 14 | 15 | private String logContent; 16 | 17 | private boolean isEnd; 18 | 19 | public LogResult() {} 20 | 21 | public LogResult(int fromLineNum, int toLineNum, String logContent, boolean isEnd) { 22 | this.fromLineNum = fromLineNum; 23 | this.toLineNum = toLineNum; 24 | this.logContent = logContent; 25 | this.isEnd = isEnd; 26 | } 27 | 28 | public int getFromLineNum() { 29 | return fromLineNum; 30 | } 31 | 32 | public void setFromLineNum(int fromLineNum) { 33 | this.fromLineNum = fromLineNum; 34 | } 35 | 36 | public int getToLineNum() { 37 | return toLineNum; 38 | } 39 | 40 | public void setToLineNum(int toLineNum) { 41 | this.toLineNum = toLineNum; 42 | } 43 | 44 | public String getLogContent() { 45 | return logContent; 46 | } 47 | 48 | public void setLogContent(String logContent) { 49 | this.logContent = logContent; 50 | } 51 | 52 | public boolean isEnd() { 53 | return isEnd; 54 | } 55 | 56 | public void setEnd(boolean end) { 57 | isEnd = end; 58 | } 59 | 60 | @Override 61 | public String toString() { 62 | return JsonConvert.root().convertTo(this); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/test/java/org/redkalex/source/pgsql/PgSourceTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | */ 3 | package org.redkalex.source.pgsql; 4 | 5 | import static org.redkale.boot.Application.RESNAME_APP_CLIENT_ASYNCGROUP; 6 | 7 | import java.util.Properties; 8 | import org.redkale.boot.LoggingFileHandler; 9 | import org.redkale.inject.ResourceFactory; 10 | import org.redkale.net.AsyncIOGroup; 11 | import org.redkale.util.*; 12 | import org.redkalex.source.base.SourceTest; 13 | 14 | /** @author zhangjx */ 15 | public class PgSourceTest { 16 | 17 | public static void main(String[] args) throws Throwable { 18 | 19 | LoggingFileHandler.initDebugLogConfig(); 20 | final AsyncIOGroup asyncGroup = new AsyncIOGroup(8192, 16); 21 | asyncGroup.start(); 22 | ResourceFactory factory = ResourceFactory.create(); 23 | factory.register(RESNAME_APP_CLIENT_ASYNCGROUP, asyncGroup); 24 | 25 | Properties prop = new Properties(); 26 | prop.setProperty("redkale.datasource.default.url", "jdbc:postgresql://127.0.0.1:5432/hello_world"); 27 | prop.setProperty("redkale.datasource.default.table-autoddl", "true"); 28 | prop.setProperty("redkale.datasource.default.user", "postgres"); 29 | prop.setProperty("redkale.datasource.default.password", "1234"); 30 | 31 | PgsqlDataSource source = new PgsqlDataSource(); 32 | factory.inject(source); 33 | source.init(AnyValue.loadFromProperties(prop) 34 | .getAnyValue("redkale") 35 | .getAnyValue("datasource") 36 | .getAnyValue("default")); 37 | System.out.println("---------"); 38 | SourceTest.run(source); 39 | source.close(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/scheduled/xxljob/ReturnT.java: -------------------------------------------------------------------------------- 1 | package org.redkalex.scheduled.xxljob; 2 | 3 | import java.io.Serializable; 4 | import org.redkale.convert.json.JsonConvert; 5 | 6 | /** 7 | * common return 8 | * 9 | * @author xuxueli 2015-12-4 16:32:31 10 | * @param T 11 | */ 12 | public class ReturnT implements Serializable { 13 | 14 | public static final long serialVersionUID = 42L; 15 | 16 | public static final int SUCCESS_CODE = 200; 17 | 18 | public static final int FAIL_CODE = 500; 19 | 20 | public static final ReturnT SUCCESS = new ReturnT(null); 21 | 22 | public static final ReturnT FAIL = new ReturnT(FAIL_CODE, null); 23 | 24 | private int code; 25 | 26 | private String msg; 27 | 28 | private T content; 29 | 30 | public ReturnT() {} 31 | 32 | public ReturnT(int code, String msg) { 33 | this.code = code; 34 | this.msg = msg; 35 | } 36 | 37 | public ReturnT(T content) { 38 | this.code = SUCCESS_CODE; 39 | this.content = content; 40 | } 41 | 42 | public int getCode() { 43 | return code; 44 | } 45 | 46 | public void setCode(int code) { 47 | this.code = code; 48 | } 49 | 50 | public String getMsg() { 51 | return msg; 52 | } 53 | 54 | public void setMsg(String msg) { 55 | this.msg = msg; 56 | } 57 | 58 | public T getContent() { 59 | return content; 60 | } 61 | 62 | public void setContent(T content) { 63 | this.content = content; 64 | } 65 | 66 | @Override 67 | public String toString() { 68 | return JsonConvert.root().convertTo(this); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/scheduled/xxljob/HandleCallbackParam.java: -------------------------------------------------------------------------------- 1 | package org.redkalex.scheduled.xxljob; 2 | 3 | import java.io.Serializable; 4 | import org.redkale.convert.json.JsonConvert; 5 | 6 | /** Created by xuxueli on 17/3/2. */ 7 | public class HandleCallbackParam implements Serializable { 8 | 9 | private static final long serialVersionUID = 42L; 10 | 11 | private long logId; 12 | 13 | private long logDateTim; 14 | 15 | private int handleCode; 16 | 17 | private String handleMsg; 18 | 19 | public HandleCallbackParam() {} 20 | 21 | public HandleCallbackParam(long logId, long logDateTim, int handleCode, String handleMsg) { 22 | this.logId = logId; 23 | this.logDateTim = logDateTim; 24 | this.handleCode = handleCode; 25 | this.handleMsg = handleMsg; 26 | } 27 | 28 | public long getLogId() { 29 | return logId; 30 | } 31 | 32 | public void setLogId(long logId) { 33 | this.logId = logId; 34 | } 35 | 36 | public long getLogDateTim() { 37 | return logDateTim; 38 | } 39 | 40 | public void setLogDateTim(long logDateTim) { 41 | this.logDateTim = logDateTim; 42 | } 43 | 44 | public int getHandleCode() { 45 | return handleCode; 46 | } 47 | 48 | public void setHandleCode(int handleCode) { 49 | this.handleCode = handleCode; 50 | } 51 | 52 | public String getHandleMsg() { 53 | return handleMsg; 54 | } 55 | 56 | public void setHandleMsg(String handleMsg) { 57 | this.handleMsg = handleMsg; 58 | } 59 | 60 | @Override 61 | public String toString() { 62 | return JsonConvert.root().convertTo(this); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/test/java/org/redkalex/source/parser2/ForumInfoService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | */ 4 | package org.redkalex.source.parser2; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | import java.util.concurrent.CompletableFuture; 9 | import org.redkale.annotation.Resource; 10 | import org.redkale.service.AbstractService; 11 | import org.redkale.source.DataSqlSource; 12 | 13 | /** 14 | * 15 | * @author zhangjx 16 | */ 17 | public class ForumInfoService extends AbstractService { 18 | 19 | //查询单个记录的sql 20 | private static final String findOneSql = "SELECT f.forum_groupid, s.forum_section_color " 21 | + "FROM forum_info f, forum_section s " 22 | + " WHERE f.forumid = s.forumid AND " 23 | + "s.forum_sectionid = ${bean.forumSectionid} AND " 24 | + "f.forumid = ${bean.forumid} AND s.forum_section_color = ${bean.forumSectionColor}"; 25 | 26 | //查询列表记录的sql 27 | private static final String queryListSql = "SELECT f.forum_groupid, s.forum_section_color " 28 | + "FROM forum_info f, forum_section s " 29 | + " WHERE f.forumid = s.forumid AND " 30 | + "s.forum_sectionid = ${bean.forumSectionid} AND " 31 | + "f.forumid = ${bean.forumid} AND s.forum_section_color = ${bean.forumSectionColor}"; 32 | 33 | @Resource 34 | private DataSqlSource source; 35 | 36 | public ForumResult findForumResultOne(ForumBean bean) { 37 | return source.nativeQueryOne(ForumResult.class, findOneSql, Map.of("bean", bean)); 38 | } 39 | 40 | public CompletableFuture> queryForumResultListAsync(ForumBean bean) { 41 | return source.nativeQueryListAsync(ForumResult.class, queryListSql, Map.of("bean", bean)); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/test/java/org/redkalex/source/mongo/TestRecord.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.mongo; 7 | 8 | import org.redkale.convert.ConvertColumn; 9 | import org.redkale.convert.json.JsonConvert; 10 | import org.redkale.persistence.*; 11 | 12 | /** @author zhangjx */ 13 | @Entity 14 | public class TestRecord { 15 | 16 | @Id 17 | private String recordid; 18 | 19 | private String name; 20 | 21 | private short status; 22 | 23 | private int score; 24 | 25 | @ConvertColumn(ignore = true) 26 | private long createTime; 27 | 28 | public String getRecordid() { 29 | return recordid; 30 | } 31 | 32 | public void setRecordid(String recordid) { 33 | this.recordid = recordid; 34 | } 35 | 36 | public String getName() { 37 | return name; 38 | } 39 | 40 | public void setName(String name) { 41 | this.name = name; 42 | } 43 | 44 | public short getStatus() { 45 | return status; 46 | } 47 | 48 | public void setStatus(short status) { 49 | this.status = status; 50 | } 51 | 52 | public int getScore() { 53 | return score; 54 | } 55 | 56 | public void setScore(int score) { 57 | this.score = score; 58 | } 59 | 60 | public long getCreateTime() { 61 | return createTime; 62 | } 63 | 64 | public void setCreateTime(long createTime) { 65 | this.createTime = createTime; 66 | } 67 | 68 | @Override 69 | public String toString() { 70 | return JsonConvert.root().convertTo(this); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/mysql/MyClientRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.mysql; 7 | 8 | import java.util.Objects; 9 | import org.redkale.net.client.ClientRequest; 10 | import org.redkale.source.EntityInfo; 11 | import org.redkale.util.ObjectPool; 12 | 13 | /** @author zhangjx */ 14 | public abstract class MyClientRequest extends ClientRequest { 15 | 16 | public static final int REQ_TYPE_AUTH = 1 << 1; 17 | 18 | public static final int REQ_TYPE_QUERY = 1 << 2; 19 | 20 | public static final int REQ_TYPE_UPDATE = 1 << 3; 21 | 22 | public static final int REQ_TYPE_INSERT = 1 << 4; 23 | 24 | public static final int REQ_TYPE_DELETE = 1 << 5; 25 | 26 | public static final int REQ_TYPE_BATCH = 1 << 6; 27 | 28 | public static final int REQ_TYPE_EXTEND_QUERY = (1 << 2) + 1; // 预编译的16进制值都要以1结尾 29 | 30 | public static final int REQ_TYPE_EXTEND_UPDATE = (1 << 3) + 1; // 预编译的16进制值都要以1结尾 31 | 32 | public static final int REQ_TYPE_EXTEND_INSERT = (1 << 4) + 1; // 预编译的16进制值都要以1结尾 33 | 34 | public static final int REQ_TYPE_EXTEND_DELETE = (1 << 5) + 1; // 预编译的16进制值都要以1结尾 35 | 36 | // -------------------------------------------------- 37 | protected ObjectPool objpool; 38 | 39 | protected EntityInfo info; 40 | 41 | protected byte packetIndex; 42 | 43 | public abstract int getType(); 44 | 45 | public MyClientRequest reuse() { 46 | return this; 47 | } 48 | 49 | public String toSimpleString() { 50 | return getClass().getSimpleName() + "_" + Objects.hashCode(this) + "{...}"; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/search/HitResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.search; 7 | 8 | import java.util.*; 9 | import org.redkale.util.Attribute; 10 | import org.redkale.util.Utility; 11 | 12 | /** 13 | * @author zhangjx 14 | * @param T 15 | */ 16 | public class HitResult extends BaseBean { 17 | 18 | public HitTotal total; 19 | 20 | public Float max_score; // 返回值会有null 21 | 22 | public HitEntity[] hits; 23 | 24 | public List list(final SearchInfo info) { 25 | List vals = new ArrayList(); 26 | if (Utility.isEmpty(hits)) { 27 | return vals; 28 | } 29 | Attribute highlightAttrId = info.getHighlightAttributeId(); 30 | Attribute highlightAttrIndex = info.getHighlightAttributeIndex(); 31 | for (HitEntity item : hits) { 32 | T obj = item._source; 33 | vals.add(obj); 34 | if (highlightAttrId != null) highlightAttrId.set(obj, item._id); 35 | if (highlightAttrIndex != null) highlightAttrIndex.set(obj, item._index); 36 | if (obj != null && item.highlight != null) { 37 | item.highlight.forEach((t, v) -> { 38 | Attribute attr = info.getHighlightAttribute(t); 39 | if (attr != null) attr.set(obj, v[0]); 40 | }); 41 | } 42 | } 43 | return vals; 44 | } 45 | 46 | public static class HitTotal extends BaseBean { 47 | 48 | public int value; 49 | 50 | public String relation; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/htel/FreemarkerTemplateRender.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.htel; 7 | 8 | import java.io.*; 9 | import org.redkale.annotation.Resource; 10 | import org.redkale.convert.Convert; 11 | import org.redkale.net.http.*; 12 | import org.redkale.util.*; 13 | 14 | /** @author zhangjx */ 15 | public class FreemarkerTemplateRender implements org.redkale.net.http.HttpRender { 16 | 17 | @Resource(name = "APP_HOME") 18 | private File home; 19 | 20 | private freemarker.template.Configuration engine; 21 | 22 | @Override 23 | public void init(HttpContext context, AnyValue config) { 24 | this.engine = new freemarker.template.Configuration(freemarker.template.Configuration.VERSION_2_3_31); 25 | String path = config == null 26 | ? new File(home, "templates").getPath() 27 | : config.getOrDefault("path", new File(home, "templates").getPath()); 28 | try { 29 | this.engine.setDirectoryForTemplateLoading(new File(path)); 30 | } catch (IOException e) { 31 | throw new RedkaleException(e); 32 | } 33 | } 34 | 35 | @Override 36 | public void renderTo(HttpRequest request, HttpResponse response, Convert convert, HttpScope scope) { 37 | ByteArrayOutputStream out = new ByteArrayOutputStream(); 38 | try { 39 | engine.getTemplate(scope.getReferid()).process(scope.getAttributes(), new OutputStreamWriter(out)); 40 | } catch (Exception e) { 41 | throw new RedkaleException(e); 42 | } 43 | response.finish(out.toByteArray()); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/search/SearchMapping.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.search; 7 | 8 | import java.lang.reflect.Type; 9 | import java.util.Map; 10 | import org.redkale.util.TypeToken; 11 | 12 | /** @author zhangjx */ 13 | public class SearchMapping extends BaseBean { 14 | 15 | public static final Type MAPPING_MAP_TYPE = new TypeToken>() {}.getType(); 16 | 17 | public SearchProperties mappings; 18 | 19 | public static class SearchProperties extends BaseBean { 20 | 21 | public Map properties; 22 | 23 | public boolean equal(Map ms) { 24 | if (properties == null) return false; 25 | if (ms == null) return false; 26 | if (properties.size() != ms.size()) return false; 27 | for (Map.Entry en : properties.entrySet()) { 28 | Map infomap = ms.get(en.getKey()); 29 | if (infomap == null) return false; 30 | Object infoanalyzer = infomap.get("analyzer"); 31 | if (en.getValue().analyzer == null && infoanalyzer != null) return false; 32 | if (en.getValue().analyzer != null && infoanalyzer == null) return false; 33 | if (en.getValue().analyzer != null && !en.getValue().analyzer.equals(infoanalyzer)) return false; 34 | } 35 | return true; 36 | } 37 | } 38 | 39 | public static class MappingItem extends BaseBean { 40 | 41 | public String type; 42 | 43 | public String analyzer; 44 | 45 | public Integer ignore_above; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/test/java/org/redkalex/source/search/TestPostBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.search; 7 | 8 | import org.redkale.annotation.Comment; 9 | import org.redkale.convert.json.JsonConvert; 10 | import org.redkale.persistence.Column; 11 | import org.redkale.source.*; 12 | 13 | /** @author zhangjx */ 14 | public class TestPostBean implements FilterBean { 15 | 16 | @FilterColumn 17 | @Comment("用户ID") 18 | private int userid; 19 | 20 | @FilterColumn 21 | @Comment("文章标题") 22 | private String title = ""; 23 | 24 | @FilterColumn(express = FilterExpress.LIKE) 25 | @Comment("文章公开内容") 26 | private String pubContent = ""; 27 | 28 | @Column(updatable = false, comment = "生成时间,单位毫秒") 29 | private Range.LongRange createTime; 30 | 31 | public int getUserid() { 32 | return userid; 33 | } 34 | 35 | public void setUserid(int userid) { 36 | this.userid = userid; 37 | } 38 | 39 | public String getTitle() { 40 | return title; 41 | } 42 | 43 | public void setTitle(String title) { 44 | this.title = title; 45 | } 46 | 47 | public String getPubContent() { 48 | return pubContent; 49 | } 50 | 51 | public void setPubContent(String pubContent) { 52 | this.pubContent = pubContent; 53 | } 54 | 55 | public Range.LongRange getCreateTime() { 56 | return createTime; 57 | } 58 | 59 | public void setCreateTime(Range.LongRange createTime) { 60 | this.createTime = createTime; 61 | } 62 | 63 | @Override 64 | public String toString() { 65 | return JsonConvert.root().convertTo(this); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/pgsql/PgReqAuthentication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.pgsql; 7 | 8 | import java.util.Objects; 9 | import org.redkale.net.client.ClientConnection; 10 | import org.redkale.source.AbstractDataSource.SourceUrlInfo; 11 | import org.redkale.util.ByteArray; 12 | 13 | /** @author zhangjx */ 14 | public class PgReqAuthentication extends PgClientRequest { 15 | 16 | protected final SourceUrlInfo urlInfo; 17 | 18 | public PgReqAuthentication(SourceUrlInfo urlInfo) { 19 | this.urlInfo = urlInfo; 20 | } 21 | 22 | @Override 23 | public int getType() { 24 | return REQ_TYPE_AUTH; 25 | } 26 | 27 | @Override 28 | public String toString() { 29 | return "PgReqAuthentication_" + Objects.hashCode(this) + "{username=" + urlInfo.username + ", password=" 30 | + urlInfo.password + ", database=" + urlInfo.database + "}"; 31 | } 32 | 33 | @Override 34 | public void writeTo(ClientConnection conn, ByteArray array) { 35 | int start = array.length(); 36 | array.putInt(0); 37 | array.putInt(196608); 38 | writeUTF8String(writeUTF8String(array, "user"), urlInfo.username); 39 | writeUTF8String(writeUTF8String(array, "database"), urlInfo.database); 40 | writeUTF8String(writeUTF8String(array, "client_encoding"), "UTF8"); 41 | writeUTF8String(writeUTF8String(array, "application_name"), "redkalex-pgsql-client"); 42 | writeUTF8String(writeUTF8String(array, "DateStyle"), "ISO"); 43 | writeUTF8String(writeUTF8String(array, "extra_float_digits"), "2"); 44 | array.putByte(0); 45 | array.putInt(start, array.length() - start); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/pgsql/PgRespRowDescDecoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.pgsql; 7 | 8 | import static org.redkalex.source.pgsql.PgClientCodec.*; 9 | 10 | import java.nio.ByteBuffer; 11 | import org.redkale.source.SourceException; 12 | import org.redkale.util.ByteArray; 13 | 14 | /** @author zhangjx */ 15 | public class PgRespRowDescDecoder extends PgRespDecoder { 16 | 17 | public static final PgRespRowDescDecoder instance = new PgRespRowDescDecoder(); 18 | 19 | private PgRespRowDescDecoder() {} 20 | 21 | @Override 22 | public byte messageid() { 23 | return MESSAGE_TYPE_ROW_DESCRIPTION; // 'T' 24 | } 25 | 26 | @Override 27 | public PgRowDesc read( 28 | PgClientConnection conn, 29 | ByteBuffer buffer, 30 | final int length, 31 | ByteArray array, 32 | PgClientRequest request, 33 | PgResultSet dataset) { 34 | PgRowColumn[] columns = new PgRowColumn[buffer.getShort()]; 35 | PgColumnFormat[] formats = new PgColumnFormat[columns.length]; 36 | for (int i = 0; i < columns.length; i++) { 37 | String name = PgClientCodec.readUTF8String(buffer, array); 38 | buffer.position(buffer.position() + 6); 39 | int oid = buffer.getInt(); 40 | buffer.position(buffer.position() + 8); 41 | columns[i] = new PgRowColumn(name, oid); 42 | formats[i] = PgColumnFormat.valueOf(oid); 43 | if (formats[i].decoder() == null) { 44 | throw new SourceException("Unsupported data decode ColumnFormat: " + formats[i]); 45 | } 46 | } 47 | return new PgRowDesc(columns, formats); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/pay/PayCreatResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.pay; 7 | 8 | import java.util.Map; 9 | import org.redkale.convert.ConvertDisabled; 10 | import org.redkale.util.Copier; 11 | 12 | /** 13 | * 详情见: https://redkale.org 14 | * 15 | * @author zhangjx 16 | */ 17 | public class PayCreatResponse extends PayResponse { 18 | 19 | private static final Copier copier = 20 | Copier.create(PayPreResponse.class, PayCreatResponse.class); 21 | 22 | private String thirdPayno = ""; // 第三方的支付流水号 23 | 24 | public PayCreatResponse() {} 25 | 26 | public PayCreatResponse(PayPreResponse resp) { 27 | copier.apply(resp, this); 28 | } 29 | 30 | @Override 31 | public PayCreatResponse retcode(int retcode) { 32 | this.retcode = retcode; 33 | this.retinfo = PayRetCodes.retInfo(retcode); 34 | return this; 35 | } 36 | 37 | @Override 38 | public PayCreatResponse retinfo(String retinfo) { 39 | if (retinfo != null) { 40 | this.retinfo = retinfo; 41 | } 42 | return this; 43 | } 44 | 45 | @Override 46 | public PayCreatResponse result(Map result) { 47 | this.setResult(result); 48 | return this; 49 | } 50 | 51 | public String getThirdPayno() { 52 | return thirdPayno; 53 | } 54 | 55 | public void setThirdPayno(String thirdPayno) { 56 | this.thirdPayno = thirdPayno; 57 | } 58 | 59 | @Deprecated 60 | @ConvertDisabled 61 | public String getThirdpayno() { 62 | return thirdPayno; 63 | } 64 | 65 | @Deprecated 66 | @ConvertDisabled 67 | public void setThirdpayno(String thirdPayno) { 68 | this.thirdPayno = thirdPayno; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/pgsql/PgReqAuthScramSaslContinueResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.pgsql; 7 | 8 | import org.redkale.convert.json.JsonConvert; 9 | 10 | /** @author zhangjx */ 11 | public class PgReqAuthScramSaslContinueResult { 12 | 13 | public String saslmsg; // r=hu~1A]pOoftNMKg<~YWKp`1^F2avWJEdla6IQr3BiNBORfiy,s=1uyIEWcUJVLPlhSivlUMZg==,i=4096 14 | 15 | protected String username; 16 | 17 | public String password; 18 | 19 | public String clientNonce; // hu~1A]pOoftNMKg<~YWKp`1^ 20 | 21 | public String serverNonce; // F2avWJEdla6IQr3BiNBORfiy 22 | 23 | public String salt; // 1uyIEWcUJVLPlhSivlUMZg== 24 | 25 | public int iteration; // 4096 26 | 27 | public PgReqAuthScramSaslContinueResult(PgReqAuthScramPassword req, String saslmsg) { 28 | String[] msgs = saslmsg.split(","); 29 | this.saslmsg = saslmsg; 30 | this.username = req.username; 31 | this.password = req.password; 32 | this.clientNonce = req.clientNonce; 33 | if (!msgs[0].startsWith("r=" + clientNonce)) { 34 | throw new IllegalArgumentException("parsed serverNonce does not start with client serverNonce"); 35 | } 36 | if (!msgs[1].startsWith("s=")) { 37 | throw new IllegalArgumentException("not found salt value"); 38 | } 39 | if (!msgs[2].startsWith("i=")) { 40 | throw new IllegalArgumentException("not found iteration value"); 41 | } 42 | this.serverNonce = msgs[0].substring(clientNonce.length() + 2); 43 | this.salt = msgs[1].substring(2); 44 | this.iteration = Integer.parseInt(msgs[2].substring(2)); 45 | } 46 | 47 | @Override 48 | public String toString() { 49 | return JsonConvert.root().convertTo(this); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/mysql/MyRespRowColumnDecoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.mysql; 7 | 8 | import static org.redkalex.source.mysql.MysqlType.ColumnFlags.UNSIGNED_FLAG; 9 | import static org.redkalex.source.mysql.MysqlType.FIELD_FLAG_BINARY; 10 | 11 | import java.nio.ByteBuffer; 12 | import org.redkale.util.ByteArray; 13 | 14 | /** @author zhangjx */ 15 | public class MyRespRowColumnDecoder extends MyRespDecoder { 16 | 17 | public static final MyRespRowColumnDecoder instance = new MyRespRowColumnDecoder(); 18 | 19 | @Override 20 | public MyRowColumn read( 21 | MyClientConnection conn, 22 | ByteBuffer buffer, 23 | int length, 24 | byte index, 25 | ByteArray array, 26 | MyClientRequest request, 27 | MyResultSet dataset) { 28 | MyRowColumn column = new MyRowColumn(); 29 | column.catalog = Mysqls.readBytesWithLength(buffer); 30 | column.schema = Mysqls.readBytesWithLength(buffer); 31 | column.tableLabel = Mysqls.readBytesWithLength(buffer); 32 | column.tableName = Mysqls.readBytesWithLength(buffer); 33 | column.columnLabel = new String(Mysqls.readBytesWithLength(buffer)); 34 | column.columnName = new String(Mysqls.readBytesWithLength(buffer)); 35 | buffer.get(); // nextLength : always 0x0c 12 36 | column.charsetSet = Mysqls.readUB2(buffer); 37 | column.length = Mysqls.readUB4(buffer); 38 | column.type = buffer.get() & 0xff; 39 | column.flags = Mysqls.readUB2(buffer); 40 | column.decimals = buffer.get(); 41 | column.binary = (column.flags & FIELD_FLAG_BINARY) > 0; 42 | column.unsign = (column.flags & UNSIGNED_FLAG) != 0; 43 | return column; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/test/java/org/redkalex/source/pgsql/PgSQLJdbcTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | */ 4 | package org.redkalex.source.pgsql; 5 | 6 | import java.util.Properties; 7 | import org.redkale.inject.ResourceFactory; 8 | import org.redkale.source.DataJdbcSource; 9 | import org.redkale.util.*; 10 | import org.redkalex.source.base.IncreWorld; 11 | 12 | /** @author zhangjx */ 13 | public class PgSQLJdbcTest { 14 | 15 | private static final String url = "jdbc:postgresql://127.0.0.1:5432/hello_world"; 16 | 17 | private static final String user = "postgres"; 18 | 19 | private static final String password = "1234"; 20 | 21 | public static void main(String[] args) throws Throwable { 22 | Properties prop = new Properties(); 23 | prop.setProperty("redkale.datasource.default.url", url); 24 | prop.setProperty("redkale.datasource.default.table-autoddl", "true"); 25 | prop.setProperty("redkale.datasource.default.user", user); 26 | prop.setProperty("redkale.datasource.default.password", password); 27 | 28 | ResourceFactory factory = ResourceFactory.create(); 29 | DataJdbcSource source = new DataJdbcSource(); 30 | factory.inject(source); 31 | source.init(AnyValue.loadFromProperties(prop) 32 | .getAnyValue("redkale") 33 | .getAnyValue("datasource") 34 | .getAnyValue("default")); 35 | System.out.println("---------"); 36 | 37 | source.dropTable(IncreWorld.class); 38 | IncreWorld in1 = new IncreWorld(); 39 | in1.setRandomNumber(11); 40 | IncreWorld in2 = new IncreWorld(); 41 | in2.setRandomNumber(22); 42 | source.insert(in1, in2); 43 | System.out.println("IncreWorld记录: " + in1); 44 | System.out.println("IncreWorld记录: " + in2); 45 | 46 | System.out.println("---------------- 准备关闭DataSource ----------------"); 47 | source.close(); 48 | System.out.println("---------------- 全部执行完毕 ----------------"); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/cache/redis/RedisCacheConnection.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.cache.redis; 7 | 8 | import java.io.Serializable; 9 | import java.util.concurrent.CompletableFuture; 10 | import java.util.function.Function; 11 | import org.redkale.net.*; 12 | import org.redkale.net.client.*; 13 | 14 | /** @author zhangjx */ 15 | public class RedisCacheConnection extends ClientConnection { 16 | 17 | public RedisCacheConnection(Client client, AsyncConnection channel) { 18 | super(client, channel); 19 | } 20 | 21 | @Override 22 | protected ClientCodec createCodec() { 23 | return new RedisCacheCodec(this); 24 | } 25 | 26 | protected CompletableFuture writeRequest(RedisCacheRequest request) { 27 | return super.writeChannel(request); 28 | } 29 | 30 | protected CompletableFuture[] writeRequest(RedisCacheRequest[] requests) { 31 | return super.writeChannel(requests); 32 | } 33 | 34 | protected CompletableFuture writeRequest( 35 | Function respTransfer, RedisCacheRequest request) { 36 | return super.writeChannel(respTransfer, request); 37 | } 38 | 39 | protected CompletableFuture[] writeRequest( 40 | Function respTransfer, RedisCacheRequest[] requests) { 41 | return super.writeChannel(respTransfer, requests); 42 | } 43 | 44 | public RedisCacheResult pollResultSet(RedisCacheRequest request) { 45 | RedisCacheResult rs = new RedisCacheResult(); 46 | return rs; 47 | } 48 | 49 | protected ClientFuture pollRespFuture(Serializable requestid) { 50 | return super.pollRespFuture(requestid); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/mysql/MyRowData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.mysql; 7 | 8 | import java.io.Serializable; 9 | import java.nio.charset.StandardCharsets; 10 | import java.util.Arrays; 11 | 12 | /** @author zhangjx */ 13 | public class MyRowData { 14 | 15 | final byte[][] byteBalues; 16 | 17 | final Serializable[] realValues; 18 | 19 | public MyRowData(byte[][] byteBalues, Serializable[] realValues) { 20 | this.byteBalues = byteBalues; 21 | this.realValues = realValues; 22 | } 23 | 24 | public Serializable getObject(MyRowDesc rowDesc, int i) { 25 | if (realValues != null) { 26 | return realValues[i]; 27 | } 28 | byte[] bs = byteBalues[i]; 29 | MyRowColumn colDesc = rowDesc.getColumn(i); 30 | if (bs == null) { 31 | return null; 32 | } 33 | return colDesc.getObject(bs); 34 | } 35 | 36 | @Override 37 | public String toString() { 38 | if (realValues != null) { 39 | return Arrays.toString(realValues).replace('[', '{').replace(']', '}'); 40 | } 41 | int size = byteBalues == null ? -1 : byteBalues.length; 42 | StringBuilder sb = new StringBuilder(); 43 | sb.append(MyRowData.class.getSimpleName()).append('{'); 44 | if (size < 1) { 45 | sb.append("[size]:").append(size); 46 | } else { 47 | StringBuilder d = new StringBuilder(); 48 | for (int i = 0; i < size; i++) { 49 | if (d.length() > 0) { 50 | d.append(','); 51 | } 52 | d.append(new String(byteBalues[0], StandardCharsets.UTF_8)); 53 | } 54 | sb.append(d); 55 | } 56 | return sb.append('}').toString(); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/pay/PayPreResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.pay; 7 | 8 | import java.util.Map; 9 | import org.redkale.convert.*; 10 | 11 | /** 12 | * 详情见: https://redkale.org 13 | * 14 | * @author zhangjx 15 | */ 16 | public class PayPreResponse extends PayResponse { 17 | 18 | public static final String PREPAY_PREPAYID = "prepayid"; 19 | 20 | public static final String PREPAY_PAYURL = "payurl"; 21 | 22 | @ConvertColumn(ignore = true, type = ConvertType.JSON) 23 | private String appid = ""; 24 | 25 | private String thirdPayno = ""; // 第三方的支付流水号 26 | 27 | @Override 28 | public PayPreResponse retcode(int retcode) { 29 | this.retcode = retcode; 30 | this.retinfo = PayRetCodes.retInfo(retcode); 31 | return this; 32 | } 33 | 34 | @Override 35 | public PayPreResponse retinfo(String retinfo) { 36 | if (retinfo != null) this.retinfo = retinfo; 37 | return this; 38 | } 39 | 40 | @Override 41 | public PayPreResponse result(Map result) { 42 | this.setResult(result); 43 | return this; 44 | } 45 | 46 | public String getThirdPayno() { 47 | return thirdPayno; 48 | } 49 | 50 | public void setThirdPayno(String thirdPayno) { 51 | this.thirdPayno = thirdPayno; 52 | } 53 | 54 | public String getAppid() { 55 | return appid == null ? "" : appid; 56 | } 57 | 58 | public void setAppid(String appid) { 59 | this.appid = appid; 60 | } 61 | 62 | @Deprecated 63 | @ConvertDisabled 64 | public String getThirdpayno() { 65 | return thirdPayno; 66 | } 67 | 68 | @Deprecated 69 | @ConvertDisabled 70 | public void setThirdpayno(String thirdPayno) { 71 | this.thirdPayno = thirdPayno; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/mongo/MongodbDataSource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | */ 4 | 5 | package org.redkalex.source.mongo; 6 | 7 | import com.mongodb.client.model.BsonField; 8 | import com.mongodb.reactivestreams.client.MongoClient; 9 | import com.mongodb.reactivestreams.client.MongoCollection; 10 | import com.mongodb.reactivestreams.client.MongoDatabase; 11 | import java.io.Serializable; 12 | import java.util.List; 13 | import org.bson.Document; 14 | import org.bson.conversions.Bson; 15 | import org.redkale.source.AbstractDataSource; 16 | import org.redkale.source.ColumnValue; 17 | import org.redkale.source.EntityInfo; 18 | import org.redkale.source.FilterFunc; 19 | import org.redkale.source.FilterNode; 20 | import org.redkale.source.Flipper; 21 | 22 | /** 23 | * 24 | * @author zhangjx 25 | */ 26 | public abstract class MongodbDataSource extends AbstractDataSource { 27 | 28 | public abstract MongoClient getReadMongoClient(); 29 | 30 | public abstract MongoDatabase getReadMongoDatabase(); 31 | 32 | public abstract MongoCollection getReadMongoCollection(EntityInfo info); 33 | 34 | public abstract MongoCollection getReadMongoDocumentCollection(EntityInfo info); 35 | 36 | public abstract MongoClient getWriteMongoClient(); 37 | 38 | public abstract MongoDatabase getWriteMongoDatabase(); 39 | 40 | public abstract MongoCollection getWriteMongoCollection(EntityInfo info); 41 | 42 | public abstract MongoCollection getWriteMongoDocumentCollection(EntityInfo info); 43 | 44 | public abstract Bson createSortBson(Flipper flipper); 45 | 46 | public abstract List createUpdateBson(EntityInfo info, ColumnValue... values); 47 | 48 | public abstract Bson createUpdateBson(EntityInfo info, ColumnValue colval); 49 | 50 | public abstract BsonField createBsonField(FilterFunc func, String fieldName, Serializable column); 51 | 52 | public abstract Bson createFilterBson(EntityInfo info, FilterNode node); 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/mysql/MyReqUpdate.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.mysql; 7 | 8 | import static org.redkalex.source.mysql.Mysqls.COM_QUERY; 9 | 10 | import java.io.Serializable; 11 | import java.nio.charset.StandardCharsets; 12 | import java.util.Objects; 13 | import org.redkale.convert.json.JsonConvert; 14 | import org.redkale.net.client.ClientConnection; 15 | import org.redkale.util.*; 16 | 17 | /** @author zhangjx */ 18 | public class MyReqUpdate extends MyClientRequest { 19 | 20 | protected int fetchSize; 21 | 22 | protected Attribute[] attrs; 23 | 24 | protected String sql; 25 | 26 | protected Object[][] parameters; 27 | 28 | public MyReqUpdate prepare(String sql) { 29 | prepare(sql, 0, null); 30 | return this; 31 | } 32 | 33 | public MyReqUpdate prepare( 34 | String sql, int fetchSize, final Attribute[] attrs, final Object[]... parameters) { 35 | super.prepare(); 36 | this.sql = sql; 37 | this.fetchSize = fetchSize; 38 | this.attrs = attrs; 39 | this.parameters = parameters; 40 | return this; 41 | } 42 | 43 | @Override 44 | public int getType() { 45 | return REQ_TYPE_UPDATE; 46 | } 47 | 48 | @Override 49 | public String toString() { 50 | return "MyReqUpdate_" + Objects.hashCode(this) + "{sql=" + sql + ", parameters=" 51 | + JsonConvert.root().convertTo(parameters) + "}"; 52 | } 53 | 54 | @Override 55 | public void writeTo(ClientConnection conn, ByteArray array) { 56 | byte[] sqlbytes = sql.getBytes(StandardCharsets.UTF_8); 57 | Mysqls.writeUB3(array, 1 + sqlbytes.length); 58 | array.put(packetIndex); 59 | array.put(COM_QUERY); 60 | array.put(sqlbytes); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/test/java/org/redkalex/source/mysql/MySourceTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | */ 3 | package org.redkalex.source.mysql; 4 | 5 | import static org.redkale.boot.Application.RESNAME_APP_CLIENT_ASYNCGROUP; 6 | 7 | import java.util.Properties; 8 | import org.redkale.boot.LoggingFileHandler; 9 | import org.redkale.inject.ResourceFactory; 10 | import org.redkale.net.AsyncIOGroup; 11 | import org.redkale.util.*; 12 | 13 | /** @author zhangjx */ 14 | public class MySourceTest { 15 | 16 | public static void main(String[] args) throws Throwable { 17 | 18 | LoggingFileHandler.initDebugLogConfig(); 19 | final AsyncIOGroup asyncGroup = new AsyncIOGroup(8192, 16); 20 | asyncGroup.start(); 21 | ResourceFactory factory = ResourceFactory.create(); 22 | factory.register(RESNAME_APP_CLIENT_ASYNCGROUP, asyncGroup); 23 | 24 | Properties prop = new Properties(); 25 | prop.setProperty( 26 | "redkale.datasource.default.url", 27 | "jdbc:mysql://127.0.0.1:3389/aa_test?useSSL=false&rewriteBatchedStatements=true&serverTimezone=UTC&characterEncoding=utf8"); 28 | prop.setProperty("redkale.datasource.default.table-autoddl", "true"); 29 | prop.setProperty("redkale.datasource.default.user", "root"); 30 | prop.setProperty("redkale.datasource.default.password", ""); 31 | 32 | MysqlDataSource source = new MysqlDataSource(); 33 | factory.inject(source); 34 | source.init(AnyValue.loadFromProperties(prop) 35 | .getAnyValue("redkale") 36 | .getAnyValue("datasource") 37 | .getAnyValue("default")); 38 | System.out.println("---------"); 39 | source.clearTable(World.class); 40 | World[] words = new World[10000]; 41 | for (int i = 0; i < words.length; i++) { 42 | words[i] = new World(); 43 | words[i].id = i + 1; 44 | words[i].randomNumber = i + 1; 45 | } 46 | source.insert(words); 47 | source.close(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/pgsql/PgRowData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.pgsql; 7 | 8 | import java.io.Serializable; 9 | import java.nio.charset.StandardCharsets; 10 | import java.util.Arrays; 11 | 12 | /** @author zhangjx */ 13 | public class PgRowData { 14 | 15 | static final PgRowData NIL = new PgRowData(null, null); 16 | 17 | final byte[][] byteBalues; 18 | 19 | final Serializable[] realValues; 20 | 21 | public PgRowData(byte[][] byteBalues, Serializable[] realValues) { 22 | this.byteBalues = byteBalues; 23 | this.realValues = realValues; 24 | } 25 | 26 | public Serializable getObject(PgRowDesc rowDesc, int i) { 27 | if (realValues != null) { 28 | return realValues[i]; 29 | } 30 | byte[] bs = byteBalues[i]; 31 | PgRowColumn colDesc = rowDesc.getColumn(i); 32 | if (bs == null) { 33 | return null; 34 | } 35 | return colDesc.getObject(bs); 36 | } 37 | 38 | @Override 39 | public String toString() { 40 | if (realValues != null) { 41 | return Arrays.toString(realValues).replace('[', '{').replace(']', '}'); 42 | } 43 | int size = byteBalues == null ? -1 : byteBalues.length; 44 | StringBuilder sb = new StringBuilder(); 45 | sb.append(PgRowData.class.getSimpleName()).append('{'); 46 | if (size < 1) { 47 | sb.append("[size]:").append(size); 48 | } else { 49 | StringBuilder d = new StringBuilder(); 50 | for (int i = 0; i < size; i++) { 51 | if (d.length() > 0) { 52 | d.append(','); 53 | } 54 | d.append(new String(byteBalues[0], StandardCharsets.UTF_8)); 55 | } 56 | sb.append(d); 57 | } 58 | return sb.append('}').toString(); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/search/SearchResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.search; 7 | 8 | import java.lang.reflect.Type; 9 | import java.util.*; 10 | import org.redkale.convert.json.JsonConvert; 11 | 12 | /** 13 | * @author zhangjx 14 | * @param T 15 | */ 16 | public class SearchResult extends BaseBean { 17 | 18 | public int took; // 操作耗时 19 | 20 | public boolean timed_out; 21 | 22 | public ShardResult _shards; 23 | 24 | public HitResult hits; 25 | 26 | public Map aggregations; 27 | 28 | public static class Aggregations extends BaseBean { 29 | 30 | public int doc_count_error_upper_bound; 31 | 32 | public int sum_other_doc_count; 33 | 34 | public BucketItem[] buckets; 35 | 36 | public double value; // 等同func_count.value 简化方式 37 | 38 | public T forEachCount(JsonConvert convert, Type itemType, T c) { 39 | if (buckets == null) return c; 40 | for (BucketItem item : buckets) { 41 | if (item == null || item.key == null) continue; 42 | c.add(itemType == String.class ? item.key : convert.convertFrom(itemType, item.key)); 43 | } 44 | return c; 45 | } 46 | } 47 | 48 | public static class BucketItem extends BaseBean { 49 | 50 | public String key; 51 | 52 | public int doc_count; 53 | 54 | public BucketItemCount count; 55 | 56 | public BucketItemFuncCount func_count; 57 | 58 | public double funcCount() { 59 | return func_count == null ? 0.0 : func_count.value; 60 | } 61 | } 62 | 63 | public static class BucketItemCount extends BaseBean { 64 | 65 | public int value; 66 | } 67 | 68 | public static class BucketItemFuncCount extends BaseBean { 69 | 70 | public double value; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/parser/NativeCountDeParser.java: -------------------------------------------------------------------------------- 1 | /* - 2 | * #%L 3 | * JSQLParser library 4 | * %% 5 | * Copyright (C) 2004 - 2019 JSQLParser 6 | * %% 7 | * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 8 | * #L% 9 | * 10 | * 复制过来增加deparseWhereClause方法 11 | */ 12 | package org.redkalex.source.parser; 13 | 14 | import java.util.List; 15 | import net.sf.jsqlparser.expression.ExpressionVisitor; 16 | import net.sf.jsqlparser.statement.select.Distinct; 17 | import net.sf.jsqlparser.statement.select.OrderByElement; 18 | import net.sf.jsqlparser.statement.select.PlainSelect; 19 | import net.sf.jsqlparser.statement.select.SelectItem; 20 | 21 | public class NativeCountDeParser extends CustomSelectDeParser { 22 | 23 | private PlainSelect countSelect; 24 | 25 | private List> countRootSelectItems; 26 | 27 | public NativeCountDeParser(ExpressionVisitor expressionVisitor, StringBuilder buffer) { 28 | super(expressionVisitor, buffer); 29 | } 30 | 31 | public void initCountSelect(PlainSelect countSelect, List> countSelectItems) { 32 | this.countSelect = countSelect; 33 | this.countRootSelectItems = countSelectItems; 34 | } 35 | 36 | @Override 37 | protected void deparseDistinctClause(PlainSelect plainSelect, Distinct distinct) { 38 | if (this.countSelect != plainSelect) { 39 | super.deparseDistinctClause(plainSelect, distinct); 40 | } 41 | } 42 | 43 | @Override 44 | protected void deparseSelectItemsClause(PlainSelect plainSelect, List> selectItems) { 45 | if (this.countSelect != plainSelect) { 46 | super.deparseSelectItemsClause(plainSelect, selectItems); 47 | } else { 48 | super.deparseSelectItemsClause(plainSelect, this.countRootSelectItems); 49 | } 50 | } 51 | 52 | @Override 53 | protected void deparseOrderByElementsClause(PlainSelect plainSelect, List orderByElements) { 54 | if (this.countSelect != plainSelect) { 55 | super.deparseOrderByElementsClause(plainSelect, orderByElements); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/yaml/SnakeYamlLoader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | */ 4 | 5 | package org.redkalex.yaml; 6 | 7 | import java.util.Collection; 8 | import java.util.Map; 9 | import org.redkale.convert.json.JsonConvert; 10 | import org.redkale.util.AnyValue; 11 | import org.redkale.util.AnyValueWriter; 12 | import org.redkale.util.YamlProvider; 13 | import org.yaml.snakeyaml.Yaml; 14 | 15 | /** 16 | * 17 | * @author zhangjx 18 | */ 19 | public class SnakeYamlLoader implements YamlProvider.YamlLoader { 20 | 21 | /** 22 | * 将yml内容转换成AnyValue 23 | * 24 | * @param content yml内容 25 | * @return AnyValue 26 | */ 27 | @Override 28 | public AnyValue read(String content) { 29 | Map map = new Yaml().load(content); 30 | AnyValueWriter writer = AnyValue.create(); 31 | read(writer, map); 32 | return writer; 33 | } 34 | 35 | protected static void read(AnyValueWriter writer, Map map) { 36 | map.forEach((k, v) -> { 37 | if (v == null) { 38 | writer.addValue(k, (String) null); 39 | } else if (v instanceof Map) { 40 | AnyValueWriter item = AnyValue.create(); 41 | writer.addValue(k, item); 42 | read(item, (Map) v); 43 | } else if (v instanceof Collection) { 44 | read(writer, k, (Collection) v); 45 | } else { 46 | writer.addValue(k, JsonConvert.root().convertTo(v)); 47 | } 48 | }); 49 | } 50 | 51 | protected static void read(AnyValueWriter writer, String k, Collection list) { 52 | for (Object v : list) { 53 | if (v == null) { 54 | writer.addValue(k, (String) null); 55 | } else if (v instanceof Map) { 56 | AnyValueWriter item = AnyValue.create(); 57 | writer.addValue(k, item); 58 | read(item, (Map) v); 59 | } else if (v instanceof Collection) { 60 | read(writer, k, (Collection) v); 61 | } else { 62 | writer.addValue(k, JsonConvert.root().convertTo(v)); 63 | } 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/test/java/org/redkalex/convert/pb/ArrayBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.convert.pb; 7 | 8 | import java.util.*; 9 | import org.redkale.convert.pb.ProtobufConvert; 10 | import org.redkale.util.Utility; 11 | 12 | /** @author zhangjx */ 13 | public class ArrayBean { 14 | 15 | public static class IntArrayBean { 16 | 17 | public int[] values1; 18 | } 19 | 20 | public static class IntListBean { 21 | 22 | public List values2; 23 | } 24 | 25 | public static class IntegerArrayBean { 26 | 27 | public Integer[] values3; 28 | } 29 | 30 | public static void main(String[] args) throws Throwable { 31 | IntArrayBean bean1 = new IntArrayBean(); 32 | bean1.values1 = new int[] {2, 3, 4}; 33 | IntListBean bean2 = new IntListBean(); 34 | bean2.values2 = Utility.ofList(2, 3, 4); 35 | IntegerArrayBean bean3 = new IntegerArrayBean(); 36 | bean3.values3 = new Integer[] {2, 3, 4}; 37 | byte[] bs1 = ProtobufConvert.root().convertTo(bean1); 38 | byte[] bs2 = ProtobufConvert.root().convertTo(bean2); 39 | byte[] bs3 = ProtobufConvert.root().convertTo(bean3); 40 | if (!Arrays.equals(bs1, bs2)) { 41 | Utility.println("int数组: ", bs1); 42 | Utility.println("int列表: ", bs2); 43 | } else if (!Arrays.equals(bs1, bs3)) { 44 | Utility.println("int数组: ", bs1); 45 | Utility.println("int集合: ", bs3); 46 | } else { 47 | System.out.println("两者相同"); 48 | } 49 | IntArrayBean bean11 = ProtobufConvert.root().convertFrom(IntArrayBean.class, bs1); 50 | IntListBean bean22 = ProtobufConvert.root().convertFrom(IntListBean.class, bs2); 51 | IntegerArrayBean bean33 = ProtobufConvert.root().convertFrom(IntegerArrayBean.class, bs3); 52 | System.out.println(Arrays.toString(bean11.values1)); 53 | System.out.println(bean22.values2); 54 | System.out.println(Arrays.toString(bean33.values3)); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/pay/PayRetCodes.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.pay; 7 | 8 | import java.util.concurrent.atomic.AtomicBoolean; 9 | import org.redkale.annotation.AutoLoad; 10 | import org.redkale.service.*; 11 | 12 | /** 13 | * 详情见: https://redkale.org 14 | * 15 | * @author zhangjx 16 | */ 17 | @AutoLoad(false) 18 | public abstract class PayRetCodes extends RetCodes { 19 | 20 | protected PayRetCodes() {} 21 | 22 | // --------------------------------------------- 支付模块结果码 ---------------------------------------------- 23 | @RetLabel("支付失败") 24 | public static final int RETPAY_PAY_ERROR = 20010001; 25 | 26 | @RetLabel("第三方支付失败") 27 | public static final int RETPAY_PAY_FAILED = 20010002; 28 | 29 | @RetLabel("支付配置异常") 30 | public static final int RETPAY_CONF_ERROR = 20010003; 31 | 32 | @RetLabel("重复支付") 33 | public static final int RETPAY_PAY_REPEAT = 20010004; 34 | 35 | @RetLabel("等待用户支付") 36 | public static final int RETPAY_PAY_WAITING = 20010005; 37 | 38 | @RetLabel("不支持的支付类型") 39 | public static final int RETPAY_PAY_TYPEILLEGAL = 20010006; 40 | 41 | @RetLabel("支付超时") 42 | public static final int RETPAY_PAY_EXPIRED = 20010007; 43 | 44 | @RetLabel("支付信息不存在") 45 | public static final int RETPAY_PAY_RECORD_ILLEGAL = 20010008; 46 | 47 | @RetLabel("交易签名被篡改") 48 | public static final int RETPAY_FALSIFY_ERROR = 20010011; 49 | 50 | @RetLabel("支付状态异常") 51 | public static final int RETPAY_STATUS_ERROR = 20010012; 52 | 53 | @RetLabel("退款异常") 54 | public static final int RETPAY_REFUND_ERROR = 20010013; 55 | 56 | @RetLabel("退款失败") 57 | public static final int RETPAY_REFUND_FAILED = 20010014; 58 | 59 | @RetLabel("用户标识缺失") 60 | public static final int RETPAY_PARAM_ERROR = 20010021; 61 | 62 | protected static AtomicBoolean loaded = new AtomicBoolean(); 63 | 64 | static void init() { 65 | if (loaded.compareAndSet(false, true)) { 66 | RetCodes.load(PayRetCodes.class); 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/test/java/org/redkalex/convert/pb/User.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016-2116 Redkale 3 | * All rights reserved. 4 | */ 5 | package org.redkalex.convert.pb; 6 | 7 | import java.util.Date; 8 | import org.redkale.convert.ConvertColumn; 9 | import org.redkale.convert.json.JsonConvert; 10 | 11 | /** 12 | * 13 | * @author zhangjx 14 | */ 15 | public class User { 16 | @ConvertColumn(index = 3) 17 | private Long id; 18 | 19 | @ConvertColumn(index = 4) 20 | private String name; 21 | 22 | @ConvertColumn(index = 5) 23 | private String nickName; 24 | 25 | @ConvertColumn(index = 1) 26 | private Integer age; 27 | 28 | @ConvertColumn(index = 6) 29 | private String sex; 30 | 31 | @ConvertColumn(index = 2) 32 | private Date createTime; 33 | 34 | public static User create() { 35 | User user = new User(); 36 | user.setId(1L); 37 | user.setName("Hello"); 38 | user.setAge(18); 39 | user.setSex("男"); 40 | user.setNickName("测试号"); 41 | user.setCreateTime(new Date(1451577600000L)); 42 | return user; 43 | } 44 | 45 | public Long getId() { 46 | return id; 47 | } 48 | 49 | public void setId(Long id) { 50 | this.id = id; 51 | } 52 | 53 | public String getName() { 54 | return name; 55 | } 56 | 57 | public void setName(String name) { 58 | this.name = name; 59 | } 60 | 61 | public String getNickName() { 62 | return nickName; 63 | } 64 | 65 | public void setNickName(String nickName) { 66 | this.nickName = nickName; 67 | } 68 | 69 | public Integer getAge() { 70 | return age; 71 | } 72 | 73 | public void setAge(Integer age) { 74 | this.age = age; 75 | } 76 | 77 | public String getSex() { 78 | return sex; 79 | } 80 | 81 | public void setSex(String sex) { 82 | this.sex = sex; 83 | } 84 | 85 | public Date getCreateTime() { 86 | return createTime; 87 | } 88 | 89 | public void setCreateTime(Date createTime) { 90 | this.createTime = createTime; 91 | } 92 | 93 | @Override 94 | public String toString() { 95 | return JsonConvert.root().convertTo(this); 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/pay/PayQueryResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.pay; 7 | 8 | import java.util.Map; 9 | import org.redkale.convert.ConvertDisabled; 10 | 11 | /** 12 | * 详情见: https://redkale.org 13 | * 14 | * @author zhangjx 15 | */ 16 | public class PayQueryResponse extends PayResponse { 17 | 18 | protected short payStatus; 19 | 20 | protected long payedMoney; 21 | 22 | protected String thirdPayno = ""; // 第三方的支付流水号 23 | 24 | @Override 25 | public PayQueryResponse retcode(int retcode) { 26 | this.retcode = retcode; 27 | this.retinfo = PayRetCodes.retInfo(retcode); 28 | return this; 29 | } 30 | 31 | @Override 32 | public PayQueryResponse retinfo(String retinfo) { 33 | if (retinfo != null) this.retinfo = retinfo; 34 | return this; 35 | } 36 | 37 | @Override 38 | public PayQueryResponse result(Map result) { 39 | this.setResult(result); 40 | return this; 41 | } 42 | 43 | public long getPayedMoney() { 44 | return payedMoney; 45 | } 46 | 47 | public void setPayedMoney(long payedMoney) { 48 | this.payedMoney = payedMoney; 49 | } 50 | 51 | public short getPayStatus() { 52 | return payStatus; 53 | } 54 | 55 | public void setPayStatus(short payStatus) { 56 | this.payStatus = payStatus; 57 | } 58 | 59 | public String getThirdPayno() { 60 | return thirdPayno; 61 | } 62 | 63 | public void setThirdPayno(String thirdPayno) { 64 | this.thirdPayno = thirdPayno; 65 | } 66 | 67 | @Deprecated 68 | @ConvertDisabled 69 | public short getPaystatus() { 70 | return payStatus; 71 | } 72 | 73 | @Deprecated 74 | @ConvertDisabled 75 | public void setPaystatus(short payStatus) { 76 | this.payStatus = payStatus; 77 | } 78 | 79 | @Deprecated 80 | @ConvertDisabled 81 | public String getThirdpayno() { 82 | return thirdPayno; 83 | } 84 | 85 | @Deprecated 86 | @ConvertDisabled 87 | public void setThirdpayno(String thirdPayno) { 88 | this.thirdPayno = thirdPayno; 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/test/java/org/redkalex/source/search/TestComment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.search; 7 | 8 | import org.redkale.convert.json.JsonConvert; 9 | import org.redkale.persistence.*; 10 | 11 | /** @author zhangjx */ 12 | public class TestComment { 13 | 14 | @Id 15 | @Column(length = 64, comment = "评论ID= userid+'-'+createTime") 16 | private String commentid = ""; 17 | 18 | @Column(length = 64, comment = "动态ID") 19 | private String postid = ""; 20 | 21 | @Column(comment = "用户ID") 22 | private int userid; 23 | 24 | @SearchColumn(text = true, options = "offsets", analyzer = "ik_max_word") 25 | @Column(length = 255, comment = "评论标题") 26 | private String title = ""; 27 | 28 | @SearchColumn(text = true, options = "offsets", analyzer = "ik_max_word") 29 | @Column(comment = "评论内容") 30 | private String content = ""; 31 | 32 | @Column(updatable = false, comment = "生成时间,单位毫秒") 33 | private long createTime; 34 | 35 | public String getCommentid() { 36 | return commentid; 37 | } 38 | 39 | public void setCommentid(String commentid) { 40 | this.commentid = commentid; 41 | } 42 | 43 | public String getPostid() { 44 | return postid; 45 | } 46 | 47 | public void setPostid(String postid) { 48 | this.postid = postid; 49 | } 50 | 51 | public int getUserid() { 52 | return userid; 53 | } 54 | 55 | public void setUserid(int userid) { 56 | this.userid = userid; 57 | } 58 | 59 | public String getTitle() { 60 | return title; 61 | } 62 | 63 | public void setTitle(String title) { 64 | this.title = title; 65 | } 66 | 67 | public String getContent() { 68 | return content; 69 | } 70 | 71 | public void setContent(String content) { 72 | this.content = content; 73 | } 74 | 75 | public long getCreateTime() { 76 | return createTime; 77 | } 78 | 79 | public void setCreateTime(long createTime) { 80 | this.createTime = createTime; 81 | } 82 | 83 | @Override 84 | public String toString() { 85 | return JsonConvert.root().convertTo(this); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/pgsql/PgReqAuthMd5Password.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.pgsql; 7 | 8 | import java.nio.charset.StandardCharsets; 9 | import java.security.*; 10 | import java.util.*; 11 | import org.redkale.net.client.ClientConnection; 12 | import org.redkale.source.SourceException; 13 | import org.redkale.util.*; 14 | 15 | /** @author zhangjx */ 16 | public class PgReqAuthMd5Password extends PgClientRequest { 17 | 18 | protected String username; 19 | 20 | protected String password; 21 | 22 | protected byte[] salt; 23 | 24 | public PgReqAuthMd5Password(String username, String password, byte[] salt) { 25 | this.username = username; 26 | this.password = password; 27 | this.salt = salt; 28 | } 29 | 30 | @Override 31 | public int getType() { 32 | return REQ_TYPE_AUTH; 33 | } 34 | 35 | @Override 36 | public String toString() { 37 | return "PgReqAuthMd5Password_" + Objects.hashCode(this) + "{username=" + username + ", password=" + password 38 | + ", salt=" + Arrays.toString(salt) + "}"; 39 | } 40 | 41 | @Override 42 | public void writeTo(ClientConnection conn, ByteArray array) { 43 | array.putByte('p'); 44 | int start = array.length(); 45 | array.putInt(0); 46 | if (salt == null) { 47 | array.put(password.getBytes(StandardCharsets.UTF_8)); 48 | } else { 49 | MessageDigest md5; 50 | try { 51 | md5 = MessageDigest.getInstance("MD5"); 52 | } catch (NoSuchAlgorithmException e) { 53 | throw new SourceException(e); 54 | } 55 | md5.update(password.getBytes(StandardCharsets.UTF_8)); 56 | md5.update(username.getBytes(StandardCharsets.UTF_8)); 57 | md5.update(Utility.binToHexString(md5.digest()).getBytes(StandardCharsets.UTF_8)); 58 | md5.update(salt); 59 | array.put((byte) 'm', (byte) 'd', (byte) '5'); 60 | array.put(Utility.binToHexString(md5.digest()).getBytes(StandardCharsets.UTF_8)); 61 | } 62 | array.putByte(0); 63 | array.putInt(start, array.length() - start); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/test/java/org/redkalex/pay/UnionPayServiceTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.pay; 7 | 8 | import org.redkale.util.Utility; 9 | 10 | /** @author zhangjx */ 11 | public class UnionPayServiceTest { 12 | 13 | public static void main(String[] args) throws Throwable { 14 | UnionPayService service = new UnionPayService(); 15 | // service.createurl = "https://101.231.204.80:5000/gateway/api/appTransReq.do"; //请求支付url 16 | // service.queryurl = "https://101.231.204.80:5000/gateway/api/queryTrans.do"; //请求查询url 17 | // service.refundurl = "https://101.231.204.80:5000/gateway/api/backTransReq.do"; //请求退款url 18 | // service.closeurl = "https://101.231.204.80:5000/gateway/api/backTransReq.do"; //请求关闭url 19 | // 20 | // service.home = new File("D:/Java-Project/RedkalePluginsProject"); 21 | // service.signcertpath = "acp_test_sign.pfx"; //放在 {APP_HOME}/conf 目录下 22 | // service.verifycertpath = "acp_test_verify_sign.cer";//放在 {APP_HOME}/conf 目录下 23 | // service.signcertpwd = "000000"; 24 | service.init(null); 25 | 26 | // 支付 27 | final PayCreatRequest creatRequest = new PayCreatRequest(); 28 | creatRequest.setPayType(Pays.PAYTYPE_UNION); 29 | creatRequest.setPayno("Redkale100000001"); 30 | creatRequest.setPayMoney(10); // 1毛钱 31 | creatRequest.setPayTitle("一斤红菜苔"); 32 | creatRequest.setPayBody("一斤红菜苔"); 33 | creatRequest.setClientAddr(Utility.localInetAddress().getHostAddress()); 34 | final PayCreatResponse creatResponse = service.create(creatRequest); 35 | System.out.println(creatResponse); 36 | 37 | // 查询 38 | // 请求不能太频繁,否则 You have been added to the blacklist. Please don't do stress testing. TPS could not be greater 39 | // than 0.5 . BlackList Will be clear at time 00:00 40 | PayRequest queryRequest = new PayRequest(); 41 | queryRequest.setPayType(Pays.PAYTYPE_UNION); 42 | queryRequest.setPayno(creatRequest.getPayno()); 43 | // PayQueryResponse queryResponse = service.query(queryRequest); 44 | // System.out.println(queryResponse); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/apns/ApnsMessage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.apns; 7 | 8 | import org.redkale.convert.json.JsonFactory; 9 | 10 | /** 11 | * 详情见: https://redkale.org 12 | * 13 | * @author zhangjx 14 | */ 15 | public class ApnsMessage { 16 | 17 | public static final int PRIORITY_IMMEDIATELY = 10; 18 | 19 | public static final int PRIORITY_A_TIME = 5; 20 | 21 | private ApnsPayload payload; 22 | 23 | private int expiredate; 24 | 25 | private int priority = PRIORITY_IMMEDIATELY; 26 | 27 | private int identifier; 28 | 29 | private String token; 30 | 31 | public ApnsMessage() {} 32 | 33 | public ApnsMessage(String token, ApnsPayload payload) { 34 | this(token, payload, 0); 35 | } 36 | 37 | public ApnsMessage(String token, ApnsPayload payload, int expiredate) { 38 | this(token, payload, expiredate, PRIORITY_IMMEDIATELY); 39 | } 40 | 41 | public ApnsMessage(String token, ApnsPayload payload, int expiredate, int priority) { 42 | this.token = token; 43 | this.payload = payload; 44 | this.expiredate = expiredate; 45 | this.priority = priority; 46 | } 47 | 48 | public String getToken() { 49 | return token; 50 | } 51 | 52 | public void setToken(String token) { 53 | this.token = token; 54 | } 55 | 56 | public int getExpiredate() { 57 | return expiredate; 58 | } 59 | 60 | public void setExpiredate(int expiredate) { 61 | this.expiredate = expiredate; 62 | } 63 | 64 | public int getPriority() { 65 | return priority; 66 | } 67 | 68 | public void setPriority(int priority) { 69 | this.priority = priority; 70 | } 71 | 72 | public ApnsPayload getPayload() { 73 | return payload; 74 | } 75 | 76 | public void setPayload(ApnsPayload payload) { 77 | this.payload = payload; 78 | } 79 | 80 | public int getIdentifier() { 81 | return identifier; 82 | } 83 | 84 | public void setIdentifier(int identifier) { 85 | this.identifier = identifier; 86 | } 87 | 88 | @Override 89 | public String toString() { 90 | return JsonFactory.root().getConvert().convertTo(this); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/test/java/org/redkalex/convert/pb/PTestBeanSelf.java: -------------------------------------------------------------------------------- 1 | package org.redkalex.convert.pb; 2 | 3 | import java.util.Map; 4 | import org.redkale.convert.ConvertColumn; 5 | import org.redkale.convert.json.JsonConvert; 6 | 7 | /** 8 | * 9 | * @author zhangjx 10 | */ 11 | public class PTestBeanSelf { 12 | 13 | public static class PTestEntry { 14 | 15 | @ConvertColumn(index = 1) 16 | public boolean[] bools = new boolean[] {true, false, true}; 17 | 18 | @ConvertColumn(index = 2) 19 | public byte[] bytes = new byte[] {1, 2, 3, 4}; 20 | 21 | @ConvertColumn(index = 3) 22 | public char[] chars = new char[] {'A', 'B', 'C'}; 23 | 24 | @ConvertColumn(index = 4) 25 | public short[] shorts = new short[] {10, 20, 30}; 26 | 27 | @Override 28 | public String toString() { 29 | return JsonConvert.root().convertTo(this); 30 | } 31 | } 32 | 33 | public static enum Kind { 34 | ONE, 35 | TWO, 36 | THREE 37 | } 38 | 39 | @ConvertColumn(index = 1) 40 | public boolean[] bools; 41 | 42 | @ConvertColumn(index = 2) 43 | public byte[] bytes; 44 | 45 | @ConvertColumn(index = 3) 46 | public char[] chars; 47 | 48 | @ConvertColumn(index = 4) 49 | public PTestEntry[] entrys; 50 | 51 | @ConvertColumn(index = 5) 52 | public int[] ints; 53 | 54 | @ConvertColumn(index = 6) 55 | public float[] floats; 56 | 57 | @ConvertColumn(index = 7) 58 | public long[] longs; 59 | 60 | @ConvertColumn(index = 8) 61 | public double[] doubles; // 8 62 | 63 | @ConvertColumn(index = 9) 64 | public String[] strings; // 9 65 | 66 | @ConvertColumn(index = 10) 67 | public int id = 0x7788; // 10 68 | 69 | @ConvertColumn(index = 11) 70 | public String name; // 11 71 | 72 | @ConvertColumn(index = 12) 73 | public String email; // 12 74 | 75 | @ConvertColumn(index = 13) 76 | public Kind kind; // 13 77 | 78 | @ConvertColumn(index = 14) 79 | public Map map; // 14 80 | 81 | @ConvertColumn(index = 15) 82 | public String end; // 15 83 | 84 | @Override 85 | public String toString() { 86 | return JsonConvert.root().convertTo(this); 87 | } 88 | 89 | 90 | } 91 | 92 | // protoc --java_out=D:\Java-Projects\RedkalePluginProject\src\test\java 93 | // --proto_path=D:\Java-Projects\RedkalePluginProject\src\test\java\org\redkalex\convert\pb PTestBean.proto 94 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/mysql/MyRespDecoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.mysql; 7 | 8 | import java.nio.ByteBuffer; 9 | import java.nio.charset.StandardCharsets; 10 | import java.sql.SQLException; 11 | import org.redkale.util.*; 12 | 13 | /** 14 | * @author zhangjx 15 | * @param 泛型 16 | */ 17 | public abstract class MyRespDecoder { 18 | 19 | public abstract T read( 20 | MyClientConnection conn, 21 | ByteBuffer buffer, 22 | int length, 23 | byte index, 24 | ByteArray array, 25 | MyClientRequest request, 26 | MyResultSet dataset) 27 | throws SQLException; 28 | 29 | protected static SQLException readErrorPacket( 30 | MyClientConnection conn, ByteBuffer buffer, int length, byte index, ByteArray array) { 31 | int vendorCode = Mysqls.readUB2(buffer); // errorCode 32 | buffer.get(); // 固定为 # SQL state marker will always be # 33 | String sqlState = new String(Mysqls.readBytes(buffer, array, 5), StandardCharsets.UTF_8); 34 | // typeid=1, errorCode=2, #=1, sqlState=5 35 | String errorMessage = 36 | new String(Mysqls.readBytes(buffer, array, length - 1 - 2 - 1 - 5), StandardCharsets.UTF_8); 37 | return new SQLException(errorMessage, sqlState, vendorCode); 38 | } 39 | 40 | protected static MyRespOK readOKPacket( 41 | MyClientConnection conn, ByteBuffer buffer, int length, byte index, ByteArray array) { 42 | final MyRespOK rs = new MyRespOK(); 43 | // com.mysql.cj.protocol.a.NativeProtocol 44 | // com.mysql.cj.protocol.a.result.OkPacket 45 | int pos = buffer.position() - 1; // typeid已经被读了 46 | rs.affectedRows = Mysqls.readLength(buffer); 47 | rs.lastInsertId = Mysqls.readLength(buffer); 48 | rs.serverStatusFlags = Mysqls.readUB2(buffer); 49 | rs.warningCount = Mysqls.readUB2(buffer); 50 | int limit = length + pos - buffer.position(); 51 | rs.info = Mysqls.readUTF8StringWithTerm(buffer, array, limit); 52 | // read session state changes info 53 | if ((rs.serverStatusFlags & Mysqls.SERVER_SESSION_STATE_CHANGED) > 0) { 54 | Mysqls.readUB2(buffer); // totalLen 55 | } 56 | return rs; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/test/java/org/redkalex/cache/redis/PubSubRedisTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.cache.redis; 7 | 8 | import java.nio.charset.StandardCharsets; 9 | import static org.redkale.boot.Application.RESNAME_APP_CLIENT_ASYNCGROUP; 10 | import org.redkale.boot.LoggingBaseHandler; 11 | import org.redkale.inject.ResourceFactory; 12 | import org.redkale.net.AsyncIOGroup; 13 | import static org.redkale.source.AbstractCacheSource.CACHE_SOURCE_MAXCONNS; 14 | import static org.redkale.source.AbstractCacheSource.CACHE_SOURCE_NODES; 15 | import org.redkale.source.CacheEventListener; 16 | import org.redkale.util.AnyValueWriter; 17 | import org.redkale.util.Utility; 18 | 19 | /** 20 | * 21 | * @author zhangjx 22 | */ 23 | public class PubSubRedisTest { 24 | 25 | private static final String TOPIC = "channel001"; 26 | 27 | public static void main(String[] args) throws Exception { 28 | LoggingBaseHandler.initDebugLogConfig(); 29 | AnyValueWriter conf = new AnyValueWriter() 30 | .addValue(CACHE_SOURCE_MAXCONNS, "1") 31 | .addValue(CACHE_SOURCE_NODES, "redis://127.0.0.1:6363"); 32 | final ResourceFactory factory = ResourceFactory.create(); 33 | final AsyncIOGroup asyncGroup = new AsyncIOGroup(8192, 16); 34 | asyncGroup.start(); 35 | factory.register(RESNAME_APP_CLIENT_ASYNCGROUP, asyncGroup); 36 | 37 | RedisCacheSource source = new RedisCacheSource(); 38 | factory.inject(source); 39 | source.init(conf); 40 | run(source); 41 | } 42 | 43 | public static void run(RedisSource source) throws Exception { 44 | // ---------------------------------------------- 45 | TestEventListener listener = new TestEventListener(); 46 | source.subscribe(listener, TOPIC); 47 | source.publish(TOPIC, "这是一个推送消息"); 48 | System.in.read(); 49 | Utility.sleep(1000); 50 | source.publish(TOPIC, "这是一个推送消息"); 51 | // ---------------------------------------------- 52 | Utility.sleep(1000); 53 | source.close(); 54 | } 55 | 56 | public static class TestEventListener implements CacheEventListener { 57 | 58 | @Override 59 | public void onMessage(String topic, byte[] message) { 60 | System.out.println("收到topic(" + topic + ")消息: " + new String(message, StandardCharsets.UTF_8)); 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/test/java/org/redkalex/source/mapper/ForumInfoMapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | */ 4 | package org.redkalex.source.mapper; 5 | 6 | import java.util.List; 7 | import java.util.concurrent.CompletableFuture; 8 | import org.redkale.annotation.Param; 9 | import org.redkale.persistence.Sql; 10 | import org.redkale.source.RowBound; 11 | import org.redkale.util.Sheet; 12 | 13 | /** @author zhangjx */ 14 | public interface ForumInfoMapper extends BaseMapper { 15 | 16 | @Sql("SELECT f.forum_groupid, s.forum_section_color " 17 | + "FROM forum_info f, forum_section s " 18 | + " WHERE f.forumid = s.forumid AND " 19 | + "s.forum_sectionid = #{bean.forumSectionid} AND " 20 | + "f.forumid = #{bean.forumid} AND s.forum_section_color = #{bean.forumSectionColor}") 21 | public ForumResult findForumResult(ForumBean bean); 22 | 23 | @Sql("SELECT f.forum_groupid, s.forum_section_color " 24 | + "FROM forum_info f, forum_section s " 25 | + " WHERE f.forumid = s.forumid AND " 26 | + "s.forum_sectionid = #{bean.forumSectionid} AND " 27 | + "f.forumid = #{bean.forumid} AND s.forum_section_color = #{bean.forumSectionColor}") 28 | public CompletableFuture findForumResultAsync(ForumBean bean); 29 | 30 | @Sql("SELECT f.forum_groupid, s.forum_section_color " 31 | + "FROM forum_info f, forum_section s " 32 | + " WHERE f.forumid = s.forumid AND " 33 | + "s.forum_sectionid = #{bean.forumSectionid} AND " 34 | + "f.forumid = #{bean.forumid} AND s.forum_section_color = #{bean.forumSectionColor}") 35 | public List queryForumResult(@Param("bean") ForumBean bean0); 36 | 37 | @Sql("SELECT f.forum_groupid, s.forum_section_color " 38 | + "FROM forum_info f, forum_section s " 39 | + " WHERE f.forumid = s.forumid AND " 40 | + "s.forum_sectionid = #{bean.forumSectionid} AND " 41 | + "f.forumid = #{bean.forumid} AND s.forum_section_color = #{bean.forumSectionColor}") 42 | public CompletableFuture> queryForumResultAsync(ForumBean bean); 43 | 44 | @Sql("SELECT f.forum_groupid, s.forum_section_color " 45 | + "FROM forum_info f, forum_section s " 46 | + " WHERE f.forumid = s.forumid AND " 47 | + "s.forum_sectionid = #{bean.forumSectionid} AND " 48 | + "f.forumid = #{bean.forumid} AND s.forum_section_color = #{bean.forumSectionColor}") 49 | public Sheet queryForumResultSheet(ForumBean bean, RowBound round); 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/pay/PayResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.pay; 7 | 8 | import java.util.Map; 9 | import java.util.concurrent.CompletableFuture; 10 | import org.redkale.convert.*; 11 | import org.redkale.convert.json.JsonFactory; 12 | import org.redkale.service.RetResult; 13 | 14 | /** 15 | * 详情见: https://redkale.org 16 | * 17 | * @author zhangjx 18 | */ 19 | public class PayResponse extends RetResult> { 20 | 21 | @ConvertColumn(ignore = true, type = ConvertType.JSON) 22 | protected String responseText = ""; // 第三方支付返回的原始结果字符串 23 | 24 | public PayResponse() {} 25 | 26 | public PayResponse(Map result) { 27 | super(result); 28 | } 29 | 30 | public PayResponse(int retcode) { 31 | super(retcode); 32 | } 33 | 34 | public PayResponse(int retcode, String retinfo) { 35 | super(retcode, retinfo); 36 | } 37 | 38 | public PayResponse(int retcode, String retinfo, Map result) { 39 | super(retcode, retinfo, result); 40 | } 41 | 42 | @Override 43 | public CompletableFuture toFuture() { 44 | return CompletableFuture.completedFuture(this); 45 | } 46 | 47 | @Override 48 | public PayResponse retcode(int retcode) { 49 | this.retcode = retcode; 50 | this.retinfo = PayRetCodes.retInfo(retcode); 51 | return this; 52 | } 53 | 54 | @Override 55 | public PayResponse retinfo(String retinfo) { 56 | if (retinfo != null) this.retinfo = retinfo; 57 | return this; 58 | } 59 | 60 | @Override 61 | public PayResponse result(Map result) { 62 | this.setResult(result); 63 | return this; 64 | } 65 | 66 | public String getResponseText() { 67 | return responseText; 68 | } 69 | 70 | public void setResponseText(String responseText) { 71 | this.responseText = responseText; 72 | } 73 | 74 | @Override 75 | public String toString() { 76 | return jf.getConvert().convertTo(this); 77 | } 78 | 79 | private static final JsonFactory jf = JsonFactory.create().skipAllIgnore(true); 80 | 81 | @Deprecated 82 | @ConvertDisabled 83 | public String getResponsetext() { 84 | return responseText; 85 | } 86 | 87 | @Deprecated 88 | @ConvertDisabled 89 | public void setResponsetext(String responseText) { 90 | this.responseText = responseText; 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/test/java/org/redkalex/source/mongo/TestCodecProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | */ 3 | 4 | package org.redkalex.source.mongo; 5 | 6 | import com.mongodb.MongoClientSettings; 7 | import java.io.StringWriter; 8 | import java.util.HashSet; 9 | import java.util.List; 10 | import java.util.Set; 11 | import org.bson.codecs.Codec; 12 | import org.bson.codecs.EncoderContext; 13 | import org.bson.codecs.configuration.CodecRegistries; 14 | import org.bson.codecs.configuration.CodecRegistry; 15 | import org.bson.codecs.pojo.ClassModelBuilder; 16 | import org.bson.codecs.pojo.Convention; 17 | import org.bson.codecs.pojo.PojoCodecProvider; 18 | import org.bson.json.JsonWriter; 19 | 20 | /** 21 | * 22 | * @author zhangjx 23 | */ 24 | public class TestCodecProvider { 25 | public static void main(String[] args) throws Throwable { 26 | MongoClientSettings.Builder settingBuilder = MongoClientSettings.builder(); 27 | CodecRegistry registry = CodecRegistries.fromRegistries( 28 | MongoClientSettings.getDefaultCodecRegistry(), 29 | CodecRegistries.fromProviders(PojoCodecProvider.builder() 30 | .automatic(true) 31 | .conventions(List.of(new MongoConvention())) 32 | .build())); 33 | settingBuilder.codecRegistry(registry); 34 | MongoClientSettings setting = settingBuilder.build(); 35 | CodecRegistry reg = setting.getCodecRegistry(); 36 | /** 37 | * @see org.bson.codecs.pojo.AutomaticPojoCodec 38 | */ 39 | Codec codec = reg.get(TestRecord.class); 40 | StringWriter pw = new StringWriter(); 41 | JsonWriter writer = new JsonWriter(pw); 42 | TestRecord bean = new TestRecord(); 43 | EncoderContext context = EncoderContext.builder().build(); 44 | bean.setCreateTime(1); 45 | bean.setStatus((short)1); 46 | bean.setName("haha"); 47 | bean.setRecordid("xxxx"); 48 | codec.encode(writer, bean, context); 49 | System.out.println(pw); 50 | } 51 | 52 | public static class MongoConvention implements Convention { 53 | 54 | @Override 55 | public void apply(ClassModelBuilder builder) { 56 | 57 | Set cols = Set.of("recordid", "status"); 58 | 59 | Set fields = new HashSet<>(); 60 | builder.getPropertyModelBuilders().forEach(p -> { 61 | fields.add(p.getWriteName()); 62 | }); 63 | for (String field : fields) { 64 | if (!cols.contains(field)) { 65 | builder.removeProperty(field); 66 | } 67 | } 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/vertx/VertxSqlDataSourceProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.vertx; 7 | 8 | import static org.redkale.source.DataSources.*; 9 | 10 | import org.redkale.annotation.Priority; 11 | import org.redkale.source.*; 12 | import org.redkale.source.spi.DataSourceProvider; 13 | import org.redkale.util.*; 14 | 15 | /** @author zhangjx */ 16 | @Priority(-300) 17 | public class VertxSqlDataSourceProvider implements DataSourceProvider { 18 | 19 | @Override 20 | public boolean acceptsConf(AnyValue config) { 21 | String dbtype = config.getValue("dbtype"); 22 | if (dbtype == null) { 23 | AnyValue read = config.getAnyValue("read"); 24 | AnyValue node = read == null ? config : read; 25 | dbtype = parseDbtype(node.getValue(DATA_SOURCE_URL)); 26 | } 27 | try { 28 | boolean pgsql = "postgresql".equalsIgnoreCase(dbtype); 29 | if (pgsql) { 30 | io.vertx.sqlclient.spi.Driver.class.isAssignableFrom( 31 | io.vertx.pgclient.spi.PgDriver.class); // 试图加载PgClient相关类 32 | Class clazz = 33 | Thread.currentThread().getContextClassLoader().loadClass("io.vertx.pgclient.PgConnectOptions"); 34 | RedkaleClassLoader.putReflectionClass(clazz.getName()); 35 | RedkaleClassLoader.putReflectionPublicConstructors(clazz, clazz.getName()); 36 | return pgsql; 37 | } 38 | } catch (Throwable t) { 39 | return false; 40 | } 41 | try { 42 | boolean mysql = "mysql".equalsIgnoreCase(dbtype); 43 | if (mysql) { 44 | io.vertx.sqlclient.spi.Driver.class.isAssignableFrom( 45 | io.vertx.mysqlclient.spi.MySQLDriver.class); // 试图加载MySQLClient相关类 46 | Class clazz = Thread.currentThread() 47 | .getContextClassLoader() 48 | .loadClass("io.vertx.mysqlclient.MySQLConnectOptions"); 49 | RedkaleClassLoader.putReflectionClass(clazz.getName()); 50 | RedkaleClassLoader.putReflectionPublicConstructors(clazz, clazz.getName()); 51 | return mysql; 52 | } 53 | return false; 54 | } catch (Throwable t) { 55 | return false; 56 | } 57 | } 58 | 59 | @Override 60 | public DataSource createInstance() { 61 | return new VertxSqlDataSource(); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/pgsql/PgReqBatch.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.pgsql; 7 | 8 | import java.util.*; 9 | import java.util.logging.Level; 10 | import org.redkale.net.client.ClientConnection; 11 | import org.redkale.util.*; 12 | import static org.redkalex.source.pgsql.PgClientCodec.logger; 13 | 14 | /** @author zhangjx */ 15 | public class PgReqBatch extends PgClientRequest { 16 | 17 | protected String[] sqls; 18 | 19 | @Override 20 | public int getType() { 21 | return REQ_TYPE_BATCH; 22 | } 23 | 24 | public PgReqBatch prepare(String... sqls) { 25 | super.prepare(); 26 | this.sqls = sqls; 27 | return this; 28 | } 29 | 30 | @Override 31 | public String toString() { 32 | return "PgReqBatch_" + Objects.hashCode(this) + "{sqls=" + Arrays.toString(sqls) + "}"; 33 | } 34 | 35 | @Override 36 | public void writeTo(ClientConnection conn, ByteArray array) { 37 | for (String sql : sqls) { 38 | { // PARSE 39 | array.putByte('P'); 40 | int start = array.length(); 41 | array.putInt(0); 42 | array.putByte(0); // unnamed prepared statement 43 | writeUTF8String(array, sql); 44 | array.putShort((short) 0); // no parameter types 45 | array.putInt(start, array.length() - start); 46 | } 47 | { // DESCRIBE 48 | array.putByte('D'); 49 | array.putInt(4 + 1 + 1); 50 | array.putByte('S'); 51 | array.putByte(0); 52 | } 53 | { // BIND 54 | array.putByte('B'); 55 | int start = array.length(); 56 | array.putInt(0); 57 | array.putByte(0); // portal 58 | array.putByte(0); // prepared statement 59 | array.putShort((short) 0); // 后面跟着的参数格式代码的数目(在下面的 C 中说明)。这个数值可以是零,表示没有参数,或者是参数都使用缺省格式(文本) 60 | array.putShort((short) 0); // number of format codes 参数格式代码。目前每个都必须是零(文本)或者一(二进制)。 61 | array.putShort((short) 0); // number of parameters 后面跟着的参数值的数目(可能为零)。这些必须和查询需要的参数个数匹配。 62 | array.putInt(start, array.length() - start); 63 | } 64 | writeExecute(array, 0); // EXECUTE 65 | writeSync(array); // SYNC 66 | if (PgsqlDataSource.debug) 67 | logger.log( 68 | Level.FINEST, 69 | "[" + Times.nowMillis() + "] [" + Thread.currentThread().getName() + "]: " + conn + ", " 70 | + getClass().getSimpleName() + ".PARSE: " + sql + ", DESCRIBE, BIND, EXECUTE, SYNC"); 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/config-template.properties: -------------------------------------------------------------------------------- 1 | 2 | 3 | ###################### \u5fae\u4fe1\u516c\u4f17\u53f7\u914d\u7f6e ######################### 4 | weixin.mp.conf = config.properties 5 | 6 | weixin.mp.[0].clientid = app1,app2 7 | weixin.mp.[0].appid = wxaaaaaaaaaaaaaaaaa 8 | weixin.mp.[0].appsecret = xxxxxxxxxxxxxxxxxxx 9 | 10 | weixin.mp.clientid = app1 11 | weixin.mp.appid = wxaaaaaaaaaaaaaaaaa 12 | weixin.mp.appsecret = xxxxxxxxxxxxxxxxxxx 13 | 14 | ####################### \u5fae\u4fe1\u652f\u4ed8\u914d\u7f6e ########################## 15 | pay.weixin.conf = config.properties 16 | 17 | pay.weixin.[0].merchno = 1300000001 18 | pay.weixin.[0].appid = wxaaaaaaaaaaaa1 19 | pay.weixin.[0].signkey = 6440000000000000000000000001 20 | pay.weixin.[0].certpwd = 1300000001 21 | pay.weixin.[0].certpath = apiclient_cert_01.p12 22 | pay.weixin.[0].notifyurl = http://aaa.redkale.org/pipes/pay/weixin/nodify 23 | 24 | pay.weixin.[1].merchno = 1300000002 25 | pay.weixin.[1].appid = wxaaaaaaaaaaaa2 26 | pay.weixin.[1].signkey = 6440000000000000000000000002 27 | pay.weixin.[1].certpwd = 1300000002 28 | pay.weixin.[1].certpath = apiclient_cert_02.p12 29 | pay.weixin.[1].notifyurl = http://aaa.redkale.org/pipes/pay/weixin/nodify 30 | 31 | ###################### \u652f\u4ed8\u5b9d\u652f\u4ed8\u914d\u7f6e ######################### 32 | 33 | pay.alipay.conf = config.properties 34 | 35 | pay.alipay.appid = 20160000000000001 36 | pay.alipay.merchno = 20880000000001 37 | pay.alipay.charset = GBK 38 | pay.alipay.signcertkey = MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAM7bX3dTp8IkBlqGS5wJIF/+Zut8wouk5MpRH5c/PDEbVawBlkYSWWHDxuWi+h833d7sT9pzDuZMhCk0Fr4OOCHX1I6FTc4lKeY7udLDYIM53wfqlJkOfsbgQBFZe4FSahuBTHcGaWeXhRwE8DoEb6C3EiMMyZEUDDOJGcb/lpwhAgMBAAECgYAJd0J0HHDl0m40AEc/ea9wlRyyk//3EfGiTHoMmskvWhfeiigNRtOuRJ46be3SNeVCSUASOAerhD7b/9U2l0H8PVTFfAIRQZoPgy45+aU/g8LHJ0a0hnyTZ60LsoSwCksnsscp1C2v8HHKIHiOSfE2QN9Q4nnUvHTWkcdBzjZhQQJBAPxCGYOBuz53R7hqFILira2PzUerV4y0zU4ndHtCnyFZZUjgvI1871Bnhxre5JfUbmLytFsWFhPzdTn5t3tbLqkCQQDR7N71tsvSsi7A9wn6j6k+mvPIDjwHB7Nhvi7J34wmCXTsoaAQ/o516r4fMJi7cBJ7QVd+VmsDYHHxaa2RBUS5AkEAngNZsAKno61cA6yPRJ1xZXLah7ZQlRb8M6SLVlqZC27P/yKneYl07syq2K4eSu0KaHjXeOcQ1VZ/a918jYzEYQJAR2bM80BolVKbynB8SWghxbSIpIwK6M06u00ntuw9TBa9WVskCYO7yum8Hvm1iVN2RcwUyVj1byGXv+gU7BWhqQJAB/xRqoRGqHiJudOvFiGUE+DRd9RNhai62lAAtQnPq/Mml70OtX8/YAJdTgid5RviO65X+IJ8ihbwwZXv6cg03A== 39 | pay.alipay.verifycertkey = MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDO2193U6fCJAZahkucCSBf/mbrfMKLpOTKUR+XPzwxG1WsAZZGEllhw8blovofN93e7E/acw7mTIQpNBa+Djgh19SOhU3OJSnmO7nSw2CDOd8H6pSZDn7G4EARWXuBUmobgUx3Bmlnl4UcBPA6BG+gtxIjDMmRFAwziRnG/5acIQIDAQAB 40 | pay.alipay.notifyurl = http://aaa.redkale.org/pipes/pay/alipay/nodify 41 | 42 | ####################### \u94f6\u8054\u652f\u4ed8\u914d\u7f6e ########################## 43 | 44 | pay.union.merchno = 45 | pay.union.signcertpwd = 46 | pay.union.signcertpath = 47 | pay.union.verifycertpath = 48 | pay.union.notifyurl = http://aaa.redkale.org/pipes/pay/union/nodify 49 | -------------------------------------------------------------------------------- /src/test/java/org/redkalex/source/mapper/DynForumInfoMapperImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | */ 4 | package org.redkalex.source.mapper; 5 | 6 | import java.util.HashMap; 7 | import java.util.List; 8 | import java.util.Map; 9 | import java.util.concurrent.CompletableFuture; 10 | import org.redkale.source.DataSqlSource; 11 | import org.redkale.source.RowBound; 12 | import org.redkale.util.Sheet; 13 | 14 | /** @author zhangjx */ 15 | public class DynForumInfoMapperImpl implements ForumInfoMapper { 16 | 17 | private DataSqlSource _source; 18 | 19 | private Class _type; 20 | 21 | @Override 22 | public ForumResult findForumResult(ForumBean bean) { 23 | String sql = 24 | "SELECT f.forum_groupid, s.forum_section_color FROM forum_info f, forum_section s WHERE f.forumid = s.forumid"; 25 | Map params = new HashMap<>(); 26 | params.put("bean", bean); 27 | return dataSource().nativeQueryOne(ForumResult.class, sql, params); 28 | } 29 | 30 | @Override 31 | public CompletableFuture findForumResultAsync(ForumBean bean) { 32 | String sql = 33 | "SELECT f.forum_groupid, s.forum_section_color FROM forum_info f, forum_section s WHERE f.forumid = s.forumid"; 34 | Map params = new HashMap<>(); 35 | params.put("bean", bean); 36 | return dataSource().nativeQueryOneAsync(ForumResult.class, sql, params); 37 | } 38 | 39 | @Override 40 | public List queryForumResult(ForumBean bean) { 41 | String sql = 42 | "SELECT f.forum_groupid, s.forum_section_color FROM forum_info f, forum_section s WHERE f.forumid = s.forumid"; 43 | Map params = new HashMap<>(); 44 | params.put("bean", bean); 45 | return dataSource().nativeQueryList(ForumResult.class, sql, params); 46 | } 47 | 48 | @Override 49 | public CompletableFuture> queryForumResultAsync(ForumBean bean) { 50 | String sql = 51 | "SELECT f.forum_groupid, s.forum_section_color FROM forum_info f, forum_section s WHERE f.forumid = s.forumid"; 52 | Map params = new HashMap<>(); 53 | params.put("bean", bean); 54 | return dataSource().nativeQueryListAsync(ForumResult.class, sql, params); 55 | } 56 | 57 | @Override 58 | public Sheet queryForumResultSheet(ForumBean bean, RowBound round) { 59 | String sql = 60 | "SELECT f.forum_groupid, s.forum_section_color FROM forum_info f, forum_section s WHERE f.forumid = s.forumid"; 61 | Map params = new HashMap<>(); 62 | params.put("bean", bean); 63 | return dataSource().nativeQuerySheet(ForumResult.class, sql, round, params); 64 | } 65 | 66 | @Override 67 | public DataSqlSource dataSource() { 68 | return _source; 69 | } 70 | 71 | @Override 72 | public Class entityType() { 73 | return _type; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/pgsql/PgRespRowDataDecoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.pgsql; 7 | 8 | import static org.redkalex.source.pgsql.PgClientCodec.*; 9 | import static org.redkalex.source.pgsql.PgPrepareDesc.PgExtendMode.*; 10 | 11 | import java.io.Serializable; 12 | import java.nio.ByteBuffer; 13 | import org.redkale.util.*; 14 | 15 | /** @author zhangjx */ 16 | public class PgRespRowDataDecoder extends PgRespDecoder { 17 | 18 | public static final PgRespRowDataDecoder instance = new PgRespRowDataDecoder(); 19 | 20 | private PgRespRowDataDecoder() {} 21 | 22 | @Override 23 | public byte messageid() { 24 | return MESSAGE_TYPE_DATA_ROW; // 'D' 25 | } 26 | 27 | @Override // RowData 一行数据 28 | public PgRowData read( 29 | PgClientConnection conn, 30 | ByteBuffer buffer, 31 | final int length, 32 | ByteArray array, 33 | PgClientRequest request, 34 | PgResultSet dataset) { 35 | PgPrepareDesc prepareDesc = request.getType() == PgClientRequest.REQ_TYPE_EXTEND_QUERY 36 | ? conn.getPgPrepareDesc(((PgReqExtended) request).sql) 37 | : null; 38 | if (prepareDesc == null) { // text 39 | byte[][] byteValues = new byte[buffer.getShort()][]; 40 | for (int i = 0; i < byteValues.length; i++) { 41 | byteValues[i] = (byte[]) PgsqlFormatter.decodeRowColumnValue(buffer, array, null, buffer.getInt()); 42 | } 43 | return new PgRowData(byteValues, null); 44 | } 45 | PgPrepareDesc.PgExtendMode mode = prepareDesc.mode(); 46 | // binary 47 | PgColumnFormat[] formats = prepareDesc.resultFormats(); 48 | Attribute[] attrs = prepareDesc.resultAttrs(); 49 | Serializable[] realValues = new Serializable[buffer.getShort()]; 50 | for (int i = 0; i < realValues.length; i++) { 51 | PgColumnFormat f = i < formats.length ? formats[i] : PgColumnFormat.VARCHAR; 52 | Attribute attr = i < attrs.length ? attrs[i] : null; 53 | realValues[i] = f.decoder().decode(buffer, array, attr, buffer.getInt()); 54 | } 55 | if (mode == FIND_ENTITY) { 56 | dataset.oneEntity = request.info.getBuilder().getFullEntityValue(realValues); 57 | return PgRowData.NIL; 58 | } else if (mode == FINDS_ENTITY) { 59 | dataset.addEntity(request.info.getBuilder().getFullEntityValue(realValues)); 60 | return PgRowData.NIL; 61 | } else if (mode == LISTALL_ENTITY) { 62 | dataset.addEntity(request.info.getBuilder().getFullEntityValue(realValues)); 63 | return PgRowData.NIL; 64 | } else { 65 | return new PgRowData(null, realValues); 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/parser/DataNativeJsqlParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | */ 4 | package org.redkalex.source.parser; 5 | 6 | import java.util.Map; 7 | import java.util.concurrent.ConcurrentHashMap; 8 | import java.util.function.IntFunction; 9 | import java.util.logging.*; 10 | import org.redkale.annotation.ResourceType; 11 | import org.redkale.source.DataNativeSqlInfo; 12 | import org.redkale.source.DataNativeSqlParser; 13 | import org.redkale.source.DataNativeSqlStatement; 14 | import org.redkale.source.RowBound; 15 | 16 | /** 17 | * 基于jsqlparser的DataNativeSqlParser实现类 18 | * 19 | * @author zhangjx 20 | */ 21 | @ResourceType(DataNativeSqlParser.class) 22 | public class DataNativeJsqlParser implements DataNativeSqlParser { 23 | 24 | protected final Logger logger = Logger.getLogger(DataNativeJsqlParser.class.getSimpleName()); 25 | 26 | private final ConcurrentHashMap parserInfo = new ConcurrentHashMap(); 27 | 28 | @Override 29 | public DataNativeSqlInfo parse(IntFunction signFunc, String dbType, String rawSql) { 30 | return parserInfo.computeIfAbsent(rawSql, sql -> new NativeParserInfo(sql, dbType, signFunc)); 31 | } 32 | 33 | @Override 34 | public DataNativeSqlStatement parse( 35 | IntFunction signFunc, 36 | String dbType, 37 | String rawSql, 38 | boolean countable, 39 | RowBound round, 40 | Map params) { 41 | NativeParserInfo info = parserInfo.computeIfAbsent(rawSql, sql -> new NativeParserInfo(sql, dbType, signFunc)); 42 | NativeSqlTemplet templet = info.createTemplet(params); 43 | if (logger.isLoggable(Level.FINER)) { 44 | logger.log( 45 | Level.FINER, 46 | DataNativeSqlParser.class.getSimpleName() + " parse. rawSql: " + rawSql + ", dynamic: " 47 | + info.isDynamic() + ", templetSql: " + templet.getJdbcSql()); 48 | } 49 | NativeParserNode node = info.loadParserNode(templet.getJdbcSql(), countable); 50 | DataNativeSqlStatement statement = node.loadStatement(round, templet.getTempletParams()); 51 | if (logger.isLoggable(Level.FINE)) { 52 | if (countable) { 53 | logger.log( 54 | Level.FINE, 55 | DataNativeSqlParser.class.getSimpleName() + " parse. rawSql: " + rawSql + ", nativePageSql: " 56 | + statement.getNativePageSql() + ", nativeCountSql: " + statement.getNativeCountSql() 57 | + ", paramNames: " + statement.getParamNames()); 58 | } else { 59 | logger.log( 60 | Level.FINE, 61 | DataNativeSqlParser.class.getSimpleName() + " parse. rawSql: " + rawSql + ", nativeSql: " 62 | + statement.getNativeSql() + ", paramNames: " + statement.getParamNames()); 63 | } 64 | } 65 | return statement; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/test/java/org/redkalex/convert/pb/AnyValueBeanTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | */ 3 | 4 | package org.redkalex.convert.pb; 5 | 6 | import org.junit.jupiter.api.Assertions; 7 | import org.junit.jupiter.api.Test; 8 | import org.redkale.convert.pb.ProtobufConvert; 9 | import org.redkale.util.AnyValueWriter; 10 | import org.redkale.util.Utility; 11 | 12 | /** 13 | * 14 | * @author zhangjx 15 | */ 16 | public class AnyValueBeanTest { 17 | 18 | public static void main(String[] args) throws Throwable { 19 | AnyValueBeanTest test = new AnyValueBeanTest(); 20 | test.run1(); 21 | } 22 | 23 | // protoc --java_out=D:\Java-Projects\RedkalePluginProject\src\test\java 24 | // --proto_path=D:\Java-Projects\RedkalePluginProject\src\test\java\org\redkalex\convert\pb AnyValueBean.proto 25 | @Test 26 | public void run1() throws Exception { 27 | AnyValueWriter bean = createAnyValueWriter(); 28 | AnyValueBeanOuterClass.AnyValueBean.Builder builder = AnyValueBeanOuterClass.AnyValueBean.newBuilder(); 29 | AnyValueBeanOuterClass.AnyValueBean bean2 = createAnyValueBean(bean, builder); 30 | byte[] bs1 = bean2.toByteArray(); 31 | String rs1 = Utility.println("proto:", bs1); 32 | byte[] bs2 = ProtobufConvert.root().convertTo(bean); 33 | String rs2 = Utility.println("proto:", bs2); 34 | Assertions.assertEquals(rs1, rs2); 35 | } 36 | 37 | private static AnyValueWriter createAnyValueWriter() { 38 | AnyValueWriter writer = AnyValueWriter.create(); 39 | writer.addValue("name", "aaa"); 40 | writer.addValue("name", "bbb"); 41 | writer.addValue("node", AnyValueWriter.create("id", "111")); 42 | writer.addValue("node", AnyValueWriter.create("id", "222")); 43 | writer.addValue("node", AnyValueWriter.create("id", "333")); 44 | return writer; 45 | } 46 | 47 | private static AnyValueBeanOuterClass.AnyValueBean createAnyValueBean( 48 | AnyValueWriter bean, AnyValueBeanOuterClass.AnyValueBean.Builder builder) { 49 | bean.forEach( 50 | (k, v) -> { 51 | AnyValueBeanOuterClass.AnyValueBean.StringEntry.Builder b = 52 | AnyValueBeanOuterClass.AnyValueBean.StringEntry.newBuilder(); 53 | b.setName(k); 54 | b.setValue(v); 55 | builder.addStringEntrys(b.build()); 56 | }, 57 | (k, v) -> { 58 | AnyValueBeanOuterClass.AnyValueBean.AnyValueEntry.Builder b = 59 | AnyValueBeanOuterClass.AnyValueBean.AnyValueEntry.newBuilder(); 60 | b.setName(k); 61 | AnyValueBeanOuterClass.AnyValueBean.Builder vv = AnyValueBeanOuterClass.AnyValueBean.newBuilder(); 62 | b.setValue(createAnyValueBean((AnyValueWriter) v, vv)); 63 | builder.addAnyEntrys(b.build()); 64 | }); 65 | AnyValueBeanOuterClass.AnyValueBean bean2 = builder.build(); 66 | return bean2; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/scheduled/xxljob/XxljobConfig.java: -------------------------------------------------------------------------------- 1 | package org.redkalex.scheduled.xxljob; 2 | 3 | import java.io.Serializable; 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | import java.util.Objects; 7 | import java.util.function.UnaryOperator; 8 | import org.redkale.convert.ConvertColumn; 9 | import org.redkale.convert.json.JsonConvert; 10 | import org.redkale.util.AnyValue; 11 | import org.redkale.util.Utility; 12 | 13 | /** @author zhangjx */ 14 | public class XxljobConfig { 15 | 16 | // 不以/结尾 17 | @ConvertColumn(ignore = true) 18 | private String domain; 19 | 20 | private String addresses; 21 | 22 | private String ip; 23 | 24 | private int port; 25 | 26 | private String executorName; 27 | 28 | @ConvertColumn(ignore = true) 29 | private String accessToken; 30 | 31 | @ConvertColumn(ignore = true) 32 | private Map headers; 33 | 34 | public XxljobConfig() {} 35 | 36 | public XxljobConfig(AnyValue conf, UnaryOperator func) { 37 | this.addresses = 38 | Objects.requireNonNull(func.apply(conf.getValue("addresses").trim())); 39 | this.executorName = Objects.requireNonNull(func.apply(conf.getValue("executorName"))); 40 | this.ip = func.apply(conf.getValue("ip", Utility.localInetAddress().getHostAddress())); 41 | this.port = conf.getIntValue("port", 0); 42 | this.accessToken = func.apply(conf.getValue("accessToken", "")); 43 | this.headers = new HashMap<>(); 44 | this.headers.put("XXL-JOB-ACCESS-TOKEN", this.accessToken); 45 | if (this.addresses.endsWith("/")) { 46 | this.domain = this.addresses.substring(0, this.addresses.length() - 1); 47 | } else { 48 | this.domain = this.addresses; 49 | } 50 | } 51 | 52 | public Map getHeaders() { 53 | return headers; 54 | } 55 | 56 | public String getDomain() { 57 | return domain; 58 | } 59 | 60 | public String getAddresses() { 61 | return addresses; 62 | } 63 | 64 | public void setAddresses(String addresses) { 65 | this.addresses = addresses; 66 | } 67 | 68 | public String getIp() { 69 | return ip; 70 | } 71 | 72 | public void setIp(String ip) { 73 | this.ip = ip; 74 | } 75 | 76 | public int getPort() { 77 | return port; 78 | } 79 | 80 | public void setPort(int port) { 81 | this.port = port; 82 | } 83 | 84 | public String getExecutorName() { 85 | return executorName; 86 | } 87 | 88 | public void setExecutorName(String executorName) { 89 | this.executorName = executorName; 90 | } 91 | 92 | public String getAccessToken() { 93 | return accessToken; 94 | } 95 | 96 | public void setAccessToken(String accessToken) { 97 | this.accessToken = accessToken; 98 | } 99 | 100 | @Override 101 | public String toString() { 102 | return JsonConvert.root().convertTo(this); 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/pgsql/PgsqlOid.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 = the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.redkalex.source.pgsql; 15 | 16 | /** 17 | * Object identifiers, copied from org.postgresql.core.PgOid. 18 | * 19 | * @author zhangjx 20 | */ 21 | public interface PgsqlOid { 22 | 23 | int UNSPECIFIED = 0; 24 | 25 | int INT2 = 21; 26 | 27 | int INT2_ARRAY = 1005; 28 | 29 | int INT4 = 23; 30 | 31 | int INT4_ARRAY = 1007; 32 | 33 | int INT8 = 20; 34 | 35 | int INT8_ARRAY = 1016; 36 | 37 | int TEXT = 25; 38 | 39 | int TEXT_ARRAY = 1009; 40 | 41 | int FLOAT4 = 700; 42 | 43 | int FLOAT4_ARRAY = 1021; 44 | 45 | int FLOAT8 = 701; 46 | 47 | int FLOAT8_ARRAY = 1022; 48 | 49 | int BOOL = 16; 50 | 51 | int BOOL_ARRAY = 1000; 52 | 53 | int DATE = 1082; 54 | 55 | int DATE_ARRAY = 1182; 56 | 57 | int TIME = 1083; 58 | 59 | int TIME_ARRAY = 1183; 60 | 61 | int TIMETZ = 1266; 62 | 63 | int TIMETZ_ARRAY = 1270; 64 | 65 | int TIMESTAMP = 1114; 66 | 67 | int TIMESTAMP_ARRAY = 1115; 68 | 69 | int TIMESTAMPTZ = 1184; 70 | 71 | int TIMESTAMPTZ_ARRAY = 1185; 72 | 73 | int BYTEA = 17; 74 | 75 | int BYTEA_ARRAY = 1001; 76 | 77 | int VARCHAR = 1043; 78 | 79 | int VARCHAR_ARRAY = 1015; 80 | 81 | int OID = 26; 82 | 83 | int OID_ARRAY = 1028; 84 | 85 | int BPCHAR = 1042; 86 | 87 | int BPCHAR_ARRAY = 1014; 88 | 89 | int MONEY = 790; 90 | 91 | int MONEY_ARRAY = 791; 92 | 93 | int NAME = 19; 94 | 95 | int NAME_ARRAY = 1003; 96 | 97 | int BIT = 1560; 98 | 99 | int BIT_ARRAY = 1561; 100 | 101 | int VOID = 2278; 102 | 103 | int INTERVAL = 1186; 104 | 105 | int INTERVAL_ARRAY = 1187; 106 | 107 | int CHAR = 18; 108 | 109 | int CHAR_ARRAY = 1002; 110 | 111 | int VARBIT = 1562; 112 | 113 | int VARBIT_ARRAY = 1563; 114 | 115 | int UUID = 2950; 116 | 117 | int UUID_ARRAY = 2951; 118 | 119 | int XML = 142; 120 | 121 | int XML_ARRAY = 143; 122 | 123 | int POINT = 600; 124 | 125 | int BOX = 603; 126 | 127 | int JSON = 114; // Added 128 | 129 | int JSONB = 3802; 130 | 131 | int HSTORE = 33670; 132 | 133 | int NUMERIC = 1700; // false Number 134 | 135 | int NUMERIC_ARRAY = 1231; // false Number 136 | 137 | int UNKNOWN = 705; // false String 138 | 139 | int TS_VECTOR = 3614; // false String 140 | 141 | int TS_VECTOR_ARRAY = 3643; // false String 142 | 143 | int TS_QUERY = 3615; // false String 144 | 145 | int TS_QUERY_ARRAY = 3645; // false String 146 | } 147 | -------------------------------------------------------------------------------- /src/main/java/org/redkalex/source/mysql/MyClientConnection.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.redkalex.source.mysql; 7 | 8 | import java.util.*; 9 | import java.util.concurrent.atomic.AtomicBoolean; 10 | import java.util.logging.Logger; 11 | import org.redkale.net.*; 12 | import org.redkale.net.client.*; 13 | import org.redkale.source.EntityInfo; 14 | 15 | /** @author zhangjx */ 16 | public class MyClientConnection extends ClientConnection { 17 | 18 | private final Map cacheExtendedIndexs = new HashMap<>(); 19 | 20 | private final Map cacheExtendedPrepares = new HashMap<>(); 21 | 22 | private final Map cacheExtendedDescs = new HashMap<>(); 23 | 24 | MyRespHandshakeResultSet handshake; 25 | 26 | // int clientCapabilitiesFlag; 27 | // 28 | public MyClientConnection(MyClient client, AsyncConnection channel) { 29 | super(client, channel); 30 | } 31 | 32 | @Override 33 | protected ClientCodec createCodec() { 34 | return new MyClientCodec(this); 35 | } 36 | 37 | @Override 38 | protected void preComplete(MyResultSet resp, MyClientRequest req, Throwable exc) { 39 | if (resp != null) { 40 | resp.request = req; 41 | } 42 | } 43 | 44 | protected boolean autoddl() { 45 | return ((MyClient) client).autoddl; 46 | } 47 | 48 | protected Logger logger() { 49 | return ((MyClient) client).logger(); 50 | } 51 | 52 | public AtomicBoolean getPrepareFlag(String prepareSql) { 53 | return cacheExtendedPrepares.computeIfAbsent(prepareSql, t -> new AtomicBoolean()); 54 | } 55 | 56 | public Long getStatementIndex(String prepareSql) { 57 | return cacheExtendedIndexs.get(prepareSql); 58 | } 59 | 60 | public MyPrepareDesc getPrepareDesc(String prepareSql) { 61 | return cacheExtendedDescs.get(prepareSql); 62 | } 63 | 64 | public void putStatementIndex(String prepareSql, long id) { 65 | cacheExtendedIndexs.put(prepareSql, id); 66 | } 67 | 68 | public void putPrepareDesc(String prepareSql, MyPrepareDesc desc) { 69 | cacheExtendedDescs.put(prepareSql, desc); 70 | } 71 | 72 | public MyResultSet pollResultSet(EntityInfo info) { 73 | MyResultSet rs = new MyResultSet(); 74 | rs.info = info; 75 | return rs; 76 | } 77 | 78 | public MyReqUpdate pollReqUpdate(WorkThread workThread, EntityInfo info) { 79 | MyReqUpdate rs = new MyReqUpdate(); 80 | rs.info = info; 81 | rs.workThread(workThread); 82 | return rs; 83 | } 84 | 85 | public MyReqQuery pollReqQuery(WorkThread workThread, EntityInfo info) { 86 | MyReqQuery rs = new MyReqQuery(); 87 | rs.info = info; 88 | rs.workThread(workThread); 89 | return rs; 90 | } 91 | 92 | public MyReqExtended pollReqExtended(WorkThread workThread, EntityInfo info) { 93 | MyReqExtended rs = new MyReqExtended(); 94 | rs.info = info; 95 | rs.workThread(workThread); 96 | return rs; 97 | } 98 | } 99 | --------------------------------------------------------------------------------