JBIAutoDeployerpublic class JBIAutoDeployer extends Object This is a singleton that controls autodeployment of
JBI service assemblies. It hold another utility
class JBIDeployer, which does all the mbean operations.
One difference between JBI archives and Java EE archives
is that JBI service assembly conatin a deployment descriptor
where the name of the service assembly can be specified.
During deployment of the service assembly, this name will
be registered as the identifier of the service assembly.
For any further activity on the service assembly, this
identifier will be used to refer the service assembly.
For all house keeping within the autodeploy framework,
.autodeploystatus directory is used to keep the status
files. Also, the java ee archive file name is used
as the status file name. But, for undeploying the JBI
archive, service assembly name need to be saved.
A new status directory (.jbi) is created inside the
.autodeploystatus directory. Status files with the name
jbiarchivefilename__serviceassemblyname will be created
in this directory during deployment and the same will be
removed during undeployment. |
Fields Summary |
---|
private static final JBIAutoDeployer | jad | private static final String | JBI_STATUS_DIR | private static final String | DELIMITER | private static final String | SA_NAME_PATH | private String | JBIXML | private final JBIDeployer | deployer | private static final Logger | sLogger | private static final com.sun.enterprise.util.i18n.StringManager | localStrings |
Constructors Summary |
---|
private JBIAutoDeployer()
deployer = new JBIDeployer();
|
Methods Summary |
---|
private java.lang.String | __getServiceAssemblyName(java.io.File fStatDir, java.io.File file)Split the application name from the status file name and
returns the service assembly name.
File[] stFiles = fStatDir.listFiles(new ServiceAssemblyFinder(file));
if (stFiles == null || stFiles.length == 0) {
return null;
}
String[] splitNames =
stFiles[0].getName().split(file.getName() + DELIMITER , 2);
return splitNames[1];
| JBIDeployer | getDeployer()Return the object that do the mbean operations.
return deployer;
| static com.sun.enterprise.deployment.autodeploy.JBIAutoDeployer | getInstance()
return jad;
| private javax.xml.namespace.NamespaceContext | getJbiNSContext()Need to handle JBI namespace
return new NamespaceContext() {
public String getNamespaceURI(String prefix) {
if (prefix.equals("jbi")) {
return "http://java.sun.com/xml/ns/jbi";
} else {
return null;
}
}
public String getPrefix(String uri) {
return null;
}
public java.util.Iterator getPrefixes(String uri) {
return null;
}
};
| java.lang.String | getServiceAssemblyName(java.io.File file)Return the service assembly name from the archive.
JarFile jf = null;
try {
jf = new JarFile(file);
XPath xPath = XPathFactory.newInstance().newXPath();
xPath.setNamespaceContext(getJbiNSContext());
String saName = xPath.evaluate(SA_NAME_PATH,
new InputSource(jf.getInputStream(jf.getEntry(JBIXML))));
return saName;
} catch(Exception e) {
String msg = localStrings.getString
("enterprise.deployment.autodeploy.sa_invalid", file);
sLogger.log(Level.INFO, msg, e);
throw new AutoDeploymentException(msg, e);
} finally {
try {
jf.close();
} catch (Exception e) {
}
}
| java.lang.String | getServiceAssemblyName(java.io.File file, java.io.File autodeployDir)Get the service assembly name of the deleted file.
try {
File statDir =
new File(autodeployDir, AutoDeployedFilesManager.STATUS_DIR_NAME);
if (statDir.getParentFile() == null) {
return null;
}
File jbiStatDir = new File(statDir, JBI_STATUS_DIR);
File fStatDir = AutoDeployedFilesManager.obtainFileStatusDir
(file, jbiStatDir, statDir.getParentFile());
return __getServiceAssemblyName(fStatDir, file);
} catch (Exception e) {
return null;
// safe bet. JBI should not cause normal autodeploy to
// fail.
}
| java.io.File | getStatusFile(java.io.File file, java.io.File statDir)Return the status file for the JBI archive.
File jbiStatDir = new File(statDir, JBI_STATUS_DIR);
File fStatDir = AutoDeployedFilesManager.obtainFileStatusDir
(file, jbiStatDir, statDir.getParentFile());
String saName = null;
if (file.exists()) {
try {
if (isJbiArchive(file)) {
saName = getServiceAssemblyName(file);
}
} catch (Exception e) {
sLogger.log(Level.FINE, e.getMessage(), e);
}
} else {
saName = __getServiceAssemblyName(fStatDir, file);
}
if (saName == null) return null;
return new File (fStatDir, file.getName() + DELIMITER + saName);
| boolean | isJbiArchive(java.io.File file)Checks whether it is a JBI archive or not.
JarFile jf = null;
try {
String name = file.getName();
String fileType = name.substring(name.lastIndexOf(".") + 1);
if ("class".equals(fileType)) {
return false;
}
jf = new JarFile(file);
return jf.getEntry(JBIXML) != null;
} catch(Exception e) {
String msg = localStrings.getString
("enterprise.deployment.autodeploy.sa_invalid", file);
sLogger.log(Level.FINE, msg, e);
return false;
} finally {
try {
if (jf != null) {
jf.close();
}
} catch (Exception e) {
// ignore
e.hashCode(); // silence FindBugs
}
}
|
|