/** * @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()]); }
final String[] manifestClasspath = manifest.getClassPathTokenized(); final List updatedCP = new ArrayList(); for (int i = 0; i < manifestClasspath.length; i++) { manifest.setClassPath(cpBuffer.toString()); manifest.write(outputStream); outputStream.flush(); } finally {
public IStatus execute(IProgressMonitor monitor, IAdaptable adaptable) throws ExecutionException { IFile file = (IFile)model.getProperty(UpdateManifestDataModelProperties.MANIFEST_FILE); String classPathValue = model.getStringProperty(UpdateManifestDataModelProperties.JAR_LIST_TEXT_UI); try { ArchiveManifest mf = J2EEProjectUtilities.readManifest(file); if (mf == null) mf = new ArchiveManifestImpl(); mf.addVersionIfNecessary(); if (model.getBooleanProperty(UpdateManifestDataModelProperties.MERGE)) { mf.mergeClassPath(ArchiveUtil.getTokens(classPathValue)); } else { mf.setClassPath(classPathValue); } if (model.isPropertySet(UpdateManifestDataModelProperties.MAIN_CLASS)) { mf.setMainClass(model.getStringProperty(UpdateManifestDataModelProperties.MAIN_CLASS)); } J2EEProjectUtilities.writeManifest(file, mf); } catch (java.io.IOException ex) { throw new ExecutionException(ex.getMessage(),ex); } return OK_STATUS; }
protected void resetClassPath(List cp) { ArchiveManifest mf = outgoingArchive.getManifest(); if (cp.isEmpty()) mf.getMainAttributes().remove(Attributes.Name.CLASS_PATH); else { mf.setClassPath("");//$NON-NLS-1$ for (int i = 0; i < cp.size(); i++) { mf.appendClassPath((String) cp.get(i)); } } }
if (mf == null) mf = new ArchiveManifestImpl(); mf.addVersionIfNecessary(); if (replace) mf.setClassPath(classPathValue); else mf.mergeClassPath(ArchiveUtil.getTokens(classPathValue)); J2EEProjectUtilities.writeManifest(p, mf); } catch (java.io.IOException ex) {
public ArchiveManifest copy(ArchiveManifest mf) { try { ByteArrayOutputStream out = new ByteArrayOutputStream(); mf.write(out); InputStream in = new ByteArrayInputStream(out.toByteArray()); return new ArchiveManifestImpl(in); } catch (IOException iox) { //This should almost never happen, unless there is an issure with memory allocation throw new ArchiveRuntimeException(CommonArchiveResourceHandler.IOException_occurred_while_EXC_, iox); // = "IOException occurred while copying manifest" } }
/** * Sets the Class-path manifest entry, rebuilds the class loader, and refreshes any reflected * java classes */ public void setManifestClassPathAndRefresh(String classpath) { ArchiveManifest mf = getManifest(); if (manifest == null) { makeManifest(); } mf.setClassPath(classpath); //Optimization - only re init if a cl exists; otherwise it will init on // demand if (archiveClassLoader != null) initializeClassLoader(); }
/** * @see com.ibm.etools.archive.SaveStrategy */ public void save(org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveManifest aManifest) throws SaveFailureException { try { OutputStream out = getUriConverter().createOutputStream(URI.createURI(J2EEConstants.MANIFEST_URI)); aManifest.write(out); out.close(); } catch (IOException iox) { throw new SaveFailureException(J2EEConstants.MANIFEST_URI, iox); } }
/** * Updates the manifest Class-Path:, and sends out a notification of type * {@link ClasspathModelEvent#CLASS_PATH_CHANGED} */ public void updateManifestClasspath() { if (classPathSelection != null && classPathSelection.isModified()) { manifest.setClassPath(classPathSelection.toString()); fireNotification(new ClasspathModelEvent(ClasspathModelEvent.CLASS_PATH_CHANGED)); } }
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; }
/** * @see com.ibm.etools.archive.SaveStrategy */ public void save(org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveManifest aManifest) throws SaveFailureException { try { ZipEntry entry = new ZipEntry(J2EEConstants.MANIFEST_URI); getZipOutputStream().putNextEntry(entry); aManifest.write(getZipOutputStream()); getZipOutputStream().closeEntry(); } catch (IOException iox) { throw new SaveFailureException(J2EEConstants.MANIFEST_URI, iox); } }
/** * 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.archive.SaveStrategy */ public void save(org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveManifest aManifest) throws SaveFailureException { try { OutputStream out = getUriConverter().createOutputStream(URI.createURI(J2EEConstants.MANIFEST_URI)); aManifest.write(out); out.close(); if (getArchive().getOptions().isReadOnly()) setTimestampAfterSaving(J2EEConstants.MANIFEST_URI); } catch (IOException iox) { throw new SaveFailureException(J2EEConstants.MANIFEST_URI, iox); } }
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() ] ); }
public void save(ArchiveManifest aManifest) throws SaveFailureException { IVirtualFolder rootFolder = vComponent.getRootFolder(); IVirtualFile vFile = rootFolder.getFile(new Path(J2EEConstants.MANIFEST_URI)); IFile iFile = vFile.getUnderlyingFile(); validateEdit(iFile); OutputStream out = new WorkbenchByteArrayOutputStream(iFile); try { aManifest.write(out); } catch (IOException e) { Logger.getLogger().logError(e); } finally { try { out.close(); } catch (IOException e) { Logger.getLogger().logError(e); } } }
/** * @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; }
public void save(ArchiveManifest aManifest) throws SaveFailureException { IVirtualFolder rootFolder = vComponent.getRootFolder(); IVirtualFile vFile = rootFolder.getFile(new Path(J2EEConstants.MANIFEST_URI)); IFile iFile = vFile.getUnderlyingFile(); validateEdit(iFile); OutputStream out = new WorkbenchByteArrayOutputStream(iFile); try { aManifest.write(out); } catch (IOException e) { Logger.getLogger().logError(e); } finally { try { out.close(); } catch (IOException e) { Logger.getLogger().logError(e); } } }
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); }