1 20 21 package org.apache.directory.ldapstudio.browser.core; 22 23 24 import org.apache.directory.ldapstudio.browser.core.events.CoreEventRunner; 25 import org.apache.directory.ldapstudio.browser.core.events.EventRunner; 26 import org.apache.directory.ldapstudio.browser.core.model.IAuthHandler; 27 import org.apache.directory.ldapstudio.browser.core.model.IConnection; 28 import org.apache.directory.ldapstudio.browser.core.model.IReferralHandler; 29 import org.eclipse.core.runtime.Plugin; 30 import org.osgi.framework.BundleContext; 31 32 33 36 public class BrowserCorePlugin extends Plugin 37 { 38 39 public static final String PLUGIN_ID = "org.apache.directory.ldapstudio.browser.core"; 41 42 private static BrowserCorePlugin plugin; 43 44 45 private ConnectionManager connectionManager; 46 47 48 private IAuthHandler authHandler; 49 50 51 private IReferralHandler referralHandler; 52 53 54 private BrowserCorePreferences preferences; 55 56 57 private EventRunner eventRunner; 58 59 60 63 public BrowserCorePlugin() 64 { 65 super(); 66 plugin = this; 67 this.preferences = new BrowserCorePreferences(); 68 } 69 70 71 74 public void start( BundleContext context ) throws Exception  75 { 76 super.start( context ); 77 78 if ( eventRunner == null ) 79 { 80 eventRunner = new CoreEventRunner(); 81 } 82 83 if ( connectionManager == null ) 84 { 85 connectionManager = new ConnectionManager(); 86 } 87 } 88 89 90 93 public void stop( BundleContext context ) throws Exception  94 { 95 super.stop( context ); 96 97 if ( eventRunner != null ) 98 { 99 eventRunner = null; 100 } 101 102 if ( connectionManager != null ) 103 { 104 IConnection[] connections = connectionManager.getConnections(); 105 for ( int i = 0; i < connections.length; i++ ) 106 { 107 connections[i].close(); 108 } 109 connectionManager = null; 110 } 111 } 112 113 114 119 public static BrowserCorePlugin getDefault() 120 { 121 return plugin; 122 } 123 124 125 131 public ConnectionManager getConnectionManager() 132 { 133 return connectionManager; 134 } 135 136 137 141 public BrowserCorePreferences getCorePreferences() 142 { 143 return preferences; 144 } 145 146 147 153 public IAuthHandler getAuthHandler() 154 { 155 return authHandler; 156 } 157 158 159 165 public void setAuthHandler( IAuthHandler authHandler ) 166 { 167 this.authHandler = authHandler; 168 } 169 170 171 177 public IReferralHandler getReferralHandler() 178 { 179 return referralHandler; 180 } 181 182 183 189 public void setReferralHandler( IReferralHandler referralHandler ) 190 { 191 this.referralHandler = referralHandler; 192 } 193 194 195 200 public EventRunner getEventRunner() 201 { 202 return eventRunner; 203 } 204 } 205 | Popular Tags |