master
xuxueli 7 years ago
parent 3595d9c062
commit 1970f7f3b8
  1. 2
      xxl-job-admin/src/main/java/com/xxl/job/admin/controller/resolver/WebExceptionResolver.java
  2. 2
      xxl-job-admin/src/main/java/com/xxl/job/admin/core/jobbean/impl/DemoConcurrentJobBean.java
  3. 2
      xxl-job-admin/src/main/java/com/xxl/job/admin/core/jobbean/impl/DemoNomalJobBean.java
  4. 4
      xxl-job-admin/src/main/java/com/xxl/job/admin/core/schedule/XxlJobDynamicScheduler.java
  5. 93
      xxl-job-admin/src/main/java/com/xxl/job/admin/core/util/JacksonUtil.java
  6. 2
      xxl-job-admin/src/main/java/com/xxl/job/admin/core/util/MailUtil.java
  7. 8
      xxl-job-admin/src/main/java/com/xxl/job/admin/service/impl/XxlJobServiceImpl.java
  8. 2
      xxl-job-admin/src/test/java/com/xxl/job/dao/impl/AdminBizTest.java
  9. 4
      xxl-job-core/src/main/java/com/xxl/job/core/glue/GlueFactory.java
  10. 4
      xxl-job-core/src/main/java/com/xxl/job/core/log/XxlJobFileAppender.java
  11. 4
      xxl-job-core/src/main/java/com/xxl/job/core/util/HttpClientUtil.java
  12. 24
      xxl-job-core/src/main/java/com/xxl/job/core/util/JacksonUtil.java

@ -1,7 +1,7 @@
package com.xxl.job.admin.controller.resolver;
import com.xxl.job.admin.core.util.JacksonUtil;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.util.JacksonUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ResponseBody;

@ -21,7 +21,7 @@ package com.xxl.job.admin.core.jobbean.impl;
// try {
// TimeUnit.SECONDS.sleep(10);
// } catch (InterruptedException e) {
// e.printStackTrace();
// logger.error(e.getMessage(), e);
// }
//
// return false;

@ -23,7 +23,7 @@ package com.xxl.job.admin.core.jobbean.impl;
// try {
// TimeUnit.SECONDS.sleep(10);
// } catch (InterruptedException e) {
// e.printStackTrace();
// logger.error(e.getMessage(), e);
// }
//
// return false;

@ -143,7 +143,7 @@ public final class XxlJobDynamicScheduler implements ApplicationContextAware {
}
} catch (SchedulerException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
}
}
@ -377,7 +377,7 @@ public final class XxlJobDynamicScheduler implements ApplicationContextAware {
}
} catch (SchedulerException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
return null;
}
return jobList;

@ -1,93 +0,0 @@
package com.xxl.job.admin.core.util;
import org.codehaus.jackson.JsonGenerationException;
import org.codehaus.jackson.JsonParseException;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.type.TypeReference;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
/**
* Jackson util
*
* 1obj need private and set/get
* 2do not support inner class
*
* @author xuxueli 2015-9-25 18:02:56
*/
public class JacksonUtil {
private final static ObjectMapper objectMapper = new ObjectMapper();
public static ObjectMapper getInstance() {
return objectMapper;
}
/**
* beanarrayListMap --> json
*
* @param obj
* @return json string
* @throws Exception
*/
public static String writeValueAsString(Object obj) {
try {
return getInstance().writeValueAsString(obj);
} catch (JsonGenerationException e) {
e.printStackTrace();
} catch (JsonMappingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
/**
* string --> beanMapList(array)
*
* @param jsonStr
* @param clazz
* @return obj
* @throws Exception
*/
public static <T> T readValue(String jsonStr, Class<T> clazz) {
try {
return getInstance().readValue(jsonStr, clazz);
} catch (JsonParseException e) {
e.printStackTrace();
} catch (JsonMappingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
public static <T> T readValueRefer(String jsonStr, Class<T> clazz) {
try {
return getInstance().readValue(jsonStr, new TypeReference<T>() { });
} catch (JsonParseException e) {
e.printStackTrace();
} catch (JsonMappingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
public static void main(String[] args) {
try {
Map<String, String> map = new HashMap<String, String>();
map.put("aaa", "111");
map.put("bbb", "222");
String json = writeValueAsString(map);
System.out.println(json);
System.out.println(readValue(json, Map.class));
} catch (Exception e) {
e.printStackTrace();
}
}
}

@ -147,7 +147,7 @@ public class MailUtil {
mailSender.send(mimeMessage);
return true;
} catch (Exception e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
}
return false;
}

@ -226,7 +226,7 @@ public class XxlJobServiceImpl implements XxlJobService {
xxlJobLogGlueDao.deleteByJobId(id);
return ReturnT.SUCCESS;
} catch (SchedulerException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
}
return ReturnT.FAIL;
}
@ -241,7 +241,7 @@ public class XxlJobServiceImpl implements XxlJobService {
boolean ret = XxlJobDynamicScheduler.pauseJob(name, group); // jobStatus do not store
return ret?ReturnT.SUCCESS:ReturnT.FAIL;
} catch (SchedulerException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
return ReturnT.FAIL;
}
}
@ -256,7 +256,7 @@ public class XxlJobServiceImpl implements XxlJobService {
boolean ret = XxlJobDynamicScheduler.resumeJob(name, group);
return ret?ReturnT.SUCCESS:ReturnT.FAIL;
} catch (SchedulerException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
return ReturnT.FAIL;
}
}
@ -271,7 +271,7 @@ public class XxlJobServiceImpl implements XxlJobService {
XxlJobDynamicScheduler.triggerJob(name, group);
return ReturnT.SUCCESS;
} catch (SchedulerException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
return ReturnT.FAIL;
}
}

@ -43,7 +43,7 @@ public class AdminBizTest {
AdminBiz adminBiz = (AdminBiz) new NetComClientProxy(AdminBiz.class, addressUrl, accessToken).getObject();
int jobId = 1;
ReturnT<String> returnT = adminBiz.triggerJob(1);
ReturnT<String> returnT = adminBiz.triggerJob(jobId);
Assert.assertTrue(returnT.getCode() == ReturnT.SUCCESS_CODE);
}

@ -75,9 +75,9 @@ public class GlueFactory {
try {
field.set(instance, fieldBean);
} catch (IllegalArgumentException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
} catch (IllegalAccessException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
}
}
}

@ -174,13 +174,13 @@ public class XxlJobFileAppender {
return sb.toString();
}
} catch (IOException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
}
}
}

@ -71,7 +71,7 @@ public class HttpClientUtil {
try {
httpClient.close();
} catch (IOException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
}
}
return responseBytes;
@ -101,7 +101,7 @@ public class HttpClientUtil {
}
return message;
} catch (IOException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
throw e;
}
}

@ -6,6 +6,8 @@ import org.codehaus.jackson.JsonParseException;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.type.TypeReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.HashMap;
@ -20,6 +22,8 @@ import java.util.Map;
* @author xuxueli 2015-9-25 18:02:56
*/
public class JacksonUtil {
private static Logger logger = LoggerFactory.getLogger(JacksonUtil.class);
private final static ObjectMapper objectMapper = new ObjectMapper();
public static ObjectMapper getInstance() {
return objectMapper;
@ -36,11 +40,11 @@ public class JacksonUtil {
try {
return getInstance().writeValueAsString(obj);
} catch (JsonGenerationException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
} catch (JsonMappingException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
} catch (IOException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
}
return null;
}
@ -57,11 +61,11 @@ public class JacksonUtil {
try {
return getInstance().readValue(jsonStr, clazz);
} catch (JsonParseException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
} catch (JsonMappingException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
} catch (IOException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
}
return null;
}
@ -69,11 +73,11 @@ public class JacksonUtil {
try {
return getInstance().readValue(jsonStr, new TypeReference<T>() { });
} catch (JsonParseException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
} catch (JsonMappingException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
} catch (IOException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
}
return null;
}
@ -87,7 +91,7 @@ public class JacksonUtil {
System.out.println(json);
System.out.println(readValue(json, Map.class));
} catch (Exception e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
}
}
}

Loading…
Cancel
Save