List of usage examples for java.lang IllegalAccessException printStackTrace
public void printStackTrace()
From source file:com.dp2345.util.SettingUtils.java
/** * ?/*from w w w .jav a2s. co m*/ * * @return */ public static Setting get() { Ehcache cache = cacheManager.getEhcache(Setting.CACHE_NAME); net.sf.ehcache.Element cacheElement = cache.get(Setting.CACHE_KEY); Setting setting; if (cacheElement != null) { setting = (Setting) cacheElement.getObjectValue(); } else { setting = new Setting(); try { File dp2345XmlFile = new ClassPathResource(CommonAttributes.DP2345_XML_PATH).getFile(); Document document = new SAXReader().read(dp2345XmlFile); List<Element> elements = document.selectNodes("/dp2345/setting"); for (Element element : elements) { String name = element.attributeValue("name"); String value = element.attributeValue("value"); try { beanUtils.setProperty(setting, name, value); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } } } catch (Exception e) { e.printStackTrace(); } cache.put(new net.sf.ehcache.Element(Setting.CACHE_KEY, setting)); } return setting; }
From source file:gov.guilin.util.SettingUtils.java
/** * ?/*from w w w .ja v a2 s .c o m*/ * * @return */ public static Setting get() { Ehcache cache = cacheManager.getEhcache(Setting.CACHE_NAME); net.sf.ehcache.Element cacheElement = cache.get(Setting.CACHE_KEY); Setting setting; if (cacheElement != null) { setting = (Setting) cacheElement.getObjectValue(); } else { setting = new Setting(); try { File guilinXmlFile = new ClassPathResource(CommonAttributes.XML_PATH).getFile(); Document document = new SAXReader().read(guilinXmlFile); List<Element> elements = document.selectNodes("/guilin/setting"); for (Element element : elements) { String name = element.attributeValue("name"); String value = element.attributeValue("value"); try { beanUtils.setProperty(setting, name, value); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } } } catch (Exception e) { e.printStackTrace(); } cache.put(new net.sf.ehcache.Element(Setting.CACHE_KEY, setting)); } return setting; }
From source file:com.zigbee.framework.common.util.BeanCopyUtil.java
/** * Apache Copy Properties/*from w w w . j av a2 s .com*/ * @Date : 2011-8-5 * @param srcBean source bean instance * @param destBean destination bean instance * @throws AppException */ public static void beanCopyProperties(Object srcBean, Object destBean) throws AppException { try { org.apache.commons.beanutils.BeanUtils.copyProperties(destBean, srcBean); } catch (IllegalAccessException e) { e.printStackTrace(); String errMsg = "BEAN COPY Exception!" + e.getMessage() + e.getStackTrace(); throw new AppException(CommonErrorConstants.BEAN_COPY_EXCEPTION, errMsg, e.getCause()); } catch (InvocationTargetException e) { e.printStackTrace(); String errMsg = "BEAN COPY Exception!" + e.getMessage() + e.getStackTrace(); throw new AppException(CommonErrorConstants.BEAN_COPY_EXCEPTION, errMsg, e.getCause()); } }
From source file:org.openhie.openempi.util.TestConversions.java
public static void exploringBeanUtils() { Person person = new Person(); person.setAddress1("2930 Oak Shadow Drive"); person.setCity("Oak Hill"); PersonIdentifier id = new PersonIdentifier(); id.setIdentifier("1234"); IdentifierDomain domain = new IdentifierDomain(); domain.setIdentifierDomainName("testDomain"); domain.setNamespaceIdentifier("testDomain"); id.setIdentifierDomain(domain);//from w w w . jav a2s. c o m person.addPersonIdentifier(id); Nationality nationality = new Nationality(); nationality.setNationalityCd(100); person.setNationality(nationality); person.setDateOfBirth(new java.util.Date()); ConvertingWrapDynaBean bean = new ConvertingWrapDynaBean(person); System.out.println("Build a dyna bean using my person:"); System.out.println(bean.get("address1")); System.out.println(bean.get("dateOfBirth")); System.out.println("Changing some of the values."); bean.set("givenName", "Odysseas"); bean.set("familyName", "Pentakalos"); System.out.println(bean.get("nationality.nationalityCd")); bean.set("nationality.nationalityCd", "150"); System.out.println("Value " + bean.get("nationality.nationalityCd") + " is of type " + bean.get("nationality.nationalityCd").getClass()); person = (Person) bean.getInstance(); System.out.println(person); List<String> properties = ConvertUtil.extractProperties(person); for (String property : properties) { System.out.println("Property name is: " + property); } // DynaProperty[] properties = bean.getDynaClass().getDynaProperties(); // for (DynaProperty property : properties) { // System.out.println("The map has the property: " + property.getName() + " which is mapped " + property.getType()); // if (property.getType().getName().startsWith("org.openhie")) { // WrapDynaClass dynaClass = WrapDynaClass.createDynaClass(property.getType()); // DynaProperty[] internalProperties = dynaClass.getDynaProperties(); // for (DynaProperty internalProperty : internalProperties) { // System.out.println("The map has the property: " + property.getName() + "." + internalProperty.getName()); // } // } // } // BeanMap beanMap = new BeanMap(person); // Set<String> properties = beanMap.keySet(); // for (String key : properties) { // System.out.println("The map has the property: " + key); // } org.apache.commons.beanutils.converters.DateConverter converter = new org.apache.commons.beanutils.converters.DateConverter(); converter.setPattern("yyyy.MM.dd HH:mm:ss z"); String[] patterns = converter.getPatterns(); for (String pattern : patterns) { System.out.println("Pattern is " + pattern); } Date now = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss z"); System.out.println(sdf.format(now)); ConvertUtils.register(converter, java.util.Date.class); ConvertUtils convertUtils = new ConvertUtils(); System.out.println(convertUtils.convert("2009.03.06 15:13:29 EST", java.util.Date.class)); try { BeanUtils.setProperty(person, "dateOfBirth", "2009.03.06 15:13:29 EST"); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } System.out.println(bean.get("dateOfBirth")); System.out.println(bean.getDynaClass().getDynaProperty("dateOfBirth")); bean.set("dateOfBirth", "2009.03.06 15:13:29 EST"); System.out.println(bean.get("dateOfBirth")); }
From source file:com.sammyun.util.SettingUtils.java
/** * ?//from w w w . ja v a 2 s . c o m * * @return */ public static Setting get() { Ehcache cache = cacheManager.getEhcache(Setting.CACHE_NAME); net.sf.ehcache.Element cacheElement = cache.get(Setting.CACHE_KEY); Setting setting; if (cacheElement != null) { setting = (Setting) cacheElement.getObjectValue(); } else { setting = new Setting(); try { File preschoolEduXmlFile = new ClassPathResource(CommonAttributes.PRESCHOOLEDU_XML_PATH).getFile(); Document document = new SAXReader().read(preschoolEduXmlFile); List<Element> elements = document.selectNodes("/preschoolEdu/setting"); for (Element element : elements) { String name = element.attributeValue("name"); String value = element.attributeValue("value"); try { beanUtils.setProperty(setting, name, value); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } } } catch (Exception e) { e.printStackTrace(); logger.error(e.getMessage()); } cache.put(new net.sf.ehcache.Element(Setting.CACHE_KEY, setting)); } return setting; }
From source file:com.wedian.site.common.utils.SettingUtils.java
/** * // w ww .j a va 2s. co m * * @param setting * */ public static void set(Setting setting) { try { File shopxxXmlFile = new ClassPathResource(CommonAttributes.SITE_XML_PATH).getFile(); Document document = new SAXReader().read(shopxxXmlFile); List<Element> elements = document.selectNodes("/site/setting"); for (Element element : elements) { try { String name = element.attributeValue("name"); String value = beanUtils.getProperty(setting, name); Attribute attribute = element.attribute("value"); attribute.setValue(value); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } } FileOutputStream fileOutputStream = null; XMLWriter xmlWriter = null; try { OutputFormat outputFormat = OutputFormat.createPrettyPrint(); outputFormat.setEncoding("UTF-8"); outputFormat.setIndent(true); outputFormat.setIndent(" "); outputFormat.setNewlines(true); fileOutputStream = new FileOutputStream(shopxxXmlFile); xmlWriter = new XMLWriter(fileOutputStream, outputFormat); xmlWriter.write(document); } catch (Exception e) { e.printStackTrace(); } finally { if (xmlWriter != null) { try { xmlWriter.close(); } catch (IOException e) { } } IOUtils.closeQuietly(fileOutputStream); } Ehcache cache = cacheManager.getEhcache(Setting.CACHE_NAME); cache.put(new net.sf.ehcache.Element(Setting.CACHE_KEY, setting)); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.iterzp.momo.utils.SettingUtils.java
/** * /*from w w w . j a v a 2 s .co m*/ * * @param setting * */ public static void set(Setting setting) { try { File shopxxXmlFile = new ClassPathResource(CommonAttributes.MOMO_XML_PATH).getFile(); Document document = new SAXReader().read(shopxxXmlFile); List<Element> elements = document.selectNodes("/momo/setting"); for (Element element : elements) { try { String name = element.attributeValue("name"); String value = beanUtils.getProperty(setting, name); Attribute attribute = element.attribute("value"); attribute.setValue(value); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } } FileOutputStream fileOutputStream = null; XMLWriter xmlWriter = null; try { OutputFormat outputFormat = OutputFormat.createPrettyPrint(); outputFormat.setEncoding("UTF-8"); outputFormat.setIndent(true); outputFormat.setIndent(" "); outputFormat.setNewlines(true); fileOutputStream = new FileOutputStream(shopxxXmlFile); xmlWriter = new XMLWriter(fileOutputStream, outputFormat); xmlWriter.write(document); } catch (Exception e) { e.printStackTrace(); } finally { if (xmlWriter != null) { try { xmlWriter.close(); } catch (IOException e) { } } IOUtils.closeQuietly(fileOutputStream); } Ehcache cache = cacheManager.getEhcache(Setting.CACHE_NAME); cache.put(new net.sf.ehcache.Element(Setting.CACHE_KEY, setting)); } catch (Exception e) { e.printStackTrace(); } }
From source file:net.groupbuy.util.SettingUtils.java
/** * /*from w w w . ja v a2 s. c o m*/ * * @param setting * */ public static void set(Setting setting) { try { File shopxxXmlFile = new ClassPathResource(CommonAttributes.SHOPXX_XML_PATH).getFile(); Document document = new SAXReader().read(shopxxXmlFile); List<Element> elements = document.selectNodes("/groupbuy/setting"); for (Element element : elements) { try { String name = element.attributeValue("name"); String value = beanUtils.getProperty(setting, name); Attribute attribute = element.attribute("value"); attribute.setValue(value); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } } FileOutputStream fileOutputStream = null; XMLWriter xmlWriter = null; try { OutputFormat outputFormat = OutputFormat.createPrettyPrint(); outputFormat.setEncoding("UTF-8"); outputFormat.setIndent(true); outputFormat.setIndent(" "); outputFormat.setNewlines(true); fileOutputStream = new FileOutputStream(shopxxXmlFile); xmlWriter = new XMLWriter(fileOutputStream, outputFormat); xmlWriter.write(document); } catch (Exception e) { e.printStackTrace(); } finally { if (xmlWriter != null) { try { xmlWriter.close(); } catch (IOException e) { } } IOUtils.closeQuietly(fileOutputStream); } Ehcache cache = cacheManager.getEhcache(Setting.CACHE_NAME); cache.put(new net.sf.ehcache.Element(Setting.CACHE_KEY, setting)); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.hyeb.util.SettingUtils.java
/** * /* w w w .j av a 2 s.c om*/ * * @param setting * */ public static void set(Setting setting) { try { File shopxxXmlFile = new ClassPathResource(CommonAttributes.SHOPXX_XML_PATH).getFile(); Document document = new SAXReader().read(shopxxXmlFile); List<Element> elements = document.selectNodes("/shopxx/setting"); for (Element element : elements) { try { String name = element.attributeValue("name"); String value = beanUtils.getProperty(setting, name); Attribute attribute = element.attribute("value"); attribute.setValue(value); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } } FileOutputStream fileOutputStream = null; XMLWriter xmlWriter = null; try { OutputFormat outputFormat = OutputFormat.createPrettyPrint(); outputFormat.setEncoding("UTF-8"); outputFormat.setIndent(true); outputFormat.setIndent(" "); outputFormat.setNewlines(true); fileOutputStream = new FileOutputStream(shopxxXmlFile); xmlWriter = new XMLWriter(fileOutputStream, outputFormat); xmlWriter.write(document); } catch (Exception e) { e.printStackTrace(); } finally { if (xmlWriter != null) { try { xmlWriter.close(); } catch (IOException e) { } } IOUtils.closeQuietly(fileOutputStream); } Ehcache cache = cacheManager.getEhcache(Setting.CACHE_NAME); cache.put(new net.sf.ehcache.Element(Setting.CACHE_KEY, setting)); } catch (Exception e) { e.printStackTrace(); } }
From source file:net.osxx.util.SettingUtils.java
/** * /*w w w . ja v a 2 s. c om*/ * * @param setting * */ public static void set(Setting setting) { try { File osxxXmlFile = new ClassPathResource(CommonAttributes.SHOPXX_XML_PATH).getFile(); Document document = new SAXReader().read(osxxXmlFile); List<Element> elements = document.selectNodes("/osxx/setting"); for (Element element : elements) { try { String name = element.attributeValue("name"); String value = beanUtils.getProperty(setting, name); Attribute attribute = element.attribute("value"); attribute.setValue(value); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } } FileOutputStream fileOutputStream = null; XMLWriter xmlWriter = null; try { OutputFormat outputFormat = OutputFormat.createPrettyPrint(); outputFormat.setEncoding("UTF-8"); outputFormat.setIndent(true); outputFormat.setIndent(" "); outputFormat.setNewlines(true); fileOutputStream = new FileOutputStream(osxxXmlFile); xmlWriter = new XMLWriter(fileOutputStream, outputFormat); xmlWriter.write(document); } catch (Exception e) { e.printStackTrace(); } finally { if (xmlWriter != null) { try { xmlWriter.close(); } catch (IOException e) { } } IOUtils.closeQuietly(fileOutputStream); } Ehcache cache = cacheManager.getEhcache(Setting.CACHE_NAME); cache.put(new net.sf.ehcache.Element(Setting.CACHE_KEY, setting)); } catch (Exception e) { e.printStackTrace(); } }