private <T> Class<? extends T> loadBeanType(String classLoaderName, DozerClassLoader classLoader, Class<T> iface) { Class<?> beanType = classLoader.loadClass(classLoaderName); if (beanType != null && !iface.isAssignableFrom(beanType)) { MappingUtils.throwMappingException("Incompatible types: " + iface.getName() + " and " + classLoaderName); } return (Class<? extends T>) beanType; }
public InputSource resolveEntity(String publicId, String systemId) { log.debug("Trying to resolve XML entity with public ID [{}] and system ID [{}]", publicId, systemId); if (systemId != null && systemId.indexOf(DozerConstants.XSD_NAME) > systemId.lastIndexOf("/")) { String fileName = systemId.substring(systemId.indexOf(DozerConstants.XSD_NAME)); log.debug("Trying to locate [{}] in classpath", fileName); try { DozerClassLoader classLoader = BeanContainer.getInstance().getClassLoader(); URL url = classLoader.loadResource(fileName); InputStream stream = url.openStream(); InputSource source = new InputSource(stream); source.setPublicId(publicId); source.setSystemId(systemId); log.debug("Found beanmapping XML Schema [{}] in classpath", systemId); return source; } catch (Exception ex) { log.error("Could not resolve beanmapping XML Schema [" + systemId + "]: not found in classpath", ex); } } // use the default behaviour -> download from website or wherever return null; } }
public static Class<?> loadClass(String name) { BeanContainer container = BeanContainer.getInstance(); DozerClassLoader loader = container.getClassLoader(); return loader.loadClass(name); }
public InputSource resolveEntity(String publicId, String systemId) { log.debug("Trying to resolve XML entity with public ID [{}] and system ID [{}]", publicId, systemId); if (systemId != null && systemId.indexOf(DozerConstants.XSD_NAME) > systemId.lastIndexOf("/")) { String fileName = systemId.substring(systemId.indexOf(DozerConstants.XSD_NAME)); log.debug("Trying to locate [{}] in classpath", fileName); try { DozerClassLoader classLoader = BeanContainer.getInstance().getClassLoader(); URL url = classLoader.loadResource(fileName); InputStream stream = url.openStream(); InputSource source = new InputSource(stream); source.setPublicId(publicId); source.setSystemId(systemId); log.debug("Found beanmapping XML Schema [{}] in classpath", systemId); return source; } catch (Exception ex) { log.error("Could not resolve beanmapping XML Schema [" + systemId + "]: not found in classpath", ex); } } // use the default behaviour -> download from website or wherever return null; } }
public static Class<?> loadClass(String name) { BeanContainer container = BeanContainer.getInstance(); DozerClassLoader loader = container.getClassLoader(); return loader.loadClass(name); }
public MappingFileData read(String fileName) { DozerClassLoader classLoader = BeanContainer.getInstance().getClassLoader(); URL url = classLoader.loadResource(fileName); return read(url); }
public static Class<?> loadClass(String name) { BeanContainer container = BeanContainer.getInstance(); DozerClassLoader loader = container.getClassLoader(); return loader.loadClass(name); }
URL url = classLoader.loadResource(propFileName); if (url == null) { log.warn("Dozer configuration file not found: {}. Using defaults for all Dozer global properties.", propFileName);
public Object create(MappingParameters params, BeanCreationDirective directive) { Class<?> actualClass = directive.getActualClass(); String createMethod = directive.getCreateMethod(); Method method; if (createMethod.contains(".")) { String methodName = createMethod.substring(createMethod.lastIndexOf(".") + 1, createMethod.length()); String typeName = createMethod.substring(0, createMethod.lastIndexOf(".")); DozerClassLoader loader = BeanContainer.getInstance().getClassLoader(); Class<?> type = loader.loadClass(typeName); method = findMethod(type, methodName); } else { method = findMethod(actualClass, createMethod); } return ReflectionUtils.invoke(method, null, null); }
public MappingFileData read(String fileName) { DozerClassLoader classLoader = BeanContainer.getInstance().getClassLoader(); URL url = classLoader.loadResource(fileName); return read(url); }
public Object create(BeanCreationDirective directive) { Class<?> actualClass = directive.getActualClass(); String createMethod = directive.getCreateMethod(); Method method; if (createMethod.contains(".")) { String methodName = createMethod.substring(createMethod.lastIndexOf(".") + 1, createMethod.length()); String typeName = createMethod.substring(0, createMethod.lastIndexOf(".")); DozerClassLoader loader = BeanContainer.getInstance().getClassLoader(); Class type = loader.loadClass(typeName); method = findMethod(type, methodName); } else { method = findMethod(actualClass, createMethod); } return ReflectionUtils.invoke(method, null, null); }
URL url = classLoader.loadResource(propFileName); if (url == null) { log.warn("Dozer configuration file not found: {}. Using defaults for all Dozer global properties.",
public Object create(MappingParameters params, BeanCreationDirective directive) { Class<?> actualClass = directive.getActualClass(); String createMethod = directive.getCreateMethod(); Method method; if (createMethod.contains(".")) { String methodName = createMethod.substring(createMethod.lastIndexOf(".") + 1, createMethod.length()); String typeName = createMethod.substring(0, createMethod.lastIndexOf(".")); DozerClassLoader loader = BeanContainer.getInstance().getClassLoader(); Class<?> type = loader.loadClass(typeName); method = findMethod(type, methodName); } else { method = findMethod(actualClass, createMethod); } return ReflectionUtils.invoke(method, null, null); }
public static URL validateURL(String fileName) { DozerClassLoader classLoader = BeanContainer.getInstance().getClassLoader(); if (fileName == null) { MappingUtils.throwMappingException("File name is null"); } URL url = classLoader.loadResource(fileName); if (url == null) { MappingUtils.throwMappingException("Unable to locate dozer mapping file [" + fileName + "] in the classpath!"); } InputStream stream = null; try { stream = url.openStream(); } catch (IOException e) { MappingUtils.throwMappingException("Unable to open URL input stream for dozer mapping file [" + url + "]"); } finally { if (stream != null) { try { stream.close(); } catch (IOException e) { MappingUtils.throwMappingException("Unable to close input stream for dozer mapping file [" + url + "]"); } } } return url; }
public static URL validateURL(String fileName) { DozerClassLoader classLoader = BeanContainer.getInstance().getClassLoader(); if (fileName == null) { MappingUtils.throwMappingException("File name is null"); } URL url = classLoader.loadResource(fileName); if (url == null) { MappingUtils .throwMappingException("Unable to locate dozer mapping file [" + fileName + "] in the classpath!"); } InputStream stream = null; try { stream = url.openStream(); } catch (IOException e) { MappingUtils.throwMappingException("Unable to open URL input stream for dozer mapping file [" + url + "]"); } finally { if (stream != null) { try { stream.close(); } catch (IOException e) { MappingUtils .throwMappingException("Unable to close input stream for dozer mapping file [" + url + "]"); } } } return url; }