Initialization

master
xueli.xue 9 years ago
parent f60cce5ba7
commit 90f658464e
  1. 12
      xxl-job-admin/src/main/java/com/xxl/job/service/job/RemoteHttpJobBean.java
  2. 2
      xxl-job-admin/src/main/resources/config.properties
  3. 4
      xxl-job-client-demo/src/main/resources/applicationcontext-base.xml
  4. 2
      xxl-job-client-demo/src/main/webapp/WEB-INF/web.xml
  5. 9
      xxl-job-client/pom.xml
  6. 120
      xxl-job-client/src/main/java/com/xxl/job/client/netcom/servlet/XxlJobServlet.java

@ -58,10 +58,16 @@ public class RemoteHttpJobBean extends QuartzJobBean {
params.put(HandlerRepository.TRIGGER_LOG_ID, String.valueOf(jobLog.getId()));
params.put(HandlerRepository.HANDLER_NAME, jobDataMap.get(HandlerRepository.HANDLER_NAME));
params.put(HandlerRepository.HANDLER_PARAMS, jobDataMap.get(HandlerRepository.HANDLER_PARAMS));
String[] postResp = HttpUtil.post(jobDataMap.get(HandlerRepository.HANDLER_ADDRESS), params);
// handler address, netty or servlet
String handler_address = jobDataMap.get(HandlerRepository.HANDLER_ADDRESS);
if (!handler_address.startsWith("http")){
handler_address = "http://" + handler_address + "/";
}
String[] postResp = HttpUtil.post(handler_address, params);
logger.info(">>>>>>>>>>> xxl-job trigger http response, jobLog.id:{}, jobLog:{}", jobLog.getId(), jobLog);
// parse trigger response
String responseMsg = postResp[0];
String exceptionMsg = postResp[1];

@ -1 +1 @@
trigger_log_url=http://localhost:8080/xxl-job-admin/joblog/save
trigger_log_url=http://localhost:8080/joblog/save

@ -11,4 +11,8 @@
<context:component-scan base-package="com.xxl.job.service" />
<bean id="xxlJobJettyServer" class="com.xxl.job.client.netcom.jetty.XxlJobJettyServer" init-method="start">
<property name="port" value="9999" />
</bean>
</beans>

@ -23,7 +23,7 @@
<!-- Xxl Job Servlet -->
<servlet>
<servlet-name>XxlJobServlet</servlet-name>
<servlet-class>com.xxl.job.client.netcom.http.XxlJobServlet</servlet-class>
<servlet-class>com.xxl.job.client.netcom.servlet.XxlJobServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>

@ -24,6 +24,13 @@
<version>2.1</version>
<scope>provided</scope>
</dependency>
<!-- jetty -->
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>7.6.9.v20130131</version>
</dependency>
<!-- slf4j -->
<dependency>
@ -45,7 +52,7 @@
<artifactId>httpclient</artifactId>
<version>4.3.6</version>
</dependency>
</dependencies>
<build>

@ -1,60 +1,60 @@
package com.xxl.job.client.netcom.http;
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.pushHandleQueue(_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
*/
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.pushHandleQueue(_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…
Cancel
Save