title: Blueprint: how do I check if an optional dependency is satisfied?
body: <p>In <code>blueprint.xml</code>, I declare an optional dependency this way:</p>
  
  <pre><code>&lt;reference id="RepositoryListener"
      interface="ru.focusmedia.odp.server.datastore.api.RepositoryListener"
      availability="optional" /&gt;
  
  &lt;bean id="Repository"
      class="ru.focusmedia.odp.server.datastore.jpa.repository.RepositoryImpl"&gt;
      &lt;jpa:context property="entityManager" unitname="ODP_Server" /&gt;
      &lt;tx:transaction method="*" value="Required" /&gt;
      &lt;property name="repositoryListener" ref="RepositoryListener" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>and in <code>RepositoryImpl</code>, I have</p>
  
  <pre><code>public void setRepositoryListener(RepositoryListener repositoryListener) {
      logger.info("Repository listener set");
      this.repositoryListener = repositoryListener;
  }
  </code></pre>
  
  <p>This method is called by Blueprint even when there is no <code>RepositoryListener</code> service available, as expected. The problem is, how can I check later whether there <em>is</em> a service?</p>
  
  <pre><code>    if (repositoryListener != null) {
          repositoryListener.notifyDelete(node);
      } else {
          logger.warn("No repository listener set!");
      }
  </code></pre>
  
  <p>doesn't work, since <code>repositoryListener</code> isn't <code>null</code>, but a Blueprint proxy.</p>