myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Myfaces Wiki] Update of "TracingMyFacesUsingAspectJ" by JamesRichards
Date Wed, 07 Jun 2006 23:44:09 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Myfaces Wiki" for change notification.

The following page has been changed by JamesRichards:
http://wiki.apache.org/myfaces/TracingMyFacesUsingAspectJ

------------------------------------------------------------------------------
  Here is the aspect upon which the discussion will be based:
  
  {{{
- package com.dbz.lms.aspects;
- 
  import java.io.BufferedWriter;
  import java.io.File;
  import java.io.FileWriter;
@@ -41, +39 @@

  			e.printStackTrace();
  		}
  	}
- 	
- 	pointcut renderResponse(Object cmp) : this(cmp) && call(* FacesContext+.renderResponse());
- 
-     Object around(Object cmp): renderResponse(cmp) {
-     	if (cmp instanceof UIComponentBase) {
-         	UIComponentBase uiCmp = (UIComponentBase)cmp;
-             traceEntry("UIComponent calling renderResponse():" + uiCmp.getId() + ":" + thisJoinPoint.getThis()
+ ":");
-     	} else {
-             traceEntry("Non-UIComponent calling renderResponse():" + cmp + ":" + thisJoinPoint.getThis()
+ ":");
-     	}
-         Object retVal = proceed(cmp);
-         traceExit(cmp.hashCode() + ":" + thisJoinPointStaticPart.getSignature() + " returning
" + retVal); 
-         return retVal;
-     }
- 	
  	
      pointcut myClass(Object obj): this(obj) && 
      	(
@@ -93, +76 @@

      	&& !execution(* UIViewRoot.create*())
      	&& !execution(* ApplicationImpl.get*())
      	&& !execution(* ApplicationImpl.set*(..))
-     	&& !within(com.dbz.lms.aspects.*)
      	&& !execution(String *.toString())
      	&& !execution(String *.hashCode());
  
@@ -216, +198 @@

  
  Upon relaunching your application, once MyFaces actually runs, you should be able to "tail
-f c:\trace.out" to follow the execution of MyFaces.  Note that the file location should be
changed as appropriate for Unix.
  
+ What is this trace doing?  The trace is capturing the major classes upon which MyFaces processing
depends so that the general application flow may be followed.  You will notice that there
are two major parts to the tracing pointcut: inclusive and exclusive.  The inclusive parts:
+ 
+ {{{
+ 
+     	(
+     	    within(ApplicationImpl)
+     	    || within(NavigationHandler)
+     		|| within(ServletFacesContextImpl)
+     	    || within(LifecycleImpl)
+     	    || within(UIViewRoot)
+     	    || within(UIComponentBase)
+     	    || within(UICommand)
+     	    || within(ActionListenerImpl)
+     	)
+ }}}
+ 
+ capture as much information as possible about the application flows.  Each of the included
classes plays a vital role in the lifecycle of MyFaces and piecing together what's happening
when something goes wrong will invariably involve at least a few of the included classes.
 
+ 
+ The exclusive parts:
+ 
+ {{{    	&& !execution(UIComponentBase.new(..))
+     	&& !execution(* ServletFacesContextImpl.getApplication(..))
+     	&& !execution(* ServletFacesContextImpl.getExternalContext(..))
+     	&& !execution(* ServletFacesContextImpl.getM*(..))
+ //...
+     	&& !execution(String *.toString())
+     	&& !execution(String *.hashCode());
+ }}}
+ 
+ are designed to exclude cases where too much output is generated.  The compositional approach
taken by MyFaces results in a large number of similar invocations taking place which obscure
the critial elements of application flow.  Excluding the above cases produces a much cleaner
trace.  Note that in cases where too much output is straining the eyes, adding to the cases
of exclusions will usually make tracing much easier.
+ 

Mime
View raw message