class JcrSessionFactory implements InitializingBean, DisposableBean, SessionFactory {

    protected void registerNamespaces() throws Exception {

        if (namespaces == null || namespaces.isEmpty())
            return;

        if (LOG.isDebugEnabled())
            LOG.debug("registering custom namespaces " + namespaces);

        Session session = getBareSession();
        NamespaceRegistry registry = session.getWorkspace().getNamespaceRegistry();

        // do the lookup, so we avoid exceptions
        String[] prefixes = registry.getPrefixes();
        // sort the array
        Arrays.sort(prefixes);

        // unregister namespaces if told so
        if (forceNamespacesRegistration) {

            // save the old namespace only if it makes sense
            if (!keepNewNamespaces)
                overwrittenNamespaces = new HashMap<String, String>(namespaces.size());

            // search occurrences
            for (Object key : namespaces.keySet()) {
                String prefix = (String) key;
                int position = Arrays.binarySearch(prefixes, prefix);
                if (position >= 0) {
                    if (LOG.isDebugEnabled()) {
                        LOG.debug("prefix " + prefix + " was already registered; unregistering it");
                    }
                    if (!keepNewNamespaces) {
                        // save old namespace
                        overwrittenNamespaces.put(prefix, registry.getURI(prefix));
                    }
                    registry.unregisterNamespace(prefix);
                    // postpone registration for later
                }
            }
        }

        // do the registration
        for (Map.Entry<?, ?> entry : namespaces.entrySet()) {
            //            Map.Entry<String, String> namespace = (Map.Entry<String, String>) entry;
            String prefix = (String) entry.getKey();
            String ns = (String) entry.getValue();

            int position = Arrays.binarySearch(prefixes, prefix);

            if (skipExistingNamespaces && position >= 0) {
                LOG.debug("namespace already registered under [" + prefix + "]; skipping registration");
            } else {
                LOG.debug("registering namespace [" + ns + "] under [" + prefix + "]");
                registry.registerNamespace(prefix, ns);
            }
        }

        session.logout();
    }

    public  JcrSessionFactory(Repository repository, String workspaceName, Credentials credentials);
    public  JcrSessionFactory(Repository repository, String workspaceName, Credentials credentials, SessionHolderProviderManager sessionHolderProviderManager);
    public  JcrSessionFactory();

}