浏览代码

update martian framework (#6410)

* test martian

* martian

* martian

* add readme.md

* edit dockerfile

* edit dockerfile

* edit dockerfile

* test martian

* test martian

* test martian

* test martian

* test martian

* test martian

* test martian

* add martian

* update martian

* update martian

* update martian

* update martian

* update martian

* update martian

* update martian
俞晔 4 年之前
父节点
当前提交
d8013e9bc9

+ 1 - 1
frameworks/Java/martian/martian.dockerfile

@@ -11,4 +11,4 @@ COPY --from=maven /martian/target/lib lib
 
 
 EXPOSE 8080
 EXPOSE 8080
 
 
-CMD ["java", "-jar", "martian.jar"]
+CMD ["java", "-jar", "martian.jar", "--illegal-access=deny", "--add-opens","java.base/java.lang=ALL-UNNAMED"]

+ 1 - 1
frameworks/Java/martian/pom.xml

@@ -18,7 +18,7 @@
         <dependency>
         <dependency>
             <groupId>com.github.yuyenews</groupId>
             <groupId>com.github.yuyenews</groupId>
             <artifactId>mars-starter</artifactId>
             <artifactId>mars-starter</artifactId>
-            <version>3.2.13</version>
+            <version>3.2.15</version>
         </dependency>
         </dependency>
 
 
         <!-- 下面的jar包为日志框架,必须引入,否则控制台看不到任何信息,此处以jdk日志为例 -->
         <!-- 下面的jar包为日志框架,必须引入,否则控制台看不到任何信息,此处以jdk日志为例 -->

+ 10 - 0
frameworks/Java/martian/src/main/java/com/text/config/TestConfig.java

@@ -1,6 +1,7 @@
 package com.text.config;
 package com.text.config;
 
 
 import com.mars.common.base.config.MarsConfig;
 import com.mars.common.base.config.MarsConfig;
+import com.mars.common.base.config.model.ThreadPoolConfig;
 
 
 public class TestConfig extends MarsConfig {
 public class TestConfig extends MarsConfig {
 
 
@@ -9,4 +10,13 @@ public class TestConfig extends MarsConfig {
         return 8080;
         return 8080;
     }
     }
 
 
+    @Override
+    public ThreadPoolConfig threadPoolConfig() {
+        ThreadPoolConfig threadPoolConfig = new ThreadPoolConfig();
+        threadPoolConfig.setCorePoolSize(2);
+        threadPoolConfig.setMaxPoolSize(10000000);
+        threadPoolConfig.setKeepAliveTime(20);
+        threadPoolConfig.setBackLog(2000);
+        return threadPoolConfig;
+    }
 }
 }

+ 19 - 8
frameworks/Java/martian/src/main/java/com/text/service/TestService.java

@@ -1,28 +1,39 @@
 package com.text.service;
 package com.text.service;
 
 
 import com.mars.common.annotation.bean.MarsBean;
 import com.mars.common.annotation.bean.MarsBean;
+import com.mars.iserver.constant.HttpConstant;
 import com.mars.iserver.server.impl.MarsHttpExchange;
 import com.mars.iserver.server.impl.MarsHttpExchange;
-import com.mars.iserver.server.model.HttpHeaders;
-import com.mars.server.server.request.HttpMarsRequest;
 import com.mars.server.server.request.HttpMarsResponse;
 import com.mars.server.server.request.HttpMarsResponse;
 import com.text.api.vo.MessageVO;
 import com.text.api.vo.MessageVO;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 
+import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.Date;
+import java.util.Locale;
+import java.util.TimeZone;
 
 
 @MarsBean
 @MarsBean
 public class TestService {
 public class TestService {
 
 
-    private Logger logger = LoggerFactory.getLogger(TestService.class);
+    private SimpleDateFormat simpleDateFormat = new SimpleDateFormat("E, dd MMM yyyy H:m:s z", Locale.US);
 
 
     public MessageVO json(HttpMarsResponse response){
     public MessageVO json(HttpMarsResponse response){
-        MessageVO messageVO = new MessageVO();
-        messageVO.setMessage("Hello, World!");
+        /*
+            Because this is a purely front-end and back-end separation framework,
+            the response header will include cross-domain by default.
+            In order to adapt to the tfb test, these default headers are removed here.
+         */
+        response.geNativeResponse(MarsHttpExchange.class).getResponseHeaders().clear();
+
+        // Add the header required by tfb
+        String str = simpleDateFormat.format(new Date());
 
 
+        response.setHeader("Content-Type", HttpConstant.RESPONSE_CONTENT_TYPE);
         response.setHeader("Server","Martian");
         response.setHeader("Server","Martian");
-        response.setHeader("Date", "Wed, "+new Date().toGMTString());
+        response.setHeader("Date", str);
 
 
+
+        MessageVO messageVO = new MessageVO();
+        messageVO.setMessage("Hello, World!");
         return messageVO;
         return messageVO;
     }
     }
 }
 }