0

i´m currently writing a web-application, which shall fetch some websites, crawl them for information and send these informations to my email.

Now i´m thinking about, how to make the application configurable. I don´t want to set my email-adress in the code.

My thought is, to store a config.xml file in the wildfly standalone/lib folder and then accessing this easily in the code? Would this be possible, or have you nicer solutions?

goblingift
  • 409
  • 4
  • 19
  • Maybe your question is duplicated. Look at [link](http://stackoverflow.com/questions/27953261/wildfly-reading-properties-from-configuration-directory) – Alexander Fedyukov Jun 17 '15 at 06:56
  • What you're asking is possible, but there are A LOT of ways to do it. Take a look at how to read XML, or other types of configuration files in Java. – JNYRanger Jun 18 '15 at 14:57

1 Answers1

0

You can add it to your standalone.xml under <system-properties>

<property name="my.email.address" value="you@something.com"/>

and in your code get it with:

String emailAddress = System.getProperty("my.email.address"); 
KgaboL
  • 130
  • 5
  • Thank you for your answer- this works very well :) But if i want to read a configuration XML-file, which i´ll store on the wildfly, how can i access this? If i would have more than just one parameter, this would be better. – goblingift Jun 17 '15 at 07:28
  • Im not sure I follow what you asking but you can add as many properties as you wish, is not limited to just 1 property, hope that answers you. – KgaboL Jun 17 '15 at 07:35