How to implement a webapp class loader
I would like to implement my on webapp class loader, that will look for jars in specific places (to be defined in the configuration). I would like to inherit the behavior of the default class loader of the webapp, so I can not use a regular ClassLoader. I considered inheriting from WebappClassLoader. Is there a simpler way? Is there some documentation how to create such a class loader? Thanks G. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: How to call an external class from a webapp (i.e. - implement a plugin)
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-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: How to call an external class from a webapp (i.e. - implement a plugin)
so the basic idea is: 1. Define an interface (WSDL or named parameters for a post message) 2. Enable specifying the URL of the plugin in the context of the webapp 3. As part of the flow, call that URL with the defined format Did I follow your thought? It seems like an overhead in terms of performance, but if there is no other possibility - this is what we shall do. Thanks On 06-Jul-10 18:15, Caldarale, Charles R wrote: From: Goren Il [mailto:gore...@hotmail.com] Subject: Re: How to call an external class from a webapp (i.e. - implement a plugin) Aren't there other webapps that have plugin capabilities? The philosophy of the servlet spec is to have self-contained webapps, so plugins aren't really catered for. (Might be something in the 3.0 spec, but I haven't really studied it yet.) As an alternative to direct class calls, can you package the add-on as a separate context and reference it via forwarding or as a web service? - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
How to implement a webapp class loader
I would like to implement my on webapp class loader, that will look for jars in specific places (to be defined in the configuration). I would like to inherit the behavior of the default class loader of the webapp, so I can not start use a regular ClassLoader. I considered inheriting from WebappClassLoader. Is there a simpler way? Is there some documentation how to create such a class loader? Thanks G. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: How to call an external class from a webapp (i.e. - implement a plugin)
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) 2. When we provide a new version, we will replace the WAR and all the changes are gone. Aren't there other webapps that have plugin capabilities? How do they implement this capability? Thanks G. On 06-Jul-10 15:45, Joseph Morgan wrote: What's wrong with providing instructions to the customer on how to install the plugin with a particular web app? -Original Message- From: Goren Il [mailto:gore...@hotmail.com] Sent: Monday, July 05, 2010 2:44 AM To: users@tomcat.apache.org Subject: How to call an external class from a webapp (i.e. - implement a plugin) I would like my webapp to call an external class, which will be provided (as a name) in an XML file at run time. The external class will be developed by 3rd party, and might include additional JARs. I will refer to the external class and JARs as the plugin. My webapp is provided as a WAR, so it is not possible to add the plugin into the same WAR (unless the customer performs it himself). I do not want to put the plugin's JARs in the common lib of Tomcat, so that it will not affect other webapps (the plugin might include JARs of different versions than the webapps use). I considered putting the plugin in a separate folder, and implement my own class loader that will look at that folder as well. It seems like too much of an effort for a simple task. What is the recommended way to achieve plugin capabilities for a webapp? Thanks G. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
How to call an external class from a webapp (i.e. - implement a plugin)
I would like my webapp to call an external class, which will be provided (as a name) in an XML file at run time. The external class will be developed by 3rd party, and might include additional JARs. I will refer to the external class and JARs as the plugin. My webapp is provided as a WAR, so it is not possible to add the plugin into the same WAR (unless the customer performs it himself). I do not want to put the plugin's JARs in the common lib of Tomcat, so that it will not affect other webapps (the plugin might include JARs of different versions than the webapps use). I considered putting the plugin in a separate folder, and implement my own class loader that will look at that folder as well. It seems like too much of an effort for a simple task. What is the recommended way to achieve plugin capabilities for a webapp? Thanks G. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org