首先,对话服务器将获得mnemosyne对象的一个实例,该实例被绑定到对话服务器的本地ip上。
protected void bindmnemosyne()
{
file://得到mnemosyne
mnemosyne mnemosyne = null;
try
{
mnemosyne = mnemosynefactory.getmnemosyne();
}
catch(remoteexception remoteexception)
{
system.out.println("internal error:");
system.out.println("cant create a mnemosyne");
system.exit(1);
}
// 把mnemosyne绑定到mnemosyneimpl
try
{
string rmiurl = "//" + _localip + "/mnemosyneimpl";
naming.rebind(rmiurl, mnemosyne);
}
catch(arrayindexoutofboundsexception arrayindexoutofboundsexception)
{
throw new illegalargumentexception("localip is invalid");
}
catch(malformedurlexception malformedurlexception)
{
throw new illegalargumentexception("localip is invalid");
}
catch(remoteexception remoteexception)
{
system.out.println("internal error:");
system.out.println("cant rebind a mnemosyne to mnemosyneimpl");
system.exit(1);
}
}
通过把本地mnemosyne上一系列代表rmi名字符号的url赋予远程对话服务器,就能引发同步操作,这些url存贮在一个被称作rmiurl的字符串数组中。在sessionserver的符号中,url是作为参数从命令行命令中获得的,但它可以来自其他渠道:
protected void synchronizemnemosyne()
{
file://获得本地mnemosyne
mnemosyne localmnemosyne = null;
try
{
localmnemosyne = (mnemosyne) naming.lookup(_localip);
}
catch(exception exception)
{
system.out.println("internal error:");
system.out.println("cant lookup local mnemosyneimpl");
system.exit(1);
}
file://获得同步用的远程mnemosynes
vector remotemnemosynes = new vector();
// _rmiurls对象是代表需要进行同步的远程服务器的字符串数组
for(int index = 1;index < _rmiurls.length;index++)
{
try
{
remotemnemosynes.add(naming.lookup(_rmiurls[index]));
}
catch(exception exception)
{
}
}
file:// 同步
try
{
if(remotemnemosynes.size() > 1)
localmnemosyne.synchronize(remotemnemosynes);
}
catch(exception exception)
{
system.out.println("internal error:");
system.out.println("cant synchronize local mnemosyneimpl");
system.exit(1);
}
}
