org.quartz.Matcher Java Examples

The following examples show how to use org.quartz.Matcher. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ListenerManagerImpl.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
public void addJobListener(JobListener jobListener, Matcher<JobKey> matcher) {
    if (jobListener.getName() == null || jobListener.getName().length() == 0) {
        throw new IllegalArgumentException(
                "JobListener name cannot be empty.");
    }
    
    synchronized (globalJobListeners) {
        globalJobListeners.put(jobListener.getName(), jobListener);
        LinkedList<Matcher<JobKey>> matchersL = new  LinkedList<Matcher<JobKey>>();
        if(matcher != null)
            matchersL.add(matcher);
        else
            matchersL.add(EverythingMatcher.allJobs());
        
        globalJobListenersMatchers.put(jobListener.getName(), matchersL);
    }
}
 
Example #2
Source File: Quartz2Adapter.java    From javamelody with Apache License 2.0 6 votes vote down vote up
@Override
public void addGlobalJobListener(JobListener jobGlobalListener) throws SchedulerException {
	final Scheduler defaultScheduler;
	final List<Matcher<JobKey>> allJobs = new ArrayList<Matcher<JobKey>>();
	allJobs.add(EverythingMatcher.allJobs());
	if (Parameter.QUARTZ_DEFAULT_LISTENER_DISABLED.getValueAsBoolean()) {
		defaultScheduler = null;
		LOG.debug("Initialization of Quartz default listener has been disabled");
	} else {
		defaultScheduler = StdSchedulerFactory.getDefaultScheduler();
		defaultScheduler.getListenerManager().addJobListener(jobGlobalListener, allJobs);
	}
	for (final Scheduler scheduler : JobInformations.getAllSchedulers()) {
		if (scheduler != defaultScheduler) {
			scheduler.getListenerManager().addJobListener(jobGlobalListener, allJobs);
		}
	}
}
 
Example #3
Source File: ListenerManagerImpl.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
public void addTriggerListener(TriggerListener triggerListener, Matcher<TriggerKey> matcher) {
    if(matcher == null)
        throw new IllegalArgumentException("Null value not acceptable for matcher.");
    
    if (triggerListener.getName() == null
            || triggerListener.getName().length() == 0) {
        throw new IllegalArgumentException(
                "TriggerListener name cannot be empty.");
    }

    synchronized (globalTriggerListeners) {
        globalTriggerListeners.put(triggerListener.getName(), triggerListener);
        List<Matcher<TriggerKey>> matchers = new LinkedList<Matcher<TriggerKey>>();
        matchers.add(matcher);
        globalTriggerListenersMatchers.put(triggerListener.getName(), matchers);
    }
}
 
Example #4
Source File: ListenerManagerImpl.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
public void addTriggerListener(TriggerListener triggerListener, List<Matcher<TriggerKey>> matchers) {
    if (triggerListener.getName() == null
            || triggerListener.getName().length() == 0) {
        throw new IllegalArgumentException(
                "TriggerListener name cannot be empty.");
    }

    synchronized (globalTriggerListeners) {
        globalTriggerListeners.put(triggerListener.getName(), triggerListener);

        LinkedList<Matcher<TriggerKey>> matchersL = new  LinkedList<Matcher<TriggerKey>>();
        if(matchers != null && matchers.size() > 0)
            matchersL.addAll(matchers);
        else
            matchersL.add(EverythingMatcher.allTriggers());

        globalTriggerListenersMatchers.put(triggerListener.getName(), matchersL);
    }
}
 
Example #5
Source File: ListenerManagerImpl.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
public void addJobListener(JobListener jobListener, List<Matcher<JobKey>> matchers) {
    if (jobListener.getName() == null || jobListener.getName().length() == 0) {
        throw new IllegalArgumentException(
                "JobListener name cannot be empty.");
    }
    
    synchronized (globalJobListeners) {
        globalJobListeners.put(jobListener.getName(), jobListener);
        LinkedList<Matcher<JobKey>> matchersL = new  LinkedList<Matcher<JobKey>>();
        if(matchers != null && matchers.size() > 0)
            matchersL.addAll(matchers);
        else
            matchersL.add(EverythingMatcher.allJobs());
        
        globalJobListenersMatchers.put(jobListener.getName(), matchersL);
    }
}
 
Example #6
Source File: ListenerManagerImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public List<Matcher<JobKey>> getJobListenerMatchers(String listenerName) {
    synchronized (globalJobListeners) {
        List<Matcher<JobKey>> matchers = globalJobListenersMatchers.get(listenerName);
        if(matchers == null)
            return null;
        return Collections.unmodifiableList(matchers);
    }
}
 
Example #7
Source File: AndMatcher.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
protected AndMatcher(Matcher<T> leftOperand, Matcher<T> rightOperand) {
    if(leftOperand == null || rightOperand == null)
        throw new IllegalArgumentException("Two non-null operands required!");
    
    this.leftOperand = leftOperand;
    this.rightOperand = rightOperand;
}
 
Example #8
Source File: QuartzScheduler.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private boolean matchTriggerListener(TriggerListener listener, TriggerKey key) {
    List<Matcher<TriggerKey>> matchers = getListenerManager().getTriggerListenerMatchers(listener.getName());
    if(matchers == null)
        return true;
    for(Matcher<TriggerKey> matcher: matchers) {
        if(matcher.isMatch(key))
            return true;
    }
    return false;
}
 
Example #9
Source File: QuartzScheduler.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private boolean matchJobListener(JobListener listener, JobKey key) {
    List<Matcher<JobKey>> matchers = getListenerManager().getJobListenerMatchers(listener.getName());
    if(matchers == null)
        return true;
    for(Matcher<JobKey> matcher: matchers) {
        if(matcher.isMatch(key))
            return true;
    }
    return false;
}
 
Example #10
Source File: ListenerManagerImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public boolean setTriggerListenerMatchers(String listenerName, List<Matcher<TriggerKey>> matchers)  {
    if(matchers == null)
        throw new IllegalArgumentException("Non-null value not acceptable.");
    
    synchronized (globalTriggerListeners) {
        List<Matcher<TriggerKey>> oldMatchers = globalTriggerListenersMatchers.get(listenerName);
        if(oldMatchers == null)
            return false;
        globalTriggerListenersMatchers.put(listenerName, matchers);
        return true;
    }
}
 
Example #11
Source File: ListenerManagerImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public List<Matcher<TriggerKey>> getTriggerListenerMatchers(String listenerName) {
    synchronized (globalTriggerListeners) {
        List<Matcher<TriggerKey>> matchers = globalTriggerListenersMatchers.get(listenerName);
        if(matchers == null)
            return null;
        return Collections.unmodifiableList(matchers);
    }
}
 
Example #12
Source File: ListenerManagerImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public boolean removeTriggerListenerMatcher(String listenerName, Matcher<TriggerKey> matcher) {
    if(matcher == null)
        throw new IllegalArgumentException("Non-null value not acceptable.");
    
    synchronized (globalTriggerListeners) {
        List<Matcher<TriggerKey>> matchers = globalTriggerListenersMatchers.get(listenerName);
        if(matchers == null)
            return false;
        return matchers.remove(matcher);
    }
}
 
Example #13
Source File: ListenerManagerImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public boolean addTriggerListenerMatcher(String listenerName, Matcher<TriggerKey> matcher) {
    if(matcher == null)
        throw new IllegalArgumentException("Non-null value not acceptable.");
    
    synchronized (globalTriggerListeners) {
        List<Matcher<TriggerKey>> matchers = globalTriggerListenersMatchers.get(listenerName);
        if(matchers == null)
            return false;
        matchers.add(matcher);
        return true;
    }
}
 
Example #14
Source File: ListenerManagerImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public boolean setJobListenerMatchers(String listenerName, List<Matcher<JobKey>> matchers)  {
    if(matchers == null)
        throw new IllegalArgumentException("Non-null value not acceptable.");
    
    synchronized (globalJobListeners) {
        List<Matcher<JobKey>> oldMatchers = globalJobListenersMatchers.get(listenerName);
        if(oldMatchers == null)
            return false;
        globalJobListenersMatchers.put(listenerName, matchers);
        return true;
    }
}
 
Example #15
Source File: ListenerManagerImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public boolean removeJobListenerMatcher(String listenerName, Matcher<JobKey> matcher) {
    if(matcher == null)
        throw new IllegalArgumentException("Non-null value not acceptable.");
    
    synchronized (globalJobListeners) {
        List<Matcher<JobKey>> matchers = globalJobListenersMatchers.get(listenerName);
        if(matchers == null)
            return false;
        return matchers.remove(matcher);
    }
}
 
Example #16
Source File: ListenerManagerImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public boolean addJobListenerMatcher(String listenerName, Matcher<JobKey> matcher) {
    if(matcher == null)
        throw new IllegalArgumentException("Null value not acceptable.");
    
    synchronized (globalJobListeners) {
        List<Matcher<JobKey>> matchers = globalJobListenersMatchers.get(listenerName);
        if(matchers == null)
            return false;
        matchers.add(matcher);
        return true;
    }
}
 
Example #17
Source File: AbstractQuartzTaskManager.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
public AbstractQuartzTaskManager(TaskRepository taskRepository, TaskStore taskStore) throws TaskException {

        this.taskRepository = taskRepository;
        this.scheduler = TasksDSComponent.getScheduler();
        this.taskStore = taskStore;
        try {
            Matcher<TriggerKey> tenantTaskTypeGroupMatcher = GroupMatcher.groupEquals(this.getTenantTaskGroup());
            this.getScheduler().getListenerManager().addTriggerListener(
                    new TaskTriggerListener(this.getTenantTaskGroup()), tenantTaskTypeGroupMatcher);
        } catch (SchedulerException e) {
            throw new TaskException("Error in initiating task trigger listener", TaskException.Code.UNKNOWN, e);
        }
    }
 
Example #18
Source File: OrMatcher.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
protected OrMatcher(Matcher<T> leftOperand, Matcher<T> rightOperand) {
    if(leftOperand == null || rightOperand == null)
        throw new IllegalArgumentException("Two non-null operands required!");
    
    this.leftOperand = leftOperand;
    this.rightOperand = rightOperand;
}
 
Example #19
Source File: NotMatcher.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
protected NotMatcher(Matcher<T> operand) {
    if(operand == null)
        throw new IllegalArgumentException("Non-null operand required!");
    
    this.operand = operand;
}
 
Example #20
Source File: AndMatcher.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public Matcher<T> getRightOperand() {
    return rightOperand;
}
 
Example #21
Source File: ListenerManagerImpl.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public void addTriggerListener(TriggerListener triggerListener, Matcher<TriggerKey> ... matchers) {
    addTriggerListener(triggerListener, Arrays.asList(matchers));
}
 
Example #22
Source File: AndMatcher.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public Matcher<T> getLeftOperand() {
    return leftOperand;
}
 
Example #23
Source File: AndMatcher.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create an AndMatcher that depends upon the result of both of the given matchers.
 */
public static <U extends Key<?>> AndMatcher<U> and(Matcher<U> leftOperand, Matcher<U> rightOperand) {
    return new AndMatcher<U>(leftOperand, rightOperand);
}
 
Example #24
Source File: ListenerManagerImpl.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public void addJobListener(JobListener jobListener, Matcher<JobKey> ... matchers) {
    addJobListener(jobListener, Arrays.asList(matchers));
}
 
Example #25
Source File: OrMatcher.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public Matcher<T> getRightOperand() {
    return rightOperand;
}
 
Example #26
Source File: OrMatcher.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public Matcher<T> getLeftOperand() {
    return leftOperand;
}
 
Example #27
Source File: OrMatcher.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create an OrMatcher that depends upon the result of at least one of the given matchers.
 */
public static <U extends Key<?>> OrMatcher<U> or(Matcher<U> leftOperand, Matcher<U> rightOperand) {
    return new OrMatcher<U>(leftOperand, rightOperand);
}
 
Example #28
Source File: NotMatcher.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public Matcher<T> getOperand() {
    return operand;
}
 
Example #29
Source File: NotMatcher.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create a NotMatcher that reverses the result of the given matcher.
 */
public static <U extends Key<?>> NotMatcher<U> not(Matcher<U> operand) {
    return new NotMatcher<U>(operand);
}