com.github.quartzwebui.service.QuartzWebUIService Maven / Gradle / Ivy
The newest version!
/**
* Licensed under the Apache License, Version 2.0 (the "License");
*/
package com.github.quartzwebui.service;
import com.github.quartzwebui.manager.web.QuartzWebUIManager;
import com.github.quartzwebui.service.strategy.DefaultServiceStrategyURL;
import com.github.quartzwebui.service.strategy.QuartzWebUIServiceContext;
import com.github.quartzwebui.service.strategy.ServiceStrategy;
import com.github.quartzwebui.service.strategy.ServiceStrategyParameter;
import com.github.quartzwebui.service.strategy.ServiceStrategyURL;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* @author quxiucheng [[email protected]]
*/
public class QuartzWebUIService {
/**
* 日志信息
*/
private static final Logger logger = LoggerFactory.getLogger(QuartzWebUIService.class);
private final static QuartzWebUIService instance = new QuartzWebUIService();
public static QuartzWebUIService getInstance() {
return instance;
}
/**
* 业务策略工厂
*/
private ServiceStrategyFactory serviceStrategyFactory = new DefaultServiceStrategyFactory();
public String service(String url, HttpServletRequest request, HttpServletResponse response) {
try {
ServiceStrategy serviceStrategy = serviceStrategyFactory.createStrategy(url);
ServiceStrategyParameter parameter = serviceStrategy.newServiceStrategyParameterInstance();
parameter.translate(request);
ServiceStrategyURL serviceStrategyURL = new DefaultServiceStrategyURL(url);
QuartzWebUIServiceContext context = new QuartzWebUIServiceContext(serviceStrategy);
return context.service(serviceStrategyURL, parameter).json();
} catch (Exception e) {
//e.printStackTrace();
return JSONResult.build(JSONResult.RESULT_CODE_ERROR, e.getMessage()).json();
}
}
/**
* 获取 业务策略工厂
* @return serviceStrategyFactory 业务策略工厂
*/
public ServiceStrategyFactory getServiceStrategyFactory() {
return this.serviceStrategyFactory;
}
/**
* 设置 业务策略工厂
* @param serviceStrategyFactory 业务策略工厂
*/
public void setServiceStrategyFactory(ServiceStrategyFactory serviceStrategyFactory) {
this.serviceStrategyFactory = serviceStrategyFactory;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy