Community
Participate
Working Groups
Following is from a post to the newsgroup. Although he has resolved the situation, he shouldnt be getting a BCException. --- Never mind. I was using the "setSessionContext" as the pointcut name. This name is used inside the advice as well. Sorry for the confusion Thanks Sekar Gopinathan wrote: > Hi, > I am using aspects to do make my code independant of the J2EE container > without going into Spring framework. In order to accomplish this I have > a stateless session EJB that merely acts as wrapper providing > transactional capabilities. Inside the EJB, I instantialte a > BusinessService class and set the BusinessSessionContext(contains info > such as the current user). For every call to the ejb I set the context > and then call the business methods in the service object. I am planning > to refactor the application such that aspect sets the "business session > context" into the service object before calling the business methods of > the service. This will let the service know the currently logged on user > and hence can use this info during audit.(Which again is an aspect). So > I wrote two aspects > 1. for setting the session context > 2. for doing the audit after each service is completed > The aspects look like > 1. > public aspect Context { > pointcut setSessionContext(AbstractBusinessServiceEjbBean > businessServiceEjb): > call(* AbstractBusinessService.execute(..)) && > target(businessServiceEjb) ; > before(AbstractBusinessServiceEjbBean businessServiceEjb) throws > InvalidCTXParamException :setSessionContext(businessServiceEjb){ > SessionContext sessionContext=new SessionContext(); > sessionContext.storeContext(Constants.SESSION_CONTEXT_USER_KEY,businessServiceEjb.getUserId()); > businessServiceEjb.getService().setSessionContext(sessionContext); > } > } > 2. > public aspect DoAudit { > pointcut writingAudit() : > call(* AuditService.execute(..)); > declare warning : writingAudit() && !within(DoAudit) > : "Only DoAudit policy can call AuditService"; > pointcut doAudit(AbstractBusinessService businessService) : > execution(* execute(..)) && this(businessService); > after(AbstractBusinessService businessService) throws SystemException : > doAudit(businessService) { > AuditService auditStep=null; > auditStep=(AuditService)new > BusinessFactory().create(AuditService.class.getName()); > ((AbstractBusinessService)auditStep).setSessionContext(businessService.getSessionContext()); > auditStep.execute((BusinessStep)businessService); > } > } > When I clean the project and rebuild the project, I get a BCEException > right around the line > "((AbstractBusinessService)auditStep).setSessionContext(businessService.getSessionContext());" > Exception reads: > BCE Exception:illegal change to pointcut declaration: > setSessionContext(BindingTypePattern(com.xxx.backoffice.common.sb.Abs...(not > clear after this) > Note: I had my "incremental compile" turned on. > I am kind of stuck. Any help here appreciated. > Thanks > SG
related to something I am working on...
Under another bug I have just removed the unhelpful exception 'illegal change to pointcut declaration'. There were situations where it was incorrectly coming out and there was a better message hiding behind it that users wouldn't typically see. I'm closing this as resolved too :)