Progress
Open Client
Developer’s Guide


Extending Proxy Objects

For the Java client, ProxyGen actually generates two class files for each object. One contains the implementation and the other is a delegating class that just calls this implementation class. The java-client code accesses the delegating classes. The delegating classes are created so that the Java client is not exposed to implementation details of the proxy. These delegating class are available for inheritance in Java while the implementation classes are final and cannot be extended.

CAUTION: Direct editing of any delegating class generated by ProxyGen is not supported. To modify a delegating class, you must extend (subclass) it.

For example, if we have an Account AppObject and a Tax SubAppObject, ProxyGen generates the implementation classes AccountImpl.java and TaxImpl.java as well as the delegating classes Account.java and Tax.java. A skeleton of what the delegating class Account looks like can be found in Example 5–6.

Account Class (Delegating)
Public class Account
{
  protected AccountImpl m_accountImpl;

  public Account(connect-parameters)
  {
    m_accountImpl = new AccountImpl(connect-parameters);  
  }
  public Add(add-parameters)
  {
    m_accountImpl.Add(add-parameters);
  }
  public Tax createAO_Tax()
  {
    return new Tax(m_accountImpl);
  }
  public Tax createPO_AccountInfo(AccountInfo-parameters)
  {
    return new AccountInfo(m_accountImpl, AccountInfo-parameters);
  }
  public _release()
  {
    m_accountImpl._release();
  }
  ...
} 

Example 5–6: Delegating Classes

Note the protected member variable m_accountImpl. If a SubAppObject or a ProcObject is created, this variable must be passed to its constructor. Example 5–7 shows what the constructor in the Tax class looks like.

Tax Class Constructor
Public class Tax
{
  protected TaxImpl m_taxImpl;

  public Tax(AccountImpl accountImpl)
  {
    m_taxImpl = new TaxImpl(accountImpl);  
  }
     
} 

Example 5–7: SubAppObject/ProcObject Constructors

The member variables are protected rather than private to allow a Java client to extend these classes. Example 5–8 shows how a client might extend the Account class as well as the Tax class.

NOTE: To extend a SubAppObject or ProcObject, you must also extend the associated AppObject.

Account and Tax Class Extensions
Public class MyAccount extends Account
{
  public MyAccount(parameters)
  {
    super(parameters);
  }
  public MyTax createAO_MyTax()
  {
    return new MyTax(m_accountImpl);
  }
  public sendMail()  // a new method
  {
    /*** Do my own thing ***/
  }
}

Public class MyTax extends Tax
{
  public MyTax(AccountImpl accountImpl)
  {
    super(accountImpl);
  }
  public SetStatus(int status)  // override Tax’s method
  {
    /*** Do my own thing and then defer to superclass ***/
    super.SetStatus(status);  
  }
} 

Example 5–8: Class Extensions

Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095