001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.scheduler;
016    
017    import com.liferay.portal.kernel.util.ProxyFactory;
018    
019    import java.util.Date;
020    
021    /**
022     * @author Shuyang Zhou
023     */
024    public class TriggerFactoryUtil {
025    
026            public static Trigger createTrigger(
027                    String jobName, String groupName, Date startDate, Date endDate,
028                    int interval, TimeUnit timeUnit) {
029    
030                    return _triggerFactory.createTrigger(
031                            jobName, groupName, startDate, endDate, interval, timeUnit);
032            }
033    
034            public static Trigger createTrigger(
035                    String jobName, String groupName, Date startDate, Date endDate,
036                    String cronExpression) {
037    
038                    return _triggerFactory.createTrigger(
039                            jobName, groupName, startDate, endDate, cronExpression);
040            }
041    
042            public static Trigger createTrigger(
043                    String jobName, String groupName, Date startDate, int interval,
044                    TimeUnit timeUnit) {
045    
046                    return _triggerFactory.createTrigger(
047                            jobName, groupName, startDate, null, interval, timeUnit);
048            }
049    
050            public static Trigger createTrigger(
051                    String jobName, String groupName, Date startDate,
052                    String cronExpression) {
053    
054                    return _triggerFactory.createTrigger(
055                            jobName, groupName, startDate, null, cronExpression);
056            }
057    
058            public static Trigger createTrigger(
059                    String jobName, String groupName, int interval, TimeUnit timeUnit) {
060    
061                    return _triggerFactory.createTrigger(
062                            jobName, groupName, null, null, interval, timeUnit);
063            }
064    
065            public static Trigger createTrigger(
066                    String jobName, String groupName, String cronExpression) {
067    
068                    return _triggerFactory.createTrigger(
069                            jobName, groupName, null, null, cronExpression);
070            }
071    
072            private static final TriggerFactory _triggerFactory =
073                    ProxyFactory.newServiceTrackedInstance(TriggerFactory.class);
074    
075    }