AppInfoCollectorpublic class AppInfoCollector extends Object implements CollectorResponsible for collecting applications deployment descriptors and generated
files. |
Fields Summary |
---|
private String | destFolder | private String | repositoryFolder | private com.sun.enterprise.diagnostics.ServiceConfig | config | private static Logger | logger |
Constructors Summary |
---|
public AppInfoCollector(String repositoryFolder, String destFolder)Creates new instance of AppInfoCollector
this.destFolder = destFolder;
this.repositoryFolder = repositoryFolder;
this.config = config;
|
Methods Summary |
---|
public com.sun.enterprise.diagnostics.Data | capture()Captures applications deployment descriptors and generated files
WritableDataImpl dataImpl = new WritableDataImpl(DataType.APPL_INFO);
dataImpl.addChild(captureAppRelatedInfo(Constants.GENERATED_DIR));
dataImpl.addChild(
captureAppRelatedInfo(Constants.APPLICATIONS_DIR,
new DDFilter()));
return dataImpl;
| private com.sun.enterprise.diagnostics.Data | captureAppRelatedInfo(java.lang.String relativePath)Captures files
try {
String sourceFolder = repositoryFolder + File.separator + relativePath;
String destFileObj = destFolder + File.separator + relativePath;
FileUtils.copyDir(sourceFolder, destFileObj, true);
return new FileData(destFileObj, DataType.APPL_INFO);
} catch(IOException ioe) {
logger.log(Level.WARNING, "diagnostic-service.copy_failed" ,
new Object[]{relativePath, ioe.getMessage()});
}
return null;
| private com.sun.enterprise.diagnostics.Data | captureAppRelatedInfo(java.lang.String relativePath, java.io.FilenameFilter filter)Capture filtered files
WritableDataImpl dataImpl = new WritableDataImpl(relativePath);
String sourceFolderName = repositoryFolder + File.separator + relativePath;
File sourceFolder = new File(sourceFolderName);
String[] filteredChildren = null;
String[] children = null;
// Assumes that there is no further sub directory , if children
// satisfying the filter are found
if (filter != null) {
filteredChildren = sourceFolder.list(filter);
}
// Visit subfolders to search files with matching the filter
if (filteredChildren != null) {
if(filteredChildren.length == 0) {
children = sourceFolder.list();
for (int i = 0 ; i < children.length; i++) {
String childName = relativePath + File.separator + children[i];
String absoluteChildName = repositoryFolder + File.separator + childName;
File child = new File(absoluteChildName);
if (child.isDirectory())
dataImpl.addChild(captureAppRelatedInfo(childName, filter));
}
} else {
for (int i = 0 ; i < filteredChildren.length; i++) {
String childName = relativePath + File.separator +
filteredChildren[i];
String absoluteChildName = repositoryFolder +
File.separator + childName;
File child = new File(absoluteChildName);
try {
String dest = destFolder + File.separator + childName;
FileUtils.copyFile(absoluteChildName, dest);
dataImpl.addChild(new FileData(dest, DataType.APPL_INFO));
}catch(IOException ioe) {
logger.log(Level.WARNING, "diagnostic-service.copy_failed" ,
new Object[]{absoluteChildName, ioe.getMessage()});
}
}// for
}//else
}//if
return dataImpl;
|
|