How to copy a folder from jboss deployment to your local machine

The code below will copy a folder from a deployed application in jboss to a local folder in your machine. This is useful if you want to deploy something, perhaps a set of configuration files on your local machine on deployment.


File destinationDir = new File(destinationFolder);
if (!destinationDir.exists()) {
destinationDir.mkdirs();

//get the folder path from resource
String sourcePath = Thread.currentThread().getContextClassLoader().getResource("./jasper").getPath();
File sourceFile = new File(sourcePath);
if (!sourceFile.exists()) {
//get the vfs path
VirtualFile vfDir = VFS.getChild("/content/"
+ ParamBean.getInstance().getProperty("meveo.moduleName", "meveo")
+ ".war/WEB-INF/classes/jasper");
URL vfPath = VFSUtils.getPhysicalURL(vfDir);
sourceFile = new File(vfPath.getPath());
if (!sourceFile.exists()) {
throw new Exception("missing source");
}
}

//copy the resource files to local machine
FileUtils.copyDirectory(sourceFile, destinationDir);
}

0 nhận xét:

Đăng nhận xét