@Override public ForeignDescriptor createForeignDescriptor(Binding binding) { ForeignDescriptor foreignDescriptor = createAndTranslateForeignDescriptor(binding); ActiveDescriptor<Object> activeDescriptor = ServiceLocatorUtilities .addOneDescriptor(getServiceLocator(), (Descriptor) foreignDescriptor.get(), false); return ForeignDescriptor.wrap(activeDescriptor, activeDescriptor::dispose); }
@Override public ForeignDescriptor createForeignDescriptor(Binding binding) { ForeignDescriptor foreignDescriptor = createAndTranslateForeignDescriptor(binding); ActiveDescriptor<Object> activeDescriptor = ServiceLocatorUtilities .addOneDescriptor(getServiceLocator(), (Descriptor) foreignDescriptor.get(), false); return ForeignDescriptor.wrap(activeDescriptor, activeDescriptor::dispose); }
private ActiveDescriptor<Dom> addWithAlias(ServiceLocator locator, AbstractActiveDescriptor<?> descriptor, Class<?> contract, String name) { ActiveDescriptor<Dom> added = ServiceLocatorUtilities.findOneDescriptor(locator, descriptor); if (added == null) { if (ConfigBean.class.isAssignableFrom(this.getClass())) { if (!descriptor.getAdvertisedContracts().contains(ConfigBean.class.getName())) { descriptor.addContractType(ConfigBean.class); } } added = ServiceLocatorUtilities.addOneDescriptor(locator, descriptor); } AliasDescriptor<Dom> alias = new AliasDescriptor<Dom>(locator, added, contract.getName(), name); ServiceLocatorUtilities.addOneDescriptor(locator, alias); return added; }
ServiceLocatorUtilities.addOneDescriptor(locator, injectorDescriptor);
/** * It is very often the case that one wishes to add a single descriptor to * a service locator. This method adds that one descriptor. If the descriptor * is an {@link ActiveDescriptor} and is reified, it will be added as an * {@link ActiveDescriptor}. Otherwise it will be bound as a {@link Descriptor}. * A deep copy will be made of the descriptor passed in * * @param locator The non-null locator to add this descriptor to * @param descriptor The non-null descriptor to add to this locator * @return The descriptor that was added to the system * @throws MultiException On a commit failure */ public static <T> ActiveDescriptor<T> addOneDescriptor(ServiceLocator locator, Descriptor descriptor) { return addOneDescriptor(locator, descriptor, true); }
/** * It is very often the case that one wishes to add a single descriptor to * a service locator. This method adds that one descriptor. If the descriptor * is an {@link ActiveDescriptor} and is reified, it will be added as an * {@link ActiveDescriptor}. Otherwise it will be bound as a {@link Descriptor}. * A deep copy will be made of the descriptor passed in * * @param locator The non-null locator to add this descriptor to * @param descriptor The non-null descriptor to add to this locator * @return The descriptor that was added to the system * @throws MultiException On a commit failure */ public static <T> ActiveDescriptor<T> addOneDescriptor(ServiceLocator locator, Descriptor descriptor) { return addOneDescriptor(locator, descriptor, true); }
/** * It is very often the case that one wishes to add a single descriptor to * a service locator. This method adds that one descriptor. If the descriptor * is an {@link ActiveDescriptor} and is reified, it will be added as an * {@link ActiveDescriptor}. Otherwise it will be bound as a {@link Descriptor}. * A deep copy will be made of the descriptor passed in * * @param locator The non-null locator to add this descriptor to * @param descriptor The non-null descriptor to add to this locator * @return The descriptor that was added to the system * @throws MultiException On a commit failure */ public static <T> ActiveDescriptor<T> addOneDescriptor(ServiceLocator locator, Descriptor descriptor) { return addOneDescriptor(locator, descriptor, true); }
/** * It is very often the case that one wishes to add a single descriptor to * a service locator. This method adds that one descriptor. If the descriptor * is an {@link ActiveDescriptor} and is reified, it will be added as an * {@link ActiveDescriptor}. Otherwise it will be bound as a {@link Descriptor}. * A deep copy will be made of the descriptor passed in * * @param locator The non-null locator to add this descriptor to * @param descriptor The non-null descriptor to add to this locator * @return The descriptor that was added to the system * @throws MultiException On a commit failure */ public static <T> ActiveDescriptor<T> addOneDescriptor(ServiceLocator locator, Descriptor descriptor) { return addOneDescriptor(locator, descriptor, true); }
/** * This method adds one existing object to the given service locator. The caller * of this will not get a chance to customize the descriptor that goes into the * locator, and hence must rely completely on the analysis of the system to determine * the set of contracts and metadata associated with the descriptor. The same algorithm * is used in this method as in the {@link BuilderHelper#createConstantDescriptor(Object)} * method. * * @param locator The non-null locator to add this descriptor to * @param constant The non-null constant to add to the service locator * @return The descriptor that was added to the service locator */ public static <T> ActiveDescriptor<T> addOneConstant(ServiceLocator locator, Object constant) { if (locator == null || constant == null) throw new IllegalArgumentException(); return addOneDescriptor(locator, BuilderHelper.createConstantDescriptor(constant), false); }
/** * This method adds one existing object to the given service locator. The caller * of this will not get a chance to customize the descriptor that goes into the * locator, and hence must rely completely on the analysis of the system to determine * the set of contracts and metadata associated with the descriptor. The same algorithm * is used in this method as in the {@link BuilderHelper#createConstantDescriptor(Object)} * method. * * @param locator The non-null locator to add this descriptor to * @param constant The non-null constant to add to the service locator * @return The descriptor that was added to the service locator */ public static <T> ActiveDescriptor<T> addOneConstant(ServiceLocator locator, Object constant) { if (locator == null || constant == null) throw new IllegalArgumentException(); return addOneDescriptor(locator, BuilderHelper.createConstantDescriptor(constant), false); }
private ActiveDescriptor<Dom> addWithAlias(ServiceLocator locator, AbstractActiveDescriptor<?> descriptor, Class<?> contract, String name) { ActiveDescriptor<Dom> added = ServiceLocatorUtilities.findOneDescriptor(locator, descriptor); if (added == null) { if (ConfigBean.class.isAssignableFrom(this.getClass())) { if (!descriptor.getAdvertisedContracts().contains(ConfigBean.class.getName())) { descriptor.addContractType(ConfigBean.class); } } added = ServiceLocatorUtilities.addOneDescriptor(locator, descriptor); } AliasDescriptor<Dom> alias = new AliasDescriptor<Dom>(locator, added, contract.getName(), name); ServiceLocatorUtilities.addOneDescriptor(locator, alias); return added; }
private ActiveDescriptor<Dom> addWithAlias(ServiceLocator locator, AbstractActiveDescriptor<?> descriptor, Class<?> contract, String name) { ActiveDescriptor<Dom> added = ServiceLocatorUtilities.findOneDescriptor(locator, descriptor); if (added == null) { if (ConfigBean.class.isAssignableFrom(this.getClass())) { if (!descriptor.getAdvertisedContracts().contains(ConfigBean.class.getName())) { descriptor.addContractType(ConfigBean.class); } } added = ServiceLocatorUtilities.addOneDescriptor(locator, descriptor); } AliasDescriptor<Dom> alias = new AliasDescriptor<Dom>(locator, added, contract.getName(), name); ServiceLocatorUtilities.addOneDescriptor(locator, alias); return added; }
private void addMe(Class<?> lookForMe, String name, Injectee injectee) { HashSet<Type> contracts = new HashSet<Type>(); contracts.add(injectee.getRequiredType()); Set<Annotation> qualifiers = new HashSet<Annotation>(injectee.getRequiredQualifiers()); SpringServiceHK2Bean<Object> springHK2Bean = new SpringServiceHK2Bean<Object>( name, contracts, qualifiers, lookForMe, beanFactory); ServiceLocatorUtilities.addOneDescriptor(locator, springHK2Bean, false); }
@Override public ActiveDescriptor<?> compute(Class<?> key) { // below we make sure HK2 behaves as if injection happens into a request scoped type // this is to avoid having proxies injected (see JERSEY-2386) // before touching the following statement, check BeanParamMemoryLeakTest first! final AbstractActiveDescriptor<Object> descriptor = BuilderHelper.activeLink(key).to(key).in(RequestScoped.class).build(); return ServiceLocatorUtilities.addOneDescriptor(locator, descriptor, false); } });
@Override public ActiveDescriptor<?> compute(Class<?> key) { // below we make sure HK2 behaves as if injection happens into a request scoped type // this is to avoid having proxies injected (see JERSEY-2386) // before touching the following statement, check BeanParamMemoryLeakTest first! final AbstractActiveDescriptor<Object> descriptor = BuilderHelper.activeLink(key).to(key).in(RequestScoped.class).build(); return ServiceLocatorUtilities.addOneDescriptor(locator, descriptor, false); } });
@Override public ForeignDescriptor createForeignDescriptor(Binding binding) { ForeignDescriptor foreignDescriptor = createAndTranslateForeignDescriptor(binding); ActiveDescriptor<Object> activeDescriptor = ServiceLocatorUtilities .addOneDescriptor(getServiceLocator(), (Descriptor) foreignDescriptor.get(), false); return ForeignDescriptor.wrap(activeDescriptor, activeDescriptor::dispose); }
@Override public ForeignDescriptor createForeignDescriptor(Binding binding) { ForeignDescriptor foreignDescriptor = createAndTranslateForeignDescriptor(binding); ActiveDescriptor<Object> activeDescriptor = ServiceLocatorUtilities .addOneDescriptor(getServiceLocator(), (Descriptor) foreignDescriptor.get(), false); return ForeignDescriptor.wrap(activeDescriptor, activeDescriptor::dispose); }
@Override public ActiveDescriptor<?> compute(Class<?> key) { // below we make sure HK2 behaves as if injection happens into a request scoped type // this is to avoid having proxies injected (see JERSEY-2386) // before touching the following statement, check BeanParamMemoryLeakTest first! final AbstractActiveDescriptor<Object> descriptor = BuilderHelper.activeLink(key).to(key).in(RequestScoped.class).build(); return ServiceLocatorUtilities.addOneDescriptor(locator, descriptor, false); } });
@Override public boolean justInTimeResolution(Injectee injectee) { Type type = injectee.getRequiredType(); Class<?> clazz = MoreTypes.getRawType(type); if (clazz != null) { Binding<?> binding = findBinding(injectee); if (binding != null) { Key<?> key = binding.getKey(); Set<Annotation> qualifiers = BindingUtils.getQualifiers(key); GuiceBindingDescriptor<?> descriptor = new GuiceBindingDescriptor<>( type, clazz, qualifiers, binding); ServiceLocatorUtilities.addOneDescriptor(locator, descriptor); return true; } } return false; }
@Override public boolean justInTimeResolution(Injectee injectee) { Type type = injectee.getRequiredType(); Class<?> clazz = MoreTypes.getRawType(type); if (clazz != null) { Binding<?> binding = findBinding(injectee); if (binding != null) { Key<?> key = binding.getKey(); Set<Annotation> qualifiers = BindingUtils.getQualifiers(key); GuiceBindingDescriptor<?> descriptor = new GuiceBindingDescriptor<>( type, clazz, qualifiers, binding); ServiceLocatorUtilities.addOneDescriptor(locator, descriptor); return true; } } return false; }