Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » AJDT » aspect in J2ee
aspect in J2ee [message #585389] Tue, 21 December 2004 01:07
Eclipse UserFriend
Originally posted by:

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
public aspect Context {

pointcut setSessionContext(AbstractBusinessServiceEjbBean
call(* AbstractBusinessService.execute(..)) &&
target(businessServiceEjb) ;

before(AbstractBusinessServiceEjbBean businessServiceEjb) throws
InvalidCTXParamException :setSessionContext(businessServiceEjb){
SessionContext sessionContext=new SessionContext();

sessionContext.storeContext(Constants.SESSION_CONTEXT_USER_K EY,businessServiceEjb.getUserId());
businessServiceEjb.getService().setSessionContext(sessionCon text);


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;
((AbstractBusinessService)auditStep).setSessionContext(busin essService.getSessionContext());

When I clean the project and rebuild the project, I get a BCEException
right around the line
" ((AbstractBusinessService)auditStep).setSessionContext(busin essService.getSessionContext()); "

Exception reads:
BCE Exception:illegal change to pointcut declaration:
clear after this)

Note: I had my "incremental compile" turned on.

I am kind of stuck. Any help here appreciated.

Previous Topic:How to access 'this'
Next Topic:aspect in J2ee
Goto Forum:

Current Time: Tue Oct 16 00:22:24 GMT 2018

Powered by FUDForum. Page generated in 0.01858 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top