org.barracudamvc.plankton.srv
Class SimpleServiceFinder

java.lang.Object
  extended by org.barracudamvc.plankton.srv.SimpleServiceFinder
Direct Known Subclasses:
SimpleServiceFinder

public class SimpleServiceFinder
extends Object

Given an EventGateway or Container heirarchy, this class provides a series of utilities to find a service (or a collection of services) by looking for an an instance of a class in a given heirarchy. A "service" is simply defined as an object class signature.

The basic search strategy is to start low and sweep upwards (UPSTREAM). What we do is look through everything in the Gateway/Container object (without diving deeper) and then we go upwards and repeat the process until we find a match or hit a root. This class is capable of searching Maps, Lists, ServiceProviders, and Containers

This class also supports downward searches (DOWNSTREAM). In this case we evaluate children completely based on interface (SimpleServiceProviders first, then Lists, then Maps, and finally Containers). We go downwards and repeat the process until we find a match or run out of children.

The key point of this is that the search strategy is totally separated from the container mechanism: the heirarchy simply provides the vehicle; we can customize the behavior with our particular implementation

TODO: are the classes in this package actually used by anyone? if not, can we just nuke them?


Field Summary
static int DOWNSTREAM
           
protected static org.apache.log4j.Logger logger
           
static int UPSTREAM
           
 
Constructor Summary
SimpleServiceFinder()
           
 
Method Summary
static Object findInstance(Class c, Container cont)
          Find an instance of a Class in a Container heirarchy.
static Object findInstance(Class c, Container cont, int searchDirection)
          Find an instance of a Class in an Container heirarchy
static Object findInstance(Class c, PData pdata)
          Find an instance of a Class in an PData heirarchy.
static Object findInstance(Class c, PData pdata, int searchDirection)
          Find an instance of a Class in an PData heirarchy
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static final org.apache.log4j.Logger logger

UPSTREAM

public static final int UPSTREAM
See Also:
Constant Field Values

DOWNSTREAM

public static final int DOWNSTREAM
See Also:
Constant Field Values
Constructor Detail

SimpleServiceFinder

public SimpleServiceFinder()
Method Detail

findInstance

public static Object findInstance(Class c,
                                  PData pdata)
Find an instance of a Class in an PData heirarchy. Search direction defaults to UPSTREAM

Parameters:
c - the class we're looking for
pdata - the entry point to the PData heirarchy
Returns:
the first instance of the specified class

findInstance

public static Object findInstance(Class c,
                                  PData pdata,
                                  int searchDirection)
Find an instance of a Class in an PData heirarchy

Parameters:
c - the class we're looking for
pdata - the entry point to the PData heirarchy
searchDirection - the search direction
Returns:
the first instance of the specified class

findInstance

public static Object findInstance(Class c,
                                  Container cont)
Find an instance of a Class in a Container heirarchy. Search direction defaults to UPSTREAM

Parameters:
c - the class we're looking for
cont - the entry point to the Container heirarchy
Returns:
the first instance of the specified class

findInstance

public static Object findInstance(Class c,
                                  Container cont,
                                  int searchDirection)
Find an instance of a Class in an Container heirarchy

Parameters:
c - the class we're looking for
cont - the entry point to the Container heirarchy
searchDirection - the search direction
Returns:
the first instance of the specified class


Copyright © 2006 BarracudaMVC.org All Rights Reserved.