HomeDigital EditionSys-Con RadioSearch Java Cd
Advanced Java AWT Book Reviews/Excerpts Client Server Corba Editorials Embedded Java Enterprise Java IDE's Industry Watch Integration Interviews Java Applet Java & Databases Java & Web Services Java Fundamentals Java Native Interface Java Servlets Java Beans J2ME Libraries .NET Object Orientation Observations/IMHO Product Reviews Scalability & Performance Security Server Side Source Code Straight Talking Swing Threads Using Java with others Wireless XML
 

"Building J2EE Apps For Performance And Scalability"
Vol. 6, Issue 4, p. 56

	




Listing 1

public class PolicyBean implements javax.ejb.EntityBean {
  public Vehicle vehicle; // data we're interested in
  public Holder holder;


  public void ejbLoad() {} // Load nothing by default


  public String getVehicleId() {
    loadVehicle(); // insure that dependent beans are loaded
    return vehicle.getVIN();
  }


  private void loadVehicle() { // do this in-line for better performance
    if (vehicle != null) {
      // get initCtxt hereŠ
      home = (VehicleHome) initCtxt.lookup("VehicleHome");
      vehicle = home.findByPolicy (policyID);
    }
  }
}




Listing 2

public class SharedData implements SessionBean {
  private ListArray m_data; // cached data
  private int m_accessCnt; // access counter
  public void ejbCreate() {
    reloadData(); // get data for the first time
  }
  private void reloadData() {
    // do sql query, store result in m_data
  }
  public String[] readNextRow (Cursor curs) {
    if (m_accessCnt++ > 1000) { // refresh?
      m_accessCnt = 0;
      reloadData(); // re-get the data
    }
    int i = curs.incRow(); // update row
    return (String[]) m_data.elementAt(i);
  }
}


  
 
 

All Rights Reserved
Copyright ©  2004 SYS-CON Media, Inc.
  E-mail: [email protected]

Java and Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. SYS-CON Publications, Inc. is independent of Sun Microsystems, Inc.