@Override protected void configure() { while (instances.peek() != null) { Instance constant = instances.poll(); Object instance = constant.getValue(); Class instanceType = instance.getClass(); String name = constant.getName(); Class contract = constant.getContract(); if (name != null && contract != null) { bind(instanceType).annotatedWith(Names.named(name)).toInstance(instance); bind(contract).annotatedWith(Names.named(name)).toInstance(instance); bind(contract).toInstance(instance); } else if (name != null) { bind(instanceType).annotatedWith(Names.named(name)).toInstance(instance); } else if (contract != null) { bind(contract).toInstance(instance); } else { for (Class instanceInterface : instanceType.getInterfaces()) { bind(instanceInterface).toInstance(instance); } } bind(instanceType).toInstance(instance); } }
Instance<Object> client = clientInstance.getClient(); String clientName = client.getName(); Class<?> clientContract = client.getContract(); Instance<Object> clientSupplier = foundClientSupplier.get(); String clientSupplierName = clientSupplier.getName(); Class<?> clientSupplierContract = clientSupplier.getContract();
void removeInstances(ServiceLocator serviceLocator, ConcurrentLinkedDeque<Instance<?>> instances) { instances.forEach(instance -> { String name = instance.getName(); Class contract = instance.getContract(); Class instanceType = instance.getClass(); IndexedFilter filter = BuilderHelper.createContractFilter(instanceType .getTypeName()); removeFilter(serviceLocator, filter, true); if (name != null && contract != null) { removeFilter(serviceLocator, createNameAndContractFilter(contract.getName(), name), true); removeFilter(serviceLocator, createNameFilter(name), true); removeFilter(serviceLocator, createContractFilter(contract.getName()), true); } else if (name != null) { removeFilter(serviceLocator, createNameFilter(name), true); } else if (contract != null) { removeFilter(serviceLocator, createContractFilter(contract.getName()), true); } }); }
void removeInstances(InjectionManager injectionManager, ConcurrentLinkedDeque<Instance<?>> instances) { ServiceLocator serviceLocator = ((ImmediateHk2InjectionManager) injectionManager) .getServiceLocator(); instances.forEach(instance -> { String name = instance.getName(); Class contract = instance.getContract(); Class instanceType = instance.getClass(); IndexedFilter filter = BuilderHelper.createContractFilter(instanceType .getTypeName()); removeFilter(serviceLocator, filter, true); if (name != null && contract != null) { removeFilter(serviceLocator, createNameAndContractFilter(contract.getName(), name), true); removeFilter(serviceLocator, createNameFilter(name), true); removeFilter(serviceLocator, createContractFilter(contract.getName()), true); } else if (name != null) { removeFilter(serviceLocator, createNameFilter(name), true); } else if (contract != null) { removeFilter(serviceLocator, createContractFilter(contract.getName()), true); } }); }
@Override protected void configure() { while (constants.peek() != null) { Instance constant = constants.poll(); Object instance = constant.getValue(); Class instanceType = instance.getClass(); String name = constant.getName(); Class contract = constant.getContract(); if (name != null && contract != null) { bind(instance).named(name).to(contract); bind(instance).to(contract); } else if (name != null) { bind(instance).named(name).to(instanceType); } else if (contract != null) { bind(instance).to(contract); } else { for (Class instanceInterface : instanceType.getInterfaces()) { bind(instance).to(instanceInterface); } } bind(instance).to(instanceType); } }
@Override protected void configure() { while (constants.peek() != null) { Instance constant = constants.poll(); Object instance = constant.getValue(); Class instanceType = instance.getClass(); String name = constant.getName(); Class contract = constant.getContract(); if (name != null && contract != null) { bind(instance).named(name).to(contract); bind(instance).to(contract); } else if (name != null) { bind(instance).named(name).to(instanceType); } else if (contract != null) { bind(instance).to(contract); } else { for (Class instanceInterface : instanceType.getInterfaces()) { bind(instance).to(instanceInterface); } } bind(instance).to(instanceType); } }
Class contract = instance.getContract();