Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

mutliple use application  RSS feed

 
Gary Down
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The setting...

I have writen a stand alone applcation which is controlled by a single top-level class.
This class controls a series of panels where the user can make selections/enter data etc..

Much of the input/output from different panels depends upon input from other panels.
To fascilitate this all common data used is kept in a single class containing
"private static" fields, all accessed via "public static" functions.
This class is never (by code) instantiated as all fields and functions are static.
Also, the data can not be "final" as it changes according to user input.

All this works fine when a single user runs the application.

The question...

What would be the approach to allow a second/multiple user to run the application
and have access to the same static data.


Thanks,
Gary.
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if i understood you right you do persist your data.
In this case all you have to do is change the name of the database user...
 
Eddie Vanda
Ranch Hand
Posts: 283
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All the arguments you use to justify static fields in your common class could be reversed to say that taking away the static keywords and each user getting a "new" copy of your common class would fix the problem, assuming that all this data is separate for each user and only valid for the current session.

However, if you want your data shared by different users, you would need to synchronize the data class so that the data gets updated by the different users.

It could be that you are talking about a server. If the server is running a db, then you would use a "new" copy of the data class for each user and let the db worry about the synchronization.
[ July 03, 2004: Message edited by: Eddie Vanda ]
 
Gary Down
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Firstly,
an aplogy. When I posted this I then thoughy it would be better in the beginners form so I posted it there too.. I nade a note on that thread but forgot to make a note here.

if i understood you right you do persist your data.
In this case all you have to do is change the name of the database user...


Miguel,
sorry but I don't understand what "persist your data" means.


However, if you want your data shared by different users, you would need to synchronize the data class so that the data gets updated by the different users.

It could be that you are talking about a server. If the server is running a db, then you would use a "new" copy of the data class for each user and let the db worry about the synchronization.


Yes the data is to be shared not as a new copy for each user. How do I synchronise a class in this usage?

The replies in the other thread seem to point to using RMI. As you have also suggeted this I will look into that.

Thanks both of you,
Gary.
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
persisting data means saving it (usually) to a database
 
Gary Down
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have changed my application to use RMI.... not too difficult.

For a single user it works fine.


The first reference (to any function/variable in the class) from each transaction produces -

"WBR - setting english words true"
"WBR - setting english words false"

indicating the "static Set allEnglshWords" is not populated for the second/subsequent transaction.

Is it possible to have a second/third.. user start a new application and access the static Sets or is it that "tatic" variables are only "class" variables within a single trnsaction?


I have gotten a bit confusd here. I thought "static" variables were "class" variables and the same for all users/transactions.

I know I can get a similar effect by applying all updates to the database and then re-reading but I would prefer (due to user requirments) not to. If I have to it isn't a big deal.

Hope I've made myself clear,
Thanks,
Gary.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!