示例#1
0
        public override FutureResponse AsyncRequest(Command command)
        {
            int commandId = GetNextCommandId();

            command.CommandId = commandId;
            command.ResponseRequired = true;
            FutureResponse future = new FutureResponse();
	        Exception priorError = null;
	        lock(requestMap.SyncRoot) 
			{
	            priorError = this.error;
	            if(priorError == null) 
				{
		            requestMap[commandId] = future;
	            }
	        }
	
	        if(priorError != null) 
			{
				BrokerError brError = new BrokerError();
				brError.Message = priorError.Message;
				ExceptionResponse response = new ExceptionResponse();
				response.Exception = brError;
	            future.Response = response;
	            throw priorError;
	        }
			
            next.Oneway(command);

			return future;
        }
 protected void LooseMarshalBrokerError(
     OpenWireFormat wireFormat,
     BrokerError o,
     BinaryWriter dataOut)
 {
     dataOut.Write(o!=null);
     if (o!=null)
     {
         LooseMarshalString(o.ExceptionClass, dataOut);
         LooseMarshalString(o.Message, dataOut);
         if (wireFormat.StackTraceEnabled)
         {
             StackTraceElement[] stackTrace = o.StackTraceElements;
             dataOut.Write((short) stackTrace.Length);
             
             for (int i = 0; i < stackTrace.Length; i++)
             {
                 StackTraceElement element = stackTrace[i];
                 LooseMarshalString(element.ClassName, dataOut);
                 LooseMarshalString(element.MethodName, dataOut);
                 LooseMarshalString(element.FileName, dataOut);
                 dataOut.Write(element.LineNumber);
             }
             LooseMarshalBrokerError(wireFormat, o.Cause, dataOut);
         }
     }
 }
 protected virtual BrokerError LooseUnmarshalBrokerError(
     OpenWireFormat wireFormat,
     BinaryReader dataIn)
 {
     if (dataIn.ReadBoolean())
     {
         BrokerError answer = new BrokerError();
         
         answer.ExceptionClass = LooseUnmarshalString(dataIn);
         answer.Message = LooseUnmarshalString(dataIn);
         if (wireFormat.StackTraceEnabled)
         {
             short length = dataIn.ReadInt16();
             StackTraceElement[] stackTrace = new StackTraceElement[length];
             for (int i = 0; i < stackTrace.Length; i++)
             {
                 StackTraceElement element = new StackTraceElement();
                 element.ClassName = LooseUnmarshalString(dataIn);
                 element.MethodName = LooseUnmarshalString(dataIn);
                 element.FileName = LooseUnmarshalString(dataIn);
                 element.LineNumber = dataIn.ReadInt32();
                 stackTrace[i] = element;
             }
             answer.StackTraceElements = stackTrace;
             answer.Cause = LooseUnmarshalBrokerError(wireFormat, dataIn);
         }
         return answer;
     }
     else
     {
         return null;
     }
 }
 protected void TightMarshalBrokerError2(
     OpenWireFormat wireFormat,
     BrokerError o,
     BinaryWriter dataOut,
     BooleanStream bs)
 {
     if (bs.ReadBoolean())
     {
         TightMarshalString2(o.ExceptionClass, dataOut, bs);
         TightMarshalString2(o.Message, dataOut, bs);
         if (wireFormat.StackTraceEnabled)
         {
             StackTraceElement[] stackTrace = o.StackTraceElements;
             dataOut.Write((short) stackTrace.Length);
             
             for (int i = 0; i < stackTrace.Length; i++)
             {
                 StackTraceElement element = stackTrace[i];
                 TightMarshalString2(element.ClassName, dataOut, bs);
                 TightMarshalString2(element.MethodName, dataOut, bs);
                 TightMarshalString2(element.FileName, dataOut, bs);
                 dataOut.Write(element.LineNumber);
             }
             TightMarshalBrokerError2(wireFormat, o.Cause, dataOut, bs);
         }
     }
 }
 protected int TightMarshalBrokerError1(OpenWireFormat wireFormat, BrokerError o, BooleanStream bs)
 {
     if (o == null)
     {
         bs.WriteBoolean(false);
         return 0;
     }
     else
     {
         int rc = 0;
         bs.WriteBoolean(true);
         rc += TightMarshalString1(o.ExceptionClass, bs);
         rc += TightMarshalString1(o.Message, bs);
         if (wireFormat.StackTraceEnabled)
         {
             rc += 2;
             StackTraceElement[] stackTrace = o.StackTraceElements;
             for (int i = 0; i < stackTrace.Length; i++)
             {
                 StackTraceElement element = stackTrace[i];
                 rc += TightMarshalString1(element.ClassName, bs);
                 rc += TightMarshalString1(element.MethodName, bs);
                 rc += TightMarshalString1(element.FileName, bs);
                 rc += 4;
             }
             rc += TightMarshalBrokerError1(wireFormat, o.Cause, bs);
         }
         
         return rc;
     }
 }
示例#6
0
 /// <summary>
 /// Initializes a new instance of the BrokerException class with serialized data.
 /// Throws System.ArgumentNullException if the info parameter is null.
 /// Throws System.Runtime.Serialization.SerializationException if the class name is null or System.Exception.HResult is zero (0).
 /// </summary>
 /// <param name="info">The SerializationInfo that holds the serialized object data about the exception being thrown.</param>
 /// <param name="context">The StreamingContext that contains contextual information about the source or destination.</param>
 protected BrokerException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
     : base(info, context)
 {
     brokerError = info.GetValue("BrokerException.brokerError", typeof(BrokerError)) as BrokerError;
 }
示例#7
0
        public BrokerException(BrokerError brokerError, Exception innerException)
            : base(brokerError.ExceptionClass + " : " + brokerError.Message + "\n" + StackTraceDump(brokerError.StackTraceElements),
					innerException)
        {
            this.brokerError = brokerError;
        }
示例#8
0
 public BrokerException(BrokerError brokerError)
     : this(brokerError, null)
 {
 }
示例#9
0
		private void Dispose(Exception error)
		{
			ArrayList requests = null;
			
	        lock(requestMap.SyncRoot) 
			{
	            if(this.error == null) 
				{
	                this.error = error;
	                requests = new ArrayList(requestMap.Values);
	                requestMap.Clear();
	            }
	        }
			
	        if(requests != null)
			{
				foreach(FutureResponse future in requests)
				{
					BrokerError brError = new BrokerError();
					brError.Message = error.Message;
					ExceptionResponse response = new ExceptionResponse();
					response.Exception = brError;
		            future.Response = response;
				}
	        }
		}