Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] declare parents with delegate

Santi Villalba wrote:
Yes, that is the challenge, generate the methods when needed by delegating them to the delegate member.

Hello,

sorry, if I misunderstood or didn't get the point. But
why can't you do something of this sort:

    pointcut proxyCall(Object myTarget)
        : call(* MyTarget.*(..))
          && target(myTarget)
          && within(my.special.rootpackage..*);

    Object around(Object myTarget)
        : proxyCall(myTarget) {

            Object realTarget =
			this.getTarget(myTarget);
            try {
                Object val=proceed(realTarget);
                return val;
            }
            catch(Throwable T) {
                // do something if necessary
                // maybe package it into a Runtime Exception
            }
        }

    private Object getTarget(Object myTarget) {
        return ServiceLocator.getServiceObject(myTarget.getClass());
        // or something similar
    }


Guntis Ozols wrote:
Is there a shortcut for something like this:

class DatabaseMetaDataWrapper implements DatabaseMetaData {

   private DatabaseMetaData delegate;

   // constructor, some implemented methods here

   //===================== DELEGATE METHODS =====================
   public boolean allProceduresAreCallable() throws SQLException {
       return delegate.allProceduresAreCallable();
   }
   public boolean allTablesAreSelectable() throws SQLException {
       return delegate.allTablesAreSelectable();
   }
   // And so on and so on...
   // Problem #1: more than 500 useless lines
   // Problem #2: depends on java version!
   // Also want to advice some of the methods
}


--

Best regards,
Hermann Vosseler



---------------------------------------------------------------
Hermann Voßeler
Baader Wertpapierhandelsbank AG / IT
Weihenstephaner Straße 4
D-85716 Unterschleißheim
eMail: hermann.vosseler@xxxxxxxxxxxxx
Internet: www.baaderbank.de
---------------------------------------------------------------


Back to the top