Hi
I have several aspects that introduce a bean into several types, used
for management. All except one functions as intented. The culprit in
this case is javax.naming.InitialContext.
In my aop.xml:
<aspectj>
<!-- -showWeaveInfo -verbose -debug -->
<weaver
options="-proceedOnError
-Xlintfile:META-INF/Xlint.properties -showWeaveInfo -verbose -debug">
...
<include within="javax.naming.InitialContext+" />
...
</weaver>
...
<aspects>
...
<aspect
name="no.dnbnor.it01.aspects.NamingServiceAspect" />
<aspect name="no.dnbnor.it01.aspects.BaseAspect" />
...
</aspects>
</aspectj>
My aspect:
public aspect NamingServiceAspect extends BaseAspect {
public interface IInitialContextManagedBean {
public InitialContextManagementBean getManagedBean();
public void setManagedBean(InitialContextManagementBean
context);
}
private InitialContextManagementBean
IInitialContextManagedBean.managementBean;
public InitialContextManagementBean
IInitialContextManagedBean.getManagedBean() {
return this.managementBean;
}
public void IInitialContextManagedBean.setManagedBean(
InitialContextManagementBean context) {
this.managementBean = context;
}
declare parents : javax.naming.Context+ implements
IInitialContextManagedBean;
...
public pointcut nsConstruction() : call(Context+.new(..));
...
after() returning(Context context): nsConstruction(){
if
(thisJoinPointStaticPart.getSignature().getDeclaringType() != context
.getClass()) {
System.err.println("Not context.getClass())");
return;
}
// Check that we have not already managed this context
if (((IInitialContextManagedBean)
context).getManagedBean() != null) {
return;
}
System.out.println("In after nsConstruction");
}
..
}
My testclass:
public class Test {
/**
* @param args
*/
public static void main(String[] args) throws Exception {
Test7 me = new Test7();
me.doIt();
}
public void doIt() throws Exception {
try {
Context ctx1=new InitialContext();
} catch (RemoteException e) {
e.printStackTrace();
} catch (CreateException e) {
e.printStackTrace();
}
}
}
When I run this, I get
java.lang.ClassCastException: javax.naming.InitialContext
at
no.dnbnor.it01.aspects.NamingServiceAspect.ajc$afterReturning$no_dnbnor_
it01_aspects_NamingServiceAspect$1$75cc02b7(NamingServiceAspect.aj:57)
at no.dnbnor.it01.test.Test7.doIt(Test7.java:45)
at no.dnbnor.it01.test.Test.main(Test.java:23)
Exception in thread "main"
In the standard output I do get entries like
[EMAIL PROTECTED] weaveinfo Join point 'constructor-call(void
javax.naming.InitialContext.<init>())' in Type
'no.dnbnor.it01.test.Test7' (Test7.java:45) advised by afterReturning
advice from 'no.dnbnor.it01.aspects.NamingServiceAspect'
(NamingServiceAspect.aj:49)
...
[EMAIL PROTECTED] weaveinfo Extending interface set for type
'com.ibm.ws.naming.util.WsnInitCtx' (WsnInitCtx.java) to include
'no.dnbnor.it01.aspects.NamingServiceAspect$IInitialContextManagedBean'
(NamingServiceAspect.aj)
[EMAIL PROTECTED] weaveinfo Type
'com.ibm.ws.naming.util.WsnInitCtx' (WsnInitCtx.java) has intertyped
field from 'no.dnbnor.it01.aspects.NamingServiceAspect'
(NamingServiceAspect.aj:'no.dnbnor.it01.aspectj.beans.InitialContextMana
gementBean
no.dnbnor.it01.aspects.NamingServiceAspect$IInitialContextManagedBean.ma
nagementBean')
However I never see a intertype declaration for InititalContext - Anyone
have a clue?
Hermod
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
This email with attachments is solely for the use of the individual or
entity to whom it is addressed. Please also be aware that the DnB NOR Group
cannot accept any payment orders or other legally binding correspondence with
customers as a part of an email.
This email message has been virus checked by the anti virus programs used
in the DnB NOR Group.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users