'Look through *sink* for handlers named like _handle_component_event.
Use that to build a list of components, and append any components
explicitly specified by *components*.
listen_args is a dict of "component_name"={"arg_name":"arg_value",...},
allowing you to specify additional arguments to addListeners().
When all the referenced components are registered, do the following:
1) Set up all the event listeners
2) Call "_all_dependencies_met" on *sink* if it exists
3) If attrs=True, set attributes on *sink* for each component
(e.g, sink._openflow_ would be set to core.openflow)
For example, if topology is a dependency, a handler for topology\'s
SwitchJoin event must be defined as so:
def _handle_topology_SwitchJoin (self, ...):
*NOTE*: The semantics of this function changed somewhat in the
Summer 2012 milestone, though its intention remains the same.'

def listen_to_dependencies(self, sink, components=None, attrs=True, short_attrs=False, listen_args={}):

    if (components is None):
        components = set()
    elif isinstance(components, basestring):
        components = set([components])
    else:
        components = set(components)
    for c in dir(sink):
        if (not c.startswith('_handle_')):
            continue
        if (c.count('_') < 3):
            continue
        c = '_'.join(c.split('_')[2:(-1)])
        components.add(c)
    if (None in listen_args):
        args = listen_args.pop(None)
        for (k, v) in args.iteritems():
            for c in components:
                if (c not in listen_args):
                    listen_args[c] = {}
                if (k not in listen_args[c]):
                    listen_args[c][k] = v
    if set(listen_args).difference(components):
        log.error(('Specified    listen_args    for    missing    component(s):    %s' % ('    '.join(set(listen_args).difference(components)),)))
    def done(sink, components, attrs, short_attrs):
        if (attrs or short_attrs):
            for c in components:
                if short_attrs:
                    attrname = c
                else:
                    attrname = ('_%s_' % (c,))
                setattr(sink, attrname, getattr(self, c))
        for c in components:
            if hasattr(getattr(self, c), '_eventMixin_events'):
                kwargs = {'prefix': c}
                kwargs.update(listen_args.get(c, {}))
                getattr(self, c).addListeners(sink, **kwargs)
        getattr(sink, '_all_dependencies_met', (lambda : None))()
    self.call_when_ready(done, components, name=sink.__class__.__name__, args=(sink, components, attrs, short_attrs))
    if (not self.starting_up):
        self._waiter_notify()
