1
1
/*
2
- * Copyright 2002-2010 the original author or authors.
2
+ * Copyright 2002-2012 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
27
27
28
28
import org .apache .commons .logging .Log ;
29
29
import org .apache .commons .logging .LogFactory ;
30
+
30
31
import org .springframework .core .NestedIOException ;
31
32
import org .springframework .util .ReflectionUtils ;
32
33
@@ -58,14 +59,15 @@ private static enum VFS_VER { V2, V3 }
58
59
private static Method VFS_METHOD_GET_ROOT_URI = null ;
59
60
60
61
private static Method VIRTUAL_FILE_METHOD_EXISTS = null ;
62
+ private static Method VIRTUAL_FILE_METHOD_GET_INPUT_STREAM ;
61
63
private static Method VIRTUAL_FILE_METHOD_GET_SIZE ;
62
64
private static Method VIRTUAL_FILE_METHOD_GET_LAST_MODIFIED ;
63
- private static Method VIRTUAL_FILE_METHOD_GET_CHILD ;
64
- private static Method VIRTUAL_FILE_METHOD_GET_INPUT_STREAM ;
65
65
private static Method VIRTUAL_FILE_METHOD_TO_URL ;
66
66
private static Method VIRTUAL_FILE_METHOD_TO_URI ;
67
67
private static Method VIRTUAL_FILE_METHOD_GET_NAME ;
68
68
private static Method VIRTUAL_FILE_METHOD_GET_PATH_NAME ;
69
+ private static Method VIRTUAL_FILE_METHOD_GET_CHILD ;
70
+
69
71
protected static Class <?> VIRTUAL_FILE_VISITOR_INTERFACE ;
70
72
protected static Method VIRTUAL_FILE_METHOD_VISIT ;
71
73
@@ -101,9 +103,10 @@ private static enum VFS_VER { V2, V3 }
101
103
102
104
if (logger .isDebugEnabled ())
103
105
logger .debug ("JBoss VFS packages for JBoss AS 5 found" );
104
- } catch (ClassNotFoundException ex1 ) {
106
+ }
107
+ catch (ClassNotFoundException ex2 ) {
105
108
logger .error ("JBoss VFS packages (for both JBoss AS 5 and 6) were not found - JBoss VFS support disabled" );
106
- throw new IllegalStateException ("Cannot detect JBoss VFS packages" , ex1 );
109
+ throw new IllegalStateException ("Cannot detect JBoss VFS packages" , ex2 );
107
110
}
108
111
}
109
112
@@ -117,8 +120,8 @@ private static enum VFS_VER { V2, V3 }
117
120
Class <?> virtualFile = loader .loadClass (pkg + "VirtualFile" );
118
121
119
122
VIRTUAL_FILE_METHOD_EXISTS = ReflectionUtils .findMethod (virtualFile , "exists" );
120
- VIRTUAL_FILE_METHOD_GET_SIZE = ReflectionUtils .findMethod (virtualFile , "getSize" );
121
123
VIRTUAL_FILE_METHOD_GET_INPUT_STREAM = ReflectionUtils .findMethod (virtualFile , "openStream" );
124
+ VIRTUAL_FILE_METHOD_GET_SIZE = ReflectionUtils .findMethod (virtualFile , "getSize" );
122
125
VIRTUAL_FILE_METHOD_GET_LAST_MODIFIED = ReflectionUtils .findMethod (virtualFile , "getLastModified" );
123
126
VIRTUAL_FILE_METHOD_TO_URI = ReflectionUtils .findMethod (virtualFile , "toURI" );
124
127
VIRTUAL_FILE_METHOD_TO_URL = ReflectionUtils .findMethod (virtualFile , "toURL" );
@@ -183,6 +186,10 @@ static boolean isReadable(Object vfsResource) {
183
186
}
184
187
}
185
188
189
+ static long getSize (Object vfsResource ) throws IOException {
190
+ return (Long ) invokeVfsMethod (VIRTUAL_FILE_METHOD_GET_SIZE , vfsResource );
191
+ }
192
+
186
193
static long getLastModified (Object vfsResource ) throws IOException {
187
194
return (Long ) invokeVfsMethod (VIRTUAL_FILE_METHOD_GET_LAST_MODIFIED , vfsResource );
188
195
}
0 commit comments