...To be more specific, I consider creating my own custom-modification
of Tomcat including functionality for application-level control of
resources - see the below sketch. I kind of think upon a modified
'JspServlet' hidden behind a nice interface so as to avoid fiddling
directly with JSP-compilation and so on.
Is this possible?
How hard is it to implement?
Are there alternatives (like hacking class-loaders or
file-system-access)?
I believe, that it can be done by direct JSPC-invocation or abuse of the
file-system containing unpacked WAR's - both compromises the integrity
of WAR's - I do not consider any of these a clean of "pure" way of doing
it. I want programmatic control.
Dynamic JSP's/resources are (sadly) not part of Sun's specifications.
As far as I can tell from a short look at the source-code for Tomcat, it
should not be too hard to create this functionality. It would be a nice
experiment.
If you care to comment, I would like to here some opinions from people
with insight into the internals of Tomcat.
Morten Sabroe Mortensen
----- BEGIN: Idea for application-level control of resources: -----
The idea is this:
A web-resource like e.g. a JSP-page is to be obtained by the
servlet-engine from the web-application through an interface like this:
/**
* Description of a resource within the context of a servlet-engine. */
public interface Resource {
/**
*
*/
long getTimeModification()
throws
IOException;
/**
*
*/
InputStream getInputStream(String path)
throws
IOException;
}
When a user-agent addresses e.g. a JSP-page, a 'ResourceManager' set by
the application is requested by the servlet-engine with the purpose of
delivering the resource:
ServletContext (modified - Tomcat-specific):
void setResourceManager(ResourceManager resourceManager) ...
ResourceManager getResourceManager() ...
Resource getResourceAsResource(String path)
{
Resource res=null;
{
ResourceManager resourceManager=getResourceManager();
if (resourceManager!=null)
{
res=resourceManager.getResource(path);
}
}
return res;
}
void addResourceListener(ResourceListener l)
void removeResourceListener(ResourceListener l)
void fireResourceUpdate(ResourceEvent ev)
interface ResourceManager:
Resource getResource(String path) ...
interface ResourceListener:
void onResourceUpdate(ResourceEvent ev) ... //event-object must
contain path-information
There could be two strategies for accessing a resource:
1) Each time a resource like e.g. a JSP-page is requested, the
servlet-engine performs a lookup for the 'Resource' object and uses
'getTimeModification()' to determine, if the JSP-page has changed and
therefore should be re-compiled and re-loaded. The resource could also
have been removed completely, which would result in no 'Resource' object
being found and 'null' returned - in which case the page no longer
exists.
2) The application always notifies the servlet-engine about changes to
resources. If a resource like e.g. a JSP-page is changed or removed, the
application calls 'fireResourceUpdate()' which again trickers all
'ResourceListener' instances, where the servlet-engine itself per
default has a specific listener added and this listener makes the
servlet-engine perform a lookup for the 'Resource' as in 1).
The 'ResourceManager' could implement a chain-of-responsibility, but
this can be left to the specific application and does not need to be
part of the interface between the servlet-engine and the
web-application.
Interesting types of resources include JSP-pages/-fragments and
tag-libraries.
As I see it, the 'Resource'-type of interface could also be in play,
when Tomcat differs between obtaining resources from an unpacked
WAR-file to when the WAR-file is actually unpacked within the
file-system and JSP-pages are added or changed directly within the
file-system. Tomcat must have something like my 'Resource'-functionality
already, but possibly not expressed as an interface between Tomcat and
web-applications. When moving to a "live" repository like a file-system,
the 'Resource.getTimeModification()' comes into play. There is a
possibility for a unification here.
----- END: Idea for application-level control of resources. -----
-----Original Message-----
From: Morten Sabroe Mortensen [mailto:[EMAIL PROTECTED]
Sent: 9. april 2005 18:36
To: [email protected]
Subject: Application-level control of web-resources
What are the possibilites for application-level control of resources
like JSP-resources?
This would open up for e.g. creating a wiki-like application, where each
wiki-page is a valid JSP-page, which is created dynamically and stored
elsewhere than within the deployed WAR-file.
If anyone fancy this type of functionality - or have tried to implement
it by whatever means possible - please make a statement!
Morten Sabroe Mortensen
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]