@Override public Class<?> loadClass(String name) throws ClassNotFoundException { Class loadedClass = loadedClasses.get(name); if(loadedClass != null) { return loadedClass; } String resName = name.replace('.', '/') + ".class"; byte[] classBytes = archive.getEntryBytes(resName); if(classBytes != null) { loadedClass = defineClass(name, classBytes, 0, classBytes.length); loadedClasses.put(name, loadedClass); return loadedClass; } else { return super.loadClass(name); } }
@Override protected URL findResource(String resName) { URL resource = archive.getEntryURL(resName); if (resource != null) { return resource; } return getParent().getResource(resName); }
private static boolean loadZippedMappingModels(String mappingModelFile, Map<String, EdifactModel> mappingModels, URI baseURI) throws IOException, SAXException, EDIConfigurationException { URIResourceLocator locator = new URIResourceLocator(); locator.setBaseURI(baseURI); InputStream rawZipStream = locator.getResource(mappingModelFile); if(rawZipStream != null) { Archive archive = loadArchive(rawZipStream); if(archive != null) { List<String> rootMappingModels = getMappingModelList(archive); if(rootMappingModels.isEmpty()) { logger.debug("Configured mapping model file '" + mappingModelFile + "' is not a valid Mapping Model zip file. Check that the zip has a valid '" + EDI_MAPPING_MODEL_ZIP_LIST_FILE + "' mapping list file."); return false; } ClassLoader threadCCL = Thread.currentThread().getContextClassLoader(); try { ArchiveClassLoader archiveClassLoader = new ArchiveClassLoader(threadCCL, archive); Thread.currentThread().setContextClassLoader(archiveClassLoader); loadMappingModels(mappingModels, baseURI, rootMappingModels); } finally { Thread.currentThread().setContextClassLoader(threadCCL); } return true; } } return false; }
private static boolean loadZippedMappingModels(String mappingModelFile, Map<String, EdifactModel> mappingModels, URI baseURI) throws IOException, SAXException, EDIConfigurationException { URIResourceLocator locator = new URIResourceLocator(); locator.setBaseURI(baseURI); InputStream rawZipStream = locator.getResource(mappingModelFile); if(rawZipStream != null) { Archive archive = loadArchive(rawZipStream); if(archive != null) { List<String> rootMappingModels = getMappingModelList(archive); if(rootMappingModels.isEmpty()) { logger.debug("Configured mapping model file '" + mappingModelFile + "' is not a valid Mapping Model zip file. Check that the zip has a valid '" + EDI_MAPPING_MODEL_ZIP_LIST_FILE + "' mapping list file."); return false; } ClassLoader threadCCL = Thread.currentThread().getContextClassLoader(); try { ArchiveClassLoader archiveClassLoader = new ArchiveClassLoader(threadCCL, archive); Thread.currentThread().setContextClassLoader(archiveClassLoader); loadMappingModels(mappingModels, baseURI, rootMappingModels); } finally { Thread.currentThread().setContextClassLoader(threadCCL); } return true; } } return false; }
private static boolean loadZippedMappingModels(String mappingModelFile, Map<String, EdifactModel> mappingModels, URI baseURI) throws IOException, SAXException, EDIConfigurationException { URIResourceLocator locator = new URIResourceLocator(); locator.setBaseURI(baseURI); InputStream rawZipStream = locator.getResource(mappingModelFile); if(rawZipStream != null) { Archive archive = loadArchive(rawZipStream); if(archive != null) { List<String> rootMappingModels = getMappingModelList(archive); if(rootMappingModels.isEmpty()) { logger.debug("Configured mapping model file '" + mappingModelFile + "' is not a valid Mapping Model zip file. Check that the zip has a valid '" + EDI_MAPPING_MODEL_ZIP_LIST_FILE + "' mapping list file."); return false; } ClassLoader threadCCL = Thread.currentThread().getContextClassLoader(); try { ArchiveClassLoader archiveClassLoader = new ArchiveClassLoader(threadCCL, archive); Thread.currentThread().setContextClassLoader(archiveClassLoader); loadMappingModels(mappingModels, baseURI, rootMappingModels); } finally { Thread.currentThread().setContextClassLoader(threadCCL); } return true; } } return false; }
@Override protected URL findResource(String resName) { URL resource = archive.getEntryURL(resName); if (resource != null) { return resource; } return getParent().getResource(resName); }
@Override public Class<?> loadClass(String name) throws ClassNotFoundException { Class loadedClass = loadedClasses.get(name); if(loadedClass != null) { return loadedClass; } String resName = name.replace('.', '/') + ".class"; byte[] classBytes = archive.getEntryBytes(resName); if(classBytes != null) { loadedClass = defineClass(name, classBytes, 0, classBytes.length); loadedClasses.put(name, loadedClass); return loadedClass; } else { return super.loadClass(name); } }
private static boolean loadZippedMappingModels(String mappingModelFile, Map<String, EdifactModel> mappingModels, URI baseURI) throws IOException, SAXException, EDIConfigurationException { URIResourceLocator locator = new URIResourceLocator(); locator.setBaseURI(baseURI); InputStream rawZipStream = locator.getResource(mappingModelFile); if(rawZipStream != null) { Archive archive = loadArchive(rawZipStream); if(archive != null) { List<String> rootMappingModels = getMappingModelList(archive); if(rootMappingModels.isEmpty()) { logger.debug("Configured mapping model file '" + mappingModelFile + "' is not a valid Mapping Model zip file. Check that the zip has a valid '" + EDI_MAPPING_MODEL_ZIP_LIST_FILE + "' mapping list file."); return false; } ClassLoader threadCCL = Thread.currentThread().getContextClassLoader(); try { ArchiveClassLoader archiveClassLoader = new ArchiveClassLoader(threadCCL, archive); Thread.currentThread().setContextClassLoader(archiveClassLoader); loadMappingModels(mappingModels, baseURI, rootMappingModels); } finally { Thread.currentThread().setContextClassLoader(threadCCL); } return true; } } return false; }
@Override protected Enumeration<URL> findResources(String resName) throws IOException { List<URL> resources = new ArrayList<URL>(); URL resource = archive.getEntryURL(resName); if (resource != null) { resources.add(resource); } Enumeration<URL> parentResource = getParent().getResources(resName); resources.addAll(Collections.list(parentResource)); return Collections.enumeration(resources); } }
@Override public Class<?> loadClass(String name) throws ClassNotFoundException { Class loadedClass = loadedClasses.get(name); if(loadedClass != null) { return loadedClass; } String resName = name.replace('.', '/') + ".class"; byte[] classBytes = archive.getEntryBytes(resName); if(classBytes != null) { loadedClass = defineClass(name, classBytes, 0, classBytes.length); loadedClasses.put(name, loadedClass); return loadedClass; } else { return super.loadClass(name); } }
@Override protected Enumeration<URL> findResources(String resName) throws IOException { List<URL> resources = new ArrayList<URL>(); URL resource = archive.getEntryURL(resName); if (resource != null) { resources.add(resource); } Enumeration<URL> parentResource = getParent().getResources(resName); resources.addAll(Collections.list(parentResource)); return Collections.enumeration(resources); } }
@Override protected URL findResource(String resName) { URL resource = archive.getEntryURL(resName); if (resource != null) { return resource; } return getParent().getResource(resName); }
@Override protected Enumeration<URL> findResources(String resName) throws IOException { List<URL> resources = new ArrayList<URL>(); URL resource = archive.getEntryURL(resName); if (resource != null) { resources.add(resource); } Enumeration<URL> parentResource = getParent().getResources(resName); resources.addAll(Collections.list(parentResource)); return Collections.enumeration(resources); } }