Service that deploys ".rar" files containing resource adapters. Deploying
the RAR file is the first step in making the resource adapter available to
application components; once it is deployed, one or more connection
factories must be configured and bound into JNDI, a task performed by the
service.
| Method from org.jboss.resource.RARDeployer Detail: |
public boolean accepts(DeploymentInfo sdi) {
String urlStr = sdi.url.toString();
return urlStr.endsWith("rar") || urlStr.endsWith("rar/");
}
Gets the DeployableFilter attribute of the RARDeployer object |
public void create(DeploymentInfo rdi) throws DeploymentException {
log.debug("Attempting to deploy RAR at '" + rdi.url + "'");
try
{
RARMetaData metaData = (RARMetaData) rdi.metaData;
//set up the RARDeployment mbean for dependency management.
rdi.deployedObject =
new ObjectName("jboss.jca:service=RARDeployment,name=" + metaData.getDisplayName());
server.createMBean("org.jboss.resource.RARDeployment",
rdi.deployedObject,
new Object[]{metaData},
new String[]{"org.jboss.resource.RARMetaData"});
serviceController.create(rdi.deployedObject);
}
catch (Exception e)
{
throw new DeploymentException(e);
}
super.create(rdi);
}
The deploy method deploys a rar at the given url. |
public void destroy(DeploymentInfo rdi) throws DeploymentException {
try
{
serviceController.destroy(rdi.deployedObject);
serviceController.remove(rdi.deployedObject);
}
catch (Exception e)
{
throw new DeploymentException(e);
}
((RARMetaData) rdi.metaData).setClassLoader(null);
super.destroy(rdi);
}
|
public void init(DeploymentInfo rdi) throws DeploymentException {
URL raUrl = rdi.localCl.findResource("META-INF/ra.xml");
Document dd = XmlFileLoader.getDocument(raUrl);
Element root = dd.getDocumentElement();
RARMetaData metadata = new RARMetaData();
metadata.importXml(root);
metadata.setClassLoader(rdi.ucl);
rdi.metaData = metadata;
// resolve the watch
if (rdi.url.getProtocol().equals("file"))
{
File file = new File(rdi.url.getFile());
// If not directory we watch the package
if (!file.isDirectory())
rdi.watch = rdi.url;
// If directory we watch the xml files
else
{
try
{
rdi.watch = new URL(rdi.url, "META-INF/ra.xml");
}
catch (MalformedURLException mue)
{
throw new DeploymentException("Could not watch ra.xml file", mue);
} // end of try-catch
} // end of else
}
else
{
// We watch the top only, no directory support
rdi.watch = rdi.url;
}
// invoke super-class initialization
super.init(rdi);
}
|
public void postRegister(Boolean done) {
super.postRegister(done);
serviceController = (ServiceControllerMBean)
MBeanProxyExt.create(ServiceControllerMBean.class,
ServiceControllerMBean.OBJECT_NAME,
server);
}
Once registration has finished, create a proxy to the ServiceController
for later use. |
public void start(DeploymentInfo rdi) throws DeploymentException {
try
{
serviceController.start(rdi.deployedObject);
}
catch (Exception e)
{
throw new DeploymentException(e);
}
super.start(rdi);
}
|
public void stop(DeploymentInfo rdi) throws DeploymentException {
if (log.isDebugEnabled())
{
log.debug("Undeploying RAR at '" + rdi.url + "'");
}
try
{
log.info("About to undeploy RARDeploymentMBean, objectname: " + rdi.deployedObject);
serviceController.stop(rdi.deployedObject);
}
catch (Exception e)
{
throw new DeploymentException(e);
}
super.stop(rdi);
}
|