Result result = getInitializedResult();
result.setStatus(Result.PASSED);
addErrorDetails(result,
getVerifierContext().getComponentNameConstructor());
PersistenceUnitDescriptor pu = PersistenceUnitDescriptor.class.cast(
descriptor);
File absolutePURootFile = getAbsolutePuRootFile(pu);
logger.fine("Absolute PU Root: " + absolutePURootFile);
String absolutePuRoot = absolutePURootFile.getAbsolutePath();
List<String> jarFileNames = new ArrayList<String>(pu.getJarFiles());
for (String jarFileName : jarFileNames) {
// ASSUMPTION:
// Because of the way deployment changes names of directories etc.
// it is very difficult to back calculate path names. So,
// the following code assumes user is specifying valid URIs.
// in the xml, names always use '/'
String nativeJarFileName = jarFileName.replace('/",
File.separatorChar);
final File parentFile = new File(absolutePuRoot).getParentFile();
// only components are exploded, hence first look for original archives.
File jarFile = new File(parentFile, nativeJarFileName);
if (!jarFile.exists()) {
// if the referenced jar is itself a component, then
// it might have been exploded, hence let's see
// if that is the case.
// let's calculate the name component and path component from this URI
// e.g. if URI is ../../foo_bar/my-ejb.jar,
// name component is foo_bar/my-ejb.jar and
// path component is ../../
// These are my own notions used here.
String pathComponent = "";
String nameComponent = jarFileName;
if(jarFileName.lastIndexOf("../") != -1) {
final int separatorIndex = jarFileName.lastIndexOf("../")+3;
pathComponent = jarFileName.substring(0,separatorIndex);
nameComponent = jarFileName.substring(separatorIndex);
}
logger.fine("For jar-file="+ jarFileName+ ", " +
"pathComponent=" +pathComponent +
", nameComponent=" + nameComponent);
File parentPath = new File(parentFile, pathComponent);
jarFile = new File(parentPath, DeploymentUtils.
getRelativeEmbeddedModulePath(parentPath.
getAbsolutePath(), nameComponent));
if (!jarFile.exists()) {
result.failed(smh.getLocalString(
getClass().getName() + "failed",
"[ {0} ] specified in persistence.xml does not exist in the application.",
new Object[]{jarFileName}));
}
}
}
return result;