Package org.sonatype.nexus.capability

Examples of org.sonatype.nexus.capability.CapabilityFactory


  public final void setUpCapabilityRegistry() throws Exception {
    final ValidatorRegistryProvider validatorRegistryProvider = mock(ValidatorRegistryProvider.class);
    final ValidatorRegistry validatorRegistry = mock(ValidatorRegistry.class);
    when(validatorRegistryProvider.get()).thenReturn(validatorRegistry);

    final CapabilityFactory factory = mock(CapabilityFactory.class);
    when(factory.create()).thenAnswer(new Answer<Capability>()
    {
      @Override
      public Capability answer(final InvocationOnMock invocation)
          throws Throwable
      {
View Full Code Here


  private DefaultCapabilityReference create(final CapabilityIdentity id,
                                            final CapabilityType type,
                                            final CapabilityDescriptor descriptor)
  {
    final CapabilityFactory factory = capabilityFactoryRegistry.get(type);
    if (factory == null) {
      throw new RuntimeException(format("No factory found for a capability of type %s", type));
    }

    final Capability capability = factory.create();

    final DefaultCapabilityReference reference = createReference(id, type, descriptor, capability);

    references.put(id, reference);
View Full Code Here

  }

  @Override
  public CapabilityFactoryRegistry unregister(final CapabilityType type) {
    if (type != null) {
      final CapabilityFactory factory = dynamicFactories.remove(type);
      log.debug("Removed {} -> {}", type, factory);
    }

    return this;
  }
View Full Code Here

    return this;
  }

  @Override
  public CapabilityFactory get(final CapabilityType type) {
    CapabilityFactory factory = factories.get(checkNotNull(type).toString());
    if (factory == null) {
      factory = dynamicFactories.get(checkNotNull(type).toString());
    }
    if (factory == null) {
      final CapabilityDescriptor descriptor = capabilityDescriptorRegistry.get(type);
      if (descriptor != null && descriptor instanceof CapabilityFactory) {
        factory = (CapabilityFactory) descriptor;
      }
      if (factory == null) {
        try {
          final Iterable<? extends BeanEntry<?, Capability>> entries = beanLocator.locate(
              Key.get(Capability.class, named(type.toString()))
          );
          if (entries != null && entries.iterator().hasNext()) {
            factory = new CapabilityFactory()
            {
              @Override
              public Capability create() {
                return entries.iterator().next().getValue();
              }
View Full Code Here

      final Validator validator = descriptor.validator();
      if (validator != null) {
        typeValidators.add(validator);
      }

      final CapabilityFactory factory = capabilityFactoryRegistry.get(type);
      if (factory != null) {
        if (factory instanceof Validator) {
          typeValidators.add((Validator) factory);
        }
      }
View Full Code Here

TOP

Related Classes of org.sonatype.nexus.capability.CapabilityFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.