summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--ryu/base/app_manager.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/ryu/base/app_manager.py b/ryu/base/app_manager.py
index a9895a24..1a2567e2 100644
--- a/ryu/base/app_manager.py
+++ b/ryu/base/app_manager.py
@@ -46,6 +46,7 @@ class RyuApp(object):
Base class for Ryu network application
"""
_CONTEXTS = {}
+ _EVENTS = [] # list of events to be generated in app
@classmethod
def context_iteritems(cls):
@@ -179,11 +180,18 @@ class AppManager(object):
for key, i in SERVICE_BRICKS.items():
for _k, m in inspect.getmembers(i, inspect.ismethod):
if hasattr(m, 'observer'):
+ # name is module name of ev_cls
name = m.observer.split('.')[-1]
if name in SERVICE_BRICKS:
brick = SERVICE_BRICKS[name]
brick.register_observer(m.ev_cls, i.name)
+ # allow RyuApp and Event class are in different module
+ if hasattr(m, 'ev_cls'):
+ for brick in SERVICE_BRICKS.itervalues():
+ if m.ev_cls in brick._EVENTS:
+ brick.register_observer(m.ev_cls, i.name)
+
for brick, i in SERVICE_BRICKS.items():
LOG.debug("BRICK %s" % brick)
for ev_cls, list in i.observers.items():