class EditionLocksFactories {

    public static LocksFactory createLockFactory( Config config, LogService logging )
    {
        String key = config.get( GraphDatabaseSettings.lock_manager );
        for ( DynamicLocksFactory candidate : Service.load( DynamicLocksFactory.class ) )
        {
            String candidateId = candidate.getKeys().iterator().next();
            if ( key.equals( candidateId ) )
            {
                return candidate;
            }
            else if ( "".equals( key ) )
            {
                logging.getInternalLog( CommunityEditionModule.class )
                        .info( "No locking implementation specified, defaulting to '" + candidateId + "'" );
                return candidate;
            }
        }

        if ( "community".equals( key ) )
        {
            return new CommunityLocksFactory();
        }
        else if ( StringUtils.isEmpty( key ) )
        {
            logging.getInternalLog( CommunityEditionModule.class )
                    .info( "No locking implementation specified, defaulting to 'community'" );
            return new CommunityLocksFactory();
        }

        throw new IllegalArgumentException( "No lock manager found with the name '" + key + "'." );
    }

}