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.discovery.darchrow.bean.PropertyUtil.java

/**
 *  {@link PropertyUtils#setProperty(Object, String, Object)} ?(<b>??</b>).
 * /*from ww w  . j  av  a  2s.  c o  m*/
 * <pre>
 * BeanUtils.setProperty(pt1, &quot;x&quot;, &quot;9&quot;); // 9String
 * PropertyUtils.setProperty(pt1, &quot;x&quot;, 9); // int
 * // BeanUtilsPropertyUtils,?int??
 * </pre>
 * 
 * 
 * <pre>
 * {@code
 * getPropertysetProperty,?2?JavaBean????.
 * Company c = new Company();
 * c.setName("Simple");
 * 
 * Simple?????
 * //Simple
 * LOGGER.debug(BeanUtils.getProperty(c, "name"));
 * 
 * Map???key??
 * //Map
 *     LOGGER.debug(BeanUtils.getProperty(c, "address (A2)"));
 *     HashMap am = new HashMap();
 *     am.put("1","234-222-1222211");
 *     am.put("2","021-086-1232323");
 *     BeanUtils.setProperty(c,"telephone",am);
 * LOGGER.debug(BeanUtils.getProperty(c, "telephone (2)"));
 * 
 * Indexed??[]??ArrayList???.
 * //index
 *     LOGGER.debug(BeanUtils.getProperty(c, "otherInfo[2]"));
 *     BeanUtils.setProperty(c, "product[1]", "NOTES SERVER");
 *     LOGGER.debug(BeanUtils.getProperty(c, "product[1]"));
 * 
 * 3????
 * //nest
 *     LOGGER.debug(BeanUtils.getProperty(c, "employee[1].name"));
 * }
 * </pre>
 *
 * @param bean
 *            Bean whose property is to be modified
 * @param name
 *            Possibly indexed and/or nested name of the property to be modified
 * @param value
 *            Value to which this property is to be set
 * @see org.apache.commons.beanutils.BeanUtils#setProperty(Object, String, Object)
 * @see org.apache.commons.beanutils.PropertyUtils#setProperty(Object, String, Object)
 * @see com.baozun.nebulaplus.bean.BeanUtil#setProperty(Object, String, Object)
 */
public static void setProperty(Object bean, String name, Object value) {
    try {
        //Set the value of the specified property of the specified bean, no matter which property reference format is used, with no type conversions.

        // PropertyUtilsBeanUtils,?????
        PropertyUtils.setProperty(bean, name, value);
    } catch (Exception e) {
        LOGGER.error(e.getClass().getName(), e);
        throw new BeanUtilException(e);
    }
}

From source file:com.discovery.darchrow.bean.PropertyUtil.java

/**
 *  {@link PropertyUtils#getProperty(Object, String)} ?.
 * /*from ww  w .ja v a  2 s . c o  m*/
 * <h3>{@link BeanUtils#getProperty(Object, String) BeanUtils.getProperty}& {@link PropertyUtils#getProperty(Object, String)
 * PropertyUtils.getProperty}:</h3>
 * 
 * <blockquote>
 * <p>
 * {@link BeanUtils#getProperty(Object, String)} ?String,<br>
 * {@link PropertyUtils#getProperty(Object, String)} Object,???
 * </p>
 * </blockquote>
 * 
 * 
 * <h3>:</h3>
 * 
 * <pre>
 * {@code
 * getPropertysetProperty,?2?JavaBean????.
 * Company c = new Company();
 * c.setName("Simple");
 * 
 * Simple?????
 * //Simple
 * LOGGER.debug(BeanUtils.getProperty(c, "name"));
 * 
 * Map???key??
 * //Map
 *     LOGGER.debug(BeanUtils.getProperty(c, "address (A2)"));
 *     HashMap am = new HashMap();
 *     am.put("1","234-222-1222211");
 *     am.put("2","021-086-1232323");
 *     BeanUtils.setProperty(c,"telephone",am);
 * LOGGER.debug(BeanUtils.getProperty(c, "telephone (2)"));
 * 
 * Indexed??[]??ArrayList???.
 * //index
 *     LOGGER.debug(BeanUtils.getProperty(c, "otherInfo[2]"));
 *     BeanUtils.setProperty(c, "product[1]", "NOTES SERVER");
 *     LOGGER.debug(BeanUtils.getProperty(c, "product[1]"));
 * 
 * 3????
 * //nest
 *     LOGGER.debug(BeanUtils.getProperty(c, "employee[1].name"));
 * 
 * }
 * </pre>
 *
 * @param <T>
 *            the generic type
 * @param bean
 *            Bean whose property is to be extracted
 * @param name
 *            Possibly indexed and/or nested name of the property to be extracted
 * @return {@link PropertyUtils#getProperty(Object, String)} ?
 * @see com.baozun.nebulaplus.bean.BeanUtil#getProperty(Object, String)
 * @see org.apache.commons.beanutils.BeanUtils#getProperty(Object, String)
 * @see org.apache.commons.beanutils.PropertyUtils#getProperty(Object, String)
 * @see org.apache.commons.beanutils.PropertyUtilsBean
 */
public static <T> T getProperty(Object bean, String name) {
    //Return the value of the specified property of the specified bean, no matter which property reference format is used, with no type conversions.
    //For more details see PropertyUtilsBean.
    try {
        @SuppressWarnings("unchecked")
        T propertyValue = (T) PropertyUtils.getProperty(bean, name);
        return propertyValue;
    } catch (Exception e) {
        LOGGER.error(e.getClass().getName(), e);
        throw new BeanUtilException(e);
    }
}

From source file:com.feilong.commons.core.bean.PropertyUtil.java

/**
 * <p>/*from  ww  w  .  j  a  v  a  2s. co  m*/
 * <code>bean</code>???/Map.
 * </p>
 * 
 * ???classObject??classjava.lang.Object
 * 
 * @param bean
 *            Bean whose properties are to be extracted
 * @return The set of properties for the bean
 * @throws BeanUtilException
 *             if IllegalAccessException | InvocationTargetException | NoSuchMethodException
 * @see org.apache.commons.beanutils.BeanUtils#describe(Object)
 * @see org.apache.commons.beanutils.PropertyUtils#describe(Object)
 * @see com.feilong.commons.core.bean.BeanUtil#describe(Object)
 */
public static Map<String, Object> describe(Object bean) throws BeanUtilException {
    try {
        //Return the entire set of properties for which the specified bean provides a read method.
        Map<String, Object> propertyMap = PropertyUtils.describe(bean);
        return propertyMap;
    } catch (Exception e) {
        log.error(e.getClass().getName(), e);
        throw new BeanUtilException(e);
    }
}

From source file:com.feilong.commons.core.bean.PropertyUtil.java

/**
 *  {@link PropertyUtils#setProperty(Object, String, Object)} ?(<b>??</b>).
 * //w  ww  . j  av a  2 s  .  c om
 * <pre>
 * 
 * BeanUtils.setProperty(pt1, &quot;x&quot;, &quot;9&quot;); // 9String
 * PropertyUtils.setProperty(pt1, &quot;x&quot;, 9); // int
 * // BeanUtilsPropertyUtils,?int??
 * </pre>
 * 
 * 
 * <pre>
 * {@code
 * getPropertysetProperty,?2?JavaBean????.
 * Company c = new Company();
 * c.setName("Simple");
 * 
 * Simple?????
 * //Simple
 * log.debug(BeanUtils.getProperty(c, "name"));
 * 
 * Map???key??
 * //Map
 *     log.debug(BeanUtils.getProperty(c, "address (A2)"));
 *     HashMap am = new HashMap();
 *     am.put("1","234-222-1222211");
 *     am.put("2","021-086-1232323");
 *     BeanUtils.setProperty(c,"telephone",am);
 * log.debug(BeanUtils.getProperty(c, "telephone (2)"));
 * 
 * Indexed??[]??ArrayList???.
 * //index
 *     log.debug(BeanUtils.getProperty(c, "otherInfo[2]"));
 *     BeanUtils.setProperty(c, "product[1]", "NOTES SERVER");
 *     log.debug(BeanUtils.getProperty(c, "product[1]"));
 * 
 * 3????
 * //nest
 *     log.debug(BeanUtils.getProperty(c, "employee[1].name"));
 * 
 * }
 * </pre>
 * 
 * @param bean
 *            Bean whose property is to be modified
 * @param name
 *            Possibly indexed and/or nested name of the property to be modified
 * @param value
 *            Value to which this property is to be set
 * @throws BeanUtilException
 *             if IllegalAccessException | InvocationTargetException | NoSuchMethodException
 * @see org.apache.commons.beanutils.BeanUtils#setProperty(Object, String, Object)
 * @see org.apache.commons.beanutils.PropertyUtils#setProperty(Object, String, Object)
 * @see com.feilong.commons.core.bean.BeanUtil#setProperty(Object, String, Object)
 */
public static void setProperty(Object bean, String name, Object value) throws BeanUtilException {
    try {
        //Set the value of the specified property of the specified bean, no matter which property reference format is used, with no type conversions.

        // PropertyUtilsBeanUtils,?????
        PropertyUtils.setProperty(bean, name, value);
    } catch (Exception e) {
        log.error(e.getClass().getName(), e);
        throw new BeanUtilException(e);
    }
}

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

/**
 * ID?????/*from w w w  . ja v  a 2 s. c  o m*/
 * 
 * @param notifyGroupId ID
 * @return ????
 */
public static List<NotifyRelationInfo> getNotifyList(String notifyGroupId) {
    try {
        {
            HashMap<String, List<NotifyRelationInfo>> cache = getCache();

            // ?????????????????????????
            // (?????????????????????????)
            List<NotifyRelationInfo> notifyList = cache.get(notifyGroupId);
            if (notifyList != null) {
                return notifyList;
            }

            // ????????????
            if (onCache(notifyGroupId)) {
                return new ArrayList<NotifyRelationInfo>();
            }
        }

        m_log.debug("getNotifyIdList() : Job Master or Job Session. " + notifyGroupId);
        List<NotifyRelationInfo> nriList = QueryUtil.getNotifyRelationInfoByNotifyGroupId(notifyGroupId);
        return nriList;
    } catch (Exception e) {
        m_log.warn("getNotifyList() : " + e.getClass().getSimpleName() + ", " + e.getMessage(), e);
        return new ArrayList<NotifyRelationInfo>(); // ??
    }
}

From source file:com.feilong.commons.core.bean.PropertyUtil.java

/**
 *  {@link PropertyUtils#getProperty(Object, String)} ?.
 * /* w ww . j  a v a  2  s.c om*/
 * <pre>
 * {@code
 * getPropertysetProperty,?2?JavaBean????.
 * Company c = new Company();
 * c.setName("Simple");
 * 
 * Simple?????
 * //Simple
 * log.debug(BeanUtils.getProperty(c, "name"));
 * 
 * Map???key??
 * //Map
 *     log.debug(BeanUtils.getProperty(c, "address (A2)"));
 *     HashMap am = new HashMap();
 *     am.put("1","234-222-1222211");
 *     am.put("2","021-086-1232323");
 *     BeanUtils.setProperty(c,"telephone",am);
 * log.debug(BeanUtils.getProperty(c, "telephone (2)"));
 * 
 * Indexed??[]??ArrayList???.
 * //index
 *     log.debug(BeanUtils.getProperty(c, "otherInfo[2]"));
 *     BeanUtils.setProperty(c, "product[1]", "NOTES SERVER");
 *     log.debug(BeanUtils.getProperty(c, "product[1]"));
 * 
 * 3????
 * //nest
 *     log.debug(BeanUtils.getProperty(c, "employee[1].name"));
 * 
 * }
 * </pre>
 * 
 * <h3>{@link BeanUtils#getProperty(Object, String)}&{@link PropertyUtils#getProperty(Object, String)}</h3>
 * 
 * <blockquote>
 * <p>
 * {@link BeanUtils#getProperty(Object, String)} ?String,<br>
 * {@link PropertyUtils#getProperty(Object, String)} Object,???
 * </p>
 * </blockquote>
 * 
 * @param <T>
 *            the generic type
 * @param bean
 *            Bean whose property is to be extracted
 * @param name
 *            Possibly indexed and/or nested name of the property to be extracted
 * 
 * @return {@link PropertyUtils#getProperty(Object, String)} ?
 * @throws BeanUtilException
 *             if IllegalAccessException | InvocationTargetException | NoSuchMethodException
 * @see com.feilong.commons.core.bean.BeanUtil#getProperty(Object, String)
 * @see org.apache.commons.beanutils.BeanUtils#getProperty(Object, String)
 * @see org.apache.commons.beanutils.PropertyUtils#getProperty(Object, String)
 * @see org.apache.commons.beanutils.PropertyUtilsBean
 */
public static <T> T getProperty(Object bean, String name) throws BeanUtilException {
    //Return the value of the specified property of the specified bean, no matter which property reference format is used, with no type conversions.
    //For more details see PropertyUtilsBean.
    try {
        @SuppressWarnings("unchecked")
        T propertyValue = (T) PropertyUtils.getProperty(bean, name);
        return propertyValue;
    } catch (Exception e) {
        log.error(e.getClass().getName(), e);
        throw new BeanUtilException(e);
    }
}

From source file:com.magnet.plugin.common.helpers.URLHelper.java

public static String checkURLConnection(String urlS, String username, String password) {
    String status = "Error connection to server!";
    FormattedLogger logger = new FormattedLogger(URLHelper.class);
    logger.append("checkURLConnection:" + urlS);
    try {/* ww w  .  ja  v  a  2  s .  co  m*/
        URL url = new URL(urlS);
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();

        if (username != null && username.trim().length() > 0 && password != null
                && password.trim().length() > 0) {
            final String authString = username + ":" + password;
            conn.setRequestProperty("Authorization", "Basic " + Base64.encode(authString.getBytes()));
        }

        conn.setRequestMethod("GET");
        conn.setDoInput(true);

        status = "" + conn.getResponseCode();
        logger.append("Response code:" + status);
        logger.showInfoLog();
    } catch (Exception e) {
        logger.append(">>>" + e.getClass().getName() + " message: " + e.getMessage());
        logger.showErrorLog();
    }
    return status;
}

From source file:au.com.jwatmuff.eventmanager.Main.java

/**
 * Main method./*from w w  w  .  j ava  2 s  .com*/
 */
public static void main(String args[]) {
    LogUtils.setupUncaughtExceptionHandler();

    /* Set timeout for RMI connections - TODO: move to external file */
    System.setProperty("sun.rmi.transport.tcp.handshakeTimeout", "2000");
    updateRmiHostName();

    /*
     * Set up menu bar for Mac
     */
    System.setProperty("apple.laf.useScreenMenuBar", "true");
    System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Event Manager");

    /*
     * Set look and feel to 'system' style
     */
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
        log.info("Failed to set system look and feel");
    }

    /*
     * Set workingDir to a writable folder for storing competitions, settings etc.
     */
    String applicationData = System.getenv("APPDATA");
    if (applicationData != null) {
        workingDir = new File(applicationData, "EventManager");
        if (workingDir.exists() || workingDir.mkdirs()) {
            // redirect logging to writable folder
            LogUtils.reconfigureFileAppenders("log4j.properties", workingDir);
        } else {
            workingDir = new File(".");
        }
    }

    // log version for debugging
    log.info("Running version: " + VISIBLE_VERSION + " (Internal: " + VERSION + ")");

    /*
     * Copy license if necessary
     */
    File license1 = new File("license.lic");
    File license2 = new File(workingDir, "license.lic");
    if (license1.exists() && !license2.exists()) {
        try {
            FileUtils.copyFile(license1, license2);
        } catch (IOException e) {
            log.warn("Failed to copy license from " + license1 + " to " + license2, e);
        }
    }
    if (license1.exists() && license2.exists()) {
        if (license1.lastModified() > license2.lastModified()) {
            try {
                FileUtils.copyFile(license1, license2);
            } catch (IOException e) {
                log.warn("Failed to copy license from " + license1 + " to " + license2, e);
            }
        }
    }

    /*
     * Check if run lock exists, if so ask user if it is ok to continue
     */
    if (!obtainRunLock(false)) {
        int response = JOptionPane.showConfirmDialog(null,
                "Unable to obtain run-lock.\nPlease ensure that no other instances of EventManager are running before continuing.\nDo you wish to continue?",
                "Run-lock detected", JOptionPane.YES_NO_OPTION);
        if (response == JOptionPane.YES_OPTION)
            obtainRunLock(true);
        else
            System.exit(0);
    }

    try {
        LoadWindow loadWindow = new LoadWindow();
        loadWindow.setVisible(true);

        loadWindow.addMessage("Reading settings..");

        /*
         * Read properties from file
         */
        final Properties props = new Properties();
        try {
            Properties defaultProps = PropertiesLoaderUtils
                    .loadProperties(new ClassPathResource("eventmanager.properties"));
            props.putAll(defaultProps);
        } catch (IOException ex) {
            log.error(ex);
        }

        props.putAll(System.getProperties());

        File databaseStore = new File(workingDir, "comps");
        int rmiPort = Integer.parseInt(props.getProperty("eventmanager.rmi.port"));

        loadWindow.addMessage("Loading Peer Manager..");
        log.info("Loading Peer Manager");

        ManualDiscoveryService manualDiscoveryService = new ManualDiscoveryService();
        JmDNSRMIPeerManager peerManager = new JmDNSRMIPeerManager(rmiPort, new File(workingDir, "peerid.dat"));
        peerManager.addDiscoveryService(manualDiscoveryService);

        monitorNetworkInterfaceChanges(peerManager);

        loadWindow.addMessage("Loading Database Manager..");
        log.info("Loading Database Manager");

        DatabaseManager databaseManager = new SQLiteDatabaseManager(databaseStore, peerManager);
        LicenseManager licenseManager = new LicenseManager(workingDir);

        loadWindow.addMessage("Loading Load Competition Dialog..");
        log.info("Loading Load Competition Dialog");

        LoadCompetitionWindow loadCompetitionWindow = new LoadCompetitionWindow(databaseManager, licenseManager,
                peerManager);
        loadCompetitionWindow.setTitle(WINDOW_TITLE);

        loadWindow.dispose();
        log.info("Starting Load Competition Dialog");

        while (true) {
            // reset permission checker to use our license
            licenseManager.updatePermissionChecker();

            GUIUtils.runModalJFrame(loadCompetitionWindow);

            if (loadCompetitionWindow.getSuccess()) {
                DatabaseInfo info = loadCompetitionWindow.getSelectedDatabaseInfo();

                if (!databaseManager.checkLock(info.id)) {
                    String message = "EventManager did not shut down correctly the last time this competition was open. To avoid potential data corruption, you are advised to take the following steps:\n"
                            + "1) Do NOT open this competition\n" + "2) Create a backup of this competition\n"
                            + "3) Delete the competition from this computer\n"
                            + "4) If possible, reload this competition from another computer on the network\n"
                            + "5) Alternatively, you may manually load the backup onto all computers on the network, ensuring the 'Preserve competition ID' option is checked.";
                    String title = "WARNING: Potential Data Corruption Detected";

                    int status = JOptionPane.showOptionDialog(null, message, title, JOptionPane.YES_NO_OPTION,
                            JOptionPane.ERROR_MESSAGE, null,
                            new Object[] { "Cancel (recommended)", "Open anyway" }, "Cancel (recommended)");

                    if (status == 0)
                        continue; // return to load competition window
                }

                SynchronizingWindow syncWindow = new SynchronizingWindow();
                syncWindow.setVisible(true);
                long t = System.nanoTime();
                DistributedDatabase database = databaseManager.activateDatabase(info.id, info.passwordHash);
                long dt = System.nanoTime() - t;
                log.debug(String.format("Initial sync in %dms",
                        TimeUnit.MILLISECONDS.convert(dt, TimeUnit.NANOSECONDS)));
                syncWindow.dispose();

                if (loadCompetitionWindow.isNewDatabase()) {
                    GregorianCalendar calendar = new GregorianCalendar();
                    Date today = calendar.getTime();
                    calendar.set(Calendar.MONTH, Calendar.DECEMBER);
                    calendar.set(Calendar.DAY_OF_MONTH, 31);
                    Date endOfYear = new java.sql.Date(calendar.getTimeInMillis());

                    CompetitionInfo ci = new CompetitionInfo();
                    ci.setName(info.name);
                    ci.setStartDate(today);
                    ci.setEndDate(today);
                    ci.setAgeThresholdDate(endOfYear);
                    //ci.setPasswordHash(info.passwordHash);
                    License license = licenseManager.getLicense();
                    if (license != null) {
                        ci.setLicenseName(license.getName());
                        ci.setLicenseType(license.getType().toString());
                        ci.setLicenseContact(license.getContactPhoneNumber());
                    }
                    database.add(ci);
                }

                // Set PermissionChecker to use database's license type
                String competitionLicenseType = database.get(CompetitionInfo.class, null).getLicenseType();
                PermissionChecker.setLicenseType(LicenseType.valueOf(competitionLicenseType));

                TransactionNotifier notifier = new TransactionNotifier();
                database.setListener(notifier);

                MainWindow mainWindow = new MainWindow();
                mainWindow.setDatabase(database);
                mainWindow.setNotifier(notifier);
                mainWindow.setPeerManager(peerManager);
                mainWindow.setLicenseManager(licenseManager);
                mainWindow.setManualDiscoveryService(manualDiscoveryService);
                mainWindow.setTitle(WINDOW_TITLE);
                mainWindow.afterPropertiesSet();

                TestUtil.setActivatedDatabase(database);

                // show main window (modally)
                GUIUtils.runModalJFrame(mainWindow);

                // shutdown procedures

                // System.exit();

                database.shutdown();
                databaseManager.deactivateDatabase(1500);

                if (mainWindow.getDeleteOnExit()) {
                    for (File file : info.localDirectory.listFiles())
                        if (!file.isDirectory())
                            file.delete();
                    info.localDirectory.deleteOnExit();
                }
            } else {
                // This can cause an RuntimeException - Peer is disconnected
                peerManager.stop();
                System.exit(0);
            }
        }
    } catch (Throwable e) {
        log.error("Error in main function", e);
        String message = e.getMessage();
        if (message == null)
            message = "";
        if (message.length() > 100)
            message = message.substring(0, 97) + "...";
        GUIUtils.displayError(null,
                "An unexpected error has occured.\n\n" + e.getClass().getSimpleName() + "\n" + message);
        System.exit(0);
    }
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccXMsg.CFAccXMsgSchemaMessageFormatter.java

public static String formatRspnException(String separator, Exception e) {
    String retval = "<RspnException "
            + CFLibXmlUtil.formatRequiredXmlString(null, "Name", e.getClass().getName())
            + CFLibXmlUtil.formatRequiredXmlString(separator, "Message", e.getMessage()) + " />";
    return (retval);
}

From source file:org.addhen.birudo.data.net.BaseHttpClient.java

private static void debug(Exception e) {
    Timber.d(CLASS_TAG, "Exception: " + e.getClass().getName() + " " + getRootCause(e).getMessage());
}