List of usage examples for java.lang NoSuchMethodException getMessage
public String getMessage()
From source file:nl.nn.adapterframework.util.Misc.java
public static String getFileSystemFreeSpace() { try {//w w w . j a v a 2 s. c o m Method getFreeSpace = File.class.getMethod("getFreeSpace", (java.lang.Class[]) null); String dirName = System.getProperty("APPSERVER_ROOT_DIR"); if (dirName == null) { dirName = System.getProperty("user.dir"); if (dirName == null) { return null; } } File file = new File(dirName); long l = ((Long) getFreeSpace.invoke(file, (java.lang.Object[]) null)).longValue(); return toFileSize(l); } catch (NoSuchMethodException e) { log.debug("Caught NoSuchMethodException, just not on JDK 1.6: " + e.getMessage()); return null; } catch (Exception e) { log.debug("Caught Exception", e); return null; } }
From source file:nl.nn.adapterframework.util.Misc.java
public static Properties getEnvironmentVariables() throws IOException { Properties props = new Properties(); try {// w ww . j av a 2 s. c om Method getenvs = System.class.getMethod("getenv", (java.lang.Class[]) null); Map env = (Map) getenvs.invoke(null, (java.lang.Object[]) null); for (Iterator it = env.keySet().iterator(); it.hasNext();) { String key = (String) it.next(); String value = (String) env.get(key); props.setProperty(key, value); } } catch (NoSuchMethodException e) { log.debug("Caught NoSuchMethodException, just not on JDK 1.5: " + e.getMessage()); } catch (IllegalAccessException e) { log.debug("Caught IllegalAccessException, using JDK 1.4 method", e); } catch (InvocationTargetException e) { log.debug("Caught InvocationTargetException, using JDK 1.4 method", e); } if (props.size() == 0) { BufferedReader br = null; Process p = null; Runtime r = Runtime.getRuntime(); String OS = System.getProperty("os.name").toLowerCase(); if (OS.indexOf("windows 9") > -1) { p = r.exec("command.com /c set"); } else if ((OS.indexOf("nt") > -1) || (OS.indexOf("windows 20") > -1) || (OS.indexOf("windows xp") > -1)) { p = r.exec("cmd.exe /c set"); } else { //assume Unix p = r.exec("env"); } // props.load(p.getInputStream()); // this does not work, due to potential malformed escape sequences br = new BufferedReader(new InputStreamReader(p.getInputStream())); String line; while ((line = br.readLine()) != null) { int idx = line.indexOf('='); if (idx >= 0) { String key = line.substring(0, idx); String value = line.substring(idx + 1); props.setProperty(key, value); } } } return props; }
From source file:com.liferay.util.PropertyComparator.java
public int compare(Object obj1, Object obj2) { try {/*from w w w .j a va 2 s. c o m*/ for (int i = 0; i < _propertyNames.length; i++) { String propertyName = _propertyNames[i]; Object property1 = PropertyUtils.getProperty(obj1, propertyName); Object property2 = PropertyUtils.getProperty(obj2, propertyName); if (property1 instanceof String) { int result = property1.toString().compareToIgnoreCase(property2.toString()); if (result != 0) { return result; } } if (property1 instanceof Comparable) { int result = ((Comparable) property1).compareTo(property2); if (result != 0) { return result; } } } } catch (NoSuchMethodException nsme) { Logger.error(this, nsme.getMessage(), nsme); } catch (InvocationTargetException ite) { Logger.error(this, ite.getMessage(), ite); } catch (IllegalAccessException iae) { Logger.error(this, iae.getMessage(), iae); } return -1; }
From source file:info.magnolia.objectfactory.DefaultClassFactory.java
private <T> T newInstance(Class<T> c, Object[] params, Invoker<T> invoker) { // TODO -// w w w.j a va2s. c o m // c.isAnnotationPresent(Deprecated) - at class or constructor level, // output a warning - todo bis - use a subclass of java.lang.Deprecated which allows a message try { if (params == null || params.length == 0) { // shortcut return c.newInstance(); } // org.apache.commons.beanutils.ConstructorUtils#getMatchingAccessibleConstructor is private, // otherwise, we'd simply extract a getConstructor() method to implement our 2 newInstance() methods. return invoker.invoke(); } catch (NoSuchMethodException e) { throw new MgnlInstantiationException(e.getMessage(), e); } catch (IllegalAccessException e) { throw new MgnlInstantiationException(e.getMessage(), e); } catch (InvocationTargetException e) { throw new MgnlInstantiationException(e.getMessage(), e); } catch (InstantiationException e) { throw new MgnlInstantiationException(e.getMessage(), e); } }
From source file:org.kordamp.ezmorph.object.ObjectListMorpher.java
private void setMorpher(Morpher morpher) { if (morpher == null) { throw new IllegalArgumentException("morpher can not be null"); }//from w ww .j ava 2 s. c o m this.morpher = morpher; // cache the morph method try { morphMethod = morpher.getClass().getDeclaredMethod("morph", new Class[] { Object.class }); } catch (NoSuchMethodException nsme) { throw new IllegalArgumentException(nsme.getMessage()); } }
From source file:org.pepstock.jem.jbpm.tasks.workitems.CustomMethodWorkItem.java
@Override public int execute(Map<String, Object> parameters) throws Exception { // sets Fields if they are using annotations SetFields.applyByAnnotation(instance); applyByAnnotation(instance, parameters); Method method = null;/* w w w .j a v a 2 s . c om*/ try { // before try to get the method without parms method = clazz.getMethod(methodName); return executeMethod(method, null); } catch (NoSuchMethodException e) { LogAppl.getInstance().ignore(e.getMessage(), e); // if not finds the method without parms, try with a MAP as parm method = clazz.getMethod(methodName, Map.class); return executeMethod(method, loadParameters(parameters)); } }
From source file:org.kordamp.ezmorph.array.ObjectArrayMorpher.java
private void setMorpher(Morpher morpher) { if (morpher == null) { throw new IllegalArgumentException("morpher can not be null"); }/* w w w. ja v a 2 s .c o m*/ if (morpher.morphsTo().isArray()) { throw new IllegalArgumentException("morpher target class can not be an array"); } this.morpher = morpher; this.targetArrayClass = Array.newInstance(morpher.morphsTo(), 1).getClass(); this.target = morpher.morphsTo(); // cache the morph method try { morphMethod = morpher.getClass().getDeclaredMethod("morph", new Class[] { Object.class }); } catch (NoSuchMethodException nsme) { throw new IllegalArgumentException(nsme.getMessage()); } }
From source file:com.googlecode.arit.jul.HandlerResourceScanner.java
public HandlerResourceScanner() { LogManager logManager = LogManager.getLogManager(); Class<? extends LogManager> clazz = logManager.getClass(); try {/* w ww . ja v a 2s. c o m*/ // We only enable the plugin if the getLoggerNames method has not been overridden. // An overridden getLoggerNames method is an indication that the log manager maintains // multiple logger name spaces and that we need a specialized plugin. This is the // case for Tomcat's ClassLoaderLogManager. Note that WebSphere's WsLogManager // overrides getLogger, but not getLoggerNames. if (clazz.getMethod("getLoggerNames").getDeclaringClass().equals(LogManager.class)) { this.logManager = logManager; } else { this.logManager = null; } } catch (NoSuchMethodException ex) { throw new NoSuchMethodError(ex.getMessage()); } }
From source file:com.qcadoo.customTranslation.internal.CustomTranslationManagementServiceImpl.java
private Object getInstanceForEntity(final DataDefinition dataDefinition) { try {//from w w w.java2 s .c o m return MethodUtils.invokeExactMethod(dataDefinition, "getInstanceForEntity", new Object[0]); } catch (NoSuchMethodException e) { throw new IllegalStateException(e.getMessage(), e); } catch (IllegalAccessException e) { throw new IllegalStateException(e.getMessage(), e); } catch (InvocationTargetException e) { throw new IllegalStateException(e.getMessage(), e); } }
From source file:com.qcadoo.customTranslation.internal.CustomTranslationManagementServiceImpl.java
private Session getCurrentSession(final DataDefinition dataDefinition) { Object dataAccessService = FieldUtils.getProtectedFieldValue("dataAccessService", dataDefinition); Object hibernateService = FieldUtils.getProtectedFieldValue("hibernateService", dataAccessService); try {/*from w ww . ja va 2 s .c o m*/ return (Session) MethodUtils.invokeExactMethod(hibernateService, "getCurrentSession", new Object[0]); } catch (NoSuchMethodException e) { throw new IllegalStateException(e.getMessage(), e); } catch (IllegalAccessException e) { throw new IllegalStateException(e.getMessage(), e); } catch (InvocationTargetException e) { throw new IllegalStateException(e.getMessage(), e); } }