First Question:
Is there a difference between:
<class_name>.class.getResource()
and
this.getClass().getResource()
Is one done natively? How does the VM see these two - as equivalent?
Second Question:
I know that when getClass().getResource() is called, that it
delegates the check to the Class's ClassLoader. So really the call is to
the ClassLoader. So when you normally do a call for getResource() it just creates a path by changing the class's package dots into "/" and then passes this to the ClassLoader to look in the folder structure.
Here's what I want to do:
1. Have XML config files for Objects in a package
a. Have these XML files available either through Http, file, etc.
2. Be able to tie the domain address to the ProtectionDomain (I think this is what I mean) of a package
EXAMPLE
If I set "http://www.site.com/Person.cfg" as the config file for
the object of class: com.site.dept.Person, then when the Person
object calls:
this.getClass().getResource("/Person.cfg");
the resource should be found at
http://www.site.com/Person.cfg ONLY from a call of an object in that package. So basically, it
ties "http://www.site.com/Person.cfg" to the package
com.site.dept; As with normal lookups, if I'm calling it from
a class com.site.other.People.class.getResource( "Person.cfg")
then it will return null (even though Person.cfg is really
located in an http location.
As well, just as with any resource actually in the folder:
com/site/dept (inside the jar or whatever), it will be
a part of that ProtectionDomain and have the same security
settings as any file in that folder would have, even though
the ClassLoader fetches it from http.
I want this to be as clean and secure as possible. I also know that I
should delegate to the super class (URLClassLoader) as much as possible, but I don't know if I can do that here since I'm doing something completely different in terms of storing URLs and tying them together. So I'm at a loss as to what's the best way to tie the http addresses (or other protocol addresses) to the correct package spots. Just to give you all more info, when I create the classloader I can pass it the info of what address is supposed to go with what object. So maybe something like this:
Thanks and please let me know if anything here needs more explaining!
-Robert
[ July 29, 2002: Message edited by: Robert Paris ]
[ July 29, 2002: Message edited by: Robert Paris ]