[ajug-members] How to read external configuration files inside anEJB jar
Arvindeep.Anchala at alltel.com
Arvindeep.Anchala at alltel.com
Thu Nov 17 10:13:04 EST 2005
Yogesh,
As a pointer, I am giving you a sample of how it is done in a Servlet container. I have not done it for EJBs, but you can probably find a parallel in EJB API.
// Assuming the file to modify is under /xml directory. We do not know where will be the /xml directory be created physically on the server on deployment of the .war
ServletContext context = getServletContext();
java.net.URL url = context.getResource("/xml");
String path = url.getPath();
//pass this 'path' to the application so that it can modify the file
Hope this helps,
Regards,
Arvindeep
-----Original Message-----
From: ajug-members-bounces at ajug.org [mailto:ajug-members-bounces at ajug.org]On Behalf Of Yogesh Bhardwaj
Sent: Thursday, November 17, 2005 9:42 AM
To: ajug-members at ajug.org
Subject: [ajug-members] How to read external configuration files inside anEJB jar
Hello all,
I'm trying to read an external XML configuration file in a bean inside my EJB jar. Initially I placed it inside my EJB project's META-INF and was able to read it doing a
getResourceAsStream(CONFIGURATION_FILENAME)
But just came to know that the client using this application needs to be able to modify this configuration. I certainly would not want them to open up the jar and re-package it. Is there a way I can have the XML inside EAR's META-INF or somewhere at the root level of the EAR package and still read it in my bean? I just needed some suggestions as I have less than an hour to implement this change, before I do it in a down and dirty manner. Really appreciate your help.
Thanks
-yogesh
_____
Yahoo! <http://us.lrd.yahoo.com/_ylc=X3oDMTFqODRtdXQ4BF9TAzMyOTc1MDIEX3MDOTY2ODgxNjkEcG9zAzEEc2VjA21haWwtZm9vdGVyBHNsawNmYw--/SIG=110oav78o/**http%3a//farechase.yahoo.com/> FareChase - Search multiple travel sites in one click.
******************************************************************************************
The information contained in this message, including attachments, may contain
privileged or confidential information that is intended to be delivered only to the
person identified above. If you are not the intended recipient, or the person
responsible for delivering this message to the intended recipient, ALLTEL requests
that you immediately notify the sender and asks that you do not read the message or its
attachments, and that you delete them without copying or sending them to anyone else.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.ajug.org/pipermail/ajug-members/attachments/20051117/43bcbd97/attachment.html
More information about the ajug-members
mailing list