日期:2014-05-20  浏览次数:20735 次

一个复杂一点的简单问题!谢谢!
SwitchboardSession ss = new SwitchboardSession( msn, serv, (String)null ) //在同一个包里有SwitchboardSession的定义;
{

private String firstCallName = null;
private boolean isFirstJoin = true;
public void init() throws IOException //重写了init();
{
this.firstCallName = toCallLoginName;
Callback cb = Callback.getInstance("processUserCall", this.getClass());

OutgoingMessage out = new OutgoingMessage("USR");
markTransactionId( out );
out.add( msn.getLoginName() );
out.add( cookie );
out.setBackProcess( cb );

sendMessage( out );
}

public void processUserCall( IncomingMessage msg ) throws IOException //重写了一些方法;  
{
Callback cb = Callback.getInstance("processCallResult",this.getClass());

OutgoingMessage out = new OutgoingMessage("CAL");
markTransactionId( out );
out.add( firstCallName );
out.setBackProcess( cb );

sendMessage( out );
}

protected void processWhoJoined( IncomingMessage msg ) throws Exception
{
callingMap.remove( toCallLoginName );
super.processWhoJoined( msg );

if( isFirstJoin )
{
isFirstJoin = false;
msn.fireSwitchboardSessionStartedEvent( this );

if( lockMap.containsKey(tr) )
{
sessionMap.put( tr, this );
Object lock = lockMap.remove(tr);
if( lock!=null )
{
synchronized(lock)
{
lock.notify();
}
}
}

sessionOpened();
}
}

public void processCallResult( IncomingMessage msg ) throws IOException
{
callingMap.remove( toCallLoginName );
String sessionId = msg.get(1);
setSessionId( sessionId );
}

public void cleanUp()
{
super.cleanUp();
callingMap.remove( toCallLoginName );

if( getSessionId()==null )
msn.fireSwitchboardSessionAbandonEvent( this, firstCallName );
}
};

  ss.start(); //start()在上面没有被重写,此处应该调用的是同一个包内定义的那
  //个SwitchboardSession类中的方法;
  //其中start()中调用了init();试问,会调用哪个init()?
  //是上面重写过的,还是同一个包内的SwitchboardSession那个?

以上代码是Java实现简单的的MSN功能中的部分代码!

------解决方案--------------------

是调用这里的:SwitchboardSession