List of usage examples for java.lang ClassLoader ClassLoader
protected ClassLoader(ClassLoader parent)
From source file:net.firejack.platform.model.service.reverse.ReverseEngineeringService.java
@ProgressStatus(weight = 100, description = "Preparing for reverse engineering...") public void reverseEngineeringProcess(RegistryNodeModel registryNodeModel, String wsdl) throws IOException, InterruptedException, NotFoundException, CannotCompileException, JAXBException { List<EntityModel> models = entityStore.findChildrenByParentId(registryNodeModel.getId(), null); for (EntityModel model : models) { entityStore.deleteRecursiveById(model.getId()); }//from ww w .j a v a 2s . co m File dir = generate(wsdl, registryNodeModel.getName()); ClassLoader classLoader = new ClassLoader(dir); Collection<Class> classes = classLoader.allClasses(); analyze(classes, registryNodeModel); FileUtils.forceDelete(dir); }
From source file:wjhk.jupload2.policies.DefaultUploadPolicy.java
/** @see wjhk.jupload2.policies.UploadPolicy#setLang(String) */ public void setLang(String lang) { this.lang = lang; if (lang == null) { displayInfo("lang = null, taking default language"); locale = Locale.getDefault(); } else {// w ww.ja v a 2 s. c om // If we have a 5 characters lang string, then it should look like // ll_CC, where ll is the language code // and CC is the Country code. if (lang.length() == 5 && (lang.substring(2, 3).equals("_") || lang.substring(2, 3).equals("-"))) { String language = lang.substring(0, 2); String country = lang.substring(3, 5); displayDebug("setLang - language read: " + language, 50); displayDebug("setLang - country read: " + country, 50); locale = new Locale(language, country.toUpperCase()); } else { locale = new Locale(lang); displayDebug("setLang - language read (no country): " + lang, 50); } } /* * Patch given by Patrick Use of a specific class loader. The standard * ResourceBundle checks first for a class that has the name of the * resource bundle. Since there is no such class in the jar file, the * AppletClassLoader makes a http request to the server, which will end * with a 404 since there is no such class either. To avoid this * unnecessary lookup we use a class loader that throws directly a * ClassNotFoundException. After looking for a class (which is * unsuccessful) ResourceBundle looks finally for a properties file. * Therefore we delegate that lookup to the original class loader since * this is in the jar file. */ this.resourceBundle = ResourceBundle.getBundle("lang.lang", locale, // Special class loader, see description above new ClassLoader(this.getClass().getClassLoader()) { /** {@inheritDoc} */ @Override public Class<?> loadClass(String name) throws ClassNotFoundException { throw new ClassNotFoundException(); } /** {@inheritDoc} */ @Override public InputStream getResourceAsStream(String name) { return this.getClass().getClassLoader().getResourceAsStream(name); } }); }