All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.ibm.beans.samples.daps.sql.Common

java.lang.Object
   |
   +----com.ibm.beans.samples.daps.sql.Common

public abstract class Common
extends Object
implements Serializable
The Common class encapsulates common behavior and functionality for the Connection and Statement classes. This behavior includes support for background thread execution, property change events (both firing and listeners), serialization and the successful and exception properties.

The Common class is an abstract class.

See Also:
Connection, Statement, CommonBeanInfo

Variable Index

 o backgroundThread
Background thread if executeInBackground is true.
 o changes
Supporting class to provide easy firing of property change events.
 o exception
An ouput exception for the latest database operation.
 o executeInBackground
A flag that signifies whether database operations are to be performed asynchronously in a background thread or synchronously in the current thread.
 o INITIAL
Initial value of current background thread task.
 o successful
An output flag that signifies whether the method executed was successful.
 o task
Field that signifies which task is being executed in the background.

Constructor Index

 o Common()
Default constructor.

Method Index

 o addPropertyChangeListener(PropertyChangeListener)
Add a property change event listener.
 o coordinateBackgroundThread()
Method to ensure background exists if the user requires it and it doesn't exist if the user doesn't require it.
 o finalize()
Finalize this object.
 o firePropertyChange(String, Object, Object)
Fire a property change event.
 o getException()
Get the exception flag for the latest database operation.
 o getExecuteInBackground()
Get the executeInBackground flag for the database operations.
 o getSuccessful()
Get the successful flag for the latest database operation.
 o initialize()
Common initialization for both initial and serialized instantiation.
 o myNotify()
Determine whether to perform operation in background thread or in current thread.
 o performWork()
Call method based on the background task to be performed.
 o performWorkAndSetStatus()
Call method based on the background task to be performed and set status.
 o removePropertyChangeListener(PropertyChangeListener)
Remove a property change event listener.
 o runBackgroundThread()
Actual background thread operation running in this Common object.
 o setException(Exception)
Set the exception field.
 o setExecuteInBackground(boolean)
Set the executeInBackground flag for the database operations.
 o setSuccessful(boolean)
Set the successful operation flag.
 o waitForBackgroundWork()
Method to wait for and drive actual database work is executing in a background thread.

Variables

 o executeInBackground
 protected boolean executeInBackground
A flag that signifies whether database operations are to be performed asynchronously in a background thread or synchronously in the current thread.

This property is used by the myNotify() method.

 o exception
 protected transient Exception exception
An ouput exception for the latest database operation.

 o successful
 protected transient boolean successful
An output flag that signifies whether the method executed was successful.

 o INITIAL
 protected static final transient int INITIAL
Initial value of current background thread task.

 o task
 protected transient int task
Field that signifies which task is being executed in the background.

 o changes
 protected PropertyChangeSupport changes
Supporting class to provide easy firing of property change events.

 o backgroundThread
 protected transient Thread backgroundThread
Background thread if executeInBackground is true.

Constructors

 o Common
 public Common()
Default constructor.

Methods

 o finalize
 protected void finalize() throws Throwable
Finalize this object.

Throws: Throwable
Possibly thrown by the superclass.
Overrides:
finalize in class Object
 o getExecuteInBackground
 public boolean getExecuteInBackground()
Get the executeInBackground flag for the database operations.

Returns:
The executeInBackground flag for the database operations.
 o setExecuteInBackground
 public synchronized void setExecuteInBackground(boolean executeInBackground)
Set the executeInBackground flag for the database operations.

This value is used by the myNotify() method.

Fire the property change event for the executeInBackground boolean.

Parameters:
executeInBackground - The executeInBackground flag for the database operations.
 o getException
 public Exception getException()
Get the exception flag for the latest database operation.

Returns:
The exception flag for the last database operation.
 o setException
 protected void setException(Exception exception)
Set the exception field.

This method can only be called internally.

Fire the property change event for the exception Exception.

Parameters:
exception - The exception for the latest database operation.
 o getSuccessful
 public boolean getSuccessful()
Get the successful flag for the latest database operation.

Returns:
The successful flag for the last database operation.
 o setSuccessful
 protected void setSuccessful(boolean successful)
Set the successful operation flag.

This method can only be called internally.

Fire the property change event for the successful boolean.

Parameters:
successful - The successful database operation flag.
 o firePropertyChange
 public void firePropertyChange(String propertyName,
                                Object oldValue,
                                Object newValue)
Fire a property change event.

This method is necessary so the dip code can see events.

Parameters:
propertyName - The String name of the property.
oldValue - The old value of the property.
newValue - The new value of the property.
 o coordinateBackgroundThread
 protected synchronized void coordinateBackgroundThread()
Method to ensure background exists if the user requires it and it doesn't exist if the user doesn't require it.

In JDK 1.1 it is impossible to destroy() a thread once it has been created.

This method uses the executeInBackground property.

This method sets the backgroundThread property.

 o initialize
 protected void initialize()
Common initialization for both initial and serialized instantiation.

 o addPropertyChangeListener
 public synchronized void addPropertyChangeListener(PropertyChangeListener l)
Add a property change event listener.

Parameters:
l - A listener.
 o removePropertyChangeListener
 public synchronized void removePropertyChangeListener(PropertyChangeListener l)
Remove a property change event listener.

Parameters:
l - A listener.
 o myNotify
 protected synchronized void myNotify()
Determine whether to perform operation in background thread or in current thread.

If the executeInBackground property is true, standard java.lang.Object notify() is executed. Otherwise, the background task is performed via direct call.

The executeInBackground property is used in this method.

 o runBackgroundThread
 protected void runBackgroundThread()
Actual background thread operation running in this Common object.

This is called from the worker thread.

 o waitForBackgroundWork
 protected synchronized void waitForBackgroundWork()
Method to wait for and drive actual database work is executing in a background thread.

waitForBackgroundWork has to be synchronized for wait() to work.

 o performWorkAndSetStatus
 protected void performWorkAndSetStatus()
Call method based on the background task to be performed and set status.

The exception and successful properties are set by this method.

 o performWork
 protected abstract void performWork() throws Exception
Call method based on the background task to be performed. The caller has guaranteed this will NOT be called for the INITIAL task.

Returns:
Whether operation was successful or not.
Throws: Exception
Thrown if any exception.

All Packages  Class Hierarchy  This Package  Previous  Next  Index