Re: [OS-webwork] XWork, Webwork and reloading xml

2004-03-09 Thread Craig Raw
Hi,

After spending some time with the xwork/oscore code, I find that what you say is not wrong, but it 
is broken in this case. The problem is in FileManager, which stores a reference to the file and its 
last modified timestamp as you say, to check if it needs reloading later. Before storing this 
however, FileManager checks if the file exists and is readable (reasonably so, since it needs to 
obtain the last modified timestamp). However, in the case of deployment on JBoss and sharing the 
xwork/oscore libs, the file does not exist. JBoss does not explode its shared libs, and the file url 
that FileManager obtains looks something like 
/jboss/server/default/lib/webwork-2.0.jar!/webwork-default.xml.

Since this doesn't exist, webwork-default.xml is never added to FileManagers references, 
XmlConfigurationProvider.needsReload() always returns true and thus every request to the site means 
all the configuration files are reloaded.

Note that this only happens with the include file=webwork-default.xml type references in 
xwork.xml, not xwork.xml itself, but XmlConfigurationProvider checks all of its referenced files for 
reloading.

I don't whether jboss or xwork/oscore is broken here, but I'd appreciate any suggestions.

Thanks,
Craig
Jason Carreira wrote:
It doesn't actually re-parse the configuration XML file every time. The
ConfigurationManager calls provider.needsReload() on every
ConfigurationProvider to see if that config provider thinks it needs to
reload (so any custom ConfigurationProvider can implement this in its
own way). The XmlConfigurationProvider, which parses xwork.xml or any
file using that DTD, uses the FileManager from OSCore which I wrote
(stole from some of Hani's code :-) )... That utility maintains a
reference to the file and checks its timestamp vs. the time stamp the
last time we read it to see if the file timestamp has changed. 

Note that if you set this flag the same check will be done for all
validation files and conversion property files, although not for text
bundles (complain to Sun, it's their PropertyResourceBundle). 

Jason


-Original Message-
From: Craig Raw [mailto:[EMAIL PROTECTED] 
Sent: Monday, March 08, 2004 7:37 AM
To: [EMAIL PROTECTED]
Subject: [OS-webwork] XWork, Webwork and reloading xml

Hi,

I have run into issues surrounding xwork and the reloading of 
classes using hot deploy. My 
deployment environment is JBoss, where I am sharing the 
webwork/xwork libraries between ears (to 
keep the ear file size down) and using a separate loader 
repository for each ear (to keep the 
configurations separated by classloader namespace).

The problem comes with the flag, 
webwork.configuration.xml.reload. When set to false, xwork holds on 
the xwork.xml file (loaded by a classloader) even after a hot 
redeploy. This causes all the classes 
loaded by that classloader to remain accessible as well, and 
the hot redeploy fails in the sense 
that the deployed classes do not change, and neither does the 
xwork configuration. (This would not 
happen if I bundled the xwork/webwork libraries into the 
ear/war, at the cost of a much larger ear 
file size.)

If the flag is true, hot redeploy works fine, but 
com.opensymphony.work.config.ConfigurationManager 
reloads xwork.xml on every request to the server.

I would like to be in a situation where I can hot deploy to a 
production server, to avoid having to 
drop all the deployments and restart the server just to 
update one. However, I am concerned as to 
the additional load caused by constantly reloading xwork.xml. 
I see that there is a comment in the 
class mentioned above, on line 127:

 @todo it currently appears that the reload strategy is to 
check on each call to 
getConfiguration().  this seems extremely burdensome.  a 
caching mechanism should be implemented

Is it possible to have the best of both worlds, and have the 
xwork.xml reloaded only on redeploy?

TIA,
Craig
---
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President 
and CEO of GenToo technologies. Learn everything from 
fundamentals to system 
administration.http://ads.osdn.com/?ad_id=1470alloc_id=3638op=click
___
Opensymphony-webwork mailing list 
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork



---
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id70alloc_id638op=click
___
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork



---
This SF.Net email is sponsored by: 

Re: [OS-webwork] XWork, Webwork and reloading xml

2004-03-09 Thread Philipp Meier
Jason Carreira schrieb:
Well, that code is really there for the case where you do have exploded
war files, you're editing them, and you want the changes to be picked
up...
Tell me, will each redeployment get its own classloader? I'm planning on
refactoring so that the configuration is not a singleton, but is instead
kept in a Map of classloader - configuration...
I think that each redeployment will get a new classloader. This is 
because beside hotswap the vm does not support reloading classes. To 
provide a redeploy feature the servlet containers makes use of the fact 
that what makes as java class is really classname + classloader.

-billy

--
Meisterbohne   Küfner, Mekle, Meier GbR   Tel: +49-731-399 499-0
   eLösungen   Söflinger Straße 100   Fax: +49-731-399 499-9
   89077 Ulm http://www.meisterbohne.de/
---
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id70alloc_id638op=click
___
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork


RE: [OS-webwork] XWork, Webwork and reloading xml

2004-03-09 Thread Cuong Tran

Does File.canWrite() work for this case?

--- Jason Carreira [EMAIL PROTECTED] wrote:
 Do you know if there's a way to tell if it's in a jar file?
 
  -Original Message-
  From: Hani Suleiman [mailto:[EMAIL PROTECTED] 
  Sent: Tuesday, March 09, 2004 12:40 PM
  To: [EMAIL PROTECTED]
  Subject: Re: [OS-webwork] XWork, Webwork and reloading xml
  
  
  In this case I'd say xwork is broken. The solution is for it to
 not  
  bother monitoring files that are in jars.
  
  On Mar 9, 2004, at 11:53 AM, Craig Raw wrote:
  
  
 
 
 ---
 This SF.Net email is sponsored by: IBM Linux Tutorials
 Free Linux tutorial presented by Daniel Robbins, President and CEO
 of
 GenToo technologies. Learn everything from fundamentals to system
 administration.http://ads.osdn.com/?ad_id70alloc_id638op=click
 ___
 Opensymphony-webwork mailing list
 [EMAIL PROTECTED]
 https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork


__
Do you Yahoo!?
Yahoo! Search - Find what you’re looking for faster
http://search.yahoo.com


---
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470alloc_id=3638op=click
___
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork


Re: [OS-webwork] XWork, Webwork and reloading xml

2004-03-09 Thread Craig Raw
Each redeployment does get its own classloader. I am using Jboss' separate loader repositories 
feature to acheive this.

While I fully support what you are going to do in removing the static singleton configuration ( I 
filed the issue for that one :) ), it will unfortunately not help here. FileManager will still 
attempt to check the timestamp on unreachable files and reload them with every request. This is 
actually not centrally a repdeployment issue, redeployment is just the original cause for using the 
xml.reload flag.

Jason Carreira wrote:
Well, that code is really there for the case where you do have exploded
war files, you're editing them, and you want the changes to be picked
up...
Tell me, will each redeployment get its own classloader? I'm planning on
refactoring so that the configuration is not a singleton, but is instead
kept in a Map of classloader - configuration...
Would that help?


-Original Message-
From: Craig Raw [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, March 09, 2004 11:54 AM
To: [EMAIL PROTECTED]
Subject: Re: [OS-webwork] XWork, Webwork and reloading xml

Hi,

After spending some time with the xwork/oscore code, I find 
that what you say is not wrong, but it 
is broken in this case. The problem is in FileManager, which 
stores a reference to the file and its 
last modified timestamp as you say, to check if it needs 
reloading later. Before storing this 
however, FileManager checks if the file exists and is 
readable (reasonably so, since it needs to 
obtain the last modified timestamp). However, in the case of 
deployment on JBoss and sharing the 
xwork/oscore libs, the file does not exist. JBoss does not 
explode its shared libs, and the file url 
that FileManager obtains looks something like 
/jboss/server/default/lib/webwork-2.0.jar!/webwork-default.xml.

Since this doesn't exist, webwork-default.xml is never added 
to FileManagers references, 
XmlConfigurationProvider.needsReload() always returns true 
and thus every request to the site means 
all the configuration files are reloaded.

Note that this only happens with the include 
file=webwork-default.xml type references in 
xwork.xml, not xwork.xml itself, but XmlConfigurationProvider 
checks all of its referenced files for 
reloading.

I don't whether jboss or xwork/oscore is broken here, but I'd 
appreciate any suggestions.

Thanks,
Craig
Jason Carreira wrote:

It doesn't actually re-parse the configuration XML file every time. 
The ConfigurationManager calls provider.needsReload() on every 
ConfigurationProvider to see if that config provider thinks 
it needs 

to reload (so any custom ConfigurationProvider can 
implement this in 

its own way). The XmlConfigurationProvider, which parses 
xwork.xml or 

any file using that DTD, uses the FileManager from OSCore which I 
wrote (stole from some of Hani's code :-) )... That utility 
maintains 

a reference to the file and checks its timestamp vs. the time stamp 
the last time we read it to see if the file timestamp has changed.

Note that if you set this flag the same check will be done for all 
validation files and conversion property files, although 
not for text 

bundles (complain to Sun, it's their PropertyResourceBundle).

Jason



-Original Message-
From: Craig Raw [mailto:[EMAIL PROTECTED]
Sent: Monday, March 08, 2004 7:37 AM
To: [EMAIL PROTECTED]
Subject: [OS-webwork] XWork, Webwork and reloading xml
Hi,

I have run into issues surrounding xwork and the reloading of
classes using hot deploy. My 
deployment environment is JBoss, where I am sharing the 
webwork/xwork libraries between ears (to 
keep the ear file size down) and using a separate loader 
repository for each ear (to keep the 
configurations separated by classloader namespace).

The problem comes with the flag,
webwork.configuration.xml.reload. When set to false, xwork holds on 
the xwork.xml file (loaded by a classloader) even after a hot 
redeploy. This causes all the classes 
loaded by that classloader to remain accessible as well, and 
the hot redeploy fails in the sense 
that the deployed classes do not change, and neither does the 
xwork configuration. (This would not 
happen if I bundled the xwork/webwork libraries into the 
ear/war, at the cost of a much larger ear 
file size.)

If the flag is true, hot redeploy works fine, but
com.opensymphony.work.config.ConfigurationManager 
reloads xwork.xml on every request to the server.

I would like to be in a situation where I can hot deploy to a
production server, to avoid having to 
drop all the deployments and restart the server just to 
update one. However, I am concerned as to 
the additional load caused by constantly reloading xwork.xml. 
I see that there is a comment in the 
class mentioned above, on line 127:

@todo it currently appears that the reload strategy is to
check on each call to 
getConfiguration().  this seems extremely burdensome.  a 
caching mechanism should be implemented

Is it possible to have the best of both

Re: [OS-webwork] XWork, Webwork and reloading xml

2004-03-09 Thread Craig Raw
Jason Carreira wrote:
Do you know if there's a way to tell if it's in a jar file?
Not reliably, AFAIK. While you could get the CodeSource for a Class, a file is a different matter.

My solution would be even simpler. If a file cannot be read or written, it should not be able to 
change, at least in the normal operation of the VM. Simply excluding such files from a reload check 
would achieve the desired result.

I have attached a small patch against the current oscore CVS to illustrate this.

-craig



-Original Message-
From: Hani Suleiman [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, March 09, 2004 12:40 PM
To: [EMAIL PROTECTED]
Subject: Re: [OS-webwork] XWork, Webwork and reloading xml

In this case I'd say xwork is broken. The solution is for it to not  
bother monitoring files that are in jars.

On Mar 9, 2004, at 11:53 AM, Craig Raw wrote:




---
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id70alloc_id638op=click
___
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork


Index: FileManager.java
===
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 FileManager.java
--- FileManager.java22 May 2003 05:26:34 -  1.1.1.1
+++ FileManager.java10 Mar 2004 07:23:16 -
@@ -20,6 +20,7 @@
 /**
  * FileManager
  * @author Jason Carreira
+ * @author Craig Raw
  * Created May 7, 2003 8:44:26 PM
  */
 public class FileManager {
@@ -51,6 +52,10 @@
 return true;
 }
 
+if (revision.getLastModified() == 0) {
+return false;
+}
+
 return revision.getLastModified()  revision.getFile().lastModified();
 }
 
@@ -84,10 +89,8 @@
 long lastModified = 0;
 
 if (!file.exists() || !file.canRead()) {
-file = null;
-}
-
-if (file != null) {
+files.put(fileName, new FileRevision(file, 0));
+} else {
 lastModified = file.lastModified();
 files.put(fileName, new FileRevision(file, lastModified));
 }