@Override public boolean equals(Object o) { if (o == null) return false; if (!(o instanceof SystemInjecteeImpl)) return false; SystemInjecteeImpl other = (SystemInjecteeImpl) o; if (position != other.getPosition()) return false; if (!pClass.equals(other.getInjecteeClass())) return false; return parentIdentifier.equals(other.parentIdentifier); }
/** * This is done because sometimes when creating the creator we do not know * what the true system descriptor will be * * @param selfDescriptor The descriptor that should replace our self descriptor */ /* package */ void resetSelfDescriptor(ActiveDescriptor<?> selfDescriptor) { this.selfDescriptor = selfDescriptor; for (Injectee injectee : allInjectees) { if (!(injectee instanceof SystemInjecteeImpl)) continue; ((SystemInjecteeImpl) injectee).resetInjecteeDescriptor(selfDescriptor); } }
/** * Returns an injection resolver for the injectee * * @param locator The locator to use when finding the resolver * @param injectee Injectee from which the annotation should be extracted * @return Injection resolver used to resolve the injection for the injectee * @throws IllegalStateException If we could not find a valid resolver */ public InjectionResolver<?> getInjectionResolver( ServiceLocatorImpl locator, SystemInjecteeImpl injectee) throws IllegalStateException { return getInjectionResolver(locator, injectee.getParent(), injectee.getPosition()); }
/** * Returns all the injectees for a constructor * @param c The constructor to analyze * @param injecteeDescriptor The descriptor of the injectee * @return the list (in order) of parameters to the constructor */ public static List<SystemInjecteeImpl> getConstructorInjectees(Constructor<?> c, ActiveDescriptor<?> injecteeDescriptor) { Type genericTypeParams[] = c.getGenericParameterTypes(); Annotation paramAnnotations[][] = c.getParameterAnnotations(); List<SystemInjecteeImpl> retVal = new LinkedList<SystemInjecteeImpl>(); for (int lcv = 0; lcv < genericTypeParams.length; lcv++) { AnnotationInformation ai = getParamInformation(paramAnnotations[lcv]); retVal.add(new SystemInjecteeImpl(genericTypeParams[lcv], ai.qualifiers, lcv, c, ai.optional, ai.self, ai.unqualified, injecteeDescriptor)); } return retVal; }
/** * Just creates the thing, doesn't try to do anything else * @param createMe The thing to create * @param locator The locator to find the injection points with * @param strategy The strategy to use for analyzing the class * @return The constructed thing, no further injection is performed */ @SuppressWarnings("unchecked") public static <T> T justCreate(Class<T> createMe, ServiceLocatorImpl locator, String strategy) { if (createMe == null) throw new IllegalArgumentException(); Collector collector = new Collector(); ClassAnalyzer analyzer = getClassAnalyzer(locator, strategy, collector); collector.throwIfErrors(); Constructor<?> c = getConstructor(createMe, analyzer, collector); collector.throwIfErrors(); List<SystemInjecteeImpl> injectees = getConstructorInjectees(c, null); validateSelfInjectees(null, injectees, collector); collector.throwIfErrors(); Object args[] = new Object[injectees.size()]; for (SystemInjecteeImpl injectee : injectees) { InjectionResolver<?> resolver = locator.getPerLocatorUtilities().getInjectionResolver(locator, injectee); args[injectee.getPosition()] = resolver.resolve(injectee, null); } try { return (T) ReflectionHelper.makeMe(c, args, locator.getNeutralContextClassLoader()); } catch (Throwable th) { throw new MultiException(th); } }
private void resolve(Map<SystemInjecteeImpl, Object> addToMe, InjectionResolver<?> resolver, SystemInjecteeImpl injectee, ServiceHandle<?> root, Collector errorCollection) { if (injectee.isSelf()) { addToMe.put(injectee, selfDescriptor); return; } Object addIn = null; try { addIn = resolver.resolve(injectee, root); } catch (Throwable th) { errorCollection.addThrowable(th); } if (addIn != null) { addToMe.put(injectee, addIn); } }
/** * Returns all the injectees for a constructor * @param c The constructor to analyze * @param injecteeDescriptor The descriptor of the injectee * @return the list (in order) of parameters to the constructor */ public static List<SystemInjecteeImpl> getConstructorInjectees(Constructor<?> c, ActiveDescriptor<?> injecteeDescriptor) { Type genericTypeParams[] = c.getGenericParameterTypes(); Annotation paramAnnotations[][] = c.getParameterAnnotations(); List<SystemInjecteeImpl> retVal = new LinkedList<SystemInjecteeImpl>(); for (int lcv = 0; lcv < genericTypeParams.length; lcv++) { AnnotationInformation ai = getParamInformation(paramAnnotations[lcv]); retVal.add(new SystemInjecteeImpl(genericTypeParams[lcv], ai.qualifiers, lcv, c, ai.optional, ai.self, ai.unqualified, injecteeDescriptor)); } return retVal; }
/** * Just creates the thing, doesn't try to do anything else * @param createMe The thing to create * @param locator The locator to find the injection points with * @param strategy The strategy to use for analyzing the class * @return The constructed thing, no further injection is performed */ @SuppressWarnings("unchecked") public static <T> T justCreate(Class<T> createMe, ServiceLocatorImpl locator, String strategy) { if (createMe == null) throw new IllegalArgumentException(); Collector collector = new Collector(); ClassAnalyzer analyzer = getClassAnalyzer(locator, strategy, collector); collector.throwIfErrors(); Constructor<?> c = getConstructor(createMe, analyzer, collector); collector.throwIfErrors(); List<SystemInjecteeImpl> injectees = getConstructorInjectees(c, null); validateSelfInjectees(null, injectees, collector); collector.throwIfErrors(); Object args[] = new Object[injectees.size()]; for (SystemInjecteeImpl injectee : injectees) { InjectionResolver<?> resolver = locator.getPerLocatorUtilities().getInjectionResolver(locator, injectee); args[injectee.getPosition()] = resolver.resolve(injectee, null); } try { return (T) ReflectionHelper.makeMe(c, args, locator.getNeutralContextClassLoader()); } catch (Throwable th) { throw new MultiException(th); } }
private void resolve(Map<SystemInjecteeImpl, Object> addToMe, InjectionResolver<?> resolver, SystemInjecteeImpl injectee, ServiceHandle<?> root, Collector errorCollection) { if (injectee.isSelf()) { addToMe.put(injectee, selfDescriptor); return; } Object addIn = null; try { addIn = resolver.resolve(injectee, root); } catch (Throwable th) { errorCollection.addThrowable(th); } if (addIn != null) { addToMe.put(injectee, addIn); } }
@Override public boolean equals(Object o) { if (o == null) return false; if (!(o instanceof SystemInjecteeImpl)) return false; SystemInjecteeImpl other = (SystemInjecteeImpl) o; if (position != other.getPosition()) return false; if (!pClass.equals(other.getInjecteeClass())) return false; return parentIdentifier.equals(other.parentIdentifier); }
/** * Returns all the injectees for a constructor * @param c The constructor to analyze * @param injecteeDescriptor The descriptor of the injectee * @return the list (in order) of parameters to the constructor */ public static List<SystemInjecteeImpl> getConstructorInjectees(Constructor<?> c, ActiveDescriptor<?> injecteeDescriptor) { Type genericTypeParams[] = c.getGenericParameterTypes(); Annotation paramAnnotations[][] = c.getParameterAnnotations(); List<SystemInjecteeImpl> retVal = new LinkedList<SystemInjecteeImpl>(); for (int lcv = 0; lcv < genericTypeParams.length; lcv++) { AnnotationInformation ai = getParamInformation(paramAnnotations[lcv]); retVal.add(new SystemInjecteeImpl(genericTypeParams[lcv], ai.qualifiers, lcv, c, ai.optional, ai.self, ai.unqualified, injecteeDescriptor)); } return retVal; }
/** * Returns an injection resolver for the injectee * * @param locator The locator to use when finding the resolver * @param injectee Injectee from which the annotation should be extracted * @return Injection resolver used to resolve the injection for the injectee * @throws IllegalStateException If we could not find a valid resolver */ public InjectionResolver<?> getInjectionResolver( ServiceLocatorImpl locator, SystemInjecteeImpl injectee) throws IllegalStateException { return getInjectionResolver(locator, injectee.getParent(), injectee.getPosition()); }
/** * Just creates the thing, doesn't try to do anything else * @param createMe The thing to create * @param locator The locator to find the injection points with * @param strategy The strategy to use for analyzing the class * @return The constructed thing, no further injection is performed */ @SuppressWarnings("unchecked") public static <T> T justCreate(Class<T> createMe, ServiceLocatorImpl locator, String strategy) { if (createMe == null) throw new IllegalArgumentException(); Collector collector = new Collector(); ClassAnalyzer analyzer = getClassAnalyzer(locator, strategy, collector); collector.throwIfErrors(); Constructor<?> c = getConstructor(createMe, analyzer, collector); collector.throwIfErrors(); List<SystemInjecteeImpl> injectees = getConstructorInjectees(c, null); validateSelfInjectees(null, injectees, collector); collector.throwIfErrors(); Object args[] = new Object[injectees.size()]; for (SystemInjecteeImpl injectee : injectees) { InjectionResolver<?> resolver = locator.getPerLocatorUtilities().getInjectionResolver(locator, injectee); args[injectee.getPosition()] = resolver.resolve(injectee, null); } try { return (T) ReflectionHelper.makeMe(c, args, locator.getNeutralContextClassLoader()); } catch (Throwable th) { throw new MultiException(th); } }
/** * This is done because sometimes when creating the creator we do not know * what the true system descriptor will be * * @param selfDescriptor The descriptor that should replace our self descriptor */ /* package */ void resetSelfDescriptor(ActiveDescriptor<?> selfDescriptor) { this.selfDescriptor = selfDescriptor; for (Injectee injectee : allInjectees) { if (!(injectee instanceof SystemInjecteeImpl)) continue; ((SystemInjecteeImpl) injectee).resetInjecteeDescriptor(selfDescriptor); } }
private void resolve(Map<SystemInjecteeImpl, Object> addToMe, InjectionResolver<?> resolver, SystemInjecteeImpl injectee, ServiceHandle<?> root, Collector errorCollection) { if (injectee.isSelf()) { addToMe.put(injectee, selfDescriptor); return; } Object addIn = null; try { addIn = resolver.resolve(injectee, root); } catch (Throwable th) { errorCollection.addThrowable(th); } if (addIn != null) { addToMe.put(injectee, addIn); } }
@Override public boolean equals(Object o) { if (o == null) return false; if (!(o instanceof SystemInjecteeImpl)) return false; SystemInjecteeImpl other = (SystemInjecteeImpl) o; if (position != other.getPosition()) return false; if (!pClass.equals(other.getInjecteeClass())) return false; return parentIdentifier.equals(other.parentIdentifier); }
/** * Returns all the injectees for a constructor * @param c The constructor to analyze * @param injecteeDescriptor The descriptor of the injectee * @return the list (in order) of parameters to the constructor */ public static List<SystemInjecteeImpl> getConstructorInjectees(Constructor<?> c, ActiveDescriptor<?> injecteeDescriptor) { Type genericTypeParams[] = c.getGenericParameterTypes(); Annotation paramAnnotations[][] = c.getParameterAnnotations(); List<SystemInjecteeImpl> retVal = new LinkedList<SystemInjecteeImpl>(); for (int lcv = 0; lcv < genericTypeParams.length; lcv++) { AnnotationInformation ai = getParamInformation(paramAnnotations[lcv]); retVal.add(new SystemInjecteeImpl(genericTypeParams[lcv], ai.qualifiers, lcv, c, ai.optional, ai.self, ai.unqualified, injecteeDescriptor)); } return retVal; }
/** * Returns an injection resolver for the injectee * * @param locator The locator to use when finding the resolver * @param injectee Injectee from which the annotation should be extracted * @return Injection resolver used to resolve the injection for the injectee * @throws IllegalStateException If we could not find a valid resolver */ public InjectionResolver<?> getInjectionResolver( ServiceLocatorImpl locator, SystemInjecteeImpl injectee) throws IllegalStateException { return getInjectionResolver(locator, injectee.getParent(), injectee.getPosition()); }
/** * Just creates the thing, doesn't try to do anything else * @param createMe The thing to create * @param locator The locator to find the injection points with * @param strategy The strategy to use for analyzing the class * @return The constructed thing, no further injection is performed */ @SuppressWarnings("unchecked") public static <T> T justCreate(Class<T> createMe, ServiceLocatorImpl locator, String strategy) { if (createMe == null) throw new IllegalArgumentException(); Collector collector = new Collector(); ClassAnalyzer analyzer = getClassAnalyzer(locator, strategy, collector); collector.throwIfErrors(); Constructor<?> c = getConstructor(createMe, analyzer, collector); collector.throwIfErrors(); List<SystemInjecteeImpl> injectees = getConstructorInjectees(c, null); validateSelfInjectees(null, injectees, collector); collector.throwIfErrors(); Object args[] = new Object[injectees.size()]; for (SystemInjecteeImpl injectee : injectees) { InjectionResolver<?> resolver = locator.getPerLocatorUtilities().getInjectionResolver(locator, injectee); args[injectee.getPosition()] = resolver.resolve(injectee, null); } try { return (T) ReflectionHelper.makeMe(c, args, locator.getNeutralContextClassLoader()); } catch (Throwable th) { throw new MultiException(th); } }
/** * This is done because sometimes when creating the creator we do not know * what the true system descriptor will be * * @param selfDescriptor The descriptor that should replace our self descriptor */ /* package */ void resetSelfDescriptor(ActiveDescriptor<?> selfDescriptor) { this.selfDescriptor = selfDescriptor; for (Injectee injectee : allInjectees) { if (!(injectee instanceof SystemInjecteeImpl)) continue; ((SystemInjecteeImpl) injectee).resetInjecteeDescriptor(selfDescriptor); } }