An XMBean resource implementation of a deployer for j2ee application
client jars
| Method from org.jboss.deployment.ClientDeployer Detail: |
public boolean accepts(DeploymentInfo di) {
// To be accepted the deployment's root name must end in jar
String urlStr = di.url.getFile();
if( !urlStr.endsWith("jar") && !urlStr.endsWith("jar/") )
{
return false;
}
// However the jar must also contain an META-INF/application-client.xml
boolean accepts = false;
try
{
URL dd = di.localCl.findResource("META-INF/application-client.xml");
if (dd != null)
{
log.debug("Found a META-INF/application-client.xml file, di: "+di);
accepts = true;
}
}
catch( Exception ignore )
{
}
return accepts;
}
This method looks to the deployment for a META-INF/application-client.xml
descriptor to identify a j2ee client jar. |
public void create(DeploymentInfo di) throws DeploymentException {
InputStream in = di.localCl.getResourceAsStream("META-INF/application-client.xml");
if( in == null )
throw new DeploymentException("No META-INF/application-client.xml found");
ClientMetaData metaData = null;
try
{
XmlFileLoader xfl = new XmlFileLoader(true);
Element appClient = xfl.getDocument(in, "META-INF/application.xml").getDocumentElement();
in.close();
metaData = new ClientMetaData();
metaData.importClientXml(appClient);
di.metaData = metaData;
// Look for a jboss-client.xml descriptor
in = di.localCl.getResourceAsStream("META-INF/jboss-client.xml");
if( in != null )
{
xfl = new XmlFileLoader(true);
Element jbossClient = xfl.getDocument(in, "META-INF/jboss-client.xml").getDocumentElement();
in.close();
metaData.importJbossClientXml(jbossClient);
}
}
catch (IOException e)
{
throw new DeploymentException("Failed to parse metadata", e);
}
try
{
setupEnvironment(di, metaData);
}
catch (Exception e)
{
throw new DeploymentException("Failed to setup client ENC", e);
}
super.create(di);
}
Parse the application-client.xml and jboss-client.xml descriptors. |
public void destroy(DeploymentInfo di) throws DeploymentException {
// Setup a JNDI context which contains
ClientMetaData metaData = (ClientMetaData) di.metaData;
String appClientName = metaData.getJndiName();
try
{
InitialContext iniCtx = new InitialContext();
Util.unbind(iniCtx, appClientName);
}
catch(NamingException e)
{
throw new DeploymentException("Failed to remove client ENC", e);
}
super.destroy(di);
}
Sub-classes should override this method to provide
custom 'destroy' logic.
This method issues a JMX notification of type SubDeployer.DESTROY_NOTIFICATION. |
public void start(DeploymentInfo di) throws DeploymentException {
super.start(di);
}
Sub-classes should override this method to provide
custom 'start' logic.
This method issues a JMX notification of type SubDeployer.START_NOTIFICATION. |
protected void startService() throws Exception {
// register with MainDeployer
super.startService();
}
|
public void stop(DeploymentInfo di) throws DeploymentException {
super.stop(di);
}
Sub-classes should override this method to provide
custom 'stop' logic.
This method issues a JMX notification of type SubDeployer.START_NOTIFICATION. |
protected void stopService() throws Exception {
// deregister with MainDeployer
super.stopService();
}
Implements the template method in superclass. This method stops all the
applications in this server. |