com.clustercontrol.performance.session.PerformanceControllerBean.java Source code

Java tutorial

Introduction

Here is the source code for com.clustercontrol.performance.session.PerformanceControllerBean.java

Source

/*
    
Copyright (C) 2006 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.performance.session;

import java.util.List;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.clustercontrol.commons.util.JpaTransactionManager;
import com.clustercontrol.fault.HinemosUnknown;
import com.clustercontrol.performance.bean.CollectorItemInfo;
import com.clustercontrol.performance.util.code.CollectorItemCodeTable;
import com.clustercontrol.performance.util.code.CollectorItemTreeItem;

/**
 *????
 * ?? Entity Bean ??????Session Bean ?????
 * 
 * @version 4.0.0
 * @since 1.0.0
 *
 */
public class PerformanceControllerBean {

    //   
    private static Log m_log = LogFactory.getLog(PerformanceControllerBean.class);

    /**
     * ??????
     * 
     * @return ?ID??CollectorItemTreeItem?????HashMap
     */
    public Map<String, CollectorItemTreeItem> getItemCodeMap() throws HinemosUnknown {
        m_log.debug("getItemCodeMap()");

        JpaTransactionManager jtm = null;
        Map<String, CollectorItemTreeItem> map = null;

        try {
            jtm = new JpaTransactionManager();
            jtm.begin();

            map = CollectorItemCodeTable.getItemCodeMap();
            jtm.commit();
        } catch (Exception e) {
            m_log.warn("getItemCodeMap() : " + e.getClass().getSimpleName() + ", " + e.getMessage(), e);
            if (jtm != null)
                jtm.rollback();
            throw new HinemosUnknown(e.getMessage(), e);
        } finally {
            if (jtm != null)
                jtm.close();
        }
        return map;
    }

    /**
     * ?????????
     * ????????????????
     * ???????
     * 
     * @param facilityId ID
     * @return ??????
     * @throws HinemosUnknown
     */
    public List<CollectorItemInfo> getAvailableCollectorItemList(String facilityId) throws HinemosUnknown {
        m_log.debug("getAvailableCollectorItemList() facilityId = " + facilityId);

        JpaTransactionManager jtm = null;
        List<CollectorItemInfo> list = null;
        try {
            jtm = new JpaTransactionManager();
            jtm.begin();

            list = CollectorItemCodeTable.getAvailableCollectorItemList(facilityId);
            jtm.commit();
        } catch (HinemosUnknown e) {
            jtm.rollback();
            throw e;
        } catch (Exception e) {
            m_log.warn("getAvailableCollectorItemList() : " + e.getClass().getSimpleName() + ", " + e.getMessage(),
                    e);
            if (jtm != null)
                jtm.rollback();
            throw new HinemosUnknown(e.getMessage(), e);
        } finally {
            if (jtm != null)
                jtm.close();
        }
        return list;
    }

}