5

For the configuration of our applications we want to place some of the configuration in the application server.

We are currently using the WebSphere JNDI facility for looking up urls and datasources.

In addition we want to place simple Strings in the application server. We don't want to use the WebSphere "Enviroment variables".

Can the "Resource Environment" be used for such a purpose? If so, how can it be used?

We'd like to get the Strings with:

InitialContext ctx = new InitalContext();
String myString = (String)ctx.lookup("jndi/string/myString");

Are there any more simple alternatives?

We are using WebSphere Application Server 7.

Udo Held
  • 12,314
  • 11
  • 67
  • 93

2 Answers2

7

Take a look at the article Using resource environment providers in WebSphere Application Server

It's written for WebSphere 5 or 6 but the idea should work for version 7 too. Basically you create a custom resource environment provider, which returns objects of your own type via a factory. The factory implements javax.naming.spi.ObjectFactory and gets its input from Websphere.

In my opinion this is a nice solution if you have a few configuration parameters but it can quickly become hard to maintain as the number of parameters grows.

Danubian Sailor
  • 1
  • 38
  • 145
  • 223
DagR
  • 2,900
  • 3
  • 24
  • 36
  • This is definiately the clean way. However looking at the long guide I'm probably going for the "hack" name space bindings. Thanks! – Udo Held Nov 25 '11 at 09:24
  • 3
    I can only agree. It's a quite cumbersome way of getting a simple name/value pair into WebSphere JNDI. No one should be surprised how hard it is doing simple stuff in WAS. – DagR Nov 25 '11 at 10:56
7

I believe you can use Name Space Bindings for this (under Environment, Naming, Name Space Bindings.)

Blurb:

Name Space Bindings

Use this page to configure a name binding of a constant string value, an enterprise bean, a CORBA CosNaming Naming Context or CORBA leaf node object, or an object that can be looked up by using JNDI.

Community
  • 1
  • 1
McDowell
  • 107,573
  • 31
  • 204
  • 267
  • Its a kind of "hack" and one is limited to the "cell/persistent/" prefix, but it works without major configuration. Thanks! – Udo Held Nov 25 '11 at 09:25
  • 4
    If you create these bindings at the server or cluster scope, you don't need to use the qualified prefix to look them up. – shelley Nov 25 '11 at 17:39
  • Any links to IBM info center are dying they must have re-org'ed their site. – escape-llc Aug 08 '18 at 12:38