public WarFileDynamicClassLoader(Archive anArchive, ClassLoader parentCl, ClassLoader extraCl, ProtectionDomain pDomain) { super(anArchive, parentCl, extraCl, pDomain); allowLoadingFromWAR = anArchive.getOptions().getClassLoadingMode() == ArchiveOptions.LOAD_MODE_COMPAT; }
public void validateManifestCase(Archive anArchive) { String mfuri = J2EEConstants.MANIFEST_URI; //Indicates a manifest file with the valid name exists, //nothing left to do if (anArchive.containsFile(mfuri)) return; //Otherwise iterate the list of files //Ensure the archive is read-only first anArchive.getOptions().setIsReadOnly(true); List files = anArchive.getFiles(); String uri = null; for (int i = 0; i < files.size(); i++) { File aFile = (File) files.get(i); uri = aFile.getURI(); if (mfuri.equalsIgnoreCase(uri) && !mfuri.equals(uri)) { String[] params = {uri, anArchive.getURI()}; IResource target = earHelper.getProject().getFile(J2EEConstants.MANIFEST_URI); String msg = NLS.bind(EARValidationMessageResourceHandler.INVALID_CASE_FOR_MANIFEST_ERROR_, params); addLocalizedError(msg, target); } } }
/** * @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 void updateModificationTracking(Resource res) { boolean trackingMods = res.isTrackingModification(); boolean isReadOnly = (container != null) ? ((Archive) container).getOptions().isReadOnly() : false; boolean shouldTrackMods = !(isReadOnly || ArchiveUtil.isJavaResource(res) || ArchiveUtil.isRegisteredURIMapping(res)); if (shouldTrackMods && !trackingMods) res.setTrackingModification(true); }
/** * Create a load strategy for a nested archive; by default will extract the nested archive to a * temp file for performance reasons. This is because random access to the zip entries in a * nested archive is not supported by the java.util.zip package, and if the archive's contents * are being modified, copied, etc, this is much faster. If a temp file can not be created, or * if the archive is opened read only (for runtime), then use a NestedArchiveLoadStrategy, which * retrieves the contents of a zip entry by sequentially searching a zip input stream */ public LoadStrategy createNestedLoadStrategy(String uri, LoadStrategy parent) { LoadStrategy loadStrategy = null; ArchiveOptions options = ((Archive) parent.getContainer()).getOptions(); if (!options.isReadOnly(uri)) loadStrategy = createTempZipFileStrategyIfPossible(uri, parent); if (loadStrategy == null) return new NestedArchiveLoadStrategyImpl(parent); return loadStrategy; }
protected boolean shouldSave(Resource res) { if (!res.isModified() && getArchive().getOptions().saveOnlyDirtyMofResources()) return false; return shouldSave(res.getURI().toString()); }
/** * Used internally; clients should not need to call */ public FileIterator getFileIterator() throws IOException { if (((Archive) getContainer()).getOptions().isReadOnly()) return new NestedArchiveIterator(getContainer().getFiles(), getZipInputStream()); return super.getFileIterator(); }
return !anArchive.getOptions().isReadOnly(); else if (anArchive.getOptions().isSaveLibrariesAsFiles() && anArchive.getLoadingContainer() != null) { if (anArchive.isIndexed()) { List files = anArchive.getFiles();
/** * @see CommonarchiveFactory */ public Archive openNestedArchive(String uri, Archive parent) throws OpenFailureException { try { LoadStrategy childStrategy = createChildLoadStrategy(uri, parent.getLoadStrategy()); ArchiveOptions options = parent.getOptions().cloneWith(childStrategy, uri); if (options.shouldDiscriminateNestedArchives()) return openArchive(options, uri); return primOpenArchive(options, uri); } catch (IOException ex) { throw new OpenFailureException(CommonArchiveResourceHandler.getString(CommonArchiveResourceHandler.open_nested_EXC_, (new Object[]{uri, parent.getURI()})), ex); // = "Could not open the nested archive "{0}" in "{1}"" } }
public Archive openNestedArchive(LooseArchive loose, Archive parent) throws OpenFailureException { String uri = loose.getUri(); try { if(loose.getBinariesPath() == null){ throw new OpenFailureException(CommonArchiveResourceHandler.getString(CommonArchiveResourceHandler.open_nested_EXC_, (new Object[] {uri,parent.getURI()})), null); // = "Could not open the nested archive "{0}" in "{1}"" } LoadStrategy childStrategy = createLoadStrategy(loose.getBinariesPath()); childStrategy.setLooseArchive(loose); ArchiveOptions options = parent.getOptions().cloneWith(childStrategy, loose.getUri()); return primOpenArchive(options, uri); } catch (IOException ex) { throw new OpenFailureException(CommonArchiveResourceHandler.getString(CommonArchiveResourceHandler.open_nested_EXC_, (new Object[]{uri, parent.getURI()})), ex); // = "Could not open the nested archive "{0}" in "{1}"" } }
/** * @see com.ibm.etools.archive.ArchiveTypeDiscriminator */ public Archive convert(Archive anArchive) throws OpenFailureException { Archive destination = createConvertedArchive(); //turn of notifications destination.eSetDeliver(false); destination.eSetDeliver(false); //Copy the relevant attributes destination.setURI(anArchive.getURI()); destination.setOriginalURI(anArchive.getURI()); destination.setSize(anArchive.getSize()); destination.setLastModified(anArchive.getLastModified()); destination.setLoadStrategy(anArchive.getLoadStrategy()); destination.setOptions(anArchive.getOptions()); destination.setExtraClasspath(anArchive.getExtraClasspath()); if (destination.isModuleFile()) { ImportStrategy importStrategy = createImportStrategy(anArchive, destination); ((ModuleFile) destination).setImportStrategy(importStrategy); } //turn notifications back on destination.eSetDeliver(true); destination.eSetDeliver(true); return destination; }