ref[orm]: refactor orm

This commit is contained in:
godotg
2023-09-03 00:54:02 +08:00
parent 0435d0f9d6
commit 112d119d7c
38 changed files with 66 additions and 84 deletions
@@ -14,9 +14,9 @@ package com.zfoo.boot;
import com.zfoo.orm.OrmContext;
import com.zfoo.orm.accessor.MongodbAccessor;
import com.zfoo.orm.anno.GraalvmNativeEntityCache;
import com.zfoo.orm.config.OrmConfig;
import com.zfoo.orm.manager.OrmManager;
import com.zfoo.orm.model.anno.GraalvmNativeEntityCache;
import com.zfoo.orm.model.config.OrmConfig;
import com.zfoo.orm.query.MongodbQuery;
import com.zfoo.protocol.util.ClassUtils;
import org.slf4j.Logger;
@@ -17,7 +17,7 @@ import com.mongodb.client.MongoClient;
import com.zfoo.orm.accessor.IAccessor;
import com.zfoo.orm.manager.IOrmManager;
import com.zfoo.orm.manager.OrmManager;
import com.zfoo.orm.model.entity.IEntity;
import com.zfoo.orm.model.IEntity;
import com.zfoo.orm.query.IQuery;
import com.zfoo.orm.query.IQueryBuilder;
import com.zfoo.protocol.util.ReflectionUtils;
@@ -13,7 +13,7 @@
package com.zfoo.orm.accessor;
import com.zfoo.orm.model.entity.IEntity;
import com.zfoo.orm.model.IEntity;
import org.springframework.lang.Nullable;
import java.util.List;
@@ -17,7 +17,7 @@ import com.mongodb.client.model.BulkWriteOptions;
import com.mongodb.client.model.Filters;
import com.mongodb.client.model.ReplaceOneModel;
import com.zfoo.orm.OrmContext;
import com.zfoo.orm.model.entity.IEntity;
import com.zfoo.orm.model.IEntity;
import com.zfoo.protocol.collection.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -1,6 +1,5 @@
/*
* Copyright (C) 2020 The zfoo Authors
*
* Licensed 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
*
@@ -11,7 +10,7 @@
* See the License for the specific language governing permissions and limitations under the License.
*/
package com.zfoo.orm.model.anno;
package com.zfoo.orm.anno;
import org.springframework.aot.hint.annotation.Reflective;
@@ -1,6 +1,5 @@
/*
* Copyright (C) 2020 The zfoo Authors
*
* Licensed 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
*
@@ -11,7 +10,7 @@
* See the License for the specific language governing permissions and limitations under the License.
*/
package com.zfoo.orm.model.anno;
package com.zfoo.orm.anno;
import org.springframework.aot.hint.annotation.Reflective;
@@ -1,6 +1,5 @@
/*
* Copyright (C) 2020 The zfoo Authors
*
* Licensed 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
*
@@ -11,7 +10,7 @@
* See the License for the specific language governing permissions and limitations under the License.
*/
package com.zfoo.orm.model.anno;
package com.zfoo.orm.anno;
import org.springframework.aot.hint.annotation.Reflective;
@@ -25,5 +24,5 @@ import java.lang.annotation.*;
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD})
@Reflective
public @interface EntityCachesInjection {
public @interface EntityCacheAutowired {
}
@@ -1,6 +1,5 @@
/*
* Copyright (C) 2020 The zfoo Authors
*
* Licensed 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
*
@@ -11,7 +10,7 @@
* See the License for the specific language governing permissions and limitations under the License.
*/
package com.zfoo.orm.model.anno;
package com.zfoo.orm.anno;
import org.springframework.aot.hint.annotation.Reflective;
import org.springframework.stereotype.Component;
@@ -1,6 +1,5 @@
/*
* Copyright (C) 2020 The zfoo Authors
*
* Licensed 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
*
@@ -11,7 +10,7 @@
* See the License for the specific language governing permissions and limitations under the License.
*/
package com.zfoo.orm.model.anno;
package com.zfoo.orm.anno;
import org.springframework.aot.hint.annotation.Reflective;
@@ -1,6 +1,5 @@
/*
* Copyright (C) 2020 The zfoo Authors
*
* Licensed 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
*
@@ -11,7 +10,7 @@
* See the License for the specific language governing permissions and limitations under the License.
*/
package com.zfoo.orm.model.anno;
package com.zfoo.orm.anno;
import org.springframework.aot.hint.annotation.Reflective;
@@ -1,6 +1,5 @@
/*
* Copyright (C) 2020 The zfoo Authors
*
* Licensed 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
*
@@ -11,7 +10,7 @@
* See the License for the specific language governing permissions and limitations under the License.
*/
package com.zfoo.orm.model.anno;
package com.zfoo.orm.anno;
import org.springframework.aot.hint.annotation.Reflective;
@@ -1,6 +1,5 @@
/*
* Copyright (C) 2020 The zfoo Authors
*
* Licensed 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
*
@@ -11,7 +10,7 @@
* See the License for the specific language governing permissions and limitations under the License.
*/
package com.zfoo.orm.model.anno;
package com.zfoo.orm.anno;
import org.springframework.aot.hint.annotation.Reflective;
+3 -3
View File
@@ -18,16 +18,16 @@ import com.mongodb.client.model.BulkWriteOptions;
import com.mongodb.client.model.Filters;
import com.mongodb.client.model.ReplaceOneModel;
import com.zfoo.orm.OrmContext;
import com.zfoo.orm.model.entity.IEntity;
import com.zfoo.orm.cache.persister.IOrmPersister;
import com.zfoo.orm.cache.persister.PNode;
import com.zfoo.orm.model.EntityDef;
import com.zfoo.orm.model.IEntity;
import com.zfoo.orm.query.Page;
import com.zfoo.orm.model.vo.EntityDef;
import com.zfoo.protocol.collection.CollectionUtils;
import com.zfoo.protocol.util.AssertionUtils;
import com.zfoo.protocol.util.StringUtils;
import com.zfoo.scheduler.util.TimeUtils;
import com.zfoo.protocol.util.ThreadUtils;
import com.zfoo.scheduler.util.TimeUtils;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.slf4j.Logger;
+1 -1
View File
@@ -12,7 +12,7 @@
package com.zfoo.orm.cache;
import com.zfoo.orm.model.entity.IEntity;
import com.zfoo.orm.model.IEntity;
import java.util.List;
import java.util.function.BiConsumer;
@@ -14,7 +14,7 @@
package com.zfoo.orm.cache.persister;
import com.zfoo.orm.cache.EntityCaches;
import com.zfoo.orm.model.vo.EntityDef;
import com.zfoo.orm.model.EntityDef;
/**
* @author godotg
@@ -16,7 +16,7 @@ package com.zfoo.orm.cache.persister;
import com.zfoo.event.manager.EventBus;
import com.zfoo.orm.OrmContext;
import com.zfoo.orm.cache.EntityCaches;
import com.zfoo.orm.model.vo.EntityDef;
import com.zfoo.orm.model.EntityDef;
import com.zfoo.protocol.exception.ExceptionUtils;
import com.zfoo.scheduler.manager.SchedulerBus;
import com.zfoo.scheduler.util.TimeUtils;
+1 -1
View File
@@ -13,7 +13,7 @@
package com.zfoo.orm.cache.persister;
import com.zfoo.orm.model.entity.IEntity;
import com.zfoo.orm.model.IEntity;
import com.zfoo.scheduler.util.TimeUtils;
/**
@@ -16,7 +16,7 @@ package com.zfoo.orm.cache.persister;
import com.zfoo.event.manager.EventBus;
import com.zfoo.orm.OrmContext;
import com.zfoo.orm.cache.EntityCaches;
import com.zfoo.orm.model.vo.EntityDef;
import com.zfoo.orm.model.EntityDef;
import com.zfoo.protocol.util.StringUtils;
import com.zfoo.scheduler.manager.SchedulerBus;
@@ -1,6 +1,5 @@
/*
* Copyright (C) 2020 The zfoo Authors
*
* Licensed 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
*
@@ -11,7 +10,7 @@
* See the License for the specific language governing permissions and limitations under the License.
*/
package com.zfoo.orm.model.config;
package com.zfoo.orm.config;
/**
* @author godotg
@@ -1,6 +1,5 @@
/*
* Copyright (C) 2020 The zfoo Authors
*
* Licensed 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
*
@@ -11,7 +10,7 @@
* See the License for the specific language governing permissions and limitations under the License.
*/
package com.zfoo.orm.model.config;
package com.zfoo.orm.config;
import java.util.Map;
@@ -1,6 +1,5 @@
/*
* Copyright (C) 2020 The zfoo Authors
*
* Licensed 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
*
@@ -11,7 +10,7 @@
* See the License for the specific language governing permissions and limitations under the License.
*/
package com.zfoo.orm.model.config;
package com.zfoo.orm.config;
import java.util.List;
@@ -1,6 +1,5 @@
/*
* Copyright (C) 2020 The zfoo Authors
*
* Licensed 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
*
@@ -11,7 +10,7 @@
* See the License for the specific language governing permissions and limitations under the License.
*/
package com.zfoo.orm.model.config;
package com.zfoo.orm.config;
/**
* @author godotg
@@ -1,6 +1,5 @@
/*
* Copyright (C) 2020 The zfoo Authors
*
* Licensed 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
*
@@ -11,13 +10,13 @@
* See the License for the specific language governing permissions and limitations under the License.
*/
package com.zfoo.orm.model.config;
package com.zfoo.orm.config;
import com.zfoo.orm.cache.EntityCaches;
import com.zfoo.orm.cache.persister.CronOrmPersister;
import com.zfoo.orm.cache.persister.IOrmPersister;
import com.zfoo.orm.cache.persister.TimeOrmPersister;
import com.zfoo.orm.model.vo.EntityDef;
import com.zfoo.orm.model.EntityDef;
import com.zfoo.protocol.util.StringUtils;
/**
@@ -16,7 +16,7 @@ package com.zfoo.orm.manager;
import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoCollection;
import com.zfoo.orm.cache.IEntityCaches;
import com.zfoo.orm.model.entity.IEntity;
import com.zfoo.orm.model.IEntity;
import org.bson.Document;
import java.util.Collection;
@@ -23,14 +23,14 @@ import com.mongodb.client.MongoDatabase;
import com.mongodb.client.model.IndexOptions;
import com.mongodb.client.model.Indexes;
import com.zfoo.orm.OrmContext;
import com.zfoo.orm.anno.*;
import com.zfoo.orm.cache.EntityCaches;
import com.zfoo.orm.cache.IEntityCaches;
import com.zfoo.orm.model.anno.*;
import com.zfoo.orm.model.config.OrmConfig;
import com.zfoo.orm.model.entity.IEntity;
import com.zfoo.orm.model.vo.EntityDef;
import com.zfoo.orm.model.vo.IndexDef;
import com.zfoo.orm.model.vo.IndexTextDef;
import com.zfoo.orm.config.OrmConfig;
import com.zfoo.orm.model.EntityDef;
import com.zfoo.orm.model.IEntity;
import com.zfoo.orm.model.IndexDef;
import com.zfoo.orm.model.IndexTextDef;
import com.zfoo.protocol.collection.ArrayUtils;
import com.zfoo.protocol.collection.CollectionUtils;
import com.zfoo.protocol.exception.RunException;
@@ -189,7 +189,7 @@ public class OrmManager implements IOrmManager {
var componentBeans = applicationContext.getBeansWithAnnotation(Component.class);
for (var bean : componentBeans.values()) {
ReflectionUtils.filterFieldsInClass(bean.getClass()
, field -> field.isAnnotationPresent(EntityCachesInjection.class)
, field -> field.isAnnotationPresent(EntityCacheAutowired.class)
, field -> {
Type type = field.getGenericType();
@@ -1,6 +1,5 @@
/*
* Copyright (C) 2020 The zfoo Authors
*
* Licensed 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
*
@@ -11,10 +10,9 @@
* See the License for the specific language governing permissions and limitations under the License.
*/
package com.zfoo.orm.model.vo;
package com.zfoo.orm.model;
import com.zfoo.orm.model.config.PersisterStrategy;
import com.zfoo.orm.model.entity.IEntity;
import com.zfoo.orm.config.PersisterStrategy;
import com.zfoo.protocol.util.ReflectionUtils;
import java.lang.reflect.Field;
@@ -1,6 +1,5 @@
/*
* Copyright (C) 2020 The zfoo Authors
*
* Licensed 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
*
@@ -11,7 +10,7 @@
* See the License for the specific language governing permissions and limitations under the License.
*/
package com.zfoo.orm.model.entity;
package com.zfoo.orm.model;
import com.zfoo.protocol.util.StringUtils;
@@ -1,6 +1,5 @@
/*
* Copyright (C) 2020 The zfoo Authors
*
* Licensed 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
*
@@ -11,7 +10,7 @@
* See the License for the specific language governing permissions and limitations under the License.
*/
package com.zfoo.orm.model.vo;
package com.zfoo.orm.model;
import java.lang.reflect.Field;
@@ -1,6 +1,5 @@
/*
* Copyright (C) 2020 The zfoo Authors
*
* Licensed 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
*
@@ -11,9 +10,9 @@
* See the License for the specific language governing permissions and limitations under the License.
*/
package com.zfoo.orm.model.vo;
package com.zfoo.orm.model;
import com.zfoo.orm.model.anno.IndexText;
import com.zfoo.orm.anno.IndexText;
import com.zfoo.protocol.util.AssertionUtils;
import com.zfoo.protocol.util.ReflectionUtils;
import com.zfoo.protocol.util.StringUtils;
@@ -13,7 +13,7 @@
package com.zfoo.orm.query;
import com.zfoo.orm.model.entity.IEntity;
import com.zfoo.orm.model.IEntity;
/**
* 对数据库进行(查找)的相关方法
@@ -13,7 +13,7 @@
package com.zfoo.orm.query;
import com.zfoo.orm.model.entity.IEntity;
import com.zfoo.orm.model.IEntity;
import com.zfoo.protocol.model.Pair;
import java.util.List;
@@ -15,7 +15,7 @@ package com.zfoo.orm.query;
import com.mongodb.client.model.Filters;
import com.zfoo.orm.OrmContext;
import com.zfoo.orm.model.entity.IEntity;
import com.zfoo.orm.model.IEntity;
import com.zfoo.protocol.model.Pair;
import com.zfoo.protocol.util.StringUtils;
import org.bson.conversions.Bson;
@@ -13,7 +13,7 @@
package com.zfoo.orm.query;
import com.zfoo.orm.model.entity.IEntity;
import com.zfoo.orm.model.IEntity;
/**
* @author godotg
@@ -14,12 +14,12 @@
package com.zfoo.orm.schema;
import com.zfoo.orm.OrmContext;
import com.zfoo.orm.manager.OrmManager;
import com.zfoo.orm.accessor.MongodbAccessor;
import com.zfoo.orm.model.config.CacheStrategy;
import com.zfoo.orm.model.config.HostConfig;
import com.zfoo.orm.model.config.OrmConfig;
import com.zfoo.orm.model.config.PersisterStrategy;
import com.zfoo.orm.config.CacheStrategy;
import com.zfoo.orm.config.HostConfig;
import com.zfoo.orm.config.OrmConfig;
import com.zfoo.orm.config.PersisterStrategy;
import com.zfoo.orm.manager.OrmManager;
import com.zfoo.orm.query.MongodbQuery;
import com.zfoo.protocol.util.DomUtils;
import com.zfoo.protocol.util.StringUtils;
+2 -2
View File
@@ -13,8 +13,8 @@
package com.zfoo.orm.cache;
import com.zfoo.orm.anno.EntityCacheAutowired;
import com.zfoo.orm.entity.UserEntity;
import com.zfoo.orm.model.anno.EntityCachesInjection;
import org.springframework.stereotype.Component;
/**
@@ -24,7 +24,7 @@ import org.springframework.stereotype.Component;
@Component
public class UserManager {
@EntityCachesInjection
@EntityCacheAutowired
public IEntityCaches<Long, UserEntity> userEntityCaches;
}
@@ -13,10 +13,10 @@
package com.zfoo.orm.entity;
import com.zfoo.orm.model.anno.EntityCache;
import com.zfoo.orm.model.anno.Id;
import com.zfoo.orm.model.anno.Index;
import com.zfoo.orm.model.entity.IEntity;
import com.zfoo.orm.anno.EntityCache;
import com.zfoo.orm.anno.Id;
import com.zfoo.orm.anno.Index;
import com.zfoo.orm.model.IEntity;
import java.util.Date;
@@ -13,11 +13,11 @@
package com.zfoo.orm.entity;
import com.zfoo.orm.model.anno.EntityCache;
import com.zfoo.orm.model.anno.Id;
import com.zfoo.orm.model.anno.Index;
import com.zfoo.orm.model.anno.IndexText;
import com.zfoo.orm.model.entity.IEntity;
import com.zfoo.orm.anno.EntityCache;
import com.zfoo.orm.anno.Id;
import com.zfoo.orm.anno.Index;
import com.zfoo.orm.anno.IndexText;
import com.zfoo.orm.model.IEntity;
import java.util.List;
@@ -13,10 +13,10 @@
package com.zfoo.orm.entity.bag;
import com.zfoo.orm.model.anno.EntityCache;
import com.zfoo.orm.model.anno.Id;
import com.zfoo.orm.model.anno.Persister;
import com.zfoo.orm.model.entity.IEntity;
import com.zfoo.orm.anno.EntityCache;
import com.zfoo.orm.anno.Id;
import com.zfoo.orm.anno.Persister;
import com.zfoo.orm.model.IEntity;
import java.util.HashMap;
import java.util.Map;