Révision 1882
tmp/org.txm.core/src/java/org/txm/core/engines/EnginesManager.java (revision 1882) | ||
---|---|---|
10 | 10 |
import org.txm.utils.logger.Log; |
11 | 11 |
|
12 | 12 |
/** |
13 |
* Extension point for an Engine (eg. Search engine, Stats engine, etc.). It is |
|
14 |
* a service that may be used by TXM commands. The Toolbox will manage the |
|
15 |
* engines life-cycle. |
|
13 |
* Extension point for an engines manager (eg. SearchEnginesManager, StatsEnginesManager, ChartsEnginesManager, etc.). |
|
14 |
* Engines manager are in charge of retrieving the engines from the engine installed contributions. |
|
15 |
* They also batch start, stop, etc. the engines of the type they managed (eg. Search engine, Stats engine, etc.). |
|
16 |
* It is a service that may be used by TXM commands. The Toolbox will manage the engines life-cycle. |
|
16 | 17 |
* |
17 | 18 |
* @author mdecorde |
18 | 19 |
* @author sjacquot |
... | ... | |
20 | 21 |
*/ |
21 | 22 |
public abstract class EnginesManager<T extends Engine> extends HashMap<String, T>{ |
22 | 23 |
|
23 |
/** |
|
24 |
* |
|
25 |
*/ |
|
26 | 24 |
private static final long serialVersionUID = 9186978207738860351L; |
27 | 25 |
|
28 | 26 |
public static final String ENGINES_MANAGER_EXTENSION_POINT_ID = EnginesManager.class.getName(); |
29 | 27 |
|
30 |
// /** |
|
31 |
// * Managed engines map (name => engine). |
|
32 |
// */ |
|
33 |
// protected HashMap<String, T> engines = new HashMap<String, T>(); |
|
34 |
|
|
35 | 28 |
/** |
36 | 29 |
* Current engine. |
37 | 30 |
*/ |
38 | 31 |
protected T currentEngine = null; |
39 | 32 |
|
33 |
|
|
34 |
|
|
40 | 35 |
/** |
41 | 36 |
* Finds out the engines that matches this manager engines extension point. |
42 | 37 |
* |
... | ... | |
55 | 50 |
IConfigurationElement[] contributions = RegistryFactory.getRegistry().getConfigurationElementsFor(engineExtensionPointId); |
56 | 51 |
|
57 | 52 |
Log.finest(TXMCoreMessages.bind("Looking for {0} engines contributions with extension point id {1}...", this.getEnginesDescription(), engineExtensionPointId)); //$NON-NLS-1$ |
58 |
Log.finest(contributions.length + " engine(s) found."); //$NON-NLS-1$
|
|
53 |
Log.finest(TXMCoreMessages.bind("{0} engine(s) found.", contributions.length)); //$NON-NLS-1$
|
|
59 | 54 |
|
60 | 55 |
for (int i = 0; i < contributions.length; i++) { |
61 | 56 |
try { |
62 | 57 |
@SuppressWarnings("unchecked") |
63 |
T e = (T) contributions[i].createExecutableExtension("class"); //$NON-NLS-1$ |
|
58 |
T engine = (T) contributions[i].createExecutableExtension("class"); //$NON-NLS-1$
|
|
64 | 59 |
|
65 |
Log.fine(TXMCoreMessages.bind("Initializing engine: {0}...", e)); |
|
60 |
Log.fine(TXMCoreMessages.bind("Initializing engine: {0}...", engine));
|
|
66 | 61 |
|
67 |
if (e.initialize()) { |
|
68 |
this.put(e.getName(), e);
|
|
62 |
if (engine.initialize()) {
|
|
63 |
this.put(engine.getName(), engine);
|
|
69 | 64 |
} else { |
70 |
Log.severe("Failed to initialize " + e.getName() + " engine."); |
|
65 |
Log.severe("Failed to initialize " + engine.getName() + " engine.");
|
|
71 | 66 |
} |
72 | 67 |
} catch (Exception e) { |
73 | 68 |
Log.severe("Error: failed to instantiate " + contributions[i].getName() + "."); |
Formats disponibles : Unified diff