This commit is contained in:
wentch
2016-01-05 09:51:25 +08:00
parent cf333b27ff
commit b961f79fe8
47 changed files with 322 additions and 275 deletions

View File

@@ -26,7 +26,7 @@ import java.util.regex.*;
* 详情见: http://www.redkale.org
*
* @author zhangjx
* @param <T>
* @param <T> 泛型
*/
public final class ClassFilter<T> {

View File

@@ -12,10 +12,12 @@ import java.math.BigInteger;
/**
*
* <p> 详情见: http://www.redkale.org
* <p>
* 详情见: http://www.redkale.org
*
* @author zhangjx
* @param <R>
* @param <W>
* @param <R> Reader输入的子类型
* @param <W> Writer输出的子类型
*/
public final class BigIntegerSimpledCoder<R extends Reader, W extends Writer> extends SimpledCoder<R, W, BigInteger> {

View File

@@ -13,8 +13,8 @@ import org.redkale.convert.Writer;
*
* <p> 详情见: http://www.redkale.org
* @author zhangjx
* @param <R>
* @param <W>
* @param <R> Reader输入的子类型
* @param <W> Writer输出的子类型
*/
public final class BoolArraySimpledCoder<R extends Reader, W extends Writer> extends SimpledCoder<R, W, boolean[]> {

View File

@@ -13,8 +13,8 @@ import org.redkale.convert.Writer;
*
* <p> 详情见: http://www.redkale.org
* @author zhangjx
* @param <R>
* @param <W>
* @param <R> Reader输入的子类型
* @param <W> Writer输出的子类型
*/
public final class BoolSimpledCoder<R extends Reader, W extends Writer> extends SimpledCoder<R, W, Boolean> {

View File

@@ -13,8 +13,8 @@ import org.redkale.convert.Writer;
*
* <p> 详情见: http://www.redkale.org
* @author zhangjx
* @param <R>
* @param <W>
* @param <R> Reader输入的子类型
* @param <W> Writer输出的子类型
*/
public final class ByteArraySimpledCoder<R extends Reader, W extends Writer> extends SimpledCoder<R, W, byte[]> {

View File

@@ -11,10 +11,12 @@ import org.redkale.convert.Writer;
/**
*
* <p> 详情见: http://www.redkale.org
* <p>
* 详情见: http://www.redkale.org
*
* @author zhangjx
* @param <R>
* @param <W>
* @param <R> Reader输入的子类型
* @param <W> Writer输出的子类型
*/
public final class ByteSimpledCoder<R extends Reader, W extends Writer> extends SimpledCoder<R, W, Byte> {

View File

@@ -13,8 +13,8 @@ import org.redkale.convert.Writer;
*
* <p> 详情见: http://www.redkale.org
* @author zhangjx
* @param <R>
* @param <W>
* @param <R> Reader输入的子类型
* @param <W> Writer输出的子类型
*/
public final class CharArraySimpledCoder<R extends Reader, W extends Writer> extends SimpledCoder<R, W, char[]> {

View File

@@ -11,8 +11,8 @@ import org.redkale.convert.*;
*
* <p> 详情见: http://www.redkale.org
* @author zhangjx
* @param <R>
* @param <W>
* @param <R> Reader输入的子类型
* @param <W> Writer输出的子类型
*/
public class CharSequenceSimpledCoder<R extends Reader, W extends Writer> extends SimpledCoder<R, W, CharSequence> {

View File

@@ -14,8 +14,8 @@ import org.redkale.convert.Writer;
*
* <p> 详情见: http://www.redkale.org
* @author zhangjx
* @param <R>
* @param <W>
* @param <R> Reader输入的子类型
* @param <W> Writer输出的子类型
*/
public final class CharSimpledCoder<R extends Reader, W extends Writer> extends SimpledCoder<R, W, Character> {

View File

@@ -12,8 +12,8 @@ import org.redkale.convert.*;
*
* <p> 详情见: http://www.redkale.org
* @author zhangjx
* @param <R>
* @param <W>
* @param <R> Reader输入的子类型
* @param <W> Writer输出的子类型
*/
public final class CompletionHandlerSimpledCoder<R extends Reader, W extends Writer> extends SimpledCoder<R, W, CompletionHandler> {

View File

@@ -14,8 +14,8 @@ import org.redkale.util.*;
*
* <p> 详情见: http://www.redkale.org
* @author zhangjx
* @param <R>
* @param <W>
* @param <R> Reader输入的子类型
* @param <W> Writer输出的子类型
*/
public final class DLongSimpledCoder<R extends Reader, W extends Writer> extends SimpledCoder<R, W, DLong> {

View File

@@ -14,8 +14,8 @@ import java.util.Date;
*
* <p> 详情见: http://www.redkale.org
* @author zhangjx
* @param <R>
* @param <W>
* @param <R> Reader输入的子类型
* @param <W> Writer输出的子类型
*/
public final class DateSimpledCoder<R extends Reader, W extends Writer> extends SimpledCoder<R, W, Date> {

View File

@@ -13,8 +13,8 @@ import org.redkale.convert.Writer;
*
* <p> 详情见: http://www.redkale.org
* @author zhangjx
* @param <R>
* @param <W>
* @param <R> Reader输入的子类型
* @param <W> Writer输出的子类型
*/
public final class DoubleArraySimpledCoder<R extends Reader, W extends Writer> extends SimpledCoder<R, W, double[]> {

View File

@@ -13,8 +13,8 @@ import org.redkale.convert.Writer;
*
* <p> 详情见: http://www.redkale.org
* @author zhangjx
* @param <R>
* @param <W>
* @param <R> Reader输入的子类型
* @param <W> Writer输出的子类型
*/
public final class DoubleSimpledCoder<R extends Reader, W extends Writer> extends SimpledCoder<R, W, Double> {

View File

@@ -15,9 +15,9 @@ import org.redkale.convert.Writer;
* 详情见: http://www.redkale.org
*
* @author zhangjx
* @param <R>
* @param <W>
* @param <E>
* @param <R> Reader输入的子类型
* @param <W> Writer输出的子类型
* @param <E> Enum的子类
*/
public final class EnumSimpledCoder<R extends Reader, W extends Writer, E extends Enum> extends SimpledCoder<R, W, E> {

View File

@@ -13,8 +13,8 @@ import org.redkale.convert.Writer;
*
* <p> 详情见: http://www.redkale.org
* @author zhangjx
* @param <R>
* @param <W>
* @param <R> Reader输入的子类型
* @param <W> Writer输出的子类型
*/
public final class FloatArraySimpledCoder<R extends Reader, W extends Writer> extends SimpledCoder<R, W, float[]> {

View File

@@ -13,8 +13,8 @@ import org.redkale.convert.Writer;
*
* <p> 详情见: http://www.redkale.org
* @author zhangjx
* @param <R>
* @param <W>
* @param <R> Reader输入的子类型
* @param <W> Writer输出的子类型
*/
public final class FloatSimpledCoder<R extends Reader, W extends Writer> extends SimpledCoder<R, W, Float> {

View File

@@ -14,8 +14,8 @@ import java.net.*;
*
* <p> 详情见: http://www.redkale.org
* @author zhangjx
* @param <R>
* @param <W>
* @param <R> Reader输入的子类型
* @param <W> Writer输出的子类型
*/
public final class InetAddressSimpledCoder<R extends Reader, W extends Writer> extends SimpledCoder<R, W, InetAddress> {

View File

@@ -13,8 +13,8 @@ import org.redkale.convert.Writer;
*
* <p> 详情见: http://www.redkale.org
* @author zhangjx
* @param <R>
* @param <W>
* @param <R> Reader输入的子类型
* @param <W> Writer输出的子类型
*/
public final class IntArraySimpledCoder<R extends Reader, W extends Writer> extends SimpledCoder<R, W, int[]> {

View File

@@ -13,8 +13,8 @@ import org.redkale.convert.Writer;
*
* <p> 详情见: http://www.redkale.org
* @author zhangjx
* @param <R>
* @param <W>
* @param <R> Reader输入的子类型
* @param <W> Writer输出的子类型
*/
public final class IntSimpledCoder<R extends Reader, W extends Writer> extends SimpledCoder<R, W, Integer> {

View File

@@ -11,10 +11,12 @@ import org.redkale.convert.Writer;
/**
*
* <p> 详情见: http://www.redkale.org
* <p>
* 详情见: http://www.redkale.org
*
* @author zhangjx
* @param <R>
* @param <W>
* @param <R> Reader输入的子类型
* @param <W> Writer输出的子类型
*/
public final class LongArraySimpledCoder<R extends Reader, W extends Writer> extends SimpledCoder<R, W, long[]> {

View File

@@ -14,8 +14,8 @@ import org.redkale.convert.Writer;
*
* <p> 详情见: http://www.redkale.org
* @author zhangjx
* @param <R>
* @param <W>
* @param <R> Reader输入的子类型
* @param <W> Writer输出的子类型
*/
public final class LongSimpledCoder<R extends Reader, W extends Writer> extends SimpledCoder<R, W, Long> {

View File

@@ -13,8 +13,8 @@ import org.redkale.convert.Writer;
*
* <p> 详情见: http://www.redkale.org
* @author zhangjx
* @param <R>
* @param <W>
* @param <R> Reader输入的子类型
* @param <W> Writer输出的子类型
*/
public final class NumberSimpledCoder<R extends Reader, W extends Writer> extends SimpledCoder<R, W, Number> {

View File

@@ -12,8 +12,8 @@ import org.redkale.convert.*;
*
* <p> 详情见: http://www.redkale.org
* @author zhangjx
* @param <R>
* @param <W>
* @param <R> Reader输入的子类型
* @param <W> Writer输出的子类型
*/
public class PatternSimpledCoder<R extends Reader, W extends Writer> extends SimpledCoder<R, W, Pattern> {

View File

@@ -13,8 +13,8 @@ import org.redkale.convert.Writer;
*
* <p> 详情见: http://www.redkale.org
* @author zhangjx
* @param <R>
* @param <W>
* @param <R> Reader输入的子类型
* @param <W> Writer输出的子类型
*/
public final class ShortArraySimpledCoder<R extends Reader, W extends Writer> extends SimpledCoder<R, W, short[]> {

View File

@@ -13,8 +13,8 @@ import org.redkale.convert.Writer;
*
* <p> 详情见: http://www.redkale.org
* @author zhangjx
* @param <R>
* @param <W>
* @param <R> Reader输入的子类型
* @param <W> Writer输出的子类型
*/
public final class ShortSimpledCoder<R extends Reader, W extends Writer> extends SimpledCoder<R, W, Short> {

View File

@@ -13,8 +13,8 @@ import org.redkale.convert.Writer;
*
* <p> 详情见: http://www.redkale.org
* @author zhangjx
* @param <R>
* @param <W>
* @param <R> Reader输入的子类型
* @param <W> Writer输出的子类型
*/
public final class StringArraySimpledCoder<R extends Reader, W extends Writer> extends SimpledCoder<R, W, String[]> {

View File

@@ -13,8 +13,8 @@ import org.redkale.convert.Writer;
*
* <p> 详情见: http://www.redkale.org
* @author zhangjx
* @param <R>
* @param <W>
* @param <R> Reader输入的子类型
* @param <W> Writer输出的子类型
*/
public final class StringSimpledCoder<R extends Reader, W extends Writer> extends SimpledCoder<R, W, String> {

View File

@@ -13,8 +13,8 @@ import org.redkale.convert.SimpledCoder;
*
* <p> 详情见: http://www.redkale.org
* @author zhangjx
* @param <R>
* @param <W>
* @param <R> Reader输入的子类型
* @param <W> Writer输出的子类型
*/
public class TypeSimpledCoder<R extends Reader, W extends Writer> extends SimpledCoder<R, W, Class> {

View File

@@ -15,7 +15,7 @@ import org.redkale.boot.*;
*
* <p> 详情见: http://www.redkale.org
* @author zhangjx
* @param <T>
* @param <T> Service的子类
*/
public final class ServiceWrapper<T extends Service> {

View File

@@ -27,7 +27,9 @@ import org.redkale.service.DynRemote;
* Service Node Communicate Protocol
* 生成Service的本地模式或远程模式Service-Class的工具类
*
* <p> 详情见: http://www.redkale.org
* <p>
* 详情见: http://www.redkale.org
*
* @author zhangjx
*/
public abstract class Sncp {
@@ -86,8 +88,8 @@ public abstract class Sncp {
/**
* 对类名或者name字符串进行hash。
*
* @param name
* @return
* @param name String
* @return hash值
*/
public static DLong hash(final String name) {
if (name == null || name.isEmpty()) return DLong.ZERO;
@@ -179,10 +181,10 @@ public abstract class Sncp {
*
* 创建Service的本地模式Class
*
* @param <T>
* @param name
* @param serviceClass
* @return
* @param <T> Service子类
* @param name 资源名
* @param serviceClass Service类
* @return Service实例
*/
@SuppressWarnings("unchecked")
public static <T extends Service> Class<? extends T> createLocalServiceClass(final String name, final Class<T> serviceClass) {
@@ -645,15 +647,15 @@ public abstract class Sncp {
*
* 创建本地模式Service实例
*
* @param <T>
* @param name
* @param executor
* @param serviceClass
* @param clientAddress
* @param groups
* @param sameGroupTransports
* @param diffGroupTransports
* @return
* @param <T> Service泛型
* @param name 资源名
* @param executor 线程池
* @param serviceClass Service类
* @param clientAddress 本地IP地址
* @param groups 含同组和异组的组集合
* @param sameGroupTransports 同组的通信组件列表
* @param diffGroupTransports 异组的通信组件列表
* @return Service的本地模式实例
*/
@SuppressWarnings("unchecked")
public static <T extends Service> T createLocalService(final String name, final Consumer<Runnable> executor, final Class<T> serviceClass,
@@ -805,15 +807,16 @@ public abstract class Sncp {
* </pre></blockquote>
*
* 创建远程模式的Service实例
* <p>
* @param <T>
* @param name
* @param executor
* @param serviceClass
* @param clientAddress
* @param groups
* @param transport
* @return
*
* @param <T> Service泛型
* @param name 资源名
* @param executor 线程池
* @param serviceClass Service类
* @param clientAddress 本地IP地址
* @param groups 含同组和异组的组集合
*
* @param transport 通信组件
* @return Service的远程模式实例
*/
@SuppressWarnings("unchecked")
public static <T extends Service> T createRemoteService(final String name, final Consumer<Runnable> executor, final Class<T> serviceClass,

View File

@@ -24,7 +24,9 @@ import org.redkale.service.DynCall;
/**
*
* <p> 详情见: http://www.redkale.org
* <p>
* 详情见: http://www.redkale.org
*
* @author zhangjx
*/
public final class SncpDynServlet extends SncpServlet {
@@ -138,35 +140,34 @@ public final class SncpDynServlet extends SncpServlet {
out.writeByte((byte) 0);
}
/** **
*
* public class TestService implements Service {
* public boolean change(TestBean bean, String name, int id) {
*
* }
* }
*
* public class DynActionTestService_change extends SncpServletAction {
*
* public TestService service;
*
* @Override
* public void action(final BsonReader in, final BsonWriter out) throws Throwable {
* TestBean arg1 = convert.convertFrom(in, paramTypes[1]);
* String arg2 = convert.convertFrom(in, paramTypes[2]);
* int arg3 = convert.convertFrom(in, paramTypes[3]);
* Object rs = service.change(arg1, arg2, arg3);
* callParameter(out, arg1, arg2, arg3);
* convert.convertTo(out, paramTypes[0], rs);
* }
* }
*/
/**
* <blockquote><pre>
* public class TestService implements Service {
* public boolean change(TestBean bean, String name, int id) {
*
* @param service
* @param actionid
* @param method
* @return
* }
* }
*
* public class DynActionTestService_change extends SncpServletAction {
*
* public TestService service;
*
* &#64;Override
* public void action(final BsonReader in, final BsonWriter out) throws Throwable {
* TestBean arg1 = convert.convertFrom(in, paramTypes[1]);
* String arg2 = convert.convertFrom(in, paramTypes[2]);
* int arg3 = convert.convertFrom(in, paramTypes[3]);
* Object rs = service.change(arg1, arg2, arg3);
* callParameter(out, arg1, arg2, arg3);
* convert.convertTo(out, paramTypes[0], rs);
* }
* }
* </pre></blockquote>
*
* @param service Service
* @param actionid 操作ID
* @param method 方法
* @return SncpServletAction
*/
@SuppressWarnings("unchecked")
public static SncpServletAction create(final Service service, final DLong actionid, final Method method) {

View File

@@ -21,9 +21,10 @@ import org.redkale.util.*;
/**
*
* @param <K>
* @param <V>
* <p> 详情见: http://www.redkale.org
* @param <K> key类型
* @param <V> value类型
* <p>
* 详情见: http://www.redkale.org
* @author zhangjx
*/
@AutoLoad(false)

View File

@@ -10,9 +10,11 @@ import org.redkale.convert.json.*;
/**
* 通用的结果对象在常见的HTTP+JSON接口中返回的结果需要含结果码错误信息和实体对象。
*
* <p> 详情见: http://www.redkale.org
* <p>
* 详情见: http://www.redkale.org
*
* @author zhangjx
* @param <T>
* @param <T> 结果对象的泛型
*/
public class RetResult<T> {
@@ -67,7 +69,7 @@ public class RetResult<T> {
/**
* 判断结果是否成功返回, retcode = 0 视为成功, 否则视为错误码
*
* @return
* @return 是否成功
*/
public boolean isSuccess() {
return retcode == 0;
@@ -76,7 +78,7 @@ public class RetResult<T> {
/**
* 结果码 0表示成功、 非0表示错误
*
* @return
* @return 结果码
*/
public int getRetcode() {
return retcode;
@@ -97,7 +99,7 @@ public class RetResult<T> {
/**
* 结果对象, 通常只有在retcode = 0时值才有效
*
* @return
* @return 结果对象
*/
public T getResult() {
return result;

View File

@@ -12,11 +12,13 @@ import org.redkale.util.*;
* 注意: "$"是一个很特殊的Service.name值 。 被标记为@Resource(name = "$") 的Service的资源名与所属父Service的资源名一致。
*
* <p>
* @Resource(name = ".*")
* private HashMap<String, XXXService> nodemap;
* &#64;Resource(name = ".*")
* private HashMap&lt;String, XXXService&gt; nodemap;
* 被注入的多个XXXService实例 但不会包含自身的XXXService。
*
* <p> 详情见: http://www.redkale.org
* <p>
* 详情见: http://www.redkale.org
*
* @author zhangjx
*/
public interface Service {
@@ -24,20 +26,25 @@ public interface Service {
/**
* 该方法必须是可以重复调用, 当reload时需要重复调用init方法
*
* @param config
* @param config 配置参数
*/
default void init(AnyValue config) {
}
/**
* 进程退出时调用Service销毁
*
* @param config 配置参数
*/
default void destroy(AnyValue config) {
}
/**
* Service的name 一个Service在同一进程内可以包含多个实例 使用name区分
* <p>
* @return
*
* @return 资源名
*/
default String name() {
return "";

View File

@@ -11,8 +11,8 @@ import java.util.*;
/**
*
* @param <K>
* @param <V>
* @param <K> key的类型
* @param <V> value的类型
* <p> 详情见: http://www.redkale.org
* @author zhangjx
*/

View File

@@ -11,10 +11,12 @@ import org.redkale.util.*;
/**
*
* <p> 详情见: http://www.redkale.org
* <p>
* 详情见: http://www.redkale.org
*
* @author zhangjx
* @param <T>
* @param <F>
* @param <T> Entity类的类型
* @param <F> 字段的类型
*/
public final class DataCallArrayAttribute<T, F> implements Attribute<T[], F> {

View File

@@ -22,7 +22,9 @@ import org.redkale.util.*;
/**
*
* <p> 详情见: http://www.redkale.org
* <p>
* 详情见: http://www.redkale.org
*
* @author zhangjx
*/
@SuppressWarnings("unchecked")
@@ -286,9 +288,9 @@ public final class DataDefaultSource implements DataSource, Function<Class, Enti
/**
* 将entity的对象全部加载到Cache中去如果clazz没有被@javax.persistence.Cacheable注解则不做任何事
* <p>
* @param <T>
* @param clazz
*
* @param <T> Entity类泛型
* @param clazz Entity类
*/
public <T> void refreshCache(Class<T> clazz) {
EntityInfo<T> info = loadEntityInfo(clazz);
@@ -301,8 +303,8 @@ public final class DataDefaultSource implements DataSource, Function<Class, Enti
/**
* 新增对象, 必须是Entity对象
*
* @param <T>
* @param values
* @param <T> Entity类泛型
* @param values Entity对象
*/
@Override
public <T> void insert(T... values) {
@@ -478,8 +480,8 @@ public final class DataDefaultSource implements DataSource, Function<Class, Enti
/**
* 删除对象, 必须是Entity对象
*
* @param <T>
* @param values
* @param <T> Entity类泛型
* @param values Entity对象
*/
@Override
public <T> void delete(T... values) {
@@ -616,8 +618,8 @@ public final class DataDefaultSource implements DataSource, Function<Class, Enti
/**
* 更新对象, 必须是Entity对象
*
* @param <T>
* @param values
* @param <T> Entity类泛型
* @param values Entity对象
*/
@Override
public <T> void update(T... values) {
@@ -705,11 +707,11 @@ public final class DataDefaultSource implements DataSource, Function<Class, Enti
/**
* 根据主键值更新对象的column对应的值 必须是Entity Class
*
* @param <T>
* @param clazz
* @param id
* @param column
* @param value
* @param <T> Entity类的泛型
* @param clazz Entity类
* @param id 主键值
* @param column 过滤字段名
* @param value 过滤字段值
*/
@Override
public <T> void updateColumn(Class<T> clazz, Serializable id, String column, Serializable value) {
@@ -757,12 +759,13 @@ public final class DataDefaultSource implements DataSource, Function<Class, Enti
/**
* 根据主键值给对象的column对应的值+incvalue 必须是Entity Class
* 等价SQL: UPDATE {clazz} SET {column} = {column} + {incvalue} WHERE {primary} = {id}
*
* @param <T>
* @param clazz
* @param id
* @param column
* @param incvalue
* @param <T> Entity类的泛型
* @param clazz Entity类
* @param id 主键值
* @param column 字段名
* @param incvalue 字段加值
*/
@Override
public <T> void updateColumnIncrement(Class<T> clazz, Serializable id, String column, long incvalue) {
@@ -812,12 +815,13 @@ public final class DataDefaultSource implements DataSource, Function<Class, Enti
/**
* 根据主键值给对象的column对应的值 &#38; andvalue 必须是Entity Class
* 等价SQL: UPDATE {clazz} SET {column} = {column} &#38; {incvalue} WHERE {primary} = {id}
*
* @param <T>
* @param clazz
* @param id
* @param column
* @param andvalue
* @param <T> Entity类的泛型
* @param clazz Entity类
* @param id 主键值
* @param column 字段名
* @param andvalue 字段与值
*/
@Override
public <T> void updateColumnAnd(Class<T> clazz, Serializable id, String column, long andvalue) {
@@ -867,12 +871,13 @@ public final class DataDefaultSource implements DataSource, Function<Class, Enti
/**
* 根据主键值给对象的column对应的值 | andvalue 必须是Entity Class
* 等价SQL: UPDATE {clazz} SET {column} = {column} | {incvalue} WHERE {primary} = {id}
*
* @param <T>
* @param clazz
* @param id
* @param column
* @param orvalue
* @param <T> Entity类的泛型
* @param clazz Entity类
* @param id 主键值
* @param column 字段名
* @param orvalue 字段或值
*/
@Override
public <T> void updateColumnOr(Class<T> clazz, Serializable id, String column, long orvalue) {
@@ -923,9 +928,9 @@ public final class DataDefaultSource implements DataSource, Function<Class, Enti
/**
* 更新对象指定的一些字段, 必须是Entity对象
*
* @param <T>
* @param value
* @param columns
* @param <T> Entity类的泛型
* @param value Entity对象
* @param columns 需要更新的字段
*/
@Override
public <T> void updateColumns(final T value, final String... columns) {
@@ -1134,10 +1139,10 @@ public final class DataDefaultSource implements DataSource, Function<Class, Enti
/**
* 根据主键获取对象
*
* @param <T>
* @param clazz
* @param pk
* @return
* @param <T> Entity类的泛型
* @param clazz Entity类
* @param pk 主键值
* @return Entity对象
*/
@Override
public <T> T find(Class<T> clazz, Serializable pk) {
@@ -1404,13 +1409,13 @@ public final class DataDefaultSource implements DataSource, Function<Class, Enti
/**
* 根据指定参数查询对象某个字段的集合
* <p>
* @param <T>
* @param <V>
* @param selectedColumn
* @param clazz
* @param flipper
* @param bean
* @return
* @param <T> Entity类的泛型
* @param <V> 字段值的类型
* @param selectedColumn 字段名
* @param clazz Entity类
* @param flipper 翻页对象
* @param bean 过滤Bean
* @return 字段集合
*/
@Override
public <T, V extends Serializable> Sheet<V> queryColumnSheet(final String selectedColumn, Class<T> clazz, final Flipper flipper, final FilterBean bean) {
@@ -1459,11 +1464,11 @@ public final class DataDefaultSource implements DataSource, Function<Class, Enti
/**
* 根据指定字段值查询对象集合
*
* @param <T>
* @param clazz
* @param column
* @param key
* @return
* @param <T> Entity类的泛型
* @param clazz Entity类
* @param column 过滤字段名
* @param key 过滤字段值
* @return Entity对象的集合
*/
@Override
public <T> List<T> queryList(final Class<T> clazz, final String column, final Serializable key) {
@@ -1479,10 +1484,10 @@ public final class DataDefaultSource implements DataSource, Function<Class, Enti
/**
* 根据过滤对象FilterBean查询对象集合
*
* @param <T>
* @param clazz
* @param bean
* @return
* @param <T> Entity类的泛型
* @param clazz Entity类
* @param bean 过滤Bean
* @return Entity对象集合
*/
@Override
public <T> List<T> queryList(final Class<T> clazz, final FilterBean bean) {
@@ -1510,11 +1515,11 @@ public final class DataDefaultSource implements DataSource, Function<Class, Enti
/**
* 根据过滤对象FilterBean查询对象集合 对象只填充或排除SelectField指定的字段
*
* @param <T>
* @param clazz
* @param selects
* @param bean
* @return
* @param <T> Entity类的泛型
* @param clazz Entity类
* @param selects 收集的字段
* @param bean 过滤Bean
* @return Entity对象的集合
*/
@Override
public <T> List<T> queryList(final Class<T> clazz, final SelectColumn selects, final FilterBean bean) {
@@ -1600,11 +1605,11 @@ public final class DataDefaultSource implements DataSource, Function<Class, Enti
/**
* 根据过滤对象FilterBean和翻页对象Flipper查询一页的数据
*
* @param <T>
* @param clazz
* @param flipper
* @param bean
* @return
* @param <T> Entity类的泛型
* @param clazz Entity类
* @param flipper 翻页对象
* @param bean 过滤Bean
* @return Entity对象的集合
*/
@Override
public <T> Sheet<T> querySheet(final Class<T> clazz, final Flipper flipper, final FilterBean bean) {
@@ -1632,12 +1637,12 @@ public final class DataDefaultSource implements DataSource, Function<Class, Enti
/**
* 根据过滤对象FilterBean和翻页对象Flipper查询一页的数据 对象只填充或排除SelectField指定的字段
*
* @param <T>
* @param clazz
* @param selects
* @param flipper
* @param bean
* @return
* @param <T> Entity类的泛型
* @param clazz Entity类
* @param selects 收集的字段集合
* @param flipper 翻页对象
* @param bean 过滤Bean
* @return Entity对象的集合
*/
@Override
public <T> Sheet<T> querySheet(final Class<T> clazz, final SelectColumn selects, final Flipper flipper, final FilterBean bean) {

View File

@@ -6,7 +6,7 @@
package org.redkale.source;
/**
* @Resource(name = "property.datasource.nodeid")
* &#64;Resource(name = "property.datasource.nodeid")
*
* <p> 详情见: http://www.redkale.org
* @author zhangjx

View File

@@ -12,7 +12,9 @@ import org.redkale.util.*;
/**
*
* <p> 详情见: http://www.redkale.org
* <p>
* 详情见: http://www.redkale.org
*
* @author zhangjx
*/
@SuppressWarnings("unchecked")
@@ -22,8 +24,8 @@ public interface DataSource {
/**
* 新增对象, 必须是Entity对象
*
* @param <T>
* @param values
* @param <T> 泛型
* @param values Entity对象
*/
public <T> void insert(final T... values);
@@ -34,11 +36,19 @@ public interface DataSource {
/**
* 删除对象, 必须是Entity对象
*
* @param <T>
* @param values
* @param <T> 泛型
* @param values Entity对象
*/
public <T> void delete(final T... values);
/**
* 根据主键值删除数据
* 等价SQL: DELETE FROM WHERE {primary} IN {ids}
*
* @param <T> Entity类的泛型
* @param clazz Entity类
* @param ids 主键值
*/
public <T> void delete(final Class<T> clazz, final Serializable... ids);
public <T> void delete(final Class<T> clazz, final FilterNode node);
@@ -54,8 +64,8 @@ public interface DataSource {
/**
* 更新对象, 必须是Entity对象
*
* @param <T>
* @param values
* @param <T> 泛型
* @param values Entity对象
*/
public <T> void update(final T... values);
@@ -112,10 +122,10 @@ public interface DataSource {
/**
* 根据主键获取对象
*
* @param <T>
* @param clazz
* @param pk
* @return
* @param <T> 泛型
* @param clazz Entity类
* @param pk 主键值
* @return Entity对象
*/
public <T> T find(final Class<T> clazz, final Serializable pk);
@@ -162,13 +172,13 @@ public interface DataSource {
/**
* 根据指定字段值查询对象某个字段的集合
*
* @param <T>
* @param <V>
* @param selectedColumn
* @param clazz
* @param column
* @param key
* @return
* @param <T> Entity泛型
* @param <V> 字段类型
* @param selectedColumn 字段名
* @param clazz Entity类
* @param column 过滤字段名
* @param key 过滤字段值
* @return 字段值的集合
*/
public <T, V extends Serializable> HashSet<V> queryColumnSet(final String selectedColumn, final Class<T> clazz, final String column, final Serializable key);
@@ -197,14 +207,14 @@ public interface DataSource {
/**
* 根据指定参数查询对象某个字段的集合
* <p>
* @param <T>
* @param <V>
* @param selectedColumn
* @param clazz
* @param flipper
* @param bean
* @return
*
* @param <T> Entity泛型
* @param <V> 字段类型
* @param selectedColumn 字段名
* @param clazz Entity类
* @param flipper 翻页对象
* @param bean 过滤Bean
* @return 结果集合
*/
public <T, V extends Serializable> Sheet<V> queryColumnSheet(final String selectedColumn, final Class<T> clazz, final Flipper flipper, final FilterBean bean);
@@ -218,11 +228,11 @@ public interface DataSource {
/**
* 根据指定字段值查询对象集合
*
* @param <T>
* @param clazz
* @param column
* @param key
* @return
* @param <T> Entity泛型
* @param clazz Entity类
* @param column 过滤字段名
* @param key 过滤字段值
* @return Entity的List
*/
public <T> List<T> queryList(final Class<T> clazz, final String column, final Serializable key);
@@ -269,11 +279,11 @@ public interface DataSource {
/**
* 根据指定参数查询对象某个对象的集合页
* <p>
* @param <T>
* @param clazz
* @param flipper
* @param bean
* @return
* @param <T> Entity泛型
* @param clazz Entity类
* @param flipper 翻页对象
* @param bean 过滤Bean
* @return Entity的Sheet
*/
public <T> Sheet<T> querySheet(final Class<T> clazz, final Flipper flipper, final FilterBean bean);

View File

@@ -22,8 +22,8 @@ public @interface DistributeGenerator {
/**
* 如果allocationSize的值小于或等于1,则主键不会加上nodeid
* <p>
* @return
*
* @return allocationSize
*/
int allocationSize() default 1000;
}

View File

@@ -18,9 +18,11 @@ import org.redkale.util.*;
/**
*
* <p> 详情见: http://www.redkale.org
* <p>
* 详情见: http://www.redkale.org
*
* @author zhangjx
* @param <T>
* @param <T> Entity类的泛型
*/
public final class EntityCache<T> {

View File

@@ -19,9 +19,11 @@ import org.redkale.util.*;
/**
*
* <p> 详情见: http://www.redkale.org
* <p>
* 详情见: http://www.redkale.org
*
* @author zhangjx
* @param <T>
* @param <T> Entity类的泛型
*/
@SuppressWarnings("unchecked")
public final class EntityInfo<T> {
@@ -266,8 +268,8 @@ public final class EntityInfo<T> {
/**
* 是否虚拟类
* <p>
* @return
*
* @return 是否虚拟类
*/
public boolean isVirtualEntity() {
return table == null;

View File

@@ -11,7 +11,9 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
*
* <p> 详情见: http://www.redkale.org
* <p>
* 详情见: http://www.redkale.org
*
* @author zhangjx
*/
@Inherited
@@ -23,24 +25,24 @@ public @interface FilterColumn {
/**
* 对应Entity Class中字段的名称 而不是SQL字段名称
*
* @return
* @return 字段名
*/
String name() default "";
/**
* 当字段类型是Number时 如果值>=least() 则需要过滤, 否则跳过该字段
* 当字段类型是Number时 如果值&gt;=least() 则需要过滤, 否则跳过该字段
*
* @return
* @return 最小可过滤值
*/
long least() default 1;
/**
* express的默认值根据字段类型的不同而不同:
* 数组 --> IN
* Range --> Between
* 其他 --> =
* 数组 --&gt; IN
* Range --&gt; Between
* 其他 --&gt; =
*
* @return
* @return 字段表达式
*/
FilterExpress express() default FilterExpress.EQUAL;

View File

@@ -11,7 +11,9 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
*
* <p> 详情见: http://www.redkale.org
* <p>
* 详情见: http://www.redkale.org
*
* @author zhangjx
*/
@Inherited
@@ -23,7 +25,7 @@ public @interface FilterJoinColumn {
/**
* 关联表 通常join表默认别名为b/c/d/...自增, 被join表默认别名为a
*
* @return
* @return 关联表
*/
Class table();
@@ -31,9 +33,9 @@ public @interface FilterJoinColumn {
*
* 多个关联字段, 默认使用join表(b)的主键, join表与被join表(a)的字段必须一样
* 例如: SELECT a.* FROM user a INNER JOIN record b ON a.userid = b.userid AND a.usertype = b.usertype
* 那么注解为: @FilterJoinColumn(table = Record.class, columns = {"userid", "usertype"})
* <p>
* @return
* 那么注解为: &#64;FilterJoinColumn(table = Record.class, columns = {"userid", "usertype"})
*
* @return 关联字段
*/
String[] columns();
}

View File

@@ -17,7 +17,9 @@ import org.redkale.util.*;
* 在调用 createSQLExpress 之前必须先调用 createSQLJoin
* 在调用 createPredicate 之前必须先调用 isCacheUseable
*
* <p> 详情见: http://www.redkale.org
* <p>
* 详情见: http://www.redkale.org
*
* @author zhangjx
*/
public class FilterNode {
@@ -112,11 +114,11 @@ public class FilterNode {
/**
* 该方法需要重载
*
* @param <T>
* @param func
* @param joinTabalis
* @param info
* @return
* @param <T> Entity类的泛型
* @param func EntityInfo的加载器
* @param joinTabalis 关联表集合
* @param info Entity类的EntityInfo
* @return SQL的join语句 不存在返回null
*/
protected <T> CharSequence createSQLJoin(final Function<Class, EntityInfo> func, final Map<Class, String> joinTabalis, final EntityInfo<T> info) {
if (joinTabalis == null || this.nodes == null) return null;
@@ -133,7 +135,7 @@ public class FilterNode {
/**
* 该方法需要重载
*
* @return
* @return 是否存在关联表
*/
protected boolean isjoin() {
if (this.nodes == null) return false;
@@ -160,8 +162,8 @@ public class FilterNode {
/**
* 该方法需要重载
*
* @param entityApplyer
* @return
* @param entityApplyer EntityInfo的加载器
* @return 是否可以使用缓存
*/
protected boolean isCacheUseable(final Function<Class, EntityInfo> entityApplyer) {
if (this.nodes == null) return true;
@@ -174,10 +176,10 @@ public class FilterNode {
/**
* 该方法需要重载
*
* @param <T>
* @param joinTabalis
* @param info
* @return
* @param <T> Entity类的泛型
* @param joinTabalis 关联表的集合
* @param info EntityInfo
* @return JOIN的SQL语句
*/
protected <T> CharSequence createSQLExpress(final EntityInfo<T> info, final Map<Class, String> joinTabalis) {
CharSequence sb0 = this.column == null || info == null ? null : createElementSQLExpress(info, joinTabalis == null ? null : joinTabalis.get(info.getType()));

View File

@@ -13,7 +13,7 @@ import java.util.function.*;
* 详情见: http://www.redkale.org
*
* @author zhangjx
* @param <E>
* @param <E> Comparable的子类型
*/
public interface Range<E extends Comparable> extends java.io.Serializable, Predicate<E> {