Skip to content

Commit

Permalink
v3.0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
justlive1 committed Sep 10, 2021
1 parent a2b0b57 commit 68ceff7
Show file tree
Hide file tree
Showing 71 changed files with 754 additions and 665 deletions.
6 changes: 6 additions & 0 deletions oxygen-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
<artifactId>cglib-nodep</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -24,36 +24,36 @@
@UtilityClass
public class CoreConfigKeys {

public ConfigKey CACHE_CLASS = new ConfigKey("oxygen.cache.class");
public final ConfigKey CACHE_CLASS = new ConfigKey("oxygen.cache.class");

public ConfigKey CLASS_SCAN = new ConfigKey("oxygen.class.scan");
public final ConfigKey CLASS_SCAN = new ConfigKey("oxygen.class.scan");

public ConfigKey AOP_ENABLED = new ConfigKey("oxygen.aop.enabled", "true");
public final ConfigKey AOP_ENABLED = new ConfigKey("oxygen.aop.enabled", "true");

public ConfigKey COMPILER_OPTIONS = new ConfigKey("oxygen.compiler.options");
public final ConfigKey COMPILER_OPTIONS = new ConfigKey("oxygen.compiler.options");

public ConfigKey CONFIG_OVERRIDE_PATH = new ConfigKey("oxygen.config.override.path");
public final ConfigKey CONFIG_OVERRIDE_PATH = new ConfigKey("oxygen.config.override.path");

public ConfigKey JOB_THREAD_NAME_FORMAT = new ConfigKey("oxygen.job.threadNameFormat", "jobs-%d");
public ConfigKey JOB_CORE_POOL_SIZE = new ConfigKey("oxygen.job.corePoolSize", "10");

public ConfigKey I18N_PATH = new ConfigKey("oxygen.i18n.path", "classpath:message/*.properties");
public ConfigKey I18N_LANGUAGE = new ConfigKey("oxygen.i18n.language", "zh");
public ConfigKey I18N_COUNTRY = new ConfigKey("oxygen.i18n.country", "CN");
public ConfigKey I18N_PARAM_KEY = new ConfigKey("oxygen.i18n.param.key", "locale");
public ConfigKey I18N_SESSION_KEY = new ConfigKey("oxygen.i18n.session.key",
public final ConfigKey I18N_PATH = new ConfigKey("oxygen.i18n.path",
"classpath:message/*.properties");
public final ConfigKey I18N_LANGUAGE = new ConfigKey("oxygen.i18n.language", "zh");
public final ConfigKey I18N_COUNTRY = new ConfigKey("oxygen.i18n.country", "CN");
public final ConfigKey I18N_PARAM_KEY = new ConfigKey("oxygen.i18n.param.key", "locale");
public final ConfigKey I18N_SESSION_KEY = new ConfigKey("oxygen.i18n.session.key",
"I18N_SESSION_LOCALE");

public ConfigKey TEMP_DIR = new ConfigKey("oxygen.temp.dir");
public final ConfigKey TEMP_DIR = new ConfigKey("oxygen.temp.dir");

public ConfigKey THREAD_POOL_SIZE = new ConfigKey("oxygen.threadPool.size", "10");
public ConfigKey THREAD_POOL_QUEUE = new ConfigKey("oxygen.threadPool.queue", "100000");
public final ConfigKey THREAD_POOL_SIZE = new ConfigKey("oxygen.threadPool.size", "10");
public final ConfigKey THREAD_POOL_QUEUE = new ConfigKey("oxygen.threadPool.queue", "100000");

public ConfigKey WHEEL_TIMER_WHEEL_SIZE = new ConfigKey("oxygen.wheelTimer.wheelSize", "60");
public ConfigKey WHEEL_TIMER_POOL_SIZE = new ConfigKey("oxygen.wheelTimer.poolSize", "10");
public ConfigKey WHEEL_TIMER_TIMEOUT = new ConfigKey("oxygen.wheelTimer.timeout", "100");
public final ConfigKey WHEEL_TIMER_WHEEL_SIZE = new ConfigKey("oxygen.wheelTimer.wheelSize",
"60");
public final ConfigKey WHEEL_TIMER_POOL_SIZE = new ConfigKey("oxygen.wheelTimer.poolSize", "10");
public final ConfigKey WHEEL_TIMER_TIMEOUT = new ConfigKey("oxygen.wheelTimer.timeout", "100");

public ConfigKey RESIDENT_POOL_MAX_SIZE = new ConfigKey("oxygen.residentPool.maxSize", "100");
public final ConfigKey RESIDENT_POOL_MAX_SIZE = new ConfigKey("oxygen.residentPool.maxSize",
"100");

public ConfigKey AIO_USE_FUTURE = new ConfigKey("oxygen.aio.future", "false");
public final ConfigKey AIO_USE_FUTURE = new ConfigKey("oxygen.aio.future", "false");
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import vip.justlive.oxygen.core.util.base.Strings;

/**
* aspect
Expand Down Expand Up @@ -57,7 +56,7 @@
*
* <br>
*/
String method() default Strings.EMPTY;
String method() default "";

/**
* 优先级,越小优先级越大
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
*/
package vip.justlive.oxygen.core.util.base;


import java.lang.annotation.Annotation;
import java.lang.reflect.Array;
import java.lang.reflect.Constructor;
Expand Down Expand Up @@ -65,8 +64,8 @@ public class ClassUtils {
public final String NON_PRIMITIVE_ARRAY_PREFIX = "[L";

private final boolean HAS_FAST_METHOD = ClassUtils.isPresent("net.sf.cglib.reflect.FastMethod");
private final boolean HAS_CGLIB_PROXY = ClassUtils
.isPresent("net.sf.cglib.proxy.MethodInterceptor");
private final boolean HAS_CGLIB_PROXY =
ClassUtils.isPresent("net.sf.cglib.proxy.MethodInterceptor");

private final Map<Class<?>, Class<?>> PRIMITIVE_TO_WRAPPER_TYPE;
private final Map<Class<?>, Class<?>> WRAPPER_TO_PRIMITIVE_TYPE;
Expand All @@ -89,8 +88,11 @@ public class ClassUtils {
WRAPPER_TO_PRIMITIVE_TYPE = Collections.unmodifiableMap(wrapToPrim);
}

private void add(Map<Class<?>, Class<?>> forward, Map<Class<?>, Class<?>> backward,
Class<?> key, Class<?> value) {
private void add(
Map<Class<?>, Class<?>> forward,
Map<Class<?>, Class<?>> backward,
Class<?> key,
Class<?> value) {
forward.put(key, value);
backward.put(value, key);
}
Expand All @@ -117,29 +119,29 @@ public Set<Class<?>> allWrapperTypes() {
* 获取包装类型
*
* @param type 类型
* @param <T> 泛型
* @param <T> 泛型
* @return 包装类
*/
public <T> Class<T> wrap(Class<T> type) {
MoreObjects.notNull(type);
// cast is safe: long.class and Long.class are both of type Class<Long>
@SuppressWarnings("unchecked") Class<T> wrapped = (Class<T>) PRIMITIVE_TO_WRAPPER_TYPE
.get(type);
@SuppressWarnings("unchecked")
Class<T> wrapped = (Class<T>) PRIMITIVE_TO_WRAPPER_TYPE.get(type);
return (wrapped == null) ? type : wrapped;
}

/**
* 获取包装类的基本类型
*
* @param type 类型
* @param <T> 泛型
* @param <T> 泛型
* @return 基本类型
*/
public <T> Class<T> unwrap(Class<T> type) {
MoreObjects.notNull(type);
// cast is safe: long.class and Long.class are both of type Class<Long>
@SuppressWarnings("unchecked") Class<T> unwrapped = (Class<T>) WRAPPER_TO_PRIMITIVE_TYPE
.get(type);
@SuppressWarnings("unchecked")
Class<T> unwrapped = (Class<T>) WRAPPER_TO_PRIMITIVE_TYPE.get(type);
return (unwrapped == null) ? type : unwrapped;
}

Expand All @@ -150,8 +152,8 @@ public <T> Class<T> unwrap(Class<T> type) {
* @return true则为基本类型或包装类
*/
public boolean isPrimitive(Class<?> type) {
return PRIMITIVE_TO_WRAPPER_TYPE.containsKey(type) || WRAPPER_TO_PRIMITIVE_TYPE
.containsKey(type);
return PRIMITIVE_TO_WRAPPER_TYPE.containsKey(type)
|| WRAPPER_TO_PRIMITIVE_TYPE.containsKey(type);
}

/**
Expand Down Expand Up @@ -194,7 +196,7 @@ public Class<?> forName(String name) {
/**
* 获取Class实例
*
* @param name 类名
* @param name 类名
* @param classLoader 类加载器
* @return class
*/
Expand Down Expand Up @@ -232,7 +234,8 @@ public Class<?> forName(String name, ClassLoader classLoader) {
String innerClassName =
name.substring(0, lastDotIndex) + Strings.DOLLAR + name.substring(lastDotIndex + 1);
try {
return (clToUse != null ? clToUse.loadClass(innerClassName)
return (clToUse != null
? clToUse.loadClass(innerClassName)
: Class.forName(innerClassName));
} catch (ClassNotFoundException ex2) {
// Swallow - let original exception get through
Expand All @@ -255,7 +258,7 @@ public boolean isPresent(String className) {
/**
* 类是否存在
*
* @param className 类名
* @param className 类名
* @param classLoader 类加载器
* @return true为存在
*/
Expand Down Expand Up @@ -335,12 +338,12 @@ public String getClassName(Class<?> clazz) {
/**
* 获取类下被注解的方法
*
* @param clazz 类
* @param clazz
* @param annotation 注解
* @return methods
*/
public Set<Method> getMethodsAnnotatedWith(Class<?> clazz,
Class<? extends Annotation> annotation) {
public Set<Method> getMethodsAnnotatedWith(
Class<?> clazz, Class<? extends Annotation> annotation) {
Set<Method> methods = new HashSet<>();
Class<?> actualClass = getActualClass(clazz);
if (actualClass == null) {
Expand All @@ -358,8 +361,8 @@ public Set<Method> getMethodsAnnotatedWith(Class<?> clazz,
* 执行方法
*
* @param method 方法
* @param bean 对象
* @param args 参数
* @param bean 对象
* @param args 参数
* @return 结果
*/
public Object methodInvoke(Method method, Object bean, Object... args) {
Expand All @@ -373,7 +376,6 @@ public Object methodInvoke(Method method, Object bean, Object... args) {
}
}


/**
* 获取类所有方法
*
Expand All @@ -394,7 +396,7 @@ public Set<Method> getAllMethods(Class<?> clazz) {
* 获取构造参数类型
*
* @param clazz 类
* @param args 参数
* @param args 参数
* @return class[]
*/
public Class<?>[] getConstructorArgsTypes(Class<?> clazz, Object... args) {
Expand All @@ -420,24 +422,24 @@ public Class<?>[] getConstructorArgsTypes(Class<?> clazz, Object... args) {
/**
* 获取被注解的构造方法
*
* @param clazz 类
* @param clazz
* @param annotation 注解
* @return Constructor
*/
public Constructor<?> getConstructorAnnotatedWith(Class<?> clazz,
Class<? extends Annotation> annotation) {
public Constructor<?> getConstructorAnnotatedWith(
Class<?> clazz, Class<? extends Annotation> annotation) {
return getConstructorAnnotatedWith(clazz.getConstructors(), annotation);
}

/**
* 获取被注解的构造方法
*
* @param constructors 构造方法
* @param annotation 注解
* @param annotation 注解
* @return Constructor
*/
public Constructor<?> getConstructorAnnotatedWith(Constructor<?>[] constructors,
Class<? extends Annotation> annotation) {
public Constructor<?> getConstructorAnnotatedWith(
Constructor<?>[] constructors, Class<? extends Annotation> annotation) {
for (Constructor<?> constructor : constructors) {
if (constructor.isAnnotationPresent(annotation)) {
return constructor;
Expand All @@ -459,21 +461,20 @@ public boolean isInJavaLangAnnotationPackage(Class<? extends Annotation> annotat
/**
* 是否存在注解
*
* @param clazz 类型
* @param clazz 类型
* @param annotation 注解
* @return true表示存在注解
*/
public boolean isAnnotationPresent(Class<?> clazz,
Class<? extends Annotation> annotation) {
public boolean isAnnotationPresent(Class<?> clazz, Class<? extends Annotation> annotation) {
return getAnnotation(clazz, annotation) != null;
}

/**
* 获取注解 支持派生注解
*
* @param clazz 类型
* @param clazz 类型
* @param annotation 注解
* @param <A> 泛型
* @param <A> 泛型
* @return 注解
*/
@SuppressWarnings("unchecked")
Expand Down Expand Up @@ -522,7 +523,7 @@ public Field[] getAllDeclaredFields(Class<?> clazz) {
/**
* 根据属性名,在当前Class类实例的所有Field对象中(包括父类的Field)检索对应的属性值
*
* @param clazz Class类实例
* @param clazz Class类实例
* @param propertyName 属性名
* @return Field 对象
*/
Expand All @@ -539,7 +540,7 @@ public Field getDeclaredField(Class<?> clazz, String propertyName) {
/**
* 根据属性名来获取属性的值
*
* @param object 需要得到属性值的对象
* @param object 需要得到属性值的对象
* @param propertyName 属性名
* @return Object 属性值
*/
Expand All @@ -552,7 +553,7 @@ public Object getValue(Object object, String propertyName) {
* 获取属性值
*
* @param object 需要得到属性值的对象
* @param field 字段
* @param field 字段
* @return Object 属性值
*/
public Object getValue(Object object, Field field) {
Expand All @@ -573,8 +574,8 @@ public Object getValue(Object object, Field field) {
* 根据field设置值
*
* @param object 目标对象
* @param field 属性
* @param value 值
* @param field 属性
* @param value
*/
public void setValue(Object object, Field field, Object value) {
try {
Expand All @@ -590,7 +591,7 @@ public void setValue(Object object, Field field, Object value) {
/**
* 实例化一个类型为clazz的对象。
*
* @param <T> 实例化对象类型
* @param <T> 实例化对象类型
* @param clazz 实例化类型
* @return 实例化的对象
*/
Expand Down Expand Up @@ -655,7 +656,7 @@ public boolean isJavaInternalType(Class<?> type) {
/**
* 生成invoker
*
* @param bean 实例
* @param bean 实例
* @param method 方法
* @return Invoker
*/
Expand All @@ -672,7 +673,7 @@ public Invoker generateInvoker(Object bean, Method method) {
* @return BeanProxy
*/
public BeanProxy generateBeanProxy() {
if (CoreConfigKeys.AOP_ENABLED.castValue(boolean.class)) {
if (Boolean.TRUE.equals(CoreConfigKeys.AOP_ENABLED.castValue(boolean.class))) {
List<BeanProxy> list = ServiceLoaderUtils.loadServices(BeanProxy.class);
if (!list.isEmpty()) {
Collections.sort(list);
Expand All @@ -691,11 +692,12 @@ public BeanProxy generateBeanProxy() {
return new SimpleBeanProxy();
}

private void recursivelyCollectAnnotations(Set<Annotation> visited,
Annotation annotation) {
private void recursivelyCollectAnnotations(Set<Annotation> visited, Annotation annotation) {
Class<? extends Annotation> annotationType = annotation.annotationType();
if (annotationType == null || isInJavaLangAnnotationPackage(annotationType) || !Modifier
.isPublic(annotationType.getModifiers()) || !visited.add(annotation)) {
if (annotationType == null
|| isInJavaLangAnnotationPackage(annotationType)
|| !Modifier.isPublic(annotationType.getModifiers())
|| !visited.add(annotation)) {
return;
}

Expand Down
Loading

0 comments on commit 68ceff7

Please sign in to comment.