use of com.geccocrawler.gecco.dynamic.JavassistDynamicBean in project dq-easy-cloud by dq-open-cloud.
the class EcReptileUtils method buildJavassistDynamicBean.
/**
* <p>
* 构建动态JavassistDynamicBean对象
* </p>
* <p>
* <pre>
* 所需参数示例及其说明
* 参数名称 : 示例值 : 说明 : 是否必须
* </pre>
*
* @param dynamicBeanDTO
* @return
* @author daiqi
* @创建时间 2018年6月7日 下午7:14:00
*/
private static JavassistDynamicBean buildJavassistDynamicBean(EcReptileDynamicBeanDTO dynamicBeanDTO) {
if (EcCollectionsUtils.isEmpty(dynamicBeanDTO.getMatchUrlList())) {
throw new EcBaseBusinessException(EcBaseErrorCodeEnum.LIST_NULL, "matchUrlList");
}
if (EcCollectionsUtils.isEmpty(dynamicBeanDTO.getPipelineNameList())) {
throw new EcBaseBusinessException(EcBaseErrorCodeEnum.LIST_NULL, "pipelineNameList");
}
JavassistDynamicBean dynamicBean;
if (EcStringUtils.isNotEmpty(dynamicBeanDTO.getBeanClassNameBody()) && EcStringUtils.isNotEmpty(dynamicBeanDTO.getBeanClassFullName())) {
dynamicBean = DynamicGecco.html(dynamicBeanDTO.getBeanClassFullName());
} else {
dynamicBean = DynamicGecco.html();
}
List<String> matchUrls = dynamicBeanDTO.getMatchUrlList();
// 获取matchUrl
List<String> pipelineNameList = dynamicBeanDTO.getPipelineNameList();
dynamicBean.gecco(matchUrls.toArray(new String[matchUrls.size()]), pipelineNameList.toArray(new String[pipelineNameList.size()]));
return dynamicBean;
}
use of com.geccocrawler.gecco.dynamic.JavassistDynamicBean in project dq-easy-cloud by dq-open-cloud.
the class EcReptileUtils method loadReptileEngineRule.
/**
* <p>
* 加载爬虫引擎的规则
* </p>
* <p>
* <pre>
* 所需参数示例及其说明
* 参数名称 : 示例值 : 说明 : 是否必须
* </pre>
*
* @param dynamicBeanDTO
* @return
* @author daiqi
* @创建时间 2018年6月7日 下午6:45:26
*/
public static void loadReptileEngineRule(EcReptileDynamicBeanDTO dynamicBeanDTO) {
// 构建JavassistDynamicBean
JavassistDynamicBean dynamicBean = buildJavassistDynamicBean(dynamicBeanDTO);
// 构建规则属性列表
buildDynamicField(dynamicBean, dynamicBeanDTO);
// 加载class
loadReptileRuleClass(dynamicBean);
}
use of com.geccocrawler.gecco.dynamic.JavassistDynamicBean in project dq-easy-cloud by dq-open-cloud.
the class EcReptileUtils method unLoadReptileRuleClass.
/**
* <p>
* 从引擎中下线相关规则
* </p>
*
* @return void
* @author daiqi
* @date 2018/6/12 17:04
*/
public static synchronized void unLoadReptileRuleClass() {
EcReptileEngineBeanClassDTO reptileEngineBeanClassDTO = EcReptileConfig.getReptileEngineBeanClassDTO();
for (JavassistDynamicBean javassistDynamicBean : reptileEngineBeanClassDTO.getJavassistDynamicBeans()) {
javassistDynamicBean.unloadClass();
}
reptileEngineBeanClassDTO.clearJavassistDynamicBeans();
reptileEngineBeanClassDTO.clearRuleBeanClazzs();
}
Aggregations