protected Archive getResolvedArchive(String mfValue, EARFile ear) { String aUri = ArchiveUtil.deriveEARRelativeURI(mfValue, this); if (aUri == null) return null; try { return (Archive) ear.getFile(aUri); } catch (FileNotFoundException ex) { return null; } catch (ClassCastException ex2) { return null; } }
/** * Leverage the java.io.File apis to resolve things like "./xxx" and "../xxx" into uris of * entries in the ear file * * @param classpathEntry - * a classpath entry from the manifest of * @anArchive * @param anArchive - * the archive to which the dependent jar is relative * * @return a cananonicalized relative uri of an entry in an ear file representing the dependent * jar */ public static String deriveEARRelativeURI(String classpathEntry, Archive anArchive) { return deriveEARRelativeURI(classpathEntry, anArchive.getURI()); }
public void setSelected(Archive referencingJar, Archive referencedJar, List classPath) { for (int i = 0; i < classPath.size(); i++) { String cpEntry = (String) classPath.get(i); String uri = ArchiveUtil.deriveEARRelativeURI(cpEntry, referencingJar); if (uri != null && uri.equals(referencedJar.getURI())) { setSelected(true); return; } } setSelected(false); }
public static List normalize(String[] mfEntries, IProject earProject, IProject ejbProject, boolean filterServiceLocator) { String jarURI = null; EARArtifactEdit edit = null; try { edit = EARArtifactEdit.getEARArtifactEditForRead( earProject ); if (edit != null){ jarURI = edit.getModuleURI( ComponentCore.createComponent( ejbProject )); if (jarURI == null) return Collections.EMPTY_LIST; } } finally { if(edit != null) edit.dispose(); } List result = new ArrayList(mfEntries.length); for (int i = 0; i < mfEntries.length; i++) { String norm = ArchiveUtil.deriveEARRelativeURI(mfEntries[i], jarURI); if (norm == null) norm = mfEntries[i]; //We know this is an implementation dependency so we don't want to move it if (!SERVICE_LOCATOR_JAR_NAME.equals(norm) || !filterServiceLocator) result.add(norm); } return result; }
protected Archive resolveClasspathEntryInEAR(String entry) { /* * Added to support runtime classpath for loose modules */ Container parent = getContainer(); if (parent == null || !parent.isEARFile()) return null; String aUri = ArchiveUtil.deriveEARRelativeURI(entry, this); if (aUri == null) return null; File aFile = null; try { aFile = parent.getFile(aUri); } catch (FileNotFoundException ex) { return null; } return aFile.isArchive() ? (Archive) aFile : null; }
String ejbJarUri = ArchiveUtil.deriveEARRelativeURI(ejbJarName, moduleUri); if (ejbJarUri != null) { try {
shouldAdd = archiveName.equals(manifestClasspath[i]); } else { String earRelativeURI = ArchiveUtil.deriveEARRelativeURI(manifestClasspath[i], earArchiveURI); if(null != earRelativeURI){ shouldAdd = earRelativeURI.equals(archiveName);
public static Archive getClientJAR(EJBJarFile file, EARFile earFile) { EJBJar jar = null; try { jar = file.getDeploymentDescriptor(); } catch (DeploymentDescriptorLoadException exc) { return null; } if (jar == null) return null; String clientJAR = jar.getEjbClientJar(); if (clientJAR == null || clientJAR.length() == 0) return null; String normalized = ArchiveUtil.deriveEARRelativeURI(clientJAR, file.getURI()); if (normalized != null) { try { File aFile = earFile.getFile(normalized); if (aFile.isArchive() && !aFile.isModuleFile()) return (Archive) aFile; } catch (FileNotFoundException nothingThere) { } } return null; // TODO - release the DD here to free up space }
protected void traverseClasspaths(List projectCpEntries, Set visited) { File aFile = null; try { aFile = getEARFile().getFile(getText()); } catch (FileNotFoundException notThere) { } if (aFile == null || !aFile.isArchive()) return; Archive depArchive = (Archive) aFile; String[] manifestCpEntries = depArchive.getManifest().getClassPathTokenized(); for (int i = 0; i < manifestCpEntries.length; i++) { String uri = ArchiveUtil.deriveEARRelativeURI(manifestCpEntries[i], depArchive); if (uri == null) continue; ClasspathElement other = parentSelection.getClasspathElement(uri); //If the other element is already selected, then // we don't need to add it again if (other == null || other.isSelected()) continue; IClasspathEntry[] cpEntries = other.newClasspathEntries(visited); for (int j = 0; j < cpEntries.length; j++) { if (!projectCpEntries.contains(cpEntries[j])) projectCpEntries.add(cpEntries[j]); } } }
protected Object getResourceInDependentJarInEAR(String name, Set visitedArchives, int type) { String[] classpath = archive.getManifest().getClassPathTokenized(); for (int i = 0; i < classpath.length; i++) { try { String uri = ArchiveUtil.deriveEARRelativeURI(classpath[i], archive); if (uri == null) continue; File jarFile = getEARFile().getFile(uri); if (jarFile.isArchive()) { Archive dep = (Archive) jarFile; switch (type) { case CLASS_TYPE : try { return ((ArchiveFileDynamicClassLoader) dep.getArchiveClassLoader()).loadClass(name, visitedArchives); } catch (ClassNotFoundException noDice) { continue; } case FILE_TYPE : try { return dep.getFile(name); } catch (FileNotFoundException noDice) { continue; } } } } catch (java.io.FileNotFoundException depJarNotInEAR) { } } return null; }
String uri = ArchiveUtil.deriveEARRelativeURI(cp[i], anArchive); if (uri == null) { invalidClassPathEntryWarning(cp[i], anArchive);
for (int i = 0; i < cp.length; i++) { String cpEntry = cp[i]; String uri = ArchiveUtil.deriveEARRelativeURI(cpEntry, projectUri);