Class PluginComponentAccessor

java.lang.Object
com.atlassian.crowd.plugin.PluginComponentAccessor

public class PluginComponentAccessor extends Object
Utility class to access OSGi components publicly exported by plugins.
Since:
v2.7
  • Constructor Details

    • PluginComponentAccessor

      public PluginComponentAccessor()
  • Method Details

    • getOSGiComponentInstanceOfType

      @Nullable public static <T> T getOSGiComponentInstanceOfType(Class<T> clazz)
      Returns an instance of the service identified by the given interface, as exported by a plugin module.

      Warning: as the instance returned comes from OSGi-land, it can become invalid at anytime (if the plugin is disabled/enabled for instance). For this reason, it should NEVER be cached (e.g stored in a field variable).

      Type Parameters:
      T - the interface type
      Parameters:
      clazz - the interface of the service
      Returns:
      an instance of the service, or null if no plugin publicly exports this particular service.
    • getOSGiComponentsInstanceOfType

      @Nonnull public static <T> List<T> getOSGiComponentsInstanceOfType(Class<T> clazz)
      Returns an instances of the service identified by the given interface, as exported by a plugin module.

      Warning: as the instance returned comes from OSGi-land, it can become invalid at anytime (if the plugin is disabled/enabled for instance). For this reason, it should NEVER be cached (e.g stored in a field variable).

      Type Parameters:
      T - the interface type
      Parameters:
      clazz - the interface of the service
      Returns:
      instances of the services implementing given interface