donators

n@work Internet Informationssysteme GmbH
Your ad here

Advertising

DevBlog: FLOW3 aspects

By: Thomas

22.02.08 15:17 Age: 320 days

After getting my first output from FLOW3 yesterday I continued my tests and gave aspects a try. It took my some time to get my aspect running but eventually it worked out.

Same as the first "Hello Worl" test, this test is fairly simple. All I do is, definig an aspect called "AspectTest" (Yeah... This some fancy kind of a name) which is executed around every method in all classes beginning with "T3_ThomasTest_":

  1.  
  2. /**
  3. * Advice to check if the static function is proxied correctly (will result in a fatal error
  4. * if it doesn't)
  5. *
  6. * @around method(T3_ThomasTest_.*->.*())
  7. */
  8. public function someTestAdvice(T3_FLOW3_AOP_JoinPointInterface $joinPoint) {
  9. $startTime = microtime(true);
  10.  
  11. $returnResult = $joinPoint->getAdvicechain()->proceed($joinPoint);
  12.  
  13. $endTime = microtime(true);
  14. $logMessage = $joinPoint->getClassName().'->'.$joinPoint->getMethodName().' execution time: '.(($endTime -$startTime)*1000).'ms';
  15. $this->logger->log($logMessage, T3_Log_LoggerInterface::SEVERITY_DEBUG);
  16.  
  17. return $returnResult;
  18. }

What the advice actually does is nothing outstanding. Before the target method is executed, it stores the timestamp in a variable. The next step is to process the advice chain which means, that all other advices at this point are exceuted until the target method is reached. The result is passed through the calls and eventually arrives our advice.

When it arrives, the timestamp is stored again and the difference between both timestamps is calculated and written to a logmessage.

This logmessage is than handed over to the Logger Interface. How it is processed further is not decided by the advice because we only "talk" to a generic Logger interface. The final implenetation of the logging mechanism has to be configured via a Components.ini file. In my case I configured the usage of the "SimpleFileLogger" Because it's the only implemeted Logging mechanism yet.

You can download the complete "ThomasTest" package at the end of this article.

Greets,
Thomas


Please leave a comment

4 Responses to “DevBlog: FLOW3 aspects”

#1: Tim commented on Friday, 22-02-08 18:50

Gravatar: Tim

Hi Thomas,

a overflow:scroll for pre Tags will fix the Code Block ;-)
Looks strange...

Regards,
Tim


#2: Thomas commented on Saturday, 23-02-08 18:17

Gravatar: Thomas

Hi Tim,
which browser do you use. It looks fine on Safari and Firefox on my systems. ^^

Greets,
Thomas


#3: Tschüge commented on Sunday, 24-02-08 10:55

Gravatar: Tschüge

Hallo,

Ich wollte FLOW3 auch mal testen, kann aber nirgends einen Download-Link finden. Kannst Du mir ev. weiter helfen?

Besten Dank
Tschüge


#4: Thomas commented on Monday, 25-02-08 09:11

Gravatar: Thomas

Hi,
you have to checkout FLOW3 from subversion because there is no distribution package available yet. See flow3.typo3.org for details.

Greets,
Thomas


Sorry, comments are closed for this post.

Calendar

January 2008
M T W T F S S
« Dec   Feb »
 1203456
7080910111213
14151617181920
21222324252627
28293031  

Latest comments

  • Anoop

    Thomas, Looking forward to it and like Mario said if you need a beta tester I sign up too! Cheers.

  • Mario Rimann

    Hi Thomas Sounds great, that you'll keep the site up and running! I use it pretty often to look ...

  • Thomas Hempel

    Hi Klaus, sorry, but you're a a few weeks too late. ;-) Greets, Thomas...

  • Klaus

    Hi, great idea, i am using the great app, but now i need a license... Thanks a lot

  • John Smyth

    How do we get a copy of this, I have been watching the t3con mailing list but no links have appeared...

Advertising