List of usage examples for java.lang Exception getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:com.feilong.commons.core.bean.BeanUtil.java
/** * {@link BeanUtils#getProperty(Object, String)} ?. * /* w w w . j av 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 bean * bean * @param name * ?? * @return BeanUtils? * @throws BeanUtilException * if IllegalAccessException | InvocationTargetException | NoSuchMethodException * @see org.apache.commons.beanutils.BeanUtils#getProperty(Object, String) * @see org.apache.commons.beanutils.PropertyUtils#getProperty(Object, String) * @see com.feilong.commons.core.bean.PropertyUtil#getProperty(Object, String) */ public static String 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, as a String. try { String propertyValue = BeanUtils.getProperty(bean, name); return propertyValue; } catch (Exception e) { log.error(e.getClass().getName(), e); throw new BeanUtilException(e); } }
From source file:com.feilong.commons.core.bean.BeanUtil.java
/** * Properties?, {@link BeanUtils#copyProperties(Object, Object)}<br> * ?:?copy???2Bean???ref<br>//ww w . ja v a 2s . co m * ?? . * * <h3>{@link BeanUtils#copyProperties(Object, Object)} {@link PropertyUtils#copyProperties(Object, Object)}</h3> * * <blockquote> * <ul> * <li>{@link BeanUtils#copyProperties(Object, Object)}??????????</li> * <li>{@link PropertyUtils#copyProperties(Object, Object)} ?????JavaBean???????????.</li> * <li>commons-beanutils v1.9.0? BeanUtils ?? nullPropertyUtils ?? null .<br> * (<b>:</b>commons-beanutils v1.9.0+?,BeanUtilsBean.copyProperties() no longer throws a ConversionException for null properties * of certain data types),?,??commons-beanutils * {@link <a href="http://commons.apache.org/proper/commons-beanutils/javadocs/v1.9.2/RELEASE-NOTES.txt">RELEASE-NOTES.txt</a>}</li> * </ul> * </blockquote> * * @param toObj * * @param fromObj * * @throws BeanUtilException * the bean util exception * @see org.apache.commons.beanutils.BeanUtils#copyProperties(Object, Object) * @see org.apache.commons.beanutils.BeanUtils#copyProperty(Object, String, Object) */ public static void copyProperties(Object toObj, Object fromObj) throws BeanUtilException { if (null == toObj) { throw new IllegalArgumentException("No destination bean/toObj specified"); } if (null == fromObj) { throw new IllegalArgumentException("No origin bean/fromObj specified"); } try { BeanUtils.copyProperties(toObj, fromObj); } catch (Exception e) { log.error(e.getClass().getName(), e); throw new BeanUtilException(e); } }
From source file:org.raegdan.troca.Main.java
private static void printException(Exception e) { err();/* ww w. j a va2 s .c o m*/ err(); out("Error occurred while querying!"); err("Error message: " + e.getMessage()); err("Error class: " + e.getClass().toString()); System.exit(10); }
From source file:com.solace.ExceptionHandler.java
public static void addToDefaults(final ExceptionHandlers.Target.Handler h) { synchronized (m_defaults) { try {//from w w w . j a v a 2 s.c o m Exception exception = ReflectionUtil.<Exception>createInstance(h.getException()); IExceptionHandler handler = ReflectionUtil.<IExceptionHandler>createInstance(h.getClazz()); m_defaults.put(exception.getClass(), handler); } catch (Exception e) { ExceptionHandler.getInstance(ExceptionHandler.class).handle(null, String.format( "Could not load handler exception: {}, class: {}.", h.getException(), h.getClazz()), e); } } }
From source file:ezbake.data.elastic.EzElasticHandler.java
private static void logError(Exception e, AuditEvent evt, String loggerMessage) { evt.failed();//from w w w . jav a 2s. c o m e.printStackTrace(); evt.arg(e.getClass().getName(), e); logger.error(loggerMessage); }
From source file:com.clustercontrol.performance.util.code.CollectorItemCodeTable.java
/** * ????????????/*from ww w .j a va2 s . c om*/ * ? ???[???] * * @param itemCode ? * @param displayName ??? * @return ? */ public static String getFullItemName(String itemCode, String displayName) { m_log.debug("getFullItemName() itemCode = " + itemCode + ", displayName = " + displayName); try { CollectorItemCodeMstData bean = CollectorMasterCache.getCategoryCodeMst(itemCode); String itemName = bean.getItemName(); if (bean.isDeviceSupport().booleanValue()) { itemName = itemName + "[" + displayName + "]"; } m_log.debug("getFullItemName() itemCode = " + itemCode + ", displayName = " + displayName + " : itemName = " + itemName); return itemName; } catch (Exception e) { m_log.warn("getFullItemName() : " + e.getClass().getSimpleName() + ", " + e.getMessage(), e); } m_log.debug("getFullItemName() itemCode = " + itemCode + ", displayName = " + displayName + " : itemName = " + itemCode + " is not found."); return itemCode + " is not found."; }
From source file:org.eel.kitchen.jsonschema.keyword.KeywordFactory.java
/** * Build an invalid validator in the event of instantiation failure * * @param e the exception raised by the instantiation attempt * @return a keyword validator which always fails *//*from w w w . java 2 s . co m*/ private static KeywordValidator invalidValidator(final Class<? extends KeywordValidator> c, final Exception e) { final String className = c.getName(); return new KeywordValidator(className, NodeType.values()) { @Override protected void validate(final ValidationContext context, final ValidationReport report, final JsonNode instance) { final Message.Builder msg = Domain.VALIDATION.newMessage().setMessage("cannot build validator") .setKeyword(className).addInfo("exception", e.getClass().getName()) .addInfo("exceptionMessage", e.getMessage()).setFatal(true); report.addMessage(msg.build()); } @Override public String toString() { return className; } }; }
From source file:com.clustercontrol.notify.util.SendSyslog.java
/** * ????syslog?????????/*from ww w .j a v a 2 s. co m*/ * @param facilityId ?ID * @return */ private static String getSyslogHeaderHost(String facilityId) { JpaTransactionManager jtm = null; // String hostname = HinemosPropertyUtil.getHinemosPropertyStr(PROP_HOSTNAME, null); if (hostname == null) { // undef hostname of syglog header MODE_HOSTNAME = MODE_HOSTNAME_DEFAULT; } else if ("".equals(hostname)) { // invalid hostname of syslog header MODE_HOSTNAME = MODE_HOSTNAME_DEFAULT; } else if ("#[FACILITY_ID]".equals(hostname)) { // use facility_id as hostname of syslog header MODE_HOSTNAME = MODE_HOSTNAME_FACILITYID; } else if ("#[NODE]".equals(hostname)) { // use nodename as hostname of syslog header MODE_HOSTNAME = MODE_HOSTNAME_NODENAME; } else { MODE_HOSTNAME = MODE_HOSTNAME_DEFINED; HOSTNAME_DEFINED = hostname; } try { HOSTNAME_SERVER = InetAddress.getLocalHost().getHostName(); } catch (Exception e) { m_log.warn("static() : " + e.getClass().getSimpleName() + ", " + e.getMessage(), e); } m_log.debug("syslog sender. (mode = " + MODE_HOSTNAME + ", hostname=" + HOSTNAME_DEFINED + ")"); int mode = MODE_HOSTNAME; boolean isBuildinScope = false; // ? if (m_log.isDebugEnabled()) m_log.debug("converting syslog hostname for '" + facilityId + "'. (mode = " + MODE_HOSTNAME + ")"); if (FacilityTreeAttributeConstant.isBuiltinScope(facilityId)) { // ??????????? if (m_log.isDebugEnabled()) m_log.debug("facility '" + facilityId + "' is buildin scope."); isBuildinScope = true; } switch (mode) { case MODE_HOSTNAME_DEFINED: hostname = HOSTNAME_DEFINED; break; case MODE_HOSTNAME_FACILITYID: hostname = isBuildinScope ? HOSTNAME_SERVER : facilityId; break; case MODE_HOSTNAME_NODENAME: try { jtm = new JpaTransactionManager(); jtm.begin(); FacilityInfo facility = new RepositoryControllerBean().getFacilityEntityByPK(facilityId); if (FacilityUtil.isNode(facility)) { hostname = isBuildinScope ? HOSTNAME_SERVER : (facility instanceof NodeInfo ? ((NodeInfo) facility).getNodeName() : null); } else { if (m_log.isDebugEnabled()) m_log.debug("facility '" + facilityId + "' is not node."); hostname = HOSTNAME_SERVER; } jtm.commit(); } catch (Exception e) { hostname = HOSTNAME_SERVER; m_log.warn("getSyslogHeaderHost() use '" + hostname + "' for hostname of syslog header. (facility not found : " + facilityId + ") : " + e.getClass().getSimpleName() + ", " + e.getMessage(), e); if (jtm != null) jtm.rollback(); } finally { if (jtm != null) jtm.close(); } break; default: hostname = HOSTNAME_SERVER; } if (m_log.isDebugEnabled()) m_log.debug("use syslog hostname '" + hostname + "' for '" + facilityId + "'."); return hostname; }
From source file:eu.learnpad.simulator.mon.manager.ResponseDispatcher.java
public static void NotifyMeException(String ruleMatched, String enablerName, Exception exception) { ConsumerProfile enablerMatched = (ConsumerProfile) requestMap.get(ruleMatched); ComplexEventException exceptionRaised = ComplexEventException.Factory.newInstance(); if (exception.getCause() == null) { exceptionRaised.setCauseClassName("null"); } else {//w w w. java 2s . c o m exceptionRaised.setCauseClassName(exception.getCause().getClass().getName()); } exceptionRaised.setClassName(exception.getClass().getName()); exceptionRaised.setLocalizedMessage(exception.getLocalizedMessage()); exceptionRaised.setMessage(exception.getMessage()); exceptionRaised.setStackTrace(exception.getStackTrace().toString()); ResponseDispatcher.sendResponse(exceptionRaised, enablerName, enablerMatched.getAnswerTopic()); DebugMessages.print(TimeStamp.getCurrentTime(), ResponseDispatcher.class.getSimpleName(), "ruleMatched: " + ruleMatched + " - enablerName: " + enablerName + " - evaluationResult: " + exceptionRaised.getClassName()); }
From source file:com.clustercontrol.jobmanagement.util.JobMultiplicityCache.java
/** * ??//from w w w . j av a 2 s .c om * ?????????????????? * * @param facilityId * @return */ public static void kick(String facilityId) { m_log.debug("kick " + facilityId); boolean kickFlag = false; try { _lock.writeLock(); HashMap<String, Queue<JobSessionNodeEntityPK>> waitingCache = getWaitingCache(); HashMap<String, Queue<JobSessionNodeEntityPK>> runningCache = getRunningCache(); Queue<JobSessionNodeEntityPK> waitingQueue = waitingCache.get(facilityId); Queue<JobSessionNodeEntityPK> runningQueue = runningCache.get(facilityId); if (waitingQueue == null || waitingQueue.size() == 0) { return; } if (runningQueue == null) { runningQueue = new LinkedList<JobSessionNodeEntityPK>(); runningCache.put(facilityId, runningQueue); } if (isRunNow(facilityId)) { JpaTransactionManager jtm = new JpaTransactionManager(); try { jtm.begin(); JobSessionNodeEntityPK pk = waitingQueue.peek(); //// waitQueue??(??????) m_log.debug("kick remove waitQueue : " + pk); int status = new JobSessionNodeImpl().wait2running(pk); // ? if (status == 0) { m_log.debug("kick add runningQueue : " + pk); waitingQueue.poll(); //// waitQueue? runningQueue.offer(pk); //// runningQueue? kickFlag = true; } // ?????????? else if (status == 1) { m_log.debug("kick not add runningQueue : " + pk); waitingQueue.poll(); //// waitQueue? kickFlag = true; } jtm.commit(); } catch (Exception e) { m_log.warn("kick : " + e.getClass().getSimpleName() + ", " + e.getMessage(), e); jtm.rollback(); } finally { jtm.close(); } } storeWaitingCache(waitingCache); storeRunningCache(runningCache); if (m_log.isDebugEnabled()) { for (JobSessionNodeEntityPK q : runningQueue) { m_log.debug("kick runningQueue : " + q); } for (JobSessionNodeEntityPK q : waitingQueue) { m_log.debug("kick waitQueue : " + q); } } if (kickFlag) { kick(facilityId); } } finally { _lock.writeUnlock(); } }