Dear Developers,
I am writing about a proposal for a new feature in Tomcat. The need itself has been created in our software team, but it is not a special need to our team. It is a basic one, which probably lots of users could benefit from. The situation is the following. We are doing distributed software development of a web-based system with more developer groups. For the sake of the independent work of the groups we decided that every group would develop its own web module (in separate software projects) and we share as small part of the source code, as possible, basically interfaces and persistent entity definitions. This concept works well but only until one would like to share some object references between the web modules. At that point a classloading problem occurs which we would like to solve with this proposal. One could say: why sharing references, the ambition of web containers is to fully isolate the deployed web modules. In case of a distributed architecture described above, it is a common situation that a web module needs to have a reference to an object created in an another web module providing a certain service (for example a central scheduler, or an event dispatcher system). The classloading problem described below makes it difficult to use a web container this way, so the only solution at the moment is to use a J2EE container and deploy an enterprise module which causes unnecessary overheat. Suppose one web module gets a reference to an object created in an another web module. This can be achieved for example through accessing a mediator singleton loaded by the common class loader (singleton class deployed in $CATALINA_HOME/lib). The problem is that the classloader of the shared object (this is the classloader of the provider web module) differs from the classloader of the consumer web module. At this point the shared object can not be casted to the corresponding type in the consumer web module, fields and methods are accessible only via reflection. This makes difficult the usage of the shared object. Our proposal is to include a special web application class loader within Tomcat distribution which can be used optionally and which is capable of sharing class objects among web modules. Classes marked as ‘shared’ in a property file would be loaded only once, by one of the web application class loaders. The other web application class loaders would use the same class objects on demand, allowing shared objects to be casted in the consumer web module. A less elaborate, hackish, but basically working implementation of this special web application class loader is attached to this email. It is called SharingWebappClassLoader. In the constructor it reads the list of classes to share from the 'catalina.properties' file under the key 'package.shared'. If a class marked as shared should be loaded, first all other SharingWebappClassLoader instances will be checked, if they have already loaded that class. If one of those classloaders has already loaded the class, than that class object will be used and returned. A shared class will be loaded only if no other SharingWebappClassLoader instance has already loaded it. Loading of not shared classes does not change, it works like in the normal WebappClassLoader. Dear Developers, I recommend the consideration of the acceptance of this proposal and I am also very curious of your opinion. Regards, Roland Lohner
--------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org