Imported Upstream version 2.4+dfsg
[shibboleth/sp.git] / shibsp / remoting / impl / ListenerService.cpp
index 600c87f..2b1cd62 100644 (file)
@@ -1,6 +1,6 @@
 /*
- *  Copyright 2001-2007 Internet2
- * 
+ *  Copyright 2001-2010 Internet2
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -16,7 +16,7 @@
 
 /**
  * ListenerService.cpp
- * 
+ *
  * Interprocess remoting engine.
  */
 
@@ -48,9 +48,25 @@ void SHIBSP_API shibsp::registerListenerServices()
 #endif
 }
 
+Remoted::Remoted()
+{
+}
+
+Remoted::~Remoted()
+{
+}
+
+ListenerService::ListenerService()
+{
+}
+
+ListenerService::~ListenerService()
+{
+}
+
 Remoted* ListenerService::regListener(const char* address, Remoted* listener)
 {
-    Remoted* ret=NULL;
+    Remoted* ret=nullptr;
     map<string,Remoted*>::const_iterator i=m_listenerMap.find(address);
     if (i!=m_listenerMap.end())
         ret=i->second;
@@ -76,7 +92,7 @@ bool ListenerService::unregListener(const char* address, Remoted* current, Remot
 Remoted* ListenerService::lookup(const char *address) const
 {
     map<string,Remoted*>::const_iterator i=m_listenerMap.find(address);
-    return (i==m_listenerMap.end()) ? NULL : i->second;
+    return (i==m_listenerMap.end()) ? nullptr : i->second;
 }
 
 void ListenerService::receive(DDF &in, ostream& out)
@@ -84,15 +100,29 @@ void ListenerService::receive(DDF &in, ostream& out)
     if (!in.name())
         throw ListenerException("Incoming message with no destination address rejected.");
     else if (!strcmp("ping",in.name())) {
-        DDF outmsg=DDF(NULL).integer(in.integer() + 1);
+        DDF outmsg=DDF(nullptr).integer(in.integer() + 1);
         DDFJanitor jan(outmsg);
         out << outmsg;
     }
 
-    Locker locker(SPConfig::getConfig().getServiceProvider());
-    Remoted* dest=lookup(in.name());
-    if (!dest)
-        throw ListenerException("No destination registered for incoming message addressed to ($1).",params(1,in.name()));
-    
+    // Two stage lookup, on the listener itself, and the SP interface.
+    ServiceProvider* sp = SPConfig::getConfig().getServiceProvider();
+    Locker locker(sp);
+    Remoted* dest = lookup(in.name());
+    if (!dest) {
+        dest = sp->lookupListener(in.name());
+        if (!dest)
+            throw ListenerException("No destination registered for incoming message addressed to ($1).", params(1,in.name()));
+    }
+
     dest->receive(in, out);
 }
+
+bool ListenerService::init(bool force)
+{
+    return true;
+}
+
+void ListenerService::term()
+{
+}