tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Goren Il <gore...@hotmail.com>
Subject Re: How to call an external class from a webapp (i.e. - implement a plugin)
Date Thu, 08 Jul 2010 09:16:28 GMT

  Thanks Chris for your response.
It seems that you are thinking in the same direction that we had in mind.
About your suggestion to create a new class loader - this is the direction that we started
checking.
We considered the following:
1. Creating a new class, that extends WebappClassLoader.
2. Create an instance of this class, and copy all the configuration from the wepassp's class
loader. (Question to the forum - other than the URL's - what other properties should we copy)?
3. Add the extra directory to the URLs
4. Load the class by name, using the new class loader.

Will this work?
Is there some example code for that?
(BTW, we are using Tomcat 5.5, in case it matters).

About your last question - the webapp loads an XML from an external directory, which includes
all configuration parameters.

Thanks
G.



On 07-Jul-10 22:36, Christopher Schultz wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Goren,
>
> On 7/6/2010 10:51 AM, Goren Il wrote:
>>   There are 2 issues (not in order of priority):
>> 1. The steps are not straight forward, and may cause the system to stop
>> working (the customer should change the WAR suffix to "zip", open it,
>> add the files and rename it back)
> There isn't really a reason why the above shouldn't work.
>
>> 2. When we provide a new version, we will replace the WAR and all the
>> changes are gone.
> Fair enough, but the customer can re-install their plug-ins.
>
> Another option is to implement your own ClassLoader that scans a
> directory (such as /my/great/plugins) for JAR files and will load them
> alongside your webapp's classes.
>
> You'll either have to chain that ClassLoader into the standard webapp
> ClassLoader provided by Tomcat for transparent class-loading by your
> webapp, or write a wrapper for plug-in loading and execution by
> explicitly managing and invoking that ClassLoader as necessary.
>
> You should seriously consider how to implement security mechanisms when
> loading classes that you do not provide yourself.
>
>> I would like my webapp to call an external class, which will be
>> provided (as a name) in an XML file at run time.
> How does your webapp load this XML file if it isn't packaged in the WAR
> file?
>
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAkw011gACgkQ9CaO5/Lv0PAO9QCfRRfexlNsGjxh5pg2pHKlzbWC
> XVEAoKaBL2jk5i10EIY2DDQt6wcP4vc/
> =VS3H
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message