@Override public Injectable<Injectable> getInjectable(ComponentContext ic, Inject a, Type c) { if (c instanceof ParameterizedType) { ParameterizedType pt = (ParameterizedType)c; if (pt.getRawType() == Injectable.class) { if (pt.getActualTypeArguments().length == 1) { final Injectable<?> i = injectableFactory.getInjectable( a.annotationType(), ic, a, pt.getActualTypeArguments()[0], ComponentScope.PERREQUEST_UNDEFINED_SINGLETON); if (i == null) return null; return new Injectable<Injectable>() { @Override public Injectable getValue() { return i; } }; } } } return null; } });
private static String getBeanName(ComponentContext cc, Class<?> c, ApplicationContext springContext) { boolean annotatedWithInject = false; if (cc != null) { final Inject inject = getAnnotation(cc.getAnnotations(), Inject.class); if (inject != null) { annotatedWithInject = true; if (inject.value() != null && !inject.value().equals("")) { return inject.value(); } } } final String names[] = springContext.getBeanNamesForType(c); if (names.length == 0) { return null; } else if (names.length == 1) { return names[0]; } else { final StringBuilder sb = new StringBuilder(); sb.append("There are multiple beans configured in spring for the type "). append(c.getName()).append("."); if (annotatedWithInject) { sb.append("\nYou should specify the name of the preferred bean at @Inject: Inject(\"yourBean\")."); } else { sb.append("\nAnnotation information was not available, the reason might be because you're not using " + "@Inject. You should use @Inject and specifiy the bean name via Inject(\"yourBean\")."); } sb.append("\nAvailable bean names: ").append(toCSV(names)); throw new RuntimeException(sb.toString()); } }
@Override public Injectable<Injectable> getInjectable(ComponentContext ic, Inject a, Type c) { if (c instanceof ParameterizedType) { ParameterizedType pt = (ParameterizedType)c; if (pt.getRawType() == Injectable.class) { if (pt.getActualTypeArguments().length == 1) { final Injectable<?> i = injectableFactory.getInjectable( a.annotationType(), ic, a, pt.getActualTypeArguments()[0], ComponentScope.PERREQUEST_UNDEFINED_SINGLETON); if (i == null) return null; return new Injectable<Injectable>() { @Override public Injectable getValue() { return i; } }; } } } return null; } });
@Override public Injectable<Injectable> getInjectable(ComponentContext ic, Inject a, Type c) { if (c instanceof ParameterizedType) { ParameterizedType pt = (ParameterizedType)c; if (pt.getRawType() == Injectable.class) { if (pt.getActualTypeArguments().length == 1) { final Injectable<?> i = injectableFactory.getInjectable( a.annotationType(), ic, a, pt.getActualTypeArguments()[0], ComponentScope.PERREQUEST_UNDEFINED_SINGLETON); if (i == null) return null; return new Injectable<Injectable>() { @Override public Injectable getValue() { return i; } }; } } } return null; } });