Thanks thats a good idea, we actually found one just a couple of days ago that is
similar, but doesnt require inheritance.

Create a wraperclass, lets call it "SQLExer" and have it implement execute(), which
just does the logic below.

Funny  you should metion smalltalk blocks, I was just mentioning to some co-workers
that that would be the perfect solution for this problem :)

-thanks
Joel

Per Spilling wrote:

> Hi Joel,
>
> I would suggest using a base class which implements the common functionality in a
> generic way, combined with inner classes used as codeblocks (in the Smalltalk
> tradition) which are passed to the baseclass, i.e. something like this:
>
> public interface SqlStatment() {
>   public Result execute();
> };
>
> public class MyEjbBase {
>   public Result executeSql( SqlStatement s )
>   {
>     while ((retryCount < maxRetries) && (!success))
>     {
>       try {
>         result = s.execute()
>         success = true
>       } catch(SqlException sqe) {
>         retryCount = retryCount + 1
>       } finally {
>         ...
>       }
>       return result;
>     }
>   }
> }
>
> public class DerivedEjb extends MyEjbBase {
>   public void ejbFindByPrimaryKey()
>   {
>     ...
>     result = executeSql( new SqlStatement() { ... } );
>     ...
>   }
> }
>
> etc.
>
> -Per
>
> --
> Per Spilling <[EMAIL PROTECTED]>
> Objectware AS, Slemdalsveien 37, Pb. 137 Vinderen, 0319 Oslo, Norway
> Tel: +47 23199200 Mobile: +47 90915115 Fax: +47 23199201
>
> ===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff EJB-INTEREST".  For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to