增加javadoc注释

This commit is contained in:
Redkale
2017-03-02 10:41:15 +08:00
parent d948c7af47
commit 525e65d152
9 changed files with 116 additions and 35 deletions

View File

@@ -48,65 +48,99 @@ import org.w3c.dom.*;
*/
public final class Application {
//当前进程启动的时间, 类型: long
/**
* 当前进程启动的时间, 类型: long
*/
public static final String RESNAME_APP_TIME = "APP_TIME";
//当前进程的根目录, 类型String、File、Path
/**
* 当前进程的根目录, 类型String、File、Path
*/
public static final String RESNAME_APP_HOME = "APP_HOME";
//application.xml 文件中resources节点的内容 类型: AnyValue
/**
* application.xml 文件中resources节点的内容 类型: AnyValue
*/
public static final String RESNAME_APP_GRES = "APP_GRES";
//当前进程节点的name 类型String
/**
* 当前进程节点的name 类型String
*/
public static final String RESNAME_APP_NODE = "APP_NODE";
//当前进程节点的IP地址 类型InetAddress、String
/**
* 当前进程节点的IP地址 类型InetAddress、String
*/
public static final String RESNAME_APP_ADDR = "APP_ADDR";
//当前Service的IP地址+端口 类型: SocketAddress、InetSocketAddress、String
/**
* 当前Service的IP地址+端口 类型: SocketAddress、InetSocketAddress、String
*/
public static final String RESNAME_SERVER_ADDR = "SERVER_ADDR";
//当前SNCP Server所属的组 类型: String
/**
* 当前SNCP Server所属的组 类型: String
*/
public static final String RESNAME_SERVER_GROUP = "SERVER_GROUP";
//当前Server的ROOT目录 类型String、File、Path
/**
* 当前Server的ROOT目录 类型String、File、Path
*/
public static final String RESNAME_SERVER_ROOT = Server.RESNAME_SERVER_ROOT;
//每个地址对应的Group名
final Map<InetSocketAddress, String> globalNodes = new HashMap<>();
//协议地址的Group集合
final Map<String, GroupInfo> globalGroups = new HashMap<>();
//本地IP地址
final InetAddress localAddress;
//CacheSource 资源
final List<CacheSource> cacheSources = new CopyOnWriteArrayList<>();
//DataSource 资源
final List<DataSource> dataSources = new CopyOnWriteArrayList<>();
//NodeServer 资源
final List<NodeServer> servers = new CopyOnWriteArrayList<>();
//传输端的ByteBuffer对象池
final ObjectPool<ByteBuffer> transportBufferPool;
//传输端的线程池
final ExecutorService transportExecutor;
//传输端的ChannelGroup
final AsynchronousChannelGroup transportChannelGroup;
//全局根ResourceFactory
final ResourceFactory resourceFactory = ResourceFactory.root();
//临时计数器
CountDownLatch servicecdl; //会出现两次赋值
//--------------------------------------------------------------------------------------------
//是否用于main方法运行
private final boolean singletonrun;
//根WatchFactory
private final WatchFactory watchFactory = WatchFactory.root();
//进程根目录
private final File home;
//日志
private final Logger logger;
//服务配置项
private final AnyValue config;
//服务启动时间
private final long startTime = System.currentTimeMillis();
//Server启动的计数器用于确保所有Server都启动完后再进行下一步处理
private final CountDownLatch serversLatch;
private Application(final AnyValue config) {

View File

@@ -28,33 +28,46 @@ import org.redkale.util.*;
@SuppressWarnings("unchecked")
public final class EntityCache<T> {
//日志
private static final Logger logger = Logger.getLogger(EntityCache.class.getName());
//主键与对象的键值对
private ConcurrentHashMap<Serializable, T> map = new ConcurrentHashMap();
// CopyOnWriteArrayList 插入慢、查询快; 10w数据插入需要3.2秒; ConcurrentLinkedQueue 插入快、查询慢10w数据查询需要 0.062秒, 查询慢40%;
private Collection<T> list = new ConcurrentLinkedQueue();
//Flipper.sort转换成Comparator的缓存
private final Map<String, Comparator<T>> sortComparators = new ConcurrentHashMap<>();
//Entity类
private final Class<T> type;
//接口返回的对象是否需要复制一份
private final boolean needcopy;
//Entity构建器
private final Creator<T> creator;
//主键字段
private final Attribute<T, Serializable> primary;
//新增时的复制器, 排除了标记为&#064;Transient的字段
private final Reproduce<T, T> newReproduce;
//修改时的复制器, 排除了标记为&#064;Transient或&#064;Column(updatable=false)的字段
private final Reproduce<T, T> chgReproduce;
//是否已经全量加载过
private volatile boolean fullloaded;
//Entity信息
final EntityInfo<T> info;
//&#064;Cacheable的定时更新秒数为0表示不定时更新
final int interval;
//&#064;Cacheable的定时器
private ScheduledThreadPoolExecutor scheduler;
public EntityCache(final EntityInfo<T> info, final Cacheable c) {

View File

@@ -29,21 +29,25 @@ import org.redkale.util.*;
@SuppressWarnings("unchecked")
public final class EntityInfo<T> {
//全局静态资源
private static final ConcurrentHashMap<Class, EntityInfo> entityInfos = new ConcurrentHashMap<>();
//日志
private static final Logger logger = Logger.getLogger(EntityInfo.class);
//Entity类的类
//Entity类名
private final Class<T> type;
//类对应的数据表名, 如果是VirtualEntity 类, 则该字段为null
final String table;
//Entity构建器
private final Creator<T> creator;
//主键
final Attribute<T, Serializable> primary;
//Entity缓存对象
private final EntityCache<T> cache;
//key是field的name 不是sql字段。
@@ -56,45 +60,64 @@ public final class EntityInfo<T> {
//只有field.name 与 Column.name不同才存放在aliasmap里.
private final Map<String, String> aliasmap;
//所有可更新字段,即排除了主键字段和标记为&#064;Column(updatable=false)的字段
private final Map<String, Attribute<T, Serializable>> updateAttributeMap = new HashMap<>();
final String containSQL; //用于反向LIKE使用
//用于反向LIKE使用
final String containSQL;
final String notcontainSQL; //用于反向LIKE使用
//用于反向LIKE使用
final String notcontainSQL;
final String tablenotexistSqlstates; //用于判断表不存在的使用, 多个SQLState用;隔开
//用于判断表不存在的使用, 多个SQLState用;隔开
final String tablenotexistSqlstates;
final String tablecopySQL; //用于复制表结构使用
//用于复制表结构使用
final String tablecopySQL;
final Set<String> tables = new HashSet<>(); //用于存在table_20160202类似这种分布式表
//用于存在table_20160202类似这种分布式表
final Set<String> tables = new HashSet<>();
//分表 策略
final DistributeTableStrategy<T> tableStrategy;
//根据主键查找单个对象的SQL
final String querySQL;
private final Attribute<T, Serializable>[] queryAttributes; //数据库中所有字段
//数据库中所有字段
private final Attribute<T, Serializable>[] queryAttributes;
//新增SQL 含 ?,即排除了自增长主键和标记为&#064;Column(insertable=false)的字段
private final String insertSQL;
final Attribute<T, Serializable>[] insertAttributes; //数据库中所有可新增字段
//数据库中所有可新增字段
final Attribute<T, Serializable>[] insertAttributes;
//根据主键更新所有可更新字段的SQL
private final String updateSQL;
final Attribute<T, Serializable>[] updateAttributes; //数据库中所有可更新字段
//数据库中所有可更新字段
final Attribute<T, Serializable>[] updateAttributes;
//根据主键删除记录的SQL
private final String deleteSQL;
//日志级别从LogLevel获取
private final int logLevel;
//Flipper.sort转换成以ORDER BY开头SQL的缓存
private final Map<String, String> sortOrderbySqls = new ConcurrentHashMap<>();
//---------------------计算主键值----------------------------
//是否由数据库生成主键值
final boolean autoGenerated;
//是否UUID主键
final boolean autouuid;
//所属的DataSource
final DataSource source;
//全量数据的加载器
final BiFunction<DataSource, Class, List> fullloader;
//------------------------------------------------------------

View File

@@ -38,10 +38,10 @@ public @interface FilterColumn {
long least() default 1;
/**
* express的默认值根据字段类型的不同而不同:
* 数组 --&gt; IN
* Range --&gt; Between
* 其他 --&gt; =
* express的默认值根据字段类型的不同而不同: <br>
* 数组 --&gt; IN <br>
* Range --&gt; Between <br>
* 其他 --&gt; = <br>
*
* @return 字段表达式
*/

View File

@@ -10,9 +10,9 @@ import static java.lang.annotation.ElementType.FIELD;
import java.lang.annotation.*;
/**
* 默认情况下FilterBean下的过滤字段之间是AND关系。
* 当需要使用OR或AND OR组合过滤查询时需要使用 FilterGroup。
* FilterGroup 的value 必须是[OR]或者[AND]开头, 多级需要用点.分隔。 (注: 暂时不支持多级)
* 默认情况下FilterBean下的过滤字段之间是AND关系。 <br>
* 当需要使用OR或AND OR组合过滤查询时需要使用 FilterGroup。 <br>
* FilterGroup 的value 必须是[OR]或者[AND]开头, 多级需要用点.分隔。 (注: 暂时不支持多级) <br>
* 示例一:
* <blockquote><pre>
* public class TestFilterBean implements FilterBean {
@@ -49,9 +49,9 @@ import java.lang.annotation.*;
* private int birthday;
* }
* </pre></blockquote>
* 转换的SQL语句为: WHERE id = ? AND ((desc LIKE ? AND name LIKE ?) OR (age = ? OR birthday = ?))
* 因为默认是AND关系 &#64;FilterGroup("") 等价于 &#64;FilterGroup("[AND]")
* 所以示例二的&#64;FilterGroup("[OR]g1.[AND]subg1") 可以简化为 &#64;FilterGroup("[OR]g1.subg1")
* 转换的SQL语句为: WHERE id = ? AND ((desc LIKE ? AND name LIKE ?) OR (age = ? OR birthday = ?)) <br>
* 因为默认是AND关系 &#64;FilterGroup("") 等价于 &#64;FilterGroup("[AND]") <br>
* 所以示例二的&#64;FilterGroup("[OR]g1.[AND]subg1") 可以简化为 &#64;FilterGroup("[OR]g1.subg1") <br>
*/
/**
* <p>

View File

@@ -9,7 +9,7 @@ import java.util.Objects;
/**
* FilterKey主要用于自身字段间的表达式, 如: a.recordid = a.parentid , a.parentid就需要FilterKey来表示 new FilterKey("parentid")
*
* <br>
* 注意该类型不支持表达式FV_XXX、BETWEEN、NOTBETWEEN、IN、NOTIN
*
* <p>

View File

@@ -16,7 +16,7 @@ import org.redkale.util.*;
* 注意: <br>
* column的值以#开头的视为虚拟字段,不在过滤范围内 <br>
* 在调用 createSQLExpress 之前必须先调用 createSQLJoin <br>
* 在调用 createPredicate 之前必须先调用 isCacheUseable
* 在调用 createPredicate 之前必须先调用 isCacheUseable <br>
*
* <p>
* 详情见: https://redkale.org

View File

@@ -8,8 +8,7 @@ package org.redkale.source;
import java.io.Serializable;
/**
* 翻页对象
* offset从0开始
* 翻页对象, offset从0开始
*
* <p>
* 详情见: https://redkale.org

View File

@@ -12,7 +12,7 @@ import java.util.*;
import java.util.function.*;
/**
* VirtualEntity表示虚拟的数据实体类 通常Entity都会映射到数据库中的某个表而标记为VirtualEntity的Entity类只存在DataCache中
* VirtualEntity表示虚拟的数据实体类 通常Entity都会映射到数据库中的某个表而标记为VirtualEntity的Entity类只存在EntityCache中
*
* <p>
* 详情见: https://redkale.org
@@ -24,12 +24,24 @@ import java.util.function.*;
@Retention(RUNTIME)
public @interface VirtualEntity {
//DataSource是否直接返回对象的真实引用 而不是copy一份
/**
* DataSource是否直接返回对象的真实引用 而不是copy一份
*
* @return boolean
*/
boolean direct() default false;
//初始化时数据的加载器
/**
* 初始化时数据的加载器
*
* @return Class
*/
Class<? extends BiFunction<DataSource, Class, List>> loader() default DefaultFunctionLoader.class;
/**
* 默认全量加载器
*
*/
public static class DefaultFunctionLoader implements BiFunction<DataSource, Class, List> {
@Override