Package org.apache.roller.pojos

Examples of org.apache.roller.pojos.TaskLockData


       
        // default is "true"!
        boolean locked = true;
       
        try {
            TaskLockData taskLock = this.getTaskLockByName(task.getName());
            if(taskLock != null) {
                locked = taskLock.isLocked();
            } else {
                // if taskLock is null, but we didn't get an exception then
                // that means this lock hasn't been initialized yet
                locked = false;
            }
View Full Code Here


        try {
            Session session = ((HibernatePersistenceStrategy)this.strategy).getSession();
            Criteria criteria = session.createCriteria(TaskLockData.class);
           
            criteria.add(Expression.eq("name", name));
            TaskLockData taskLock = (TaskLockData) criteria.uniqueResult();
           
            return taskLock;
        } catch (HibernateException e) {
            throw new RollerException(e);
        }
View Full Code Here

     */
    public boolean acquireLock(RollerTask task) {
       
        boolean lockAcquired = false;
       
        TaskLockData taskLock = null;
        try {
            taskLock = this.getTaskLockByName(task.getName());
           
            // null here just means hasn't been initialized yet
            if(taskLock == null) {
                taskLock = new TaskLockData();
                taskLock.setName(task.getName());
                taskLock.setLocked(false);
            }
        } catch (RollerException ex) {
            log.warn("Error getting TaskLockData", ex);
            return false;
        }
       
        Date now = new Date();
        Date nextRun = taskLock.getNextRun(task.getInterval());
        if( !taskLock.isLocked() && (nextRun == null || now.after(nextRun))) {
           
            // set appropriate values for TaskLock and save it
            taskLock.setLocked(true);
            taskLock.setTimeAquired(now);
            taskLock.setTimeLeased(task.getLeaseTime());
            taskLock.setLastRun(now);
           
            try {
                // save it *and* flush
                this.saveTaskLock(taskLock);
                RollerFactory.getRoller().flush();
View Full Code Here

     */
    public boolean releaseLock(RollerTask task) {
       
        boolean lockReleased = false;
       
        TaskLockData taskLock = null;
        try {
            taskLock = this.getTaskLockByName(task.getName());
        } catch (RollerException ex) {
            log.warn("Error getting TaskLockData", ex);
            return false;
        }
       
        if(taskLock != null && taskLock.isLocked()) {
            // set appropriate values for TaskLock and save it
            Date now = new Date();
            taskLock.setLocked(false);
           
            try {
                // save it *and* flush
                this.saveTaskLock(taskLock);
                RollerFactory.getRoller().flush();
                lockReleased = true;
            } catch (RollerException ex) {
                log.warn("Error saving TaskLockData", ex);
                lockReleased = false;
            }
        } else if(taskLock != null && !taskLock.isLocked()) {
            // if lock is already released then don't fret about it
            lockReleased = true;
        }
       
        return lockReleased;
View Full Code Here

TOP

Related Classes of org.apache.roller.pojos.TaskLockData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.