3 Replies Latest reply on May 5, 2004 12:22 PM by raja05

    properties from a file

    jan_marien

      Is there an easy way to read some properties from a file.

      maybe you can pass some things within the web.xml or something
      or use something like "getResource()" (used in servlets)


      What shall I use in JBoss, are there any examples with a solution?

        • 1. Re:  properties from a file
          tperrigo

          If these are properties you need to access within an EJB, consider using environment entries in the bean's deployment descriptor. For example, to create an integer property called "foo" with the value of 28 add the following to the ejb-jar.xml file:

          <env-entry>
          <env-entry-name>foo</env-entry-name>
          <env-entry-type>java.lang.Integer</env-entry-type>
          <env-entry-value>28</env-entry-value>
          </env-entry>

          Hope this helps
          Tim

          • 2. Re:  properties from a file
            pjrichter

            How are these entries accessed? Also, what if the same entry also needs to be accessed by a jsp?

            • 3. Re:  properties from a file
              raja05

              Create a Singleton that would be kicked off from a load-on-startup servlet. This wud read a proprties using getResource() and store it as a singleton or jndi if clustered. Once u have it, u can access from ejb, jsp, whatever.
              Ofcourse, this is just one way, there are multitude of patterns available to solve this