From 8135442336f8a18b13f04fd763ebbcae69f3e0e6 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 15 Jan 2013 22:07:07 +0100 Subject: [PATCH] Polishing --- .../AnnotationScopeMetadataResolver.java | 12 +++++------ .../core/io/ClassPathResource.java | 20 ++++++++----------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/org.springframework.context/src/main/java/org/springframework/context/annotation/AnnotationScopeMetadataResolver.java b/org.springframework.context/src/main/java/org/springframework/context/annotation/AnnotationScopeMetadataResolver.java index 493745bd82e..6a7db8bd313 100644 --- a/org.springframework.context/src/main/java/org/springframework/context/annotation/AnnotationScopeMetadataResolver.java +++ b/org.springframework.context/src/main/java/org/springframework/context/annotation/AnnotationScopeMetadataResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2013 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,12 +39,13 @@ import static org.springframework.context.annotation.MetadataUtils.*; */ public class AnnotationScopeMetadataResolver implements ScopeMetadataResolver { + private final ScopedProxyMode defaultProxyMode; + protected Class scopeAnnotationType = Scope.class; - private final ScopedProxyMode defaultProxyMode; /** - * Create a new instance of the AnnotationScopeMetadataResolver class. + * Create a new instance of the {@code AnnotationScopeMetadataResolver} class. * @see #AnnotationScopeMetadataResolver(ScopedProxyMode) * @see ScopedProxyMode#NO */ @@ -53,7 +54,7 @@ public class AnnotationScopeMetadataResolver implements ScopeMetadataResolver { } /** - * Create a new instance of the AnnotationScopeMetadataResolver class. + * Create a new instance of the {@code AnnotationScopeMetadataResolver} class. * @param defaultProxyMode the desired scoped-proxy mode */ public AnnotationScopeMetadataResolver(ScopedProxyMode defaultProxyMode) { @@ -77,8 +78,7 @@ public class AnnotationScopeMetadataResolver implements ScopeMetadataResolver { ScopeMetadata metadata = new ScopeMetadata(); if (definition instanceof AnnotatedBeanDefinition) { AnnotatedBeanDefinition annDef = (AnnotatedBeanDefinition) definition; - AnnotationAttributes attributes = - attributesFor(annDef.getMetadata(), this.scopeAnnotationType); + AnnotationAttributes attributes = attributesFor(annDef.getMetadata(), this.scopeAnnotationType); if (attributes != null) { metadata.setScopeName(attributes.getString("value")); ScopedProxyMode proxyMode = attributes.getEnum("proxyMode"); diff --git a/org.springframework.core/src/main/java/org/springframework/core/io/ClassPathResource.java b/org.springframework.core/src/main/java/org/springframework/core/io/ClassPathResource.java index 4ccec827cae..3e8467178d3 100644 --- a/org.springframework.core/src/main/java/org/springframework/core/io/ClassPathResource.java +++ b/org.springframework.core/src/main/java/org/springframework/core/io/ClassPathResource.java @@ -30,15 +30,15 @@ import org.springframework.util.StringUtils; * {@link Resource} implementation for class path resources. * Uses either a given ClassLoader or a given Class for loading resources. * - *

Supports resolution as java.io.File if the class path + *

Supports resolution as {@code java.io.File} if the class path * resource resides in the file system, but not for resources in a JAR. * Always supports resolution as URL. * * @author Juergen Hoeller * @author Sam Brannen * @since 28.12.2003 - * @see java.lang.ClassLoader#getResourceAsStream(String) - * @see java.lang.Class#getResourceAsStream(String) + * @see ClassLoader#getResourceAsStream(String) + * @see Class#getResourceAsStream(String) */ public class ClassPathResource extends AbstractFileResolvingResource { @@ -69,8 +69,8 @@ public class ClassPathResource extends AbstractFileResolvingResource { * resource access methods will not accept it. * @param path the absolute path within the classpath * @param classLoader the class loader to load the resource with, - * or null for the thread context class loader - * @see java.lang.ClassLoader#getResourceAsStream(String) + * or {@code null} for the thread context class loader + * @see ClassLoader#getResourceAsStream(String) */ public ClassPathResource(String path, ClassLoader classLoader) { Assert.notNull(path, "Path must not be null"); @@ -205,18 +205,14 @@ public class ClassPathResource extends AbstractFileResolvingResource { */ public String getDescription() { StringBuilder builder = new StringBuilder("class path resource ["); - String pathToUse = path; - if (this.clazz != null && !pathToUse.startsWith("/")) { builder.append(ClassUtils.classPackageAsResourcePath(this.clazz)); builder.append('/'); } - if (pathToUse.startsWith("/")) { pathToUse = pathToUse.substring(1); } - builder.append(pathToUse); builder.append(']'); return builder.toString(); @@ -232,9 +228,9 @@ public class ClassPathResource extends AbstractFileResolvingResource { } if (obj instanceof ClassPathResource) { ClassPathResource otherRes = (ClassPathResource) obj; - return (this.path.equals(otherRes.path) - && ObjectUtils.nullSafeEquals(this.classLoader, otherRes.classLoader) && ObjectUtils.nullSafeEquals( - this.clazz, otherRes.clazz)); + return (this.path.equals(otherRes.path) && + ObjectUtils.nullSafeEquals(this.classLoader, otherRes.classLoader) && + ObjectUtils.nullSafeEquals(this.clazz, otherRes.clazz)); } return false; }