mirror of
https://github.com/wahyd4/Martian.git
synced 2026-08-09 05:16:21 +10:00
update version
This commit is contained in:
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.github.yuyenews</groupId>
|
||||
<artifactId>Mars-java</artifactId>
|
||||
<version>2.2.0</version>
|
||||
<version>2.2.1</version>
|
||||
</parent>
|
||||
<artifactId>mars-aop</artifactId>
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.github.yuyenews</groupId>
|
||||
<artifactId>Mars-java</artifactId>
|
||||
<version>2.2.0</version>
|
||||
<version>2.2.1</version>
|
||||
</parent>
|
||||
<artifactId>mars-core</artifactId>
|
||||
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
package com.mars.core.load;
|
||||
|
||||
import com.mars.core.annotation.Controller;
|
||||
import com.mars.core.annotation.MarsBean;
|
||||
import com.mars.core.annotation.MarsDao;
|
||||
import com.mars.core.annotation.MarsInterceptor;
|
||||
import com.mars.core.annotation.*;
|
||||
import com.mars.core.constant.MarsConstant;
|
||||
import com.mars.core.constant.MarsSpace;
|
||||
import com.mars.core.model.MarsBeanClassModel;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -20,16 +16,53 @@ public class LoadBeans {
|
||||
private static MarsSpace constants = MarsSpace.getEasySpace();
|
||||
|
||||
/**
|
||||
* 加载本地bean
|
||||
* 加载所有的bean,包括controller 的class对象
|
||||
*
|
||||
* @throws Exception 异常
|
||||
*/
|
||||
public static Set<String> loadNativeBeans() throws Exception {
|
||||
Set<String> navClassList = new HashSet<>();
|
||||
public static void loadBeans() throws Exception {
|
||||
try {
|
||||
|
||||
/* 加载 接受远程配置中心通知的controller */
|
||||
navClassList.add("com.mars.mvc.remote.controller.RemoteConfigController");
|
||||
Set<String> scanClassList = LoadHelper.getSacnClassList();
|
||||
|
||||
return navClassList;
|
||||
for (String str : scanClassList) {
|
||||
Class<?> cls = Class.forName(str);
|
||||
Controller controller = cls.getAnnotation(Controller.class);
|
||||
MarsBean marsBean = cls.getAnnotation(MarsBean.class);
|
||||
MarsInterceptor marsInterceptor = cls.getAnnotation(MarsInterceptor.class);
|
||||
MarsDao marsDao = cls.getAnnotation(MarsDao.class);
|
||||
MarsAfter marsAfter = cls.getAnnotation(MarsAfter.class);
|
||||
|
||||
int count = 0;
|
||||
|
||||
if(controller != null) {
|
||||
LoadBeans.loadController(cls, controller);
|
||||
count++;
|
||||
}
|
||||
if(marsBean != null) {
|
||||
LoadBeans.loadEasyBean(cls, marsBean);
|
||||
count++;
|
||||
}
|
||||
if(marsInterceptor != null){
|
||||
LoadBeans.loadInterceptor(cls, marsInterceptor);
|
||||
count++;
|
||||
}
|
||||
if(marsDao != null){
|
||||
LoadBeans.loadDao(cls, marsDao);
|
||||
count++;
|
||||
}
|
||||
if(marsAfter != null){
|
||||
LoadBeans.loadMarsAfter(cls);
|
||||
count++;
|
||||
}
|
||||
|
||||
if(count > 1){
|
||||
throw new Exception("类:["+cls.getName()+"]上不允许有多个Mars注解");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new Exception("从扫描出来的类里面筛选有注解的类,出现异常",e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.mars.core.load;
|
||||
|
||||
import com.mars.core.annotation.*;
|
||||
import com.mars.core.constant.MarsConstant;
|
||||
import com.mars.core.constant.MarsSpace;
|
||||
import com.mars.core.util.ReadClass;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@@ -23,69 +23,38 @@ public class LoadClass {
|
||||
*
|
||||
* @throws Exception 异常
|
||||
*/
|
||||
public static void loadBeans(String packageName) throws Exception{
|
||||
public static void sacnClass(String packageName) throws Exception{
|
||||
try {
|
||||
/* 加载本地bean */
|
||||
Set<String> navClassList = LoadBeans.loadNativeBeans();
|
||||
|
||||
/* 加载框架用户的所有bean */
|
||||
loadAllBeans(packageName,navClassList);
|
||||
Set<String> scanClassList = LoadHelper.getSacnClassList();
|
||||
|
||||
/* 扫描包下面的所有类 */
|
||||
Set<String> classList = ReadClass.loadClassList(packageName);
|
||||
|
||||
/* 加载本地bean */
|
||||
Set<String> navClassList = loadNativeBeans();
|
||||
|
||||
/* 将扫描出来的类保存到内存中 */
|
||||
scanClassList.addAll(classList);
|
||||
scanClassList.addAll(navClassList);
|
||||
|
||||
marsSpace.setAttr(MarsConstant.SCAN_ALL_CLASS,classList);
|
||||
|
||||
} catch (Exception e){
|
||||
throw new Exception("加载bean出错",e);
|
||||
throw new Exception("扫描["+packageName+"]包下的类发生错误",e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载所有的bean,包括controller 的class对象
|
||||
* @param packageName bean所在的包名
|
||||
*
|
||||
* 加载本地bean
|
||||
* @throws Exception 异常
|
||||
*/
|
||||
private static void loadAllBeans(String packageName,Set<String> navClassList) throws Exception {
|
||||
try {
|
||||
Set<String> classList = ReadClass.loadClassList(packageName);
|
||||
classList.addAll(navClassList);
|
||||
public static Set<String> loadNativeBeans() throws Exception {
|
||||
Set<String> navClassList = new HashSet<>();
|
||||
|
||||
//这里是存下来给cloud加载rpc用的,避免二次扫描
|
||||
marsSpace.setAttr(MarsConstant.SCAN_ALL_CLASS,classList);
|
||||
/* 加载 接受远程配置中心通知的controller */
|
||||
navClassList.add("com.mars.mvc.remote.controller.RemoteConfigController");
|
||||
|
||||
for (String str : classList) {
|
||||
Class<?> cls = Class.forName(str);
|
||||
Controller controller = cls.getAnnotation(Controller.class);
|
||||
MarsBean marsBean = cls.getAnnotation(MarsBean.class);
|
||||
MarsInterceptor marsInterceptor = cls.getAnnotation(MarsInterceptor.class);
|
||||
MarsDao marsDao = cls.getAnnotation(MarsDao.class);
|
||||
MarsAfter marsAfter = cls.getAnnotation(MarsAfter.class);
|
||||
|
||||
int count = 0;
|
||||
|
||||
if(controller != null) {
|
||||
LoadBeans.loadController(cls, controller);
|
||||
count++;
|
||||
}
|
||||
if(marsBean != null) {
|
||||
LoadBeans.loadEasyBean(cls, marsBean);
|
||||
count++;
|
||||
}
|
||||
if(marsInterceptor != null){
|
||||
LoadBeans.loadInterceptor(cls, marsInterceptor);
|
||||
count++;
|
||||
}
|
||||
if(marsDao != null){
|
||||
LoadBeans.loadDao(cls, marsDao);
|
||||
count++;
|
||||
}
|
||||
if(marsAfter != null){
|
||||
LoadBeans.loadMarsAfter(cls);
|
||||
count++;
|
||||
}
|
||||
|
||||
if(count > 1){
|
||||
throw new Exception("类:["+cls.getName()+"]上不允许有多个Mars注解");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new Exception("扫描["+packageName+"]包下的类发生错误",e);
|
||||
}
|
||||
return navClassList;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.github.yuyenews</groupId>
|
||||
<artifactId>Mars-java</artifactId>
|
||||
<version>2.2.0</version>
|
||||
<version>2.2.1</version>
|
||||
</parent>
|
||||
<artifactId>mars-ioc</artifactId>
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>mars-jdbc</artifactId>
|
||||
<groupId>com.github.yuyenews</groupId>
|
||||
<version>2.2.0</version>
|
||||
<version>2.2.1</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>mars-jdbc</artifactId>
|
||||
<groupId>com.github.yuyenews</groupId>
|
||||
<version>2.2.0</version>
|
||||
<version>2.2.1</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.github.yuyenews</groupId>
|
||||
<artifactId>mars-jdbc</artifactId>
|
||||
<version>2.2.0</version>
|
||||
<version>2.2.1</version>
|
||||
</parent>
|
||||
<artifactId>mars-mybatis</artifactId>
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>Mars-java</artifactId>
|
||||
<groupId>com.github.yuyenews</groupId>
|
||||
<version>2.2.0</version>
|
||||
<version>2.2.1</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.github.yuyenews</groupId>
|
||||
<artifactId>Mars-java</artifactId>
|
||||
<version>2.2.0</version>
|
||||
<version>2.2.1</version>
|
||||
</parent>
|
||||
<artifactId>mars-mvc</artifactId>
|
||||
|
||||
|
||||
@@ -44,6 +44,9 @@ public class MarsCoreServlet implements MarsServlet {
|
||||
* @return
|
||||
*/
|
||||
public boolean isNotObject(Object result){
|
||||
if(result == null){
|
||||
return true;
|
||||
}
|
||||
String fieldTypeName = result.getClass().getSimpleName().toUpperCase();
|
||||
switch (fieldTypeName){
|
||||
case DataType.INT:
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.github.yuyenews</groupId>
|
||||
<artifactId>Mars-java</artifactId>
|
||||
<version>2.2.0</version>
|
||||
<version>2.2.1</version>
|
||||
</parent>
|
||||
<artifactId>mars-netty</artifactId>
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>Mars-java</artifactId>
|
||||
<groupId>com.github.yuyenews</groupId>
|
||||
<version>2.2.0</version>
|
||||
<version>2.2.1</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.github.yuyenews</groupId>
|
||||
<artifactId>Mars-java</artifactId>
|
||||
<version>2.2.0</version>
|
||||
<version>2.2.1</version>
|
||||
</parent>
|
||||
<artifactId>mars-server</artifactId>
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>Mars-java</artifactId>
|
||||
<groupId>com.github.yuyenews</groupId>
|
||||
<version>2.2.0</version>
|
||||
<version>2.2.1</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user