1 23 24 package com.sun.enterprise.appclient.jws; 25 26 import com.sun.enterprise.deployment.Application; 27 import com.sun.enterprise.deployment.ApplicationClientDescriptor; 28 import com.sun.enterprise.deployment.BundleDescriptor; 29 import com.sun.enterprise.deployment.runtime.JavaWebStartAccessDescriptor; 30 import com.sun.enterprise.deployment.util.ModuleDescriptor; 31 import com.sun.enterprise.server.event.ApplicationClientEvent; 32 import com.sun.enterprise.server.event.ApplicationClientLoaderEventListener; 33 import com.sun.enterprise.server.event.ApplicationEvent; 34 import com.sun.enterprise.server.event.ApplicationLoaderEventListener; 35 import com.sun.enterprise.server.event.ApplicationLoaderEventNotifier; 36 import com.sun.logging.LogDomains; 37 import java.io.IOException ; 38 import java.util.Iterator ; 39 import java.util.Vector ; 40 import java.util.logging.Level ; 41 import java.util.logging.Logger ; 42 import javax.enterprise.deploy.shared.ModuleType ; 43 44 51 public class AppclientJWSSupportManager implements ApplicationLoaderEventListener, ApplicationClientLoaderEventListener { 52 53 private static Logger _logger=LogDomains.getLogger(LogDomains.SERVER_LOGGER); 54 55 56 private static AppclientJWSSupportManager instance; 57 58 59 private AppclientJWSSupportInfo jwsInfo; 60 61 62 private static final String JWS_FEATURE_ON_PROPERTY_NAME = "com.sun.aas.jws.featureon"; 63 64 65 private final boolean isJWSFeatureOn = Boolean.valueOf(System.getProperty(JWS_FEATURE_ON_PROPERTY_NAME, "true")); 66 67 71 public static AppclientJWSSupportManager getInstance() { 72 if (instance == null) { 73 instance = new AppclientJWSSupportManager(); 74 if (instance.isJWSFeatureOn) { 75 try { 76 79 instance.jwsInfo = AppclientJWSSupportInfo.getInstance(); 80 } catch (IOException ioe) { 81 _logger.log(Level.SEVERE, "Error initializing Java Web Start support information", ioe); 82 } catch (Exception e) { 83 throw new RuntimeException (e); 84 } 85 } 86 } 87 return instance; 88 } 89 90 94 public void startJWSServicesForDeployedAppclients() { 95 jwsInfo.startJWSServicesForDeployedAppclients(); 96 } 97 98 99 100 private AppclientJWSSupportManager() { 101 105 if (isJWSFeatureOn) { 106 ApplicationLoaderEventNotifier.getInstance().addListener((ApplicationLoaderEventListener) this); 107 ApplicationLoaderEventNotifier.getInstance().addListener((ApplicationClientLoaderEventListener) this); 108 } else { 109 _logger.info("Java Web Start support turned off by " + JWS_FEATURE_ON_PROPERTY_NAME); 110 } 111 } 112 113 117 public void handleApplicationEvent(ApplicationEvent event) { 118 121 int eventType = event.getEventType(); 122 if ((eventType == event.BEFORE_APPLICATION_LOAD) || 123 (eventType == event.AFTER_APPLICATION_UNLOAD) ) { 124 return; 125 } 126 127 132 Application app = event.getApplication(); 133 ModuleDescriptor [] mds = NamingConventions.getEligibleAppclientModuleDescriptors(app); 134 135 if (mds.length > 0) { 136 try { 137 if (eventType == event.AFTER_APPLICATION_LOAD) { 138 jwsInfo.startJWSServicesForApplication(app, mds); 139 } else if (eventType == event.BEFORE_APPLICATION_UNLOAD) { 140 jwsInfo.endJWSServicesForApplication(app, mds); 141 } 142 } catch (Throwable thr) { 143 _logger.log(Level.SEVERE, "Error updating Java Web Start information for application " + app.getRegistrationName(), thr); 144 } 145 } 146 147 } 148 149 152 public void handleEjbContainerEvent(com.sun.enterprise.server.event.EjbContainerEvent ejbContainerEvent) { 153 } 154 155 159 public void handleApplicationClientEvent(ApplicationClientEvent event) { 160 163 int eventType = event.getEventType(); 164 if ((eventType == event.BEFORE_APPLICATION_CLIENT_LOAD) || 165 (eventType == event.AFTER_APPLICATION_CLIENT_UNLOAD) ) { 166 return; 167 } 168 169 172 Application app = event.getApplication(); 173 174 178 ModuleDescriptor [] mds = NamingConventions.getEligibleAppclientModuleDescriptors(app); 179 180 if (mds.length > 1) { 181 _logger.warning("During app client loading, expected exactly one app client module in the wrapping application but found more; using the first one and ignoring the others"); 182 } else if (mds.length == 0) { 183 _logger.warning("During app client loading, expected exactly one app client module in the wrapping application but found none; ignoring this app client and continuing"); 184 return; 185 } 186 187 try { 188 if (eventType == event.AFTER_APPLICATION_CLIENT_LOAD) { 189 jwsInfo.startJWSServicesForAppclient(app, mds[0]); 190 } else if (eventType == event.BEFORE_APPLICATION_CLIENT_UNLOAD) { 191 jwsInfo.endJWSServicesForAppclient(app, mds[0]); 192 } 193 } catch (Throwable thr) { 194 _logger.log(Level.SEVERE, "Error updating Java Web Start information for app client " + app.getRegistrationName(), thr); 195 } 196 } 197 } 198 | Popular Tags |