Пример #1
0
    @Override
    void complete(DynamicConfiguration configuration, HK2Loader defaultLoader) {
      if (this.loader == null) {
        this.loader = defaultLoader;
      }
      AbstractActiveDescriptor descriptor = BuilderHelper.createConstantDescriptor(service);
      descriptor.setName(name);
      descriptor.setLoader(this.loader);

      if (scope != null) {
        descriptor.setScope(scope.getName());
      }

      if (ranked != null) {
        descriptor.setRanking(ranked);
      }

      for (String key : metadata.keySet()) {
        for (String value : metadata.get(key)) {
          descriptor.addMetadata(key, value);
        }
      }

      for (Annotation annotation : qualifiers) {
        descriptor.addQualifierAnnotation(annotation);
      }

      for (Type contract : contracts) {
        descriptor.addContractType(contract);
      }

      configuration.bind(descriptor);
    }
Пример #2
0
    @Override
    void complete(final DynamicConfiguration configuration, final HK2Loader defaultLoader) {
      if (this.loader == null) {
        this.loader = defaultLoader;
      }

      ActiveDescriptorBuilder builder =
          BuilderHelper.activeLink(service).named(name).andLoadWith(this.loader);

      if (scope != null) {
        builder.in(scope);
      }

      if (ranked != null) {
        builder.ofRank(ranked);
      }

      for (String key : metadata.keySet()) {
        for (String value : metadata.get(key)) {
          builder.has(key, value);
        }
      }

      for (Annotation annotation : qualifiers) {
        builder.qualifiedBy(annotation);
      }

      for (Type contract : contracts) {
        builder.to(contract);
      }

      configuration.bind(builder.build());
    }
Пример #3
0
    @Override
    void complete(DynamicConfiguration configuration, HK2Loader defaultLoader) {
      if (this.loader == null) {
        this.loader = defaultLoader;
      }

      ActiveDescriptorBuilder factoryDescriptorBuilder =
          BuilderHelper.activeLink(factoryClass).named(name).andLoadWith(this.loader);
      if (factoryScope != null) {
        factoryDescriptorBuilder.in(factoryScope);
      }

      ActiveDescriptorBuilder descriptorBuilder =
          BuilderHelper.activeLink(factoryClass).named(name).andLoadWith(this.loader);
      if (scope != null) {
        descriptorBuilder.in(scope);
      }

      if (ranked != null) {
        //                factoryContractDescriptor.ofRank(factoryRank);
        descriptorBuilder.ofRank(ranked);
      }

      for (Annotation qualifier : qualifiers) {
        factoryDescriptorBuilder.qualifiedBy(qualifier);
        descriptorBuilder.qualifiedBy(qualifier);
      }

      for (Type contract : contracts) {
        factoryDescriptorBuilder.to(new ParameterizedTypeImpl(Factory.class, contract));
        descriptorBuilder.to(contract);
      }

      configuration.bind(
          new FactoryDescriptorsImpl(
              factoryDescriptorBuilder.build(), descriptorBuilder.buildFactory()));
    }
Пример #4
0
    @Override
    void complete(DynamicConfiguration configuration, HK2Loader defaultLoader) {
      if (this.loader == null) {
        this.loader = defaultLoader;
      }

      AbstractActiveDescriptor factoryContractDescriptor =
          BuilderHelper.createConstantDescriptor(factory);
      factoryContractDescriptor.addContractType(factory.getClass());
      factoryContractDescriptor.setName(name);
      factoryContractDescriptor.setLoader(this.loader);

      ActiveDescriptorBuilder descriptorBuilder =
          BuilderHelper.activeLink(factory.getClass()).named(name).andLoadWith(this.loader);
      if (scope != null) {
        descriptorBuilder.in(scope);
      }

      if (ranked != null) {
        descriptorBuilder.ofRank(ranked);
      }

      for (Annotation qualifier : qualifiers) {
        factoryContractDescriptor.addQualifierAnnotation(qualifier);
        descriptorBuilder.qualifiedBy(qualifier);
      }

      for (Type contract : contracts) {
        factoryContractDescriptor.addContractType(
            new ParameterizedTypeImpl(Factory.class, contract));
        descriptorBuilder.to(contract);
      }

      configuration.bind(
          new FactoryDescriptorsImpl(factoryContractDescriptor, descriptorBuilder.buildFactory()));
    }