Listing 7: The liaison bean’s source code

//  Elided package and import statements.

public class DynamicLiaisonBean
  extends SessionAdapter
  implements LiaisonInterface                         //  Line D
{
  private String    targetJNDI;
  private String    converterHomeName;

  private ConverterInterface    proxy = null;         //  Line E

  private final String targetJNDIKey =
    new String( "targetJNDI" );                       //  Line F
  private final String converterHomeKey =
    new String( "targetHomeClass" );

  //  Elided methods...

  public void ejbCreate()
    throws CreateException
  {
    super.ejbCreate();

    try
    {
      Context ictx = new InitialContext();
      Context env = (Context) ictx.lookup( "java:comp/env" );

      targetJNDI =
        (String) env.lookup( targetJNDIKey );         //  Line G
      converterHomeName =
        (String) env.lookup( converterHomeKey );      //  Line H

      Class converterHome =
        Class.forName( converterHomeName );           //  Line I

      Object ref =
        env.lookup( "ejb/" + targetJNDI );            //  Line J
      Object home =
        PortableRemoteObject.narrow( ref
                                   , converterHome ); //  Line K

      Method createRemoteProxy =
        converterHome.getMethod( "create"
                               , null );              //  Line L

      proxy = (ConverterInterface)
        createRemoteProxy.invoke( home, null );       //  Line M
    }
    catch (Exception e)
    {
      log( beanName, myMethod, e.getMessage() );
      throw new CreateException( e.getMessage() );
    }
  }
}

— End of Listing —