Example usage for java.lang Exception getClass

List of usage examples for java.lang Exception getClass

Introduction

In this page you can find the example usage for java.lang Exception getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:com.clustercontrol.hub.util.CollectStringDataUtil.java

private static Long getCollectStringKeyInfoPK(String monitorId, String facilityId, String targetName,
        JpaTransactionManager jtm) {// w  ww.ja  v  a  2s.  co m
    CollectStringKeyInfo collectKeyInfo = null;
    try {
        // collectKeyInfo(?collectorid)?????????????
        m_log.debug("getCollectStringKeyInfoPK() : " + monitorId + ", " + facilityId + "," + targetName);
        collectKeyInfo = QueryUtil
                .getCollectStringKeyPK(new CollectStringKeyInfoPK(monitorId, facilityId, targetName));
        if (collectKeyInfo == null) {
            throw new CollectKeyNotFound();
        }
        return collectKeyInfo.getCollectId();
    } catch (CollectKeyNotFound e) {
        m_log.debug("getCollectStringKeyInfoPK() : CollectKeyNotFound");
        // collectId??????????
        synchronized (maxLock) {
            if (maxId == null) {
                maxId = QueryUtil.getMaxId();//??ID?
                if (maxId == null) {
                    maxId = (long) -1;
                }
            }
            maxId++;
            try {
                HinemosEntityManager em = jtm.getEntityManager();
                collectKeyInfo = new CollectStringKeyInfo(monitorId, facilityId, targetName, maxId);
                em.persist(collectKeyInfo);
                em.flush();
                return collectKeyInfo.getCollectId();
            } catch (Exception e1) {
                m_log.warn("store() : " + e1.getClass().getSimpleName() + ", " + e1.getMessage(), e1);
                if (jtm != null) {
                    jtm.rollback();
                }
            }
        }
    }
    m_log.warn("getId : error");
    return null;
}

From source file:com.clustercontrol.notify.util.NotifyRelationCache.java

public static void refresh() {
    JpaTransactionManager jtm = new JpaTransactionManager();
    if (!jtm.isNestedEm()) {
        m_log.warn("refresh() : transactioin has not been begined.");
        jtm.close();// w w  w.  j a  v  a 2  s  .com
        return;
    }

    try {
        _lock.writeLock();

        long start = HinemosTime.currentTimeMillis();
        new JpaTransactionManager().getEntityManager().clear();
        HashMap<String, List<NotifyRelationInfo>> notifyMap = new HashMap<String, List<NotifyRelationInfo>>();
        List<NotifyRelationInfo> nriList = null;
        try {
            nriList = QueryUtil.getAllNotifyRelationInfoWithoutJob();
        } catch (Exception e) {
            m_log.warn("refresh() : " + e.getClass().getSimpleName() + ", " + e.getMessage(), e);
            return;
        }
        for (NotifyRelationInfo nri : nriList) {
            String notifyGroupId = nri.getId().getNotifyGroupId();
            // ???????????
            if (onCache(notifyGroupId)) {
                List<NotifyRelationInfo> notifyList = notifyMap.get(notifyGroupId);
                if (notifyList == null) {
                    notifyList = new ArrayList<NotifyRelationInfo>();
                    notifyList.add(nri);
                    notifyMap.put(notifyGroupId, notifyList);
                } else {
                    notifyList.add(nri);
                }
            }
        }
        for (List<NotifyRelationInfo> notifyList : notifyMap.values()) {
            if (notifyList == null) {
                continue;
            }
            Collections.sort(notifyList);
        }
        storeCache(notifyMap);
        m_log.info("refresh NotifyRelationCache. " + (HinemosTime.currentTimeMillis() - start) + "ms. size="
                + notifyMap.size());
    } finally {
        _lock.writeUnlock();
    }
}

From source file:com.thruzero.common.core.utils.ExceptionUtilsExt.java

public static LocatorException logAndCreateLocatorException(final Logger logger, final String errorMessage,
        final Exception cause) {
    String err = errorMessage + " - " + cause.getClass().getSimpleName();

    logger.error(err, cause);/*from  www  . j  av a2s.c  o  m*/

    return new LocatorException(err, cause);
}

From source file:com.thruzero.common.core.utils.ExceptionUtilsExt.java

public static IllegalArgumentException logAndCreateIllegalArgumentException(final Logger logger,
        final String errorMessage, final Exception cause) {
    String err = errorMessage + " - " + cause.getClass().getSimpleName();

    logger.error(err, cause);//w ww .  j av a  2  s . co  m

    return new IllegalArgumentException(err, cause);
}

From source file:com.thruzero.common.core.utils.ExceptionUtilsExt.java

public static RuntimeException logAndCreateRuntimeException(final Logger logger, final String errorMessage,
        final Exception cause) {
    String err = errorMessage + " - " + cause.getClass().getSimpleName();

    logger.error(err, cause);/* w w w.  j  a va  2 s.co  m*/

    return new RuntimeException(err, cause);
}

From source file:com.thruzero.common.core.utils.ExceptionUtilsExt.java

public static ClassUtilsException logAndCreateClassUtilsException(final Logger logger,
        final String errorMessage, final Exception cause) {
    String err = errorMessage + " - " + cause.getClass().getSimpleName();

    logger.error(err, cause);//  w  w w  .jav  a2 s  .c  o  m

    return new ClassUtilsException(err, cause);
}

From source file:com.autentia.tnt.util.ApplicationLock.java

public static void refresh() {
    try {/* w  w w  .ja  v a 2  s .c  o  m*/
        Version db = Version.getDatabaseVersion();
        Version code = Version.getApplicationVersion();

        int cmp = db.compareTo(code, Version.MINOR);
        if (cmp == 0) {
            locked = false;
            reason = "msg.notLocked";
            log.info("refresh - database version correct: application unlocked");
        } else if (cmp < 0) {
            locked = true;
            reason = "msg.dbNeedsUpdate";
            log.info("refresh - database version not correct: database needs update");
        } else {
            locked = true;
            reason = "msg.appNeedsUpdate";
            log.info("refresh - database version not correct: application code needs update");
        }
    } catch (Exception e) {
        log.fatal("refresh - exception initializing ApplicationLock: application will not be available", e);
        locked = true;
        reason = e.getMessage() + " (" + e.getClass().getSimpleName() + ")";
    }
}

From source file:org.gc.networktester.util.Util.java

public static String exceptionMessageOrClass(Exception e) {
    return e.getMessage() != null && e.getMessage().length() > 0 ? e.getMessage()
            : e.getClass().getSimpleName();
}

From source file:com.clustercontrol.repository.factory.AgentLibDownloader.java

/**
 * MD5??//from   www  . ja v a 2 s.  c  om
 * @param filepath
 * @return
 * @throws HinemosUnknown 
 */
private static String getMD5(String filepath) throws HinemosUnknown {
    MessageDigest md = null;
    DigestInputStream inStream = null;
    byte[] digest = null;
    try {
        md = MessageDigest.getInstance("MD5");
        inStream = new DigestInputStream(new BufferedInputStream(new FileInputStream(filepath)), md);
        while (inStream.read() != -1) {
        }
        digest = md.digest();
    } catch (Exception e) {
        m_log.warn("getMD5() : filepath=" + filepath + ", " + e.getClass(), e);
    } finally {
        if (inStream != null) {
            try {
                inStream.close();
            } catch (Exception e) {
                m_log.warn("getMD5() : close " + e.getClass(), e);
            }
        }
        if (digest == null)
            throw new HinemosUnknown("MD5 digest is null");
    }
    return hashByte2MD5(digest);
}

From source file:com.zarkonnen.longan.Main.java

static String exception(Exception e) {
    e.printStackTrace();/*from w w  w.java 2 s .c  o m*/
    return e.getMessage() == null ? e.getClass().getName()
            : e.getMessage().replace("\n", " ").replace("\r", " ");
}