GithubHelp home page GithubHelp logo

silviuilie / reload-quartz Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 2.0 283 KB

pause / resume quartz jobs / triggers or change cron triggers schedule at runtime using simple servlet / spring controller

Java 99.92% Groovy 0.08%

reload-quartz's Introduction

reload-quartz

java/maven build Dependency Status Coverage Status

quartz-scheduler utility

why

if you need to change quartz (>=2.2.1) scheduled job/trigger states (or CronTrigger cron expressions) at runtime.

how to use

  1. as a Servlet

in the deployment descriptor of your application the following context parameters must be used to configure the servlet :

  • quartz-authorization-class class name of the QuartzUtilityAuthorization implementation. optional parameter, if not defined eu.pm.tools.quartz.DefaultQuartzUtilityAuthorization will be used.
  • quartz-jsp-location, location of the JSP files. optional parameter , if not defined /WEB-INF/jsp will be used.

(?) probably the Servlet, rather than Controller configuration should be used since it is easier to configure.

the utility is available by default at <context>/quartz.quartz. see src/main/resources/META-INF/web-fragment.xml for details.

  1. as a spring Controller

create a bean for QuartzApplicationContext to describe the host application :

  • authorization to be performed on the actions.

add a QuartzApplicationContext spring bean in your spring context

 @Bean
 public QuartzApplicationContext quartzjApplicationContext() {
     return new QuartzApplicationContext(QuartzApplicationContext.DEFAULT_AUTHORIZATION);
 }

The default authorization ( QuartzApplicationContext.DEFAULT_AUTHORIZATION ) allows access to quartz utilities to all requests. To restrict access, create your own authorization by implementing QuartzUtilityAuthorization :

@Bean
public CustomAuthorization implements QuartzUtilityAuthorization {
    @Override
    public boolean authorize(HttpSession session) {
        // your auth. code ..
    }
}

and initialize QuartzApplicationContext using it.

configure spring component scanner to include eu.pm.tools.quartz package

@ComponentScan(
        basePackages = {
                // your packages
                "your.packages",
                "eu.pm.tools.quartz"
        }
)

(?) This is needed to enable @Controller class that manages the utility requests.

web.xml configuration

Add the the *.quartz url extension to your DispatcherServlet :

<servlet-mapping>
    <servlet-name>your-spring-servlet-dispatcher-name</servlet-name>
    <url-pattern>*.quartz</url-pattern>
</servlet-mapping>

(?) This is needed to enable your DispatcherServlet to serve the utility requests :

  • quartz.quartz is the "home" of the utility, loads the UI,
  • see QuartzUtility.QUARTZ_UTILITY_* constants for all requests

JSP configuration

If the host application JSPs are not located in the (more or less) standard location /WEB-INF/jsp/, add a new view resolver in your spring configuration with the /WEB-INF/jsp/prefix. Otherwise, no other configuration is required.

reload-quartz's People

Contributors

silviuilie avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.