Skip to content

Commit 340d320

Browse files
committed
Clarified VfsResource constructor
Issue: SPR-17563 (cherry picked from commit 50e5bdb)
1 parent bc864dc commit 340d320

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

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

+8-3
Original file line numberDiff line numberDiff line change
@@ -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

+8-8
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.
@@ -31,9 +31,9 @@
3131
/**
3232
* Utility for detecting and accessing JBoss VFS in the classpath.
3333
*
34-
* <p>As of Spring 4.0, this class supports VFS 3.x on JBoss AS 6+ (package
35-
* {@code org.jboss.vfs}) and is in particular compatible with JBoss AS 7 and
36-
* WildFly 8.
34+
* <p>As of Spring 4.0, this class supports VFS 3.x on JBoss AS 6+
35+
* (package {@code org.jboss.vfs}) and is in particular compatible with
36+
* JBoss AS 7 and WildFly 8+.
3737
*
3838
* <p>Thanks go to Marius Bogoevici for the initial patch.
3939
* <b>Note:</b> This is an internal class and should not be used outside the framework.
@@ -58,13 +58,13 @@ public abstract class VfsUtils {
5858
private static final Method VIRTUAL_FILE_METHOD_TO_URI;
5959
private static final Method VIRTUAL_FILE_METHOD_GET_NAME;
6060
private static final Method VIRTUAL_FILE_METHOD_GET_PATH_NAME;
61+
private static final Method VIRTUAL_FILE_METHOD_GET_PHYSICAL_FILE;
6162
private static final Method VIRTUAL_FILE_METHOD_GET_CHILD;
6263

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

6667
private static final Field VISITOR_ATTRIBUTES_FIELD_RECURSE;
67-
private static final Method GET_PHYSICAL_FILE;
6868

6969
static {
7070
ClassLoader loader = VfsUtils.class.getClassLoader();
@@ -82,7 +82,7 @@ public abstract class VfsUtils {
8282
VIRTUAL_FILE_METHOD_TO_URL = virtualFile.getMethod("toURL");
8383
VIRTUAL_FILE_METHOD_GET_NAME = virtualFile.getMethod("getName");
8484
VIRTUAL_FILE_METHOD_GET_PATH_NAME = virtualFile.getMethod("getPathName");
85-
GET_PHYSICAL_FILE = virtualFile.getMethod("getPhysicalFile");
85+
VIRTUAL_FILE_METHOD_GET_PHYSICAL_FILE = virtualFile.getMethod("getPhysicalFile");
8686
VIRTUAL_FILE_METHOD_GET_CHILD = virtualFile.getMethod("getChild", String.class);
8787

8888
VIRTUAL_FILE_VISITOR_INTERFACE = loader.loadClass(VFS3_PKG + "VirtualFileVisitor");
@@ -125,7 +125,7 @@ static boolean exists(Object vfsResource) {
125125

126126
static boolean isReadable(Object vfsResource) {
127127
try {
128-
return ((Long) invokeVfsMethod(VIRTUAL_FILE_METHOD_GET_SIZE, vfsResource) > 0);
128+
return (Long) invokeVfsMethod(VIRTUAL_FILE_METHOD_GET_SIZE, vfsResource) > 0;
129129
}
130130
catch (IOException ex) {
131131
return false;
@@ -170,7 +170,7 @@ static Object getChild(Object vfsResource, String path) throws IOException {
170170
}
171171

172172
static File getFile(Object vfsResource) throws IOException {
173-
return (File) invokeVfsMethod(GET_PHYSICAL_FILE, vfsResource);
173+
return (File) invokeVfsMethod(VIRTUAL_FILE_METHOD_GET_PHYSICAL_FILE, vfsResource);
174174
}
175175

176176
static Object getRoot(URI url) throws IOException {

0 commit comments

Comments
 (0)