Results 1 to 8 of 8
- 01-08-2011, 05:15 PM #1
standard communication protocol among modules
Friends,
I got 2-3 modules in my java project.
UI module creates some events.
Logic module has to collect and take actions based on these events.
FieldEnabler module has to enable-disable fields based on actions chosen by Logic module.
What shall I use to communicate among these modules.
Is there any pattern-based or standard method I can follow?
Any existing framework that I can reuse?
Regards,
PG
- 01-08-2011, 05:18 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,399
- Blog Entries
- 7
- Rep Power
- 17
When people rob a bank they get a penalty; when banks rob people they get a bonus.
- 01-08-2011, 06:18 PM #3
Thanks for reply,
well, I understand that I use Observer pattern here.
I want to know the communication-mechanism that can be used.
What I want to use is a standard communication protocol / framework.
A rough idea I've in mind is I would like a Message having a structure
{ id,
object-it can be either of type boolean / rectangle / button / string / any
}
any java-framework or pattern - matching similar solution?
Regards,
PG
- 01-08-2011, 06:42 PM #4
I am not sure if I've posted the problem correctly.
I want something similar to what light version of SOAP (though not XML based totally) would provide. This I should be able to use within modules of a single program running in single process boundary.
Please help
- 01-08-2011, 06:45 PM #5
Senior Member
- Join Date
- Mar 2009
- Posts
- 552
- Rep Power
- 5
I posted this in the thread you posted in New to Java, but I'll copy it here too. Please don't double-post. It drives us nuts trying to track down what has actually been said. Anyway, here it is:
Its actually a very common design pattern. Usually, what you do is create a listener interface, which is implemented by classes that need to know about events. The class that is being listened to would provide an addXXXListener method, and probably a removeXXXListener method as well, and send the appropriate events to the listeners. The pattern is used by your UI as well, if you're using ActionListener, which I would guess is the case.
Many of my projects now hit at least 5 xxxListener interfaces, just for core UI components to ensure that they update on time.
In your case, as your logic module is running on a different event, you'll want the listener methods to queue events to be handled by the logic thread. However, unless your calculations to decide what to do next can take a long time, I'd suggest getting rid of that extra thread, as it will just complicate your code.
Finally, there is another pattern, as used by Java NIO with its selectors. That one you'll have to look up, as its much more complicated. It only works with multiple threads.If the above doesn't make sense to you, ignore it, but remember it - might be useful!
And if you just randomly taught yourself to program, well... you're just like me!
- 01-08-2011, 07:04 PM #6
Thanks Jos and Boyo
@Boyo: Yes, I've xxxxlistener method used for catching UI events
There are about 20-30 such events that my UI module would generate
Each of these have to work on 'message-id & a reference-object-of-some-type'
So I explored and found something about Proxy classes.
Something really neutral implementation which I can use directly in my program for transferring 'Message-Object (having id&object)' I'm looking for...
- 01-09-2011, 12:38 PM #7
Senior Member
- Join Date
- Jan 2009
- Posts
- 671
- Rep Power
- 5
It would be unusual to use a serialized messaging system (such as SOAP) to communication inside a process. If you want to abstract away the details of the source, then use an interface and have all your calling classes implement it. That's the way events work in Java, and your code will be very odd (aka unmaintainable) if you try to do something different.
- 01-09-2011, 01:39 PM #8
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,399
- Blog Entries
- 7
- Rep Power
- 17
Those listeners don't have to handle the events themselves; they can always delegate the stuff to other methods. Of course you want that delegation done in a more or less uniform way; the event listeners shoudl 'mould' the event in some standard form and pass that around to the other methods.
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
Similar Threads
-
modules in notepad
By joypik in forum New To JavaReplies: 6Last Post: 11-22-2010, 05:47 PM -
how many modules?
By joypik in forum New To JavaReplies: 13Last Post: 08-04-2010, 04:46 AM -
Inventory book store -Modules
By saran87 in forum New To JavaReplies: 2Last Post: 08-24-2009, 02:14 PM -
can you recommand site for java modules - (free)
By itaipee in forum New To JavaReplies: 3Last Post: 01-20-2009, 12:18 PM -
Creating J2ee Modules In NetBeans IDE
By JavaForums in forum NetBeansReplies: 0Last Post: 07-30-2007, 11:13 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks