All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class uhr.core.attract.Matchmaker

java.lang.Object
   |
   +----uhr.core.attract.Matchmaker

public class Matchmaker
extends Object
implements ServiceClient, ServiceHost, ContainerListener, NodeUser, ServiceSource, UF_void
The Matchmaker matches client needs to host offerings using the attractor mechanism. Basically it keeps an up-to-date collection of ServiceItems in its container, and matches then to ServiceNeeds when requested.

Future feature - If a need is unsatisfied, the MatchMaker asks the Inventory to provide a part to satisfy the need. If the Inventory has such a part, it's added to the System Tree and used to satisfy the immediate need. In this manner a few "seed parts" can cause a System Tree to grow in an intelligent but random manner. Randomness occurs when the PartStore has more than one part that can satisfy a need. There may be other future sources of randomness.

Automatic tree growth from seed parts in an interesting case of "smart parts", which express their needs and capabilities. In the right environment, such as this framework, smart parts can relieve the developer of much dedious and defect prone work. Smart part and a good environment can actually exceed what a good developer could do in many cases.

The above implies parts can come from two sources - the PartStore and elsewhere. The "elsewhere" is the System DK. We shall see how actual detailed behavior works out....

My loving wife Martha named this class when I was excitedly explaining attractors to her, and how they were used to match up parts. She said, "The matchmaker could do that." :-) A few months earlier I had see "Fiddler on the Roof" for the first time, and we both really liked the matchmaker in that fabulous tale. Martha had seen the stage version much earlier 3 times. So when you use this class, think of Fiddler....


Constructor Index

 o Matchmaker()

Method Index

 o act()
This uniface is redirected to checkNeeds().
 o checkNeeds()
Checks for needs needing satisfaction.
 o getServiceClientAide()
Returns the aide handling the ServiceClient's attractor work.
 o getServiceHostAide()
Returns the aide handling the ServiceHost's attractor work.
 o nodeAdded(Node, Container)
Called by an event source when a node has been added.
 o processContainerEvent(ContainerEvent)
The listener should process the event any way it sees fit.
 o satisfyInherited(ServiceNeed, boolean)
Satisfies the need using only inherited ServiceHosts.
 o satisfyNeed(ServiceNeed, boolean)
Returns the Object service if the need can be satisfied or null if cannot be satisfied.
 o setMyNode(Node)
Sets the node the part is in.
 o setServiceNeeded(ServiceNeed, Object)
Sets the service provided by a host and identifed by the serviceID.

Constructors

 o Matchmaker
 public Matchmaker()

Methods

 o getServiceClientAide
 public ServiceClientAide getServiceClientAide()
Returns the aide handling the ServiceClient's attractor work. My ServiceNeeds are none. I'm a ServiceClient so that a container has a ServiceClient delegate. In the future I or another part will publish a containers needs.

Returns:
the aide.
 o setServiceNeeded
 public void setServiceNeeded(ServiceNeed need,
                              Object service)
Sets the service provided by a host and identifed by the serviceID.

Parameters:
need - the need that described the service.
service - the attracted service.
 o getServiceHostAide
 public ServiceHostAide getServiceHostAide()
Returns the aide handling the ServiceHost's attractor work. My ServiceItems are:
   Type:      uhr.uniface.UF_void
   ServiceID: uhr.core.attract.CheckClientNeeds
 

Returns:
the aide.
 o processContainerEvent
 public void processContainerEvent(ContainerEvent evt)
The listener should process the event any way it sees fit.

Parameters:
evt - the event that just occurred.
 o setMyNode
 public void setMyNode(Node node)
Sets the node the part is in.

 o satisfyNeed
 public Object satisfyNeed(ServiceNeed need,
                           boolean isNeededNow)
Returns the Object service if the need can be satisfied or null if cannot be satisfied. If this Matchmaker cannot satisfy and is not in the root container, then the parent Matchmaker's satisfyInherited(ServiceNeed) method is called, etc, all they way up to the root of the System Tree. This allows automatic service inheritance, a powerful form of Service Architecture. RECURSIVE.

Note that the clients and host have no knowledge of whether a service in inherited or not. This is an aspect of enshroudment.

Parameters:
need - the need to satisfy.
isNeededNow - true to ignore ServiceNeed.isDeferred() or false to honor ServiceNeed.isDeferred().
Returns:
the service satisfying the need or null if cannot satisfy.
 o act
 public void act()
This uniface is redirected to checkNeeds().

 o nodeAdded
 public void nodeAdded(Node child,
                       Container parent)
Called by an event source when a node has been added.

Parameters:
child - the child node just added.
parent - the parent the node was added to.
 o checkNeeds
 public void checkNeeds()
Checks for needs needing satisfaction. Any ClientNeeds that are unsatisfied and not deferred we attempt to satisfy. First we look in this container for ServiceItem matches. If that fails and we are not in the root, we call satisfyInherited(ServiceNeed) on the parent Matchmaker. This allows inherited services.

Note that after this call some unsatisfed needs may remain.

 o satisfyInherited
 public Object satisfyInherited(ServiceNeed need,
                                boolean isNeededNow)
Satisfies the need using only inherited ServiceHosts. Otherwise this is the same as satisfy(ServiceNeed need) .

Parameters:
need - the need to satisfy.
isNeededNow - true to ignore ServiceNeed.isDeferred() or false to honor ServiceNeed.isDeferred().
Returns:
the service satisfying the need or null if cannot or should not satisfy.

All Packages  Class Hierarchy  This Package  Previous  Next  Index