public object ProcessMessage(IInterDomainMessage message) { object ret = null; RoutedInterDomainMessage ridm = (RoutedInterDomainMessage)message; lock (_handlers) { foreach (sRoute srt in ridm.HandlerRoutes) { if (_handlers.ContainsKey(srt)) { foreach (IInterDomainMessageHandler idmh in _handlers[srt]) { try { ret = idmh.ProcessMessage(ridm); break; } catch (Exception e) { System.Error(e); ret = null; } } if (ret != null) { break; } } } } return(ret); }
public RoutedInterDomainMessage(RoutedInterDomainMessage ridm, IInterDomainMessage message) { _handlerRoutes = ridm._handlerRoutes; _preInterceptRoutes = ridm._preInterceptRoutes; _postInterceptRoutes = ridm._postInterceptRoutes; _message = message; }
public bool HandlesMessage(IInterDomainMessage message) { RoutedInterDomainMessage ridm = (RoutedInterDomainMessage)message; bool ret = false; lock (_myRoutes) { foreach (sRoute srt in ridm.HandlerRoutes) { if (_myRoutes.Contains(srt)) { ret = true; break; } } } if (!ret) { lock (_subRoutes) { foreach (sRoute srt in ridm.HandlerRoutes) { if (_subRoutes.ContainsKey(srt)) { ret = true; break; } } } } return(ret); }
public RoutedInterDomainMessage(IInterDomainMessage message) { _message = message; _handlerRoutes = new List <sRoute>(); foreach (AllowedRequestHandler arh in message.GetType().GetCustomAttributes(typeof(AllowedRequestHandler), true)) { _handlerRoutes.Add(new sRoute(arh.DomainName, arh.HandlerTypeFullName, message.Name)); } if (_handlerRoutes.Count == 0) { _handlerRoutes.Add(new sRoute(null, null, message.Name)); } bool addPreIntercepts = true; bool addPostIntercepts = true; foreach (BlockRequestIntercept bri in message.GetType().GetCustomAttributes(typeof(BlockRequestIntercept), true)) { switch (bri.Direction) { case InterceptDirections.Both: addPostIntercepts = false; addPreIntercepts = false; break; case InterceptDirections.Post: addPostIntercepts = false; break; case InterceptDirections.Pre: addPreIntercepts = false; break; } } _preInterceptRoutes = new List <sRoute>(); _postInterceptRoutes = new List <sRoute>(); foreach (AllowedRequestIntercept ari in message.GetType().GetCustomAttributes(typeof(AllowedRequestIntercept), true)) { if ((ari.Direction == InterceptDirections.Both || ari.Direction == InterceptDirections.Pre) && addPreIntercepts) { _preInterceptRoutes.Add(new sRoute(ari.DomainName, ari.HandlerTypeFullName, message.Name)); } if ((ari.Direction == InterceptDirections.Both || ari.Direction == InterceptDirections.Post) && addPostIntercepts) { _postInterceptRoutes.Add(new sRoute(ari.DomainName, ari.HandlerTypeFullName, message.Name)); } } if (_preInterceptRoutes.Count == 0 && addPreIntercepts) { _preInterceptRoutes.Add(new sRoute(null, null, message.Name)); } if (_postInterceptRoutes.Count == 0 && addPostIntercepts) { _postInterceptRoutes.Add(new sRoute(null, null, message.Name)); } }
public IInterDomainMessage InterceptMessage(IInterDomainMessage message) { IInterDomainMessage ret = message; RoutedInterDomainMessage ridm = (RoutedInterDomainMessage)message; List <Core> subCores = new List <Core>(); lock (_myRoutes) { foreach (sRoute srt in ridm.PreInterceptRoutes) { if (_myRoutes.Contains(srt)) { if (_messageController.InterceptsMessage(ridm)) { subCores.Add(this); } break; } } } lock (_subRoutes) { foreach (sRoute srt in ridm.PreInterceptRoutes) { if (_subRoutes.ContainsKey(srt)) { foreach (Core cr in _subRoutes[srt]) { if (!subCores.Contains(cr)) { subCores.Add(cr); } } } } } foreach (Core cr in subCores) { try { ret = cr.InterceptMessage(ret); } catch (Exception e) { } } return(ret); }
public bool HandlesMessage(IInterDomainMessage message) { bool ret = false; RoutedInterDomainMessage ridm = (RoutedInterDomainMessage)message; lock (_handlers) { foreach (sRoute srt in ridm.HandlerRoutes) { if (_handlers.ContainsKey(srt)) { ret = true; break; } } } return ret; }
public InterDomainMessageResponse ProcessMessage(IInterDomainMessage message) { InterDomainMessageResponse ret = null; RoutedInterDomainMessage ridm = (RoutedInterDomainMessage)message; lock (_myRoutes) { foreach (sRoute srt in ridm.HandlerRoutes) { if (_myRoutes.Contains(srt)) { if (_messageController.HandlesMessage(ridm)) { ret = new InterDomainMessageResponse(ridm, _messageController.ProcessMessage(ridm)); break; } } } } if (ret == null) { lock (_subRoutes) { foreach (sRoute srt in ridm.HandlerRoutes) { if (_subRoutes.ContainsKey(srt)) { foreach (Core cr in _subRoutes[srt]) { if (cr.HandlesMessage(ridm)) { ret = cr.ProcessMessage(ridm); break; } } if (ret != null) { break; } } } } } return(ret); }
public bool InterceptsMessage(IInterDomainMessage message) { bool ret = false; RoutedInterDomainMessage ridm = (RoutedInterDomainMessage)message; lock (_preRequestors) { foreach (sRoute srt in ridm.PreInterceptRoutes) { if (_preRequestors.ContainsKey(srt)) { ret = true; break; } } } return(ret); }
public IInterDomainMessage InterceptMessage(IInterDomainMessage message) { IInterDomainMessage ret = message; RoutedInterDomainMessage ridm = (RoutedInterDomainMessage)message; lock (_preRequestors) { foreach (sRoute srt in ridm.PreInterceptRoutes) { if (_preRequestors.ContainsKey(srt)) { foreach (IInterDomainMessagePreRequestInterceptor iidmpri in _preRequestors[srt]) ret = iidmpri.InterceptMessage(ret); break; } } } return new RoutedInterDomainMessage(ridm,ret); }
public static InterDomainMessageResponse ProcessInterDomainMessage(IInterDomainMessage message) { DateTime start = DateTime.Now; message = new RoutedInterDomainMessage(message); message = _core.AbsoluteParent.InterceptMessage(message); Debug("Time to intercept interdomain message {0}:{1}ms", message.Name, DateTime.Now.Subtract(start).TotalMilliseconds); start = DateTime.Now; InterDomainMessageResponse ret = _core.AbsoluteParent.ProcessMessage(message); Debug("Time to handle interdomain message {0}:{1}ms", message.Name, DateTime.Now.Subtract(start).TotalMilliseconds); start = DateTime.Now; if (ret != null) { _core.AbsoluteParent.InterceptResponse(ref ret); Debug("Time to intercept interdomain response {0}:{1}ms", message.Name, DateTime.Now.Subtract(start).TotalMilliseconds); } return(ret); }
public IInterDomainMessage InterceptMessage(IInterDomainMessage message) { IInterDomainMessage ret = message; RoutedInterDomainMessage ridm = (RoutedInterDomainMessage)message; lock (_preRequestors) { foreach (sRoute srt in ridm.PreInterceptRoutes) { if (_preRequestors.ContainsKey(srt)) { foreach (IInterDomainMessagePreRequestInterceptor iidmpri in _preRequestors[srt]) { ret = iidmpri.InterceptMessage(ret); } break; } } } return(new RoutedInterDomainMessage(ridm, ret)); }
public RoutedInterDomainMessage(IInterDomainMessage message) { _message = message; _handlerRoutes = new List<sRoute>(); foreach (AllowedRequestHandler arh in message.GetType().GetCustomAttributes(typeof(AllowedRequestHandler), true)) _handlerRoutes.Add(new sRoute(arh.DomainName, arh.HandlerTypeFullName,message.Name)); if (_handlerRoutes.Count == 0) _handlerRoutes.Add(new sRoute(null, null,message.Name)); bool addPreIntercepts = true; bool addPostIntercepts = true; foreach (BlockRequestIntercept bri in message.GetType().GetCustomAttributes(typeof(BlockRequestIntercept),true)) { switch (bri.Direction) { case InterceptDirections.Both: addPostIntercepts = false; addPreIntercepts = false; break; case InterceptDirections.Post: addPostIntercepts = false; break; case InterceptDirections.Pre: addPreIntercepts = false; break; } } _preInterceptRoutes = new List<sRoute>(); _postInterceptRoutes = new List<sRoute>(); foreach (AllowedRequestIntercept ari in message.GetType().GetCustomAttributes(typeof(AllowedRequestIntercept), true)) { if ((ari.Direction == InterceptDirections.Both || ari.Direction == InterceptDirections.Pre) && addPreIntercepts) _preInterceptRoutes.Add(new sRoute(ari.DomainName, ari.HandlerTypeFullName,message.Name)); if ((ari.Direction == InterceptDirections.Both || ari.Direction == InterceptDirections.Post) && addPostIntercepts) _postInterceptRoutes.Add(new sRoute(ari.DomainName, ari.HandlerTypeFullName, message.Name)); } if (_preInterceptRoutes.Count == 0 && addPreIntercepts) _preInterceptRoutes.Add(new sRoute(null, null, message.Name)); if (_postInterceptRoutes.Count == 0 && addPostIntercepts) _postInterceptRoutes.Add(new sRoute(null, null, message.Name)); }
internal InterDomainMessageResponse(IInterDomainMessage message, object response) { _message = message; _response = response; _interceptors = new List <sInterceptor>(); }
public InterDomainMessageResponse ProcessMessage(IInterDomainMessage message) { InterDomainMessageResponse ret = null; RoutedInterDomainMessage ridm = (RoutedInterDomainMessage)message; lock (_myRoutes) { foreach (sRoute srt in ridm.HandlerRoutes) { if (_myRoutes.Contains(srt)) { if (_messageController.HandlesMessage(ridm)) { ret = new InterDomainMessageResponse(ridm, _messageController.ProcessMessage(ridm)); break; } } } } if (ret == null) { lock (_subRoutes) { foreach (sRoute srt in ridm.HandlerRoutes) { if (_subRoutes.ContainsKey(srt)) { foreach (Core cr in _subRoutes[srt]) { if (cr.HandlesMessage(ridm)) { ret = cr.ProcessMessage(ridm); break; } } if (ret != null) break; } } } } return ret; }
public IInterDomainMessage InterceptMessage(IInterDomainMessage message) { IInterDomainMessage ret = message; RoutedInterDomainMessage ridm = (RoutedInterDomainMessage)message; List<Core> subCores = new List<Core>(); lock (_myRoutes) { foreach (sRoute srt in ridm.PreInterceptRoutes) { if (_myRoutes.Contains(srt)) { if (_messageController.InterceptsMessage(ridm)) subCores.Add(this); break; } } } lock (_subRoutes) { foreach (sRoute srt in ridm.PreInterceptRoutes) { if (_subRoutes.ContainsKey(srt)) { foreach (Core cr in _subRoutes[srt]) { if (!subCores.Contains(cr)) subCores.Add(cr); } } } } foreach (Core cr in subCores) { try { ret = cr.InterceptMessage(ret); } catch (Exception e) { } } return ret; }
public static InterDomainMessageResponse ProcessInterDomainMessage(IInterDomainMessage message) { DateTime start = DateTime.Now; message = new RoutedInterDomainMessage(message); message = _core.AbsoluteParent.InterceptMessage(message); Debug("Time to intercept interdomain message {0}:{1}ms", message.Name, DateTime.Now.Subtract(start).TotalMilliseconds); start = DateTime.Now; InterDomainMessageResponse ret = _core.AbsoluteParent.ProcessMessage(message); Debug("Time to handle interdomain message {0}:{1}ms", message.Name, DateTime.Now.Subtract(start).TotalMilliseconds); start = DateTime.Now; if (ret != null) { _core.AbsoluteParent.InterceptResponse(ref ret); Debug("Time to intercept interdomain response {0}:{1}ms", message.Name, DateTime.Now.Subtract(start).TotalMilliseconds); } return ret; }
internal InterDomainMessageResponse(IInterDomainMessage message, object response) { _message = message; _response = response; _interceptors = new List<sInterceptor>(); }
public bool InterceptsMessage(IInterDomainMessage message) { bool ret = false; RoutedInterDomainMessage ridm = (RoutedInterDomainMessage)message; lock (_preRequestors) { foreach (sRoute srt in ridm.PreInterceptRoutes) { if (_preRequestors.ContainsKey(srt)) { ret = true; break; } } } return ret; }
public object ProcessMessage(IInterDomainMessage message) { object ret = null; RoutedInterDomainMessage ridm = (RoutedInterDomainMessage)message; lock (_handlers) { foreach (sRoute srt in ridm.HandlerRoutes) { if (_handlers.ContainsKey(srt)) { foreach (IInterDomainMessageHandler idmh in _handlers[srt]) { try { ret = idmh.ProcessMessage(ridm); break; } catch (Exception e) { System.Error(e); ret = null; } } if (ret != null) { break; } } } } return ret; }