Esempio n. 1
0
 public AdapterConfiguration(string adapterName, string gatewayName, string adapterTypeName)
 {
     AdapterName = adapterName;
     GatewayName = gatewayName;
     AdapterTypeName = adapterTypeName;
     Configuration = new SerializableXDocument(XDocument.Parse("<objectConfig />"));
 }
Esempio n. 2
0
 public AdapterConfiguration(string adapterName, string gatewayName, string adapterTypeName, XDocument config)
 {
     AdapterName = adapterName;
     GatewayName = gatewayName;
     AdapterTypeName = adapterTypeName;
     if (config == null)
     {
         throw new ArgumentNullException("config");
     }
     if (config.Root.Name != XName.Get("objectConfig")) {
         throw new ArgumentException("config");
     }
     Configuration = new SerializableXDocument(config);
 }
Esempio n. 3
0
 public void AddMessageToToken(string updatingProcessorName, Token targetToken,
     string messageName, SerializableXDocument message)
 {
     lock (syncLock)
     {
         storage.UpdateToken(targetToken, delegate(Token token)
         {
             MessageFlowState messageflowState = token.GetMessageFlowState();
             if (messageflowState.AssignedProcessor == updatingProcessorName)
             {
                 token.UpdateMessageFlowState(mfs => { mfs.LastResponseFromProcessor = DateTime.Now; });
                 token.AddMessage(messageName, message);
             }
         });
     }
 }
 public ApplicationConfiguration(XDocument content)
 {
     Content = new SerializableXDocument(content);
 }
Esempio n. 5
0
        public SerializableXDocument SendMessage(EndpointAddress address, SerializableXDocument message, SerializableXDocument metadata)
        {
            if (!AdaptersByName.ContainsKey(address.AdapterName)) {
                throw new ArgumentException(string.Format(
                    "There is no adapter named '{0}' in gateway '{1}'.",
                    address.AdapterName, Name), "address");
            }

            Adapter adapter = AdaptersByName[address.AdapterName];
            XDocument result = adapter.SendMessage(address.EndpointName, message.XDocument, metadata.XDocument);
            return new SerializableXDocument(result);
        }
Esempio n. 6
0
 public void ReceiveReturn(Guid tokenGuid, SerializableXDocument resultMessage, SerializableXDocument sourceMetadata)
 {
     ResultHandlingInfo resultHandlingInfo;
     if (waitingResultMessageHandlers.TryRemove(tokenGuid, out resultHandlingInfo))
     {
         resultHandlingInfo.ResultHandler(tokenGuid, resultMessage.XDocument, sourceMetadata.XDocument, resultHandlingInfo.Context);
     }
 }
Esempio n. 7
0
        public void FinishToken(string updatingProcessorName, Token targetToken,
            SerializableXDocument resultMessage)
        {
            lock (syncLock)
            {
                MessageFlowState messageflowState = targetToken.GetMessageFlowState();
                if (messageflowState.AssignedProcessor == updatingProcessorName)
                {
                    storage.UpdateToken(targetToken, delegate(Token token)
                    {
                        token.UpdateMessageFlowState(mfs => { mfs.LastResponseFromProcessor = DateTime.Now; });
                    });

                    XDocument sourceMetadata = targetToken.GetSourceMetadata();
                    var sourceAdress = targetToken.GetSourceAddress();
                    if (sourceAdress != null)
                    {
                        string sourceGatewayName = sourceAdress.GatewayName;
                        GatewayAccessor sourceGateway = componentsAccessors.Values.OfType<GatewayAccessor>().SingleOrDefault(gwa => gwa.ComponentName == sourceGatewayName);
                        sourceGateway.ReceiveReturn(targetToken.Guid, resultMessage, new SerializableXDocument(sourceMetadata));
                    }

                    storage.UpdateToken(targetToken, delegate(Token token)
                    {
                        token.State = TokenState.Finished;
                    });
                }
            }
        }
Esempio n. 8
0
 public SerializableXDocument SendMessageToOutputEndPoint(EndpointAddress address, SerializableXDocument message, SerializableXDocument metadata)
 {
     SerializableXDocument result = gateway.SendMessage(address, message, metadata);
     return result;
 }
Esempio n. 9
0
 public SerializableXDocument SendMessage(EndpointAddress address, SerializableXDocument message, SerializableXDocument metadata)
 {
     ComponentAccessor component;
     if (componentsAccessors.TryGetValue(address.GatewayName, out component))
     {
         if (component is GatewayAccessor)
         {
             GatewayAccessor gateway = (GatewayAccessor)component;
             SerializableXDocument result = gateway.SendMessageToOutputEndPoint(address, message, metadata);
             return result;
         }
     }
     throw new ArgumentException(string.Format(
         "Cannot find target gateway of endpoint address '{0}'.", address));
 }
Esempio n. 10
0
 public void ReceiveReturn(Guid tokenGuid, SerializableXDocument resultMessage, SerializableXDocument sourceMetadata)
 {
     gateway.ReceiveReturn(tokenGuid, resultMessage, sourceMetadata);
 }
Esempio n. 11
0
 /// <summary>
 /// Creates a new instance of Token from given content and GUID.
 /// </summary>
 /// <param name="guid">token GUID; replaces any GUID in contentXml</param>
 /// <param name="contentXml">initial token content</param>
 public Token(Guid guid, string contentXml)
 {
     Guid = guid;
     Content = new SerializableXDocument(XDocument.Parse(contentXml));
     Content.XDocument.Root.SetAttributeValue(XName.Get("guid"), guid.ToString());
 }
Esempio n. 12
0
 /// <summary>
 /// Creates a new instance of Token from given content including a
 /// GUID.
 /// </summary>
 /// <param name="contentXml">initial token content</param>
 public Token(string contentXml)
 {
     Content = new SerializableXDocument(XDocument.Parse(contentXml));
     Guid = Guid.Parse(Content.XDocument.Root.Attribute(XName.Get("guid")).Value);
 }
Esempio n. 13
0
 /// <summary>
 /// Replaces the whole XML content of the token with a new one.
 /// </summary>
 /// <remarks>
 /// <para>
 /// This can be useful for updating the token without
 /// creating a new instance.
 /// </para>
 /// <para>NOTE: It could be dangerous to replace the contents with
 /// arbitrary XML because it can damage the internal invariants of a
 /// token instance. Use with care!
 /// </para>
 /// <para>
 /// This method is synchronized and can block.
 /// </para>
 /// </remarks>
 /// <param name="content">new content of the token</param>
 public void UpdateContent(XDocument content)
 {
     lock (SyncLock)
     {
         Content = new SerializableXDocument(content);
     }
 }
Esempio n. 14
0
 /// <summary>
 /// Finishes the token processing. It changes only the token state, not
 /// the message flow. Also it might send a reply message back to the
 /// source gateway.
 /// </summary>
 /// <param name="token">token to be finished</param>
 /// <param name="resultMessage">reply message going back the the original
 /// gateway; can be null</param>
 public void FinishToken(Token token, XDocument resultMessage)
 {
     SerializableXDocument serializableResultMessage = new SerializableXDocument(resultMessage);
     BrokerService.FinishToken(ProcessorName, token,
         serializableResultMessage);
 }