public ExceptionTypeFilter(String expectedType) throws ClassNotFoundException { this(ClassUtils.loadClass(expectedType, ExceptionTypeFilter.class)); }
public PayloadTypeFilter(String expectedType) throws ClassNotFoundException { this(ClassUtils.loadClass(expectedType, PayloadTypeFilter.class)); }
/** * Can be used by serice endpoints to select which service to use based on what's * loaded on the classpath * * @param className The class name to look for * @param currentClass the calling class * @return true if the class is on the path */ public static boolean isClassOnPath(String className, Class currentClass) { try { return (loadClass(className, currentClass) != null); } catch (ClassNotFoundException e) { return false; } }
private static void addToConsumableClasses(String className) { try { consumableClasses.add(ClassUtils.loadClass(className, DefaultMuleMessage.class)); } catch (ClassNotFoundException e) { // ignore } }
protected Class getClass(String className) throws ClassNotFoundException { return ClassUtils.loadClass(className, getClass()); }
protected Class[] stringsToClasses(Collection strings) throws ClassNotFoundException { Class[] classes = new Class[strings.size()]; int index = 0; Iterator string = strings.iterator(); while (string.hasNext()) { classes[index++] = ClassUtils.loadClass((String) string.next(), getClass()); } return classes; }
/** * fetch classes by name to avoid circular dependency between spring module * and devkit support. If the class is in fact present, then it's * added to {@code presentClasses} */ private void fetchExcludedClassByName(String name, List<Class<?>> presentClasses) { try { Class<?> excludedClass = ClassUtils.loadClass(name, getClass()); if (excludedClass != null) { presentClasses.add(excludedClass); } } catch (ClassNotFoundException e) { // silently continue } } }
protected Class<?> loadClass(String name) { String c = name.replace("/", "."); try { return ClassUtils.loadClass(c, classLoader); } catch (ClassNotFoundException e) { if (logger.isWarnEnabled()) { logger.warn(String.format("%s : %s", c, e.toString())); } return null; } }
public static Object instanciateClass(String name, Object[] constructorArgs, ClassLoader classLoader) throws ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException { Class<?> clazz; if (classLoader != null) { clazz = loadClass(name, classLoader); } else { clazz = loadClass(name, ClassUtils.class); } if (clazz == null) { throw new ClassNotFoundException(name); } return instanciateClass(clazz, constructorArgs); }
protected Class<?> removeClassProperty(String name, Properties properties) throws ClassNotFoundException { String clazz = removeProperty(name, properties); if (clazz == null) { return null; } else { return ClassUtils.loadClass(clazz, getClass()); } }
/** * Support string or class parameters */ static Class toClass(Object value) throws ClassNotFoundException { Class clazz; if (value instanceof String) { clazz = ClassUtils.loadClass(value.toString(), value.getClass()); } else if(value instanceof Class) { clazz = (Class)value; } else { throw new IllegalArgumentException("Notification types and listeners must be a Class with fully qualified class name. Value is: " + value); } return clazz; }
public void setPayloadClass(String className) { if (className != null) { try { payloadClass = ClassUtils.loadClass(className, this.getClass()); } catch (ClassNotFoundException e) { log.error("Expected message type not valid: " + e.getMessage()); } } }
public void addIgnoredMethods(ReflectionServiceFactoryBean svcFac, String className) { try { Class<?> c = ClassUtils.loadClass(className, getClass()); for (int i = 0; i < c.getMethods().length; i++) { svcFac.getIgnoredMethods().add(c.getMethods()[i]); } } catch (ClassNotFoundException e) { // can be ignored. } }
public void setPayloadClass(String className) { if (className != null) { try { payloadClass = ClassUtils.loadClass(className, this.getClass()); } catch (ClassNotFoundException e) { log.error("Expected message type not valid: " + e.getMessage()); } } }
public void setResponsePayloadClass(String className) { if (className != null) { try { responsePayloadClass = ClassUtils.loadClass(className, this.getClass()); } catch (ClassNotFoundException e) { log.error("Expected message type not valid: " + e.getMessage()); } } }
public void setResponsePayloadClass(String className) { if (className != null) { try { responsePayloadClass = ClassUtils.loadClass(className, this.getClass()); } catch (ClassNotFoundException e) { log.error("Expected message type not valid: " + e.getMessage()); } } }
protected void printResult(DOMResult result) { // Since mule-module-xml isn't (and can't be) a dependency of mule-core, we don't know // whether we have it on the classpath or not. try { Class xmlUtils = ClassUtils.loadClass(XML_UTILS_CLASS, getClass()); Method toXml = ClassUtils.getMethod(xmlUtils, "toXml", new Class[]{Document.class}); String xml = (String) toXml.invoke(null, new Object[]{result.getNode()}); logger.debug("Transformed document is:\n" + xml); } catch (ClassNotFoundException e) { logger.debug("Unable to print out transformed document because XMLUtils is not on the classpath."); } catch (Exception e) { logger.warn("Unable to dynamically invoke the XMLUtils.toXml() method", e); } }
/** * Returns the {@link Class} object that is associated to the {@code typeElement} * * @param typeElement a {@link TypeElement} which represents a {@link Class} * @param processingEnvironment the current {@link ProcessingEnvironment} * @param <T> the generic type of the returned {@link Class} * @return the {@link Class} represented by {@code typeElement} */ public static <T> Class<T> classFor(TypeElement typeElement, ProcessingEnvironment processingEnvironment) { try { return ClassUtils.loadClass(processingEnvironment.getElementUtils().getBinaryName(typeElement).toString(), typeElement.getClass()); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } }
public static Object instanciateClass(String name, Object[] constructorArgs, Class<?> callingClass) throws ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException { Class<?> clazz = loadClass(name, callingClass); return instanciateClass(clazz, constructorArgs); }
public XStreamFactory(String driverClassName, Map<String, Class<?>> aliases, Set<Class <? extends Converter>> converters) throws ClassNotFoundException, InstantiationException, IllegalAccessException { Class<?> driverClass = ClassUtils.loadClass(driverClassName, this.getClass()); xstream = new XStream((HierarchicalStreamDriver) driverClass.newInstance()); // We must always register this converter as the Mule Message uses // ConcurrentHashMaps, but XStream currently does not support them out of the // box. xstream.registerConverter(new XStreamFactory.ConcurrentHashMapConverter(xstream.getMapper()), -1); registerAliases(aliases); registerConverters(converters); }