// Elided package and import statements...
public class StaticLiaisonBean
extends SessionAdapter
{
private String beanName;
private UpperCaseConverterRemoteProxy proxy = null; // Line A
private InitialContext context = null;
private final String beanNameKey = new String( "beanName" );
public String forward( String obj )
throws RemoteException
{
String myMethod = "forward";
log( beanName, myMethod, "Invoked" );
try
{
return proxy.process( obj );
}
finally
{
log( beanName, myMethod, "Finished" );
}
}
public void ejbCreate()
throws CreateException
{
super.ejbCreate();
String myMethod = "ejbCreate";
log( beanName, myMethod, "Invoked" );
try
{
Context ictx = new InitialContext();
Context env = (Context) ictx.lookup( "java:comp/env" );
beanName = (String) env.lookup( beanNameKey );
Object obj = env.lookup( "ejb/TargetBean" ); // Line B
UpperCaseConverterHome home =
(UpperCaseConverterHome) PortableRemoteObject.narrow
( obj,
UpperCaseConverterHome.class ); // Line C
proxy = home.create();
}
catch (Exception e)
{
log( beanName, myMethod, e.getMessage() );
throw new CreateException( e.getMessage() );
}
finally
{
log( beanName, myMethod, "Finished" );
}
}
}
End of Listing