Exemplo n.º 1
0
 /** {@inheritDoc} */
 public ClassSpec getClassSpec(final String name) throws IOException {
   final VirtualFile file = root.getChild(name);
   if (!file.exists()) {
     return null;
   }
   final long size = file.getSize();
   final ClassSpec spec = new ClassSpec();
   final InputStream is = file.openStream();
   try {
     if (size <= (long) Integer.MAX_VALUE) {
       final int castSize = (int) size;
       byte[] bytes = new byte[castSize];
       int a = 0, res;
       while ((res = is.read(bytes, a, castSize - a)) > 0) {
         a += res;
       }
       // done
       is.close();
       spec.setBytes(bytes);
       spec.setCodeSource(new CodeSource(rootUrl, file.getCodeSigners()));
       return spec;
     } else {
       throw ServerMessages.MESSAGES.resourceTooLarge();
     }
   } finally {
     VFSUtils.safeClose(is);
   }
 }
Exemplo n.º 2
0
 /** {@inheritDoc} */
 public long getSize(VirtualFile mountPoint, VirtualFile target) {
   final VirtualFile assemblyFile = assembly.getFile(mountPoint, target);
   return assemblyFile == null ? 0L : assemblyFile.getSize();
 }
Exemplo n.º 3
0
 public long getSize() {
   final long size = entry.getSize();
   return size == -1 ? 0 : size;
 }
 public long getSize() {
   return file.getSize();
 }