Java tutorial
/* Copyright (C) 2012 NTT DATA Corporation This program is free software; you can redistribute it and/or Modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ package com.clustercontrol.selfcheck; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import com.clustercontrol.commons.util.JpaTransactionManager; import com.clustercontrol.selfcheck.monitor.SelfCheckMonitor; /** * ???? */ public class SelfCheckTask implements Runnable { private static Log m_log = LogFactory.getLog(SelfCheckTask.class); private final SelfCheckMonitor monitor; /** * * @param config */ public SelfCheckTask(SelfCheckMonitor monitor) { this.monitor = monitor; } /** * ??? */ @Override public void run() { /** */ JpaTransactionManager tm = null; /** ? */ if (m_log.isDebugEnabled()) m_log.debug("executing self-check. (" + toString() + ")"); try { tm = new JpaTransactionManager(); tm.begin(); // ?? monitor.execute(); tm.commit(); } catch (Exception e) { m_log.warn("run() : " + e.getClass().getSimpleName() + ", " + e.getMessage(), e); if (tm != null) tm.rollback(); } finally { if (tm != null) tm.close(); } if (m_log.isDebugEnabled()) m_log.debug("selfcheck scheduler task is executed. (" + toString() + ")"); } /** * ?????? */ @Override public String toString() { /** ? */ return monitor.toString(); } }