Author |
Message
|
lancelotlinc |
Posted: Tue May 18, 2010 8:10 am Post subject: Q: getClass().getResource ? |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
Hi ya,
Created a BAR file, included an xml file I wanted to read via the Broker Archive / bar / Prepare tab.
How to reference the xml file inside JCN?
If BAR were a JAR, we could do this in a JAR file:
URL url = getClass().getResource("Somexmlfilethatiwanttoread.xml");
String urlRef = url.toExternalForm();
urlRef would then hold the explicit path to the file.
However, trying this in a WMB BAR file / JCN, url is null.
So here is the question:
How do you read an xml file that is included in a BAR file as a resource?
TIA _________________ http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER |
|
Back to top |
|
 |
fjb_saper |
Posted: Sun May 23, 2010 9:15 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Expect the bar file to act as a war or ear file and to get exploded upon deployment. So your default root would be where the jar is located and this should be on the classpath... So why not just use get.class().getResource("path in jar to xml file") and see what you get...
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
mqmatt |
Posted: Mon May 24, 2010 8:32 am Post subject: |
|
|
 Grand Master
Joined: 04 Aug 2004 Posts: 1213 Location: Hursley, UK
|
When added to a BAR file, XML files are deployed similar to XSL files. They'll end up on the broker's filesystem under the directory $MQSI_WORKPATH/XML, where $MQSI_WORKPATH is the environment variable that the broker uses to store its configuration.
Use System.getenv() to work out the value of this workpath from within your JavaCompute node, and then navigate through to your XML file. |
|
Back to top |
|
 |
lancelotlinc |
Posted: Tue May 25, 2010 10:08 am Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
|
Back to top |
|
 |
lancelotlinc |
Posted: Thu May 27, 2010 8:29 am Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
Hi Matt,
Ok, using $MQSI_WORKPATH, this is where the XML file gets stored at by the broker at deploy time:
Code: |
C:\Documents and Settings\All Users\Application Data\IBM\MQSI\components\MB7BROKER\0872b3b6-2801-0000-0080-f2b8adcf9c88\config\XML
|
How do I programmatically determine the
Code: |
0872b3b6-2801-0000-0080-f2b8adcf9c88
|
part of this file name? What function call can I make from within a JCN that would give me back this string of characters?
TIA _________________ http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER |
|
Back to top |
|
 |
lancelotlinc |
Posted: Thu May 27, 2010 11:07 am Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
Found it!
Here is the solution:
Code: |
ExecutionGroupProxy e = b.getExecutionGroupByName(this.getExecutionGroup().getName());
String egUuid = e.getProperty("uuid"); // ExecutionGroup UUID.
DeployedObject xfs = e.getDeployedObjectByName("SomexmlfilethatIwanttoread"); // No file extension
if( xfs != null ){
String envMQSIWorkpath = System.getenv("MQSI_WORKPATH");
if( envMQSIWorkpath != null ){
String filename = envMQSIWorkpath+"/components/"+getBroker().getName()+"/"+egUuid+"/config/XML/"+"SomexmlfilethatIwanttoread.xml";
|
Thanks for all the help!
Ciao' _________________ http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER |
|
Back to top |
|
 |
|