class AbstractSessionHolderProviderManager implements SessionHolderProviderManager {

    public SessionHolderProvider getSessionProvider(Repository repository) {
        // graceful fallback
        if (repository == null)
            return defaultProvider;

        String key = repository.getDescriptor(Repository.REP_NAME_DESC);
        List<SessionHolderProvider> providers = getProviders();

        // search the provider
        for (int i = 0; i < providers.size(); i++) {
            SessionHolderProvider provider = providers.get(i);
            if (provider.acceptsRepository(key)) {
                if (LOG.isDebugEnabled())
                    LOG.debug("specific SessionHolderProvider found for repository " + key);
                return provider;
            }
        }

        // no provider found - return the default one
        if (LOG.isDebugEnabled())
            LOG.debug("no specific SessionHolderProvider found for repository " + key + "; using the default one");
        return defaultProvider;
    }

}