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
 

"Transaction Management in OODB Platforms and CORBA"
Vol. 3, Issue 6, P.56

	

Listing 1.

public class MyPersistentObjectExample  {

	// NOTE: this is example code only
  // Don't expect it to compile as is.

  private int _foo;

  private String _bar;

  private transient 
        A_CorbaStruct _myCorbaStruct;

  public MyPersistentObject(int foo, 
                          String bar) {

     this._foo = foo;

     this._bar = bar;

     _myCorbaStruct = new 
              A_CorbaStruct(foo, bar);

  }

  // The transient data is the working data

  public void setFoo(int foo) {

     _myCorbaStruct.foo = foo;

  }
  public void setBar(String bar) {
     _myCorbaStruct.bar = bar;   
  } 
  // Clients use the transient data
  // it is guaranteed to be current.
  public int getFoo() {
     return(_myCorbaStruct.foo);
  }
  public String getBar() {
     return(_myCorbaStruct.bar); 
  }

  public A_CorbaStruct 
     getPersistentObjectExampleAttrs() {

     return(_myCorbaStruct);   
  }
  public void 
     setPersistentObjectExampleAttrs(
              A_CorbaStruct attrs) {
     _myCorbaStruct = attrs;           
  }

  public void postInitializeContents() {
     // move persistent contents to transient
     _myCorbaStruct = new A_CorbaStruct(
                           _foo, _bar);      
  }
  public void preFlushContents() {
     // Move transient contents to persistent
     this._foo = _myCorbaStruct.foo;
     this._bar = _myCorbaStruct.bar;   
  }

  public void save() {
    // This will force a flush
    this._foo = this._foo;
  }
}
  
      
 

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.