I have a requirement for accessing and setting parameters from and to a properties file(complying with java.util.Properties), to customize my EJB logic.
I have the following questions on this issue
1. Can any one please give me solution for setting and getting the attributes and values from the properties file.
2. what should be the structure of the properties file (example key and value pair for each of the attributes.??)
Thanx in advance
Kadekoppa
-
Accessing Properties file inside EJB (7 messages)
- Posted by: KIRAN R KADEKOPPA
- Posted on: December 21 2000 04:43 EST
Threaded Messages (7)
- Accessing Properties file inside EJB by Senthil K on December 21 2000 15:07 EST
- Accessing Properties file inside EJB by Dave Wolf on December 21 2000 15:35 EST
- Accessing Properties file inside EJB by Kiran Patchigolla on December 21 2000 20:35 EST
-
Accessing Properties file inside EJB by Dave Wolf on December 22 2000 12:26 EST
-
Accessing Properties file inside EJB by W Lee on December 22 2000 05:52 EST
- Accessing Properties file inside EJB by Kiran Patchigolla on December 22 2000 12:33 EST
-
Accessing Properties file inside EJB by W Lee on December 22 2000 05:52 EST
-
Accessing Properties file inside EJB by Dave Wolf on December 22 2000 12:26 EST
- Accessing Properties file inside EJB by Kiran Patchigolla on December 21 2000 20:35 EST
- Accessing Properties file inside EJB by aquaregia aquaregia on December 21 2000 21:42 EST
-
Accessing Properties file inside EJB[ Go to top ]
- Posted by: Senthil K
- Posted on: December 21 2000 15:07 EST
- in response to KIRAN R KADEKOPPA
Using java.util.Properties you can write and read property file using store(OutputStream) & load(InputStream) method repectively. Default seperator for key value pair is ASCII = , : and whitespace character, which has to be in single line. Try it out with EJB through helper class since EJB use
to restrict for direct accessing files or directories using java.io package. I didn't try it out with EJB, give reply. -
Accessing Properties file inside EJB[ Go to top ]
- Posted by: Dave Wolf
- Posted on: December 21 2000 15:35 EST
- in response to KIRAN R KADEKOPPA
I would use JNDI environment properties instead of a Properties file.
Dave Wolf
Internet Applications Division
Sybase
-
Accessing Properties file inside EJB[ Go to top ]
- Posted by: Kiran Patchigolla
- Posted on: December 21 2000 20:35 EST
- in response to Dave Wolf
Probably I am wrong but isn't this environment properties file (jndi.properties) only to store the JNDI provider information? Could we store application specific properties in this file and JNDI will load them and bind the key-values pairs under the initial context?
-
Accessing Properties file inside EJB[ Go to top ]
- Posted by: Dave Wolf
- Posted on: December 22 2000 00:26 EST
- in response to Kiran Patchigolla
As of EJB 1.1 you can store any environment variables in the JNDI tree. These are mapped in the deployment descriptor. Think of them like normal property name/value pairs. You can then look them up via JNDI
Boolean flag = (Boolean) ctx.lookup("java:comp/env/use_xa");
Dave Wolf
Internet Applications Division
Sybase
-
Accessing Properties file inside EJB[ Go to top ]
- Posted by: W Lee
- Posted on: December 22 2000 05:52 EST
- in response to Dave Wolf
Most servers allow you to have a startup class (Class that runs when the server starts) You could have the startup class loads up a properties file, and put the information into the JNDI tree. Then the EJB can lookup the initialisation information from there.
William -
Accessing Properties file inside EJB[ Go to top ]
- Posted by: Kiran Patchigolla
- Posted on: December 22 2000 12:33 EST
- in response to W Lee
We evaluated several different options for this purpose. We found that the only portable mechanism that adheres to the spec is using the database to store the properties and bind them to JNDI the first time they are looked up (thanks to Ed Roman, who suggested this option).
Options available include:
1. load the properties file using container start up classes -- container specific (not that it is so bad but trying to get away from container specific code). In fact our code has negligible or no dependency on the container. Of course still needs lot of configuration per container but no code changes..
2. load proeprties from a helper class - (i dont think this should even be a option) -- against the spec
3. design a properties bean that would load up the properties from its environment and bind them to a new subcontext in JNDI ---- i think possible but not clean...
4. using a database to store the properties and bind them to JNDI....
my 2 cents...
kiran.
-
Accessing Properties file inside EJB[ Go to top ]
- Posted by: aquaregia aquaregia
- Posted on: December 21 2000 21:42 EST
- in response to KIRAN R KADEKOPPA
aaaaa