-
1. Re: How to include a script during deployment phase
peterj Jul 20, 2011 9:25 AM (in response to chogall)Here are a few suggestions.
a) Use a path that contains '/' as directory separators and don't specify a drive letter. For example, if the path is "/data/webapp/config.properties", then that is the exact location used on Linux and on Windows that path is interpreted as being on the current disk drive (for example, at c:\data\webapp\config.properties). I use this mechanism all the time. The nicest thing about it is that it works even if on Windows I am used a different disk drive. For example, on my laptops I have everything on the C: drive but on my desktops I work on either the F: drive or the D: drive. Using a drive-less path lets me use the exact same code/scripts/files on all of my PCs, Windows and LInux, without having to change anything.
b) Define two properties, one for each system. For example, linux.location=xxx and windows.location=yyy. Then in your code determine if you are running Linux or Windows and based on that pick the correct property. I also use this mechanism occasionally. (I know this mechanism isn't a perfect fit for your situation, but perhaps it will spark an idea...)
-
2. Re: How to include a script during deployment phase
chogall Jul 20, 2011 9:57 AM (in response to peterj)Hi Peter,
Thank for your reply!
Basically, the path on windows is C:\temp\blabla and that on linux is /usr/local/lib64.
My XML line was :
<Property name="folder" value="C:\temp\blabla" />
and following what you explained in a), I changed it to :
<Property name="folder" value="/temp/blabla" />
and it works well!
Actually the path on Linux can't be changed, it has to remain /usr/local/lib64. So it means that I should change the one on Windows to C:\usr\local\lib64 as well ? With your solution in a), both should be the same, right ?
Meanwhile, I thought about another possible solution: to include both paths in the value field. Something like:
<Property name="folder" value="C:\temp\blabla;usr/local/lib64" />
I thought it could pick only the path that works but it doesn't. Maybe because this is in a string and that later this value will be inserted in a java program as a String value I guess...
In regards to your solution in b), does XML allow you to have control loops (if-statements) ? or should I use something like XSLT ?
Thank you!
-
3. Re: How to include a script during deployment phase
peterj Jul 20, 2011 11:07 AM (in response to chogall)>>With your solution in a), both should be the same, right ?
Correct, the file should be in the same location on both machines. (All of my Windows machines have an /opt directory for this reason...)
>>I thought it could pick only the path that works but it doesn't.
This could actually work - you code would get both paths which you could then split via String.split() and choose the appropriate value.
Another alternative:
<Property name="win.folder" value="C:\temp\blabla" />
<Property name="linux.folder" value="/usr/local/lib64" />
Then have your code pick the appropriate value based on the OS.
-
4. Re: How to include a script during deployment phase
chogall Jul 20, 2011 11:20 AM (in response to peterj)Ok thank you very much for these tips! Really helped!
-
5. Re: How to include a script during deployment phase
chogall Jul 21, 2011 4:16 AM (in response to peterj)Hi again,
b) Define two properties, one for each system. For example, linux.location=xxx and windows.location=yyy. Then in your code determine if you are running Linux or Windows and based on that pick the correct property. I also use this mechanism occasionally. (I know this mechanism isn't a perfect fit for your situation, but perhaps it will spark an idea...)
Is it possible to test the operating system inside an XML file ? Because it seems it's not possible, am I correct ? Let's say I would like to include a script inside my WAR file (shell script, or even a JAVA file) that would be responsible to test which OS the machine is running on and choose the right "Property". How should I tell JBoss that it should execute that particular script first ? Or is there a better way of doing this ?
Thanks!
-
6. Re: How to include a script during deployment phase
peterj Jul 21, 2011 10:34 AM (in response to chogall)The decision between the two values is done within your Java code. Neither XML nor JBoss AS will do this for you.