public void TestDestinationTypeHostAndQueueAreRecognizedCorrectly()
        {
            JmsDestination destination = new JmsDestination(Host + "?" + Queue);

            Assert.AreEqual <String>(Host, destination.Host);
            Assert.AreEqual <String>(Queue, destination.Queue);
            Assert.AreEqual <String>(Host + "?" + Queue, destination.FullDestination);
        }
        public void TestDestinationTypeWhereNoQueueIsIndicated()
        {
            JmsDestination destination = new JmsDestination(Url + "?");

            Assert.AreEqual <String>(destination.Host, Url);
            Assert.IsTrue(String.IsNullOrEmpty(destination.Queue));
            Assert.AreEqual <String>(destination.FullDestination, Url);
        }
Beispiel #3
0
 /// <summary>
 /// Default constructor
 /// </summary>
 /// <param name="localDomainService">LocalDomain</param>
 /// <param name="host">Host</param>
 /// <param name="connectorId">ServiceId</param>
 /// <param name="domainName">name of the remote Domain</param>
 /// <param name="domainEvents">Type of the remoteDomainEvents</param>
 public DomainReverse(domainServiceType localDomainService, string host, string connectorId, string domainName, Boolean createNewConnector, ABridgeExceptionHandling exceptionhandler)
     : this()
 {
     this.ExceptionHandler = exceptionhandler;
     this.Destination      = JmsDestination.CreateDestinationString(host, connectorId);
     this.connectorId      = connectorId;
     this.domainName       = domainName;
     this.domainService    = localDomainService;
     this.PortIn           = new JmsIncomingPort(Destination, exceptionhandler, connectorId);
     this.Username         = "******";
     this.Password         = "******";
     this.createService    = createNewConnector;
 }
Beispiel #4
0
        private MethodResultMessage WaitAndCheckAnswer(JmsDestination destinationinfo, String id)
        {
            IIncomingPort       portIn = new JmsIncomingPort(JmsDestination.CreateDestinationString(destinationinfo.Host, id), ExceptionHandler, ConnectorId);
            string              reply  = portIn.Receive();
            MethodResultMessage result = Marshaller.UnmarshallObject <MethodResultMessage>(reply);

            portIn.Close();
            if (result.Result.Type == ReturnType.Exception)
            {
                throw new OpenEngSBException("Remote Exception while Registering service proxy", new Exception(result.Result.ClassName));
            }

            return(result);
        }
Beispiel #5
0
        /// <summary>
        /// Will be invoked when a call to the proxy has been made.
        /// </summary>
        /// <param name="msg">Message, which contains the Parameters of the Method</param>
        /// <returns>Received Method</returns>
        public override IMessage Invoke(IMessage msg)
        {
            IMethodCallMessage callMessage       = msg as IMethodCallMessage;
            MethodCallMessage  methodCallRequest = ToMethodCallRequest(callMessage);
            string             methodCallMsg     = Marshaller.MarshallObject(methodCallRequest);
            IOutgoingPort      portOut           = new JmsOutgoingPort(JmsDestination.CreateDestinationString(Host, HostQueue), Exceptionhandler, ConnectorId);

            portOut.Send(methodCallMsg, methodCallRequest.CallId);
            IIncomingPort       portIn          = new JmsIncomingPort(JmsDestination.CreateDestinationString(Host, methodCallRequest.CallId), Exceptionhandler, ConnectorId);
            string              methodReturnMsg = portIn.Receive();
            MethodResultMessage methodReturn    = Marshaller.UnmarshallObject <MethodResultMessage>(methodReturnMsg);

            return(ToMessage(methodReturn.Result, callMessage));
        }
Beispiel #6
0
        /// <summary>
        /// Blocks an waits for messages.
        /// </summary>
        public override void Listen()
        {
            try
            {
                while (IsEnabled)
                {
                    String textMsg;
                    textMsg = PortIn.Receive();

                    if (textMsg == null)
                    {
                        continue;
                    }

                    MethodCallMessage methodCallRequest = Marshaller.UnmarshallObject <MethodCallMessage>(textMsg);
                    if (methodCallRequest.MethodCall.Args == null)
                    {
                        methodCallRequest.MethodCall.Args = new List <Object>();
                    }

                    MethodResultMessage methodReturnMessage = CallMethod(methodCallRequest);
                    if (methodCallRequest.Answer)
                    {
                        string         returnMsg = Marshaller.MarshallObject(methodReturnMessage);
                        JmsDestination dest      = new JmsDestination(Destination);
                        IOutgoingPort  portOut   = new JmsOutgoingPort(JmsDestination.CreateDestinationString(dest.Host, methodCallRequest.CallId), ExceptionHandler, ConnectorId);
                        portOut.Send(returnMsg);
                        portOut.Close();
                        if (methodReturnMessage.Result.Type.Equals(ReturnType.Exception))
                        {
                            throw new BridgeException("A exception occurs, while the message has been created", new BridgeException(methodReturnMessage.Result.Arg.ToString()));
                        }
                    }
                }
            }
            catch (Exception e)
            {
                if (IsEnabled)
                {
                    ExceptionHandler.Changed += delegate(object[] obj)
                    {
                        Listen();
                        return(null);
                    };
                    ExceptionHandler.HandleException(e);
                }
            }
        }
Beispiel #7
0
        /// <summary>
        /// Creates an Proxy on the bus.
        /// </summary>
        public override void CreateRemoteProxy()
        {
            Logger.Info("Create a new connector");
            IDictionary <string, string> metaData = new Dictionary <string, string>();

            metaData.Add("serviceId", CreationServiceId);
            metaData.Add("contextId", ContextId);
            RegisterId = ConnectorId;

            IList <string> classes   = new List <string>();
            LocalType      localType = new LocalType(typeof(String));

            classes.Add(localType.RemoteTypeFullName);
            classes.Add("org.openengsb.core.api.model.ConnectorDescription");

            IList <object> args = new List <object>();

            Org.Openengsb.Loom.CSharp.Bridge.OpenEngSB300.Remote.RemoteObjects.ConnectorDescription connectorDescription = new Org.Openengsb.Loom.CSharp.Bridge.OpenEngSB300.Remote.RemoteObjects.ConnectorDescription();
            connectorDescription.Attributes.Add("serviceId", ConnectorId);
            connectorDescription.Attributes.Add("portId", CreationPort);
            connectorDescription.Attributes.Add("destination", Destination);
            connectorDescription.ConnectorType = CreationConnectorType;
            connectorDescription.DomainType    = DomainName;

            args.Add(RegisterId);
            args.Add(connectorDescription);

            RemoteMethodCall creationCall = RemoteMethodCall.CreateInstance(CreationMethodName, args, metaData, classes, null);

            JmsDestination destinationinfo = new JmsDestination(Destination);

            destinationinfo.Queue = CreationQueue;
            String          id      = Guid.NewGuid().ToString();
            BeanDescription autinfo = BeanDescription.CreateInstance(AuthentificationClass);

            autinfo.Data.Add("value", Password);
            MethodCallMessage secureRequest = MethodCallMessage.CreateInstance(Username, autinfo, creationCall, id, true, String.Empty);
            IOutgoingPort     portOut       = new JmsOutgoingPort(destinationinfo.FullDestination, ExceptionHandler, ConnectorId);
            string            request       = Marshaller.MarshallObject(secureRequest);

            portOut.Send(request, id);
            WaitAndCheckAnswer(destinationinfo, id);
            RegistrationProcess = ERegistration.CREATED;
            portOut.Close();
            Logger.Info("Create done");
        }
Beispiel #8
0
        /// <summary>
        /// Connect a connector to xlink
        /// </summary>
        /// <param name="ServiceId"></param>
        /// <param name="hostId"></param>
        /// <param name="toolName"></param>
        /// <param name="modelsToViews"></param>
        /// <returns></returns>
        public override XLinkUrlBlueprint ConnectToXLink(string toolName, String hostId, ModelToViewsTuple[] modelsToViews)
        {
            Logger.Info("Create a Xlink connector");
            IDictionary <string, string> metaData = new Dictionary <string, string>();

            metaData.Add("serviceId", CreationServiceId);
            metaData.Add("contextId", ContextId);

            IList <string> classes   = new List <string>();
            LocalType      localType = new LocalType(typeof(String));

            classes.Add(localType.RemoteTypeFullName);
            classes.Add(localType.RemoteTypeFullName);
            classes.Add(localType.RemoteTypeFullName);
            localType = new LocalType(modelsToViews.GetType());
            classes.Add(localType.RemoteTypeFullName);

            IList <object> args = new List <object>();

            args.Add(RegisterId);
            args.Add(hostId);
            args.Add(toolName);
            args.Add(modelsToViews);

            RemoteMethodCall creationCall = RemoteMethodCall.CreateInstance(XlinkMethodName, args, metaData, classes, null);

            JmsDestination destinationinfo = new JmsDestination(Destination);

            destinationinfo.Queue = CreationQueue;
            String          id      = Guid.NewGuid().ToString();
            BeanDescription autinfo = BeanDescription.CreateInstance(AuthentificationClass);

            autinfo.Data.Add("value", Password);
            MethodCallMessage methodCall = MethodCallMessage.CreateInstance(Username, autinfo, creationCall, id, true, String.Empty);
            IOutgoingPort     portOut    = new JmsOutgoingPort(destinationinfo.FullDestination, ExceptionHandler, ConnectorId);
            string            request    = Marshaller.MarshallObject(methodCall);

            portOut.Send(request, id);
            portOut.Close();
            MethodResultMessage result = WaitAndCheckAnswer(destinationinfo, id);

            RegistrationProcess = ERegistration.XLINK;
            Logger.Info("Create done");
            return(Marshaller.UnmarshallObject <XLinkUrlBlueprint>(result.Result.Arg.ToString()));
        }
Beispiel #9
0
        /// <summary>
        /// Creates an Proxy on the bus.
        /// </summary>
        public override void UnRegisterConnector()
        {
            if (!RegistrationProcess.Equals(ERegistration.REGISTERED))
            {
                return;
            }

            Logger.Info("Unregister the connector with ID: " + ConnectorId);
            IDictionary <string, string> metaData = new Dictionary <string, string>();

            metaData.Add("serviceId", CreationRegistration);
            metaData.Add("contextId", ContextId);
            LocalType      localType = new LocalType(typeof(String));
            IList <string> classes   = new List <string>();

            classes.Add(localType.RemoteTypeFullName);

            IList <object> args = new List <object>();

            args.Add(ConnectorId);

            RemoteMethodCall creationCall = RemoteMethodCall.CreateInstance(UnregistrationMethodName, args, metaData, classes, null);

            JmsDestination destinationinfo = new JmsDestination(Destination);

            destinationinfo.Queue = CreationQueue;

            BeanDescription autinfo = BeanDescription.CreateInstance(AuthentificationClass);

            autinfo.Data.Add("value", Password);
            String            id            = Guid.NewGuid().ToString();
            MethodCallMessage secureRequest = MethodCallMessage.CreateInstance(Username, autinfo, creationCall, id, true, String.Empty);
            IOutgoingPort     portOut       = new JmsOutgoingPort(destinationinfo.FullDestination, ExceptionHandler, ConnectorId);
            string            request       = Marshaller.MarshallObject(secureRequest);

            portOut.Send(request, id);
            WaitAndCheckAnswer(destinationinfo, id);
            if (RegistrationProcess.Equals(ERegistration.REGISTERED))
            {
                RegistrationProcess = ERegistration.CREATED;
            }

            portOut.Close();
            Logger.Info("Unregister done");
        }
Beispiel #10
0
        /// <summary>
        /// Disconnect the Connector from XLink
        /// </summary>
        public override void DisconnectFromXLink(String hostId)
        {
            Logger.Info("Disconnect connector from xlink with the serviceId: " + ConnectorId);
            IDictionary <string, string> metaData = new Dictionary <string, string>();

            metaData.Add("serviceId", CreationServiceId);
            metaData.Add("contextId", ContextId);
            LocalType      localType = new LocalType(typeof(String));
            IList <String> classes   = new List <String>();

            classes.Add(localType.RemoteTypeFullName);
            classes.Add(localType.RemoteTypeFullName);
            IList <object> args = new List <object>();

            args.Add(RegisterId);
            args.Add(hostId);

            RemoteMethodCall deletionCall = RemoteMethodCall.CreateInstance(RemoveXlinkConnectorMethodName, args, metaData, classes, null);

            String          id = Guid.NewGuid().ToString();
            BeanDescription authentification = BeanDescription.CreateInstance(AuthentificationClass);

            authentification.Data.Add("value", Password);
            MethodCallMessage callRequest = MethodCallMessage.CreateInstance(Username, authentification, deletionCall, id, true, String.Empty);

            JmsDestination destinationinfo = new JmsDestination(Destination);

            destinationinfo.Queue = CreationQueue;

            IOutgoingPort portOut = new JmsOutgoingPort(destinationinfo.FullDestination, ExceptionHandler, ConnectorId);
            string        request = Marshaller.MarshallObject(callRequest);

            portOut.Send(request, id);
            WaitAndCheckAnswer(destinationinfo, id);
            portOut.Close();
            RegistrationProcess = ERegistration.REGISTERED;
            Logger.Info("XLink is disconnected");
        }
Beispiel #11
0
 public void TestInvalidSignBetweenUrlAndParameter()
 {
     JmsDestination destination = new JmsDestination(Host + "!" + Queue);
 }
Beispiel #12
0
 public void TestDestinationWhitInvalidParametInTheUrl()
 {
     JmsDestination destination = new JmsDestination(Url + "?Test?Test");
 }
Beispiel #13
0
 public void TestDestinationTypeWhereNoQuestionMarkIsIndicated()
 {
     JmsDestination destination = new JmsDestination(Url);
 }