The idea behind a bulk accessor is to return a single
object that holds all the data of your EJB.

(Forgive me for any syntax mistakes.  I'm doing this
from heart and I've done so much EJB2.0 stuff that my
1.1 is a little rusty.)

If you have an EJB like this:

public class FooEJB implements EntityBean
{
   public String data1;
   public String data2;
   public int data3;
   ...

   // this is a bulk accessor
   public FooView getFoo()
   {
      return new FooView(data1, data2, data3);
   }
}

You would create a "view" object that can hold all
the EJB data.  A view is a very thin "bean-like"
object:

public class FooView
{
   String data1;
   String data2;
   int data3;

   public String getData1() { return data1; }
   public String getData2() { return data2; }
   public int getData3() { return data3; }

   public FooView(String data1, String data2, int data3)
   {
      this.data1 = data1;
      this.data2 = data2;
      this.data3 = data3;
   }
}

Now you client only need to call:

   FooView fv = fooejb.getFooView();

to get all the data within the Foo EJB.  This reduces
the RMI marshalling to a single call.  Then, you use
the FooView accessors to get to the data; since FooView
is a local object, this will be fast.

NOTE: if you followed this thread, you heard from others
that Orion optimizes intra-VM EJB calls to "call-by-value"
which doesn't use RMI.  This is great for Orion, but is
not specified in the spec, so if you were to port your
application to another container, you aren't guaranteed
this optimization.  The above bulk accessor/View pattern
will always work.

-tim



-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, November 14, 2000 7:04 PM
To: Orion-Interest
Subject: Re: EJB Performance Question.


Thank You for your kind reply. Can I get some pseudo-code an example?

Thank you.
----- Original Message -----
From: Tim Drury
To: Orion-Interest
Sent: Wednesday, November 15, 2000 12:03 AM
Subject: RE: EJB Performance Question.


Every single one of those calls to dir.getXXX() has to go across
the network via RMI.  This is slow.  You are better off using a
bulk accessor pattern.  For example, create a new class called
DirView which contains all the attributes of your Dir EJB.  Then
make a single call to the Dir EJB to get a DirView.  This will cause
only 1 RMI call and save you a huge amount of time.

Do you understand?  I can probably pseudo-code an example
if necessary.

-tim


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, November 14, 2000 3:56 AM
To: Orion-Interest
Subject: EJB Performance Question.


Hi, every one. First i'm sorry for my english.

We use servlet that call EJB. Next is code fraction.

//---------------------------------------------------
public Vector findByFirstPage(DirHome home, Integer rowCount) throws
Exception{

  Vector rows  = new Vector();
  Dir dir = null;

  System.out.println("step 11 time : " + (new java.util.Date()));

  // call EJB
  Collection col = home.findByFirstPage(rowCount.intValue());
  Iterator iter = col.iterator();

  System.out.println("step 12 time : " + (new java.util.Date()));

  while(iter.hasNext()) {
    dir = (Dir)iter.next();
    rows.add(EJBToRow(dir)); //<------- #### bottle neck #####
  }

  System.out.println("step 13 time : " + (new java.util.Date()));

  return rows;

 }
 //---------------------------------------------------


Simple code. In while loop, EJBToRow() method take 3 second each call.

Next code is EJBToRow(). Very Simple. Only call EJB Meber methods.

 //---------------------------------------------------
 public Vector EJBToRow(Dir dir) throws Exception {

  Vector row = new Vector();

System.out.println("step 21 time : " + (new java.util.Date()));

  row.add(dir.getId());
  row.add(new Long(dir.getPId()));
  row.add(dir.getName());
  row.add(new Long(dir.getSerial()));
  row.add(new Long(dir.getChildCount()));
  row.add(new Long(dir.getDepth()));
  row.add(dir.getPMap());
  row.add(dir.getType());
  row.add(dir.getUserId());
  row.add(dir.getGroupId());
  row.add(dir.getOwnerPermR());
  row.add(dir.getOwnerPermW());
  row.add(dir.getOwnerPermX());
  row.add(dir.getGroupPermR());
  row.add(dir.getGroupPermW());
  row.add(dir.getGroupPermX());
  row.add(dir.getOtherPermR());
  row.add(dir.getOtherPermW());
  row.add(dir.getOtherPermX());
  row.add(dir.getCreateDate());
  row.add(dir.getUpdateDate());
  row.add(dir.getExpireDate());
  row.add(dir.getRemark());

System.out.println("step 22 time : " + (new java.util.Date()));

  return row;

 }
 //---------------------------------------------------

What's the key problem?












e-mail
site: [EMAIL PROTECTED]
: www.javanuri.comÀüÈ­
mobile : 02-6257-3002
: 019-255-2855


Reply via email to