欢迎光临
我们一直在努力

分布式对话服务器的管理(4)-JSP教程,J2EE/EJB/服务器

建站超值云服务器,限时71元/月

  首先,对话服务器将获得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);
}
}

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 分布式对话服务器的管理(4)-JSP教程,J2EE/EJB/服务器
分享到: 更多 (0)

相关推荐

  • 暂无文章