欧美一级特黄大片做受成人-亚洲成人一区二区电影-激情熟女一区二区三区-日韩专区欧美专区国产专区

Castle整合.NETRemoting-創(chuàng)新互聯(lián)

今天研究了一下Castle的Remoting Facility.記錄如下:

在萬年等地區(qū),都構建了全面的區(qū)域性戰(zhàn)略布局,加強發(fā)展的系統(tǒng)性、市場前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務理念,為客戶提供網(wǎng)站設計制作、網(wǎng)站設計 網(wǎng)站設計制作按需定制網(wǎng)站,公司網(wǎng)站建設,企業(yè)網(wǎng)站建設,品牌網(wǎng)站設計,營銷型網(wǎng)站建設,成都外貿(mào)網(wǎng)站制作,萬年網(wǎng)站建設費用合理。

微軟以前使用COM/DCOM的技術來處理分布式系統(tǒng)架構,通過Client端的Proxy代理程序來呼叫遠程Server機器上的對象。.NET Framework則使用.NET Remoting或Web Services技術來實作分布式處理的工作概念;在這里針對.NET Remoting的設計架構做一個初步的簡介和Castle整合示例。

.NET Framework提供了多種的機制來支持Remoting,如:

.利用Channel來負責信息的發(fā)送與接收。
.利用Formatter來負責在信息要通過channel發(fā)送出去之前,先將信息做適當?shù)募用?,或于信息在通過Channel接收進來之后,先將信息做相對的解密工作。
.利用Proxy來呼叫遠程的對象執(zhí)行所要的功能呼叫。

其關系如下圖所示:

Castle 整合.NET Remoting
Channel 和 Formatter

在遠程對象被使用之前,必須先在Server端注冊好信息發(fā)送的信道(Channel),這些Channel可通過.NET Remotin configuration file或 ChannelServices對象類別的RegisterChannel方法來注冊。

在Channel的使用上,.NET Framework支持HTTP、TCP及SMTP等通道。若使用HTTP Channel ,則使用SOAP協(xié)議來收送信息,所有的信息會被發(fā)送到SOAP Formatter中,被序列化(serialized)成XML的格式,而SOAP所需的headers也會被加入。至于使用TCP Channel者,則使用TCP協(xié)議來將信息發(fā)送到Binary Formatter中,以Binary Stream的方式來將信息發(fā)送到URI目的地。(URI : Universal Resource Identifier,類似大家所熟悉的URL)。

Activation and Proxy
Server-Side Activation
Server端在Client端要獲取Remoting對象時必需在Server端能自動啟動Remoting對象,可使用RemotingConfiguration對象類別的RegisterWellKnownServiceType方法來完成這項工作。

Client-Side Activation
Client端要使用遠程對象之前,可使用New 或Activator 對象類別所提供的CreateInstance或GetObject方法來啟動對象并傳回Proxy,以便Client端可通過Proxy來執(zhí)行叫用遠程對象的方法。

范例
以下分三個步驟來介紹

1.    建立Remoting對象

2.    在Server上初始Remoting物件

3.    Client端使用Remoting對象

步驟1:建立Remoting對象
建立一個MathServer對象類別,提供Sum方法,可給予一連串的整數(shù)由Sum方法代為計算總和。程序代碼如下,并說明于后:

using System;

namespace RemoteSample.Components

{

    /// <summary>

    /// Class1 的摘要說明。

    /// </summary>

    public interface IRemoteMath

    {

        int Sum(params int[] a);

        int CallCounter

        {

             get;

        }

    }

}

using System;

using RemoteSample.Components;

namespace RemoteSample.Components

{

    /// <summary>

    /// RemoteMath 的摘要說明。

    /// </summary>

    public class RemoteMath: MarshalByRefObject,IRemoteMath

    {

        private int callCounter = 0;

        public RemoteMath()

        {

  

        }

        #region 接口IRemoteMath的成員實現(xiàn)

        /// <summary>

        /// 求和計算

        /// </summary>

        /// <param name="a"></param>

        /// <returns></returns>

        public int Sum(params int[] a)

        {

             int sum = 0;

             for (int i = 0; i <= a.Length - 1; i++)

             {

                  sum += a[i];

             }

             callCounter += 1;

             return sum;

        }

        public int CallCounter

        {

             get

             {

                  return this.callCounter;

             }

        }

        #endregion

    }

}

說明:Remoting對象必須繼承自MarshalByRefObject,這樣才能通過網(wǎng)絡,將對象執(zhí)行個體的參考位置傳遞給呼叫端。

步驟2:在Server上初始化Remoting對象,程序代碼如下,并說明于后:

namespace RemoteSample.Server

{

    class RemoteServerMain

    {

        [STAThread]

        internal static void Main(string[] args)

        {

             IWindsorContainer container = new RemotingContainer();

             Console.ReadLine();

        }

    }

}

ServerConfig.xml文件:

<?xml version="1.0" encoding="utf-8" ?>

<configuration>

    <facilities>

        <facility id="remote.facility" type="Castle.Facilities.Remoting.RemotingFacility, Castle.Facilities.Remoting"

                  remotingConfigurationFile ="../../RemotingTcpConfig.config"

               isServer="true"

                registryUri="kernel.rem" >

        </facility>

    </facilities>

    <components>

        <component

             id="remote.math"

             service="RemoteSample.Components.IRemoteMath, RemoteSample.Components"

             type="RemoteSample.Components.RemoteMath, RemoteSample.Components"

             remoteserver="component"  >

        </component>

    </components>

</configuration>

RemotingTcpConfig.config文件:

<?xml version="1.0" encoding="utf-8" ?>

<configuration>

   <system.runtime.remoting>

      <application>

          <channels>

             <channel ref="tcp" port="2133" />

          </channels>

      </application>

   </system.runtime.remoting>

</configuration>

說明:

使用Castle 的Remoting Facillity 使用Remoting 。

1.配置指出在2133 port上要建立TCP Channel, 2133 port上要建立tcp Channel

2.<components>指出在Server端注冊所要使用的組件、服務的名稱及啟動的方式。其中component表示一個執(zhí)行個體可供多個前端來呼叫,可保留其狀態(tài),另一種則為ClientActivated,一個執(zhí)行個體只能服務一個前端的呼叫,無法保留其狀態(tài)。

步驟3:在Client端使用Remoting對象

ClientConfig.xml

<?xml version="1.0" encoding="utf-8" ?>

<configuration>

    <facilities>

        <facility

                  id="remote.facility"

                type="Castle.Facilities.Remoting.RemotingFacility, Castle.Facilities.Remoting"

                remotingConfigurationFile="../../RemotingTcpConfigClient.config"

                isClient="true"

                remoteKernelUri="tcp://localhost:2133/kernel.rem"

                baseUri="tcp://localhost:2133" >

        </facility>

    </facilities>

 <components>

   <component

        id="remote.math"

        service="RemoteSample.Components.IRemoteMath, RemoteSample.Components"

        type="RemoteSample.Components.RemoteMath, RemoteSample.Components"

        remoteclient="component" />

 </components>

</configuration>

RemotingTcpConfigClient.config

<?xml version="1.0" encoding="utf-8" ?>

<configuration>

    <system.runtime.remoting>

        <application>

             <channels>

                  <channel ref="tcp" port="0" />

             </channels>

        </application>

    </system.runtime.remoting>

</configuration>

程序代碼如下:

namespace RemoteSample.Client

{

    /// <summary>

    /// RemoteClient的摘要說明。

    /// </summary>

    public class RemoteClientMain

    {

        [STAThread]

        static void Main(String[] args)

        {

             IWindsorContainer container = new RemotingContainer();

             IRemoteMath remoteMath = (IRemoteMath)container[typeof(IRemoteMath)] ;

             Console.WriteLine("Client1 TCP Call Sum method {0} Counter {1}",remoteMath.Sum(10, 20, 30),remoteMath.CallCounter);

             Console.WriteLine("....press a key to stop");

             Console.ReadLine();

        }

    }

}

新航道雅思

創(chuàng)新互聯(lián)www.cdcxhl.cn,專業(yè)提供香港、美國云服務器,動態(tài)BGP最優(yōu)骨干路由自動選擇,持續(xù)穩(wěn)定高效的網(wǎng)絡助力業(yè)務部署。公司持有工信部辦法的idc、isp許可證, 機房獨有T級流量清洗系統(tǒng)配攻擊溯源,準確進行流量調(diào)度,確保服務器高可用性。佳節(jié)活動現(xiàn)已開啟,新人活動云服務器買多久送多久。

本文名稱:Castle整合.NETRemoting-創(chuàng)新互聯(lián)
網(wǎng)頁URL:http://aaarwkj.com/article2/jdsoc.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供小程序開發(fā)、移動網(wǎng)站建設、品牌網(wǎng)站建設網(wǎng)站收錄、微信公眾號、用戶體驗

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

外貿(mào)網(wǎng)站建設
一区二区三区欧美影片| 日本理论午夜三级在线观看| 狠狠久久五月综合色和啪| 亚洲精品色婷婷一区二区| 国产原创av剧情在线观看| 91九色国产老熟女乱子| 亚洲精品日韩av专区| 久久精品亚洲精品国产| 97在线观看免费播放| 亚洲国产欧美日韩在线一区| 国产情侣最新地址在线| 亚洲成人久久久久久久| 久久亚洲精品综合一区| 国产av剧情日韩精品| 亚洲限制级电影一区二区| 国产成人在线免费短视频| 午夜欧美日韩精品久久久| 蜜桃精品人妻一区二区三区 | 国产一区二区欧美久久| 国产中文字幕有码视频| 男人的天堂久久精品激情| 91高清国产在线播放| 国产夫妻自拍在线视频| 国内精品久久久久久2021| 国产欧美成人精品第一区| 国产精品免费网站在线观看| 欧美成人精品欧美一级黄片| 亚洲av毛片在线免费| 亚洲成人免费电影久久| 小黄片免费在线播放观看| 看看永久成人免费视频| 日本东京热二三四区不卡免费的| 亚洲国产精品中文字幕一区久久| 七十二式性日韩视频| 免费亚洲网站在线观看视频| 亚洲福利网址一二三区| 中国成熟女人毛茸茸视频| 溪乱毛片一区二区三区| 欧美日韩亚洲1区2区| 91高清国产在线播放| 日韩精品一区二区av在线|