KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > directory > ldapstudio > browser > core > BrowserCorePlugin


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  *
19  */

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 /**
34  * The main plugin class to be used in the desktop.
35  */

36 public class BrowserCorePlugin extends Plugin
37 {
38     /** The plugin ID */
39     public static final String JavaDoc PLUGIN_ID = "org.apache.directory.ldapstudio.browser.core"; //$NON-NLS-1$
40

41     /** The shared instance. */
42     private static BrowserCorePlugin plugin;
43
44     /** The connection manager */
45     private ConnectionManager connectionManager;
46
47     /** The credential provider */
48     private IAuthHandler authHandler;
49
50     /** The connection provider */
51     private IReferralHandler referralHandler;
52
53     /** The preferences */
54     private BrowserCorePreferences preferences;
55
56     /** The event runner. */
57     private EventRunner eventRunner;
58
59
60     /**
61      * Creates a new instance of BrowserCorePlugin.
62      */

63     public BrowserCorePlugin()
64     {
65         super();
66         plugin = this;
67         this.preferences = new BrowserCorePreferences();
68     }
69
70
71     /**
72      * {@inheritDoc}
73      */

74     public void start( BundleContext context ) throws Exception JavaDoc
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     /**
91      * {@inheritDoc}
92      */

93     public void stop( BundleContext context ) throws Exception JavaDoc
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     /**
115      * Returns the BrowserPlugin instance.
116      *
117      * @return The BrowserPlugin instance
118      */

119     public static BrowserCorePlugin getDefault()
120     {
121         return plugin;
122     }
123
124
125     /**
126      * Gets the Connection Manager
127      *
128      * @return
129      * the connection manager
130      */

131     public ConnectionManager getConnectionManager()
132     {
133         return connectionManager;
134     }
135
136
137     /**
138      *
139      * @return The preferences
140      */

141     public BrowserCorePreferences getCorePreferences()
142     {
143         return preferences;
144     }
145
146
147     /**
148      * Gets the AuthHandler
149      *
150      * @return
151      * the AuthHandler
152      */

153     public IAuthHandler getAuthHandler()
154     {
155         return authHandler;
156     }
157
158
159     /**
160      * Sets the AuthHandler
161      *
162      * @param authHandler
163      * the authHandler to set
164      */

165     public void setAuthHandler( IAuthHandler authHandler )
166     {
167         this.authHandler = authHandler;
168     }
169
170
171     /**
172      * Gets the ReferralHanlder
173      *
174      * @return
175      * the ReferralHandler
176      */

177     public IReferralHandler getReferralHandler()
178     {
179         return referralHandler;
180     }
181
182
183     /**
184      * Sets the ReferralHandler
185      *
186      * @param referralHandler
187      * the ReferralHandler to set
188      */

189     public void setReferralHandler( IReferralHandler referralHandler )
190     {
191         this.referralHandler = referralHandler;
192     }
193
194
195     /**
196      * Gets the event runner.
197      *
198      * @return the event runner
199      */

200     public EventRunner getEventRunner()
201     {
202         return eventRunner;
203     }
204 }
205
Popular Tags