/// <summary> /// This will build a proxy for the interface representing the gateway and register the /// proxy instance in the container based on the definition. /// </summary> /// <param name="container"><seealso cref="IContainer"/></param> /// <param name="gatewayDefinition">Definition of the gateway</param> public void BuildProxy(IObjectBuilder container, IGatewayDefinition gatewayDefinition) { var methodInterceptor = new GatewayMethodInterceptor(container, gatewayDefinition); var gatewayInstance = container.Resolve<IReflection>().GetTypeForNamedInstance(gatewayDefinition.Contract); var proxy = BuildFor(gatewayInstance, methodInterceptor); container.Register(gatewayDefinition.Id, gatewayInstance, proxy); }
public void ForwardMessage(IGatewayDefinition definition, object message) { // find the output adapter that will accept the message: var adapterRegistry = _builder.Resolve<IAdapterRegistry>(); AbstractOutputChannelAdapter outputChannelAdapter = null; try { outputChannelAdapter = (from adapter in adapterRegistry.OutputAdapters where adapter.ChannelName.Trim().ToLower() == definition.RequestChannel.Trim().ToLower() select adapter).First(); } catch { } // HACK: See why this is not working correctly, I think the messages must be put onto an adapter from the gateway var envelope = new Envelope(message); if (outputChannelAdapter != null) outputChannelAdapter.Send(envelope); else { var target = _builder.Resolve<IChannelRegistry>().FindChannel(definition.RequestChannel); target.Send(envelope); } }
private void ForwardToChannel(IGatewayDefinition definition, object[] arguments) { var requestChannel = m_container.Resolve<IChannelRegistry>().FindChannel(definition.RequestChannel); if ((requestChannel is NullChannel)) return; var forwarder = m_container.Resolve<IGatewayMessageForwarder>(); forwarder.ForwardMessage(definition, arguments[0]); }
/// <summary> /// .ctor /// </summary> /// <param name="container"></param> /// <param name="gatewayDefinition"></param> public GatewayMethodInterceptor(IObjectBuilder container, IGatewayDefinition gatewayDefinition) { m_container = container; m_gateway_definition = gatewayDefinition; }