You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2012/05/05 09:59:35 UTC
svn commit: r1334336 -
/ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java
Author: jleroux
Date: Sat May 5 07:59:34 2012
New Revision: 1334336
URL: http://svn.apache.org/viewvc?rev=1334336&view=rev
Log:
Better way to read the distributable element from web.xml files.
I did not put any distributable elements in web.xml files. So people still needs to follow the advice in catalina-container element in ofbiz-containers.xml
Modified:
ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java
Modified: ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java?rev=1334336&r1=1334335&r2=1334336&view=diff
==============================================================================
--- ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java (original)
+++ ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java Sat May 5 07:59:34 2012
@@ -20,6 +20,7 @@ package org.ofbiz.catalina.container;
import java.io.File;
import java.io.IOException;
+import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Iterator;
@@ -77,8 +78,8 @@ import org.ofbiz.base.container.Containe
import org.ofbiz.base.container.ContainerConfig;
import org.ofbiz.base.container.ContainerConfig.Container.Property;
import org.ofbiz.base.container.ContainerException;
+import org.ofbiz.base.location.FlexibleLocation;
import org.ofbiz.base.util.Debug;
-import org.ofbiz.base.util.FileUtil;
import org.ofbiz.base.util.SSLUtil;
import org.ofbiz.base.util.UtilURL;
import org.ofbiz.base.util.UtilValidate;
@@ -619,17 +620,26 @@ public class CatalinaContainer implement
mount = mount.substring(0, mount.length() - 2);
}
+ final String webXmlFilePath = new StringBuilder().append("file:///").append(location).append("/WEB-INF/web.xml").toString();
- final String webXmlFilePath = new StringBuilder().append(location)
- .append(File.separatorChar).append("WEB-INF")
- .append(File.separatorChar).append("web.xml").toString();
- boolean appIsDistributable = false;
+ URL webXmlUrl;
try {
- appIsDistributable = FileUtil.containsString(webXmlFilePath, "<distributable/>");
- } catch (IOException e) {
- Debug.logWarning(String.format("Failed to read web.xml [%s].", webXmlFilePath), module);
- appIsDistributable = false;
+ webXmlUrl = FlexibleLocation.resolveLocation(webXmlFilePath);
+ } catch (MalformedURLException e) {
+ throw new ContainerException(e);
}
+ Document webXmlDoc = null;
+ try {
+ webXmlDoc = UtilXml.readXmlDocument(webXmlUrl);
+ } catch (SAXException se) {
+ throw new ContainerException(se);
+ } catch (ParserConfigurationException pce) {
+ throw new ContainerException(pce);
+ } catch (IOException ioe) {
+ throw new ContainerException(ioe);
+ }
+
+ boolean appIsDistributable = webXmlDoc.getElementsByTagName("distributable").getLength() > 0 ? true : false;
final boolean contextIsDistributable = distribute && appIsDistributable;
// configure persistent sessions
Re: svn commit: r1334336 - /ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java
Posted by Jacques Le Roux <ja...@les7arts.com>.
Right, that I copied from elsewhere in code, I will then review this/ese other part/s too...
Jacques
From: "Adrian Crum" <ad...@sandglass-software.com>
> On 5/5/2012 9:19 AM, Jacopo Cappellato wrote:
>> On May 5, 2012, at 9:59 AM, jleroux@apache.org wrote:
>>
>>> + boolean appIsDistributable = webXmlDoc.getElementsByTagName("distributable").getLength()> 0 ? true : false;
>> (a trivial note) this can be simplified with:
>>
>> boolean appIsDistributable = webXmlDoc.getElementsByTagName("distributable").getLength()> 0;
>>
>> Jacopo
>
> Also, the multiple catch blocks can be reduced to a singe catch
> (Exception e).
>
> -Adrian
>
Re: svn commit: r1334336 - /ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java
Posted by Adrian Crum <ad...@sandglass-software.com>.
On 5/5/2012 9:19 AM, Jacopo Cappellato wrote:
> On May 5, 2012, at 9:59 AM, jleroux@apache.org wrote:
>
>> + boolean appIsDistributable = webXmlDoc.getElementsByTagName("distributable").getLength()> 0 ? true : false;
> (a trivial note) this can be simplified with:
>
> boolean appIsDistributable = webXmlDoc.getElementsByTagName("distributable").getLength()> 0;
>
> Jacopo
Also, the multiple catch blocks can be reduced to a singe catch
(Exception e).
-Adrian
Re: svn commit: r1334336 - /ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java
Posted by Jacques Le Roux <ja...@les7arts.com>.
Yes, indeed. I used another way before (instead of webXmlDoc.getElementsByTagName("distributable").getLength() > 0 ) an forgot to
remove the ternary operator after ;o)
Will do when I will get a chance....
Jacques
From: "Jacopo Cappellato" <ja...@hotwaxmedia.com>
> On May 5, 2012, at 9:59 AM, jleroux@apache.org wrote:
>
>> + boolean appIsDistributable = webXmlDoc.getElementsByTagName("distributable").getLength() > 0 ? true : false;
>
> (a trivial note) this can be simplified with:
>
> boolean appIsDistributable = webXmlDoc.getElementsByTagName("distributable").getLength() > 0;
>
> Jacopo
Re: svn commit: r1334336 - /ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java
Posted by Jacopo Cappellato <ja...@hotwaxmedia.com>.
On May 5, 2012, at 9:59 AM, jleroux@apache.org wrote:
> + boolean appIsDistributable = webXmlDoc.getElementsByTagName("distributable").getLength() > 0 ? true : false;
(a trivial note) this can be simplified with:
boolean appIsDistributable = webXmlDoc.getElementsByTagName("distributable").getLength() > 0;
Jacopo