Skip to content

Commit 7ff1b0e

Browse files
committed
Clarified VfsResource constructor
Issue: SPR-17563 (cherry picked from commit 50e5bdb)
1 parent 792991a commit 7ff1b0e

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

spring-core/src/main/java/org/springframework/core/io/VfsResource.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -28,9 +28,9 @@
2828
/**
2929
* JBoss VFS based {@link Resource} implementation.
3030
*
31-
* <p>As of Spring 4.0, this class supports VFS 3.x on JBoss AS 6+ (package
32-
* {@code org.jboss.vfs}) and is in particular compatible with JBoss AS 7 and
33-
* WildFly 8.
31+
* <p>As of Spring 4.0, this class supports VFS 3.x on JBoss AS 6+
32+
* (package {@code org.jboss.vfs}) and is in particular compatible with
33+
* JBoss AS 7 and WildFly 8+.
3434
*
3535
* @author Ales Justin
3636
* @author Juergen Hoeller
@@ -44,6 +44,11 @@ public class VfsResource extends AbstractResource {
4444
private final Object resource;
4545

4646

47+
/**
48+
* Create a new {@code VfsResource} wrapping the given resource handle.
49+
* @param resource a {@code org.jboss.vfs.VirtualFile} instance
50+
* (untyped in order to avoid a static dependency on the VFS API)
51+
*/
4752
public VfsResource(Object resource) {
4853
Assert.notNull(resource, "VirtualFile must not be null");
4954
this.resource = resource;

spring-core/src/main/java/org/springframework/core/io/VfsUtils.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -30,9 +30,9 @@
3030
/**
3131
* Utility for detecting and accessing JBoss VFS in the classpath.
3232
*
33-
* <p>As of Spring 4.0, this class supports VFS 3.x on JBoss AS 6+ (package
34-
* {@code org.jboss.vfs}) and is in particular compatible with JBoss AS 7 and
35-
* WildFly 8.
33+
* <p>As of Spring 4.0, this class supports VFS 3.x on JBoss AS 6+
34+
* (package {@code org.jboss.vfs}) and is in particular compatible with
35+
* JBoss AS 7 and WildFly 8+.
3636
*
3737
* <p>Thanks go to Marius Bogoevici for the initial patch.
3838
* <b>Note:</b> This is an internal class and should not be used outside the framework.
@@ -57,13 +57,13 @@ public abstract class VfsUtils {
5757
private static final Method VIRTUAL_FILE_METHOD_TO_URI;
5858
private static final Method VIRTUAL_FILE_METHOD_GET_NAME;
5959
private static final Method VIRTUAL_FILE_METHOD_GET_PATH_NAME;
60+
private static final Method VIRTUAL_FILE_METHOD_GET_PHYSICAL_FILE;
6061
private static final Method VIRTUAL_FILE_METHOD_GET_CHILD;
6162

6263
protected static final Class<?> VIRTUAL_FILE_VISITOR_INTERFACE;
6364
protected static final Method VIRTUAL_FILE_METHOD_VISIT;
6465

6566
private static final Field VISITOR_ATTRIBUTES_FIELD_RECURSE;
66-
private static final Method GET_PHYSICAL_FILE;
6767

6868
static {
6969
ClassLoader loader = VfsUtils.class.getClassLoader();
@@ -81,7 +81,7 @@ public abstract class VfsUtils {
8181
VIRTUAL_FILE_METHOD_TO_URL = ReflectionUtils.findMethod(virtualFile, "toURL");
8282
VIRTUAL_FILE_METHOD_GET_NAME = ReflectionUtils.findMethod(virtualFile, "getName");
8383
VIRTUAL_FILE_METHOD_GET_PATH_NAME = ReflectionUtils.findMethod(virtualFile, "getPathName");
84-
GET_PHYSICAL_FILE = ReflectionUtils.findMethod(virtualFile, "getPhysicalFile");
84+
VIRTUAL_FILE_METHOD_GET_PHYSICAL_FILE = ReflectionUtils.findMethod(virtualFile, "getPhysicalFile");
8585
VIRTUAL_FILE_METHOD_GET_CHILD = ReflectionUtils.findMethod(virtualFile, "getChild", String.class);
8686

8787
VIRTUAL_FILE_VISITOR_INTERFACE = loader.loadClass(VFS3_PKG + "VirtualFileVisitor");
@@ -124,7 +124,7 @@ static boolean exists(Object vfsResource) {
124124

125125
static boolean isReadable(Object vfsResource) {
126126
try {
127-
return ((Long) invokeVfsMethod(VIRTUAL_FILE_METHOD_GET_SIZE, vfsResource) > 0);
127+
return (Long) invokeVfsMethod(VIRTUAL_FILE_METHOD_GET_SIZE, vfsResource) > 0;
128128
}
129129
catch (IOException ex) {
130130
return false;
@@ -169,7 +169,7 @@ static Object getChild(Object vfsResource, String path) throws IOException {
169169
}
170170

171171
static File getFile(Object vfsResource) throws IOException {
172-
return (File) invokeVfsMethod(GET_PHYSICAL_FILE, vfsResource);
172+
return (File) invokeVfsMethod(VIRTUAL_FILE_METHOD_GET_PHYSICAL_FILE, vfsResource);
173173
}
174174

175175
static Object getRoot(URI url) throws IOException {

0 commit comments

Comments
 (0)