Discussions

EJB programming & troubleshooting: Global Options

  1. Global Options (1 messages)

    Several ejbs in ears need to access an URL.

    I do not want to hardcode the URL, nor do I want to write it into the ejb deployment descriptor. In practice ejb-jar.xml is as hard to change as source code, because you have to rebuild the ear. And, ejb-jar.xml is in source control, and I don't want to have concrete host names in source control.
    Anyway, I don't want to change five ears because a URL changes.

    First idea is to use a property file and put it in the server classpath. Not very elegant.

    Second idea is to read it from JNDI. But how to get it there? From an XML file parsed by a server startup class? What if the option can be changed at server runtime?

    Next idea is to get the option from JMX and put it from there into JNDI. But how? How is the data specified and read in?

    Or is there a portable way to access JMX from the bean code?

    Thanks,
    Juergen

    Threaded Messages (1)

  2. Global Options[ Go to top ]

    How about a Session Bean? The URL can be stored in a configration table in your database and you just access it like normal. If you need something that can be updated on the fly, the Session Bean could just be a facade for an Entity Bean.