donators

n@work Internet Informationssysteme GmbH
Your ad here

Advertising

DevBlog: FLOW3 aspects

By: Thomas

22.02.08 15:17 Age: 284 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

February 2008
M T W T F S S
« Jan   Mar »
 123
4506708910
11121314151617
18192021222324
2526272829  

Latest comments

  • paul blondiaux

    Waouuu ! Great, 1000 thanks, THomas. I'm already having great fun trimming the app. ;)...

  • paul blondiaux

    Waouuu ! Great, 1000 thanks, THomas. I'm already having great fun trimming the app. ;)...

  • Thomas

    Hi, lottery closed. Tremendous number of attendees... ;-) Winners should have their licenses in t...

  • Holger Gebhardt

    I was really happy to find this nice tool, over your blog. i used keepassx, but its really uncomfort...

  • Firma

    Could anybody tell me where I can get more about setting Smarty with Eclipse ?

Advertising