This commit is contained in:
redkale
2023-12-19 00:07:40 +08:00
parent 1a49db8a1b
commit d3a6f46c6c
13 changed files with 34 additions and 30 deletions

View File

@@ -18,6 +18,7 @@ module org.redkale {
exports org.redkale.boot; exports org.redkale.boot;
exports org.redkale.boot.watch; exports org.redkale.boot.watch;
exports org.redkale.cache; exports org.redkale.cache;
exports org.redkale.cache.spi;
exports org.redkale.cluster; exports org.redkale.cluster;
exports org.redkale.convert; exports org.redkale.convert;
exports org.redkale.convert.bson; exports org.redkale.convert.bson;
@@ -33,6 +34,7 @@ module org.redkale {
exports org.redkale.net.sncp; exports org.redkale.net.sncp;
exports org.redkale.persistence; exports org.redkale.persistence;
exports org.redkale.schedule; exports org.redkale.schedule;
exports org.redkale.schedule.spi;
exports org.redkale.service; exports org.redkale.service;
exports org.redkale.source; exports org.redkale.source;
exports org.redkale.util; exports org.redkale.util;

View File

@@ -22,7 +22,7 @@ import java.util.logging.*;
import org.redkale.annotation.Nonnull; import org.redkale.annotation.Nonnull;
import org.redkale.annotation.Resource; import org.redkale.annotation.Resource;
import org.redkale.boot.ClassFilter.FilterEntry; import org.redkale.boot.ClassFilter.FilterEntry;
import org.redkale.cache.CacheModuleEngine; import org.redkale.cache.spi.CacheModuleEngine;
import org.redkale.cluster.*; import org.redkale.cluster.*;
import org.redkale.convert.Convert; import org.redkale.convert.Convert;
import org.redkale.convert.bson.BsonFactory; import org.redkale.convert.bson.BsonFactory;
@@ -35,7 +35,7 @@ import org.redkale.mq.*;
import org.redkale.net.*; import org.redkale.net.*;
import org.redkale.net.http.*; import org.redkale.net.http.*;
import org.redkale.net.sncp.*; import org.redkale.net.sncp.*;
import org.redkale.schedule.ScheduleModuleEngine; import org.redkale.schedule.spi.ScheduleModuleEngine;
import org.redkale.service.Service; import org.redkale.service.Service;
import org.redkale.source.*; import org.redkale.source.*;
import org.redkale.util.*; import org.redkale.util.*;

View File

@@ -1,7 +1,7 @@
/* /*
* *
*/ */
package org.redkale.cache; package org.redkale.cache.spi;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;

View File

@@ -1,7 +1,7 @@
/* /*
* *
*/ */
package org.redkale.cache; package org.redkale.cache.spi;
import org.redkale.convert.ConvertColumn; import org.redkale.convert.ConvertColumn;
import org.redkale.convert.ConvertDisabled; import org.redkale.convert.ConvertDisabled;

View File

@@ -1,7 +1,7 @@
/* /*
* *
*/ */
package org.redkale.cache; package org.redkale.cache.spi;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.time.Duration; import java.time.Duration;
@@ -40,7 +40,7 @@ import org.redkale.util.Utility;
@Component @Component
@AutoLoad(false) @AutoLoad(false)
@ResourceType(CacheManager.class) @ResourceType(CacheManager.class)
public class DefaultCacheManager implements CacheManager, Service { public class CacheManagerService implements CacheManager, Service {
//是否开启缓存 //是否开启缓存
protected boolean enabled = true; protected boolean enabled = true;
@@ -69,20 +69,20 @@ public class DefaultCacheManager implements CacheManager, Service {
//远程缓存Source //远程缓存Source
protected CacheSource remoteSource; protected CacheSource remoteSource;
protected DefaultCacheManager(@Nullable CacheSource remoteSource) { protected CacheManagerService(@Nullable CacheSource remoteSource) {
this.remoteSource = remoteSource; this.remoteSource = remoteSource;
} }
//一般用于独立组件 //一般用于独立组件
public static DefaultCacheManager create(@Nullable CacheSource remoteSource) { public static CacheManagerService create(@Nullable CacheSource remoteSource) {
return new DefaultCacheManager(remoteSource); return new CacheManagerService(remoteSource);
} }
public boolean enabled() { public boolean enabled() {
return this.enabled; return this.enabled;
} }
public DefaultCacheManager enabled(boolean val) { public CacheManagerService enabled(boolean val) {
this.enabled = val; this.enabled = val;
return this; return this;
} }
@@ -123,7 +123,7 @@ public class DefaultCacheManager implements CacheManager, Service {
return enabled; return enabled;
} }
public DefaultCacheManager addHash(String hash) { public CacheManagerService addHash(String hash) {
this.hashNames.add(hash); this.hashNames.add(hash);
return this; return this;
} }

View File

@@ -1,7 +1,7 @@
/* /*
* *
*/ */
package org.redkale.cache; package org.redkale.cache.spi;
import org.redkale.boot.Application; import org.redkale.boot.Application;
import org.redkale.boot.ModuleEngine; import org.redkale.boot.ModuleEngine;
@@ -15,7 +15,7 @@ import org.redkale.util.AnyValue;
public class CacheModuleEngine extends ModuleEngine { public class CacheModuleEngine extends ModuleEngine {
//全局缓存管理器 //全局缓存管理器
private DefaultCacheManager cacheManager; private CacheManagerService cacheManager;
public CacheModuleEngine(Application application) { public CacheModuleEngine(Application application) {
super(application); super(application);
@@ -44,7 +44,7 @@ public class CacheModuleEngine extends ModuleEngine {
*/ */
public void onAppPostInit() { public void onAppPostInit() {
//设置缓存管理器 //设置缓存管理器
this.cacheManager = DefaultCacheManager.create(null).enabled(false); this.cacheManager = CacheManagerService.create(null).enabled(false);
final AnyValue cacheConf = application.getAppConfig().getAnyValue("cache"); final AnyValue cacheConf = application.getAppConfig().getAnyValue("cache");
if (cacheConf != null && !application.isCompileMode()) { if (cacheConf != null && !application.isCompileMode()) {
this.resourceFactory.inject(this.cacheManager); this.resourceFactory.inject(this.cacheManager);

View File

@@ -1,7 +1,7 @@
/* /*
* *
*/ */
package org.redkale.cache; package org.redkale.cache.spi;
import java.time.Duration; import java.time.Duration;
import org.redkale.convert.ConvertColumn; import org.redkale.convert.ConvertColumn;

View File

@@ -1,7 +1,7 @@
/* /*
* *
*/ */
package org.redkale.schedule; package org.redkale.schedule.spi;
import java.time.DateTimeException; import java.time.DateTimeException;
import java.time.temporal.ChronoField; import java.time.temporal.ChronoField;

View File

@@ -1,7 +1,7 @@
/* /*
* *
*/ */
package org.redkale.schedule; package org.redkale.schedule.spi;
import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodHandles;
@@ -54,7 +54,7 @@ import org.redkale.util.Utility;
@Component @Component
@AutoLoad(false) @AutoLoad(false)
@ResourceType(ScheduleManager.class) @ResourceType(ScheduleManager.class)
public class DefaultScheduleManager implements ScheduleManager, Service { public class ScheduleManagerService implements ScheduleManager, Service {
protected final Logger logger = Logger.getLogger(this.getClass().getSimpleName()); protected final Logger logger = Logger.getLogger(this.getClass().getSimpleName());
@@ -76,20 +76,20 @@ public class DefaultScheduleManager implements ScheduleManager, Service {
private AnyValue config; private AnyValue config;
protected DefaultScheduleManager(UnaryOperator<String> propertyFunc) { protected ScheduleManagerService(UnaryOperator<String> propertyFunc) {
this.propertyFunc = propertyFunc; this.propertyFunc = propertyFunc;
} }
//一般用于独立组件 //一般用于独立组件
public static DefaultScheduleManager create(UnaryOperator<String> propertyFunc) { public static ScheduleManagerService create(UnaryOperator<String> propertyFunc) {
return new DefaultScheduleManager(propertyFunc); return new ScheduleManagerService(propertyFunc);
} }
public boolean enabled() { public boolean enabled() {
return this.enabled; return this.enabled;
} }
public DefaultScheduleManager enabled(boolean val) { public ScheduleManagerService enabled(boolean val) {
this.enabled = val; this.enabled = val;
return this; return this;
} }

View File

@@ -1,7 +1,7 @@
/* /*
* *
*/ */
package org.redkale.schedule; package org.redkale.schedule.spi;
import org.redkale.boot.Application; import org.redkale.boot.Application;
import org.redkale.boot.ModuleEngine; import org.redkale.boot.ModuleEngine;
@@ -16,7 +16,7 @@ import org.redkale.util.AnyValue;
public class ScheduleModuleEngine extends ModuleEngine { public class ScheduleModuleEngine extends ModuleEngine {
//全局定时任务管理器 //全局定时任务管理器
private DefaultScheduleManager scheduleManager; private ScheduleManagerService scheduleManager;
public ScheduleModuleEngine(Application application) { public ScheduleModuleEngine(Application application) {
super(application); super(application);
@@ -45,7 +45,7 @@ public class ScheduleModuleEngine extends ModuleEngine {
*/ */
public void onAppPostInit() { public void onAppPostInit() {
//设置定时管理器 //设置定时管理器
this.scheduleManager = DefaultScheduleManager.create(null).enabled(false); this.scheduleManager = ScheduleManagerService.create(null).enabled(false);
final AnyValue scheduleConf = application.getAppConfig().getAnyValue("schedule"); final AnyValue scheduleConf = application.getAppConfig().getAnyValue("schedule");
if (scheduleConf != null && !application.isCompileMode()) { if (scheduleConf != null && !application.isCompileMode()) {
this.resourceFactory.inject(this.scheduleManager); this.resourceFactory.inject(this.scheduleManager);

View File

@@ -48,6 +48,7 @@ public class RedkaleClassLoader extends URLClassLoader {
"org.redkale.boot", "org.redkale.boot",
"org.redkale.boot.watch", "org.redkale.boot.watch",
"org.redkale.cache", "org.redkale.cache",
"org.redkale.cache.spi",
"org.redkale.cluster", "org.redkale.cluster",
"org.redkale.convert", "org.redkale.convert",
"org.redkale.convert.bson", "org.redkale.convert.bson",
@@ -63,6 +64,7 @@ public class RedkaleClassLoader extends URLClassLoader {
"org.redkale.net.sncp", "org.redkale.net.sncp",
"org.redkale.persistence", "org.redkale.persistence",
"org.redkale.schedule", "org.redkale.schedule",
"org.redkale.schedule.spi",
"org.redkale.service", "org.redkale.service",
"org.redkale.source", "org.redkale.source",
"org.redkale.util", "org.redkale.util",

View File

@@ -7,7 +7,7 @@ import java.time.Duration;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import org.junit.jupiter.api.*; import org.junit.jupiter.api.*;
import org.redkale.cache.DefaultCacheManager; import org.redkale.cache.spi.CacheManagerService;
import org.redkale.convert.json.JsonConvert; import org.redkale.convert.json.JsonConvert;
import org.redkale.source.CacheMemorySource; import org.redkale.source.CacheMemorySource;
import org.redkale.util.Utility; import org.redkale.util.Utility;
@@ -18,7 +18,7 @@ import org.redkale.util.Utility;
*/ */
public class CacheManagerTest { public class CacheManagerTest {
private static DefaultCacheManager manager; private static CacheManagerService manager;
public static void main(String[] args) throws Throwable { public static void main(String[] args) throws Throwable {
CacheManagerTest test = new CacheManagerTest(); CacheManagerTest test = new CacheManagerTest();
@@ -31,7 +31,7 @@ public class CacheManagerTest {
public static void init() throws Exception { public static void init() throws Exception {
CacheMemorySource remoteSource = new CacheMemorySource("cache-remote"); CacheMemorySource remoteSource = new CacheMemorySource("cache-remote");
remoteSource.init(null); remoteSource.init(null);
manager = DefaultCacheManager.create(remoteSource); manager = CacheManagerService.create(remoteSource);
manager.init(null); manager.init(null);
} }

View File

@@ -4,7 +4,7 @@
package org.redkale.test.schedule; package org.redkale.test.schedule;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.redkale.schedule.DefaultScheduleManager; import org.redkale.schedule.spi.ScheduleManagerService;
import org.redkale.util.Utility; import org.redkale.util.Utility;
/** /**
@@ -20,7 +20,7 @@ public class SchedulingTest {
@Test @Test
public void run() throws Exception { public void run() throws Exception {
DefaultScheduleManager manager = DefaultScheduleManager.create(null); ScheduleManagerService manager = ScheduleManagerService.create(null);
manager.init(null); manager.init(null);
ScheduleService service = new ScheduleService(); ScheduleService service = new ScheduleService();
manager.schedule(service); manager.schedule(service);