parent
7b402a3c8b
commit
0f4c412fcd
9 changed files with 127 additions and 71 deletions
@ -0,0 +1,18 @@ |
||||
package com.xxl.job.client.handler; |
||||
|
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
/** |
||||
* annotation for job handler |
||||
* @author 2016-5-17 21:06:49 |
||||
*/ |
||||
@Target({ElementType.TYPE}) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
public @interface JobHander { |
||||
|
||||
String jobName(); |
||||
|
||||
} |
@ -1,60 +1,61 @@ |
||||
package com.xxl.job.client.netcom.servlet; |
||||
|
||||
|
||||
import java.io.IOException; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
import javax.servlet.ServletException; |
||||
import javax.servlet.http.HttpServlet; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
|
||||
import com.xxl.job.client.handler.HandlerRepository; |
||||
|
||||
|
||||
/** |
||||
* remote job client on http |
||||
* @author xuxueli 2015-12-19 18:36:47 |
||||
*/ |
||||
public class XxlJobServlet extends HttpServlet { |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* Default constructor. |
||||
*/ |
||||
public XxlJobServlet() { |
||||
// TODO Auto-generated constructor stub
|
||||
} |
||||
|
||||
/** |
||||
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) |
||||
*/ |
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { |
||||
request.setCharacterEncoding("UTF-8"); |
||||
response.setCharacterEncoding("UTF-8"); |
||||
|
||||
Map<String, String> _param = new HashMap<String, String>(); |
||||
if (request.getParameterMap()!=null && request.getParameterMap().size()>0) { |
||||
for (Object paramKey : request.getParameterMap().keySet()) { |
||||
if (paramKey!=null) { |
||||
String paramKeyStr = paramKey.toString(); |
||||
_param.put(paramKeyStr, request.getParameter(paramKeyStr)); |
||||
} |
||||
} |
||||
} |
||||
|
||||
String resp = HandlerRepository.service(_param); |
||||
response.getWriter().append(resp); |
||||
return; |
||||
} |
||||
|
||||
/** |
||||
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) |
||||
*/ |
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { |
||||
// TODO Auto-generated method stub
|
||||
doGet(request, response); |
||||
} |
||||
|
||||
} |
||||
//package com.xxl.job.client.netcom.servlet;
|
||||
//
|
||||
//
|
||||
//import java.io.IOException;
|
||||
//import java.util.HashMap;
|
||||
//import java.util.Map;
|
||||
//
|
||||
//import javax.servlet.ServletException;
|
||||
//import javax.servlet.http.HttpServlet;
|
||||
//import javax.servlet.http.HttpServletRequest;
|
||||
//import javax.servlet.http.HttpServletResponse;
|
||||
//
|
||||
//import com.xxl.job.client.handler.HandlerRepository;
|
||||
//
|
||||
//
|
||||
///**
|
||||
// * remote job client on http
|
||||
// * @author xuxueli 2015-12-19 18:36:47
|
||||
// */
|
||||
//@Deprecated
|
||||
//public class XxlJobServlet extends HttpServlet {
|
||||
// private static final long serialVersionUID = 1L;
|
||||
//
|
||||
// /**
|
||||
// * Default constructor.
|
||||
// */
|
||||
// public XxlJobServlet() {
|
||||
// // TODO Auto-generated constructor stub
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
// */
|
||||
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
// request.setCharacterEncoding("UTF-8");
|
||||
// response.setCharacterEncoding("UTF-8");
|
||||
//
|
||||
// Map<String, String> _param = new HashMap<String, String>();
|
||||
// if (request.getParameterMap()!=null && request.getParameterMap().size()>0) {
|
||||
// for (Object paramKey : request.getParameterMap().keySet()) {
|
||||
// if (paramKey!=null) {
|
||||
// String paramKeyStr = paramKey.toString();
|
||||
// _param.put(paramKeyStr, request.getParameter(paramKeyStr));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// String resp = HandlerRepository.service(_param);
|
||||
// response.getWriter().append(resp);
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
// */
|
||||
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
// // TODO Auto-generated method stub
|
||||
// doGet(request, response);
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
Loading…
Reference in new issue