Pergunta

I'm developing an application using Java & MySQL Database, the application is a Desktop Application working in network environment. The Application has some static content that is loaded from the database when starting the application. if the super user made some change for some variables, i need to enforce the network users to restart the application so they can load the new variables.

What idea or code do I need to use?

Foi útil?

Solução

You could implement something like this.

Observer Pattern

Or maybe you can have a "ConfigTable" in your database, with property, value, expiration time.

So, when the admin updates some value, the other applications in the network can pool the new value.

Take a look to JGroups

Regarding the pooling approach, (We don't have enough information to give you the best solution) you could try something like this.

A notification_table with ID, Event (Event is something that you know, maybe load new images, etc)

Workflow

1) The clients pool from this table every X seconds, filtering with ID > lastNotificationId (that needs to be saved in local file) 2) The client applies the new events. 3) The client updates the local file with new notificationId.

Outras dicas

I don't get what do you really need to do. But what I normally do is to tell the user that the changes will only have effect when the application is restarted. After that the user is responsible for restarting the application. If you want to do it automatically you just need to refresh the changed data at the moment they get changed

there are many solutions for that usecase. I would set a timestamp to your object. When the admin changes that object the timestamp will be updated on server side to the current date. After deliver the object to the client, the client has to compare the received object with that one which is currently used on client side. If the timestamp is not equal you can show a warning dialog. If you have the architecture that solution is very easy to implement...

Why don't you store your data in a container where you can overwrite the values? This way you don't have to restart the application, only refresh data on-the-fly.

This way you can redefine the content of a MessageBundle, a Properties, or whatever container object you use to store the data.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top