/** * create or obtain an embedded archive within this abstraction. * * @param name the name of the embedded archive. */ public ReadableArchive getSubArchive(String name) throws IOException { InputStream is = getEntry(name); if (is!=null) { ReadableArchive archive = new MemoryMappedArchive(is); is.close(); return archive; } return null; }
/** * @return an @see java.util.Enumeration of entries in this abstract * archive, providing the list of embedded archive to not count their * entries as part of this archive */ public Enumeration entries(Enumeration embeddedArchives) { // jar file are not recursive return entries(); }
/** Creates a new instance of MemoryMappedArchive */ public MemoryMappedArchive(InputStream is) throws IOException { read(is); }
public static String getResourceAdapterClassName (String rarLocation) { //Use the deployment APIs to get the name of the resourceadapter //class through the connector descriptor try { FileInputStream fis = new FileInputStream(rarLocation); MemoryMappedArchive mma = new MemoryMappedArchive(fis); ConnectorArchivist ca = new ConnectorArchivist(); ConnectorDescriptor cd = (ConnectorDescriptor) ca.open(mma); return cd.getResourceAdapterClass(); } catch (IOException e) { _logger.info(e.getMessage()); if(_logger.isLoggable(Level.FINE)) { _logger.log(Level.FINE, "Error while trying to read connector" + "descriptor to get resource-adapter properties", e); } } catch (SAXParseException e) { _logger.info(e.getMessage()); if(_logger.isLoggable(Level.FINE)) { _logger.log(Level.FINE, "Error while trying to read connector" + "descriptor to get resource-adapter properties", e); } } return null; }
private File writeMemoryMappedArchiveToTempFile(MemoryMappedArchive mma, String fileSuffix) throws IOException { File tempFile = File.createTempFile("jsr88-", fileSuffix); BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(tempFile)); int chunkSize = 32 * 1024; long remaining = mma.getArchiveSize(); BufferedInputStream bis = new BufferedInputStream( new ByteArrayInputStream(mma.getByteArray())); try { while(remaining != 0) { int actual = (remaining < chunkSize) ? (int) remaining : chunkSize; byte[] bytes = new byte[actual]; try { bis.read(bytes); bos.write(bytes); } catch (EOFException eof) { break; } remaining -= actual; } } finally { bos.flush(); bis.close(); bos.close(); } return tempFile; }
/** * Returns the existence of the given entry name * The file name must be relative to the root of the module. * * @param name the file name relative to the root of the module. * @return the existence the given entry name. */ public boolean exists(String name) throws IOException { return (getEntry(name) != null); }
moduleArchive = new MemoryMappedArchive(moduleStream); if (deploymentPlanStream != null) { deploymentPlanArchive = new MemoryMappedArchive(deploymentPlanStream);
BufferedInputStream bis = null; int chunkSize = 32 * 1024; long remaining = mma.getArchiveSize(); try { bos = new BufferedOutputStream(new FileOutputStream(tempFile)); bis = new BufferedInputStream( new ByteArrayInputStream(mma.getByteArray())); while(remaining != 0) { int actual = (remaining < chunkSize) ? (int) remaining : chunkSize;
moduleArchive = new MemoryMappedArchive(moduleStream); if (deploymentPlanStream != null) { deploymentPlanArchive = new MemoryMappedArchive(deploymentPlanStream);
public Collection<String> getDirectories() throws IOException { return entries(true); }
public void open(URI uri) throws IOException { File in = new File(uri); if (!in.exists()) { throw new FileNotFoundException(uri.getSchemeSpecificPart()); } FileInputStream is = null; try { is = new FileInputStream(in); read(is); } finally { if (is != null) { is.close(); } } }
/** * @return an @see java.util.Enumeration of entries in this abstract * archive */ public Enumeration entries() { return entries(false).elements(); }