private void closeQuietly(InputStream is) { try { if (is != null) is.close(); } catch (IOException e) { if (LOG.isErrorEnabled()) LOG.error("Unable to close input stream", e); } } }
private void closeQuietly(InputStream is) { try { if (is != null) is.close(); } catch (IOException e) { if (LOG.isErrorEnabled()) LOG.error("Unable to close file input stream", e); } }
private static List<URL> getURLs(ClassLoaderInterface classLoader, String[] dirNames) { List<URL> urls = new ArrayList<URL>(); for (String dirName : dirNames) { try { Enumeration<URL> classLoaderURLs = classLoader.getResources(dirName); while (classLoaderURLs.hasMoreElements()) { URL url = classLoaderURLs.nextElement(); urls.add(url); } } catch (IOException ioe) { if (LOG.isErrorEnabled()) LOG.error("Could not read driectory [#0]", ioe, dirName); } } return urls; }
public List<Class> findClasses() { classesNotLoaded.clear(); List<Class> classes = new ArrayList<Class>(); for (ClassInfo classInfo : classInfos.values()) { try { classes.add(classInfo.get()); } catch (Throwable e) { if (LOG.isErrorEnabled()) LOG.error("Error loading class [#0]", e, classInfo.getName()); classesNotLoaded.add(classInfo.getName()); } } return classes; }
public List<Class> findClasses(Test<ClassInfo> test) { classesNotLoaded.clear(); List<Class> classes = new ArrayList<Class>(); for (ClassInfo classInfo : classInfos.values()) { try { if (test.test(classInfo)) { classes.add(classInfo.get()); } } catch (Throwable e) { if (LOG.isErrorEnabled()) LOG.error("Error loading class [#0]", e, classInfo.getName()); classesNotLoaded.add(classInfo.getName()); } } return classes; }
/** * Is the given logger enalbed at the given level? * * @param logger the logger. * @param level the level to check if <code>isXXXEnabled</code>. * @return <tt>true</tt> if enabled, <tt>false</tt> if not. */ private static boolean isLoggerEnabled(Logger logger, String level) { if ("debug".equalsIgnoreCase(level)) { return logger.isDebugEnabled(); } else if ("info".equalsIgnoreCase(level)) { return logger.isInfoEnabled(); } else if ("warn".equalsIgnoreCase(level)) { return logger.isWarnEnabled(); } else if ("error".equalsIgnoreCase(level)) { return logger.isErrorEnabled(); } else if ("fatal".equalsIgnoreCase(level)) { return logger.isFatalEnabled(); } else if ("trace".equalsIgnoreCase(level)) { return logger.isTraceEnabled(); } else { throw new IllegalArgumentException("LogLevel [" + level + "] is not supported"); } }
public List<Class> findClassesInPackage(String packageName, boolean recursive) { classesNotLoaded.clear(); List<Class> classes = new ArrayList<Class>(); for (ClassInfo classInfo : classInfos.values()) { try { if (recursive && classInfo.getPackageName().startsWith(packageName)){ classes.add(classInfo.get()); } else if (classInfo.getPackageName().equals(packageName)){ classes.add(classInfo.get()); } } catch (Throwable e) { if (LOG.isErrorEnabled()) LOG.error("Error loading class [#0]", e, classInfo.getName()); classesNotLoaded.add(classInfo.getName()); } } return classes; }
public List<Class> findAnnotatedClasses(Class<? extends Annotation> annotation) { classesNotLoaded.clear(); List<Class> classes = new ArrayList<Class>(); List<Info> infos = getAnnotationInfos(annotation.getName()); for (Info info : infos) { if (info instanceof ClassInfo) { ClassInfo classInfo = (ClassInfo) info; try { Class clazz = classInfo.get(); // double check via proper reflection if (clazz.isAnnotationPresent(annotation)) { classes.add(clazz); } } catch (Throwable e) { if (LOG.isErrorEnabled()) LOG.error("Error loading class [#0]", e, classInfo.getName()); classesNotLoaded.add(classInfo.getName()); } } } return classes; }
public List<Field> findAnnotatedFields(Class<? extends Annotation> annotation) { classesNotLoaded.clear(); List<ClassInfo> seen = new ArrayList<ClassInfo>(); List<Field> fields = new ArrayList<Field>(); List<Info> infos = getAnnotationInfos(annotation.getName()); for (Info info : infos) { if (info instanceof FieldInfo) { FieldInfo fieldInfo = (FieldInfo) info; ClassInfo classInfo = fieldInfo.getDeclaringClass(); if (seen.contains(classInfo)) continue; seen.add(classInfo); try { Class clazz = classInfo.get(); for (Field field : clazz.getDeclaredFields()) { if (field.isAnnotationPresent(annotation)) { fields.add(field); } } } catch (Throwable e) { if (LOG.isErrorEnabled()) LOG.error("Error loading class [#0]", e, classInfo.getName()); classesNotLoaded.add(classInfo.getName()); } } } return fields; }
public List<Method> findAnnotatedMethods(Class<? extends Annotation> annotation) { classesNotLoaded.clear(); List<ClassInfo> seen = new ArrayList<ClassInfo>(); List<Method> methods = new ArrayList<Method>(); List<Info> infos = getAnnotationInfos(annotation.getName()); for (Info info : infos) { if (info instanceof MethodInfo && !"<init>".equals(info.getName())) { MethodInfo methodInfo = (MethodInfo) info; ClassInfo classInfo = methodInfo.getDeclaringClass(); if (seen.contains(classInfo)) continue; seen.add(classInfo); try { Class clazz = classInfo.get(); for (Method method : clazz.getDeclaredMethods()) { if (method.isAnnotationPresent(annotation)) { methods.add(method); } } } catch (Throwable e) { if (LOG.isErrorEnabled()) LOG.error("Error loading class [#0]", e, classInfo.getName()); classesNotLoaded.add(classInfo.getName()); } } } return methods; }
if (LOG.isErrorEnabled()) LOG.error("Unable to read URL [#0]", e, location.toExternalForm()); readClassDef(className); } catch (Throwable e) { if (LOG.isErrorEnabled()) LOG.error("Unable to read class [#0]", e, className);
public List<Constructor> findAnnotatedConstructors(Class<? extends Annotation> annotation) { classesNotLoaded.clear(); List<ClassInfo> seen = new ArrayList<ClassInfo>(); List<Constructor> constructors = new ArrayList<Constructor>(); List<Info> infos = getAnnotationInfos(annotation.getName()); for (Info info : infos) { if (info instanceof MethodInfo && "<init>".equals(info.getName())) { MethodInfo methodInfo = (MethodInfo) info; ClassInfo classInfo = methodInfo.getDeclaringClass(); if (seen.contains(classInfo)) continue; seen.add(classInfo); try { Class clazz = classInfo.get(); for (Constructor constructor : clazz.getConstructors()) { if (constructor.isAnnotationPresent(annotation)) { constructors.add(constructor); } } } catch (Throwable e) { if (LOG.isErrorEnabled()) LOG.error("Error loading class [#0]", e, classInfo.getName()); classesNotLoaded.add(classInfo.getName()); } } } return constructors; }
if (LOG.isErrorEnabled()) { LOG.error("Failed to convert parameter to string", e);
if (LOG.isErrorEnabled()) { LOG.error("Problem loading properties for #0", ex, clazz.getName());
if (LOG.isErrorEnabled()) { LOG.error("Unable to load saxParserFactory set by system property 'xwork.saxParserFactory': #0", e, parserProp); if (LOG.isErrorEnabled()) { LOG.error("Unable to load saxParserFactory set by system property 'xwork.saxParserFactory': #0", e, parserProp);
toPds = getPropertyDescriptors(to); } catch (IntrospectionException e) { if (LOG.isErrorEnabled()) { LOG.error("An error occured", e);
if (LOG.isErrorEnabled()) { LOG.error("Could not create and/or set value back on to object", e);
if (LOG.isErrorEnabled()) LOG.error("Error building bean", e);
return objectFactory.buildResult(resultConfig, invocationContext.getContextMap()); } catch (Exception e) { if (LOG.isErrorEnabled()) { LOG.error("There was an exception while instantiating the result of type #0", e, resultConfig.getClassName());
if (LOG.isErrorEnabled()) { LOG.error("Unable to verify action [#0] with class [#1], from [#2]", name, className, location);