DeploymentEventInfo info = null;
if (event !=null) {
info = event.getEventInfo();
}
Application rootDD = null;
DeploymentRequest dr = null;
if (info != null) {
rootDD = info.getApplicationDescriptor();
dr = info.getDeploymentRequest();
}
CacheMgr mgr = CacheMgr.getInstance();
// post deploy event
if ((event != null)
&& (event.getEventType()==DeploymentEvent.POST_DEPLOY)) {
// if an ejb module
if (dr.isEjbModule()) {
Set ws = rootDD.getWebServiceDescriptors();
if ((ws != null) && !ws.isEmpty()) {
mgr.addEjbModule(dr.getName());
mgr.save();
}
// if a web module
} else if (dr.isWebModule()) {
Set ws = rootDD.getWebServiceDescriptors();
if ((ws != null) && !ws.isEmpty()) {
mgr.addWebModule(dr.getName());
mgr.save();
}
// if application
} else if (dr.isApplication()) {
List ejb = new ArrayList();
Set ejbBundles = rootDD.getEjbBundleDescriptors();
for (Iterator iter=ejbBundles.iterator(); iter.hasNext();) {
BundleDescriptor bd = (BundleDescriptor) iter.next();
WebServicesDescriptor wsDD = bd.getWebServices();
if (wsDD.hasWebServices()) {
// ejb bundle has web services
ejb.add(bd.getModuleDescriptor().getArchiveUri());
}
}
List web = new ArrayList();
Set webBundles = rootDD.getWebBundleDescriptors();
for (Iterator iter=webBundles.iterator(); iter.hasNext();) {
BundleDescriptor bd = (BundleDescriptor) iter.next();
WebServicesDescriptor wsDD = bd.getWebServices();
if (wsDD.hasWebServices()) {
// web bundle has web services
web.add(bd.getModuleDescriptor().getArchiveUri());
}
}
if ( (!ejb.isEmpty()) || (!web.isEmpty()) ) {
mgr.addJ2eeApplication(dr.getName(), ejb, web);
mgr.save();
}
}
WebServiceMgrBackEnd.getManager().removeFromCache(dr.getName());
// post undeploy event and pre deploy event
} else if ((event != null)
&& (event.getEventType()==DeploymentEvent.POST_UNDEPLOY ||
event.getEventType()==DeploymentEvent.PRE_DEPLOY)) {
// removes the app entry from cache
if (dr.isEjbModule()) {
mgr.removeEjbModule(dr.getName());
mgr.save();
} else if (dr.isWebModule()) {
mgr.removeWebModule(dr.getName());
mgr.save();
} else if (dr.isApplication()) {
mgr.removeJ2eeApplication(dr.getName());
mgr.save();
}
WebServiceMgrBackEnd.getManager().removeFromCache(dr.getName());
}
} catch (Exception e) {