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

org.n3r.quartz.glass.web.util.JobPathScanner Maven / Gradle / Ivy

There is a newer version: 0.0.9
Show newest version
package org.n3r.quartz.glass.web.util;

import org.n3r.quartz.glass.configuration.Configuration;
import org.quartz.Job;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
import org.springframework.core.type.filter.AssignableTypeFilter;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * Scans for classes which are @GlassJob annotated.
 */
@Component
public class JobPathScanner {

    List jobPaths = new ArrayList();

    @Autowired
    private Configuration configuration;

    public List getJobsPaths() {
        return jobPaths;
    }

    @PostConstruct
    protected void scanPaths() {
        ClassPathScanningCandidateComponentProvider provider;
        provider = new ClassPathScanningCandidateComponentProvider(false);
        provider.addIncludeFilter(new AssignableTypeFilter(Job.class));

        String jobBasePackage = configuration.getJobBasePackage();
        for (BeanDefinition definition : provider.findCandidateComponents(jobBasePackage)) {
            jobPaths.add(definition.getBeanClassName());
        }

        Collections.sort(jobPaths);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy