1 11 package org.eclipse.tomcat.internal; 12 13 import java.util.*; 14 15 import org.eclipse.core.runtime.*; 16 import org.osgi.framework.*; 17 import org.osgi.service.url.*; 18 20 public class TomcatPlugin extends Plugin implements BundleActivator { 21 public final static String PLUGIN_ID = "org.eclipse.tomcat"; 23 public final static String PREF_ACCEPT_COUNT = "acceptCount"; public final static String PREF_MAX_PROCESSORS = "maxProcessors"; public final static String PREF_MIN_PROCESSORS = "minProcessors"; 28 public final static String PREF_SSL_PORT = "sslPort"; public final static String PREF_SSL_PROTOCOL = "sslProtocol"; public final static String PREF_SSL_SCHEME = "sslScheme"; public final static String PREF_SSL_ALGORITHM = "sslAlgorithm"; public final static String PREF_KEY_STORE_FILE = "keyStoreFile"; public final static String PREF_KEY_STORE_PASSWORD = "keyStorePassword"; 35 private static TomcatPlugin plugin; 36 38 private ServiceRegistration jndiURLServiceRegistration; 39 40 private TomcatAppServer appserver; 41 42 void setAppserver(TomcatAppServer appserver) { 43 this.appserver = appserver; 44 } 45 46 48 public TomcatPlugin() { 49 super(); 50 } 51 52 57 public static synchronized void logError(String message, Throwable ex) { 58 if (message == null) 59 message = ""; Status errorStatus = new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, 61 message, ex); 62 TomcatPlugin.getDefault().getLog().log(errorStatus); 63 } 64 65 public static TomcatPlugin getDefault() { 66 return plugin; 67 } 68 69 public void start(BundleContext context) throws Exception { 70 super.start(context); 71 plugin = this; 72 74 registerJndiURL(context); 75 } 76 77 public void stop(BundleContext context) throws Exception { 78 if(appserver!=null){ 79 try{ 80 appserver.stop(); 81 }catch(Exception e){ 82 } 83 } 84 unregisterJndiURL(); 85 86 plugin = null; 87 super.stop(context); 89 } 90 private void registerJndiURL(BundleContext context) { 91 Hashtable properties = new Hashtable(); 92 properties.put(URLConstants.URL_HANDLER_PROTOCOL, new String []{"jndi"}); try { 94 jndiURLServiceRegistration = context.registerService( 95 URLStreamHandlerService.class.getName(), 96 new JndiURLHandler(), properties); 97 } catch (Error t) { 98 logError(t.getMessage(), t); 99 throw t; 100 } 101 } 102 103 private void unregisterJndiURL() { 104 if (jndiURLServiceRegistration != null) { 105 jndiURLServiceRegistration.unregister(); 106 } 107 } 108 109 } 110 | Popular Tags |