Interface NoInstancesFilter

All Known Implementing Classes:
NoInstancesFilter.DefaultFilter

@Contract public interface NoInstancesFilter
Matches service classes that do not provide instances of themselves through automatic invocation of a constructor.

Use enableNoInstancesFilter(ServiceLocator) to enable the default filter, which matches abstract classes and classes with no public constructors.

When this filter matches a class, it is implied that the ActiveDescriptor for the class must disallow the creation of instances and must advertise no contracts.

This class may be useful in combination with ProvidesListener, for example, to permit registration of classes that do not provide themselves as a service but that provide other services by way of static members annotated with Provides.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static final class 
    Matches abstract classes and classes with no public constructors.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    enableNoInstancesFilter(org.glassfish.hk2.api.ServiceLocator locator)
    Enables the default NoInstancesFilter.
    boolean
    matches(Class<?> clazz)
    Returns true if the specified class does not provide instances of itself through automatic invocation of a constructor.
  • Method Details

    • matches

      boolean matches(Class<?> clazz)
      Returns true if the specified class does not provide instances of itself through automatic invocation of a constructor.
    • enableNoInstancesFilter

      static void enableNoInstancesFilter(org.glassfish.hk2.api.ServiceLocator locator)
      Enables the default NoInstancesFilter.

      This method replaces the default DynamicConfigurationService of the service locator. Therefore, this method must be invoked prior to any other configuration that relies on the NoInstancesFilter being applied. In other words, the filter will not be applied to classes that were already added to the service locator or that were already added to an uncommitted DynamicConfiguration for the service locator.

      This method is idempotent.