2010-05-25 Jb Evain <jbevain@novell.com>
[mcs.git] / class / System.Runtime.Remoting / System.Runtime.Remoting.Channels.CORBA / CORBAChannel.cs
blob1fb4216d4089b6bb7fd3b38cc1a5f02ab34b74f9
1 //
2 // System.Runtime.Remoting.Channels.CORBA.CORBAChannel.cs
3 //
4 // Author: Dietmar Maurer (dietmar@ximian.com)
5 //
6 // 2002 (C) Copyright, Ximian, Inc.
7 //
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
17 //
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
20 //
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 using System.Collections;
31 using System.Runtime.Remoting.Messaging;
32 using System.Text.RegularExpressions;
34 namespace System.Runtime.Remoting.Channels.CORBA
36 public class CORBAChannel : IChannelReceiver, IChannel,
37 IChannelSender
39 CORBAServerChannel svr_chnl;
40 CORBAClientChannel cnt_chnl;
42 string name = "corba";
44 public CORBAChannel ()
46 svr_chnl = new CORBAServerChannel (0);
47 cnt_chnl = new CORBAClientChannel ();
50 public CORBAChannel (int port)
52 svr_chnl = new CORBAServerChannel (port);
53 cnt_chnl = new CORBAClientChannel ();
56 [MonoTODO]
57 public CORBAChannel (IDictionary properties,
58 IClientChannelSinkProvider clientSinkProvider,
59 IServerChannelSinkProvider serverSinkProvider)
61 throw new NotImplementedException ();
64 public object ChannelData
66 get {
67 return svr_chnl.ChannelData;
71 public string ChannelName
73 get {
74 return name;
78 public int ChannelPriority
80 get {
81 return svr_chnl.ChannelPriority;
85 public IMessageSink CreateMessageSink (string url,
86 object remoteChannelData,
87 out string objectURI)
89 return cnt_chnl.CreateMessageSink (url, remoteChannelData, out objectURI);
92 public string[] GetUrlsForUri (string objectURI)
94 return svr_chnl.GetUrlsForUri (objectURI);
97 public string Parse (string url, out string objectURI)
99 return svr_chnl.Parse (url, out objectURI);
102 public void StartListening (object data)
104 svr_chnl.StartListening (data);
107 public void StopListening (object data)
109 svr_chnl.StopListening (data);
112 internal static string ParseCORBAURL (string url, out string objectURI, out int port)
114 // format: "corba://host:port/path/to/object"
116 objectURI = null;
117 port = 0;
119 Match m = Regex.Match (url, "corba://([^:]+):([0-9]+)(/.*)");
121 if (!m.Success)
122 return null;
124 string host = m.Groups[1].Value;
125 string port_str = m.Groups[2].Value;
126 objectURI = m.Groups[3].Value;
127 port = Convert.ToInt32 (port_str);
129 return host;