[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[ajdt-dev] AJDT / RAD / AspectPath again :(
|
hello all,
i have been posting long time ago a similar issue, i thought i have solved but i didnt.
Situation is like this
in my workspace i have 2 aspectj project
- myEJB which contains aspect related to ejbs
- myWeb which contains aspect related to web
AS of it is now, myWeb has as project dependency myEJB.
I have one aspect in myEJB which needs to call an aspect in myWeb to get
the current user associated with a request (we are not using JAAS...).
so, what i did was to include in the myEJB/AspectPath the WEB-INF/classes folder
of myWeb
Everything works fine at compile-time..
However, if i run the code at runtime, the aspect in myEJB fails giving a NoClassDefFoundException
for hte aspect defined in myWeb.
*********** sample code , myWeb aspect **********
public aspect TraceUserAspect percflow(loginFilter()){
private UserDTO user;
public TraceUserAspect() {
System.err.println("Creating aspect instance...");
}
public pointcut loginFilter() :
execution(void com.waersystems.ngenweb.login.LoginFilter.doFilter(
ServletRequest,
ServletResponse,
FilterChain));
before() : loginFilter() {
Object[] arguments =
thisJoinPoint.getArgs();
HttpServletRequest req = (HttpServletRequest)arguments[0];
System.err.println("Before. intercepted. path was:" + req.getServletPath());
user = (UserDTO)(
req.getSession().getAttribute(WebConstants.USER_KEY));
if (user != null)
System.err.println("User is:" + user.getUsername());
}
after() returning: loginFilter() {
Object[] arguments = thisJoinPoint.getArgs();
HttpServletRequest req = (HttpServletRequest)arguments[0];
System.err.println("Gotcha! intercepted. path was:" + req.getServletPath
());
user = WebUtils.getLoggedInUser((HttpServletRequest)req);
if (user != null)
System.err.println("User is:" + user.getUsername());
}
public UserDTO getUser() {
return user;
}
}
*************************************************************
*************** sample code. myEJB aspect ***************
public abstract aspect AbstractAuditAspect extends AspectEnablement {
LogHelper log = new LogHelper(LogHelper.class);
AuditFactory auditFactory = AuditFactory.getInstance();
String methodName = "";
/* This pointcut will collect informations from
* two different context..BUT IT'S Not working..
*/
pointcut wormhole(String username, String password) :
cflow(traceLogin(username,password)) && traceChanges();
/* Traces user that logs in */
pointcut traceLogin(String username, String password) :
execution (* com.waersystems.ejb.user.userdetails.UserInfo.addContainer(String,String))
&& args(username, password);
abstract pointcut objectChangeMethod();
abstract pointcut traceChanges();
before() : objectChangeMethod() && if(enableAspect()){
methodName = thisJoinPoint.getSignature
().toString();
}
after(String username, String password) returning : wormhole(username, password) {
System.err.println("INtercepted with wormhole. user is:" + username);
}
after() returning : traceChanges() && if(enableAspect()){
// Getting arguments
//String user = com.waersystems.ejb.aspectj.LoginAspect.aspectOf().getUser();
UserDTO user =
com.waersystems.ngenweb.aspectj.TraceUserAspect.aspectOf().getUser();
}
***********************************************************
what approach shall i follow?
shall i put both aspects in myEJB project and set hte aspectPath to include also myWeb/WEB-INF/classes directory?
i really want to avoid to make myEJB dependent on myWeb just for this issue.. because myWeb is already depending on
myEJB, i want to avoid circular dependencies....
amyone could help?
thanks in advance and regards
marco