You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Yoav Shapira <yo...@apache.org> on 2007/02/01 01:03:13 UTC

Please remind me why context path for XML descriptors is coded to file name?

Hi,
I know we've talked about this before and resolved Bugzilla items
related to this, but I'd like to be reminded, please.  Why does the
following code exist as such?

In org.apache.catalina.startup.HostConfig
(http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/startup/HostConfig.java?view=annotate),
deployDescriptors method (line 527), the following code:

File contextXml = new File(configBase, files[i]);
if (files[i].toLowerCase().endsWith(".xml")) {

  // Calculate the context path and make sure it is unique
  String nameTmp = files[i].substring(0, files[i].length() - 4);
  String contextPath = "/" + nameTmp.replace('#', '/');
  if (nameTmp.equals("ROOT")) {
    contextPath = "";
  }

  if (isServiced(contextPath))
    continue;
 ...

This code results in the (correctly documented at
http://tomcat.apache.org/tomcat-5.5-doc/config/context.html, but
annoying) behavior that users deploying web applications from
conf/Catalina/localhost/appname.xml context files can't set a path for
their context.  Instead, the path is taken right from the file name,
which is less flexible.

Why don't we use the path from the contextXml file and use it?  The
isServiced check will remain unmodified, enforcing unique paths per
virtual Host.  We can also keep / use the current path determination
code if the user doesn't specify a path explicitly.

Thanks,

Yoav

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


Re: Please remind me why context path for XML descriptors is coded to file name?

Posted by Remy Maucherat <re...@apache.org>.
Yoav Shapira wrote:
> This code results in the (correctly documented at
> http://tomcat.apache.org/tomcat-5.5-doc/config/context.html, but
> annoying) behavior that users deploying web applications from
> conf/Catalina/localhost/appname.xml context files can't set a path for
> their context.  Instead, the path is taken right from the file name,
> which is less flexible.

Personally, I don't see why it is less (or more) flexible.

The deployer is simple, and doesn't associate deployment artifacts 
(files, etc) with webapps other than by the pathname. I don't think a 
hack to the current deployer would work that well, so if you want to 
improve this, I think you should "start over" with a new fancier 
deployer (which is easy to do since it's a listener).

Rémy

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


Re: Please remind me why context path for XML descriptors is coded to file name?

Posted by Filip Hanik - Dev Lists <de...@hanik.com>.
hmm, that's how I thought it worked, the filename would only be used if 
the "path" attribute was not present inside the XML file.

Filip

Yoav Shapira wrote:
> Hi,
> I know we've talked about this before and resolved Bugzilla items
> related to this, but I'd like to be reminded, please.  Why does the
> following code exist as such?
>
> In org.apache.catalina.startup.HostConfig
> (http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/startup/HostConfig.java?view=annotate), 
>
> deployDescriptors method (line 527), the following code:
>
> File contextXml = new File(configBase, files[i]);
> if (files[i].toLowerCase().endsWith(".xml")) {
>
>  // Calculate the context path and make sure it is unique
>  String nameTmp = files[i].substring(0, files[i].length() - 4);
>  String contextPath = "/" + nameTmp.replace('#', '/');
>  if (nameTmp.equals("ROOT")) {
>    contextPath = "";
>  }
>
>  if (isServiced(contextPath))
>    continue;
> ...
>
> This code results in the (correctly documented at
> http://tomcat.apache.org/tomcat-5.5-doc/config/context.html, but
> annoying) behavior that users deploying web applications from
> conf/Catalina/localhost/appname.xml context files can't set a path for
> their context.  Instead, the path is taken right from the file name,
> which is less flexible.
>
> Why don't we use the path from the contextXml file and use it?  The
> isServiced check will remain unmodified, enforcing unique paths per
> virtual Host.  We can also keep / use the current path determination
> code if the user doesn't specify a path explicitly.
>
> Thanks,
>
> Yoav
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
>
>


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