Question

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 don't want it to be hard-coded. I was thinking about using a properties file but I can't visualize how I would implement it. Anyone else have any suggestion?

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

Was it helpful?

Solution

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 :)

OTHER TIPS

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.

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

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top