Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Equinox Aspects LTW: capturing aspect instantiation

Hi all!
   Does Equinox Aspects supports pointcuts defined on other aspects defined in the aop.xml file? That is, I have in my bundle:

<?xml version="1.0" encoding="UTF-8"?>
<aspectj>
    <aspects>
    <!-- SWT Thread Safety -->
   <concrete-aspect name="it.uniba.di.cdg.jtalk.aspects.SWThreadingAspect" 
     extends="it.uniba.di.cdg.penelope.ui.swt.AbstractSWThreadingAspect">
     <pointcut name="scope" _expression_="within( it.uniba.di.cdg.jtalk.ui..* )"/>
   </concrete-aspect>

             <!-- Aspect Injector -->
             <concrete-aspect name="it.uniba.di.cdg.jtalk.aspects.AspectInjectionAspect" 
     extends="it.uniba.di.cdg.penelope.AbstractAspectInjectionAspect">
     <pointcut name="scope" _expression_="within( it.uniba.di.cdg.jtalk.aspects.SWThreadingAspect )"/>
   </concrete-aspect>
    </aspects>
</aspectj>

I want AspectInjectionAspect to capture the instantiation of the SWThreadingAspect:

@Aspect // Work in progress!
public abstract class AbstractAspectInjectionAspect {

@Pointcut( "" )
protected abstract void scope();
@Pointcut( "scope() && execution( public it.uniba.di.cdg.penelope.IConfigurableAspect+.new() ) && this( aspectInstance )" )
protected void aspectInstantiation( Object aspectInstance ) { }
@After( "aspectInstantiation( aspectInstance )" )
public final void afterActivation( Object aspectInstance ) {
System.out.println( "WOW! Instantiated aspect: " + aspectInstance );
}
}

The target aspect is defined as (IConfigurableAspect is just a marker interface with no method):

@Aspect
public abstract class AbstractSWThreadingAspect implements IConfigurableAspect {

// ... other stuff 
@Pointcut( "" )
public abstract void scope();

public AbstractSWThreadingAspect() {
super();
System.out.println( "AbstractSWThreadingAspect()" );
}
// ...  other stuff
}

My RCP application works ok (the SWT Aspect is correctly woven at load time but I see that the instantiation is not captured by my injector aspect. Is this a completely doomed-to-failure approach? (Using AJDT 2.0.1 and eclipse 3.5.1 here)

Thanks
Mario

--
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." - Brian W. Kernighan

Back to the top