Search code examples
javadesign-patternsobserver-pattern

JAVA Observer multi-IHM


My teacher has a JAVA application composed with a controller that was notifying all the different HMI and I want to reproduce it.

But the HMI and the controller are really independent: he had to launch the controller (with a runnable jar) and then with another runnable Jar he could launch as many HMI that he wants.

One solution could be to use socket programming, but I was wondering if he could use another solution without using distance call. An Observer can only notify an object included in its project, isn’t it?

I want to work “locally”, it’s why I was looking for another solution than the socket programming.


Solution

  • For notification you can use Observer, but since you have separated processes you need distributed Observer or notification concept.

    There are lot options how to implement, one option is to use broker e.g. ActiveMQ and then use topic, so controller produces message to a topic and all HMIs which are listening to that topic will receive that message(will be notified), but you can implement via sockets or RPCs as well.