// Path: bootique-job/src/main/java/io/bootique/job/Job.java
// public interface Job {
// 
// 	JobMetadata getMetadata();
// 
// 	JobResult run(Map<String, Object> params);
// }
// 
// Path: bootique-job/src/main/java/io/bootique/job/JobListener.java
// public interface JobListener {
// 
//     /**
//      * A method invoked when a job is started. The listener may optionally decide to get notified when the job is
//      * finished by registering a callback function with provided "onFinishedCallbackRegistry".
//      *
//      * @param jobName           the name of a job that generated start event.
//      * @param parameters        parameters passed to the job.
//      * @param onFinishedCallbackRegistry an object that will notify registered consumers when the job that generated this start
//      *                          event is finished.
//      */
//     void onJobStarted(String jobName, Map<String, Object> parameters, Consumer<Consumer<JobResult>> onFinishedCallbackRegistry);
// }
// 
// Path: bootique-job/src/main/java/io/bootique/job/MappedJobListener.java
// public class MappedJobListener<T extends JobListener> {
//     private T listener;
//     private int order;
// 
//     public MappedJobListener(T listener, int order) {
//         this.listener = listener;
//         this.order = order;
//     }
// 
//     public T getListener() {
//         return listener;
//     }
// 
//     public int getOrder() {
//         return order;
//     }
// }


import io.bootique.ModuleExtender;
import io.bootique.di.*;
import io.bootique.job.Job;
import io.bootique.job.JobListener;
import io.bootique.job.MappedJobListener;
import io.bootique.job.lock.LockHandler;
import javax.inject.Provider;
/*
 * Licensed to ObjectStyle LLC under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ObjectStyle LLC licenses
 * this file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package io.bootique.job.runtime;



public class JobModuleExtender extends ModuleExtender<JobModuleExtender> {

    private SetBuilder<Job> jobs;
    private SetBuilder<JobListener> listeners;
    private SetBuilder<MappedJobListener> mappedListeners;
    private MapBuilder<String, LockHandler> lockHandlers;

    public JobModuleExtender(Binder binder) {
        super(binder);
    }

    @Override
    public JobModuleExtender initAllExtensions() {
        contributeListeners();
        contributeMappedListeners();
        contributeJobs();
        contributeLockHandlers();

        return this;
    }

    public JobModuleExtender addJob(Job job) {
        contributeJobs().addInstance(job);
        return this;
    }

// Path: bootique-job/src/main/java/io/bootique/job/Job.java
// public interface Job {
// 
// 	JobMetadata getMetadata();
// 
// 	JobResult run(Map<String, Object> params);
// }
// 
// Path: bootique-job/src/main/java/io/bootique/job/JobListener.java
// public interface JobListener {
// 
//     /**
//      * A method invoked when a job is started. The listener may optionally decide to get notified when the job is
//      * finished by registering a callback function with provided "onFinishedCallbackRegistry".
//      *
//      * @param jobName           the name of a job that generated start event.
//      * @param parameters        parameters passed to the job.
//      * @param onFinishedCallbackRegistry an object that will notify registered consumers when the job that generated this start
//      *                          event is finished.
//      */
//     void onJobStarted(String jobName, Map<String, Object> parameters, Consumer<Consumer<JobResult>> onFinishedCallbackRegistry);
// }
// 
// Path: bootique-job/src/main/java/io/bootique/job/MappedJobListener.java
// public class MappedJobListener<T extends JobListener> {
//     private T listener;
//     private int order;
// 
//     public MappedJobListener(T listener, int order) {
//         this.listener = listener;
//         this.order = order;
//     }
// 
//     public T getListener() {
//         return listener;
//     }
// 
//     public int getOrder() {
//         return order;
//     }
// }


// Path: bootique-job/src/main/java/io/bootique/job/runtime/JobModuleExtender.java
import io.bootique.ModuleExtender;
import io.bootique.di.*;
import io.bootique.job.Job;
import io.bootique.job.JobListener;
import io.bootique.job.MappedJobListener;
import io.bootique.job.lock.LockHandler;
import javax.inject.Provider;

/*
 * Licensed to ObjectStyle LLC under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ObjectStyle LLC licenses
 * this file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package io.bootique.job.runtime;



public class JobModuleExtender extends ModuleExtender<JobModuleExtender> {

    private SetBuilder<Job> jobs;
    private SetBuilder<JobListener> listeners;
    private SetBuilder<MappedJobListener> mappedListeners;
    private MapBuilder<String, LockHandler> lockHandlers;

    public JobModuleExtender(Binder binder) {
        super(binder);
    }

    @Override
    public JobModuleExtender initAllExtensions() {
        contributeListeners();
        contributeMappedListeners();
        contributeJobs();
        contributeLockHandlers();

        return this;
    }

    public JobModuleExtender addJob(Job job) {
        contributeJobs().addInstance(job);
        return this;
    }

    public JobModuleExtender addJob(Class<? extends Job> jobType) {