*/
public static DeployableObjectType getTypeFromFile(String name, String filePath)
throws DeploymentException {
if(filePath == null)
throw new DeploymentException("deploy file not specified");
try {
//@@@ special handling the deployment of .class POJO webservice
//class.
if (filePath.endsWith(".class")) {
// get the top directory from the moduleID, in the case of
// autodeploy, the moduleID will be the full class name (with package)
// with . replaced with _
StringTokenizer tk = new StringTokenizer(name, "_");
File f = new File(filePath);
for (int i=0;i<tk.countTokens();i++) {
f = f.getParentFile();
}
try {
// it's important to not cache this because the class can
// change overtime... we need to load the last one.
URL[] urls = new URL[1];
urls[0] = f.toURL();
URLClassLoader cLoader = new URLClassLoader(urls,
DeploymentServiceUtils.class.getClassLoader());
String className = name.replaceAll("_", ".");
Class clazz = cLoader.loadClass(className);
if (clazz!=null && clazz.getAnnotation(javax.ejb.Stateless.class)!=null) {
return DeployableObjectType.EJB;
} else {
return DeployableObjectType.WEB;
}
} catch(Exception e) {
sLogger.log(Level.WARNING, e.getMessage(), e);
return DeployableObjectType.WEB;
}
}
Archivist archivist =
ArchivistFactory.getArchivistForArchive(filePath);
ModuleType moduleType = archivist.getModuleType();
return getDeployableObjectType(moduleType);
} catch (IOException ioe) {
DeploymentException de = new DeploymentException(
localStrings.getString(
"enterprise.deployment.ioexc_getting_archtype", filePath));
de.initCause(ioe);
throw de;
} catch(Exception ex) {
DeploymentException de = new DeploymentException(
localStrings.getString(
"enterprise.deployment.unknown.application.type", filePath));
de.initCause(ex);
throw de;
}
}