private void ConfigureServerComponent(RemotingStrategy server, Type type, ComponentModel model)
        {
            if (server == RemotingStrategy.None)
            {
                return;
            }

            String uri = ConstructServerURI(server, model.Name, model);

            if (server == RemotingStrategy.Singleton)
            {
                CheckURIIsNotNull(uri, model.Name);

                RemotingConfiguration.RegisterWellKnownServiceType(type, uri, WellKnownObjectMode.Singleton);
            }
            else if (server == RemotingStrategy.SingleCall)
            {
                CheckURIIsNotNull(uri, model.Name);

                RemotingConfiguration.RegisterWellKnownServiceType(type, uri, WellKnownObjectMode.SingleCall);
            }
            else if (server == RemotingStrategy.ClientActivated)
            {
                RemotingConfiguration.RegisterActivatedServiceType(type);
            }
            else if (server == RemotingStrategy.Component)
            {
                localRegistry.AddComponentEntry(model);
            }
        }
        private void DoSemanticCheck(RemotingStrategy server, ComponentModel model, RemotingStrategy client)
        {
            if (server != RemotingStrategy.None && client != RemotingStrategy.None)
            {
                String message = String.Format("Component {0} cannot be a remote server and a client " +
                                               "at the same time", model.Name);

                throw new FacilityException(message);
            }

            if (server == RemotingStrategy.Component && !isServer)
            {
                String message = String.Format("Component {0} was marked with remoteserver='component', " +
                                               "but you must enable the remoting facility with isServer='true' to serve components this way", model.Name);

                throw new FacilityException(message);
            }

            if (client == RemotingStrategy.Component && !isClient)
            {
                String message = String.Format("Component {0} was marked with remoteserver='component', " +
                                               "but you must enable the remoting facility with isServer='true' to serve components this way", model.Name);

                throw new FacilityException(message);
            }
        }
Ejemplo n.º 3
0
        private void ConfigureServerComponent(RemotingStrategy server, Type type, ComponentModel model)
        {
            if (server == RemotingStrategy.None)
            {
                return;
            }

            var uri = ConstructServerURI(server, model);

            switch (server)
            {
            case RemotingStrategy.Singleton:
            {
                CheckURIIsNotNull(uri, model.Name);

                RemotingConfiguration.RegisterWellKnownServiceType(type, uri, WellKnownObjectMode.Singleton);

                break;
            }

            case RemotingStrategy.SingleCall:
            {
                CheckURIIsNotNull(uri, model.Name);

                RemotingConfiguration.RegisterWellKnownServiceType(type, uri, WellKnownObjectMode.SingleCall);

                break;
            }

            case RemotingStrategy.ClientActivated:
            {
                RemotingConfiguration.RegisterActivatedServiceType(type);

                break;
            }

            case RemotingStrategy.Component:
            {
                localRegistry.AddComponentEntry(model);

                break;
            }

            case RemotingStrategy.RecoverableComponent:
            {
                CheckURIIsNotNull(uri, model.Name);

                ValidateLifeStyle(model);

                localRegistry.AddComponentEntry(model);

                model.ExtendedProperties.Add("remoting.uri", uri);
                model.ExtendedProperties.Add("remoting.afinity", true);

                model.CustomComponentActivator = typeof(RemoteMarshallerActivator);

                break;
            }
            }
        }
        private String ConstructClientURI(RemotingStrategy client, String componentId, ComponentModel model)
        {
            if (client == RemotingStrategy.ClientActivated)
            {
                return(null);
            }

            String value = model.Configuration.Attributes["uri"];

            String uriText = null;

            if (client != RemotingStrategy.None && baseUri != null && value == null)
            {
                if (baseUri.EndsWith("/"))
                {
                    uriText = String.Format("{0}{1}", baseUri, componentId);
                }
                else
                {
                    uriText = String.Format("{0}/{1}", baseUri, componentId);
                }
            }
            else
            {
                uriText = value;
            }

            return(uriText);
        }
        private void ConfigureClientComponent(RemotingStrategy client, Type type, ComponentModel model)
        {
            if (client == RemotingStrategy.None)
            {
                return;
            }

            ResetDependencies(model);

            String uri = ConstructClientURI(client, model.Name, model);

            if (client == RemotingStrategy.Singleton || client == RemotingStrategy.SingleCall)
            {
                RemotingConfiguration.RegisterWellKnownClientType(type, uri);

                model.ExtendedProperties.Add("remoting.uri", uri);
                model.CustomComponentActivator = typeof(RemoteActivator);
            }
            else if (client == RemotingStrategy.ClientActivated)
            {
                CheckHasBaseURI();

                RemotingConfiguration.RegisterActivatedClientType(type, baseUri);

                model.ExtendedProperties.Add("remoting.appuri", baseUri);
                model.CustomComponentActivator = typeof(RemoteClientActivatedActivator);
            }
            else if (client == RemotingStrategy.Component)
            {
                model.ExtendedProperties.Add("remoting.remoteregistry", remoteRegistry);
                model.CustomComponentActivator = typeof(RemoteActivatorThroughRegistry);
            }
        }
        private String ConstructServerURI(RemotingStrategy server, String componentId, ComponentModel model)
        {
            if (server == RemotingStrategy.ClientActivated)
            {
                return(null);
            }

            String value = model.Configuration.Attributes["uri"];

            String uriText = null;

            if (value == null)
            {
                value = componentId;
            }
            else
            {
                uriText = value;
            }

            return(uriText);
        }
Ejemplo n.º 7
0
        private String ConstructServerURI(RemotingStrategy server, ComponentModel model)
        {
            if (server == RemotingStrategy.ClientActivated)
            {
                return(null);
            }

            var value = model.Configuration.Attributes["uri"];

            String uriText;

            if (value == null)
            {
                uriText = BuildUri(model);
            }
            else
            {
                uriText = SetUriExtensionIfNeeded(value);
            }

            return(uriText);
        }
Ejemplo n.º 8
0
        private String ConstructClientURI(RemotingStrategy client, ComponentModel model)
        {
            if (client == RemotingStrategy.ClientActivated)
            {
                return(null);
            }

            var value = model.Configuration.Attributes["uri"];

            String uriText;

            if (client != RemotingStrategy.None && baseUri != null && value == null)
            {
                uriText = BuildUri(model);
            }
            else
            {
                uriText = value;
            }

            return(uriText);
        }
Ejemplo n.º 9
0
        private void DoSemanticCheck(RemotingStrategy server, ComponentModel model, RemotingStrategy client)
        {
            if (server != RemotingStrategy.None && client != RemotingStrategy.None)
            {
                var message = String.Format("Component {0} cannot be a remote server and a client " +
                                            "at the same time", model.Name);

                throw new FacilityException(message);
            }

            if (server == RemotingStrategy.Component && !isServer)
            {
                var message = String.Format("Component {0} was marked with remoteserver='component', " +
                                            "but you must enable the remoting facility with isServer='true' to serve components this way",
                                            model.Name);

                throw new FacilityException(message);
            }

            if (client == RemotingStrategy.Component && !isClient)
            {
                var message = String.Format("Component {0} was marked with remoteserver='component', " +
                                            "but you must enable the remoting facility with isServer='true' to serve components this way",
                                            model.Name);

                throw new FacilityException(message);
            }
            var count = model.Services.Count();

            if (count > 1)
            {
                var message = String.Format("Component {0} exposes {1} services, " +
                                            "Remoting facility only supports components with single service.",
                                            model.Name, count);

                throw new FacilityException(message);
            }
        }
        public void ProcessModel(IKernel kernel, ComponentModel model)
        {
            if (model.Configuration == null)
            {
                return;
            }

            String remoteserverAttValue = model.Configuration.Attributes["remoteserver"];
            String remoteclientAttValue = model.Configuration.Attributes["remoteclient"];
            // String sponsorIdAttValue = model.Configuration.Attributes["sponsorId"];

            RemotingStrategy server = RemotingStrategy.None;
            RemotingStrategy client = RemotingStrategy.None;

            if (remoteserverAttValue == null && remoteclientAttValue == null)
            {
                return;
            }

            if (remoteserverAttValue != null)
            {
                server = (RemotingStrategy)
                         converter.PerformConversion(remoteserverAttValue, typeof(RemotingStrategy));
            }

            if (remoteclientAttValue != null)
            {
                client = (RemotingStrategy)
                         converter.PerformConversion(remoteclientAttValue, typeof(RemotingStrategy));
            }

            DoSemanticCheck(server, model, client);

            ConfigureServerComponent(server, model.Implementation, model);

            ConfigureClientComponent(client, model.Service, model);
        }
Ejemplo n.º 11
0
		private String ConstructClientURI(RemotingStrategy client, ComponentModel model)
		{
			if (client == RemotingStrategy.ClientActivated)
			{
				return null;
			}

			var value = model.Configuration.Attributes["uri"];

			String uriText;

			if (client != RemotingStrategy.None && baseUri != null && value == null)
			{
				uriText = BuildUri(model);
			}
			else
			{
				uriText = value;
			}

			return uriText;
		}
Ejemplo n.º 12
0
		private void ConfigureServerComponent(RemotingStrategy server, Type type, ComponentModel model)
		{
			if (server == RemotingStrategy.None)
			{
				return;
			}

			var uri = ConstructServerURI(server, model);

			switch (server)
			{
				case RemotingStrategy.Singleton:
				{
					CheckURIIsNotNull(uri, model.Name);

					RemotingConfiguration.RegisterWellKnownServiceType(type, uri, WellKnownObjectMode.Singleton);

					break;
				}
				case RemotingStrategy.SingleCall:
				{
					CheckURIIsNotNull(uri, model.Name);

					RemotingConfiguration.RegisterWellKnownServiceType(type, uri, WellKnownObjectMode.SingleCall);

					break;
				}
				case RemotingStrategy.ClientActivated:
				{
					RemotingConfiguration.RegisterActivatedServiceType(type);

					break;
				}
				case RemotingStrategy.Component:
				{
					localRegistry.AddComponentEntry(model);

					break;
				}
				case RemotingStrategy.RecoverableComponent:
				{
					CheckURIIsNotNull(uri, model.Name);

					ValidateLifeStyle(model);

					localRegistry.AddComponentEntry(model);

					model.ExtendedProperties.Add("remoting.uri", uri);
					model.ExtendedProperties.Add("remoting.afinity", true);

					model.CustomComponentActivator = typeof(RemoteMarshallerActivator);

					break;
				}
			}
		}
Ejemplo n.º 13
0
		private void ConfigureClientComponent(RemotingStrategy client, Type type, ComponentModel model)
		{
			if (client == RemotingStrategy.None)
			{
				return;
			}

			var uri = ConstructClientURI(client, model);

			var skipRemotingRegistration = Convert.ToBoolean(model.Configuration.Attributes["skipRemotingRegistration"]);

			switch (client)
			{
				case RemotingStrategy.Singleton:
				case RemotingStrategy.SingleCall:
				{
					if (!skipRemotingRegistration)
					{
						RemotingConfiguration.RegisterWellKnownClientType(type, uri);
					}

					model.ExtendedProperties.Add("remoting.uri", uri);
					model.CustomComponentActivator = typeof(RemoteActivator);

					break;
				}
				case RemotingStrategy.ClientActivated:
				{
					CheckHasBaseURI();

					if (!skipRemotingRegistration)
					{
						RemotingConfiguration.RegisterActivatedClientType(type, baseUri);
					}

					model.ExtendedProperties.Add("remoting.appuri", baseUri);
					model.CustomComponentActivator = typeof(RemoteClientActivatedActivator);

					break;
				}
				case RemotingStrategy.Component:
				{
					model.ExtendedProperties["remoting.remoteregistry"] = remoteRegistry;
					model.CustomComponentActivator = typeof(RemoteActivatorThroughRegistry);

					break;
				}
				case RemotingStrategy.RecoverableComponent:
				{
					CheckHasBaseURI();

					var remoteUri = SetUriExtensionIfNeeded(uri);

					model.ExtendedProperties.Add("remoting.uri", remoteUri);
					model.ExtendedProperties.Add("remoting.remoteregistry", remoteRegistry);
					model.CustomComponentActivator = typeof(RemoteActivatorThroughConnector);

					break;
				}
			}
		}
Ejemplo n.º 14
0
		private void DoSemanticCheck(RemotingStrategy server, ComponentModel model, RemotingStrategy client)
		{
			if (server != RemotingStrategy.None && client != RemotingStrategy.None)
			{
				String message = String.Format("Component {0} cannot be a remote server and a client "+ 
					"at the same time", model.Name);

				throw new FacilityException(message);
			}

			if (server == RemotingStrategy.Component && !isServer)
			{
				String message = String.Format("Component {0} was marked with remoteserver='component', " + 
					"but you must enable the remoting facility with isServer='true' to serve components this way", model.Name);

				throw new FacilityException(message);
			}
	
			if (client == RemotingStrategy.Component && !isClient)
			{
				String message = String.Format("Component {0} was marked with remoteserver='component', " + 
					"but you must enable the remoting facility with isServer='true' to serve components this way", model.Name);

				throw new FacilityException(message);
			}
		}
Ejemplo n.º 15
0
		private String ConstructServerURI(RemotingStrategy server, ComponentModel model)
		{
			if (server == RemotingStrategy.ClientActivated)
			{
				return null;
			}

			var value = model.Configuration.Attributes["uri"];

			String uriText;

			if (value == null)
			{
				uriText = BuildUri(model);
			}
			else
			{
				uriText = SetUriExtensionIfNeeded(value);
			}

			return uriText;
		}
Ejemplo n.º 16
0
		private void DoSemanticCheck(RemotingStrategy server, ComponentModel model, RemotingStrategy client)
		{
			if (server != RemotingStrategy.None && client != RemotingStrategy.None)
			{
				var message = String.Format("Component {0} cannot be a remote server and a client " +
				                            "at the same time", model.Name);

				throw new FacilityException(message);
			}

			if (server == RemotingStrategy.Component && !isServer)
			{
				var message = String.Format("Component {0} was marked with remoteserver='component', " +
				                            "but you must enable the remoting facility with isServer='true' to serve components this way",
				                            model.Name);

				throw new FacilityException(message);
			}

			if (client == RemotingStrategy.Component && !isClient)
			{
				var message = String.Format("Component {0} was marked with remoteserver='component', " +
				                            "but you must enable the remoting facility with isServer='true' to serve components this way",
				                            model.Name);

				throw new FacilityException(message);
			}
			var count = model.Services.Count();
			if (count > 1)
			{
				var message = String.Format("Component {0} exposes {1} services, " +
				                            "Remoting facility only supports components with single service.",
				                            model.Name, count);

				throw new FacilityException(message);
			}
		}
Ejemplo n.º 17
0
        private void ConfigureClientComponent(RemotingStrategy client, Type type, ComponentModel model)
        {
            if (client == RemotingStrategy.None)
            {
                return;
            }

            var uri = ConstructClientURI(client, model);

            var skipRemotingRegistration = Convert.ToBoolean(model.Configuration.Attributes["skipRemotingRegistration"]);

            switch (client)
            {
            case RemotingStrategy.Singleton:
            case RemotingStrategy.SingleCall:
            {
                if (!skipRemotingRegistration)
                {
                    RemotingConfiguration.RegisterWellKnownClientType(type, uri);
                }

                model.ExtendedProperties.Add("remoting.uri", uri);
                model.CustomComponentActivator = typeof(RemoteActivator);

                break;
            }

            case RemotingStrategy.ClientActivated:
            {
                CheckHasBaseURI();

                if (!skipRemotingRegistration)
                {
                    RemotingConfiguration.RegisterActivatedClientType(type, baseUri);
                }

                model.ExtendedProperties.Add("remoting.appuri", baseUri);
                model.CustomComponentActivator = typeof(RemoteClientActivatedActivator);

                break;
            }

            case RemotingStrategy.Component:
            {
                model.ExtendedProperties["remoting.remoteregistry"] = remoteRegistry;
                model.CustomComponentActivator = typeof(RemoteActivatorThroughRegistry);

                break;
            }

            case RemotingStrategy.RecoverableComponent:
            {
                CheckHasBaseURI();

                var remoteUri = SetUriExtensionIfNeeded(uri);

                model.ExtendedProperties.Add("remoting.uri", remoteUri);
                model.ExtendedProperties.Add("remoting.remoteregistry", remoteRegistry);
                model.CustomComponentActivator = typeof(RemoteActivatorThroughConnector);

                break;
            }
            }
        }