JpaTicketRegistry.java 文件源码

java
阅读 20 收藏 0 点赞 0 评论 0

项目:cas-server-4.2.1 作者:
@Override
public void execute(final JobExecutionContext jobExecutionContext) throws JobExecutionException {
    SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);

    try {

        logger.info("Beginning ticket cleanup.");
        logger.debug("Attempting to acquire ticket cleanup lock.");
        if (!this.jpaLockingStrategy.acquire()) {
            logger.info("Could not obtain lock.  Aborting cleanup.");
            return;
        }
        logger.debug("Acquired lock.  Proceeding with cleanup.");

        logger.info("Beginning ticket cleanup...");
        final Collection<Ticket> ticketsToRemove = Collections2.filter(this.getTickets(), new Predicate<Ticket>() {
            @Override
            public boolean apply(final Ticket ticket) {
                if (ticket.isExpired()) {
                    if (ticket instanceof TicketGrantingTicket) {
                        logger.debug("Cleaning up expired ticket-granting ticket [{}]", ticket.getId());
                        logoutManager.performLogout((TicketGrantingTicket) ticket);
                        deleteTicket(ticket.getId());
                    } else if (ticket instanceof ServiceTicket) {
                        logger.debug("Cleaning up expired service ticket [{}]", ticket.getId());
                        deleteTicket(ticket.getId());
                    } else {
                        logger.warn("Unknown ticket type [{} found to clean", ticket.getClass().getSimpleName());
                    }
                    return true;
                }
                return false;
            }
        });
        logger.info("{} expired tickets found and removed.", ticketsToRemove.size());
    } catch (final Exception e) {
        logger.error(e.getMessage(), e);
    } finally {
        logger.debug("Releasing ticket cleanup lock.");
        this.jpaLockingStrategy.release();
        logger.info("Finished ticket cleanup.");
    }

}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号