public static IServiceCollection AddStreamListener(this IServiceCollection services, MethodInfo method, string target, string condition = null, bool copyHeaders = true) { if (services == null) { throw new ArgumentNullException(nameof(services)); } var attribute = new StreamListenerAttribute(target, condition, copyHeaders); services.AddStreamListener(method, attribute); return(services); }
public override void OrchestrateStreamListener(StreamListenerAttribute streamListener, MethodInfo method, Type implementation) { var methodAnnotatedInboundName = streamListener.Target; var streamListenerMethod = new StreamListenerMethodValidator(method, _context, _streamListenerParameterAdapters); streamListenerMethod.Validate(methodAnnotatedInboundName, streamListener.Condition); var isDeclarative = streamListenerMethod.CheckDeclarativeMethod(methodAnnotatedInboundName); if (isDeclarative) { var methodAnnotatedOutboundName = streamListenerMethod.GetOutboundBindingTargetName(); var adaptedInboundArguments = AdaptAndRetrieveInboundArguments(method, methodAnnotatedInboundName, _streamListenerParameterAdapters.ToArray()); InvokeStreamListenerResultAdapter(method, implementation, methodAnnotatedOutboundName, adaptedInboundArguments); } else { RegisterHandlerMethodOnListenedChannel(streamListenerMethod, streamListener, implementation); } }
public abstract void OrchestrateStreamListener(StreamListenerAttribute streamListener, MethodInfo method, Type bean);
protected virtual StreamListenerAttribute PostProcessAttribute(StreamListenerAttribute attribute) { return(attribute); }
public StreamListenerMethod(MethodInfo method, StreamListenerAttribute attribute) { Method = method; Attribute = attribute; }
private void RegisterHandlerMethodOnListenedChannel(StreamListenerMethodValidator streamListenerMethod, StreamListenerAttribute streamListener, Type implementation) { if (string.IsNullOrEmpty(streamListener.Target)) { throw new ArgumentException("The binding target name cannot be null"); } var method = streamListenerMethod.Method; var defaultOutputChannel = streamListenerMethod.GetOutboundBindingTargetName(); if (typeof(void).Equals(method.ReturnType)) { if (!string.IsNullOrEmpty(defaultOutputChannel)) { throw new ArgumentException("An output channel cannot be specified for a method that does not return a value"); } } else { if (string.IsNullOrEmpty(defaultOutputChannel)) { throw new ArgumentException("An output channel must be specified for a method that can return a value"); } } streamListenerMethod.ValidateStreamListenerMessageHandler(); _processor.AddMappedListenerMethod(streamListener.Target, new StreamListenerHandlerMethodMapping(implementation, method, streamListener.Condition, defaultOutputChannel, streamListener.CopyHeaders)); }
public static IServiceCollection AddStreamListener(this IServiceCollection services, MethodInfo method, StreamListenerAttribute attribute) { var streamListenerMethod = new StreamListenerMethodValidator(method); streamListenerMethod.Validate(attribute.Target, attribute.Condition); services.AddSingleton <IStreamListenerMethod>(new StreamListenerMethod(method, attribute)); return(services); }