Interface OsgiServiceRegistry

  • All Known Implementing Classes:
    OsgiServiceRegistryImpl

    public interface OsgiServiceRegistry
    This registry eliminates the boilerplate required for a component in Confluence Core to consume a service that is not available in the application context, but exclusively published through OSGi.

    Use this registry to obtain services published this way from CORE code only.

    This registry can be used as a factory bean so that client code can remain agnostic of this class.

    The following example spring config creates the ContentPropertyService using the osgiServiceRegistry as a factory bean :

      <bean id="contentPropertyService" factory-bean="osgiServiceRegistry" factory-method="getService" >
          <constructor-arg type="java.lang.Class"
              value="com.atlassian.confluence.api.service.content.ContentPropertyService"/>
      </bean>
     

    NOTE: this registry's intended behaviour pretty closely overlaps a very small subset of what Gemini / Spring DM offers, but we don't want to depend on those tools for what is a moderately straightforward task.

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      <T> T getService​(Class<T> clazz)
      Provides an implementation of the given interface T that is guaranteed to be backed by the highest ranked OSGi service implementing T.
    • Method Detail

      • getService

        <T> T getService​(Class<T> clazz)
        Provides an implementation of the given interface T that is guaranteed to be backed by the highest ranked OSGi service implementing T. The provided implementation will fail fast if the service is not available - it will NOT wait for the service to become available.

        It is expected callers will use this method to obtain services that they will invoke later in response to user activity. Invoking methods on returned implementation immediately will probably not work, unless you know what you're doing.