Revision 832 org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.lib/src/main/java/org/gvsig/tools/locator/AbstractLocator.java

View differences:

AbstractLocator.java
32 32
import java.util.Map;
33 33

  
34 34
import org.gvsig.tools.extensionpoint.ExtensionPoint;
35
import org.gvsig.tools.extensionpoint.ExtensionPoint.Extension;
35 36
import org.gvsig.tools.extensionpoint.ExtensionPointManager;
36 37
import org.gvsig.tools.extensionpoint.impl.DefaultExtensionPointManager;
37 38
import org.slf4j.Logger;
......
61 62
                    throw new LocatorReferenceException(ex, name, this);
62 63
                }
63 64
                instances.put(name, instance);
64
    			logger.info("Stored the instance of " + name + " in the singleton table.");
65
                if( logger.isInfoEnabled() ) {
66
                	logger.info("Created and stored the instance of " + name + " in the singleton table (" + instance.getClass().getName() + "/" + instance.toString()+ ").");
67
                }
65 68
            }
66 69
        }
67 70

  
......
69 72
    }
70 73

  
71 74
    public boolean exists(String name) {
72
        return instances.containsKey(name); 
75
    	Extension extension = getExtensionPoint().get(name);
76
    	return extension != null;
73 77
    }
74
    
78

  
75 79
    private void removeFromInstances(String name) {
76 80
    	synchronized (lock) {
77
    		if(instances.containsKey(name)) {
78
    			logger.info("Removing the instance of " + name + " from the singleton table.");
81
			Object instance = instances.get(name);
82
    		if( instance!=null ) {
83
    			logger.warn("Removing the instance of " + name + " from the singleton table.(" + instance.getClass().getName() + "/" + instance.toString()+ ") ");
79 84
    			instances.remove(name);
80 85
    		}
81 86
    	}
......
92 97
    public void register(String name, Class clazz) {
93 98
    	DefaultExtensionPointManager.getManager().add(getLocatorName())
94 99
				.append(name, null, clazz);
100
		logger.info("Registered class " + clazz.getName() + " in locator " + name + ".");
95 101
    	removeFromInstances(name);
96 102
    }
97 103

  
......
106 112
    	DefaultExtensionPointManager.getManager().add(getLocatorName())
107 113
				.append(name,
108 114
                description, clazz);
115
		logger.info("Registered class " + clazz.getName() + " in locator " + name + ".");
109 116
    	removeFromInstances(name);
110 117
    }
111 118

  
......
121 128
    	DefaultExtensionPointManager.getManager().add(getLocatorName()).append(
122 129
				name, null,
123 130
                factory);
131
		logger.info("Registered factory " + factory.getClass().getName() + "/" + factory.toString() + " in locator " + name + ".");
124 132
    	removeFromInstances(name);
125 133
    }
126 134

  
......
129 137
    	DefaultExtensionPointManager.getManager().add(getLocatorName()).append(
130 138
				name,
131 139
                description, factory);
140
		logger.info("Registered factory " + factory.getClass().getName() + "/" + factory.toString() + " in locator " + name + ".");
132 141
    	removeFromInstances(name);
133 142
    }
134 143

  

Also available in: Unified diff