增加Nonnull、Nullable注解
This commit is contained in:
20
src/main/java/org/redkale/annotation/Nonnull.java
Normal file
20
src/main/java/org/redkale/annotation/Nonnull.java
Normal file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
*
|
||||
*/
|
||||
package org.redkale.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* 详情见: https://redkale.org
|
||||
*
|
||||
* @author zhangjx
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Nonnull {
|
||||
|
||||
}
|
||||
20
src/main/java/org/redkale/annotation/Nullable.java
Normal file
20
src/main/java/org/redkale/annotation/Nullable.java
Normal file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
*
|
||||
*/
|
||||
package org.redkale.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* 详情见: https://redkale.org
|
||||
*
|
||||
* @author zhangjx
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Nullable {
|
||||
|
||||
}
|
||||
@@ -10,8 +10,8 @@ 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.net.*;
|
||||
import java.nio.channels.*;
|
||||
import java.util.*;
|
||||
import org.redkale.annotation.*;
|
||||
import org.redkale.annotation.ResourceType;
|
||||
@@ -19,10 +19,10 @@ 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.Convert;
|
||||
import org.redkale.convert.*;
|
||||
import org.redkale.mq.*;
|
||||
import org.redkale.net.TransportFactory;
|
||||
import org.redkale.net.http.WebSocketNode;
|
||||
import org.redkale.net.*;
|
||||
import org.redkale.net.http.*;
|
||||
import org.redkale.net.sncp.SncpServiceInfo.SncpServiceAction;
|
||||
import org.redkale.service.*;
|
||||
import org.redkale.util.*;
|
||||
@@ -726,21 +726,23 @@ public abstract class Sncp {
|
||||
*
|
||||
* private AnyValue _redkale_conf;
|
||||
*
|
||||
* private OldSncpClient _redkale_client;
|
||||
* private SncpClient _redkale_client;
|
||||
*
|
||||
* private SncpServiceInfo _redkale_sncpInfo;
|
||||
*
|
||||
* @Override
|
||||
* public void createSomeThing(TestBean bean){
|
||||
* _redkale_client.remote(0, bean);
|
||||
* _redkale_client.remote(_redkale_sncpInfo, 0, bean);
|
||||
* }
|
||||
*
|
||||
* @Override
|
||||
* public String findSomeThing(){
|
||||
* return _redkale_client.remote(1);
|
||||
* return _redkale_client.remote(_redkale_sncpInfo, 1);
|
||||
* }
|
||||
*
|
||||
* @Override
|
||||
* public String updateSomeThing(String id){
|
||||
* return _redkale_client.remote(2, id);
|
||||
* return _redkale_client.remote(_redkale_sncpInfo, 2, id);
|
||||
* }
|
||||
* }
|
||||
* </pre></blockquote>
|
||||
|
||||
@@ -5,23 +5,23 @@
|
||||
*/
|
||||
package org.redkale.source;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.io.*;
|
||||
import java.math.*;
|
||||
import java.sql.SQLException;
|
||||
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.stream.Stream;
|
||||
import java.util.stream.*;
|
||||
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.persistence.Table;
|
||||
import org.redkale.service.Local;
|
||||
import org.redkale.net.*;
|
||||
import org.redkale.persistence.*;
|
||||
import org.redkale.service.*;
|
||||
import org.redkale.source.EntityInfo.EntityColumn;
|
||||
import org.redkale.util.*;
|
||||
|
||||
@@ -2528,7 +2528,18 @@ public abstract class AbstractDataSqlSource extends AbstractDataSource implement
|
||||
//----------------------------- find -----------------------------
|
||||
@Override
|
||||
public <T> T[] finds(Class<T> clazz, final SelectColumn selects, Serializable... pks) {
|
||||
return findsAsync(clazz, selects, pks).join();
|
||||
final EntityInfo<T> info = loadEntityInfo(clazz);
|
||||
if (pks == null || pks.length == 0) {
|
||||
return info.getArrayer().apply(0);
|
||||
}
|
||||
final EntityCache<T> cache = info.getCache();
|
||||
if (cache != null) {
|
||||
T[] rs = selects == null ? cache.finds(pks) : cache.finds(selects, pks);
|
||||
if (cache.isFullLoaded() || rs != null) {
|
||||
return rs;
|
||||
}
|
||||
}
|
||||
return findsDBAsync(info, selects, pks).join();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
*/
|
||||
package org.redkale.source;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.*;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.concurrent.locks.*;
|
||||
import java.util.function.*;
|
||||
import java.util.logging.*;
|
||||
import java.util.stream.*;
|
||||
@@ -128,6 +128,13 @@ public final class EntityCache<T> {
|
||||
});
|
||||
}
|
||||
|
||||
public void fullLoad() {
|
||||
CompletableFuture<List<T>> future = fullLoadAsync();
|
||||
if (future != null) {
|
||||
future.join();
|
||||
}
|
||||
}
|
||||
|
||||
public CompletableFuture<List<T>> fullLoadAsync() {
|
||||
if (this.fullloaded) {
|
||||
return this.loadFuture;
|
||||
@@ -213,6 +220,10 @@ public final class EntityCache<T> {
|
||||
return fullloaded;
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return map.size();
|
||||
}
|
||||
|
||||
public T find(Serializable pk) {
|
||||
if (pk == null) {
|
||||
return null;
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
*/
|
||||
package org.redkale.source;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.io.*;
|
||||
import java.lang.reflect.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.concurrent.locks.*;
|
||||
import java.util.function.*;
|
||||
import java.util.logging.*;
|
||||
import org.redkale.annotation.Comment;
|
||||
@@ -242,7 +242,7 @@ public final class EntityInfo<T> {
|
||||
if (fullloader == null) {
|
||||
throw new IllegalArgumentException(clazz.getName() + " auto loader is illegal");
|
||||
}
|
||||
rs.cache.fullLoadAsync();
|
||||
rs.cache.fullLoad();
|
||||
}
|
||||
return rs;
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user