views:

91

answers:

4

I have the following data:

User  System    SubSystem
user1 System1   SubSystem1
user2 System1   SubSystem2
user3 N/A       N/A

and i need to be able to determine the system/subsystem tuple from the user. I must be able to add users at any time without rebuilding and redeploying the system

I know the database would be the best option here but I cannot use a database table.

I currently have it mapped using a hash map but i dont want it to be hard coded. I was think ing about using a properties file but i can't visualize how i would implement it. Anyone else have any suggestions?

Not that it matters but i'm using JAVA, on weblogic 10.3

+3  A: 

You could do this using a HashMap (as you do now) and store it using XStream.

XStream allows you to serialise/deserialise Java objects to/from readable/editable XML. You can then write this to (say) a filesystem, and the result is editable by hand.

The downside is that it's a serialisation in XML of a Java object, so not as immediately obvious as a properties file to edit. However it's still very readable, and easily understood by anyone remotely technical. Whether this is an appropriate solution depends on the audience of this file.

Brian Agnew
storing it in the fylesystem? will the result be editable by hand?
Nuno Furtado
Yes. Edited above for clarification
Brian Agnew
you just gave me the solution for a future project ;) +1
Nuno Furtado
Excellent! Glad to be of help
Brian Agnew
+1  A: 

I would go for something as simple as :

user1 = userValue
user1.system = systemValue
user1.system.subsystem= subsystemValue
user2 = userValue
user2.system = systemValue
user2.system.subsystem= subsystemValue

user(id) is used as "primary" key in your properties, and a very simple concatenation of your fields to store your table values. I use this very often : trust me, it's much more powerfull than it may appear :)

Olivier
i was thinking of a solution in this area, with some little changes to make sure the properties dont go threading into other domains it could be the way i will be going.
Nuno Furtado
Log4J does something similar as well
Michael Rutherfurd
A: 

For this project i've gone with the solution proposed by Olivier. Some project contrainst (legacy of the project) prevent me for going with a probably better solution of using XStream.

Thx for the feed back guys

Nuno Furtado
+2  A: 

Sounds like something you could very well use YAML for..
SnakeYAML looks to be a workable Java implementation.

Tim