mirror of
https://gitee.com/dromara/MaxKey.git
synced 2025-12-07 17:38:32 +08:00
remove CacheFactory
This commit is contained in:
parent
75f117d8be
commit
cbed76953b
@ -20,7 +20,9 @@
|
|||||||
*(MAXKEY-210819) 调整了机构显示树的样式
|
*(MAXKEY-210819) 调整了机构显示树的样式
|
||||||
*(MAXKEY-210820) 企业微信扫码登录js更新wwLogin-1.2.4.js
|
*(MAXKEY-210820) 企业微信扫码登录js更新wwLogin-1.2.4.js
|
||||||
*(MAXKEY-210821) 中文切换调整为下拉菜单
|
*(MAXKEY-210821) 中文切换调整为下拉菜单
|
||||||
*(MAXKEY-210822) 依赖jar引用、更新和升级
|
*(MAXKEY-210822) 移除原有的缓存方案
|
||||||
|
*(MAXKEY-210823) 依赖jar引用、更新和升级
|
||||||
|
spring 5.3.11
|
||||||
mybatis-jpa-extra 2.6
|
mybatis-jpa-extra 2.6
|
||||||
druid 1.2.8
|
druid 1.2.8
|
||||||
caffeine 2.9.2
|
caffeine 2.9.2
|
||||||
|
|||||||
@ -44,7 +44,7 @@ poiVersion =4.1.2
|
|||||||
tomcatVersion =9.0.53
|
tomcatVersion =9.0.53
|
||||||
tomcatembedloggingjuliVersion =8.5.2
|
tomcatembedloggingjuliVersion =8.5.2
|
||||||
#spring
|
#spring
|
||||||
springVersion =5.3.10
|
springVersion =5.3.11
|
||||||
springBootVersion =2.5.5
|
springBootVersion =2.5.5
|
||||||
springSecurityVersion =5.5.2
|
springSecurityVersion =5.5.2
|
||||||
springDataVersion =2.5.2
|
springDataVersion =2.5.2
|
||||||
|
|||||||
@ -1,84 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
package org.maxkey.cache;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* AbstractCache .
|
|
||||||
* @author Crystal
|
|
||||||
* @version 1.0
|
|
||||||
* @Date 2015/11/12
|
|
||||||
*/
|
|
||||||
public abstract class AbstractCache extends Thread {
|
|
||||||
|
|
||||||
protected static final Logger _logger = LoggerFactory.getLogger(AbstractCache.class);
|
|
||||||
|
|
||||||
private int interval = 30000 / 1000;
|
|
||||||
|
|
||||||
public AbstractCache() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract void business();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
while (true) {
|
|
||||||
_logger.debug("Cache Thread Start run " + getName());
|
|
||||||
_logger.info("Cache Thread Start run " + this.getClass());
|
|
||||||
try {
|
|
||||||
|
|
||||||
business();
|
|
||||||
|
|
||||||
_logger.debug("Cache Thread " + getName() + " Finished . ");
|
|
||||||
_logger.info("Cache Thread " + this.getClass() + " Finished . ");
|
|
||||||
|
|
||||||
_logger.debug("Cache Thread sleep " + (interval * 1000) + " minute . ");
|
|
||||||
sleep(interval * 1000);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
_logger.error(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void start() {
|
|
||||||
this.run();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* constructor.
|
|
||||||
* @param name String
|
|
||||||
*/
|
|
||||||
public AbstractCache(String name) {
|
|
||||||
super(name);
|
|
||||||
// TODO Auto-generated constructor stub
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getInterval() {
|
|
||||||
return interval;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setInterval(int interval) {
|
|
||||||
this.interval = interval;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,63 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
package org.maxkey.cache;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CacheFactory.
|
|
||||||
* @author Crystal.Sea
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class CacheFactory {
|
|
||||||
protected static final Logger _logger = LoggerFactory.getLogger(CacheFactory.class);
|
|
||||||
|
|
||||||
private ArrayList<AbstractCache> cache;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CacheFactory.
|
|
||||||
*/
|
|
||||||
public CacheFactory() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* start Cache.
|
|
||||||
*/
|
|
||||||
public void start() {
|
|
||||||
|
|
||||||
for (AbstractCache cacheable : cache) {
|
|
||||||
_logger.info("Cache " + cacheable.getClass());
|
|
||||||
new Thread(cacheable).start();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList<AbstractCache> getCache() {
|
|
||||||
return cache;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCache(ArrayList<AbstractCache> cache) {
|
|
||||||
this.cache = cache;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,25 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* @author Administrator
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package org.maxkey.cache;
|
|
||||||
@ -1,51 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package org.maxkey.cache;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Crystal.sea
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class CacheFactoryTest {
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public CacheFactoryTest() {
|
|
||||||
// TODO Auto-generated constructor stub
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param args
|
|
||||||
*/
|
|
||||||
public static void main(String[] args) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
RandomCache randomCache=new RandomCache();
|
|
||||||
ArrayList<AbstractCache> cacheList=new ArrayList<AbstractCache>();
|
|
||||||
cacheList.add(randomCache);
|
|
||||||
CacheFactory cacheFactory=new CacheFactory();
|
|
||||||
cacheFactory.setCache(cacheList);
|
|
||||||
cacheFactory.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,71 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package org.maxkey.cache;
|
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author amarsoft
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class RandomCache extends AbstractCache {
|
|
||||||
java.util.Random random=new Random();
|
|
||||||
|
|
||||||
int i;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public RandomCache() {
|
|
||||||
// TODO Auto-generated constructor stub
|
|
||||||
this.setInterval(5);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param name
|
|
||||||
*/
|
|
||||||
public RandomCache(String name) {
|
|
||||||
super(name);
|
|
||||||
// TODO Auto-generated constructor stub
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see com.connsec.cache.AbstractCache#business()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void business() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
i=random.nextInt(100);
|
|
||||||
System.out.println(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getI() {
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setI(int i) {
|
|
||||||
this.i = i;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -30,12 +30,10 @@ import javax.servlet.http.HttpServlet;
|
|||||||
import org.apache.commons.lang.SystemUtils;
|
import org.apache.commons.lang.SystemUtils;
|
||||||
import org.apache.commons.lang3.ArchUtils;
|
import org.apache.commons.lang3.ArchUtils;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.maxkey.cache.CacheFactory;
|
|
||||||
import org.maxkey.configuration.ApplicationConfig;
|
import org.maxkey.configuration.ApplicationConfig;
|
||||||
import org.maxkey.util.PathUtils;
|
import org.maxkey.util.PathUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.BeansException;
|
|
||||||
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.context.ConfigurableApplicationContext;
|
import org.springframework.context.ConfigurableApplicationContext;
|
||||||
@ -80,9 +78,6 @@ public class InitializeContext extends HttpServlet {
|
|||||||
// List DatabaseMetaData Variables
|
// List DatabaseMetaData Variables
|
||||||
listDataBaseVariables();
|
listDataBaseVariables();
|
||||||
|
|
||||||
// load caches
|
|
||||||
loadCaches();
|
|
||||||
|
|
||||||
// Show License
|
// Show License
|
||||||
showLicense();
|
showLicense();
|
||||||
}
|
}
|
||||||
@ -107,26 +102,6 @@ public class InitializeContext extends HttpServlet {
|
|||||||
this.applicationContext = applicationContext;
|
this.applicationContext = applicationContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* loadCaches.
|
|
||||||
*/
|
|
||||||
public void loadCaches() {
|
|
||||||
_logger.info("-----------------------------------------------------------");
|
|
||||||
_logger.info("Load Caches ");
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (applicationContext.containsBean("cacheFactory")) {
|
|
||||||
CacheFactory cacheFactory =
|
|
||||||
applicationContext.getBean("cacheFactory", CacheFactory.class);
|
|
||||||
cacheFactory.start();
|
|
||||||
}
|
|
||||||
} catch (BeansException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
_logger.info("-----------------------------------------------------------");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* listDataBaseVariables.
|
* listDataBaseVariables.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -0,0 +1,18 @@
|
|||||||
|
package org.gateway.controller;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
public class FallbackController {
|
||||||
|
@RequestMapping("/defaultFallback")
|
||||||
|
public Map<String , Object> defaultFallback() {
|
||||||
|
Map<String , Object> map = new HashMap<>();
|
||||||
|
map.put("code", 1);
|
||||||
|
map.put("message", "服务异常");
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -7,13 +7,13 @@
|
|||||||
and id = #{id}
|
and id = #{id}
|
||||||
</if>
|
</if>
|
||||||
<if test="name != null and name != '' ">
|
<if test="name != null and name != '' ">
|
||||||
and name like '%#{name}%'
|
and name like '%${name}%'
|
||||||
</if>
|
</if>
|
||||||
<if test="parentId != null and parentId != '' ">
|
<if test="parentId != null and parentId != '' ">
|
||||||
and parentid = #{parentId}
|
and parentid = #{parentId}
|
||||||
</if>
|
</if>
|
||||||
<if test="parentName != null and parentName != ''">
|
<if test="parentName != null and parentName != ''">
|
||||||
and parentname like '%#{parentName}%'
|
and parentName like '%${parentName}%'
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
</sql>
|
</sql>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user