package com.hohai.juncao ;

import java.rmi.RemoteException ;
import javax.ejb.CreateException ;
import javax.ejb.EJBException ;
import javax.ejb.SessionBean ;
import javax.ejb.SessionContext ;
import javax.naming.InitialContext ;
import javax.naming.NamingException ;

public class HelloBean
	implements SessionBean
{
	private SessionContext ctx = null ;

	public void ejbActivate( )
		throws EJBException, RemoteException
	{
		// DO NOTHING
	}

	public void ejbPassivate( )
		throws EJBException, RemoteException
	{
		// DO NOTHING
	}

	public void ejbRemove( )
		throws EJBException, RemoteException
	{
		// DO NOTHING
	}

	public void setSessionContext( SessionContext ctx )
		throws EJBException, RemoteException
	{
		this.ctx = ctx ;
	}

	public String say( )
		throws RemoteException, NamingException, CreateException
	{
		InitialContext initialContext = new InitialContext( ) ;

		HelloLocalHome helloLocalHome = ( HelloLocalHome )initialContext.lookup( "java:comp/env/ejb/HelloLocalRefName" ) ;
		HelloLocal helloLocal = helloLocalHome.create( ) ;

		return helloLocal.say( ) ;
	}
}
