@Override public Injectee apply(CacheKey cacheKey) { Injectee injectee = cacheKey.getInjectee(); if (injectee.getParent() != null) { if (Field.class.isAssignableFrom(injectee.getParent().getClass())) { Field f = (Field) injectee.getParent(); if (foreignRequestScopedComponents.get().contains(f.getDeclaringClass())) { final Class<?> clazz = f.getType(); if (serviceLocator.getServiceHandle(clazz).getActiveDescriptor().getScopeAnnotation() == RequestScoped.class) { final AbstractActiveDescriptor<Object> descriptor = BuilderHelper.activeLink(clazz) .to(clazz) .in(RequestScoped.class) .build(); return new DescriptorOverridingInjectee(injectee, descriptor); } } } } return injectee; } });
@Override public Injectee apply(CacheKey cacheKey) { Injectee injectee = cacheKey.getInjectee(); if (injectee.getParent() != null) { if (Field.class.isAssignableFrom(injectee.getParent().getClass())) { Field f = (Field) injectee.getParent(); if (foreignRequestScopedComponents.get().contains(f.getDeclaringClass())) { final Class<?> clazz = f.getType(); if (serviceLocator.getServiceHandle(clazz).getActiveDescriptor().getScopeAnnotation() == RequestScoped.class) { final AbstractActiveDescriptor<Object> descriptor = BuilderHelper.activeLink(clazz) .to(clazz) .in(RequestScoped.class) .build(); return new DescriptorOverridingInjectee(injectee, descriptor); } } } } return injectee; } });
static ActiveDescriptor<?> translateToActiveDescriptor(ClassBinding<?> desc) { ActiveDescriptorBuilder binding = BuilderHelper.activeLink(desc.getService()).named(desc.getName()) .analyzeWith(desc.getAnalyzer()); if (desc.getScope() != null) { binding.in(transformScope(desc.getScope())); } if (desc.getRank() != null) { binding.ofRank(desc.getRank()); } for (Annotation annotation : desc.getQualifiers()) { binding.qualifiedBy(annotation); } for (Type contract : desc.getContracts()) { binding.to(contract); } if (desc.isProxiable() != null) { binding.proxy(desc.isProxiable()); } if (desc.isProxiedForSameScope() != null) { binding.proxyForSameScope(desc.isProxiedForSameScope()); } if (desc.getImplementationType() != null) { binding.asType(desc.getImplementationType()); } return binding.build(); }
static ActiveDescriptor<?> translateToActiveDescriptor(ClassBinding<?> desc) { ActiveDescriptorBuilder binding = BuilderHelper.activeLink(desc.getService()).named(desc.getName()) .analyzeWith(desc.getAnalyzer()); if (desc.getScope() != null) { binding.in(transformScope(desc.getScope())); } if (desc.getRank() != null) { binding.ofRank(desc.getRank()); } for (Annotation annotation : desc.getQualifiers()) { binding.qualifiedBy(annotation); } for (Type contract : desc.getContracts()) { binding.to(contract); } if (desc.isProxiable() != null) { binding.proxy(desc.isProxiable()); } if (desc.isProxiedForSameScope() != null) { binding.proxyForSameScope(desc.isProxiedForSameScope()); } if (desc.getImplementationType() != null) { binding.asType(desc.getImplementationType()); } return binding.build(); }
@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 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 Injectee apply(CacheKey cacheKey) { Injectee injectee = cacheKey.getInjectee(); if (injectee.getParent() != null) { if (Field.class.isAssignableFrom(injectee.getParent().getClass())) { Field f = (Field) injectee.getParent(); if (foreignRequestScopedComponents.get().contains(f.getDeclaringClass())) { final Class<?> clazz = f.getType(); if (serviceLocator.getServiceHandle(clazz).getActiveDescriptor().getScopeAnnotation() == RequestScoped.class) { final AbstractActiveDescriptor<Object> descriptor = BuilderHelper.activeLink(clazz) .to(clazz) .in(RequestScoped.class) .build(); return new DescriptorOverridingInjectee(injectee, descriptor); } } } } return injectee; } });
@Override public Injectee compute(Injectee injectee) { if (injectee.getParent() != null) { if (Field.class.isAssignableFrom(injectee.getParent().getClass())) { Field f = (Field) injectee.getParent(); if (foreignRequestScopedComponents.get().contains(f.getDeclaringClass())) { final Class<?> clazz = f.getType(); if (serviceLocator.getServiceHandle(clazz).getActiveDescriptor().getScopeAnnotation() == RequestScoped.class) { final AbstractActiveDescriptor<Object> descriptor = BuilderHelper.activeLink(clazz) .to(clazz) .in(RequestScoped.class) .build(); return new DescriptorOverridingInjectee(injectee, descriptor); } } } } return injectee; } });
@Override public Injectee compute(Injectee injectee) { if (injectee.getParent() != null) { if (Field.class.isAssignableFrom(injectee.getParent().getClass())) { Field f = (Field) injectee.getParent(); if (foreignRequestScopedComponents.get().contains(f.getDeclaringClass())) { final Class<?> clazz = f.getType(); if (serviceLocator.getServiceHandle(clazz).getActiveDescriptor().getScopeAnnotation() == RequestScoped.class) { final AbstractActiveDescriptor<Object> descriptor = BuilderHelper.activeLink(clazz) .to(clazz) .in(RequestScoped.class) .build(); return new DescriptorOverridingInjectee(injectee, descriptor); } } } } return injectee; } });
@Override public Injectee compute(Injectee injectee) { if (injectee.getParent() != null) { if (Field.class.isAssignableFrom(injectee.getParent().getClass())) { Field f = (Field) injectee.getParent(); if (foreignRequestScopedComponents.get().contains(f.getDeclaringClass())) { final Class<?> clazz = f.getType(); if (serviceLocator.getServiceHandle(clazz).getActiveDescriptor().getScopeAnnotation() == RequestScoped.class) { final AbstractActiveDescriptor<Object> descriptor = BuilderHelper.activeLink(clazz) .to(clazz) .in(RequestScoped.class) .build(); return new DescriptorOverridingInjectee(injectee, descriptor); } } } } return injectee; } });
@Override public Injectee apply(CacheKey cacheKey) { Injectee injectee = cacheKey.getInjectee(); if (injectee.getParent() != null) { if (Field.class.isAssignableFrom(injectee.getParent().getClass())) { Field f = (Field) injectee.getParent(); if (foreignRequestScopedComponents.get().contains(f.getDeclaringClass())) { final Class<?> clazz = f.getType(); if (serviceLocator.getServiceHandle(clazz).getActiveDescriptor().getScopeAnnotation() == RequestScoped.class) { final AbstractActiveDescriptor<Object> descriptor = BuilderHelper.activeLink(clazz) .to(clazz) .in(RequestScoped.class) .build(); return new DescriptorOverridingInjectee(injectee, descriptor); } } } } return injectee; } });
@SuppressWarnings("unchecked") private <T> void bindClass(final Class<T> clazz, final ServiceLocator locator, final DynamicConfiguration dc, final boolean isResource) { final Class<? extends Annotation> scope = getProviderScope(clazz); if (isResource) { final ActiveDescriptor<?> descriptor = dc.bind(BuilderHelper.activeLink(clazz).to(clazz).in(scope).build()); for (final Class contract : Providers.getProviderContracts(clazz)) { final AliasDescriptor aliasDescriptor = new AliasDescriptor(locator, descriptor, contract.getName(), null); aliasDescriptor.setScope(scope.getName()); aliasDescriptor.addQualifierAnnotation(CustomAnnotationLiteral.INSTANCE); dc.bind(aliasDescriptor); } } else { final ScopedBindingBuilder<T> bindingBuilder = Injections.newBinder(clazz).in(scope).qualifiedBy(CustomAnnotationLiteral.INSTANCE); for (final Class contract : Providers.getProviderContracts(clazz)) { bindingBuilder.to(contract); } Injections.addBinding(bindingBuilder, dc); } }
@SuppressWarnings("unchecked") private <T> void bindClass(final Class<T> clazz, final ServiceLocator locator, final DynamicConfiguration dc, final boolean isResource) { final Class<? extends Annotation> scope = getProviderScope(clazz); if (isResource) { final ActiveDescriptor<?> descriptor = dc.bind(BuilderHelper.activeLink(clazz).to(clazz).in(scope).build()); for (final Class contract : Providers.getProviderContracts(clazz)) { final AliasDescriptor aliasDescriptor = new AliasDescriptor(locator, descriptor, contract.getName(), null); aliasDescriptor.setScope(scope.getName()); aliasDescriptor.addQualifierAnnotation(CustomAnnotationLiteral.INSTANCE); dc.bind(aliasDescriptor); } } else { final ScopedBindingBuilder<T> bindingBuilder = Injections.newBinder(clazz).in(scope).qualifiedBy(CustomAnnotationLiteral.INSTANCE); for (final Class contract : Providers.getProviderContracts(clazz)) { bindingBuilder.to(contract); } Injections.addBinding(bindingBuilder, dc); } }
final Class<? extends Annotation> scope = providerModel.getScope(); final ActiveDescriptor<?> descriptor = dc.bind(BuilderHelper.activeLink(resourceClass).to(resourceClass).in(scope).build());
@SuppressWarnings("unchecked") private <T> void bindClass(final Class<T> clazz, final ServiceLocator locator, final DynamicConfiguration dc, final boolean isResource) { final Class<? extends Annotation> scope = getProviderScope(clazz); if (isResource) { final ActiveDescriptor<?> descriptor = dc.bind(BuilderHelper.activeLink(clazz).to(clazz).in(scope).build()); for (final Class contract : Providers.getProviderContracts(clazz)) { final AliasDescriptor aliasDescriptor = new AliasDescriptor(locator, descriptor, contract.getName(), null); aliasDescriptor.setScope(scope.getName()); aliasDescriptor.addQualifierAnnotation(CustomAnnotationLiteral.INSTANCE); dc.bind(aliasDescriptor); } } else { final ScopedBindingBuilder<T> bindingBuilder = Injections.newBinder(clazz).in(scope).qualifiedBy(CustomAnnotationLiteral.INSTANCE); for (final Class contract : Providers.getProviderContracts(clazz)) { bindingBuilder.to(contract); } Injections.addBinding(bindingBuilder, dc); } }
builder.to(contract);
builder.to(contract);
static ActiveDescriptor<?> translateToActiveDescriptor(ClassBinding<?> desc) { ActiveDescriptorBuilder binding = BuilderHelper.activeLink(desc.getService()).named(desc.getName()) .analyzeWith(desc.getAnalyzer()); if (desc.getScope() != null) { binding.in(transformScope(desc.getScope())); } if (desc.getRank() != null) { binding.ofRank(desc.getRank()); } for (Annotation annotation : desc.getQualifiers()) { binding.qualifiedBy(annotation); } for (Type contract : desc.getContracts()) { binding.to(contract); } if (desc.isProxiable() != null) { binding.proxy(desc.isProxiable()); } if (desc.isProxiedForSameScope() != null) { binding.proxyForSameScope(desc.isProxiedForSameScope()); } if (desc.getImplementationType() != null) { binding.asType(desc.getImplementationType()); } return binding.build(); }
static ActiveDescriptor<?> translateToActiveDescriptor(ClassBinding<?> desc) { ActiveDescriptorBuilder binding = BuilderHelper.activeLink(desc.getService()).named(desc.getName()) .analyzeWith(desc.getAnalyzer()); if (desc.getScope() != null) { binding.in(transformScope(desc.getScope())); } if (desc.getRank() != null) { binding.ofRank(desc.getRank()); } for (Annotation annotation : desc.getQualifiers()) { binding.qualifiedBy(annotation); } for (Type contract : desc.getContracts()) { binding.to(contract); } if (desc.isProxiable() != null) { binding.proxy(desc.isProxiable()); } if (desc.isProxiedForSameScope() != null) { binding.proxyForSameScope(desc.isProxiedForSameScope()); } if (desc.getImplementationType() != null) { binding.asType(desc.getImplementationType()); } return binding.build(); }