Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected URL[] jbossClassLoader(ClassLoader classLoader) {
- List<URL> urls = new ArrayList<URL>();
- Enumeration<URL> resourceURLs;
- try {
- resourceURLs = classLoader.getResources("");
- while(resourceURLs.hasMoreElements())
- {
- URL resourceURL = resourceURLs.nextElement();
- String strResourceURL = resourceURL.toString();
- if(StringUtils.contains(strResourceURL, ".jar"))
- {
- URLConnection conn = resourceURL.openConnection();
- VirtualFile vf = (VirtualFile)conn.getContent();
- URL jarVFSParentURL = VFSUtils.getPhysicalURL(vf.getParent());
- String jarVFSParentPath = jarVFSParentURL.getFile();
- List<VirtualFile> childrenJarFiles = vf.getParent().getChildren(new VirtualFileFilter() {
- @Override
- public boolean accepts(VirtualFile file) {
- return file.getName().endsWith(".jar");//filter all other than .jars
- }
- });
- if(childrenJarFiles.size() > 2) {
- for (VirtualFile virtualJarFile : childrenJarFiles) {
- //test 1
- URL jarVFSURL = virtualJarFile.getPhysicalFile().toURI().toURL();
- String jarVFSPath = jarVFSURL.getFile();
- urls.add(jarVFSURL);
- //alternatively
- String jarFileLocation = jarVFSParentPath + virtualJarFile.getName();
- File jarFile = new File(jarFileLocation);
- urls.add(jarFile.toURI().toURL());
- }
- break;//while
- }
- }
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- return urls.toArray(new URL[0]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement