1 23 package com.sun.enterprise.admin.wsmgmt.repository.impl.cache; 24 25 import java.util.List ; 26 import java.util.ArrayList ; 27 import java.util.Set ; 28 import java.util.Iterator ; 29 import com.sun.enterprise.deployment.backend.DeploymentEventListener; 30 import com.sun.enterprise.deployment.backend.DeploymentEventInfo; 31 import com.sun.enterprise.deployment.backend.DeploymentEvent; 32 import com.sun.enterprise.deployment.backend.DeploymentRequest; 33 import com.sun.enterprise.deployment.Application; 34 import com.sun.enterprise.deployment.BundleDescriptor; 35 import com.sun.enterprise.deployment.WebServicesDescriptor; 36 import com.sun.enterprise.admin.wsmgmt.WebServiceMgrBackEnd; 37 38 import java.util.logging.Logger ; 39 import java.util.logging.Level ; 40 import com.sun.logging.LogDomains; 41 42 54 public class AppServDELImpl implements DeploymentEventListener { 55 56 59 public AppServDELImpl() { 60 } 61 62 69 public void notifyDeploymentEvent(DeploymentEvent event) { 70 71 try { 72 DeploymentEventInfo info = null; 73 if (event !=null) { 74 info = event.getEventInfo(); 75 } 76 Application rootDD = null; 77 DeploymentRequest dr = null; 78 if (info != null) { 79 rootDD = info.getApplicationDescriptor(); 80 dr = info.getDeploymentRequest(); 81 } 82 CacheMgr mgr = CacheMgr.getInstance(); 83 84 if ((event != null) 86 && (event.getEventType()==DeploymentEvent.POST_DEPLOY)) { 87 88 if (dr.isEjbModule()) { 90 Set ws = rootDD.getWebServiceDescriptors(); 91 if ((ws != null) && !ws.isEmpty()) { 92 mgr.addEjbModule(dr.getName()); 93 mgr.save(); 94 } 95 96 } else if (dr.isWebModule()) { 98 Set ws = rootDD.getWebServiceDescriptors(); 99 if ((ws != null) && !ws.isEmpty()) { 100 mgr.addWebModule(dr.getName()); 101 mgr.save(); 102 } 103 104 } else if (dr.isApplication()) { 106 List ejb = new ArrayList (); 107 Set ejbBundles = rootDD.getEjbBundleDescriptors(); 108 109 for (Iterator iter=ejbBundles.iterator(); iter.hasNext();) { 110 BundleDescriptor bd = (BundleDescriptor) iter.next(); 111 WebServicesDescriptor wsDD = bd.getWebServices(); 112 if (wsDD.hasWebServices()) { 113 114 ejb.add(bd.getModuleDescriptor().getArchiveUri()); 116 } 117 } 118 119 List web = new ArrayList (); 120 Set webBundles = rootDD.getWebBundleDescriptors(); 121 for (Iterator iter=webBundles.iterator(); iter.hasNext();) { 122 BundleDescriptor bd = (BundleDescriptor) iter.next(); 123 WebServicesDescriptor wsDD = bd.getWebServices(); 124 if (wsDD.hasWebServices()) { 125 126 web.add(bd.getModuleDescriptor().getArchiveUri()); 128 } 129 } 130 131 if ( (!ejb.isEmpty()) || (!web.isEmpty()) ) { 132 mgr.addJ2eeApplication(dr.getName(), ejb, web); 133 mgr.save(); 134 } 135 } 136 WebServiceMgrBackEnd.getManager().removeFromCache(dr.getName()); 137 138 139 } else if ((event != null) 141 && (event.getEventType()==DeploymentEvent.POST_UNDEPLOY)) { 142 143 if (dr.isEjbModule()) { 145 mgr.removeEjbModule(dr.getName()); 146 mgr.save(); 147 } else if (dr.isWebModule()) { 148 mgr.removeWebModule(dr.getName()); 149 mgr.save(); 150 } else if (dr.isApplication()) { 151 mgr.removeJ2eeApplication(dr.getName()); 152 mgr.save(); 153 } 154 WebServiceMgrBackEnd.getManager().removeFromCache(dr.getName()); 155 } 156 157 158 159 } catch (Exception e) { 160 _logger.log(Level.FINE, "Error in deployment event listener", e); 161 } 162 } 163 164 private static Logger _logger = Logger.getLogger(LogDomains.ADMIN_LOGGER); 166 } 167 | Popular Tags |