# J2EE Deployer

by Daniel Schulze

### The idea

The j2ee deployer is made to delpoy j2ee compilant applications which means .ear, ejb.jar and web.war files as well.

This MBean references the `org.jboss.ejb.ContainerFactoryBMBean` and `org.jboss.tomcat.EmbededTomcatServiceMBean`. Both beans have to run in the same server and since the deployer in his start service method tries to deploy all apps that were deployed before shutdown, these both services must be started before the j2ee deployer! To make this sure, there must be a service entry for the j2ee deployer in the jboss.dependencies file.

### How it works

deploy ()
  The deployer takes the given url and tries to determine the type of the given file (this is done by seeking one of the possible deployment descriptors in this file (application.xml, ejb-jar.xml, web.xml)). If a valid file type was determined, all for the deployment needed files (modules, libs, alternative DDs, ...) are downloaded to a local directory of the app server. Once this is done the ejb and war deployers (ContainerFactory and EmbeddedTomcat) are called to deploy the single modules.
  If this was successful, the current url is stored to the deployments collection. If one of the ejb/war deployer calls fails, the deployment becomes canceled and all downloaded files are deleted.
isDeployed ()
  Looks in the collection of deployments for the given url. If the url is found, the ejb/war deployer for each module of this app is asked for isDeployed () and only if all modules are correct deployed, the method returns true. If there is an inconsistence in the deployments an exception is thrown.
undeploy ()
  Undeployes all modules of this application,removes all server local files of this app and removes this url from the collection of deployed urls. (This method should always succeed).

### What is done

- download of ejb.jar and web.war modules
- deployment of these modules
- `isDeployed ()` - method added to ContainerFactory
- extracting web.wars on download

### What is to do

- replacing module DDs with alternative DDs
- integrity check in case of ear files
  - unify security roles
  - things I ve missed ...
- find common libraries, download them and add them to the classpath(s) of the modules
- move the verification stuff from the ContainerFactory to here?