All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.rexsheng.springboot.faster.system.job.adapter.DemoJob Maven / Gradle / Ivy

The newest version!
package com.github.rexsheng.springboot.faster.system.job.adapter;

import com.github.rexsheng.springboot.faster.quartz.plugin.JobLogger;
import com.github.rexsheng.springboot.faster.spring.SpringContext;
import com.github.rexsheng.springboot.faster.system.job.application.JobService;
import jakarta.annotation.Resource;
import org.quartz.JobExecutionContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class DemoJob {

    private static final Logger logger= LoggerFactory.getLogger(DemoJob.class);

    @Resource
    private JobService jobService;

    @Resource
    private JobLogger jobLogger;

    private Integer age;

    private String city;

    public String executeMethod(){
        logger.info("正在执行0, age: {}, jobService: {}",age, jobService);
        jobLogger.info("正在执行1, age: {}, city: {}",age, city);
        if(age==null || age>100){
            throw new RuntimeException("age不能超过100");
        }
        return age+"ed";
    }

    public static void staticMethod(JobExecutionContext context){
        logger.info("正在执行staticMethod: {}",context.getJobDetail().getKey());
        SpringContext.getBeanSafe(JobLogger.class).info("正在执行1: {}",context.getJobDetail().getKey());
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public void setCity(String city) {
        this.city = city;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy