Methods Summary |
---|
public com.sun.enterprise.diagnostics.Data | capture()Captures check sum information
dataObj.addRow(Arrays.asList(new String[]{"Name", "Length", "Checksum"}));
captureChecksum(source + LIB_FOLDER, getFilter());
captureChecksum(source + BIN_FOLDER, null);
return dataObj;
|
private void | captureChecksum(java.lang.String sourceName, java.io.FilenameFilter filter)Captures checksum of files specified by the filter
File fileObj = new File(sourceName);
String[] fileNames = fileObj.list(filter);
if(fileNames != null) {
int length = fileNames.length;
for (int i = 0 ; i < length; i++) {
dataObj.addRow(generateCRC32Checksum(sourceName, fileNames[i]));
}
}
|
private java.util.List | generateCRC32Checksum(java.lang.String parent, java.lang.String fileName)Generates check sum
try {
// First item being name of file, second - length; third being checksum
String file = parent + File.separator + fileName;
List<String> checksumInfo = new ArrayList(3);
CRC32 crc32 = new CRC32();
int length = 0;
BufferedInputStream fileinputstream = new BufferedInputStream(
new FileInputStream(new File(file)));
for( CheckedInputStream checkedinputstream = new CheckedInputStream(
fileinputstream, crc32); checkedinputstream.read() != -1;)
length++;
long cksum = crc32.getValue();
fileinputstream.close();
fileinputstream = null;
crc32 = null;
checksumInfo.add(fileName);
checksumInfo.add(Integer.toString(length));
checksumInfo.add(Long.toString(cksum));
return checksumInfo;
} catch(Exception e) {
//ignore
logger.log(Level.FINE, "diagnostic-service.compute_checksum_failed"
,new Object[]{fileName, e.getMessage()});
return null;
}
|
private java.io.FilenameFilter | getFilter()Gets filter which recognizes .jar and .so/.dll files
final String[] exts ;
if(isSolaris())
exts = new String[] {JAR_EXT, SO_EXT};
else
exts = new String[] {JAR_EXT, DLL_EXT};
return new FilenameFilter(){
public boolean accept(File dir, String name) {
return name.endsWith(exts[0]) ||
name.endsWith(exts[1]);
}
};
|
private boolean | isSolaris()
return DiagnosticServiceHelper.isSolaris();
|
private void | writeToFile(java.util.List checksumInfo)
if (checksumInfo != null) {
try {
writer.write("\n");
for(String entry : checksumInfo) {
writer.write(entry + "\t");
} //for
}catch(IOException ioe) {
//ignore
}
}//if
|