This commit is contained in:
wentch
2015-12-14 11:28:27 +08:00
parent a920d6c851
commit 32c44e308a
10 changed files with 63 additions and 40 deletions

View File

@@ -420,7 +420,7 @@ public final class Application {
NodeServer server = null;
if ("SNCP".equals(protocol)) {
server = new NodeSncpServer(Application.this, serconf);
} else if ("HTTP".equals(protocol) || "HTTPS".equals(protocol)) {
} else if ("HTTP".equals(protocol)) {
server = new NodeHttpServer(Application.this, serconf);
} else {
if (!inited.get()) {
@@ -435,7 +435,7 @@ public final class Application {
NodeProtocol pros = type.getAnnotation(NodeProtocol.class);
for (String p : pros.value()) {
p = p.toUpperCase();
if ("SNCP".equals(p) || "HTTP".equals(p) || "HTTPS".equals(p)) continue;
if ("SNCP".equals(p) || "HTTP".equals(p)) continue;
final Class<? extends NodeServer> old = nodeClasses.get(p);
if (old != null && old != type) throw new RuntimeException("Protocol(" + p + ") had NodeServer-Class(" + old.getName() + ") but repeat NodeServer-Class(" + type.getName() + ")");
nodeClasses.put(p, type);

View File

@@ -27,7 +27,7 @@ import org.redkale.util.*;
*
* @author zhangjx
*/
@NodeProtocol({"HTTP", "HTTPS"})
@NodeProtocol({"HTTP"})
public final class NodeHttpServer extends NodeServer {
private final HttpServer httpServer;

View File

@@ -246,7 +246,6 @@ public abstract class NodeServer {
if (Modifier.isFinal(type.getModifiers())) continue;
if (!Modifier.isPublic(type.getModifiers())) continue;
if (Modifier.isAbstract(type.getModifiers())) continue;
if (type.getAnnotation(Ignore.class) != null) continue;
if (!isSNCP() && factory.find(entry.getName(), type) != null) continue;
final Set<InetSocketAddress> sameGroupAddrs = new LinkedHashSet<>();
final Map<String, Set<InetSocketAddress>> diffGroupAddrs = new HashMap<>();

View File

@@ -11,7 +11,11 @@ import jdk.internal.org.objectweb.asm.Type;
/**
* 该类功能是动态映射一个Data类中成员对应的getter、setter方法 代替低效的反射实现方式。
* 映射Field时field要么是public非final要么存在对应的getter、setter方法。
* 映射Field时field必须满足以下条件之一:
* 1、field属性是public且非final
* 2、至少存在对应的getter、setter方法中的一个
* 当不存在getter方法时get操作规定返回null
* 当不存在setter方法时set操作为空方法
*
* @author zhangjx
* @param <T>
@@ -78,19 +82,58 @@ public interface Attribute<T, F> {
public static <T, F> Attribute<T, F> create(Class<T> clazz, final String fieldname, final java.lang.reflect.Field field) {
return create(clazz, fieldname, field, null, null);
}
/**
* getter、setter不能全为null
*
* @param <T>
* @param <F>
* @param getter
* @param setter
* @return
*/
public static <T, F> Attribute<T, F> create(final Method getter, final Method setter) {
return create((Class) (getter == null ? setter.getDeclaringClass() : getter.getDeclaringClass()), null, null, getter, setter);
}
/**
* getter、setter不能全为null
*
* @param <T>
* @param <F>
* @param clazz
* @param getter
* @param setter
* @return
*/
public static <T, F> Attribute<T, F> create(Class<T> clazz, final Method getter, final Method setter) {
return create(clazz, null, null, getter, setter);
}
/**
* getter、setter不能全为null
*
* @param <T>
* @param <F>
* @param clazz
* @param fieldalias
* @param getter
* @param setter
* @return
*/
public static <T, F> Attribute<T, F> create(Class<T> clazz, final String fieldalias, final Method getter, final Method setter) {
return create(clazz, fieldalias, null, getter, setter);
}
/**
* field、getter、setter不能全为null
* @param <T>
* @param <F>
* @param clazz
* @param fieldalias0
* @param field0
* @param getter0
* @param setter0
* @return
*/
@SuppressWarnings("unchecked")
public static <T, F> Attribute<T, F> create(final Class<T> clazz, String fieldalias0, final Field field0, Method getter0, Method setter0) {
if (fieldalias0 != null && fieldalias0.isEmpty()) fieldalias0 = null;

View File

@@ -10,9 +10,10 @@ import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
* 自动加载。 使用场景有两种
* 一、 扫描时自动加载。 系统在启动时会扫描classpath下Service和Servlet的实现类默认情况下会加载所有的实现类 只有当标记为@AutoLoad(false)时才会被忽略。 没标记的与标记为@AutoLoad(true)是等价的。
* 二、 Entity类数据加载。 DataSource初始化某个标记为@javax.persistence.Cacheable的Entity类时如果该类存在@AutoLoad时则需要将Entity类对应的表数据全量加载进缓存中。
* 自动加载。 使用场景:
* 1、被标记为@AutoLoad(false)的Service类不会被自动加载
* 2、被标记为@AutoLoad(false)的Servlet类不会被自动加载
* 3、被标记为@AutoLoad且同时被标记为@javax.persistence.Cacheable的Entity类在被DataSource初始化时需要将Entity类对应的表数据全量加载进缓存中。
*
* @author zhangjx
*/

View File

@@ -12,7 +12,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
import jdk.internal.org.objectweb.asm.Type;
/**
* 实现一个类的构造方法。 代替低效的反射实现方式。
* 实现一个类的构造方法。 代替低效的反射实现方式。 不支持数组类
*
* @author zhangjx
* @param <T>

View File

@@ -6,6 +6,7 @@
package org.redkale.util;
/**
* 双long数据结构
*
* @author zhangjx
*/

View File

@@ -10,6 +10,11 @@ import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
* 用于忽略字段、方法或类。使用场景:
* 1、convert功能中被标记为@Ignore的字段或方法会被忽略
* 2、FilterBean中的被标记为@Ignore的字段会被忽略
* 3、被标记为@Ignore的Service类不会被自动加载
* 4、被标记为@Ignore的Servlet类不会被自动加载
*
* @author zhangjx
*/

View File

@@ -1,27 +0,0 @@
/*
* 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.util;
import java.util.*;
/**
* 便于操作的HashMap类
*
* @author zhangjx
*/
public class ObjectNode extends HashMap<String, Object> {
public static ObjectNode create(String key, Object value) {
ObjectNode node = new ObjectNode();
node.put(key, value);
return node;
}
public ObjectNode appand(String key, Object value) {
this.put(key, value);
return this;
}
}

View File

@@ -8,6 +8,7 @@ package org.redkale.util;
import java.util.*;
/**
* 页集合。 结构由一个total总数和一个List列表组合而成。
*
* @author zhangjx
* @param <T>