aspose file tools*
The moose likes Java in General and the fly likes Looking for Java pattern Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Looking for Java pattern" Watch "Looking for Java pattern" New topic
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Looking for Java pattern
 
Similar Threads
Comparator question
Question about Sequence Diagram
Question about Sequence Diagram
Island of Isolation
Associating object with static lookup tables