javax.annotation包迁移至org.redkale.annotation; javax.persistence包迁移至org.redkale.persistence
This commit is contained in:
@@ -16,16 +16,16 @@
|
||||
*/
|
||||
package javax.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 值越大,优先级越高
|
||||
*
|
||||
* @since Common Annotations 1.2
|
||||
*
|
||||
* @deprecated replace by org.redkale.annotation.Priority
|
||||
*/
|
||||
@Deprecated
|
||||
@Target({ElementType.TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Priority {
|
||||
|
||||
@@ -5,14 +5,14 @@
|
||||
*/
|
||||
package javax.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @since Common Annotations 1.0
|
||||
*
|
||||
* @deprecated replace by org.redkale.annotation.Resource
|
||||
*/
|
||||
@Deprecated
|
||||
@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Resource {
|
||||
@@ -32,15 +32,6 @@ public @interface Resource {
|
||||
// APPLICATION
|
||||
// }
|
||||
//
|
||||
/**
|
||||
* 是否必须存在
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
public boolean required() default false;
|
||||
|
||||
/**
|
||||
* 资源名称
|
||||
*
|
||||
|
||||
@@ -17,8 +17,7 @@ package javax.persistence;
|
||||
|
||||
import static java.lang.annotation.ElementType.TYPE;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* Specifies whether an entity should be cached if caching is enabled
|
||||
@@ -33,7 +32,10 @@ import java.lang.annotation.Target;
|
||||
* not be cached by the provider.
|
||||
*
|
||||
* @since Java Persistence 2.0
|
||||
*
|
||||
* @deprecated replace by org.redkale.persistence.Cacheable
|
||||
*/
|
||||
@Deprecated
|
||||
@Target({TYPE})
|
||||
@Retention(RUNTIME)
|
||||
public @interface Cacheable {
|
||||
|
||||
@@ -15,11 +15,9 @@
|
||||
***************************************************************************** */
|
||||
package javax.persistence;
|
||||
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.Retention;
|
||||
import static java.lang.annotation.ElementType.METHOD;
|
||||
import static java.lang.annotation.ElementType.FIELD;
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* Specifies the mapped column for a persistent property or field.
|
||||
@@ -48,7 +46,10 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
*
|
||||
*
|
||||
* @since Java Persistence 1.0
|
||||
*
|
||||
* @deprecated replace by org.redkale.persistence.Column
|
||||
*/
|
||||
@Deprecated
|
||||
@Target({METHOD, FIELD})
|
||||
@Retention(RUNTIME)
|
||||
public @interface Column {
|
||||
|
||||
@@ -15,16 +15,19 @@
|
||||
******************************************************************************/
|
||||
package javax.persistence;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
import static java.lang.annotation.ElementType.TYPE;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* Specifies that the class is an entity. This annotation is applied to the
|
||||
* entity class.
|
||||
*
|
||||
* @since Java Persistence 1.0
|
||||
*
|
||||
* @deprecated replace by org.redkale.persistence.Entity
|
||||
*/
|
||||
@Deprecated
|
||||
@Inherited
|
||||
@Documented
|
||||
@Target(TYPE)
|
||||
|
||||
@@ -15,11 +15,9 @@
|
||||
******************************************************************************/
|
||||
package javax.persistence;
|
||||
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.Retention;
|
||||
import static java.lang.annotation.ElementType.FIELD;
|
||||
import static java.lang.annotation.ElementType.METHOD;
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* Specifies the primary key of an entity.
|
||||
@@ -48,7 +46,10 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
* see GeneratedValue
|
||||
*
|
||||
* @since Java Persistence 1.0
|
||||
*
|
||||
* @deprecated replace by org.redkale.persistence.Id
|
||||
*/
|
||||
@Deprecated
|
||||
@Target({METHOD, FIELD})
|
||||
@Retention(RUNTIME)
|
||||
|
||||
|
||||
@@ -15,8 +15,7 @@
|
||||
package javax.persistence;
|
||||
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* Used in schema generation to specify creation of an index.
|
||||
@@ -38,8 +37,11 @@ import java.lang.annotation.Target;
|
||||
* <code>ASC</code> (ascending order) is assumed.
|
||||
*
|
||||
* @since Java Persistence 2.1
|
||||
*
|
||||
* @deprecated replace by org.redkale.persistence.Index
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
@Target({})
|
||||
@Retention(RUNTIME)
|
||||
public @interface Index {
|
||||
|
||||
@@ -15,10 +15,9 @@
|
||||
***************************************************************************** */
|
||||
package javax.persistence;
|
||||
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.Retention;
|
||||
import static java.lang.annotation.ElementType.TYPE;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* Specifies the primary table for the annotated entity. Additional
|
||||
@@ -37,7 +36,10 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
* </pre>
|
||||
*
|
||||
* @since Java Persistence 1.0
|
||||
*
|
||||
* @deprecated replace by org.redkale.persistence.Table
|
||||
*/
|
||||
@Deprecated
|
||||
@Target(TYPE)
|
||||
@Retention(RUNTIME)
|
||||
public @interface Table {
|
||||
|
||||
@@ -15,11 +15,9 @@
|
||||
******************************************************************************/
|
||||
package javax.persistence;
|
||||
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.Retention;
|
||||
import static java.lang.annotation.ElementType.METHOD;
|
||||
import static java.lang.annotation.ElementType.FIELD;
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* Specifies that the property or field is not persistent. It is used
|
||||
@@ -38,7 +36,10 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
* </pre>
|
||||
*
|
||||
* @since Java Persistence 1.0
|
||||
*
|
||||
* @deprecated replace by org.redkale.persistence.Transient
|
||||
*/
|
||||
@Deprecated
|
||||
@Target({METHOD, FIELD})
|
||||
@Retention(RUNTIME)
|
||||
|
||||
|
||||
@@ -15,9 +15,8 @@
|
||||
***************************************************************************** */
|
||||
package javax.persistence;
|
||||
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.Retention;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* Specifies that a unique constraint is to be included in
|
||||
@@ -35,7 +34,10 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
* </pre>
|
||||
*
|
||||
* @since Java Persistence 1.0
|
||||
*
|
||||
* @deprecated replace by org.redkale.persistence.UniqueConstraint
|
||||
*/
|
||||
@Deprecated
|
||||
@Target({})
|
||||
@Retention(RUNTIME)
|
||||
public @interface UniqueConstraint {
|
||||
|
||||
@@ -13,9 +13,7 @@ module redkale {
|
||||
requires java.sql;
|
||||
requires jdk.unsupported; //sun.misc.Unsafe
|
||||
|
||||
exports javax.annotation;
|
||||
exports javax.persistence;
|
||||
|
||||
exports org.redkale.annotation;
|
||||
exports org.redkale.asm;
|
||||
exports org.redkale.boot;
|
||||
exports org.redkale.boot.watch;
|
||||
@@ -29,6 +27,7 @@ module redkale {
|
||||
exports org.redkale.net.client;
|
||||
exports org.redkale.net.http;
|
||||
exports org.redkale.net.sncp;
|
||||
exports org.redkale.persistence;
|
||||
exports org.redkale.service;
|
||||
exports org.redkale.source;
|
||||
exports org.redkale.util;
|
||||
|
||||
26
src/main/java/org/redkale/annotation/AutoLoad.java
Normal file
26
src/main/java/org/redkale/annotation/AutoLoad.java
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.redkale.annotation;
|
||||
|
||||
import static java.lang.annotation.ElementType.TYPE;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 自动加载。 使用场景:
|
||||
* 1、被标记为@AutoLoad(false)的Service类不会被自动加载, 当被依赖时才会被加载
|
||||
* 2、被标记为@AutoLoad(false)的Servlet类不会被自动加载
|
||||
*
|
||||
* <p> 详情见: https://redkale.org
|
||||
* @author zhangjx
|
||||
*/
|
||||
@Documented
|
||||
@Target({TYPE})
|
||||
@Retention(RUNTIME)
|
||||
public @interface AutoLoad {
|
||||
|
||||
boolean value() default true;
|
||||
}
|
||||
23
src/main/java/org/redkale/annotation/Bean.java
Normal file
23
src/main/java/org/redkale/annotation/Bean.java
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.redkale.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
import static java.lang.annotation.ElementType.TYPE;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
/**
|
||||
* 标记参数bean
|
||||
*
|
||||
* @since 2.5.0
|
||||
*/
|
||||
@Inherited
|
||||
@Documented
|
||||
@Target(TYPE)
|
||||
@Retention(RUNTIME)
|
||||
public @interface Bean {
|
||||
|
||||
}
|
||||
50
src/main/java/org/redkale/annotation/Command.java
Normal file
50
src/main/java/org/redkale/annotation/Command.java
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.redkale.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
/**
|
||||
* 接收命令的标记, 只能标记在本地模式下Service里参数为(String)或(String, String[])的public方法上
|
||||
*
|
||||
* <p>
|
||||
* 详情见: https://redkale.org
|
||||
*
|
||||
* @author zhangjx
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
@Inherited
|
||||
@Documented
|
||||
@Target({METHOD})
|
||||
@Retention(RUNTIME)
|
||||
public @interface Command {
|
||||
|
||||
/**
|
||||
* 命令号,没有指定值则接收所有的命令
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
String value() default "";
|
||||
|
||||
/**
|
||||
* 参数帮助说明,在value不为空命令redkale --help时显示
|
||||
*
|
||||
* @return String
|
||||
*
|
||||
* @since 2.7.0
|
||||
*/
|
||||
String description() default "";
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
String comment() default "";
|
||||
}
|
||||
29
src/main/java/org/redkale/annotation/Comment.java
Normal file
29
src/main/java/org/redkale/annotation/Comment.java
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.redkale.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
/**
|
||||
* 标记注释,备注
|
||||
*
|
||||
* <p>
|
||||
* 详情见: https://redkale.org
|
||||
*
|
||||
* @author zhangjx
|
||||
*/
|
||||
@Inherited
|
||||
@Documented
|
||||
@Target({TYPE, METHOD, FIELD, PARAMETER, CONSTRUCTOR, LOCAL_VARIABLE, ANNOTATION_TYPE, TYPE_PARAMETER})
|
||||
@Retention(RUNTIME)
|
||||
public @interface Comment {
|
||||
|
||||
String name() default "";
|
||||
|
||||
String value();
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.redkale.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
/**
|
||||
* 类似java.beans.ConstructorProperties, 必须配合Creator使用
|
||||
*
|
||||
* <p>
|
||||
* 详情见: https://redkale.org
|
||||
*
|
||||
* @author zhangjx
|
||||
*/
|
||||
@Documented
|
||||
@Target({METHOD, CONSTRUCTOR})
|
||||
@Retention(RUNTIME)
|
||||
public @interface ConstructorParameters {
|
||||
|
||||
String[] value();
|
||||
}
|
||||
46
src/main/java/org/redkale/annotation/LogExcludeLevel.java
Normal file
46
src/main/java/org/redkale/annotation/LogExcludeLevel.java
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.redkale.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
import static java.lang.annotation.ElementType.TYPE;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
/**
|
||||
* 等于level日志级别且包含keys字符串的日志才会被排除 <br>
|
||||
*
|
||||
* <blockquote><pre>
|
||||
* @LogExcludeLevel(levels = {"FINEST"}, keys = {"SET username ="})
|
||||
* public class UserRecord {
|
||||
* public int userid;
|
||||
* public String username = "";
|
||||
* }
|
||||
*
|
||||
* 这样当调用DataSource对UserRecord对象进行操作时,拼接的SQL语句含"SET username ="字样的都会在FINEST日志级别过滤掉
|
||||
* </pre></blockquote>
|
||||
* <p>
|
||||
* 详情见: https://redkale.org
|
||||
*
|
||||
* @author zhangjx
|
||||
*/
|
||||
@Documented
|
||||
@Target({TYPE})
|
||||
@Retention(RUNTIME)
|
||||
@Repeatable(LogExcludeLevel.LogExcludeLevels.class)
|
||||
public @interface LogExcludeLevel {
|
||||
|
||||
String[] levels();
|
||||
|
||||
String[] keys();
|
||||
|
||||
@Documented
|
||||
@Target({TYPE})
|
||||
@Retention(RUNTIME)
|
||||
@interface LogExcludeLevels {
|
||||
|
||||
LogExcludeLevel[] value();
|
||||
}
|
||||
}
|
||||
26
src/main/java/org/redkale/annotation/LogLevel.java
Normal file
26
src/main/java/org/redkale/annotation/LogLevel.java
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.redkale.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
import static java.lang.annotation.ElementType.TYPE;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
/**
|
||||
* 被标记的日志级别以上的才会被记录
|
||||
*
|
||||
* <p>
|
||||
* 详情见: https://redkale.org
|
||||
*
|
||||
* @author zhangjx
|
||||
*/
|
||||
@Documented
|
||||
@Target({TYPE})
|
||||
@Retention(RUNTIME)
|
||||
public @interface LogLevel {
|
||||
|
||||
String value();
|
||||
}
|
||||
39
src/main/java/org/redkale/annotation/Priority.java
Normal file
39
src/main/java/org/redkale/annotation/Priority.java
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.redkale.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* 值越大,优先级越高
|
||||
*
|
||||
* @since Common Annotations 1.2
|
||||
*/
|
||||
@Target({ElementType.TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Priority {
|
||||
|
||||
/**
|
||||
* 优先级值
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
int value();
|
||||
}
|
||||
42
src/main/java/org/redkale/annotation/Resource.java
Normal file
42
src/main/java/org/redkale/annotation/Resource.java
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.redkale.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @since Common Annotations 1.0
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Resource {
|
||||
|
||||
/**
|
||||
* 是否必须存在
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
public boolean required() default true;
|
||||
|
||||
/**
|
||||
* 资源名称
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String name() default "";
|
||||
|
||||
/**
|
||||
* 依赖注入的类型
|
||||
*
|
||||
* @return Class
|
||||
*/
|
||||
public Class<?> type() default Object.class;
|
||||
|
||||
}
|
||||
64
src/main/java/org/redkale/annotation/ResourceListener.java
Normal file
64
src/main/java/org/redkale/annotation/ResourceListener.java
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.redkale.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
import static java.lang.annotation.ElementType.METHOD;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
/**
|
||||
* @Resource资源被更新时的监听事件, 本注解只能标记在方法参数为ResourceEvent[]上 <br>
|
||||
* 注意: 一个类只能存在一个@ResourceListener的方法, 多余的会被忽略 <br>
|
||||
* 方法在资源被更新以后调用。
|
||||
*
|
||||
* <blockquote><pre>
|
||||
* public class RecordService implements Service {
|
||||
*
|
||||
* @Resource(name = "record.id")
|
||||
* private int id;
|
||||
*
|
||||
* @Resource(name = "record.name")
|
||||
* private String name;
|
||||
*
|
||||
* @ResourceListener
|
||||
* private void changeResource(ResourceEvent[] events) {
|
||||
* for(ResourceEvent event : events) {
|
||||
* System.out.println("@Resource = " + event.name() + " 资源变更: newVal = " + event.newValue() + ", oldVal = " + event.oldValue());
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* public static void main(String[] args) throws Exception {
|
||||
* ResourceFactory factory = ResourceFactory.root();
|
||||
* factory.register("record.id", "2345");
|
||||
* factory.register("record.name", "my old name");
|
||||
* Record record = new Record();
|
||||
* factory.inject(record);
|
||||
* factory.register("record.name", "my new name");
|
||||
* }
|
||||
*
|
||||
* }
|
||||
* </pre></blockquote>
|
||||
*
|
||||
* <p>
|
||||
* 详情见: https://redkale.org
|
||||
*
|
||||
* @author zhangjx
|
||||
*/
|
||||
@Documented
|
||||
@Target({METHOD})
|
||||
@Retention(RUNTIME)
|
||||
public @interface ResourceListener {
|
||||
|
||||
/**
|
||||
* 新旧值是否不同时才回调方法 <br>
|
||||
* true: 新值与旧值不同时才回调ResourceListener方法
|
||||
* false: 只要执行了ResourceFactory.register 就回调ResourceListener方法
|
||||
*
|
||||
* @since 2.7.0
|
||||
* @return boolean
|
||||
*/
|
||||
boolean different() default true;
|
||||
}
|
||||
29
src/main/java/org/redkale/annotation/ResourceType.java
Normal file
29
src/main/java/org/redkale/annotation/ResourceType.java
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.redkale.annotation;
|
||||
|
||||
import static java.lang.annotation.ElementType.TYPE;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 显式的指明资源类型。
|
||||
* 调用ResourceFactory.register(Object rs)时通常执行的是ResourceFactory.register(rs.getClass(), Object rs);
|
||||
* 若rs.getClass()的类标记了@ResourceType, 则使用@ResourceType.value()的class值进行注入。
|
||||
*
|
||||
* <p>
|
||||
* 详情见: https://redkale.org
|
||||
*
|
||||
* @author zhangjx
|
||||
*/
|
||||
@Inherited
|
||||
@Documented
|
||||
@Target({TYPE})
|
||||
@Retention(RUNTIME)
|
||||
public @interface ResourceType {
|
||||
|
||||
Class value();
|
||||
}
|
||||
@@ -13,11 +13,12 @@ import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.atomic.*;
|
||||
import java.util.logging.*;
|
||||
import javax.persistence.*;
|
||||
import org.redkale.annotation.Comment;
|
||||
import org.redkale.convert.*;
|
||||
import org.redkale.convert.json.*;
|
||||
import org.redkale.mq.MessageMultiConsumer;
|
||||
import org.redkale.net.http.*;
|
||||
import org.redkale.persistence.*;
|
||||
import org.redkale.service.RetResult;
|
||||
import org.redkale.source.*;
|
||||
import org.redkale.util.*;
|
||||
@@ -261,14 +262,17 @@ public final class ApiDocCommand {
|
||||
Column col = field.getAnnotation(Column.class);
|
||||
FilterColumn fc = field.getAnnotation(FilterColumn.class);
|
||||
Comment comment = field.getAnnotation(Comment.class);
|
||||
org.redkale.util.Comment comment2 = field.getAnnotation(org.redkale.util.Comment.class);
|
||||
if (comment != null) {
|
||||
fieldmap.put("comment", comment.value());
|
||||
} else if (comment2 != null) {
|
||||
fieldmap.put("comment", comment2.value());
|
||||
} else if (col != null) {
|
||||
fieldmap.put("comment", col.comment());
|
||||
} else if (fc != null) {
|
||||
fieldmap.put("comment", fc.comment());
|
||||
}
|
||||
fieldmap.put("primary", !filter && (field.getAnnotation(Id.class) != null));
|
||||
fieldmap.put("primary", !filter && (field.getAnnotation(Id.class) != null || field.getAnnotation(javax.persistence.Id.class) != null));
|
||||
fieldmap.put("updatable", (filter || col == null || col.updatable()));
|
||||
|
||||
if (servlet.getClass().getAnnotation(Rest.RestDyn.class) != null) {
|
||||
@@ -444,6 +448,8 @@ public final class ApiDocCommand {
|
||||
}
|
||||
if (desc.isEmpty() && member.getField().getAnnotation(Comment.class) != null) {
|
||||
desc = member.getField().getAnnotation(Comment.class).value();
|
||||
} else if (desc.isEmpty() && member.getField().getAnnotation(org.redkale.util.Comment.class) != null) {
|
||||
desc = member.getField().getAnnotation(org.redkale.util.Comment.class).value();
|
||||
}
|
||||
} else if (member.getMethod() != null) {
|
||||
Column col = member.getMethod().getAnnotation(Column.class);
|
||||
@@ -459,6 +465,8 @@ public final class ApiDocCommand {
|
||||
}
|
||||
if (desc.isEmpty() && member.getMethod().getAnnotation(Comment.class) != null) {
|
||||
desc = member.getMethod().getAnnotation(Comment.class).value();
|
||||
} else if (desc.isEmpty() && member.getMethod().getAnnotation(org.redkale.util.Comment.class) != null) {
|
||||
desc = member.getMethod().getAnnotation(org.redkale.util.Comment.class).value();
|
||||
}
|
||||
}
|
||||
if (!desc.isEmpty()) schemaMap.put("description", desc);
|
||||
|
||||
@@ -5,15 +5,12 @@
|
||||
*/
|
||||
package org.redkale.boot;
|
||||
|
||||
import org.redkale.cluster.ClusterAgent;
|
||||
import org.redkale.util.RedkaleClassLoader;
|
||||
import org.redkale.net.TransportGroupInfo;
|
||||
import java.io.*;
|
||||
import java.lang.reflect.*;
|
||||
import java.net.*;
|
||||
import java.net.http.HttpClient;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.*;
|
||||
import java.nio.channels.DatagramChannel;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
@@ -21,8 +18,8 @@ import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.logging.*;
|
||||
import javax.annotation.*;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import org.redkale.annotation.Resource;
|
||||
import org.redkale.boot.ClassFilter.FilterEntry;
|
||||
import org.redkale.cluster.*;
|
||||
import org.redkale.convert.Convert;
|
||||
@@ -36,7 +33,7 @@ import org.redkale.service.Service;
|
||||
import org.redkale.source.*;
|
||||
import org.redkale.util.AnyValue.DefaultAnyValue;
|
||||
import org.redkale.util.*;
|
||||
import org.redkale.watch.*;
|
||||
import org.redkale.watch.WatchServlet;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -998,16 +995,23 @@ public final class Application {
|
||||
@Override
|
||||
public Object load(ResourceFactory rf, String srcResourceName, final Object srcObj, String resourceName, Field field, final Object attachment) {
|
||||
try {
|
||||
String resName = null;
|
||||
Resource res = field.getAnnotation(Resource.class);
|
||||
if (res == null) return null;
|
||||
if (res != null) {
|
||||
resName = res.name();
|
||||
} else {
|
||||
javax.annotation.Resource res2 = field.getAnnotation(javax.annotation.Resource.class);
|
||||
if (res2 != null) resName = res2.name();
|
||||
}
|
||||
if (resName == null) return null;
|
||||
if (srcObj instanceof Service && Sncp.isRemote((Service) srcObj)) return null; //远程模式不得注入
|
||||
Class type = field.getType();
|
||||
if (type == Application.class) {
|
||||
field.set(srcObj, application);
|
||||
return application;
|
||||
} else if (type == ResourceFactory.class) {
|
||||
boolean serv = RESNAME_SERVER_RESFACTORY.equals(res.name()) || res.name().equalsIgnoreCase("server");
|
||||
ResourceFactory rs = serv ? rf : (res.name().isEmpty() ? application.resourceFactory : null);
|
||||
boolean serv = RESNAME_SERVER_RESFACTORY.equals(resName) || resName.equalsIgnoreCase("server");
|
||||
ResourceFactory rs = serv ? rf : (resName.isEmpty() ? application.resourceFactory : null);
|
||||
field.set(srcObj, rs);
|
||||
return rs;
|
||||
} else if (type == TransportFactory.class) {
|
||||
@@ -1017,7 +1021,7 @@ public final class Application {
|
||||
NodeServer server = null;
|
||||
for (NodeServer ns : application.getNodeServers()) {
|
||||
if (ns.getClass() != NodeSncpServer.class) continue;
|
||||
if (res.name().equals(ns.server.getName())) {
|
||||
if (resName.equals(ns.server.getName())) {
|
||||
server = ns;
|
||||
break;
|
||||
}
|
||||
@@ -1028,7 +1032,7 @@ public final class Application {
|
||||
NodeServer server = null;
|
||||
for (NodeServer ns : application.getNodeServers()) {
|
||||
if (ns.getClass() != NodeHttpServer.class) continue;
|
||||
if (res.name().equals(ns.server.getName())) {
|
||||
if (resName.equals(ns.server.getName())) {
|
||||
server = ns;
|
||||
break;
|
||||
}
|
||||
@@ -1039,7 +1043,7 @@ public final class Application {
|
||||
NodeServer server = null;
|
||||
for (NodeServer ns : application.getNodeServers()) {
|
||||
if (ns.getClass() != NodeWatchServer.class) continue;
|
||||
if (res.name().equals(ns.server.getName())) {
|
||||
if (resName.equals(ns.server.getName())) {
|
||||
server = ns;
|
||||
break;
|
||||
}
|
||||
@@ -1067,7 +1071,7 @@ public final class Application {
|
||||
//------------------------------------ 注册 java.net.http.HttpClient ------------------------------------
|
||||
resourceFactory.register((ResourceFactory rf, String srcResourceName, final Object srcObj, String resourceName, Field field, final Object attachment) -> {
|
||||
try {
|
||||
if (field.getAnnotation(Resource.class) == null) return null;
|
||||
if (field.getAnnotation(Resource.class) == null && field.getAnnotation(javax.annotation.Resource.class) == null) return null;
|
||||
java.net.http.HttpClient.Builder builder = java.net.http.HttpClient.newBuilder();
|
||||
if (resourceName.endsWith(".1.1")) {
|
||||
builder.version(HttpClient.Version.HTTP_1_1);
|
||||
@@ -1087,7 +1091,7 @@ public final class Application {
|
||||
//------------------------------------ 注册 HttpSimpleClient ------------------------------------
|
||||
resourceFactory.register((ResourceFactory rf, String srcResourceName, final Object srcObj, String resourceName, Field field, final Object attachment) -> {
|
||||
try {
|
||||
if (field.getAnnotation(Resource.class) == null) return null;
|
||||
if (field.getAnnotation(Resource.class) == null && field.getAnnotation(javax.annotation.Resource.class) == null) return null;
|
||||
HttpSimpleClient httpClient = HttpSimpleClient.create(clientAsyncGroup);
|
||||
field.set(srcObj, httpClient);
|
||||
rf.inject(resourceName, httpClient, null); // 给其可能包含@Resource的字段赋值;
|
||||
@@ -1130,7 +1134,7 @@ public final class Application {
|
||||
//------------------------------------ 注册 HttpMessageClient ------------------------------------
|
||||
resourceFactory.register((ResourceFactory rf, String srcResourceName, final Object srcObj, String resourceName, Field field, final Object attachment) -> {
|
||||
try {
|
||||
if (field.getAnnotation(Resource.class) == null) return null;
|
||||
if (field.getAnnotation(Resource.class) == null && field.getAnnotation(javax.annotation.Resource.class) == null) return null;
|
||||
if (clusterAgent == null) {
|
||||
HttpMessageClient messageClient = new HttpMessageLocalClient(application, resourceName);
|
||||
field.set(srcObj, messageClient);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
package org.redkale.boot;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.annotation.*;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.net.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
@@ -15,10 +15,11 @@ import java.util.concurrent.*;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.jar.*;
|
||||
import java.util.logging.*;
|
||||
import java.util.regex.*;
|
||||
import javax.annotation.Priority;
|
||||
import org.redkale.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
import org.redkale.annotation.AutoLoad;
|
||||
import org.redkale.annotation.*;
|
||||
import org.redkale.util.AnyValue.DefaultAnyValue;
|
||||
import org.redkale.util.*;
|
||||
|
||||
/**
|
||||
* class过滤器, 符合条件的class会保留下来存入FilterEntry。
|
||||
@@ -164,10 +165,10 @@ public final class ClassFilter<T> {
|
||||
*
|
||||
* @param property application.xml中对应class节点下的property属性项
|
||||
* @param clazzname class名称
|
||||
* @param autoscan 为true表示自动扫描的, false表示显著调用filter, AutoLoad的注解将被忽略
|
||||
* @param autoScan 为true表示自动扫描的, false表示显著调用filter, AutoLoad的注解将被忽略
|
||||
* @param url URL
|
||||
*/
|
||||
public final void filter(AnyValue property, String clazzname, boolean autoscan, URL url) {
|
||||
public final void filter(AnyValue property, String clazzname, boolean autoScan, URL url) {
|
||||
boolean r = accept0(property, clazzname);
|
||||
ClassFilter cf = r ? this : null;
|
||||
if (r && ands != null) {
|
||||
@@ -187,7 +188,7 @@ public final class ClassFilter<T> {
|
||||
if (cf == null || clazzname.startsWith("sun.") || clazzname.contains("module-info")) return;
|
||||
try {
|
||||
Class clazz = classLoader.loadClass(clazzname);
|
||||
if (!cf.accept(property, clazz, autoscan)) return;
|
||||
if (!cf.accept(property, clazz, autoScan)) return;
|
||||
if (cf.conf != null) {
|
||||
if (property == null) {
|
||||
property = cf.conf;
|
||||
@@ -202,10 +203,12 @@ public final class ClassFilter<T> {
|
||||
}
|
||||
|
||||
AutoLoad auto = (AutoLoad) clazz.getAnnotation(AutoLoad.class);
|
||||
if ((expectPredicate != null && expectPredicate.test(clazzname)) || (autoscan && auto != null && !auto.value())) { //自动扫描且被标记为@AutoLoad(false)的
|
||||
expectEntrys.add(new FilterEntry(clazz, autoscan, true, property));
|
||||
org.redkale.util.AutoLoad auto2 = (org.redkale.util.AutoLoad) clazz.getAnnotation(org.redkale.util.AutoLoad.class);
|
||||
if ((expectPredicate != null && expectPredicate.test(clazzname)) || (autoScan && auto != null && !auto.value())
|
||||
|| (autoScan && auto2 != null && !auto2.value())) { //自动扫描且被标记为@AutoLoad(false)的
|
||||
expectEntrys.add(new FilterEntry(clazz, autoScan, true, property));
|
||||
} else {
|
||||
entrys.add(new FilterEntry(clazz, autoscan, false, property));
|
||||
entrys.add(new FilterEntry(clazz, autoScan, false, property));
|
||||
}
|
||||
} catch (Throwable cfe) {
|
||||
if (logger.isLoggable(Level.FINEST) && !clazzname.startsWith("sun.") && !clazzname.startsWith("javax.")
|
||||
@@ -534,7 +537,7 @@ public final class ClassFilter<T> {
|
||||
Set<String> classes = cache.get(url);
|
||||
if (classes == null) {
|
||||
classes = new LinkedHashSet<>();
|
||||
try ( JarFile jar = new JarFile(URLDecoder.decode(url.getFile(), StandardCharsets.UTF_8))) {
|
||||
try (JarFile jar = new JarFile(URLDecoder.decode(url.getFile(), StandardCharsets.UTF_8))) {
|
||||
Enumeration<JarEntry> it = jar.entries();
|
||||
while (it.hasMoreElements()) {
|
||||
String entryname = it.nextElement().getName().replace('/', '.');
|
||||
|
||||
@@ -9,13 +9,16 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.logging.*;
|
||||
import java.util.logging.Formatter;
|
||||
import java.util.regex.Pattern;
|
||||
import javax.persistence.*;
|
||||
|
||||
import static org.redkale.boot.Application.RESNAME_APP_NAME;
|
||||
import org.redkale.convert.*;
|
||||
import org.redkale.convert.json.JsonConvert;
|
||||
import org.redkale.persistence.SearchColumn;
|
||||
import org.redkale.persistence.*;
|
||||
import org.redkale.source.*;
|
||||
import org.redkale.util.*;
|
||||
|
||||
|
||||
/**
|
||||
* 基于SearchSource的日志输出类
|
||||
* <p>
|
||||
|
||||
@@ -12,7 +12,7 @@ import java.util.*;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Stream;
|
||||
import javax.annotation.*;
|
||||
import org.redkale.annotation.*;
|
||||
import static org.redkale.boot.Application.RESNAME_SNCP_ADDR;
|
||||
import org.redkale.boot.ClassFilter.FilterEntry;
|
||||
import org.redkale.cluster.ClusterAgent;
|
||||
@@ -20,7 +20,7 @@ import org.redkale.mq.MessageAgent;
|
||||
import org.redkale.net.*;
|
||||
import org.redkale.net.http.*;
|
||||
import org.redkale.net.sncp.Sncp;
|
||||
import org.redkale.service.*;
|
||||
import org.redkale.service.Service;
|
||||
import org.redkale.util.AnyValue.DefaultAnyValue;
|
||||
import org.redkale.util.*;
|
||||
import org.redkale.watch.*;
|
||||
@@ -104,7 +104,7 @@ public class NodeHttpServer extends NodeServer {
|
||||
final ResourceFactory regFactory = application.getResourceFactory();
|
||||
resourceFactory.register((ResourceFactory rf, String srcResourceName, final Object srcObj, final String resourceName, Field field, Object attachment) -> { //主要用于单点的服务
|
||||
try {
|
||||
if (field.getAnnotation(Resource.class) == null) return null;
|
||||
if (field.getAnnotation(Resource.class) == null && field.getAnnotation(javax.annotation.Resource.class) == null) return null;
|
||||
if (!(srcObj instanceof WebSocketServlet)) return null;
|
||||
ResourceTypeLoader loader = null;
|
||||
ResourceFactory sncpResFactory = null;
|
||||
@@ -114,9 +114,14 @@ public class NodeHttpServer extends NodeServer {
|
||||
loader = sncpResFactory.findTypeLoader(WebSocketNode.class, field);
|
||||
if (loader != null) break;
|
||||
}
|
||||
if (loader != null) loader.load(sncpResFactory, srcResourceName, srcObj, resourceName, field, attachment);
|
||||
Service nodeService = null;
|
||||
if (loader != null) {
|
||||
nodeService = (Service) loader.load(sncpResFactory, srcResourceName, srcObj, resourceName, field, attachment);
|
||||
}
|
||||
synchronized (regFactory) {
|
||||
Service nodeService = (Service) rf.find(resourceName, WebSocketNode.class);
|
||||
if (nodeService == null) {
|
||||
nodeService = (Service) rf.find(resourceName, WebSocketNode.class);
|
||||
}
|
||||
if (sncpResFactory != null && resourceFactory.find(RESNAME_SNCP_ADDR, String.class) == null) {
|
||||
resourceFactory.register(RESNAME_SNCP_ADDR, InetSocketAddress.class, sncpResFactory.find(RESNAME_SNCP_ADDR, InetSocketAddress.class));
|
||||
resourceFactory.register(RESNAME_SNCP_ADDR, SocketAddress.class, sncpResFactory.find(RESNAME_SNCP_ADDR, SocketAddress.class));
|
||||
@@ -126,6 +131,7 @@ public class NodeHttpServer extends NodeServer {
|
||||
MessageAgent messageAgent = null;
|
||||
try {
|
||||
Field c = WebSocketServlet.class.getDeclaredField("messageAgent");
|
||||
RedkaleClassLoader.putReflectionField("messageAgent", c);
|
||||
c.setAccessible(true);
|
||||
messageAgent = (MessageAgent) c.get(srcObj);
|
||||
} catch (Exception ex) {
|
||||
|
||||
@@ -5,22 +5,23 @@
|
||||
*/
|
||||
package org.redkale.boot;
|
||||
|
||||
import org.redkale.cluster.ClusterAgent;
|
||||
import org.redkale.mq.MessageAgent;
|
||||
import org.redkale.util.RedkaleClassLoader;
|
||||
import java.io.*;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.*;
|
||||
import java.net.*;
|
||||
import java.nio.file.*;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.*;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.logging.*;
|
||||
import javax.annotation.*;
|
||||
import org.redkale.annotation.AutoLoad;
|
||||
import org.redkale.annotation.Command;
|
||||
import org.redkale.annotation.*;
|
||||
import static org.redkale.boot.Application.*;
|
||||
import org.redkale.boot.ClassFilter.FilterEntry;
|
||||
import org.redkale.cluster.ClusterAgent;
|
||||
import org.redkale.mq.MessageAgent;
|
||||
import org.redkale.net.Filter;
|
||||
import org.redkale.net.*;
|
||||
import org.redkale.net.http.*;
|
||||
@@ -215,18 +216,25 @@ public abstract class NodeServer {
|
||||
//------------------------------------- 注册 Resource --------------------------------------------------------
|
||||
resourceFactory.register((ResourceFactory rf, String srcResourceName, final Object srcObj, String resourceName, Field field, final Object attachment) -> {
|
||||
try {
|
||||
String resName = null;
|
||||
Resource res = field.getAnnotation(Resource.class);
|
||||
if (res == null || !res.name().startsWith("properties.")) return null;
|
||||
if (res != null) {
|
||||
resName = res.name();
|
||||
} else {
|
||||
javax.annotation.Resource res2 = field.getAnnotation(javax.annotation.Resource.class);
|
||||
if (res2 != null) resName = res2.name();
|
||||
}
|
||||
if (resName == null || !resName.startsWith("properties.")) return null;
|
||||
if ((srcObj instanceof Service) && Sncp.isRemote((Service) srcObj)) return null; //远程模式不得注入 DataSource
|
||||
Class type = field.getType();
|
||||
if (type != AnyValue.class && type != AnyValue[].class) return null;
|
||||
Object resource = null;
|
||||
final AnyValue properties = application.getAppConfig().getAnyValue("properties");
|
||||
if (properties != null && type == AnyValue.class) {
|
||||
resource = properties.getAnyValue(res.name().substring("properties.".length()));
|
||||
resource = properties.getAnyValue(resName.substring("properties.".length()));
|
||||
appResFactory.register(resourceName, AnyValue.class, resource);
|
||||
} else if (properties != null && type == AnyValue[].class) {
|
||||
resource = properties.getAnyValues(res.name().substring("properties.".length()));
|
||||
resource = properties.getAnyValues(resName.substring("properties.".length()));
|
||||
appResFactory.register(resourceName, AnyValue[].class, resource);
|
||||
}
|
||||
field.set(srcObj, resource);
|
||||
@@ -241,13 +249,17 @@ public abstract class NodeServer {
|
||||
resourceFactory.register((ResourceFactory rf, String srcResourceName, final Object srcObj, String resourceName, Field field, final Object attachment) -> {
|
||||
Class<Service> resServiceType = Service.class;
|
||||
try {
|
||||
if (field.getAnnotation(Resource.class) == null) return null;
|
||||
if (field.getAnnotation(Resource.class) == null && field.getAnnotation(javax.annotation.Resource.class) == null) return null;
|
||||
if ((srcObj instanceof Service) && Sncp.isRemote((Service) srcObj)) return null; //远程模式不得注入 AutoLoad Service
|
||||
if (!Service.class.isAssignableFrom(field.getType())) return null;
|
||||
resServiceType = (Class) field.getType();
|
||||
if (resServiceType.getAnnotation(Local.class) == null) return null;
|
||||
boolean auto = true;
|
||||
AutoLoad al = resServiceType.getAnnotation(AutoLoad.class);
|
||||
if (al == null || al.value()) return null;
|
||||
if (al != null) auto = al.value();
|
||||
org.redkale.util.AutoLoad al2 = resServiceType.getAnnotation(org.redkale.util.AutoLoad.class);
|
||||
if (al2 != null) auto = al2.value();
|
||||
if (auto) return null;
|
||||
|
||||
//ResourceFactory resfactory = (isSNCP() ? appResFactory : resourceFactory);
|
||||
SncpClient client = srcObj instanceof Service ? Sncp.getSncpClient((Service) srcObj) : null;
|
||||
@@ -270,7 +282,7 @@ public abstract class NodeServer {
|
||||
//------------------------------------- 注册 DataSource --------------------------------------------------------
|
||||
resourceFactory.register((ResourceFactory rf, String srcResourceName, final Object srcObj, String resourceName, Field field, final Object attachment) -> {
|
||||
try {
|
||||
if (field.getAnnotation(Resource.class) == null) return null;
|
||||
if (field.getAnnotation(Resource.class) == null && field.getAnnotation(javax.annotation.Resource.class) == null) return null;
|
||||
if ((srcObj instanceof Service) && Sncp.isRemote((Service) srcObj)) return null; //远程模式不得注入 DataSource
|
||||
DataSource source = application.loadDataSource(resourceName, false);
|
||||
field.set(srcObj, source);
|
||||
@@ -286,7 +298,7 @@ public abstract class NodeServer {
|
||||
@Override
|
||||
public Object load(ResourceFactory rf, String srcResourceName, final Object srcObj, final String resourceName, Field field, final Object attachment) {
|
||||
try {
|
||||
if (field.getAnnotation(Resource.class) == null) return null;
|
||||
if (field.getAnnotation(Resource.class) == null && field.getAnnotation(javax.annotation.Resource.class) == null) return null;
|
||||
if (!(srcObj instanceof Service)) throw new RuntimeException("CacheSource must be inject in Service, cannot " + srcObj);
|
||||
if ((srcObj instanceof Service) && Sncp.isRemote((Service) srcObj)) return null; //远程模式不需要注入 CacheSource
|
||||
final Service srcService = (Service) srcObj;
|
||||
@@ -322,19 +334,33 @@ public abstract class NodeServer {
|
||||
@Override
|
||||
public Object load(ResourceFactory rf, String srcResourceName, final Object srcObj, final String resourceName, Field field, final Object attachment) {
|
||||
try {
|
||||
if (field.getAnnotation(Resource.class) == null) return null;
|
||||
if (field.getAnnotation(Resource.class) == null && field.getAnnotation(javax.annotation.Resource.class) == null) return null;
|
||||
if ((srcObj instanceof Service) && Sncp.isRemote((Service) srcObj)) return null; //远程模式不需要注入 WebSocketNode
|
||||
Service nodeService = (Service) rf.find(resourceName, WebSocketNode.class);
|
||||
MessageAgent messageAgent = null;
|
||||
if (srcObj instanceof Service) {
|
||||
messageAgent = Sncp.getMessageAgent((Service) srcObj);
|
||||
} else if (srcObj instanceof WebSocketServlet) {
|
||||
try {
|
||||
Field c = WebSocketServlet.class.getDeclaredField("messageAgent");
|
||||
RedkaleClassLoader.putReflectionField("messageAgent", c);
|
||||
c.setAccessible(true);
|
||||
messageAgent = (MessageAgent) c.get(srcObj);
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, "WebSocketServlet getMessageAgent error", ex);
|
||||
}
|
||||
}
|
||||
if (nodeService == null) {
|
||||
final HashSet<String> groups = new HashSet<>();
|
||||
if (groups.isEmpty() && isSNCP() && NodeServer.this.sncpGroup != null) groups.add(NodeServer.this.sncpGroup);
|
||||
nodeService = Sncp.createLocalService(serverClassLoader, resourceName, org.redkale.net.http.WebSocketNodeService.class, Sncp.getMessageAgent((Service) srcObj), application.getResourceFactory(), application.getSncpTransportFactory(), NodeServer.this.sncpAddress, groups, (AnyValue) null);
|
||||
nodeService = Sncp.createLocalService(serverClassLoader, resourceName, org.redkale.net.http.WebSocketNodeService.class, messageAgent, application.getResourceFactory(), application.getSncpTransportFactory(), NodeServer.this.sncpAddress, groups, (AnyValue) null);
|
||||
(isSNCP() ? appResFactory : resourceFactory).register(resourceName, WebSocketNode.class, nodeService);
|
||||
((org.redkale.net.http.WebSocketNodeService) nodeService).setName(resourceName);
|
||||
}
|
||||
resourceFactory.inject(resourceName, nodeService, self);
|
||||
MessageAgent messageAgent = Sncp.getMessageAgent((Service) srcObj);
|
||||
if (messageAgent != null && Sncp.getMessageAgent(nodeService) == null) Sncp.setMessageAgent(nodeService, messageAgent);
|
||||
if (messageAgent != null && Sncp.getMessageAgent(nodeService) == null) {
|
||||
Sncp.setMessageAgent(nodeService, messageAgent);
|
||||
}
|
||||
field.set(srcObj, nodeService);
|
||||
if (Sncp.isRemote(nodeService)) {
|
||||
remoteServices.add(nodeService);
|
||||
@@ -394,7 +420,8 @@ public abstract class NodeServer {
|
||||
if (localed && (serviceImplClass.isInterface() || Modifier.isAbstract(serviceImplClass.getModifiers()))) continue; //本地模式不能实例化接口和抽象类的Service类
|
||||
final ResourceTypeLoader resourceLoader = (ResourceFactory rf, String srcResourceName, final Object srcObj, final String resourceName, Field field, final Object attachment) -> {
|
||||
try {
|
||||
if (SncpClient.parseMethod(serviceImplClass).isEmpty() && serviceImplClass.getAnnotation(Priority.class) == null) { //class没有可用的方法且没有标记启动优先级的, 通常为BaseService
|
||||
if (SncpClient.parseMethod(serviceImplClass).isEmpty()
|
||||
&& (serviceImplClass.getAnnotation(Priority.class) == null && serviceImplClass.getAnnotation(javax.annotation.Priority.class) == null)) { //class没有可用的方法且没有标记启动优先级的, 通常为BaseService
|
||||
if (!serviceImplClass.getName().startsWith("org.redkale.") && !serviceImplClass.getSimpleName().contains("Base")) {
|
||||
logger.log(Level.FINE, serviceImplClass + " cannot load because not found less one public non-final method");
|
||||
}
|
||||
@@ -729,7 +756,8 @@ public abstract class NodeServer {
|
||||
//do { public方法不用递归
|
||||
for (Method m : loop.getMethods()) {
|
||||
Command c = m.getAnnotation(Command.class);
|
||||
if (c == null) continue;
|
||||
org.redkale.util.Command c2 = m.getAnnotation(org.redkale.util.Command.class);
|
||||
if (c == null && c2 == null) continue;
|
||||
if (Modifier.isStatic(m.getModifiers())) {
|
||||
logger.log(Level.WARNING, m + " is static on @Command");
|
||||
continue;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
package org.redkale.boot;
|
||||
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.net.*;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import org.redkale.boot.ClassFilter.FilterEntry;
|
||||
@@ -14,8 +14,8 @@ import org.redkale.mq.MessageAgent;
|
||||
import org.redkale.net.*;
|
||||
import org.redkale.net.sncp.*;
|
||||
import org.redkale.service.*;
|
||||
import org.redkale.util.*;
|
||||
import org.redkale.util.AnyValue.DefaultAnyValue;
|
||||
import org.redkale.util.*;
|
||||
|
||||
/**
|
||||
* SNCP Server节点的配置Server
|
||||
|
||||
@@ -6,13 +6,14 @@
|
||||
package org.redkale.boot;
|
||||
|
||||
import java.lang.reflect.Modifier;
|
||||
import javax.persistence.Entity;
|
||||
|
||||
import org.redkale.annotation.Bean;
|
||||
import org.redkale.persistence.Entity;
|
||||
import org.redkale.boot.ClassFilter.FilterEntry;
|
||||
import org.redkale.convert.Decodeable;
|
||||
import org.redkale.convert.bson.BsonFactory;
|
||||
import org.redkale.convert.json.*;
|
||||
import org.redkale.source.*;
|
||||
import org.redkale.util.*;
|
||||
|
||||
/**
|
||||
* 执行一次Application.run提前获取所有动态类
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
package org.redkale.boot.watch;
|
||||
|
||||
import org.redkale.service.AbstractService;
|
||||
import org.redkale.util.Comment;
|
||||
import org.redkale.annotation.Comment;
|
||||
import org.redkale.watch.WatchService;
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,11 +7,11 @@ package org.redkale.boot.watch;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import javax.annotation.Resource;
|
||||
import org.redkale.annotation.Resource;
|
||||
import org.redkale.boot.*;
|
||||
import org.redkale.net.http.*;
|
||||
import org.redkale.service.RetResult;
|
||||
import org.redkale.util.Comment;
|
||||
import org.redkale.annotation.Comment;
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -9,12 +9,12 @@ import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.*;
|
||||
import java.util.stream.Stream;
|
||||
import javax.annotation.Resource;
|
||||
import org.redkale.annotation.Resource;
|
||||
import org.redkale.boot.*;
|
||||
import org.redkale.net.Server;
|
||||
import org.redkale.net.http.*;
|
||||
import org.redkale.service.RetResult;
|
||||
import org.redkale.util.Comment;
|
||||
import org.redkale.annotation.Comment;
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -7,7 +7,9 @@ package org.redkale.boot.watch;
|
||||
|
||||
import java.lang.reflect.*;
|
||||
import java.util.*;
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.redkale.annotation.Comment;
|
||||
import org.redkale.annotation.Resource;
|
||||
import org.redkale.boot.*;
|
||||
import org.redkale.convert.json.JsonConvert;
|
||||
import org.redkale.net.http.*;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
package org.redkale.boot.watch;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import org.redkale.annotation.Resource;
|
||||
import org.redkale.boot.Application;
|
||||
import org.redkale.net.TransportFactory;
|
||||
import org.redkale.net.http.*;
|
||||
|
||||
@@ -10,7 +10,9 @@ import java.net.*;
|
||||
import java.nio.channels.AsynchronousSocketChannel;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.redkale.annotation.Comment;
|
||||
import org.redkale.annotation.Resource;
|
||||
import org.redkale.boot.Application;
|
||||
import org.redkale.net.*;
|
||||
import org.redkale.net.http.*;
|
||||
|
||||
@@ -9,7 +9,8 @@ import java.net.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.logging.Level;
|
||||
import javax.annotation.Resource;
|
||||
import org.redkale.annotation.Resource;
|
||||
import org.redkale.annotation.ResourceListener;
|
||||
import org.redkale.boot.*;
|
||||
import org.redkale.convert.json.JsonConvert;
|
||||
import org.redkale.service.Service;
|
||||
|
||||
@@ -11,9 +11,11 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.logging.Logger;
|
||||
import javax.annotation.Resource;
|
||||
import org.redkale.boot.*;
|
||||
import org.redkale.annotation.AutoLoad;
|
||||
import org.redkale.annotation.*;
|
||||
import org.redkale.annotation.ResourceListener;
|
||||
import static org.redkale.boot.Application.*;
|
||||
import org.redkale.boot.*;
|
||||
import org.redkale.convert.ConvertDisabled;
|
||||
import org.redkale.convert.json.JsonConvert;
|
||||
import org.redkale.mq.MessageMultiConsumer;
|
||||
@@ -153,6 +155,8 @@ public abstract class ClusterAgent {
|
||||
if ("SNCP".equalsIgnoreCase(protocol) && service.getClass().getAnnotation(Local.class) != null) return false;
|
||||
AutoLoad al = service.getClass().getAnnotation(AutoLoad.class);
|
||||
if (al != null && !al.value() && service.getClass().getAnnotation(Local.class) != null) return false;
|
||||
org.redkale.util.AutoLoad al2 = service.getClass().getAnnotation(org.redkale.util.AutoLoad.class);
|
||||
if (al2 != null && !al2.value() && service.getClass().getAnnotation(Local.class) != null) return false;
|
||||
if (service instanceof WebSocketNode) {
|
||||
if (((WebSocketNode) service).getLocalWebSocketEngine() == null) return false;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@ import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.*;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.*;
|
||||
|
||||
import org.redkale.annotation.ConstructorParameters;
|
||||
import org.redkale.convert.bson.BsonConvert;
|
||||
import org.redkale.convert.ext.*;
|
||||
import org.redkale.convert.json.JsonConvert;
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
package org.redkale.convert;
|
||||
|
||||
import java.lang.reflect.*;
|
||||
import javax.persistence.Column;
|
||||
|
||||
import org.redkale.annotation.Comment;
|
||||
import org.redkale.persistence.Column;
|
||||
import org.redkale.source.FilterColumn;
|
||||
import org.redkale.util.*;
|
||||
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
package org.redkale.convert;
|
||||
|
||||
import java.lang.reflect.*;
|
||||
import javax.persistence.Column;
|
||||
|
||||
import org.redkale.annotation.Comment;
|
||||
import org.redkale.persistence.Column;
|
||||
import org.redkale.source.FilterColumn;
|
||||
import org.redkale.util.*;
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ package org.redkale.convert;
|
||||
|
||||
import java.lang.reflect.*;
|
||||
import java.util.*;
|
||||
import org.redkale.annotation.ConstructorParameters;
|
||||
import org.redkale.convert.ext.StringSimpledCoder;
|
||||
import org.redkale.util.*;
|
||||
|
||||
@@ -312,8 +313,18 @@ public class ObjectEncoder<W extends Writer, T> implements Encodeable<W, T> {
|
||||
static String[] findConstructorProperties(Creator creator) {
|
||||
if (creator == null) return null;
|
||||
try {
|
||||
ConstructorParameters cps = creator.getClass().getMethod("create", Object[].class).getAnnotation(ConstructorParameters.class);
|
||||
return cps == null ? null : cps.value();
|
||||
Method method = creator.getClass().getMethod("create", Object[].class);
|
||||
ConstructorParameters cps = method.getAnnotation(ConstructorParameters.class);
|
||||
String[] vals = null;
|
||||
if (cps != null) {
|
||||
vals = cps.value();
|
||||
} else {
|
||||
org.redkale.util.ConstructorParameters cps2 = method.getAnnotation(org.redkale.util.ConstructorParameters.class);
|
||||
if (cps2 != null) {
|
||||
vals = cps2.value();
|
||||
}
|
||||
}
|
||||
return vals;
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.*;
|
||||
import java.util.logging.Level;
|
||||
import javax.annotation.Resource;
|
||||
import org.redkale.annotation.Resource;
|
||||
import org.redkale.boot.Application;
|
||||
import org.redkale.cluster.ClusterAgent;
|
||||
import org.redkale.net.http.*;
|
||||
|
||||
@@ -10,9 +10,11 @@ import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.logging.*;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.annotation.Resource;
|
||||
import org.redkale.boot.*;
|
||||
import org.redkale.annotation.AutoLoad;
|
||||
import org.redkale.annotation.*;
|
||||
import org.redkale.annotation.ResourceListener;
|
||||
import static org.redkale.boot.Application.RESNAME_APP_NODEID;
|
||||
import org.redkale.boot.*;
|
||||
import org.redkale.net.Servlet;
|
||||
import org.redkale.net.http.*;
|
||||
import org.redkale.net.sncp.*;
|
||||
@@ -252,6 +254,8 @@ public abstract class MessageAgent implements Resourcable {
|
||||
public final synchronized void putService(NodeHttpServer ns, Service service, HttpServlet servlet) {
|
||||
AutoLoad al = service.getClass().getAnnotation(AutoLoad.class);
|
||||
if (al != null && !al.value() && service.getClass().getAnnotation(Local.class) != null) return;
|
||||
org.redkale.util.AutoLoad al2 = service.getClass().getAnnotation(org.redkale.util.AutoLoad.class);
|
||||
if (al2 != null && !al2.value() && service.getClass().getAnnotation(Local.class) != null) return;
|
||||
{ //标记@RestService(name = " ") 需要跳过, 一般作为模板引擎
|
||||
RestService rest = service.getClass().getAnnotation(RestService.class);
|
||||
if (rest != null && !rest.name().isEmpty() && rest.name().trim().isEmpty()) return;
|
||||
@@ -266,6 +270,8 @@ public abstract class MessageAgent implements Resourcable {
|
||||
public final synchronized void putService(NodeSncpServer ns, Service service, SncpServlet servlet) {
|
||||
AutoLoad al = service.getClass().getAnnotation(AutoLoad.class);
|
||||
if (al != null && !al.value() && service.getClass().getAnnotation(Local.class) != null) return;
|
||||
org.redkale.util.AutoLoad al2 = service.getClass().getAnnotation(org.redkale.util.AutoLoad.class);
|
||||
if (al2 != null && !al2.value() && service.getClass().getAnnotation(Local.class) != null) return;
|
||||
String topic = generateSncpReqTopic(service);
|
||||
String consumerid = generateSncpConsumerid(topic, service);
|
||||
if (messageNodes.containsKey(consumerid)) throw new RuntimeException("consumerid(" + consumerid + ") is repeat");
|
||||
|
||||
@@ -12,7 +12,7 @@ import org.redkale.convert.bson.BsonConvert;
|
||||
import org.redkale.convert.json.JsonConvert;
|
||||
import org.redkale.net.http.HttpSimpleRequest;
|
||||
import org.redkale.net.sncp.SncpRequest;
|
||||
import org.redkale.util.Comment;
|
||||
import org.redkale.annotation.Comment;
|
||||
|
||||
/**
|
||||
* 存在MQ里面的数据结构<p>
|
||||
|
||||
@@ -11,6 +11,8 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.channels.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.*;
|
||||
|
||||
import org.redkale.annotation.ResourceType;
|
||||
import org.redkale.util.*;
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
package org.redkale.net;
|
||||
|
||||
import java.io.IOException;
|
||||
import javax.annotation.Priority;
|
||||
import org.redkale.annotation.Priority;
|
||||
import org.redkale.util.*;
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,7 +8,7 @@ package org.redkale.net;
|
||||
import java.io.IOException;
|
||||
import java.net.*;
|
||||
import java.util.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.redkale.annotation.Resource;
|
||||
import org.redkale.boot.Application;
|
||||
import org.redkale.util.AnyValue;
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@ import java.util.concurrent.atomic.*;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.logging.Level;
|
||||
import javax.net.ssl.SSLContext;
|
||||
|
||||
import org.redkale.annotation.ConstructorParameters;
|
||||
import org.redkale.convert.*;
|
||||
import org.redkale.convert.json.JsonConvert;
|
||||
import org.redkale.util.*;
|
||||
|
||||
@@ -14,6 +14,8 @@ import java.util.concurrent.*;
|
||||
import java.util.logging.*;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.net.ssl.SSLContext;
|
||||
|
||||
import org.redkale.annotation.Comment;
|
||||
import org.redkale.service.Service;
|
||||
import org.redkale.util.*;
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
package org.redkale.net.http;
|
||||
|
||||
import org.redkale.annotation.ConstructorParameters;
|
||||
import org.redkale.asm.MethodDebugVisitor;
|
||||
import java.nio.channels.CompletionHandler;
|
||||
import java.security.*;
|
||||
|
||||
@@ -14,6 +14,8 @@ import java.nio.charset.*;
|
||||
import java.util.*;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.redkale.annotation.Comment;
|
||||
import org.redkale.convert.*;
|
||||
import org.redkale.convert.json.JsonConvert;
|
||||
import org.redkale.net.*;
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.net.HttpCookie;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.*;
|
||||
import javax.persistence.Transient;
|
||||
import org.redkale.persistence.Transient;
|
||||
import org.redkale.convert.*;
|
||||
import org.redkale.convert.json.JsonConvert;
|
||||
import org.redkale.util.TypeToken;
|
||||
|
||||
@@ -10,6 +10,8 @@ import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.redkale.annotation.Comment;
|
||||
import org.redkale.convert.*;
|
||||
import org.redkale.convert.json.JsonConvert;
|
||||
import org.redkale.util.*;
|
||||
|
||||
@@ -5,19 +5,19 @@
|
||||
*/
|
||||
package org.redkale.net.http;
|
||||
|
||||
import org.redkale.asm.MethodDebugVisitor;
|
||||
import java.io.*;
|
||||
import java.lang.annotation.*;
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import static java.lang.annotation.ElementType.TYPE;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
import java.lang.annotation.*;
|
||||
import java.lang.reflect.*;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.channels.CompletionHandler;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.redkale.asm.*;
|
||||
import java.util.concurrent.CompletionStage;
|
||||
import org.redkale.annotation.Comment;
|
||||
import org.redkale.annotation.*;
|
||||
import static org.redkale.asm.ClassWriter.COMPUTE_FRAMES;
|
||||
import org.redkale.asm.*;
|
||||
import static org.redkale.asm.Opcodes.*;
|
||||
import org.redkale.asm.Type;
|
||||
import org.redkale.convert.*;
|
||||
@@ -26,8 +26,8 @@ import org.redkale.mq.*;
|
||||
import org.redkale.net.*;
|
||||
import org.redkale.net.sncp.Sncp;
|
||||
import org.redkale.service.*;
|
||||
import org.redkale.util.*;
|
||||
import org.redkale.source.Flipper;
|
||||
import org.redkale.util.*;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -313,7 +313,7 @@ public final class Rest {
|
||||
Class clzz = webSocketType;
|
||||
do {
|
||||
for (Field field : clzz.getDeclaredFields()) {
|
||||
if (field.getAnnotation(Resource.class) == null) continue;
|
||||
if (field.getAnnotation(Resource.class) == null && field.getAnnotation(javax.annotation.Resource.class) == null) continue;
|
||||
if (resourcesFieldNameSet.contains(field.getName())) continue;
|
||||
if (Modifier.isStatic(field.getModifiers())) {
|
||||
throw new RuntimeException(field + " cannot static on createRestWebSocketServlet");
|
||||
@@ -478,11 +478,13 @@ public final class Rest {
|
||||
for (int i = 0; i < resourcesFields.size(); i++) {
|
||||
Field field = resourcesFields.get(i);
|
||||
Resource res = field.getAnnotation(Resource.class);
|
||||
javax.annotation.Resource res2 = field.getAnnotation(javax.annotation.Resource.class);
|
||||
java.lang.reflect.Type fieldType = field.getGenericType();
|
||||
fv = cw.visitField(ACC_PRIVATE, "_redkale_resource_" + i, Type.getDescriptor(field.getType()), fieldType == field.getType() ? null : Utility.getTypeDescriptor(fieldType), null);
|
||||
{
|
||||
av0 = fv.visitAnnotation(resDesc, true);
|
||||
av0.visit("name", res.name());
|
||||
av0.visit("name", res != null ? res.name() : res2.name());
|
||||
av0.visit("required", res != null ? res.required() : false);
|
||||
av0.visitEnd();
|
||||
}
|
||||
fv.visitEnd();
|
||||
|
||||
@@ -18,7 +18,7 @@ import java.util.stream.Stream;
|
||||
import java.util.zip.*;
|
||||
import org.redkale.convert.Convert;
|
||||
import org.redkale.net.AsyncConnection;
|
||||
import org.redkale.util.Comment;
|
||||
import org.redkale.annotation.Comment;
|
||||
|
||||
/**
|
||||
* <blockquote><pre>
|
||||
|
||||
@@ -13,6 +13,8 @@ import java.util.concurrent.atomic.*;
|
||||
import java.util.function.*;
|
||||
import java.util.logging.*;
|
||||
import java.util.stream.*;
|
||||
|
||||
import org.redkale.annotation.Comment;
|
||||
import org.redkale.convert.Convert;
|
||||
import org.redkale.net.Cryptor;
|
||||
import static org.redkale.net.http.WebSocket.RETCODE_GROUP_EMPTY;
|
||||
|
||||
@@ -5,20 +5,21 @@
|
||||
*/
|
||||
package org.redkale.net.http;
|
||||
|
||||
import static org.redkale.net.http.WebSocket.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.io.Serializable;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.logging.*;
|
||||
import java.util.stream.*;
|
||||
import javax.annotation.*;
|
||||
import org.redkale.boot.*;
|
||||
import org.redkale.annotation.Comment;
|
||||
import org.redkale.annotation.*;
|
||||
import org.redkale.boot.Application;
|
||||
import org.redkale.convert.*;
|
||||
import org.redkale.convert.json.JsonConvert;
|
||||
import org.redkale.mq.MessageAgent;
|
||||
import static org.redkale.net.http.WebSocket.RETCODE_GROUP_EMPTY;
|
||||
import org.redkale.service.*;
|
||||
import org.redkale.source.*;
|
||||
import org.redkale.source.CacheSource;
|
||||
import org.redkale.util.*;
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,7 +7,9 @@ import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.logging.Level;
|
||||
import static org.redkale.net.http.WebSocket.RETCODE_GROUP_EMPTY;
|
||||
import static org.redkale.net.http.WebSocketNode.WS_SOURCE_KEY_USERID_PREFIX;
|
||||
|
||||
import org.redkale.annotation.AutoLoad;
|
||||
import org.redkale.annotation.ResourceType;
|
||||
import org.redkale.service.*;
|
||||
import org.redkale.util.*;
|
||||
|
||||
|
||||
@@ -16,7 +16,8 @@ import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.*;
|
||||
import java.util.logging.*;
|
||||
import java.util.zip.*;
|
||||
import javax.annotation.*;
|
||||
import org.redkale.annotation.*;
|
||||
import org.redkale.annotation.Comment;
|
||||
import org.redkale.boot.Application;
|
||||
import static org.redkale.boot.Application.RESNAME_SERVER_RESFACTORY;
|
||||
import org.redkale.convert.Convert;
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
*/
|
||||
package org.redkale.net.sncp;
|
||||
|
||||
import org.redkale.asm.MethodDebugVisitor;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.*;
|
||||
import java.net.InetSocketAddress;
|
||||
@@ -13,7 +12,8 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.channels.CompletionHandler;
|
||||
import java.security.*;
|
||||
import java.util.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.redkale.annotation.*;
|
||||
import org.redkale.annotation.ResourceType;
|
||||
import static org.redkale.asm.ClassWriter.COMPUTE_FRAMES;
|
||||
import org.redkale.asm.*;
|
||||
import static org.redkale.asm.Opcodes.*;
|
||||
@@ -100,25 +100,30 @@ public abstract class Sncp {
|
||||
|
||||
public static int getVersion(Service service) {
|
||||
if (service == null) return -1;
|
||||
Version ver = service.getClass().getAnnotation(Version.class);
|
||||
return ver == null ? -1 : ver.value();
|
||||
return -1; //暂不实现Version
|
||||
}
|
||||
|
||||
public static String getResourceName(Service service) {
|
||||
if (service == null) return null;
|
||||
Resource res = service.getClass().getAnnotation(Resource.class);
|
||||
return res == null ? null : res.name();
|
||||
if (res != null) return res.name();
|
||||
javax.annotation.Resource res2 = service.getClass().getAnnotation(javax.annotation.Resource.class);
|
||||
return res2 == null ? null : res2.name();
|
||||
}
|
||||
|
||||
public static Class getServiceType(Service service) {
|
||||
ResourceType rt = service.getClass().getAnnotation(ResourceType.class);
|
||||
return rt == null ? service.getClass() : rt.value();
|
||||
if (rt != null) return rt.value();
|
||||
org.redkale.util.ResourceType rt2 = service.getClass().getAnnotation(org.redkale.util.ResourceType.class);
|
||||
return rt2 == null ? service.getClass() : rt2.value();
|
||||
}
|
||||
|
||||
public static Class getResourceType(Service service) {
|
||||
if (service == null) return null;
|
||||
ResourceType type = service.getClass().getAnnotation(ResourceType.class);
|
||||
return type == null ? getServiceType(service) : type.value();
|
||||
if (type != null) return type.value();
|
||||
org.redkale.util.ResourceType rt2 = service.getClass().getAnnotation(org.redkale.util.ResourceType.class);
|
||||
return rt2 == null ? getServiceType(service) : rt2.value();
|
||||
}
|
||||
|
||||
public static AnyValue getConf(Service service) {
|
||||
@@ -327,7 +332,7 @@ public abstract class Sncp {
|
||||
AnnotationVisitor av0;
|
||||
|
||||
cw.visit(V11, ACC_PUBLIC + ACC_FINAL + ACC_SUPER, newDynName, null, supDynName, null);
|
||||
{
|
||||
{ //给动态生成的Service类标记上Resource
|
||||
av0 = cw.visitAnnotation(resDesc, true);
|
||||
av0.visit("name", name);
|
||||
av0.visitEnd();
|
||||
@@ -346,7 +351,8 @@ public abstract class Sncp {
|
||||
{
|
||||
av0 = cw.visitAnnotation(Type.getDescriptor(ResourceType.class), true);
|
||||
ResourceType rty = serviceImplClass.getAnnotation(ResourceType.class);
|
||||
av0.visit("value", Type.getType(Type.getDescriptor(rty == null ? serviceImplClass : rty.value())));
|
||||
org.redkale.util.ResourceType rty2 = serviceImplClass.getAnnotation(org.redkale.util.ResourceType.class);
|
||||
av0.visit("value", Type.getType(Type.getDescriptor(rty != null ? rty.value() : (rty2 != null ? rty2.value() : serviceImplClass))));
|
||||
av0.visitEnd();
|
||||
}
|
||||
{
|
||||
@@ -616,7 +622,7 @@ public abstract class Sncp {
|
||||
AnnotationVisitor av0;
|
||||
|
||||
cw.visit(V11, ACC_PUBLIC + ACC_FINAL + ACC_SUPER, newDynName, null, serviceTypeOrImplClass.isInterface() ? "java/lang/Object" : supDynName, serviceTypeOrImplClass.isInterface() ? new String[]{supDynName} : null);
|
||||
{
|
||||
{ //给动态生成的Service类标记上Resource
|
||||
av0 = cw.visitAnnotation(resDesc, true);
|
||||
av0.visit("name", name);
|
||||
av0.visitEnd();
|
||||
@@ -624,7 +630,8 @@ public abstract class Sncp {
|
||||
{
|
||||
av0 = cw.visitAnnotation(Type.getDescriptor(ResourceType.class), true);
|
||||
ResourceType rty = serviceTypeOrImplClass.getAnnotation(ResourceType.class);
|
||||
av0.visit("value", Type.getType(Type.getDescriptor(rty == null ? serviceTypeOrImplClass : rty.value())));
|
||||
org.redkale.util.ResourceType rty2 = serviceTypeOrImplClass.getAnnotation(org.redkale.util.ResourceType.class);
|
||||
av0.visit("value", Type.getType(Type.getDescriptor(rty != null ? rty.value() : (rty2 != null ? rty2.value() : serviceTypeOrImplClass))));
|
||||
av0.visitEnd();
|
||||
}
|
||||
{
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
package org.redkale.net.sncp;
|
||||
|
||||
import org.redkale.annotation.ConstructorParameters;
|
||||
import org.redkale.asm.MethodDebugVisitor;
|
||||
import java.nio.channels.CompletionHandler;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@@ -5,15 +5,15 @@
|
||||
*/
|
||||
package org.redkale.net.sncp;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.*;
|
||||
import java.net.*;
|
||||
import java.nio.*;
|
||||
import java.nio.channels.*;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.CompletionHandler;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.logging.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.redkale.annotation.Resource;
|
||||
import org.redkale.convert.bson.*;
|
||||
import org.redkale.convert.json.*;
|
||||
import org.redkale.mq.*;
|
||||
@@ -21,10 +21,8 @@ import org.redkale.net.*;
|
||||
import static org.redkale.net.sncp.SncpRequest.*;
|
||||
import static org.redkale.net.sncp.SncpResponse.fillRespHeader;
|
||||
import org.redkale.service.*;
|
||||
import org.redkale.source.*;
|
||||
import org.redkale.util.*;
|
||||
import org.redkale.service.RpcCall;
|
||||
import org.redkale.source.CacheSource;
|
||||
import org.redkale.source.DataSource;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -82,9 +80,8 @@ public final class SncpClient {
|
||||
this.messageClient = messageAgent == null ? null : messageAgent.getSncpMessageClient();
|
||||
this.topic = messageAgent == null ? null : messageAgent.generateSncpReqTopic(service);
|
||||
Class<?> tn = serviceTypeOrImplClass;
|
||||
Version ver = tn.getAnnotation(Version.class);
|
||||
this.serviceClass = serviceClass;
|
||||
this.serviceVersion = ver == null ? 0 : ver.value();
|
||||
this.serviceVersion = 0; //暂不实现Version
|
||||
this.clientSncpAddress = clientSncpAddress;
|
||||
this.name = serviceName;
|
||||
tn = ResourceFactory.getResourceType(tn);
|
||||
|
||||
@@ -5,26 +5,24 @@
|
||||
*/
|
||||
package org.redkale.net.sncp;
|
||||
|
||||
import org.redkale.asm.MethodDebugVisitor;
|
||||
import static org.redkale.net.sncp.SncpRequest.DEFAULT_HEADER;
|
||||
import java.io.*;
|
||||
import java.lang.annotation.*;
|
||||
import java.io.IOException;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.*;
|
||||
import java.nio.channels.CompletionHandler;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.logging.*;
|
||||
import javax.annotation.*;
|
||||
import org.redkale.asm.*;
|
||||
import org.redkale.annotation.Resource;
|
||||
import static org.redkale.asm.ClassWriter.COMPUTE_FRAMES;
|
||||
import org.redkale.asm.*;
|
||||
import static org.redkale.asm.Opcodes.*;
|
||||
import org.redkale.asm.Type;
|
||||
import org.redkale.convert.bson.*;
|
||||
import org.redkale.net.sncp.SncpAsyncHandler.DefaultSncpAsyncHandler;
|
||||
import static org.redkale.net.sncp.SncpRequest.DEFAULT_HEADER;
|
||||
import org.redkale.service.*;
|
||||
import org.redkale.util.*;
|
||||
import org.redkale.service.RpcCall;
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
62
src/main/java/org/redkale/persistence/Cacheable.java
Normal file
62
src/main/java/org/redkale/persistence/Cacheable.java
Normal file
@@ -0,0 +1,62 @@
|
||||
/** *****************************************************************************
|
||||
* Copyright (c) 2008 - 2013 Oracle Corporation. All rights reserved.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
|
||||
* which accompanies this distribution.
|
||||
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
|
||||
* and the Eclipse Distribution License is available at
|
||||
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||
*
|
||||
* Contributors:
|
||||
* Linda DeMichiel - Java Persistence 2.1
|
||||
* Linda DeMichiel - Java Persistence 2.0
|
||||
*
|
||||
***************************************************************************** */
|
||||
package org.redkale.persistence;
|
||||
|
||||
import static java.lang.annotation.ElementType.TYPE;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Specifies whether an entity should be cached if caching is enabled
|
||||
* when the value of the <code>persistence.xml</code> caching element
|
||||
* is <code>ENABLE_SELECTIVE</code> or <code>DISABLE_SELECTIVE</code>.
|
||||
* The value of the <code>Cacheable</code> annotation is inherited by
|
||||
* subclasses; it can be overridden by specifying
|
||||
* <code>Cacheable</code> on a subclass.
|
||||
*
|
||||
* <p>
|
||||
* <code>Cacheable(false)</code> means that the entity and its state must
|
||||
* not be cached by the provider.
|
||||
*
|
||||
* @since Java Persistence 2.0
|
||||
*/
|
||||
@Target({TYPE})
|
||||
@Retention(RUNTIME)
|
||||
public @interface Cacheable {
|
||||
|
||||
/**
|
||||
* (Optional) Whether or not the entity should be cached.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
boolean value() default true;
|
||||
|
||||
/**
|
||||
* (Optional) 定时自动更新缓存的周期秒数,为0表示不做定时更新, 大于0表示每经过interval秒后会自动从数据库中拉取数据更新Cache
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
int interval() default 0;
|
||||
|
||||
/**
|
||||
* DataSource是否直接返回对象的真实引用, 而不是copy一份
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
boolean direct() default false;
|
||||
|
||||
}
|
||||
153
src/main/java/org/redkale/persistence/Column.java
Normal file
153
src/main/java/org/redkale/persistence/Column.java
Normal file
@@ -0,0 +1,153 @@
|
||||
/** *****************************************************************************
|
||||
* Copyright (c) 2008 - 2013 Oracle Corporation. All rights reserved.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
|
||||
* which accompanies this distribution.
|
||||
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
|
||||
* and the Eclipse Distribution License is available at
|
||||
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||
*
|
||||
* Contributors:
|
||||
* Linda DeMichiel - Java Persistence 2.1
|
||||
* Linda DeMichiel - Java Persistence 2.0
|
||||
*
|
||||
***************************************************************************** */
|
||||
package org.redkale.persistence;
|
||||
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.Retention;
|
||||
import static java.lang.annotation.ElementType.METHOD;
|
||||
import static java.lang.annotation.ElementType.FIELD;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
/**
|
||||
* Specifies the mapped column for a persistent property or field.
|
||||
* If no <code>Column</code> annotation is specified, the default values apply.
|
||||
*
|
||||
* <blockquote><pre>
|
||||
* Example 1:
|
||||
*
|
||||
* @Column(name="DESC", nullable=false, length=512)
|
||||
* public String getDescription() { return description; }
|
||||
*
|
||||
* Example 2:
|
||||
*
|
||||
* @Column(name="DESC",
|
||||
* columnDefinition="CLOB NOT NULL",
|
||||
* table="EMP_DETAIL")
|
||||
* @Lob
|
||||
* public String getDescription() { return description; }
|
||||
*
|
||||
* Example 3:
|
||||
*
|
||||
* @Column(name="ORDER_COST", updatable=false, precision=12, scale=2)
|
||||
* public BigDecimal getCost() { return cost; }
|
||||
*
|
||||
* </pre></blockquote>
|
||||
*
|
||||
*
|
||||
* @since Java Persistence 1.0
|
||||
*/
|
||||
@Target({METHOD, FIELD})
|
||||
@Retention(RUNTIME)
|
||||
public @interface Column {
|
||||
|
||||
/**
|
||||
* (Optional) The name of the column. Defaults to
|
||||
* the property or field name.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
String name() default "";
|
||||
|
||||
/**
|
||||
* (Optional) The comment of the column.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
String comment() default "";
|
||||
|
||||
/**
|
||||
* (Optional) Whether the column is a unique key. This is a
|
||||
* shortcut for the <code>UniqueConstraint</code> annotation at the table
|
||||
* level and is useful for when the unique key constraint
|
||||
* corresponds to only a single column. This constraint applies
|
||||
* in addition to any constraint entailed by primary key mapping and
|
||||
* to constraints specified at the table level.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
boolean unique() default false;
|
||||
|
||||
/**
|
||||
* (Optional) Whether the database column is required.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
boolean nullable() default true;
|
||||
|
||||
/**
|
||||
* for OpenAPI Specification 3
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
String example() default "";
|
||||
|
||||
/**
|
||||
* (Optional) Whether the column is included in SQL INSERT
|
||||
* statements generated by the persistence provider.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
boolean insertable() default true;
|
||||
|
||||
/**
|
||||
* (Optional) Whether the column is included in SQL UPDATE
|
||||
* statements generated by the persistence provider.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
boolean updatable() default true;
|
||||
|
||||
/**
|
||||
* (Optional) The name of the table that contains the column.
|
||||
* If absent the column is assumed to be in the primary table.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
@Deprecated
|
||||
String table() default "";
|
||||
|
||||
/**
|
||||
* (Optional) The column length. (Applies only if a
|
||||
* string-valued column is used.)
|
||||
* if type==String and length == 65535 then sqltype is TEXT <br>
|
||||
* if type==String and length <= 16777215 then sqltype is MEDIUMTEXT <br>
|
||||
* if type==String and length > 16777215 then sqltype is LONGTEXT <br>
|
||||
* if type==byte[] and length <= 65535 then sqltype is BLOB <br>
|
||||
* if type==byte[] and length <= 16777215 then sqltype is MEDIUMBLOB <br>
|
||||
* if type==byte[] and length > 16777215 then sqltype is LONGBLOB <br>
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
int length() default 255;
|
||||
|
||||
/**
|
||||
* (Optional) The precision for a decimal (exact numeric)
|
||||
* column. (Applies only if a decimal column is used.)
|
||||
* Value must be set by developer if used when generating
|
||||
* the DDL for the column.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
int precision() default 0;
|
||||
|
||||
/**
|
||||
* (Optional) The scale for a decimal (exact numeric) column.
|
||||
* (Applies only if a decimal column is used.)
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
int scale() default 0;
|
||||
}
|
||||
49
src/main/java/org/redkale/persistence/Entity.java
Normal file
49
src/main/java/org/redkale/persistence/Entity.java
Normal file
@@ -0,0 +1,49 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2008 - 2013 Oracle Corporation. All rights reserved.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
|
||||
* which accompanies this distribution.
|
||||
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
|
||||
* and the Eclipse Distribution License is available at
|
||||
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||
*
|
||||
* Contributors:
|
||||
* Linda DeMichiel - Java Persistence 2.1
|
||||
* Linda DeMichiel - Java Persistence 2.0
|
||||
*
|
||||
******************************************************************************/
|
||||
package org.redkale.persistence;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
import static java.lang.annotation.ElementType.TYPE;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
/**
|
||||
* Specifies that the class is an entity. This annotation is applied to the
|
||||
* entity class.
|
||||
*
|
||||
* @since Java Persistence 1.0
|
||||
*/
|
||||
@Inherited
|
||||
@Documented
|
||||
@Target(TYPE)
|
||||
@Retention(RUNTIME)
|
||||
public @interface Entity {
|
||||
|
||||
/**
|
||||
* (Optional) The entity name. Defaults to the unqualified
|
||||
* name of the entity class. This name is used to refer to the
|
||||
* entity in queries. The name must not be a reserved literal
|
||||
* in the Java Persistence query language.
|
||||
* @return String
|
||||
*/
|
||||
String name() default "";
|
||||
|
||||
/**
|
||||
* (Optional) The comment of the entity.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
String comment() default "";
|
||||
}
|
||||
55
src/main/java/org/redkale/persistence/Id.java
Normal file
55
src/main/java/org/redkale/persistence/Id.java
Normal file
@@ -0,0 +1,55 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2008 - 2013 Oracle Corporation. All rights reserved.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
|
||||
* which accompanies this distribution.
|
||||
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
|
||||
* and the Eclipse Distribution License is available at
|
||||
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||
*
|
||||
* Contributors:
|
||||
* Linda DeMichiel - Java Persistence 2.1
|
||||
* Linda DeMichiel - Java Persistence 2.0
|
||||
*
|
||||
******************************************************************************/
|
||||
package org.redkale.persistence;
|
||||
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.Retention;
|
||||
import static java.lang.annotation.ElementType.FIELD;
|
||||
import static java.lang.annotation.ElementType.METHOD;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
/**
|
||||
* Specifies the primary key of an entity.
|
||||
* The field or property to which the <code>Id</code> annotation is applied
|
||||
* should be one of the following types: any Java primitive type;
|
||||
* any primitive wrapper type;
|
||||
* <code>String</code>;
|
||||
* <code>java.util.Date</code>;
|
||||
* <code>java.sql.Date</code>;
|
||||
* <code>java.math.BigDecimal</code>;
|
||||
* <code>java.math.BigInteger</code>.
|
||||
*
|
||||
* <p>The mapped column for the primary key of the entity is assumed
|
||||
* to be the primary key of the primary table. If no <code>Column</code> annotation
|
||||
* is specified, the primary key column name is assumed to be the name
|
||||
* of the primary key property or field.
|
||||
*
|
||||
* <pre>
|
||||
* Example:
|
||||
*
|
||||
* @Id
|
||||
* public Long getId() { return id; }
|
||||
* </pre>
|
||||
*
|
||||
* @see Column
|
||||
* see GeneratedValue
|
||||
*
|
||||
* @since Java Persistence 1.0
|
||||
*/
|
||||
@Target({METHOD, FIELD})
|
||||
@Retention(RUNTIME)
|
||||
|
||||
public @interface Id {}
|
||||
69
src/main/java/org/redkale/persistence/Index.java
Normal file
69
src/main/java/org/redkale/persistence/Index.java
Normal file
@@ -0,0 +1,69 @@
|
||||
/** *****************************************************************************
|
||||
* Copyright (c) 2011 - 2013 Oracle Corporation. All rights reserved.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
|
||||
* which accompanies this distribution.
|
||||
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
|
||||
* and the Eclipse Distribution License is available at
|
||||
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||
*
|
||||
* Contributors:
|
||||
* Linda DeMichiel - Java Persistence 2.1
|
||||
*
|
||||
***************************************************************************** */
|
||||
package org.redkale.persistence;
|
||||
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Used in schema generation to specify creation of an index.
|
||||
* <p>
|
||||
* Note that it is not necessary to specify an index for a primary key,
|
||||
* as the primary key index will be created automatically.
|
||||
*
|
||||
* <p>
|
||||
* The syntax of the <code>columnList</code> element is a
|
||||
* <code>column_list</code>, as follows:
|
||||
*
|
||||
* <pre>
|
||||
* column::= index_column [,index_column]*
|
||||
* index_column::= column_name [ASC | DESC]
|
||||
* </pre>
|
||||
*
|
||||
* <p>
|
||||
* If <code>ASC</code> or <code>DESC</code> is not specified,
|
||||
* <code>ASC</code> (ascending order) is assumed.
|
||||
*
|
||||
* @since Java Persistence 2.1
|
||||
*
|
||||
*/
|
||||
@Target({})
|
||||
@Retention(RUNTIME)
|
||||
public @interface Index {
|
||||
|
||||
/**
|
||||
* (Optional) The name of the index; defaults to a provider-generated name.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
String name() default "";
|
||||
|
||||
/**
|
||||
* (Required) The names of the columns to be included in the index,
|
||||
* in order.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
String columnList();
|
||||
|
||||
/**
|
||||
* (Optional) Whether the index is unique.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
boolean unique() default false;
|
||||
|
||||
}
|
||||
101
src/main/java/org/redkale/persistence/SearchColumn.java
Normal file
101
src/main/java/org/redkale/persistence/SearchColumn.java
Normal file
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.redkale.persistence;
|
||||
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.Retention;
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
/**
|
||||
*
|
||||
* 搜索引擎的数据Entity依附在setter、getter方法、字段进行简单的配置 <br>
|
||||
*
|
||||
* <p>
|
||||
* 详情见: https://redkale.org
|
||||
*
|
||||
* @author zhangjx
|
||||
* @since 2.4.0
|
||||
*/
|
||||
@Target({FIELD})
|
||||
@Retention(RUNTIME)
|
||||
public @interface SearchColumn {
|
||||
|
||||
//高亮显示参数
|
||||
public static class HighLights {
|
||||
|
||||
public static final String HIGHLIGHT_NAME_ID = "#[id]";
|
||||
|
||||
public static final String HIGHLIGHT_NAME_INDEX = "#[index]";
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否全文搜索
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
boolean text() default false;
|
||||
|
||||
/**
|
||||
* 高亮对应的Column.name字段名,被标记的字段为虚拟字段,不会映射表中的字段 <br>
|
||||
* 被标记的字段必须是String类型 <br>
|
||||
* 有值时,ignore必须为true
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
String highlight() default "";
|
||||
|
||||
/**
|
||||
* 解析/存储时是否屏蔽该字段
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
boolean ignore() default false;
|
||||
|
||||
/**
|
||||
* 设置索引参数, 特殊值"false"表示不被索引
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
String options() default "";
|
||||
|
||||
/**
|
||||
* 内容是否html格式
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
boolean html() default false;
|
||||
|
||||
/**
|
||||
* 内容是否时间类型,只有数据类型为int、long、String才有效
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
boolean date() default false;
|
||||
|
||||
/**
|
||||
* 内容是否ip类型,只有数据类型为String才有效
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
boolean ip() default false;
|
||||
|
||||
/**
|
||||
* 设置索引分词器
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
String analyzer() default "";
|
||||
|
||||
/**
|
||||
* 设置搜索索引分词器
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
String searchAnalyzer() default "";
|
||||
|
||||
}
|
||||
92
src/main/java/org/redkale/persistence/Table.java
Normal file
92
src/main/java/org/redkale/persistence/Table.java
Normal file
@@ -0,0 +1,92 @@
|
||||
/** *****************************************************************************
|
||||
* Copyright (c) 2008 - 2013 Oracle Corporation. All rights reserved.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
|
||||
* which accompanies this distribution.
|
||||
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
|
||||
* and the Eclipse Distribution License is available at
|
||||
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||
*
|
||||
* Contributors:
|
||||
* Linda DeMichiel - Java Persistence 2.1
|
||||
* Linda DeMichiel - Java Persistence 2.0
|
||||
*
|
||||
***************************************************************************** */
|
||||
package org.redkale.persistence;
|
||||
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.Retention;
|
||||
import static java.lang.annotation.ElementType.TYPE;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
/**
|
||||
* Specifies the primary table for the annotated entity. Additional
|
||||
* tables may be specified using SecondaryTable or SecondaryTables annotation.
|
||||
*
|
||||
* <p>
|
||||
* If no <code>Table</code> annotation is specified for an entity
|
||||
* class, the default values apply.
|
||||
*
|
||||
* <pre>
|
||||
* Example:
|
||||
*
|
||||
* @Entity
|
||||
* @Table(name="CUST", schema="RECORDS")
|
||||
* public class Customer { ... }
|
||||
* </pre>
|
||||
*
|
||||
* @since Java Persistence 1.0
|
||||
*/
|
||||
@Target(TYPE)
|
||||
@Retention(RUNTIME)
|
||||
public @interface Table {
|
||||
|
||||
/**
|
||||
* (Optional) The name of the table.
|
||||
* <p>
|
||||
* Defaults to the entity name.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
String name() default "";
|
||||
|
||||
/** (Optional) The catalog of the table.
|
||||
* <p>
|
||||
* Defaults to the default catalog.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
String catalog() default "";
|
||||
|
||||
/**
|
||||
* (Optional) Unique constraints that are to be placed on
|
||||
* the table. These are only used if table generation is in
|
||||
* effect. These constraints apply in addition to any constraints
|
||||
* specified by the <code>Column</code> and <code>JoinColumn</code>
|
||||
* annotations and constraints entailed by primary key mappings.
|
||||
* <p>
|
||||
* Defaults to no additional constraints.
|
||||
* @return UniqueConstraint[]
|
||||
*/
|
||||
UniqueConstraint[] uniqueConstraints() default {};
|
||||
|
||||
/**
|
||||
* (Optional) Indexes for the table. These are only used if
|
||||
* table generation is in effect. Note that it is not necessary
|
||||
* to specify an index for a primary key, as the primary key
|
||||
* index will be created automatically.
|
||||
*
|
||||
* @return indexes
|
||||
* @since Java Persistence 2.1
|
||||
*/
|
||||
Index[] indexes() default {};
|
||||
|
||||
/**
|
||||
* comment
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
String comment() default "";
|
||||
|
||||
}
|
||||
45
src/main/java/org/redkale/persistence/Transient.java
Normal file
45
src/main/java/org/redkale/persistence/Transient.java
Normal file
@@ -0,0 +1,45 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2008 - 2013 Oracle Corporation. All rights reserved.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
|
||||
* which accompanies this distribution.
|
||||
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
|
||||
* and the Eclipse Distribution License is available at
|
||||
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||
*
|
||||
* Contributors:
|
||||
* Linda DeMichiel - Java Persistence 2.1
|
||||
* Linda DeMichiel - Java Persistence 2.0
|
||||
*
|
||||
******************************************************************************/
|
||||
package org.redkale.persistence;
|
||||
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.Retention;
|
||||
import static java.lang.annotation.ElementType.METHOD;
|
||||
import static java.lang.annotation.ElementType.FIELD;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
/**
|
||||
* Specifies that the property or field is not persistent. It is used
|
||||
* to annotate a property or field of an entity class, mapped
|
||||
* superclass, or embeddable class.
|
||||
*
|
||||
* <pre>
|
||||
* Example:
|
||||
*
|
||||
* @Entity
|
||||
* public class Employee {
|
||||
* @Id int id;
|
||||
* @Transient User currentUser;
|
||||
* ...
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* @since Java Persistence 1.0
|
||||
*/
|
||||
@Target({METHOD, FIELD})
|
||||
@Retention(RUNTIME)
|
||||
|
||||
public @interface Transient {}
|
||||
56
src/main/java/org/redkale/persistence/UniqueConstraint.java
Normal file
56
src/main/java/org/redkale/persistence/UniqueConstraint.java
Normal file
@@ -0,0 +1,56 @@
|
||||
/** *****************************************************************************
|
||||
* Copyright (c) 2008 - 2013 Oracle Corporation. All rights reserved.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
|
||||
* which accompanies this distribution.
|
||||
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
|
||||
* and the Eclipse Distribution License is available at
|
||||
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||
*
|
||||
* Contributors:
|
||||
* Linda DeMichiel - Java Persistence 2.1
|
||||
* Linda DeMichiel - Java Persistence 2.0
|
||||
*
|
||||
***************************************************************************** */
|
||||
package org.redkale.persistence;
|
||||
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.Retention;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
/**
|
||||
* Specifies that a unique constraint is to be included in
|
||||
* the generated DDL for a primary or secondary table.
|
||||
*
|
||||
* <pre>
|
||||
* Example:
|
||||
* @Entity
|
||||
* @Table(
|
||||
* name="EMPLOYEE",
|
||||
* uniqueConstraints=
|
||||
* @UniqueConstraint(columnNames={"EMP_ID", "EMP_NAME"})
|
||||
* )
|
||||
* public class Employee { ... }
|
||||
* </pre>
|
||||
*
|
||||
* @since Java Persistence 1.0
|
||||
*/
|
||||
@Target({})
|
||||
@Retention(RUNTIME)
|
||||
public @interface UniqueConstraint {
|
||||
|
||||
/** (Optional) Constraint name. A provider-chosen name will be chosen
|
||||
* if a name is not specified.
|
||||
*
|
||||
* @return String
|
||||
* @since Java Persistence 2.0
|
||||
*/
|
||||
String name() default "";
|
||||
|
||||
/** (Required) An array of the column names that make up the constraint.
|
||||
*
|
||||
* @return String[]
|
||||
*/
|
||||
String[] columnNames();
|
||||
}
|
||||
56
src/main/java/org/redkale/persistence/VirtualEntity.java
Normal file
56
src/main/java/org/redkale/persistence/VirtualEntity.java
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.redkale.persistence;
|
||||
|
||||
import org.redkale.source.DataSource;
|
||||
import org.redkale.source.EntityInfo;
|
||||
|
||||
import static java.lang.annotation.ElementType.TYPE;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
import java.lang.annotation.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.*;
|
||||
|
||||
/**
|
||||
* VirtualEntity表示虚拟的数据实体类, 通常Entity都会映射到数据库中的某个表,而标记为@VirtualEntity的Entity类只存在EntityCache中
|
||||
*
|
||||
* <p>
|
||||
* 详情见: https://redkale.org
|
||||
*
|
||||
* @author zhangjx
|
||||
*/
|
||||
@Documented
|
||||
@Target(TYPE)
|
||||
@Retention(RUNTIME)
|
||||
public @interface VirtualEntity {
|
||||
|
||||
/**
|
||||
* DataSource是否直接返回对象的真实引用, 而不是copy一份
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
boolean direct() default false;
|
||||
|
||||
/**
|
||||
* 初始化时数据的加载器
|
||||
*
|
||||
* @return Class
|
||||
*/
|
||||
Class<? extends BiFunction<DataSource, EntityInfo, CompletableFuture<List>>> loader() default DefaultFunctionLoader.class;
|
||||
|
||||
/**
|
||||
* 默认全量加载器
|
||||
*
|
||||
*/
|
||||
public static class DefaultFunctionLoader implements BiFunction<DataSource, EntityInfo, CompletableFuture<List>> {
|
||||
|
||||
@Override
|
||||
public CompletableFuture<List> apply(DataSource source, EntityInfo info) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
package org.redkale.service;
|
||||
|
||||
import java.util.concurrent.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.redkale.annotation.Resource;
|
||||
import org.redkale.boot.Application;
|
||||
import org.redkale.net.*;
|
||||
import org.redkale.net.sncp.Sncp;
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.lang.reflect.Type;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.function.Function;
|
||||
import javax.persistence.Column;
|
||||
import org.redkale.persistence.Column;
|
||||
import org.redkale.convert.*;
|
||||
import org.redkale.convert.json.*;
|
||||
import org.redkale.util.*;
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
package org.redkale.service;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.redkale.annotation.AutoLoad;
|
||||
import org.redkale.annotation.ResourceType;
|
||||
import org.redkale.net.http.*;
|
||||
import org.redkale.util.*;
|
||||
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
*/
|
||||
package org.redkale.source;
|
||||
|
||||
import org.redkale.annotation.AutoLoad;
|
||||
import org.redkale.annotation.ResourceListener;
|
||||
import org.redkale.annotation.ResourceType;
|
||||
import org.redkale.service.*;
|
||||
import org.redkale.util.*;
|
||||
|
||||
|
||||
@@ -11,8 +11,12 @@ import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.*;
|
||||
import java.util.stream.Stream;
|
||||
import javax.persistence.Entity;
|
||||
import org.redkale.annotation.AutoLoad;
|
||||
import org.redkale.annotation.Comment;
|
||||
import org.redkale.annotation.ResourceListener;
|
||||
import org.redkale.annotation.ResourceType;
|
||||
import org.redkale.convert.json.JsonConvert;
|
||||
import org.redkale.persistence.Entity;
|
||||
import org.redkale.service.*;
|
||||
import org.redkale.util.*;
|
||||
|
||||
@@ -300,7 +304,7 @@ public abstract class AbstractDataSource extends AbstractService implements Data
|
||||
for (T val : entitys) {
|
||||
if (clazz == null) {
|
||||
clazz = val.getClass();
|
||||
if (clazz.getAnnotation(Entity.class) == null) {
|
||||
if (clazz.getAnnotation(Entity.class) == null && clazz.getAnnotation(javax.persistence.Entity.class) == null) {
|
||||
throw new RuntimeException("Entity Class " + clazz + " must be on Annotation @Entity");
|
||||
}
|
||||
continue;
|
||||
@@ -1275,7 +1279,7 @@ public abstract class AbstractDataSource extends AbstractService implements Data
|
||||
public <T> DataBatch insert(T... entitys) {
|
||||
for (T t : entitys) {
|
||||
Objects.requireNonNull(t);
|
||||
if (t.getClass().getAnnotation(Entity.class) == null) {
|
||||
if (t.getClass().getAnnotation(Entity.class) == null && t.getClass().getAnnotation(javax.persistence.Entity.class) == null) {
|
||||
throw new RuntimeException("Entity Class " + t.getClass() + " must be on Annotation @Entity");
|
||||
}
|
||||
this.actions.add(new InsertBatchAction1(t));
|
||||
@@ -1287,7 +1291,7 @@ public abstract class AbstractDataSource extends AbstractService implements Data
|
||||
public <T> DataBatch delete(T... entitys) {
|
||||
for (T t : entitys) {
|
||||
Objects.requireNonNull(t);
|
||||
if (t.getClass().getAnnotation(Entity.class) == null) {
|
||||
if (t.getClass().getAnnotation(Entity.class) == null && t.getClass().getAnnotation(javax.persistence.Entity.class) == null) {
|
||||
throw new RuntimeException("Entity Class " + t.getClass() + " must be on Annotation @Entity");
|
||||
}
|
||||
this.actions.add(new DeleteBatchAction1(t));
|
||||
@@ -1298,7 +1302,7 @@ public abstract class AbstractDataSource extends AbstractService implements Data
|
||||
@Override
|
||||
public <T> DataBatch delete(Class<T> clazz, Serializable... pks) {
|
||||
Objects.requireNonNull(clazz);
|
||||
if (clazz.getAnnotation(Entity.class) == null) {
|
||||
if (clazz.getAnnotation(Entity.class) == null && clazz.getAnnotation(javax.persistence.Entity.class) == null) {
|
||||
throw new RuntimeException("Entity Class " + clazz + " must be on Annotation @Entity");
|
||||
}
|
||||
if (pks.length < 1) {
|
||||
@@ -1319,7 +1323,7 @@ public abstract class AbstractDataSource extends AbstractService implements Data
|
||||
@Override
|
||||
public <T> DataBatch delete(Class<T> clazz, FilterNode node, Flipper flipper) {
|
||||
Objects.requireNonNull(clazz);
|
||||
if (clazz.getAnnotation(Entity.class) == null) {
|
||||
if (clazz.getAnnotation(Entity.class) == null && clazz.getAnnotation(javax.persistence.Entity.class) == null) {
|
||||
throw new RuntimeException("Entity Class " + clazz + " must be on Annotation @Entity");
|
||||
}
|
||||
this.actions.add(new DeleteBatchAction3(clazz, node, flipper));
|
||||
@@ -1330,7 +1334,7 @@ public abstract class AbstractDataSource extends AbstractService implements Data
|
||||
public <T> DataBatch update(T... entitys) {
|
||||
for (T t : entitys) {
|
||||
Objects.requireNonNull(t);
|
||||
if (t.getClass().getAnnotation(Entity.class) == null) {
|
||||
if (t.getClass().getAnnotation(Entity.class) == null && t.getClass().getAnnotation(javax.persistence.Entity.class) == null) {
|
||||
throw new RuntimeException("Entity Class " + t.getClass() + " must be on Annotation @Entity");
|
||||
}
|
||||
this.actions.add(new UpdateBatchAction1(t));
|
||||
@@ -1346,7 +1350,7 @@ public abstract class AbstractDataSource extends AbstractService implements Data
|
||||
@Override
|
||||
public <T> DataBatch update(Class<T> clazz, Serializable pk, ColumnValue... values) {
|
||||
Objects.requireNonNull(clazz);
|
||||
if (clazz.getAnnotation(Entity.class) == null) {
|
||||
if (clazz.getAnnotation(Entity.class) == null && clazz.getAnnotation(javax.persistence.Entity.class) == null) {
|
||||
throw new RuntimeException("Entity Class " + clazz + " must be on Annotation @Entity");
|
||||
}
|
||||
Objects.requireNonNull(pk);
|
||||
@@ -1373,7 +1377,7 @@ public abstract class AbstractDataSource extends AbstractService implements Data
|
||||
@Override
|
||||
public <T> DataBatch update(Class<T> clazz, FilterNode node, Flipper flipper, ColumnValue... values) {
|
||||
Objects.requireNonNull(clazz);
|
||||
if (clazz.getAnnotation(Entity.class) == null) {
|
||||
if (clazz.getAnnotation(Entity.class) == null && clazz.getAnnotation(javax.persistence.Entity.class) == null) {
|
||||
throw new RuntimeException("Entity Class " + clazz + " must be on Annotation @Entity");
|
||||
}
|
||||
if (values.length < 1) {
|
||||
@@ -1410,7 +1414,7 @@ public abstract class AbstractDataSource extends AbstractService implements Data
|
||||
@Override
|
||||
public <T> DataBatch updateColumn(T entity, final FilterNode node, SelectColumn selects) {
|
||||
Objects.requireNonNull(entity);
|
||||
if (entity.getClass().getAnnotation(Entity.class) == null) {
|
||||
if (entity.getClass().getAnnotation(Entity.class) == null && entity.getClass().getAnnotation(javax.persistence.Entity.class) == null) {
|
||||
throw new RuntimeException("Entity Class " + entity.getClass() + " must be on Annotation @Entity");
|
||||
}
|
||||
Objects.requireNonNull(selects);
|
||||
|
||||
@@ -5,17 +5,21 @@
|
||||
*/
|
||||
package org.redkale.source;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.function.*;
|
||||
import java.util.logging.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.redkale.annotation.AutoLoad;
|
||||
import org.redkale.annotation.ConstructorParameters;
|
||||
import org.redkale.annotation.*;
|
||||
import org.redkale.annotation.ResourceListener;
|
||||
import org.redkale.annotation.ResourceType;
|
||||
import org.redkale.convert.*;
|
||||
import org.redkale.convert.json.*;
|
||||
import org.redkale.service.*;
|
||||
import org.redkale.service.Local;
|
||||
import org.redkale.util.*;
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,13 +5,16 @@
|
||||
*/
|
||||
package org.redkale.source;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.Serializable;
|
||||
import java.sql.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.*;
|
||||
import java.util.function.*;
|
||||
import java.util.logging.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.logging.Level;
|
||||
import org.redkale.annotation.AutoLoad;
|
||||
import org.redkale.annotation.ResourceListener;
|
||||
import org.redkale.annotation.ResourceType;
|
||||
import org.redkale.service.Local;
|
||||
import org.redkale.util.*;
|
||||
|
||||
|
||||
@@ -7,8 +7,11 @@ package org.redkale.source;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.function.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.Function;
|
||||
import org.redkale.annotation.AutoLoad;
|
||||
import org.redkale.annotation.ResourceListener;
|
||||
import org.redkale.annotation.ResourceType;
|
||||
import org.redkale.service.Local;
|
||||
import org.redkale.util.*;
|
||||
|
||||
|
||||
@@ -13,13 +13,18 @@ import java.util.concurrent.atomic.*;
|
||||
import java.util.function.*;
|
||||
import java.util.logging.*;
|
||||
import java.util.stream.Stream;
|
||||
import javax.annotation.Resource;
|
||||
import org.redkale.annotation.AutoLoad;
|
||||
import org.redkale.annotation.*;
|
||||
import org.redkale.annotation.ResourceListener;
|
||||
import org.redkale.annotation.ResourceType;
|
||||
import static org.redkale.boot.Application.*;
|
||||
import org.redkale.net.AsyncGroup;
|
||||
import org.redkale.service.*;
|
||||
import org.redkale.persistence.Table;
|
||||
import org.redkale.service.Local;
|
||||
import org.redkale.source.EntityInfo.EntityColumn;
|
||||
import org.redkale.util.*;
|
||||
|
||||
|
||||
/**
|
||||
* DataSource的SQL抽象实现类 <br>
|
||||
* 注意: 所有的操作只能作用在一张表上,不能同时变更多张表
|
||||
@@ -255,7 +260,7 @@ public abstract class DataSqlSource extends AbstractDataSource implements Functi
|
||||
//生成创建表的SQL
|
||||
protected <T> String[] createTableSqls(EntityInfo<T> info) {
|
||||
if (info == null || !autoDDL) return null;
|
||||
javax.persistence.Table table = info.getType().getAnnotation(javax.persistence.Table.class);
|
||||
Table table = info.getType().getAnnotation(Table.class);
|
||||
if ("mysql".equals(dbtype())) { //mysql
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("CREATE TABLE IF NOT EXISTS `").append(info.getOriginTable()).append("`(\n");
|
||||
@@ -611,7 +616,7 @@ public abstract class DataSqlSource extends AbstractDataSource implements Functi
|
||||
}
|
||||
|
||||
/**
|
||||
* 将entity的对象全部加载到Cache中去,如果clazz没有被@javax.persistence.Cacheable注解则不做任何事
|
||||
* 将entity的对象全部加载到Cache中去,如果clazz没有被@org.redkale.persistence.Cacheable注解则不做任何事
|
||||
*
|
||||
* @param <T> Entity类泛型
|
||||
* @param clazz Entity类
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
*/
|
||||
package org.redkale.source;
|
||||
|
||||
import org.redkale.source.DistributeTableStrategy;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
@@ -13,7 +13,7 @@ import java.util.concurrent.atomic.*;
|
||||
import java.util.function.*;
|
||||
import java.util.logging.*;
|
||||
import java.util.stream.*;
|
||||
import javax.persistence.*;
|
||||
import org.redkale.persistence.*;
|
||||
import static org.redkale.source.FilterFunc.*;
|
||||
import org.redkale.util.*;
|
||||
|
||||
@@ -79,19 +79,28 @@ public final class EntityCache<T> {
|
||||
private CompletableFuture<List<T>> loadFuture;
|
||||
|
||||
public EntityCache(final EntityInfo<T> info, final Cacheable c) {
|
||||
this(info, c != null ? c.interval() : 0, c != null && c.direct());
|
||||
}
|
||||
|
||||
EntityCache(final EntityInfo<T> info, final int cacheInterval, final boolean cacheDirect) {
|
||||
this.info = info;
|
||||
this.interval = c == null ? 0 : c.interval();
|
||||
this.interval = cacheInterval < 0 ? 0 : cacheInterval;
|
||||
this.type = info.getType();
|
||||
this.arrayer = info.getArrayer();
|
||||
this.creator = info.getCreator();
|
||||
this.primary = info.primary;
|
||||
VirtualEntity ve = info.getType().getAnnotation(VirtualEntity.class);
|
||||
boolean direct = c != null && c.direct();
|
||||
org.redkale.persistence.VirtualEntity ve = info.getType().getAnnotation(org.redkale.persistence.VirtualEntity.class);
|
||||
boolean direct = cacheDirect;
|
||||
if (!direct) direct = ve != null && ve.direct();
|
||||
{ //兼容废弃类
|
||||
org.redkale.source.VirtualEntity ve2 = info.getType().getAnnotation(org.redkale.source.VirtualEntity.class);
|
||||
if (!direct && ve2 != null) direct = ve2.direct();
|
||||
}
|
||||
this.needcopy = !direct;
|
||||
this.newReproduce = Reproduce.create(type, type, (m) -> {
|
||||
try {
|
||||
return type.getDeclaredField(m).getAnnotation(Transient.class) == null;
|
||||
java.lang.reflect.Field field = type.getDeclaredField(m);
|
||||
return field.getAnnotation(Transient.class) == null && field.getAnnotation(javax.persistence.Transient.class) == null;
|
||||
} catch (Exception e) {
|
||||
return true;
|
||||
}
|
||||
@@ -100,6 +109,7 @@ public final class EntityCache<T> {
|
||||
try {
|
||||
java.lang.reflect.Field field = type.getDeclaredField(m);
|
||||
if (field.getAnnotation(Transient.class) != null) return false;
|
||||
if (field.getAnnotation(javax.persistence.Transient.class) != null) return false;
|
||||
Column column = field.getAnnotation(Column.class);
|
||||
return (column == null || column.updatable());
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -11,8 +11,12 @@ import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.function.*;
|
||||
import java.util.logging.*;
|
||||
import javax.persistence.*;
|
||||
import org.redkale.annotation.Comment;
|
||||
import org.redkale.annotation.ConstructorParameters;
|
||||
import org.redkale.annotation.LogExcludeLevel;
|
||||
import org.redkale.annotation.LogLevel;
|
||||
import org.redkale.convert.json.*;
|
||||
import org.redkale.persistence.*;
|
||||
import org.redkale.util.*;
|
||||
|
||||
/**
|
||||
@@ -240,7 +244,9 @@ public final class EntityInfo<T> {
|
||||
//---------------------------------------------
|
||||
|
||||
LogLevel ll = type.getAnnotation(LogLevel.class);
|
||||
this.logLevel = ll == null ? Integer.MIN_VALUE : Level.parse(ll.value()).intValue();
|
||||
org.redkale.util.LogLevel ll2 = type.getAnnotation(org.redkale.util.LogLevel.class);
|
||||
String levelName = ll != null ? ll.value() : (ll2 != null ? ll2.value() : null);
|
||||
this.logLevel = levelName == null ? Integer.MIN_VALUE : Level.parse(levelName).intValue();
|
||||
Map<Integer, HashSet<String>> logmap = new HashMap<>();
|
||||
for (LogExcludeLevel lel : type.getAnnotationsByType(LogExcludeLevel.class)) {
|
||||
for (String onelevel : lel.levels()) {
|
||||
@@ -255,6 +261,19 @@ public final class EntityInfo<T> {
|
||||
}
|
||||
}
|
||||
}
|
||||
for (org.redkale.util.LogExcludeLevel lel : type.getAnnotationsByType(org.redkale.util.LogExcludeLevel.class)) {
|
||||
for (String onelevel : lel.levels()) {
|
||||
int level = Level.parse(onelevel).intValue();
|
||||
HashSet<String> set = logmap.get(level);
|
||||
if (set == null) {
|
||||
set = new HashSet<>();
|
||||
logmap.put(level, set);
|
||||
}
|
||||
for (String key : lel.keys()) {
|
||||
set.add(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (logmap.isEmpty()) {
|
||||
this.excludeLogLevels = null;
|
||||
} else {
|
||||
@@ -262,24 +281,37 @@ public final class EntityInfo<T> {
|
||||
logmap.forEach((l, set) -> excludeLogLevels.put(l, set.toArray(new String[set.size()])));
|
||||
}
|
||||
//---------------------------------------------
|
||||
Table t = type.getAnnotation(Table.class);
|
||||
if (type.getAnnotation(VirtualEntity.class) != null || (source == null || "memory".equalsIgnoreCase(source.getType()))) {
|
||||
org.redkale.persistence.Table t1 = type.getAnnotation(org.redkale.persistence.Table.class);
|
||||
javax.persistence.Table t2 = type.getAnnotation(javax.persistence.Table.class);
|
||||
final String tableName0 = t1 != null ? t1.name() : (t2 != null ? t2.name() : null);
|
||||
final String tableCcatalog0 = t1 != null ? t1.catalog() : (t2 != null ? t2.catalog() : null);
|
||||
|
||||
if (type.getAnnotation(org.redkale.persistence.VirtualEntity.class) != null
|
||||
|| type.getAnnotation(org.redkale.source.VirtualEntity.class) != null
|
||||
|| (source == null || "memory".equalsIgnoreCase(source.getType()))) {
|
||||
this.table = null;
|
||||
BiFunction<DataSource, EntityInfo, CompletableFuture<List>> loader = null;
|
||||
try {
|
||||
VirtualEntity ve = type.getAnnotation(VirtualEntity.class);
|
||||
org.redkale.persistence.VirtualEntity ve = type.getAnnotation(org.redkale.persistence.VirtualEntity.class);
|
||||
if (ve != null) {
|
||||
loader = ve.loader().getDeclaredConstructor().newInstance();
|
||||
RedkaleClassLoader.putReflectionDeclaredConstructors(ve.loader(), ve.loader().getName());
|
||||
}
|
||||
org.redkale.source.VirtualEntity ve2 = type.getAnnotation(org.redkale.source.VirtualEntity.class);
|
||||
if (ve2 != null) {
|
||||
loader = ve2.loader().getDeclaredConstructor().newInstance();
|
||||
RedkaleClassLoader.putReflectionDeclaredConstructors(ve2.loader(), ve2.loader().getName());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.log(Level.SEVERE, type + " init @VirtualEntity.loader error", e);
|
||||
}
|
||||
this.fullloader = loader;
|
||||
} else {
|
||||
this.fullloader = fullloader;
|
||||
if (t != null && !t.name().isEmpty() && t.name().indexOf('.') >= 0) throw new RuntimeException(type + " have illegal table.name on @Table");
|
||||
this.table = (t == null) ? type.getSimpleName().toLowerCase() : (t.catalog().isEmpty()) ? (t.name().isEmpty() ? type.getSimpleName().toLowerCase() : t.name()) : (t.catalog() + '.' + (t.name().isEmpty() ? type.getSimpleName().toLowerCase() : t.name()));
|
||||
if (tableName0 != null && !tableName0.isEmpty() && tableName0.indexOf('.') >= 0) {
|
||||
throw new RuntimeException(type + " have illegal table.name on @Table");
|
||||
}
|
||||
this.table = (tableCcatalog0 == null) ? type.getSimpleName().toLowerCase() : (tableCcatalog0.isEmpty()) ? (tableName0.isEmpty() ? type.getSimpleName().toLowerCase() : tableName0) : (tableCcatalog0 + '.' + (tableName0.isEmpty() ? type.getSimpleName().toLowerCase() : tableName0));
|
||||
}
|
||||
DistributeTable dt = type.getAnnotation(DistributeTable.class);
|
||||
DistributeTableStrategy dts = null;
|
||||
@@ -293,16 +325,24 @@ public final class EntityInfo<T> {
|
||||
|
||||
this.arrayer = Creator.arrayFunction(type);
|
||||
this.creator = Creator.create(type);
|
||||
ConstructorParameters cp = null;
|
||||
String[] cps = null;
|
||||
try {
|
||||
Method cm = this.creator.getClass().getMethod("create", Object[].class);
|
||||
cp = cm.getAnnotation(ConstructorParameters.class);
|
||||
RedkaleClassLoader.putReflectionPublicMethods(this.creator.getClass().getName());
|
||||
RedkaleClassLoader.putReflectionMethod(this.creator.getClass().getName(), cm);
|
||||
ConstructorParameters cp = cm.getAnnotation(ConstructorParameters.class);
|
||||
if (cp != null && cp.value().length > 0) {
|
||||
cps = cp.value();
|
||||
} else {
|
||||
org.redkale.util.ConstructorParameters cp2 = cm.getAnnotation(org.redkale.util.ConstructorParameters.class);
|
||||
if (cp2 != null && cp2.value().length > 0) {
|
||||
cps = cp2.value();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.log(Level.SEVERE, type + " cannot find ConstructorParameters Creator", e);
|
||||
}
|
||||
this.constructorParameters = (cp == null || cp.value().length < 1) ? null : cp.value();
|
||||
this.constructorParameters = cps;
|
||||
Attribute idAttr0 = null;
|
||||
Map<String, String> aliasmap0 = null;
|
||||
Class cltmp = type;
|
||||
@@ -322,6 +362,7 @@ public final class EntityInfo<T> {
|
||||
if (Modifier.isStatic(field.getModifiers())) continue;
|
||||
if (Modifier.isFinal(field.getModifiers())) continue;
|
||||
if (field.getAnnotation(Transient.class) != null) continue;
|
||||
if (field.getAnnotation(javax.persistence.Transient.class) != null) continue;
|
||||
if (fields.contains(field.getName())) continue;
|
||||
final String fieldname = field.getName();
|
||||
final Column col = field.getAnnotation(Column.class);
|
||||
@@ -336,7 +377,9 @@ public final class EntityInfo<T> {
|
||||
} catch (RuntimeException e) {
|
||||
continue;
|
||||
}
|
||||
if (field.getAnnotation(javax.persistence.Id.class) != null && idAttr0 == null) {
|
||||
|
||||
boolean idFlag = field.getAnnotation(Id.class) != null || field.getAnnotation(javax.persistence.Id.class) != null;
|
||||
if (idFlag && idAttr0 == null) {
|
||||
idAttr0 = attr;
|
||||
insertcols.add(sqlfield);
|
||||
insertattrs.add(attr);
|
||||
@@ -355,14 +398,14 @@ public final class EntityInfo<T> {
|
||||
notNullColumns.add(fieldname);
|
||||
}
|
||||
}
|
||||
ddl.add(new EntityColumn(field.getAnnotation(javax.persistence.Id.class) != null, col, attr.field(), attr.type(), field.getAnnotation(Comment.class)));
|
||||
ddl.add(new EntityColumn(idFlag, col, attr.field(), attr.type(), field.getAnnotation(Comment.class)));
|
||||
querycols.add(sqlfield);
|
||||
queryattrs.add(attr);
|
||||
fields.add(fieldname);
|
||||
attributeMap.put(fieldname, attr);
|
||||
}
|
||||
} while ((cltmp = cltmp.getSuperclass()) != Object.class);
|
||||
if (idAttr0 == null) throw new RuntimeException(type.getName() + " have no primary column by @javax.persistence.Id");
|
||||
if (idAttr0 == null) throw new RuntimeException(type.getName() + " have no primary column by @org.redkale.persistence.Id");
|
||||
cltmp = type;
|
||||
JsonConvert convert = DEFAULT_JSON_CONVERT;
|
||||
do {
|
||||
@@ -536,9 +579,10 @@ public final class EntityInfo<T> {
|
||||
this.updateQuestionPrepareCaseSQLs = null;
|
||||
}
|
||||
//----------------cache--------------
|
||||
Cacheable c = type.getAnnotation(Cacheable.class);
|
||||
if (this.table == null || (!cacheForbidden && c != null && c.value())) {
|
||||
this.cache = new EntityCache<>(this, c);
|
||||
Cacheable c1 = type.getAnnotation(Cacheable.class);
|
||||
javax.persistence.Cacheable c2 = type.getAnnotation(javax.persistence.Cacheable.class);
|
||||
if (this.table == null || (!cacheForbidden && c1 != null && c1.value()) || (!cacheForbidden && c2 != null && c2.value())) {
|
||||
this.cache = new EntityCache<>(this, c1 == null ? c2.interval() : c1.interval(), c1 == null ? c2.direct() : c1.direct());
|
||||
} else {
|
||||
this.cache = null;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
package org.redkale.source;
|
||||
|
||||
import org.redkale.util.Bean;
|
||||
import org.redkale.annotation.Bean;
|
||||
|
||||
/**
|
||||
* FilterBean用于过滤条件, 所有的FilterBean都必须可以转换成FilterNode <br>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
package org.redkale.source;
|
||||
|
||||
import java.util.Objects;
|
||||
import org.redkale.util.ConstructorParameters;
|
||||
import org.redkale.annotation.ConstructorParameters;
|
||||
|
||||
/**
|
||||
* FilterKey主要用于自身字段间的表达式, 如: a.recordid = a.parentid , a.parentid就需要FilterKey来表示 new FilterKey("parentid")
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.io.Serializable;
|
||||
import java.lang.reflect.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import javax.persistence.Transient;
|
||||
import org.redkale.persistence.Transient;
|
||||
import static org.redkale.source.FilterExpress.*;
|
||||
import org.redkale.util.*;
|
||||
|
||||
@@ -186,6 +186,7 @@ public final class FilterNodeBean<T extends FilterBean> implements Comparable<Fi
|
||||
if (Modifier.isStatic(field.getModifiers())) continue;
|
||||
if (fields.contains(field.getName())) continue;
|
||||
if (field.getAnnotation(Transient.class) != null) continue;
|
||||
if (field.getAnnotation(javax.persistence.Transient.class) != null) continue;
|
||||
if (field.getAnnotation(FilterColumn.class) != null && field.getAnnotation(FilterColumn.class).ignore()) continue;
|
||||
|
||||
final boolean pubmod = Modifier.isPublic(field.getModifiers());
|
||||
|
||||
@@ -8,7 +8,7 @@ package org.redkale.source;
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
import org.redkale.convert.ConvertColumn;
|
||||
import org.redkale.util.Comment;
|
||||
import org.redkale.annotation.Comment;
|
||||
|
||||
/**
|
||||
* 翻页对象, offset从0开始, limit必须大于0
|
||||
|
||||
@@ -7,7 +7,7 @@ package org.redkale.source;
|
||||
|
||||
import org.redkale.convert.ConvertColumn;
|
||||
import org.redkale.convert.json.JsonConvert;
|
||||
import org.redkale.util.Bean;
|
||||
import org.redkale.annotation.Bean;
|
||||
|
||||
/**
|
||||
* 翻页对象与过滤条件Bean的组合对象
|
||||
|
||||
@@ -5,10 +5,9 @@
|
||||
*/
|
||||
package org.redkale.source;
|
||||
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.Retention;
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import static java.lang.annotation.ElementType.FIELD;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -19,7 +18,10 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
*
|
||||
* @author zhangjx
|
||||
* @since 2.4.0
|
||||
*
|
||||
* @deprecated replaced by org.redkale.persistence.SearchColumn
|
||||
*/
|
||||
@Deprecated
|
||||
@Target({FIELD})
|
||||
@Retention(RUNTIME)
|
||||
public @interface SearchColumn {
|
||||
|
||||
@@ -12,7 +12,7 @@ import org.redkale.convert.json.JsonConvert;
|
||||
/**
|
||||
* SearchQuery用于构建搜索过滤条件<br>
|
||||
*
|
||||
* 不被标记为@javax.persistence.Transient 的字段均视为过滤条件 <br>
|
||||
* 不被标记为@org.redkale.persistence.Transient 的字段均视为过滤条件 <br>
|
||||
*
|
||||
* <p>
|
||||
* 详情见: https://redkale.org
|
||||
|
||||
@@ -8,9 +8,9 @@ package org.redkale.source;
|
||||
import static java.lang.annotation.ElementType.TYPE;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
import java.lang.annotation.*;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.*;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
/**
|
||||
* VirtualEntity表示虚拟的数据实体类, 通常Entity都会映射到数据库中的某个表,而标记为@VirtualEntity的Entity类只存在EntityCache中
|
||||
@@ -19,7 +19,9 @@ import java.util.function.*;
|
||||
* 详情见: https://redkale.org
|
||||
*
|
||||
* @author zhangjx
|
||||
* @deprecated replaced by org.redkale.persistence.VirtualEntity
|
||||
*/
|
||||
@Deprecated
|
||||
@Documented
|
||||
@Target(TYPE)
|
||||
@Retention(RUNTIME)
|
||||
|
||||
@@ -9,6 +9,8 @@ import java.io.*;
|
||||
import java.nio.charset.*;
|
||||
import java.util.*;
|
||||
import java.util.function.*;
|
||||
|
||||
import org.redkale.annotation.ConstructorParameters;
|
||||
import org.redkale.convert.ConvertDisabled;
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,7 +16,9 @@ import java.lang.annotation.*;
|
||||
*
|
||||
* <p> 详情见: https://redkale.org
|
||||
* @author zhangjx
|
||||
* @deprecated replaced by org.redkale.annotation.AutoLoad
|
||||
*/
|
||||
@Deprecated
|
||||
@Documented
|
||||
@Target({TYPE})
|
||||
@Retention(RUNTIME)
|
||||
|
||||
@@ -14,6 +14,7 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
*
|
||||
* @since 2.5.0
|
||||
*/
|
||||
@Deprecated
|
||||
@Inherited
|
||||
@Documented
|
||||
@Target(TYPE)
|
||||
|
||||
@@ -19,6 +19,7 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
@Deprecated
|
||||
@Inherited
|
||||
@Documented
|
||||
@Target({METHOD})
|
||||
|
||||
@@ -17,6 +17,7 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
*
|
||||
* @author zhangjx
|
||||
*/
|
||||
@Deprecated
|
||||
@Inherited
|
||||
@Documented
|
||||
@Target({TYPE, METHOD, FIELD, PARAMETER, CONSTRUCTOR, LOCAL_VARIABLE, ANNOTATION_TYPE, TYPE_PARAMETER})
|
||||
|
||||
@@ -5,9 +5,10 @@
|
||||
*/
|
||||
package org.redkale.util;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
import java.lang.annotation.*;
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
|
||||
/**
|
||||
* 类似java.beans.ConstructorProperties, 必须配合Creator使用
|
||||
@@ -16,7 +17,9 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
* 详情见: https://redkale.org
|
||||
*
|
||||
* @author zhangjx
|
||||
* @deprecated replaced by org.redkale.annotation.ConstructorParameters
|
||||
*/
|
||||
@Deprecated
|
||||
@Documented
|
||||
@Target({METHOD, CONSTRUCTOR})
|
||||
@Retention(RUNTIME)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user