/** * @see com.ibm.etools.commonarchive.Archive */ public java.lang.String[] getRuntimeClassPath() { String absolutePath; try { absolutePath = getBinariesPath(); } catch (IOException ex) { return new String[0]; } List entries = new ArrayList(); entries.add(absolutePath); String parentPath = new java.io.File(absolutePath).getParentFile().getAbsolutePath(); String[] mfEntries = getManifest().getClassPathTokenized(); entries.addAll(getEntriesAsAbsolutePaths(mfEntries, parentPath)); return (String[]) entries.toArray(new String[entries.size()]); }
public boolean hasClasspathVisibilityTo(Archive other, Set visited, EARFile ear) { if (this == other) return true; if (visited.contains(this)) return false; visited.add(this); String[] mfEntries = getManifest().getClassPathTokenized(); for (int i = 0; i < mfEntries.length; i++) { Archive anArchive = getResolvedArchive(mfEntries[i], ear); if (anArchive != null && anArchive.hasClasspathVisibilityTo(other, visited, ear)) return true; } return false; }
/** * Parse the manifest class path and the extra class path, and instantiate a URL classloader, * with a parent of the archiveClassLoader */ protected ClassLoader getClassPathClassLoader(ClassLoader parentCl) { List classPathComponents = new ArrayList(); if (getManifest() != null) classPathComponents.addAll(Arrays.asList(getManifest().getClassPathTokenized())); String extraCp = getExtraClasspath(); if (extraCp != null) classPathComponents.addAll(Arrays.asList(ArchiveUtil.getTokens(extraCp, ";")));//$NON-NLS-1$ java.net.URL[] urlArray = ArchiveUtil.toLocalURLs(classPathComponents, getRootForRelativeDependentJars()); return new java.net.URLClassLoader(urlArray, parentCl); }
/** * @see com.ibm.etools.commonarchive.CommonarchiveFactory */ public java.lang.String[] getManifestClassPathValues(java.lang.String uri) throws org.eclipse.jst.j2ee.commonarchivecore.internal.exception.OpenFailureException { Archive anArchive = primOpenArchive(uri); String[] result = anArchive.getManifest().getClassPathTokenized(); anArchive.close(); return result; }
protected RuntimeClasspathEntry[] getDependencyClassPathAtThisLevel() { // BZ 170532: Don't use the archive's absolute path when the // archive is loosely mapped. The current archive's absolute // path, generally, will not be in a fixed location relative // to the path of the parent application. String parentPath = getParentPath(); if ( parentPath == null ) return emptyClasspath(); String[] mfEntries = getManifest().getClassPathTokenized(); if ( mfEntries.length == 0 ) return emptyClasspath(); List entries = new ArrayList(); entries.addAll( createRuntimeClasspathEntries(mfEntries, parentPath) ); return (RuntimeClasspathEntry[]) entries.toArray( new RuntimeClasspathEntry[ entries.size() ] ); }
final String[] manifestClasspath = manifest.getClassPathTokenized(); final List updatedCP = new ArrayList(); for (int i = 0; i < manifestClasspath.length; i++) {
public void merge() { String[] cp = outgoingArchive.getManifest().getClassPathTokenized(); dependentArchives = new ArrayList(cp.length); List keepClassPaths = new ArrayList(); for (int i = 0; i < cp.length; i++) { Archive dependentJar = null; IFile file = null; try { file = project.getFile(cp[i]); } catch (IllegalArgumentException e) { continue; } if (file.exists() && cp[i].endsWith(J2EEImportConstants.IMPORTED_JAR_SUFFIX)) { try { dependentJar = getArchiveFactory().primOpenArchive(file.getLocation().toOSString()); } catch (OpenFailureException ex) { // Need to write this to the log file org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError(ex); continue; } dependentArchives.add(dependentJar); mergeFiles(dependentJar); } else keepClassPaths.add(cp[i]); } resetClassPath(keepClassPaths); }
public String[] getManifestClasspath() { if (null == manifestClasspath) { Archive archive = EnterpriseBinaryComponentHelper.ArchiveCache.getInstance().getArchive(this); if (null == archive) { EnterpriseBinaryComponentHelper helper = EnterpriseBinaryComponentHelper.getHelper(this); try { archive = helper.accessArchive(); ArchiveManifest manifest = archive.getManifest(); manifestClasspath = manifest.getClassPathTokenized(); } catch (Exception e) { } finally { if (null != archive) { archive.close(); } if (null != helper) { helper.dispose(); } } } else { ArchiveManifest manifest = archive.getManifest(); manifestClasspath = manifest.getClassPathTokenized(); } if (manifestClasspath == null) { manifestClasspath = new String[0]; } } return manifestClasspath; } }
protected void setProjectValues(ClasspathElement element, Archive referencedArchive) { IProject p = getProject(referencedArchive); if (p == null) return; element.setProject(p); //Handle the imported jars in the project String[] cp = null; try { cp = referencedArchive.getManifest().getClassPathTokenized(); } catch (ManifestException mfEx) { Logger.getLogger().logError(mfEx); cp = new String[]{}; } List paths = new ArrayList(cp.length); for (int i = 0; i < cp.length; i++) { IFile file = null; try { file = p.getFile(cp[i]); } catch (IllegalArgumentException invalidPath) { continue; } if (file.exists()) paths.add(file.getFullPath()); } if (!paths.isEmpty()) element.setImportedJarPaths(paths); }
cp = referencedManifest.getClassPathTokenized(); } catch (ManifestException mfEx) { Logger.getLogger().logError(mfEx);
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]); } } }
private void removeManifestDependency(final IVirtualComponent source, final IVirtualComponent target) throws ExecutionException { final String sourceProjName = source.getProject().getName(); final String targetProjName = target.getProject().getName(); final IProgressMonitor monitor = new NullProgressMonitor(); final IFile manifestmf = J2EEProjectUtilities.getManifestFile(source.getProject()); final ArchiveManifest mf = J2EEProjectUtilities.readManifest(source.getProject()); if (mf == null) return; final IDataModel updateManifestDataModel = DataModelFactory.createDataModel(new UpdateManifestDataModelProvider()); updateManifestDataModel.setProperty(UpdateManifestDataModelProperties.PROJECT_NAME, sourceProjName); updateManifestDataModel.setBooleanProperty(UpdateManifestDataModelProperties.MERGE, false); updateManifestDataModel.setProperty(UpdateManifestDataModelProperties.MANIFEST_FILE, manifestmf); String[] cp = mf.getClassPathTokenized(); List cpList = new ArrayList(); String cpToRemove = targetProjName + ".jar";//$NON-NLS-1$ for (int i = 0; i < cp.length; i++) { if (!cp[i].equals(cpToRemove)) { cpList.add(cp[i]); } } updateManifestDataModel.setProperty(UpdateManifestDataModelProperties.JAR_LIST, cpList); updateManifestDataModel.getDefaultOperation().execute(monitor, null ); }
updateManifestDataModel.setProperty(UpdateManifestDataModelProperties.MANIFEST_FILE, manifestmf); final ArchiveManifest manifest = getArchiveManifest(manifestmf); String[] cp = manifest.getClassPathTokenized(); List cpList = new ArrayList(); String newCp = refactoredProjName + ".jar";//$NON-NLS-1$
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; }
return; String[] cp = manifest.getClassPathTokenized();
in = manifestFile.getContents(); ArchiveManifest manifest = new ArchiveManifestImpl(in); manifestClasspath = manifest.getClassPathTokenized(); } catch (IOException e) { Logger.getLogger().logError(e);
cp = manifest.getClassPathTokenized(); } catch (ManifestException ex) { Logger.getLogger().logError(ex);
if (clientMf == null) return; String[] mfEntries = clientMf.getClassPathTokenized(); if (mfEntries.length == 0) return;
if (ejbMf == null) return; String[] mfEntries = ejbMf.getClassPathTokenized(); if (mfEntries.length == 0) return;