[prev in list] [next in list] [prev in thread] [next in thread] 

List:       jedit-users
Subject:    Re: [ jEdit-users ] JARClassLoader: getResourceAsStream not working?
From:       "Eric Berry" <elberry () gmail ! com>
Date:       2006-08-18 23:09:31
Message-ID: 3bd11e000608181609n21d08032ke84388f5db8d64f4 () mail ! gmail ! com
[Download RAW message or body]

> Just to note it, the bean persistence mechanism from the java.beans
> package stores beans in XML files too, or rather in XML format, no
> matter if you pipe it into a file or somewhere else.

Yes, the XMLEncoder rocks! Spring has it's own format however. I've
used XSLT before to translate the serialized (XML) java objects into
the Spring format, but really their XML is more about dependency
injection or inversion of control (IOC). It's a way to initialize and
create beans through XML, but also to inject beans with their
perspective dependencies.

If you're interested, I urge you to check out the website, they'll be
able to explain everything much easier than I will.
http://www.springframework.org

> Why from a ClassLoader and not through an URLConnection?
> How does such an import look like and how does Spring process it?

Classes are loaded from the ClassLoader - resources are loaded through
their own ResourceLoaders, but after looking through their code and
fiddling around a bit, it looks like they end up using basically 3
different methods, URLConnection, a file or the classloader.

An import literally looks like this:
[code]
<import resource="axis.xml"/>
[/code]
This is in my web context file and loads up all the stuff for Apache
Axis since I have a small webservice.

> You are partly right. The thing is that you can still have plugins in
> both directories. Plugins in the jEdit directory get always loaded
> (unless the -noplugins switch is used), plugins in the settings
> directory get loaded if that settings directory is used (i. e. if no
> switch is used every user has its own settings directory and additional
> you can influence which settings directory is used on startup with the
> -settings switch, or suppress any settings-directory with the
> -nosettings switch). Additionally you can set the property to "settings
> directory", download some plugins, then they are put there (while the
> standard plugins QuickNotepad, LatestVersion and MacOS still are at the
> "jEdit home") and then you switch the setting to "jEdit home" and
> download again some plugins, then the new plugins are put in the jEdit
> home, but the "old" plugins still are at the settings directory. And I
> didn't think much about it, but I think it is possible to load plugins
> manually/programmatically from any location you want, so the plugin-jars
> can reside everywhere. But as I said you can get the full paths of all
> loaded plugins programmatically how I described in the last mail.

Yeah, I figured out a way to work around this. Since Spring allows for
the dynamic replacement of variables in their XML files (like ant
style variables), I can easily set the directory of each plugin as a
System property and then the plugins can reference that in their
context files.

So a plugin using my plugin might have this in their main context file.
[code]
<import resource="${myOtherPlugin.resource.root}/axis.xml"/>
[/code]
${myOtherPlugin.resource.root} will get replaced with a
"jar:file://path/to/myOtherPlugin.jar!".

This is great, this way, any plugin using my plugin (and thus Spring)
can be anywhere, as long as jEdit's JARLClassloader knows about it,
and I can find it via the getPlugins() method.

I'm not sure if it's possible to have a plugin where the jar doesn't
exist on the filesystem, but this would be the only problem.

Thanks again for all the help.
Eric


-- 
Learn from the past. Live in the present. Plan for the future.

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
-- 
-----------------------------------------------
jEdit Users' List
jEdit-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jedit-users
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic