ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Q: getClass().getResource ?

Post new topic  Reply to topic
 Q: getClass().getResource ? « View previous topic :: View next topic » 
Author Message
lancelotlinc
PostPosted: Tue May 18, 2010 8:10 am    Post subject: Q: getClass().getResource ? Reply with quote

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
View user's profile Send private message Send e-mail
fjb_saper
PostPosted: Sun May 23, 2010 9:15 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
mqmatt
PostPosted: Mon May 24, 2010 8:32 am    Post subject: Reply with quote

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
View user's profile Send private message
lancelotlinc
PostPosted: Tue May 25, 2010 10:08 am    Post subject: Reply with quote

Jedi Knight

Joined: 22 Mar 2010
Posts: 4941
Location: Bloomington, IL USA

That's what I needed! Thanks Matt.
_________________
http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER
Back to top
View user's profile Send private message Send e-mail
lancelotlinc
PostPosted: Thu May 27, 2010 8:29 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
lancelotlinc
PostPosted: Thu May 27, 2010 11:07 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Q: getClass().getResource ?
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.