private CacheKey(Injectee injectee) { this.injectee = injectee; this.hash = Objects.hash(injectee.getInjecteeClass(), injectee.getInjecteeDescriptor(), injectee.getParent(), injectee.getRequiredQualifiers(), injectee.getRequiredType(), injectee.getPosition()); }
private CacheKey(Injectee injectee) { this.injectee = injectee; this.hash = Objects.hash(injectee.getInjecteeClass(), injectee.getInjecteeDescriptor(), injectee.getParent(), injectee.getRequiredQualifiers(), injectee.getRequiredType(), injectee.getPosition()); }
@Override public Object resolve(Injectee injectee, ServiceHandle root) { InjecteeImpl injecteeWrapper = new InjecteeImpl(); injecteeWrapper.setRequiredType(injectee.getRequiredType()); injecteeWrapper.setParent(injectee.getParent()); injecteeWrapper.setRequiredQualifiers(injectee.getRequiredQualifiers()); injecteeWrapper.setOptional(injectee.isOptional()); injecteeWrapper.setPosition(injectee.getPosition()); injecteeWrapper.setFactory(ReflectionHelper.isSubClassOf(injectee.getRequiredType(), Factory.class)); injecteeWrapper.setInjecteeDescriptor(new ForeignDescriptorImpl(injectee.getInjecteeDescriptor())); Object instance = jerseyResolver.resolve(injecteeWrapper); if (injecteeWrapper.isFactory()) { return asFactory(instance); } else { return instance; } }
@Override public Object resolve(Injectee injectee, ServiceHandle root) { InjecteeImpl injecteeWrapper = new InjecteeImpl(); injecteeWrapper.setRequiredType(injectee.getRequiredType()); injecteeWrapper.setParent(injectee.getParent()); injecteeWrapper.setRequiredQualifiers(injectee.getRequiredQualifiers()); injecteeWrapper.setOptional(injectee.isOptional()); injecteeWrapper.setPosition(injectee.getPosition()); injecteeWrapper.setFactory(ReflectionHelper.isSubClassOf(injectee.getRequiredType(), Factory.class)); injecteeWrapper.setInjecteeDescriptor(new ForeignDescriptorImpl(injectee.getInjecteeDescriptor())); Object instance = jerseyResolver.resolve(injecteeWrapper); if (injecteeWrapper.isFactory()) { return asFactory(instance); } else { return instance; } }
@Override public Object resolve(Injectee injectee, ServiceHandle<?> root) { Type requiredType = injectee.getRequiredType(); boolean isHk2Factory = ReflectionHelper.isSubClassOf(requiredType, Factory.class); Injectee newInjectee; if (isHk2Factory) { newInjectee = getFactoryInjectee(injectee, ReflectionHelper.getTypeArgument(requiredType, 0)); } else { newInjectee = foreignRequestScopedInjecteeCache.apply(new CacheKey(injectee)); } ActiveDescriptor<?> ad = descriptorCache.apply(new CacheKey(newInjectee)); if (ad != null) { final ServiceHandle handle = serviceLocator.getServiceHandle(ad, newInjectee); if (isHk2Factory) { return asFactory(handle); } else { return handle.getService(); } } return null; }
@Override public Object resolve(Injectee injectee, ServiceHandle<?> root) { Type requiredType = injectee.getRequiredType(); boolean isHk2Factory = ReflectionHelper.isSubClassOf(requiredType, Factory.class); Injectee newInjectee; if (isHk2Factory) { newInjectee = getFactoryInjectee(injectee, ReflectionHelper.getTypeArgument(requiredType, 0)); } else { newInjectee = foreignRequestScopedInjecteeCache.apply(new CacheKey(injectee)); } ActiveDescriptor<?> ad = descriptorCache.apply(new CacheKey(newInjectee)); if (ad != null) { final ServiceHandle handle = serviceLocator.getServiceHandle(ad, newInjectee); if (isHk2Factory) { return asFactory(handle); } else { return handle.getService(); } } return null; }
/** * Returns {@code true} if the {@link Injectee} has a Jersey SPI {@link Contract}. * * @see Contract */ public static boolean isContract(Injectee injectee) { Type type = injectee.getRequiredType(); return type instanceof Class && ((Class<?>)type).isAnnotationPresent(Contract.class); }
/** * Returns {@code true} if the {@link Injectee} has a Jersey SPI {@link Contract}. * * @see Contract */ public static boolean isContract(Injectee injectee) { Type type = injectee.getRequiredType(); return type instanceof Class && ((Class<?>)type).isAnnotationPresent(Contract.class); }
/** * Returns {@code true} if the {@link Injectee} has a HK2 SPI * {@link org.jvnet.hk2.annotations.Contract} annotation. * * @see org.jvnet.hk2.annotations.Contract */ public static boolean isHk2Contract(Injectee injectee) { Type type = injectee.getRequiredType(); return isContact(type, org.jvnet.hk2.annotations.Contract.class); }
/** * Returns {@code true} if the {@link Injectee} has a Jersey SPI * {@link org.glassfish.jersey.spi.Contract} annotation. * * @see org.glassfish.jersey.spi.Contract */ public static boolean isJerseyContract(Injectee injectee) { Type type = injectee.getRequiredType(); return isContact(type, org.glassfish.jersey.spi.Contract.class); }
/** * Returns {@code true} if the {@link Injectee} has a Jersey SPI * {@link org.glassfish.jersey.spi.Contract} annotation. * * @see org.glassfish.jersey.spi.Contract */ public static boolean isJerseyContract(Injectee injectee) { Type type = injectee.getRequiredType(); return isContact(type, org.glassfish.jersey.spi.Contract.class); }
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); }
/** * Creates and returns a {@link Key} from the given {@link Injectee}. */ public static Key<?> toKey(Injectee injectee) { Type type = injectee.getRequiredType(); Set<Annotation> qualifiers = getQualifiers(injectee); return newKey(type, qualifiers); }
/** * Creates and returns a {@link Key} from the given {@link Injectee}. */ public static Key<?> toKey(Injectee injectee) { Type type = injectee.getRequiredType(); Set<Annotation> qualifiers = getQualifiers(injectee); return newKey(type, qualifiers); }
/** * Creates and returns a {@link Key} from the given {@link Injectee}. */ public static Key<?> toKey(Injectee injectee) { Type type = injectee.getRequiredType(); Set<Annotation> qualifiers = getQualifiers(injectee); return newKey(type, qualifiers); }
@Override public Object resolve(Injectee injectee, ServiceHandle<?> root) { final ConfiguredInteger ann = injectee.getParent().getAnnotation(ConfiguredInteger.class); assert ann != null; if(injectee.getRequiredType() instanceof ParameterizedType) { final Type fieldType = ((ParameterizedType)injectee.getRequiredType()).getRawType(); if(fieldType.equals(Supplier.class) || fieldType.equals(ConfiguredReloadable.class)) { return new ConfiguredReloadable<Integer>(config.get(), ann.value(), (Integer)ann.def(), ann.required()); } } return ann.required() ? config.get().getInt(ann.value()) : config.get().getInt(ann.value(), ann.def()); }
@Override public Object resolve(Injectee injectee, ServiceHandle<?> root) { final ConfiguredLong ann = injectee.getParent().getAnnotation(ConfiguredLong.class); assert ann != null; if(injectee.getRequiredType() instanceof ParameterizedType) { final Type fieldType = ((ParameterizedType)injectee.getRequiredType()).getRawType(); if(fieldType.equals(Supplier.class) || fieldType.equals(ConfiguredReloadable.class)) { return new ConfiguredReloadable<Long>(config.get(), ann.value(), (Long)ann.def(), ann.required()); } } return ann.required() ? config.get().getLong(ann.value()) : config.get().getLong(ann.value(), ann.def()); }
private CacheKey(Injectee injectee) { this.injectee = injectee; this.hash = Objects.hash(injectee.getInjecteeClass(), injectee.getInjecteeDescriptor(), injectee.getParent(), injectee.getRequiredQualifiers(), injectee.getRequiredType(), injectee.getPosition()); }
private CacheKey(Injectee injectee) { this.injectee = injectee; this.hash = Objects.hash(injectee.getInjecteeClass(), injectee.getInjecteeDescriptor(), injectee.getParent(), injectee.getRequiredQualifiers(), injectee.getRequiredType(), injectee.getPosition()); }
/** * @see org.glassfish.hk2.api.InjectionResolver#resolve(org.glassfish.hk2.api.Injectee, * org.glassfish.hk2.api.ServiceHandle) */ @Override public Object resolve(Injectee arg0, ServiceHandle<?> arg1) { Type requiredType = arg0.getRequiredType(); return this.serviceLocator.getService( this.getServiceCosumer((Class<?>) requiredType, arg0.getInjecteeClass(), arg0.getRequiredQualifiers())) .getService(); }