"alesj" wrote :
| I'll see if I can re-write this to use VFS directly.
I've implemented DU based Javassist ClassPath,
which does the trick by doing lookup directly on VFS.
| public class DeploymentUnitClassPath implements ClassPath
| {
| private VFSDeploymentUnit unit;
| private Map<String, VirtualFile> cache;
|
| public DeploymentUnitClassPath(VFSDeploymentUnit unit)
| {
| if (unit == null)
| throw new IllegalArgumentException("Null deployment unit.");
| this.unit = unit;
| this.cache = new HashMap<String, VirtualFile>();
| }
|
| /**
| * Find file.
| *
| * @param className the classname we're looking for
| * @return virtual file or null if not found
| * @throws IOException for any exception
| */
| protected VirtualFile findFile(String className) throws IOException
| {
| // ignore jdk classes
| if (ClassFilter.JAVA_ONLY.matchesClassName(className))
| return null;
|
| VirtualFile file = cache.get(className);
| if (file != null)
| return file;
|
| List<VirtualFile> classPath = unit.getClassPath();
| if (classPath != null && classPath.isEmpty() == false)
| {
| String path = ClassLoaderUtils.classNameToPath(className);
| for (VirtualFile cp : classPath)
| {
| file = cp.getChild(path);
| if (file != null)
| {
| cache.put(className, file);
| return file;
| }
| }
| }
|
| return null;
| }
|
| public InputStream openClassfile(String className) throws NotFoundException
| {
| try
| {
| VirtualFile file = findFile(className);
| if (file != null)
| return file.openStream();
| }
| catch (IOException e)
| {
| throw new NotFoundException("Exception finding file: " + className,
e);
| }
| throw new NotFoundException("ClassName '" + className +
"' not found in deployment unit: " + unit);
| }
|
| public URL find(String className)
| {
| try
| {
| VirtualFile file = findFile(className);
| if (file != null)
| return file.toURL();
| }
| catch (Exception ignored)
| {
| }
| return null;
| }
|
| public void close()
| {
| cache.clear();
| }
| }
It's in the deployers trunk.
Can either Stan or Shane test this?
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4185387#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...