00001 using System;
00002 using System.Collections.Generic;
00003 using System.Text;
00004 using System.Runtime.Remoting.Channels.Tcp;
00005 using System.Runtime.Remoting;
00006 using System.Runtime.Remoting.Channels;
00007 using Shared;
00008 using System.Runtime.Remoting.Lifetime;
00009
00013 namespace Server.Net
00014 {
00019 public class RMIServer : IServerAPI
00020 {
00021 TcpChannel channel;
00022 private Catalogue catalogue;
00023
00028 public RMIServer(Catalogue catalogue)
00029 {
00030 this.catalogue = catalogue;
00031 LifetimeServices.LeaseTime = TimeSpan.FromDays(1);
00032 LifetimeServices.RenewOnCallTime = TimeSpan.FromDays(1);
00033 }
00034
00038 public void Start()
00039 {
00040 channel = new TcpChannel(8080);
00041 ChannelServices.RegisterChannel(channel, false);
00042 RemotingConfiguration.RegisterWellKnownServiceType(typeof(PublicObject), "ArticleCatalogue", WellKnownObjectMode.SingleCall);
00043 PublicObject.Server = this;
00044 }
00045
00049 public void Stop()
00050 {
00051 ChannelServices.UnregisterChannel(channel);
00052 channel.StopListening(null);
00053 channel = null;
00054 }
00055
00060 public IAccessHandler GetAccessHandler()
00061 {
00062 return new RMIAccessHandler(catalogue);
00063 }
00064
00065 }
00066 }