mirror of
https://github.com/wahyd4/Martian.git
synced 2026-08-09 05:16:21 +10:00
🎨 code review
This commit is contained in:
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.github.yuyenews</groupId>
|
||||
<artifactId>Mars-java</artifactId>
|
||||
<version>2.1.2</version>
|
||||
<version>2.1.3</version>
|
||||
</parent>
|
||||
<artifactId>mars-aop</artifactId>
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.github.yuyenews</groupId>
|
||||
<artifactId>Mars-java</artifactId>
|
||||
<version>2.1.2</version>
|
||||
<version>2.1.3</version>
|
||||
</parent>
|
||||
<artifactId>mars-core</artifactId>
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.github.yuyenews</groupId>
|
||||
<artifactId>Mars-java</artifactId>
|
||||
<version>2.1.2</version>
|
||||
<version>2.1.3</version>
|
||||
</parent>
|
||||
<artifactId>mars-ioc</artifactId>
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ public class BeanFactory {
|
||||
* @param name mingc
|
||||
* @return duix
|
||||
*/
|
||||
public static Object getBean(String name) throws Exception {
|
||||
public static <T> T getBean(String name,Class<T> cls) throws Exception {
|
||||
try {
|
||||
|
||||
Object marsBeans = constants.getAttr(MarsConstant.MARS_BEAN_OBJECTS);
|
||||
@@ -116,7 +116,7 @@ public class BeanFactory {
|
||||
marsBeanObjects = (Map<String, MarsBeanModel>)marsBeans;
|
||||
}
|
||||
|
||||
return marsBeanObjects.get(name).getObj();
|
||||
return (T)marsBeanObjects.get(name).getObj();
|
||||
} catch (Exception e) {
|
||||
throw new Exception("找不到name为["+name+"]的bean",e);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>mars-jdbc</artifactId>
|
||||
<groupId>com.github.yuyenews</groupId>
|
||||
<version>2.1.2</version>
|
||||
<version>2.1.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>mars-jdbc</artifactId>
|
||||
<groupId>com.github.yuyenews</groupId>
|
||||
<version>2.1.2</version>
|
||||
<version>2.1.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.github.yuyenews</groupId>
|
||||
<artifactId>mars-jdbc</artifactId>
|
||||
<version>2.1.2</version>
|
||||
<version>2.1.3</version>
|
||||
</parent>
|
||||
<artifactId>mars-mybatis</artifactId>
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>Mars-java</artifactId>
|
||||
<groupId>com.github.yuyenews</groupId>
|
||||
<version>2.1.2</version>
|
||||
<version>2.1.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>Mars-java</artifactId>
|
||||
<groupId>com.github.yuyenews</groupId>
|
||||
<version>2.1.2</version>
|
||||
<version>2.1.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ public class MarsJunitStart {
|
||||
Resource resource = f.getAnnotation(Resource.class);
|
||||
if(resource!=null){
|
||||
f.setAccessible(true);
|
||||
f.set(obj, BeanFactory.getBean(resource.value()));
|
||||
f.set(obj, BeanFactory.getBean(resource.value(),f.getType()));
|
||||
}
|
||||
}
|
||||
} catch (Exception e){
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.github.yuyenews</groupId>
|
||||
<artifactId>Mars-java</artifactId>
|
||||
<version>2.1.2</version>
|
||||
<version>2.1.3</version>
|
||||
</parent>
|
||||
<artifactId>mars-mvc</artifactId>
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.mars.mvc.servlet;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.mars.core.enums.DataType;
|
||||
import com.mars.mvc.resolve.ResolveRequest;
|
||||
import com.mars.core.logger.MarsLogger;
|
||||
import com.mars.server.server.request.HttpRequest;
|
||||
@@ -24,11 +26,38 @@ public class EasyCoreServlet implements EasyServlet{
|
||||
Object result = resolveRequest.resolve(request,response);
|
||||
|
||||
/*将控制层 返回的结果 返回给netty,让其响应给客户端*/
|
||||
return result;
|
||||
|
||||
if(isNotObject(result)) {
|
||||
return result;
|
||||
} else {
|
||||
return JSON.toJSONString(result);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("解释请求的时候报错",e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否是对象
|
||||
* @param result
|
||||
* @return
|
||||
*/
|
||||
public boolean isNotObject(Object result){
|
||||
String fieldTypeName = result.getClass().getSimpleName().toUpperCase();
|
||||
switch (fieldTypeName){
|
||||
case DataType.INT:
|
||||
case DataType.INTEGER:
|
||||
case DataType.BYTE:
|
||||
case DataType.STRING:
|
||||
case DataType.CHAR:
|
||||
case DataType.CHARACTER:
|
||||
case DataType.DOUBLE:
|
||||
case DataType.FLOAT:
|
||||
case DataType.LONG:
|
||||
case DataType.SHORT:
|
||||
case DataType.BOOLEAN:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.github.yuyenews</groupId>
|
||||
<artifactId>Mars-java</artifactId>
|
||||
<version>2.1.2</version>
|
||||
<version>2.1.3</version>
|
||||
</parent>
|
||||
<artifactId>mars-netty</artifactId>
|
||||
|
||||
|
||||
@@ -66,8 +66,7 @@ public class RequestThread implements Runnable {
|
||||
return;
|
||||
}
|
||||
/* 将控制层返回的数据,转成json字符串返回 */
|
||||
response.send(JSON.toJSONString(result));
|
||||
|
||||
response.send(result.toString());
|
||||
} catch (InvocationTargetException e){
|
||||
log.error("处理请求的时候出错",e);
|
||||
response.send(MesUtil.getMes(500,"处理请求发生错误:"+e.getTargetException().getMessage()).toJSONString(), HttpResponseStatus.INTERNAL_SERVER_ERROR);
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.github.yuyenews</groupId>
|
||||
<artifactId>Mars-java</artifactId>
|
||||
<version>2.1.2</version>
|
||||
<version>2.1.3</version>
|
||||
</parent>
|
||||
<artifactId>mars-server</artifactId>
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>mars-start</artifactId>
|
||||
<groupId>com.github.yuyenews</groupId>
|
||||
<version>2.1.2</version>
|
||||
<version>2.1.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>mars-start</artifactId>
|
||||
<groupId>com.github.yuyenews</groupId>
|
||||
<version>2.1.2</version>
|
||||
<version>2.1.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>mars-start</artifactId>
|
||||
<groupId>com.github.yuyenews</groupId>
|
||||
<version>2.1.2</version>
|
||||
<version>2.1.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>mars-start</artifactId>
|
||||
<groupId>com.github.yuyenews</groupId>
|
||||
<version>2.1.2</version>
|
||||
<version>2.1.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>Mars-java</artifactId>
|
||||
<groupId>com.github.yuyenews</groupId>
|
||||
<version>2.1.2</version>
|
||||
<version>2.1.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
Reference in New Issue
Block a user