public ResourceElement(Member member, AnnotatedElement ae, @Nullable PropertyDescriptor pd) { super(member, pd); Resource resource = ae.getAnnotation(Resource.class); String resourceName = resource.name(); Class<?> resourceType = resource.type(); this.isDefaultName = !StringUtils.hasLength(resourceName); if (this.isDefaultName) { resourceName = this.member.getName(); if (this.member instanceof Method && resourceName.startsWith("set") && resourceName.length() > 3) { resourceName = Introspector.decapitalize(resourceName.substring(3)); } } else if (embeddedValueResolver != null) { resourceName = embeddedValueResolver.resolveStringValue(resourceName); } if (Object.class != resourceType) { checkResourceType(resourceType); } else { // No resource type specified... check field/method. resourceType = getResourceType(); } this.name = (resourceName != null ? resourceName : ""); this.lookupType = resourceType; String lookupValue = resource.lookup(); this.mappedName = (StringUtils.hasLength(lookupValue) ? lookupValue : resource.mappedName()); Lazy lazy = ae.getAnnotation(Lazy.class); this.lazyLookup = (lazy != null && lazy.value()); }
public ResourceElement(Member member, AnnotatedElement ae, @Nullable PropertyDescriptor pd) { super(member, pd); Resource resource = ae.getAnnotation(Resource.class); String resourceName = resource.name(); Class<?> resourceType = resource.type(); this.isDefaultName = !StringUtils.hasLength(resourceName); if (this.isDefaultName) { resourceName = this.member.getName(); if (this.member instanceof Method && resourceName.startsWith("set") && resourceName.length() > 3) { resourceName = Introspector.decapitalize(resourceName.substring(3)); } } else if (embeddedValueResolver != null) { resourceName = embeddedValueResolver.resolveStringValue(resourceName); } if (Object.class != resourceType) { checkResourceType(resourceType); } else { // No resource type specified... check field/method. resourceType = getResourceType(); } this.name = (resourceName != null ? resourceName : ""); this.lookupType = resourceType; String lookupValue = resource.lookup(); this.mappedName = (StringUtils.hasLength(lookupValue) ? lookupValue : resource.mappedName()); Lazy lazy = ae.getAnnotation(Lazy.class); this.lazyLookup = (lazy != null && lazy.value()); }
private Object defaultFindResource(Resource resource) throws Exception { if (injector == null) { throw new NamingException("Could not find resource: " + resource); } // noinspection unchecked log.debug("defaultFindResource using injector {}", System.identityHashCode(injector)); return injector.getInstance(resource.type()); }
private static String getType(Resource annotation, Class<?> defaultType) { Class<?> type = annotation.type(); if (type == null || type.equals(Object.class)) { if (defaultType != null) { type = defaultType; } } return Introspection.convertPrimitiveType(type).getCanonicalName(); }
private static String getType(Resource annotation, Class<?> defaultType) { Class<?> type = annotation.type(); if (type == null || type.equals(Object.class)) { if (defaultType != null) { type = defaultType; } } return Introspection.convertPrimitiveType(type).getCanonicalName(); }
private static String getType(Resource annotation, Class<?> defaultType) { Class<?> type = annotation.type(); if (type == null || type.equals(Object.class)) { if (defaultType != null) { type = defaultType; } } return Introspection.convertPrimitiveType(type).getCanonicalName(); }
private static String getType(Resource annotation, Class<?> defaultType) { Class<?> type = annotation.type(); if (type == null || type.equals(Object.class)) { if (defaultType != null) { type = defaultType; } } return Introspection.convertPrimitiveType(type).getCanonicalName(); }
private void loadClassResource(Resource resource) throws Exception { if ((resource.name().isEmpty()) || (resource.type() == Object.class)) { throw new Exception("Class resources must have both name() and type(): " + resource); } findResource(resource); }