I'm attempting to upgrade provision_solr to aegir 2.x.

I can't seem to get `solr_drush_init()` to run before Provision Server class gets initialized.

PHP Fatal error:  Uncaught exception 'ReflectionException' with message 'Class Provision_Service_solr does not exist' in /vagrant/repos/provision/Provision/Context/server.php:32

I followed the tips at http://community.aegirproject.org/content/contrib/class-auto-loading to get:


/**
 * Implements hook_drush_init()
 */
function solr_drush_init(){
  // @TODO: This is failing.  Provision is trying to load the Solr service before this ever gets called.
  drush_log('loading solr_drush_init', 'ok');
  solr_provision_register_autoload();
}

/**
 * Register our directory as a place to find Provision classes.
 *
 * This allows Provision to autoload our classes, so that we don't need to
 * specifically include the files before we use the class.
 */
function solr_provision_register_autoload() {
  static $loaded = FALSE;
  if (!$loaded) {
    $loaded = TRUE;
    $list = drush_commandfile_list();
    if (isset($list['provision'])) {
      $provision_dir = dirname($list['provision']);
      include_once($provision_dir . '/provision.inc');
      include_once($provision_dir . '/provision.service.inc');
      provision_autoload_register_prefix('Provision_', 'solr');
    }
  }
}

/**
 * Implements hook_provision_services()
 *
 *  Declares a new service type and a basic implementation of it.
 *  It matches the same service definition in the hosting front end.
 */
function solr_provision_services() {
  return array('solr' => NULL);
}