Nudity / reflections

Automatically exported from code.google.com/p/reflections
Do What The F*ck You Want To Public License
0 stars 0 forks source link

Add support for jndi URL type #119

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Would be nice to support jndi URL type in Reflections.

You get jndi URL for example when you ask the Servlet for a resource coming 
from the current war/webapp in which you can find the same kind of data than in 
a jar (classes, etc.) and that you may want to scan for the same reasons.

Original issue reported on code.google.com by thomas.m...@gmail.com on 4 Jun 2012 at 2:32

GoogleCodeExporter commented 8 years ago
I'm not sure it should be added to the default url types. 
anyway, is this working?

Vfs.addDefaultURLTypes(
                new Vfs.UrlType() {
                    public boolean matches(URL url) {
                        return url.getProtocol().equals("jndi");
                    }

                    public Vfs.Dir createDir(URL url) throws Exception {
                        return DefaultUrlTypes.jarUrl.createDir(url);
                    }
                });

Original comment by ronm...@gmail.com on 5 Jun 2012 at 7:00

GoogleCodeExporter commented 8 years ago
This is not going to work since it does not look anything like a jar URL, you 
get something like jndi://localhost/xwiki/ (where "xwiki" is the context root 
of the application). I need to check exactly how it's possible to scan file 
from a jndi URL.

Original comment by thomas.m...@gmail.com on 5 Jun 2012 at 8:25

GoogleCodeExporter commented 8 years ago
oh sure it doesn't... I'll look into it when I got the time. 
If you can provide integration instruction, it would be great (something like 
http://code.google.com/p/reflections/wiki/JBossIntegration)

Original comment by ronm...@gmail.com on 5 Jun 2012 at 11:05

GoogleCodeExporter commented 8 years ago
Hmm not sure, I'm debugging Tomcat for my tests currently. Will see if I can 
find something nicer for unit tests.

Original comment by thomas.m...@gmail.com on 5 Jun 2012 at 11:23

GoogleCodeExporter commented 8 years ago
simple-jndi (http://code.google.com/p/osjava/wiki/SimpleJNDI) sounds good. Plus 
it's on maven central.

Original comment by thomas.m...@gmail.com on 5 Jun 2012 at 11:40

GoogleCodeExporter commented 8 years ago
BTW my real use case is to scan the WAR I'm running in. Maybe there is another 
way.

Original comment by thomas.m...@gmail.com on 11 Jun 2012 at 4:30

GoogleCodeExporter commented 8 years ago
Hello, I'm studying the same use case - scanning the WAR I'm running in for 
annotated classes, and don't know how to use the jndi URL returned by a 
ServletContext.

Were you able to solve this, and if so do you have any suggestions ?

Thanks,
David

Original comment by dcjan...@gmail.com on 1 Nov 2012 at 11:58

GoogleCodeExporter commented 8 years ago
I tried to look around on how to deal with theses JNDI URLs but could not make 
anything work. I finally put some information in the MANIFEST.mf file to help 
me find what I was searching for. Works for my specific use case but you can't 
always do that...

Original comment by thomas.m...@gmail.com on 2 Nov 2012 at 8:51

GoogleCodeExporter commented 8 years ago
Thanks for your reply.  I'm not happy with my current scheme, but I seem to 
have gotten it working (for now, in JBoss AS7).  

Given a ServletContext "context":

1. Build a list of URLs with context.getResource(path) for each path returned 
in context.getResourcePaths("/").  This results in two "virtual paths" for 
resources of this war.  These paths include the virtual-server name (defaults 
to "default-host") from standalone-xml.full.

2. For each virtual path,  strip off everything but the last path component 
("META-INF" and "WEB-INF") and use context.getRealPath() on that string to get 
the actual path, e.g. 
"/opt/jboss/standalone/tmp/vfs/tempf981207421a1bc0e/content-cccac5e9cf992bde/MET
A-INF"

3.  search those directories for .jar/.class files.

[I'm using Annovention for annotation discovery - this is a small tweak to the 
com.impetus.annovention.Discoverer.getResourceIterator() method.]

Original comment by dcjan...@gmail.com on 2 Nov 2012 at 11:54

GoogleCodeExporter commented 8 years ago
on trunk (JarInputStream VfsType)

Original comment by ronm...@gmail.com on 16 Mar 2013 at 1:23

GoogleCodeExporter commented 8 years ago
Is this supposed to work on 0.9.9-RC1 or still in trunk ?

Original comment by maximili...@gmail.com on 28 Feb 2014 at 5:25

GoogleCodeExporter commented 8 years ago

Original comment by ronm...@gmail.com on 5 Jun 2014 at 7:46