private Object findTapestrysInjectedValue(final PlasticField field, Class<?> fieldType) { try { AnnotationProvider annotationProvider = new AnnotationProvider() { public <T extends Annotation> T getAnnotation(Class<T> annotationClass) { return field.getAnnotation(annotationClass); } }; Object result = masterObjectProvider.provide(fieldType, annotationProvider, this.locator, false); if (result == null) { result = this.locator.getService(fieldType); } return result; } catch (RuntimeException e) { // We get this exception if we try to find a service that does not exist return null; } } }
public boolean provideInjection(final PlasticField field, ObjectLocator locator, MutableComponentModel componentModel) { Class fieldType = classCache.forName(field.getTypeName()); Object injectionValue = masterObjectProvider.provide(fieldType, new AnnotationProvider() { public <T extends Annotation> T getAnnotation(Class<T> annotationClass) { return field.getAnnotation(annotationClass); } }, this.locator, false); // Null means that no ObjectProvider could provide the value. We have set up the chain of // command so that InjectResources can give it a try next. Later, we'll try to match against // a service. if (injectionValue != null) { field.inject(injectionValue); return true; } return false; } }
@Override public <T> T getObject(Class<T> objectType, AnnotationProvider annotationProvider, ObjectLocator locator, Module localModule) { lock.check(); AnnotationProvider effectiveProvider = annotationProvider != null ? annotationProvider : new NullAnnotationProvider(); // We do a check here for known marker/type combinations, so that you can use a marker // annotation // to inject into a contribution method that contributes to MasterObjectProvider. // We also force a contribution into MasterObjectProvider to accomplish the same thing. T result = findServiceByMarkerAndType(objectType, annotationProvider, localModule); if (result != null) return result; MasterObjectProvider masterProvider = getService(IOCConstants.MASTER_OBJECT_PROVIDER_SERVICE_ID, MasterObjectProvider.class); return masterProvider.provide(objectType, effectiveProvider, locator, true); }
@Override public <T> T getObject(Class<T> objectType, AnnotationProvider annotationProvider, ObjectLocator locator, Module localModule) { lock.check(); AnnotationProvider effectiveProvider = annotationProvider != null ? annotationProvider : new NullAnnotationProvider(); // We do a check here for known marker/type combinations, so that you can use a marker // annotation // to inject into a contribution method that contributes to MasterObjectProvider. // We also force a contribution into MasterObjectProvider to accomplish the same thing. T result = findServiceByMarkerAndType(objectType, annotationProvider, localModule); if (result != null) return result; MasterObjectProvider masterProvider = getService(IOCConstants.MASTER_OBJECT_PROVIDER_SERVICE_ID, MasterObjectProvider.class); return masterProvider.provide(objectType, effectiveProvider, locator, true); }