/* package */ ClassAnalyzer getAnalyzer(String name, Collector collector) { ClassAnalyzer retVal; synchronized (classAnalyzerLock) { if (name == null) { name = defaultClassAnalyzer ; } retVal = classAnalyzers.get(name); } if (retVal == null) { collector.addThrowable(new IllegalStateException( "Could not find an implementation of ClassAnalyzer with name " + name)); return null; } return retVal; }
/* package */ ClassAnalyzer getAnalyzer(String name, Collector collector) { ClassAnalyzer retVal; synchronized (classAnalyzerLock) { if (name == null) { name = defaultClassAnalyzer ; } retVal = classAnalyzers.get(name); } if (retVal == null) { collector.addThrowable(new IllegalStateException( "Could not find an implementation of ClassAnalyzer with name " + name)); return null; } return retVal; }
/* package */ ClassAnalyzer getAnalyzer(String name, Collector collector) { ClassAnalyzer retVal; synchronized (classAnalyzerLock) { if (name == null) { name = defaultClassAnalyzer ; } retVal = classAnalyzers.get(name); } if (retVal == null) { collector.addThrowable(new IllegalStateException( "Could not find an implementation of ClassAnalyzer with name " + name)); return null; } return retVal; }
/* package */ ClassAnalyzer getAnalyzer(String name, Collector collector) { ClassAnalyzer retVal; synchronized (classAnalyzerLock) { if (name == null) { name = defaultClassAnalyzer ; } retVal = classAnalyzers.get(name); } if (retVal == null) { collector.addThrowable(new IllegalStateException( "Could not find an implementation of ClassAnalyzer with name " + name)); return null; } return retVal; }
/** * Returns the default name if one can be found. Will only work on * classes and methods * * @param parent The parent annotated element * @param collector For errors * @return null if there is no default name (no Named) */ public static String getDefaultNameFromMethod(Method parent, Collector collector) { Named named = parent.getAnnotation(Named.class); if (named == null) { return null; } if (named.value() == null || named.value().equals("")) { collector.addThrowable(new IllegalArgumentException( "@Named on the provide method of a factory must have an explicit value")); } return named.value(); }
/** * Returns the default name if one can be found. Will only work on * classes and methods * * @param parent The parent annotated element * @param collector For errors * @return null if there is no default name (no Named) */ public static String getDefaultNameFromMethod(Method parent, Collector collector) { Named named = parent.getAnnotation(Named.class); if (named == null) { return null; } if (named.value() == null || named.value().equals("")) { collector.addThrowable(new IllegalArgumentException( "@Named on the provide method of a factory must have an explicit value")); } return named.value(); }
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); } }
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); } }
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); } }
/** * Finds the post construct method on this class * @param clazz The class to search for the post construct * @param collector An error collector * @return The post construct method or null */ public static Method findPostConstruct(Class<?> clazz, ServiceLocatorImpl locator, Collector collector) { try { return locator.getClassReflectionHelper().findPostConstruct(clazz, org.glassfish.hk2.api.PostConstruct.class); } catch (IllegalArgumentException iae) { collector.addThrowable(iae); return null; } }
/** * Finds the pre destroy method on this class * @param clazz The class to search for the pre destroy method * @param collector An error collector * @return The pre destroy method or null */ public static Method findPreDestroy(Class<?> clazz, ServiceLocatorImpl locator, Collector collector) { try { return locator.getClassReflectionHelper().findPreDestroy(clazz, org.glassfish.hk2.api.PreDestroy.class); } catch (IllegalArgumentException iae) { collector.addThrowable(iae); return null; } }
/** * Finds the post construct method on this class * @param clazz The class to search for the post construct * @param collector An error collector * @return The post construct method or null */ public static Method findPostConstruct(Class<?> clazz, ServiceLocatorImpl locator, Collector collector) { try { return locator.getClassReflectionHelper().findPostConstruct(clazz, org.glassfish.hk2.api.PostConstruct.class); } catch (IllegalArgumentException iae) { collector.addThrowable(iae); return null; } }
/** * Finds the pre destroy method on this class * @param clazz The class to search for the pre destroy method * @param collector An error collector * @return The pre destroy method or null */ public static Method findPreDestroy(Class<?> clazz, ServiceLocatorImpl locator, Collector collector) { try { return locator.getClassReflectionHelper().findPreDestroy(clazz, org.glassfish.hk2.api.PreDestroy.class); } catch (IllegalArgumentException iae) { collector.addThrowable(iae); return null; } }
/** * Finds the post construct method on this class * @param clazz The class to search for the post construct * @param collector An error collector * @return The post construct method or null */ public static Method findPostConstruct(Class<?> clazz, ServiceLocatorImpl locator, Collector collector) { try { return locator.getClassReflectionHelper().findPostConstruct(clazz, org.glassfish.hk2.api.PostConstruct.class); } catch (IllegalArgumentException iae) { collector.addThrowable(iae); return null; } }
/** * Finds the pre destroy method on this class * @param clazz The class to search for the pre destroy method * @param collector An error collector * @return The pre destroy method or null */ public static Method findPreDestroy(Class<?> clazz, ServiceLocatorImpl locator, Collector collector) { try { return locator.getClassReflectionHelper().findPreDestroy(clazz, org.glassfish.hk2.api.PreDestroy.class); } catch (IllegalArgumentException iae) { collector.addThrowable(iae); return null; } }
/** * Finds the pre destroy method on this class * @param clazz The class to search for the pre destroy method * @param collector An error collector * @return The pre destroy method or null */ public static Method findPreDestroy(Class<?> clazz, ServiceLocatorImpl locator, Collector collector) { try { return locator.getClassReflectionHelper().findPreDestroy(clazz, org.glassfish.hk2.api.PreDestroy.class); } catch (IllegalArgumentException iae) { collector.addThrowable(iae); return null; } }
/** * Finds the post construct method on this class * @param clazz The class to search for the post construct * @param collector An error collector * @return The post construct method or null */ public static Method findPostConstruct(Class<?> clazz, ServiceLocatorImpl locator, Collector collector) { try { return locator.getClassReflectionHelper().findPostConstruct(clazz, org.glassfish.hk2.api.PostConstruct.class); } catch (IllegalArgumentException iae) { collector.addThrowable(iae); return null; } }
/** * Checks to be sure the Factory class is ok * * @param factoryClass the class to check * @param collector the exception collector */ public static void checkFactoryType(Class<?> factoryClass, Collector collector) { for (Type type : factoryClass.getGenericInterfaces()) { Class<?> rawClass = ReflectionHelper.getRawClass(type); if (rawClass == null) continue; if (!Factory.class.equals(rawClass)) continue; Type firstType = ReflectionHelper.getFirstTypeArgument(type); if (firstType instanceof WildcardType) { // This should not be possible collector.addThrowable(new IllegalArgumentException("The class " + Pretty.clazz(factoryClass) + " has a Wildcard as its type")); } } }
/** * Checks to be sure the Factory class is ok * * @param factoryClass the class to check * @param collector the exception collector */ public static void checkFactoryType(Class<?> factoryClass, Collector collector) { for (Type type : factoryClass.getGenericInterfaces()) { Class<?> rawClass = ReflectionHelper.getRawClass(type); if (rawClass == null) continue; if (!Factory.class.equals(rawClass)) continue; Type firstType = ReflectionHelper.getFirstTypeArgument(type); if (firstType instanceof WildcardType) { // This should not be possible collector.addThrowable(new IllegalArgumentException("The class " + Pretty.clazz(factoryClass) + " has a Wildcard as its type")); } } }
/** * Checks to be sure the Factory class is ok * * @param factoryClass the class to check * @param collector the exception collector */ public static void checkFactoryType(Class<?> factoryClass, Collector collector) { for (Type type : factoryClass.getGenericInterfaces()) { Class<?> rawClass = ReflectionHelper.getRawClass(type); if (rawClass == null) continue; if (!Factory.class.equals(rawClass)) continue; Type firstType = ReflectionHelper.getFirstTypeArgument(type); if (firstType instanceof WildcardType) { // This should not be possible collector.addThrowable(new IllegalArgumentException("The class " + Pretty.clazz(factoryClass) + " has a Wildcard as its type")); } } }