Exemplo n.º 1
0
        //public TypeConverter TypeConverter {
        //    set {
        //        AssertUtils.ArgumentNotNull(value, "typeConverter must not be null");
        //        _typeConverter = value;
        //    }
        //}

        //public void setBeanClassLoader(ClassLoader beanClassLoader) {
        //    this.beanClassLoader = beanClassLoader;
        //}

        protected override void OnInit()
        {
            lock (_initializationMonitor) {
                if (_initialized)
                {
                    return;
                }
                if (_serviceInterface == null)
                {
                    throw new ArgumentException("'serviceInterface' must not be null");
                }
                MethodInfo[] methods = _serviceInterface.GetMethods();
                foreach (MethodInfo method in methods)
                {
                    IMessagingGateway gateway = CreateGatewayForMethod(method);
                    _gatewayMap.Add(method, gateway);
                }

                ProxyFactory pf = new ProxyFactory(new[] { _serviceInterface });
                pf.AddAdvice(this);
                _serviceProxy = pf.GetProxy();
                Start();
                _initialized = true;
            }
        }
Exemplo n.º 2
0
        private object InvokeGatewayMethod(IMethodInvocation invocation)
        {
            if (!_initialized)
            {
                AfterPropertiesSet();
            }
            MethodInfo        method   = invocation.Method;
            IMessagingGateway gateway  = _gatewayMap[method];
            Type   returnType          = method.ReturnType;
            bool   isReturnTypeMessage = typeof(IMessage).IsAssignableFrom(returnType);
            bool   shouldReply         = returnType != typeof(void);
            int    paramCount          = method.GetParameters().Length;
            object response            = null;

            if (paramCount == 0)
            {
                if (shouldReply)
                {
                    if (isReturnTypeMessage)
                    {
                        return(gateway.Receive());
                    }
                    response = gateway.Receive();
                }
            }
            else
            {
                object[] args = invocation.Arguments;
                if (shouldReply)
                {
                    response = isReturnTypeMessage ? gateway.SendAndReceiveMessage(args) : gateway.SendAndReceive(args);
                }
                else
                {
                    gateway.Send(args);
                    response = null;
                }
            }
            return((response != null) ? TypeConversionUtils.ConvertValueIfNecessary(returnType, response, null) : null);
        }
 public InssAuditMessaging(IMessagingGateway messagingGateway)
 {
     _messagingGateway = messagingGateway;
 }