Revision 827
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.lib/src/main/java/org/gvsig/tools/locator/AbstractLocator.java | ||
---|---|---|
42 | 42 |
* |
43 | 43 |
* @author <a href="mailto:cordin@disid.com">C?sar Ordi?ana</a> |
44 | 44 |
*/ |
45 |
public abstract class AbstractLocator implements Locator { |
|
45 |
public abstract class AbstractLocator implements Locator, Locator_withExists {
|
|
46 | 46 |
|
47 | 47 |
private Map instances = new HashMap(); |
48 | 48 |
private Logger logger = LoggerFactory.getLogger(AbstractLocator.class); |
... | ... | |
60 | 60 |
} catch (Exception ex) { |
61 | 61 |
throw new LocatorReferenceException(ex, name, this); |
62 | 62 |
} |
63 |
|
|
64 | 63 |
instances.put(name, instance); |
64 |
logger.info("Stored the instance of " + name + " in the singleton table."); |
|
65 | 65 |
} |
66 | 66 |
} |
67 | 67 |
|
68 | 68 |
return instance; |
69 | 69 |
} |
70 |
|
|
71 |
public boolean exists(String name) { |
|
72 |
return instances.containsKey(name); |
|
73 |
} |
|
70 | 74 |
|
71 | 75 |
private void removeFromInstances(String name) { |
72 | 76 |
synchronized (lock) { |
73 | 77 |
if(instances.containsKey(name)) { |
74 |
logger.info("Removing the instance" + name + " from the extension points");
|
|
78 |
logger.info("Removing the instance of " + name + " from the singleton table.");
|
|
75 | 79 |
instances.remove(name); |
76 | 80 |
} |
77 | 81 |
} |
... | ... | |
95 | 99 |
ExtensionPoint ep = getExtensionPoint(); |
96 | 100 |
if (ep.get(name) == null) { |
97 | 101 |
register(name, clazz); |
98 |
removeFromInstances(name); |
|
99 | 102 |
} |
100 | 103 |
} |
101 | 104 |
|
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.lib/src/main/java/org/gvsig/tools/locator/Locator_withExists.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
/* |
|
25 |
* AUTHORS (In addition to CIT): |
|
26 |
* 2008 {DiSiD Technologies} {Create a base Locator implementation} |
|
27 |
*/ |
|
28 |
package org.gvsig.tools.locator; |
|
29 |
|
|
30 |
/** |
|
31 |
* Add method exists to the Locator API |
|
32 |
* |
|
33 |
* This interface is to maintain compatility with the interface Locator. |
|
34 |
* |
|
35 |
*/ |
|
36 |
public interface Locator_withExists extends Locator { |
|
37 |
|
|
38 |
/** |
|
39 |
* Returns true if exists a manager registered for this name. |
|
40 |
* The manager can be created or no. |
|
41 |
* |
|
42 |
* @param name |
|
43 |
* of the object to return |
|
44 |
* @return true if a manager is registered for this name. |
|
45 |
*/ |
|
46 |
boolean exists(String name); |
|
47 |
} |
|
0 | 48 |
Also available in: Unified diff