| Author |
Looking for Java pattern
|
Ahmed Basheer
Ranch Hand
Joined: Apr 15, 2004
Posts: 77
|
|
I have complex issues of relating objects. LifeCycle which I don't have a control over starts my objects. Lets say I have class A, Class B and Class M. I need to make a relationship so that objA and ObjB knows about objM. General design of objects A , B and M is as follows class { start() stop() } and LifeCycle does e.g new A().start(). LifeCycle, and not me, know about these objects but I want to have some mechanism in place so that ObjA routes the calls to ObjM and ObjB also routes calls to objM. ObjB and ObjA don't need to know each other. I can't have ObjM singleton at all, otherwise solution would be simple. Any suggestions are encouraged. -Basheer
|
 |
Stan James
(instanceof Sidekick)
Ranch Hand
Joined: Jan 29, 2003
Posts: 8791
|
|
Here's a little clip from my Messaging Patterns page that might apply ... This is a variation on observable where subscribers sign up with an intermediary to receive messages. The intermediary manages all subscribe and unsubscribe operations, and perhaps maps message types to subscribers. Message originators pass new messages to the intermediary, which then passes them to subscribers. This has some interesting features. Subscriber and publisher life spans are decoupled. A subscriber could exist "permanently" for the life of the application, while publishers are created and destroyed. A subscriber might not be available in real-time. The intermediary could hold messages until the subscriber picks them up later. There can be multiple sources for identical messages. I implemented an abstract intermediary that does the subscribe & unsubscribe parts. Concrete intermediaries implement the publish methods. Here's one:
|
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
|
 |
 |
|
|
subject: Looking for Java pattern
|
|
|