예제 #1
0
  /**
   * Create an unnamed {@link ServiceLocator}.
   *
   * @param binders custom the HK2 {@link Binder binders}.
   * @return a service locator with all the bindings.
   */
  public static ServiceLocator createLocator(Binder... binders) {
    ServiceLocator locator = factory.create(null, null, generator);

    ServiceLocatorUtilities.enablePerThreadScope(locator);

    for (Binder binder : binders) {
      bind(locator, binder);
    }

    return locator;
  }
예제 #2
0
  @Override
  public boolean configure(FeatureContext context) {
    try {
      dcs.getPopulator().populate(new HK2DescriptorFileFinder());

      enableImmediateScope(locator);
      enableInheritableThreadScope(locator);
      enableLookupExceptions(locator);
      enablePerThreadScope(locator);
      enableTopicDistribution(locator);

      return true;
    } catch (IOException | MultiException e) {
      return false;
    }
  }