[Yanel-dev] Proposal to introduce the webapp protocol

Michael Wechner michael.wechner at wyona.com
Tue Aug 4 23:04:19 CEST 2009


Guillaume Déflache schrieb:
> Hi!
>
> [I actually started writing that on July 28th, but figured I needed 
> more hands-on coding before sending it. I think I have stripped all 
> now-irrelevant-after-yanelhtdocs-protocol-implementation stuff]
>
> Michael Wechner schrieb:
>> Currently various global file locations are hard-coded (like for 
>> example the login-screen XSLT)
>>
>> src/webapp/src/java/org/wyona/yanel/servlet/security/impl/DefaultWebAuthenticatorImpl.java 
>>
>>
>> File xsltLoginScreen = 
>> org.wyona.commons.io.FileUtil.file(realmDir.getAbsolutePath(), "src" 
>> + File.separator + "webapp" + File.separator + xsltLoginScreenDefault);
>>                if (!xsltLoginScreen.isFile()) xsltLoginScreen = 
>> org.wyona.commons.io.FileUtil.file(servletContextRealPath, 
>> xsltLoginScreenDefault);
>>
>> I would suggest that we introduce a "webapp" protocol, whoch would 
>> then allow something like
>>
>> href="webapp:/xslt/login-screen.xsl"
>>
>> (which would be resolved to 
>> ..../local/apache-tomcat-5.5.20/webapps/yanel/xslt/login-screen.xsl)
>>
>>
>> WDYT?
>
> Several remarks:
>
> 0) I wonder what you are referring to by "hardcoded" here, since
> xslLoginScreenDefault can also be separately overridden in web.xml, is
> it the "src/webapp" prefix?

yes, whereas I just notice the code above points to the realm and not to 
the webapp, but IIRC there must also be a fallback pointing to the webapp
if this file doesn't exist within the realm
>
> 1) current-realm-to-webapp fallback: consistency and code duplication
> 1.1) the global resource configs also use the same kind of fallback
> ($REALM_DIR/src/webapp/path/to/filename.txt or else
> $WEBAPP_DIR/path/to/filename.txt) but duplicates the needed code in
> http://svn.wyona.com/repos/public/yanel/trunk/src/webapp/src/java/org/wyona/yanel/servlet/YanelServlet.java 
>
> to handle it

it would be good to refactor this at some point or at least create a 
bugentry and add a TODO
> 1.1) the same fallback is however not used for the error screen: look
> for "exception-and-info-screen-xslt" also in YanelServlet: any reason 
> why?

no actual reason and should also be refactored/enhanced
> 1.3) I wondered if we want to use this fallback for other files; it
> might make sense, but I seem to recall Simon saying to me that he
> thought this fallback was not a very good idea: Simon, any thoughts
> about this?

I don't see any reason right now why this should be bad, but yes it 
would be good if Simon could state why
he think it's bad
>
> 2) "webapp" protocol:
> 2.1) would you like the "webapp" protocol to also take care of the
> fallback from the realm, or only of the Yanel servlet stuff? ...then
> "webapp" name might be misleading

I don't think the webapp protocol should take care of the fallback, 
because I think there can be cases where you really want the file
from the webapp directory and not from the realm even if it exists 
within the realm.

Why do you think it's misleading? Or rather what alternative name do you 
suggest?
> 2.2) the way the fallback is implemented now will make it fail for 
> unexploded
> WARs, but maybe we don't care

Can you explain in which cases the WAR will not be opened?
> 2.3) also I wonder what is supposed to happen in the case of the Yanel
> command-line? do we still want to support it BTW?

sure, but it would need some refactoring. I still think for code 
development and testing it would help a lot, because
for many cases one does not need a webapp running.

The problem is that we merged resources and webapp too much (re requests 
and responses) and would have to introduce a better separation without
breaking backwards compatibility
> 2.4) maybe the name "htdocs" could be use for the realms, but IMHO it 
> should
> refer only to documents that are also available directly through HTTP:
> that's the case for all the other existing and suggested "*htdocs"
> protocols that are also mapped under Yanel's reserved prefix

can you give an example?

Thanks

Michael
>
> Cheers,
>    Guillaume



More information about the Yanel-development mailing list