Browse Source

remove CacheFactory

Crystal.Sea 3 years ago
parent
commit
cbed76953b

+ 3 - 1
ReleaseNotes.txt

@@ -20,7 +20,9 @@
     *(MAXKEY-210819) 调整了机构显示树的样式
     *(MAXKEY-210820) 企业微信扫码登录js更新wwLogin-1.2.4.js
     *(MAXKEY-210821) 中文切换调整为下拉菜单
-    *(MAXKEY-210822) 依赖jar引用、更新和升级
+	*(MAXKEY-210822) 移除原有的缓存方案
+    *(MAXKEY-210823) 依赖jar引用、更新和升级
+         spring              5.3.11
          mybatis-jpa-extra   2.6
          druid               1.2.8
          caffeine            2.9.2

+ 1 - 1
gradle.properties

@@ -44,7 +44,7 @@ poiVersion                      =4.1.2
 tomcatVersion                   =9.0.53
 tomcatembedloggingjuliVersion   =8.5.2
 #spring
-springVersion                   =5.3.10
+springVersion                   =5.3.11
 springBootVersion               =2.5.5
 springSecurityVersion           =5.5.2
 springDataVersion               =2.5.2

+ 0 - 84
maxkey-common/src/main/java/org/maxkey/cache/AbstractCache.java

@@ -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;
-    }
-
-}

+ 0 - 63
maxkey-common/src/main/java/org/maxkey/cache/CacheFactory.java

@@ -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;
-    }
-
-}

+ 0 - 25
maxkey-common/src/main/java/org/maxkey/cache/package-info.java

@@ -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;

+ 0 - 51
maxkey-common/src/test/java/org/maxkey/cache/CacheFactoryTest.java

@@ -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();
-	}
-
-}

+ 0 - 71
maxkey-common/src/test/java/org/maxkey/cache/RandomCache.java

@@ -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;
-	}
-	
-	
-
-}

+ 0 - 25
maxkey-core/src/main/java/org/maxkey/web/InitializeContext.java

@@ -30,12 +30,10 @@ import javax.servlet.http.HttpServlet;
 import org.apache.commons.lang.SystemUtils;
 import org.apache.commons.lang3.ArchUtils;
 import org.joda.time.DateTime;
-import org.maxkey.cache.CacheFactory;
 import org.maxkey.configuration.ApplicationConfig;
 import org.maxkey.util.PathUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.beans.BeansException;
 import org.springframework.beans.factory.support.BeanDefinitionRegistry;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.ConfigurableApplicationContext;
@@ -80,9 +78,6 @@ public class InitializeContext extends HttpServlet {
         // List DatabaseMetaData Variables
         listDataBaseVariables();
 
-        // load caches
-        loadCaches();
-
         // Show License
         showLicense();
     }
@@ -108,26 +103,6 @@ public class InitializeContext extends HttpServlet {
     }
 
     /**
-     * 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.
      */
     public void listDataBaseVariables() {

+ 18 - 0
maxkey-gataway/src/main/java/org/gateway/controller/FallbackController.java

@@ -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;
+    }
+}

+ 2 - 2
maxkey-persistence/src/main/resources/org/maxkey/persistence/mapper/xml/mysql/OrganizationsMapper.xml

@@ -7,13 +7,13 @@
 			and	id	=	#{id} 	
 		</if> 
 		<if test="name != null and name != '' ">
-			and	name	like  '%#{name}%'
+			and name like '%${name}%'
 		</if>
 		<if test="parentId != null and parentId != '' ">
 			and	parentid	=	#{parentId}
 		</if>
 		<if test="parentName != null and parentName != ''">
-			and	parentname	like	'%#{parentName}%'
+			and parentName like '%${parentName}%'
 		</if>
 
     </sql>