]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - org.argeo.server.jcr/src/org/argeo/jcr/DefaultRepositoryRegister.java
Improve and simplify OSGi Boot
[lgpl/argeo-commons.git] / org.argeo.server.jcr / src / org / argeo / jcr / DefaultRepositoryRegister.java
index f13c84e3b8b1ca8fb8d4e297c3467b5dd1362fa9..e2a5026d83ba899799950e5eb6e139025a55fff6 100644 (file)
@@ -26,6 +26,7 @@ import javax.jcr.RepositoryException;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
+@Deprecated
 public class DefaultRepositoryRegister extends Observable implements
                RepositoryRegister, ArgeoJcrConstants {
        private final static Log log = LogFactory
@@ -57,11 +58,10 @@ public class DefaultRepositoryRegister extends Observable implements
        /** Registers a service, typically called when OSGi services are bound. */
        @SuppressWarnings("rawtypes")
        public synchronized void register(Repository repository, Map properties) {
-               // TODO: also check bean name?
                String alias;
                if (properties == null || !properties.containsKey(JCR_REPOSITORY_ALIAS)) {
                        log.warn("Cannot register a repository if no "
-                                       + JCR_REPOSITORY_ALIAS + " property is speecified.");
+                                       + JCR_REPOSITORY_ALIAS + " property is specified.");
                        return;
                }
                alias = properties.get(JCR_REPOSITORY_ALIAS).toString();
@@ -86,7 +86,10 @@ public class DefaultRepositoryRegister extends Observable implements
                String alias = properties.get(JCR_REPOSITORY_ALIAS).toString();
                Map<String, Repository> map = new TreeMap<String, Repository>(
                                repositories);
-               map.put(alias, repository);
+               if (map.remove(alias) == null) {
+                       log.warn("No repository was registered with alias " + alias);
+                       return;
+               }
                repositories = Collections.unmodifiableMap(map);
                setChanged();
                notifyObservers(alias);