<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>aop &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://wordpress.com/tag/aop/</link>
	<description>Feed of posts on WordPress.com tagged "aop"</description>
	<pubDate>Sat, 30 Aug 2008 13:23:32 +0000</pubDate>

	<generator>http://wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[AOP utilizando @AspectJ e Spring]]></title>
<link>http://michelzanini.wordpress.com/?p=54</link>
<pubDate>Thu, 28 Aug 2008 02:53:14 +0000</pubDate>
<dc:creator>michelzanini</dc:creator>
<guid>http://michelzanini.wordpress.com/?p=54</guid>
<description><![CDATA[Nesse artigo vou explicar os conceitos básicos de AOP e mostrar um exemplo inicial de como isso é ]]></description>
<content:encoded><![CDATA[<p>Nesse artigo vou explicar os conceitos básicos de AOP e mostrar um exemplo inicial de como isso é feito utilizando @AspectJ 5 e Spring.</p>
<p>A Programação Orientada a Aspectos (AOP) complementa a programação orientada a objetos, provendo uma nova forma de pensar sobre a arquitetura da aplicação.</p>
<p>Na programação orientada a objetos encapsulamos as responsabilidades em classes. Já na AOP, as responsabilidades são encapsuladas em um aspecto. Um aspecto permite a modularização de interesses que geralmente aparecem espalhados por várias classes do sistema (denominados de interesses transversais – <em>crosscutting concerns</em>), como o gerenciamento de transações, por exemplo.</p>
<p>Veja a imagem abaixo. Se compreendermos as linhas horizontais como classes, veremos que os interesses de segurança, transação, etc. são transversais, ou seja, repetidos entre várias classes. A AOP contribui no sentido de retirar essas funcionalidades das classes e encapsula-las em aspectos, sem alterar o comportamento do sistema.</p>
<p><img src="http://michelzanini.wordpress.com/files/2008/08/aop-cutting.png" alt="" /></p>
<h2>Conceitos</h2>
<p><strong>Aspect</strong>: é a unidade modular (funcionalidade) que encapsula interesses que atravessam vários objetos dentro do sistema.</p>
<p><strong>Join Point</strong>: é um ponto durante a execução do programa que poderá ser afetado pelo aspecto. Um join point pode ser, por exemplo, a execução de um método do programa.</p>
<p><strong>Point Cut</strong>: é uma expressão escrita em uma linguagem específica para a finalidade de selecionar join points (pontos de execução).</p>
<p><strong>Advice</strong>: quando um join point é atingido, e selecionado pelo point cut, uma ação será executada. Essa ação é determinada advice.</p>
<p><strong>Objeto Alvo</strong>: é o objeto que está sendo interceptado por um ou mais aspectos.</p>
<p><strong>Proxy AOP</strong>: é o objeto criado pelo framework AOP para implementar a ligação entre o aspecto e o objeto alvo.</p>
<p>Veja na imagem abaixo. Durante a execução do programa, vários join points serão “atingidos”. No suporte a @AspectJ do Spring Framework (veremos exemplos a seguir) um join point é sempre a execução de um método. Dessa forma, imagine que cada um dos 6 join points abaixo representem 6 diferentes métodos. Um point cut é uma expressão, em linguagem específica, que seleciona quais dos 6 métodos (join points) serão afetados pelo aspecto. Nesse caso, imagine que os 3 joint points verdes foram atingidos pela expressão pointcut. O advice é a ação que irá executar quando eles foram atingidos, nesse caso, o advice será executado 3 vezes.</p>
<p><img src="http://michelzanini.wordpress.com/files/2008/08/point-cut.png" alt="" /></p>
<h2>Tipos de Advice</h2>
<p>No AspectJ existem 5 tipos diferentes de advice:</p>
<ul>
<li><strong>Before</strong>: ação do advice executa antes do join point.</li>
</ul>
<ul>
<li><strong>After returning</strong>: ação do advice executa depois do joint ser executado com sucesso, ou seja, sem lançar exceção.</li>
</ul>
<ul>
<li><strong>After throwing</strong>: ação do advice executa depois do joint ser executado com erro, ou seja, somente quando ele lançar uma exceção.</li>
</ul>
<ul>
<li><strong>After (finally)</strong>: ação do advice executa depois do joint ser executado independente de ter causado ou não exceção.</li>
</ul>
<ul>
<li><strong>Around</strong>: advice que envolve a execução de um joint point. Com ele é possível codificar ações antes e depois do join point. Inclusive é possível alterar valores passados como parâmetro, como retorno, ou nem mesmo chamar o método do objeto alvo.</li>
</ul>
<h2>Exemplo concreto utilizando o suporte a @AspectJ com Spring</h2>
<p>A partir da versão 2.0 do Spring Framework é suportado o uso do @AspectJ 5 de forma integrada ao seu container. Ainda é possível declarar aspectos por XML, como nas versões anteriores, porém agora é possível declarar aspectos com uso de anotações.</p>
<p>Para implementar um aspecto é necessário três coisas:</p>
<ul>
<li>Colocar os jars ‘aspectjrt.jar’ e ‘aspecjtweaver.jar’ no classpath, juntamente com os jars tradicionais do Spring.</li>
</ul>
<ul>
<li>Declarar no applicationContext.xml o uso de aspectos com declaração por anotações, dessa forma:&#60;aop:aspectj-autoproxy /&#62;.</li>
</ul>
<ul>
<li>Criar uma classe anotada com @Aspect para definir o aspecto. Utilizar uma anotação de advice (before, after ou around) e definir uma expressão point cut para selecionar quais joint points o aspecto afetará.</li>
</ul>
<p>Veja um exemplo abaixo:</p>
<p><img src="http://michelzanini.wordpress.com/files/2008/08/app-context-conceitos.png" alt="" /></p>
<p><img src="http://michelzanini.wordpress.com/files/2008/08/aspecto-exemplo.png" alt="" /></p>
<p>Repare que a expressão <strong>“execution(* xyz.abc.ClienteDao.*(..))”</strong> é o point cut e a anotação @Before é o advice. A linguagem do point cut é específica do @AspectJ e sua documentação pode ser encontrada no site da biblioteca. Explicando a expressão em detalhes:</p>
<ul>
<li><strong>execution</strong>: Qualquer execução de método.</li>
</ul>
<ul>
<li><strong>Primeiro asterisco da expressão</strong>: que tenha qualquer visibilidade e retorne qualquer tipo de parâmetro.</li>
</ul>
<ul>
<li><strong>xyz.abc</strong>: pacote que estão a(s) classe(s) que o point cut afetará.</li>
</ul>
<ul>
<li><strong>ClienteDao</strong>: a classe afetada pelo point cut.</li>
</ul>
<ul>
<li><strong>Segundo asterisco da expressão</strong>: qualquer método da classe ClienteDao.</li>
</ul>
<ul>
<li><strong> (..)</strong>: O método pode ter qualquer quantidade de parâmetros, de qualquer tipo.</li>
</ul>
<p>Dessa forma podemos dizer que o método ‘realizarAcao’ será executado antes que qualquer método da classe ClienteDao executar.</p>
<p>É importante lembrar que o suporte à @AspectJ do Spring, como mostrado no exemplo, só selecionará join points que forem beans gerenciados pelo Spring. Ou seja, no exemplo acima o 'ClienteDao' tem que ser um bean no application context do Spring.</p>
<p>No próximo artigo veremos como implementar uma solução simples de auditoria utilizando AOP com Spring e @AspectJ.</p>
<p>Abraços,<br />
Michel Zanini.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[XA, JNDI and Bitronix, part 4: dancing on the happy path]]></title>
<link>http://ourcraft.wordpress.com/?p=531</link>
<pubDate>Tue, 19 Aug 2008 14:22:58 +0000</pubDate>
<dc:creator>danielmeyer</dc:creator>
<guid>http://ourcraft.wordpress.com/?p=531</guid>
<description><![CDATA[In part 3, we tried our first JMS message send; but even after we wrapped the message send in a tran]]></description>
<content:encoded><![CDATA[<p>In <a href="http://ourcraft.wordpress.com/2008/08/18/xa-jndi-and-bitronix-part-3/">part 3</a>, we tried our first JMS message send; but even after we wrapped the message send in a transaction using AOP, BTM still reported that "resource ‘activemq/QueueConnectionFactory’ cannot be used outside XA transaction scope."  Today we'll work to resolve that issue.</p>
<h2>Both Sends and Receives Need Transactions</h2>
<p><a href="http://ourcraft.wordpress.com/2008/08/18/xa-jndi-and-bitronix-part-3/#comment-179">Ludovic's helpful comment on yesterday's post</a> confirms that we need to make sure both sends and receives are in transactions.  As of yesterday, we were only wrapping the message sends, but not receives, in a transaction -- at least that was what we were trying to do!  As it turns out, the transaction-wrappage of the sends was unsuccessful, while on the other hand we were accidentally successfully wrapping the receives!  Here's how it happened:<br />
<a name="if-it-aint-a-bean"></a></p>
<h2>Wrapping Sends: If It Ain't A Bean...</h2>
<p>As you may recall from yesterday, the pointcut I had defined for applying transaction advice to message sends was as follows:</p>
<p>[sourcecode language='xml']<br />
        <aop:pointcut id="messageReceiveOperation" expression="execution(void com.example.dmn.JndiBitronixTest.transactedSendMessage(..))" /><br />
[/sourcecode]</p>
<p>But as Keith points out, since my JndiBitronixTest class is not defined as a bean in my Spring beans files, the transaction advice will not be applied to the transactedSendMessage method execution.  Oops!  I didn't realize that Spring AOP advice applied only to beans!  Fixing that is easy enough: the transactedSendMessage method calls one layer down into the MessageSender class, which <em>is</em> defined as a bean.  We can just start the transaction there instead:</p>
<p>[sourcecode language='xml']<br />
        <aop:pointcut id="messageSendOperation" expression="execution(void com.example.dmn.MessageSender.sendMessage(..))" /><br />
[/sourcecode]</p>
<h2>Wrapping Receives: Forgotten Advice</h2>
<p>I was looking in the main beans file to verify that MessageSender was defined as a bean when I saw a surprising thing:  I already had transactional advice on the message receives, including the following pointcut:</p>
<p>[sourcecode language='xml']<br />
        <aop:pointcut id="messageReceiveOperation" expression="execution(void com.example.dmn.MessageProcessor.processIt(..))" /><br />
[/sourcecode]</p>
<p>This advice came along when I brought this code over from <a href="http://ourcraft.wordpress.com/2008/07/29/xa-the-conclusion-of-the-example/">my original XA example manual test</a> that runs only on an app server.  I consolidated this advice with the send advice into the spring-beans-bitronix.xml file to yield this advice:</p>
<p>[sourcecode language='xml']<br />
   <br />
       <br />
           <br />
       <br />
    </p>
<p>   <br />
        <aop:pointcut id="messageSendOperation" expression="execution(void com.example.dmn.MessageSender.sendMessage(..))" /><br />
       <br />
    </p>
<p>   <br />
        <aop:pointcut id="messageReceiveOperation" expression="execution(void com.example.dmn.MessageProcessor.processIt(..))" /><br />
       <br />
   <br />
[/sourcecode]</p>
<p>And this time both pointcuts point to classes that are Spring beans.  :)<br />
<a name="happy-path-seems-to-work"></a></p>
<h2>Happy Path Seems to Work</h2>
<p>Now our integration test can send a JMS message and the listener picks it up from the queue and writes it to the database, without exceptions or stack traces.  Furthermore, when I bump the log level to DEBUG for Bitronix classes, in my log4j.properties file:</p>
<p>[sourcecode language='php']<br />
log4j.logger.bitronix.tm=DEBUG<br />
[/sourcecode]</p>
<p>Then I see encouraging looking XA-type messages like the following:</p>
<p>[sourcecode language='php']<br />
DEBUG bitronix.tm.BitronixTransaction  - committing, 2 enlisted resource(s)<br />
DEBUG bitronix.tm.BitronixTransaction  - changing transaction status to PREPARING<br />
DEBUG bitronix.tm.journal.TransactionLogAppender  - between 19089 and 19193, writing a Bitronix TransactionLogRecord with status=PREPARING, recordLength=96, headerLength=28, time=1219154728262, sequenceNumber=11, crc32=-1825120209, gtrid=737072696E672D62746D0000011BDB48D3FF00000000, uniqueNames=XAOracleDS,activemq/QueueConnectionFactory<br />
DEBUG bitronix.tm.journal.TransactionLogAppender  - disk journal appender now at position 19193<br />
DEBUG bitronix.tm.twopc.AbstractPhaseEngine  - executing phase on 2 resource(s) enlisted in 1 position(s) in natural position order</p>
<p>...</p>
<p>DEBUG bitronix.tm.BitronixTransaction  - changing transaction status to PREPARED<br />
...</p>
<p>DEBUG bitronix.tm.twopc.Preparer  - successfully prepared 2 resource(s)<br />
DEBUG bitronix.tm.BitronixTransaction  - 2 interested resource(s)<br />
DEBUG bitronix.tm.BitronixTransaction  - changing transaction status to COMMITTING (forced)<br />
...</p>
<p>DEBUG bitronix.tm.BitronixTransaction  - changing transaction status to COMMITTED</p>
<p>[/sourcecode]</p>
<h3>There's Also a One-Phase Commit In There (and that's good)</h3>
<p>Before I found that two-phase commit sequence in the log, I found another sequence farther up</p>
<p>[sourcecode language='php']</p>
<p>DEBUG bitronix.tm.BitronixTransaction  - committing, 1 enlisted resource(s)<br />
DEBUG bitronix.tm.BitronixTransaction  - changing transaction status to PREPARING<br />
DEBUG bitronix.tm.journal.TransactionLogAppender  - between 18721 and 18813, writing a Bitronix TransactionLogRecord with status=PREPARING, recordLength=84, headerLength=28, time=1219154728200, sequenceNumber=7, crc32=-667556454, gtrid=737072696E672D62746D0000011BDB48D4AA00000003, uniqueNames=activemq/QueueConnectionFactory<br />
DEBUG bitronix.tm.journal.TransactionLogAppender  - disk journal appender now at position 18813<br />
DEBUG bitronix.tm.twopc.Preparer  - 1 resource enlisted, no prepare needed (1PC)<br />
DEBUG bitronix.tm.BitronixTransaction  - changing transaction status to PREPARED<br />
DEBUG bitronix.tm.journal.TransactionLogAppender  - between 18813 and 18905, writing a Bitronix TransactionLogRecord with status=PREPARED, recordLength=84, headerLength=28, time=1219154728200, sequenceNumber=8, crc32=-2001767057, gtrid=737072696E672D62746D0000011BDB48D4AA00000003, uniqueNames=activemq/QueueConnectionFactory<br />
DEBUG bitronix.tm.journal.TransactionLogAppender  - disk journal appender now at position 18905<br />
DEBUG bitronix.tm.BitronixTransaction  - 1 interested resource(s)<br />
DEBUG bitronix.tm.BitronixTransaction  - changing transaction status to COMMITTING<br />
DEBUG bitronix.tm.journal.TransactionLogAppender  - between 18905 and 18997, writing a Bitronix TransactionLogRecord with status=COMMITTING, recordLength=84, headerLength=28, time=1219154728200, sequenceNumber=9, crc32=236131807, gtrid=737072696E672D62746D0000011BDB48D4AA00000003, uniqueNames=activemq/QueueConnectionFactory<br />
...</p>
<p>DEBUG bitronix.tm.BitronixTransaction  - changing transaction status to COMMITTED<br />
[/sourcecode]</p>
<p>I worried about line 8 where it said that only one resource was enlisted and so only a one-phase commit (1PC) was needed -- "What happened to the database resource?" I wondered.  But then I remembered that this must be the message <em>send</em> (I tend to forget that that's being transacted too), and the send does not involve the database resource.</p>
<h2>Next Steps</h2>
<p>I'd still like to have my integration test query the database to verify that the record really made it in there.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[AOP Online Publishing Awards 2008 - 01 Oct 2008]]></title>
<link>http://internetmedianews.wordpress.com/?p=14</link>
<pubDate>Fri, 08 Aug 2008 14:53:53 +0000</pubDate>
<dc:creator>jonllo</dc:creator>
<guid>http://internetmedianews.wordpress.com/?p=14</guid>
<description><![CDATA[Now in their seventh year, the AOP Awards will be presented at a celebratory dinner on Wednesday 1s]]></description>
<content:encoded><![CDATA[<p>Now in their seventh year, the AOP Awards will be presented at a celebratory dinner on Wednesday 1st October at the London Hilton Park Lane. Further details can be found at the <a title="AOP Awards 2008" href="https://www.ukaopevents.org.uk/AOP/frontend/reg/thome.csp?pageID=2846&#38;CSPCHDx=0000000000000&#38;eventID=13" target="_blank">AOP booking website</a>.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Web Applications Java Developer]]></title>
<link>http://spillerlaszlo.wordpress.com/?p=252</link>
<pubDate>Wed, 23 Jul 2008 11:13:57 +0000</pubDate>
<dc:creator>Spiller László</dc:creator>
<guid>http://spillerlaszlo.wordpress.com/?p=252</guid>
<description><![CDATA[The ideal candidate will possess the following skills:
Technical:

Strong hands-on Java development ]]></description>
<content:encoded><![CDATA[<p>The ideal candidate will possess the following skills:</p>
<p><strong>Technical:</strong></p>
<ul>
<li>Strong hands-on Java development experience, 5+ years</li>
<li>Strong presentation tier skills, including HTML, CSS, Javascript, with Ajax and similar technologies a definite plus.</li>
<li>UI Design and Usability testing skills</li>
<li>Knowledge of Spring framework (web MVC, AOP and data access), Hibernate and JDBC</li>
<li> Some experience with relational databases, preferably Sybase as plus</li>
<li>Recent JSP / JSTL and Servlet experience ideally on Apache / Tomcat</li>
<li>OO Development and Design Skills including UML and use of design patterns</li>
<li>Experience of Spring Webflow  framework development a bonus</li>
<li>Experience of developing on Linux / Unix platform</li>
<li>Demonstrable experience of working in all phases of the development life cycle</li>
<li>BS or MS in Computer Science or Engineering degree from a highly accredited academic institution</li>
</ul>
<p><strong>Non-technical: </strong></p>
<ul>
<li>Good inter-personal skills with ability to communicate effectively both orally and in writing</li>
<li>Must have the capacity to work effectively either in a team  or on his / her own</li>
<li>Strong analytical and organisational skills.</li>
<li>Must be able to adapt well to change.</li>
<li>Must be able to demonstrate intellectual capacity to learn very quickly and adapt to complex situations in a fast paced and demanding environment.</li>
</ul>
<p><a href="laszlo_spiller@kellyservices.hu">laszlo_spiller@kellyservices.hu</a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Join point matching]]></title>
<link>http://ourcraft.wordpress.com/?p=164</link>
<pubDate>Mon, 21 Jul 2008 16:44:47 +0000</pubDate>
<dc:creator>danielmeyer</dc:creator>
<guid>http://ourcraft.wordpress.com/?p=164</guid>
<description><![CDATA[In our last episode, I was using the pointcut expression
execution(* com.example.MessageListener(..)]]></description>
<content:encoded><![CDATA[<p>In <a href="http://ourcraft.wordpress.com/2008/07/18/captain-were-experiencing-a-configuration-problem/">our last episode</a>, I was using the pointcut expression</p>
<pre style="padding-left:30px;">execution(* com.<em>example</em>.MessageListener(..))</pre>
<p>and getting this error:</p>
<p style="padding-left:30px;">java.lang.IllegalArgumentException: warning no match for this type name: com.<em>example</em> [Xlint:invalidAbsoluteTypeName]</p>
<p>I Googled this error (alas, my beloved <a href="http://www.ask.com">Ask.com</a> seems to have fewer of the stack trace errors indexed) and found <a href="http://forum.springframework.org/archive/index.php/t-36355.html">a post to a Spring Framework support forum</a> saying it was the pointcut expression that was incorrect.  And in <a href="http://www.eclipse.org/aspectj/doc/released/progguide/">The AspectJ<sup>TM</sup> Programming Guide</a> under <a href="http://www.eclipse.org/aspectj/doc/released/progguide/semantics-pointcuts.html#matching">Matching</a> and <a href="http://www.eclipse.org/aspectj/doc/released/progguide/language-joinPoints.html#some-example-pointcuts">Some Example Pointcuts</a> it does look like there's supposed to be a method signature there in the pointcut expression, not just a class name.</p>
<p>Now that I understand the pointcut expressions a little more, I think I'll take out most of the wildcards for now (I'm leaving the ".." wildcard for the Message parameter for now because when I replaced that with Message, I got some kind of error):</p>
<p>[sourcecode language='xml']<br />
<aop:config><br />
    <aop:pointcut id="stuff" expression="execution(void com.example.MessageListener.onMessage(..))" /><br />
    <aop:advisor advice-ref="txAdvice" pointcut-ref="stuff" /><br />
</aop:config><br />
[/sourcecode]</p>
<p>Now the deployment succeeds... but when my messagelistener throws a RuntimeException the message is still gone from the queue, so it doesn't seem to be rolling back correctly yet.  So that's where we'll start <a href="http://ourcraft.wordpress.com/2008/07/21/simple-jms-transaction-rollbacks-work/">next time</a>!</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Captain, we're experiencing a configuration problem...]]></title>
<link>http://ourcraft.wordpress.com/?p=158</link>
<pubDate>Fri, 18 Jul 2008 20:44:23 +0000</pubDate>
<dc:creator>danielmeyer</dc:creator>
<guid>http://ourcraft.wordpress.com/?p=158</guid>
<description><![CDATA[Last time we briefly tried to divine whether we were truly in an XA transaction, and ended wanting t]]></description>
<content:encoded><![CDATA[<p><a href="http://ourcraft.wordpress.com/2008/07/18/xa-transactions-how-bout-them-rollbacks/">Last time</a> we briefly tried to divine whether we were truly in an XA transaction, and ended wanting to set up AOP-controlled transactions.  That's where we are today...</p>
<hr />I added this (with the class name of my domain class) to my Spring bean file to enable transactions for the messagelistener:</p>
<p>[sourcecode language='xml']<br />
<tx:advice id="txAdvice" transaction-manager="transactionManager"><br />
    <tx:attributes><br />
        <tx:method name="*" /><br />
    </tx:attributes><br />
</tx:advice></p>
<p><aop:config><br />
    <aop:pointcut id="stuff" expression="execution(* com.example.MessageListener(..))" /><br />
    <aop:advisor advice-ref="txAdvice" pointcut-ref="stuff" /><br />
</aop:config><br />
[/sourcecode]</p>
<p>When I deployed this, I got:</p>
<p>15:12:25,757 ERROR [ContextLoader] Context initialization failed<br />
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/aop]<br />
Offending resource: class path resource [applicationContext.xml]</p>
<p>The AOP xmlns and schemaLocation looked right in the applicationContext.xml, so I did a web search for the error and...</p>
<p><a href="http://note19.com/2007/11/07/activemq-embedded-broker/">An entry in the note19 blog</a> gave me the idea to check to make sure my project includes the AOP portion of the Spring libraries in its dependencies... so I ended up adding both spring-aop and spring-aspects to my pom file.</p>
<p><strong>I needed both</strong></p>
<p>With only spring-aspects I still got the Unable to locate Spring NamespaceHandler error; with only spring-aop I got an exception (nested, of course :), to wit:</p>
<p style="padding-left:30px;">NoClassDefFoundError: org/aspectj/weaver/reflect/ReflectionWorld$ReflectionWorldException</p>
<p>But with both spring-aspects and spring-aop in my pom as dependencies, the error is gone!  Replaced by...</p>
<p><strong>The next error</strong></p>
<p>Now I get this:</p>
<p style="padding-left:30px;">16:18:30,896 ERROR [ContextLoader] Context initialization failed<br />
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'queueConnectionFactory': Initialization of bean failed; nested<br />
exception is java.lang.IllegalArgumentException: warning no match for this type name: com.<em>example</em> [Xlint:invalidAbsoluteTypeName]</p>
<p>My queueConnectionFactory JNDI-lookup bean definition looks like this:</p>
<p>[sourcecode language='xml']<br />
<jee:jndi-lookup id="queueConnectionFactory" jndi-name="java:activemq/QueueConnectionFactory" /><br />
[/sourcecode]</p>
<p>And that definition has been working -- my messageListener has been getting messages using that queue connection factory.  So I suspect that somehow the AOP beans -- which look like this:</p>
<p>[sourcecode language='xml']<br />
<tx:advice id="txAdvice" transaction-manager="transactionManager"><br />
    <tx:attributes><br />
        <tx:method name="*" /><br />
    </tx:attributes><br />
</tx:advice></p>
<p><aop:config><br />
    <aop:pointcut id="stuff" expression="execution(* com.example.MessageListener(..))" /><br />
    <aop:advisor advice-ref="txAdvice" pointcut-ref="stuff" /><br />
</aop:config><br />
[/sourcecode]</p>
<p>-- are causing the problem.</p>
<p>If I comment out the</p>
<p>[sourcecode language='xml']<br />
<aop:advisor advice-ref="txAdvice" pointcut-ref="stuff" /><br />
[/sourcecode]</p>
<p>line, the error goes away (but then of course the message receives don't roll back when a runtime exception is encountered either...)</p>
<p>Let's pursue this <a href="http://ourcraft.wordpress.com/2008/07/21/join-point-matching/">next time</a>.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[AOP 2008]]></title>
<link>http://feeflofly.wordpress.com/?p=56</link>
<pubDate>Wed, 16 Jul 2008 10:29:30 +0000</pubDate>
<dc:creator>feeflofly</dc:creator>
<guid>http://feeflofly.wordpress.com/?p=56</guid>
<description><![CDATA[ 
]]></description>
<content:encoded><![CDATA[<p>!!!<!--Slide.com error: provide id, w, h--></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[What makes a great photograph? ... "how long is a piece of string?"]]></title>
<link>http://gillmoorephotography.wordpress.com/?p=167</link>
<pubDate>Mon, 30 Jun 2008 13:38:30 +0000</pubDate>
<dc:creator>gill moore</dc:creator>
<guid>http://gillmoorephotography.wordpress.com/?p=167</guid>
<description><![CDATA[This year, for the first time, I am entering the Shot Up North Awards.  These UK awards are for pho]]></description>
<content:encoded><![CDATA[<p>This year, for the first time, I am entering the <a href="http://shotupnorth.co.uk/" target="_blank">Shot Up North Awards</a>.  These UK awards are for photographers based anywhere from the Midlands northwards including Scotland.  The Awards used to be affiliated to the <a href="http://hub.the-aop.org" target="_blank">Association of Photographers (AOP)</a> however <a href="http://shotupnorth.co.uk/" target="_blank">SUN</a> is now a stand-alone organisation aimed at celebrating and promoting Northern photographers and their work.</p>
<div><a href="http://gillmoorephotography.files.wordpress.com/2008/06/sun_logo.jpg"><img class="alignnone size-full wp-image-168" src="http://gillmoorephotography.wordpress.com/files/2008/06/sun_logo.jpg" alt="" width="450" height="237" /></a></div>
<div>I started to ponder what is the key thing that makes an image a <em>great image</em>.  First port of call was viewing some of the <a href="http://shotupnorth.co.uk/image-archive/" target="_blank">previous winning images from Shot Up North</a>.  Though hugely inspiring, I was struck by the variety and disparate array of images selected for the Top 50 over the years.  </div>
<div>Studying the photograph at first-hand is always the ideal and what usually happens is you have a gut reaction upon initial viewing and this surely provides the key to answering the question. </div>
<div><a href="http://gillmoorephotography.files.wordpress.com/2008/06/conscientious.jpg"><img class="alignnone size-full wp-image-169" src="http://gillmoorephotography.wordpress.com/files/2008/06/conscientious.jpg" alt="" width="450" height="86" /></a></div>
<div>I then took a read of the always excellent blog by <a href="http://www.jmcolberg.com/weblog" target="_blank">J M Colberg "Conscientious</a>" which featured a really in-depth piece: <a href="http://www.jmcolberg.com/weblog/2007/03/what_makes_a_great_photo.html" target="_blank">"What Makes a Great Photo?"</a> with many gifted photographers and creative's discussing their own take on answering that question.  After that I just jotted down lots of random thoughts which I list below.</div>
<div style="text-align:left;"><em><strong>  </p>
<ul>
<li>emotional kick "wow" factor/connection/memorable tho it also may not wow it could linger and not go away.</li>
<li>tells a story/intrigues/shows a voice</li>
<li>captures a moment</li>
<li>has a sense of style/atmosphere/beauty</li>
<li>makes you think/question/can challenge or inform</li>
<li>has a high degree of individuality/fresh perspective</li>
<li>compelling blend of colours/form/composition</li>
<li>intimate - can open a direct channel viewer/photographer.  It communicates.</li>
<li>evocative/memory</li>
<li>has depth, image encourages/demands repeat viewing</li>
<li>reveals something new of the subject; a person/object/environment</li>
<li>has an ability to move and touch the viewer</li>
<li>element of mystery</li>
<li>powerful ... it transports you to another place</li>
</ul>
<p></strong></em><em><strong></strong></em><em><strong></strong></em><em><strong></strong></em><em><strong></strong></em></div>
<div>Sure, it is a bit like asking "how long is a piece of string" but it is such an interesting question with no right or wrong answer; just more for the mix and people react so differently and that it what is so fascinating.  </div>
<p> </p>
<p><a title="Bookmark using any bookmark manager!" href="http://www.addthis.com/bookmark.php" target="_blank"><img src="http://s3.addthis.com/button1-bm.gif" border="0" alt="AddThis Social Bookmark Button" width="125" height="16" /></a></p>
<hr class="hr_kdm" /> </p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[New Staff Intranet Release]]></title>
<link>http://journalofasoftwaredev.wordpress.com/?p=59</link>
<pubDate>Fri, 27 Jun 2008 22:17:58 +0000</pubDate>
<dc:creator>Michael Cromwell</dc:creator>
<guid>http://journalofasoftwaredev.wordpress.com/?p=59</guid>
<description><![CDATA[I have found enough spare time to put up a new release of the staff intranet project, for those who ]]></description>
<content:encoded><![CDATA[<p>I have found enough spare time to put up a new release of the <a href="http://www.codeplex.com/staffintranet" target="_blank">staff intranet project</a>, for those who are not aware of this project it is a demonstration of using best practices, principles &#38; patterns in a real world web application so if your looking for pointers or some code to use for your own applications go give it a look on <a href="http://www.codeplex.com/staffintranet" target="_blank">codeplex</a>.</p>
<p>In this newest version I have added AOP support to cut down on cross cutting code and also the ability to delete staff members from the GridView, most of the time spent was fighting against the asp.net controls (suprise, surprise) such as the GridView and the ObjectDataSource, I'm not sure what the guy(s) who created the ObjectDataSource object was smoking at the time but it must have been stronger than just tobacco :-)</p>
<p>My next release I want to demonstrate adding some service support showing how we can re-use existing code so they become little more than a remote facade (in theory!).</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[The Spring problem that wasn't]]></title>
<link>http://ourcraft.wordpress.com/?p=59</link>
<pubDate>Wed, 18 Jun 2008 13:50:27 +0000</pubDate>
<dc:creator>danielmeyer</dc:creator>
<guid>http://ourcraft.wordpress.com/?p=59</guid>
<description><![CDATA[Disclaimer: On the technicalness continuum, this post is way over into &#8220;impossibly technical]]></description>
<content:encoded><![CDATA[<p>Disclaimer: On the technicalness continuum, this post is way over into "impossibly technical".  But I needed somewhere to jot this down (a text file on one's desktop can only last so long...)</p>
<p><strong>It was blowing up...</strong></p>
<p>When we started up an application context that had a <a href="http://www.springframework.org/">Spring</a> <a href="http://static.springframework.org/spring/docs/2.5.x/reference/jms.html#jms-mdp-default">DefaultMessageListenerContainer</a>, and the <a href="http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JMS2.html">JMS</a> <a href="http://java.sun.com/j2ee/1.4/docs/api/javax/jms/Queue.html">Queue</a> that listenercontainer pointed to already had messages in it, the messagelistenercontainer (fairly reproducibly, it seemed) called our listener before our listener's beans were all initialized by Spring (i.e., before it was "wired").  This resulted in a Java NullPointerException.</p>
<p><strong>An indignant pause</strong></p>
<p>Imagine!  Not being able to trust a big-name Inversion of Control container like Spring to do its job properly!  But before reporting a bug, we wanted to put a minimal test together demonstrating the problem.</p>
<p><strong>Minimal... minimal...<br />
</strong></p>
<p>Complicating factors were:</p>
<ul>
<li>The error was happening inside an <a href="http://www.onjava.com/pub/a/onjava/2004/01/14/aop.html">AOP</a> around advice method before it even got into the MessageListener's onMessage method; and</li>
<li>The process was running on an application server</li>
</ul>
<p>So... was the problem simply with Spring?  Or was it something about the AOP setup?  Or was it something that would only show up in the context of running on an app server?  I (with Keith's help) came up with a plan to root out the cause of the error.</p>
<p><strong>Diagnostic Test Plan</strong></p>
<p><em>Level A:</em> Message already in queue (NON app server, NON AOP version)</p>
<p>We'd try the simplest test first to see if we could reproduce the issue without being on an app server and without AOP.</p>
<ul>
<li>Create a small Java app that puts a text message in the JMS Queue</li>
<li>Upon receiving a message, the Messagelistener (in a separate Java app) calls its helloWorld bean's sayHello() method, passing the string from the JMS text message.  The listener thread would create the application context and then sleep for a while.</li>
</ul>
<p><em>Level B: </em>Add AOP advice</p>
<p>If Level A didn't reproduce the problem, we'd add AOP around advice to the MessageListener's <a href="http://java.sun.com/j2ee/1.4/docs/api/javax/jms/MessageListener.html#onMessage(javax.jms.Message)">onMessage</a> method, and the around advice would need to internally use a Spring bean</p>
<p><em> Level C: </em>Do Level A test in an app server environment<br />
<em>Level D</em>: Do Level B test in an app server environment</p>
<p><em>Potential Post-D levels, if we still can't reproduce the problem:</em><br />
- Maybe it only happens with JMS Object messages...?</p>
<p><strong>An Unexpectedly Quick Resolution<br />
</strong></p>
<p>I was getting the Level A test put together when Keith had a thought.  Our Spring context bootstrap code - in what order were we loading things there?</p>
<p>We looked, and what do you know - the Spring context that contained the MessageListenerContainer that was starting up "too early" and blowing up if messages were already in the queue depended on something in another Spring context, which at that point our bootstrap code had not loaded yet.  The problem was in our bootstrap code, a simple ordering problem!</p>
<p>Being new and slow with this stuff, it took me a while to write the test to confirm this, but that was the issue.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[About the theme!!]]></title>
<link>http://khaledkhan.wordpress.com/?p=3</link>
<pubDate>Sun, 15 Jun 2008 07:46:36 +0000</pubDate>
<dc:creator>khaledkhan</dc:creator>
<guid>http://khaledkhan.wordpress.com/?p=3</guid>
<description><![CDATA[The theme which I have used for my blogs is called “Almost Spring” which by the way reflect my a]]></description>
<content:encoded><![CDATA[<p class="MsoNormal">The theme which I have used for my blogs is called “Almost Spring” which by the way reflect my appreciation for Spring Framework (sorry, I couldn’t find a theme named almost Seam). Spring really rocks when it comes to AOP and DI. But I became its fan when we (Imran Sarwar) plugged Spring resources in our desktop applications. I really fell in love with the “Plugability” of Spring based projects. I now understand the real difference between EJB and Springs.</p>
<p class="MsoNormal"><span> </span></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Enforcing Conventions]]></title>
<link>http://journalofasoftwaredev.wordpress.com/?p=52</link>
<pubDate>Thu, 12 Jun 2008 19:44:23 +0000</pubDate>
<dc:creator>Michael Cromwell</dc:creator>
<guid>http://journalofasoftwaredev.wordpress.com/?p=52</guid>
<description><![CDATA[In my last post I demonstrated adding AOP to cut down on cross cutting code, and at the end mentione]]></description>
<content:encoded><![CDATA[<p>In my last post I demonstrated adding <a href="http://en.wikipedia.org/wiki/Aspect-oriented_programming" target="_blank">AOP</a> to cut down on <a href="http://en.wikipedia.org/wiki/Cross_cutting_%28programming%29" target="_blank">cross cutting code</a>, and at the end mentioned that it would be nice to enforce a convention throughout the system, the example being each public method in the task layer being decorated with a certain attribute.</p>
<p>I was unsure about how to do this until recently seeing a post by Ayende <a href="http://www.ayende.com/Blog/archive/2008/05/05/Actively-enforce-your-conventions.aspx" target="_blank">http://www.ayende.com/Blog/archive/2008/05/05/Actively-enforce-your-conventions.aspx</a> in it he references an article by <a href="http://codebetter.com/blogs/glenn.block/Default.aspx" target="_blank">Glenn Block</a> whereby both of them came up with a unit test called <em>PrismShouldNotReferenceUnity</em> in the test they use reflection to check that there are indeed no references from the Prism assembly to the Unity assembly.</p>
<p>This is a great idea! You now have a repeatable test that can be run to make sure the conventions for your system are met, so armed with this technique I created the following test:</p>
<p>[sourcecode language='csharp']<br />
[Test]<br />
public void task_class_methods_should_be_marked_with_wrap_exception_attributes()<br />
{<br />
    try<br />
    {<br />
        Assembly asm = Assembly.LoadFrom( "MCromwell.StaffIntranet.Task.dll" );<br />
        var wrapExceptionType = asm.GetType( "MCromwell.StaffIntranet.Task.Infrastructure.WrapExceptionWithAttribute" );<br />
        Assert.IsNotNull(wrapExceptionType);</p>
<p>        foreach (Type current in asm.GetTypes())<br />
        {<br />
            if (current.FullName.StartsWith( "MCromwell.StaffIntranet.Task.Tasks." ) && (!current.IsInterface) && (!current.IsAbstract))<br />
            {<br />
                foreach (var method in current.GetMethods())<br />
                {<br />
                    if ((method.IsPublic) && (method.DeclaringType.Name != "Object"))<br />
                    {<br />
                        if (method.GetCustomAttributes(wrapExceptionType, false).Length <= 0)<br />
                            Assert.Fail("no wrap exception attribute found on type '{0}', method '{1}'", current.FullName,method.Name);<br />
                    }<br />
                }<br />
             }<br />
        }<br />
    }<br />
    catch (ReflectionTypeLoadException rex)<br />
    {<br />
        foreach (var current in rex.LoaderExceptions)<br />
            Console.WriteLine(current.ToString());<br />
        throw;<br />
    }<br />
    catch (Exception ex)<br />
    {<br />
        Console.Error.Write(ex.Message);<br />
        throw;<br />
    }<br />
}<br />
[/sourcecode]</p>
<p>In here you can see by leveraging reflection I can browse all the public methods for my task layer classes and make sure they do indeed have a <code>WrapExceptionWithAttribute</code> the other cool thing is that by doing it this way I can freely add new classes and they will need to comply with the conventions set out or the testing will fail, cool eh!</p>
<p>One thing to point out is that if you start increasing the number of conventions and want a better way to control and report on, you probably want to look into something like <a href="http://msdn.microsoft.com/en-us/library/bb429476(VS.80).aspx" target="_blank">FXCop</a> or <a href="http://www.ndepend.com/CQL.htm" target="_blank">NDepend's CQL</a>.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Le Camembert de Normandie perd du terrain]]></title>
<link>http://saveurdavance.wordpress.com/?p=121</link>
<pubDate>Thu, 12 Jun 2008 10:16:09 +0000</pubDate>
<dc:creator>Lydia</dc:creator>
<guid>http://saveurdavance.wordpress.com/?p=121</guid>
<description><![CDATA[Le 4 juin dernier, l&#8217;Institut national de l&#8217;origine et de la qualité (INAO) a approuvé]]></description>
<content:encoded><![CDATA[<p style="text-align:justify;">Le 4 juin dernier, l'Institut national de l'origine et de la qualité (INAO) a approuvé la révision du cahier des charges de l'appellation d'origine protégée (AOP) "Camembert de Normandie". Le projet du cahier des charges sera soumis au gouvernement pour être homologué. Il propose que la zone géographique de l'appellation soit réduite de moitié par rapport à l'aire initiale, soit 1 678 communes au lieu de 3 234. La méthode est aussi au cœur des évolutions de ce cahier des charges avec notamment la mise en œuvre de pratiques comme le pâturage obligatoire pendant 6 mois, la mise à disposition de foin le reste de l'année et l'augmentation de la part de la race normande dans la production de lait.</p>
<p style="text-align:justify;"><strong>A lire aussi</strong> : <a href="http://saveurdavance.wordpress.com/wp-admin/post.php?action=edit&#38;post=56">le camembert résiste !</a><strong><br />
En savoir plus : </strong><a href="http://www.inao.gouv.fr/" target="_blank">www.inao.gouv.fr</a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Adding AOP to Staff Intranet]]></title>
<link>http://journalofasoftwaredev.wordpress.com/?p=51</link>
<pubDate>Tue, 10 Jun 2008 21:29:12 +0000</pubDate>
<dc:creator>Michael Cromwell</dc:creator>
<guid>http://journalofasoftwaredev.wordpress.com/?p=51</guid>
<description><![CDATA[Because I&#8217;m a stickler for good code I put exception handling into my task layer and wrap any ]]></description>
<content:encoded><![CDATA[<p>Because I'm a stickler for good code I put exception handling into my task layer and wrap any exception that may be raised from the data access layer into an appropriate exception for the task layer and also log the exception, because of this I end up having lots of unit test code that looks similar to make sure I'm enforcing this rule:</p>
<p>[sourcecode language='csharp']<br />
[Test]<br />
public void Should_log_exception_if_exception_is_raised_when_deleting_session()<br />
{<br />
    Guid id = Guid.Empty;<br />
    IAdministrationRepository mockRepository = CreateMock<IAdministrationRepository>();</p>
<p>    IServiceResolver mockResolver = CreateMock<IServiceResolver>();<br />
    ILog mockLog = CreateMock<ILog>();<br />
    Exception mockException = new Exception( "mock ex" );</p>
<p>    using (Record)<br />
    {<br />
        SetupResult.For(mockResolver.Resolve<ILog>())<br />
                   .Return(mockLog);<br />
        SetupResult.For(mockRepository.FindLoginSessionBy(id))<br />
                   .IgnoreArguments()<br />
                   .Return(new LoginSession(id));<br />
        mockRepository.Delete(null);<br />
        LastCall.IgnoreArguments()<br />
                .Throw(mockException);<br />
        mockLog.Error(mockException);<br />
    }</p>
<p>    using (PlayBack)<br />
    {<br />
        try<br />
        {<br />
            IoC.InitializeWith(mockResolver);<br />
            IAuthenticationTask sut = createSUT(mockRepository);<br />
            sut.InvalidateSessionFor(id);<br />
        }<br />
        catch { }<br />
    }<br />
}<br />
[/sourcecode]</p>
<p>And to fulfill this I then end up with <a href="http://en.wikipedia.org/wiki/Cross_Cutting" target="_blank">cross cutting code</a> to meet the test behaviour:</p>
<p>[sourcecode language='csharp']<br />
try<br />
{<br />
    //... work here<br />
}<br />
catch (Exception thrownException)<br />
{<br />
    Log(thrownException);<br />
    throw new ProblemSavingStaffMemberException(thrownException);<br />
}<br />
[/sourcecode]</p>
<p>To try and cut down on this <a href="http://en.wikipedia.org/wiki/Cross_Cutting" target="_blank">cross cutting code</a> and to keep the tasks more lean I did some investigation into some <a href="http://en.wikipedia.org/wiki/Aspect-oriented_programming" target="_blank">AOP</a> strategies.</p>
<p>My first reaction was... I'm using <a href="http://www.castleproject.org/container/index.html" target="_blank">Castle Windsor</a> so can I utilize it's built in <a href="http://en.wikipedia.org/wiki/Aspect-oriented_programming" target="_blank">AOP</a> capabilities after changing some code and adding an interceptor I quickly found out this won't be possible as it doesn't support out or ref parameters and due to some of my task layer method using out parameters to pass back a notification object this choice was gone!</p>
<p>Next up I had a look at <a href="http://www.postsharp.org/" target="_blank">PostSharp</a> the difference between them being that <a href="http://www.postsharp.org/" target="_blank">PostSharp</a> adds code in after compilation whereas <a href="http://www.castleproject.org/container/index.html" target="_blank">Windsor</a> dynamically creates proxies at runtime. After looking at some examples I had an idea as to how to implement it so after installing <a href="http://www.postsharp.org/" target="_blank">PostSharp</a> I created my object that will inject itself into other objects:</p>
<p>[sourcecode language='csharp']<br />
[Serializable]<br />
[AttributeUsage(AttributeTargets.All)]<br />
public class TaskExceptionHandlerAttribute : OnMethodBoundaryAspect<br />
{<br />
    public override void OnException(MethodExecutionEventArgs eventArgs)<br />
    {<br />
        Exception thrownException = eventArgs.Exception;<br />
        LogException(thrownException);<br />
        WrapExceptionWithAttribute wrapExceptionAttribute = RetrieveWrappingExceptionAttribute(eventArgs.Method);<br />
        if (wrapExceptionAttribute != null)<br />
        {<br />
            Type exceptionToWrapWith = wrapExceptionAttribute.WrapExceptionType;<br />
            Exception exceptionToThrow = (Exception)Activator.CreateInstance(exceptionToWrapWith, thrownException);<br />
            if (exceptionToThrow != null)<br />
                throw exceptionToThrow;<br />
        }<br />
        throw new TaskLayerException(thrownException);<br />
    }</p>
<p>    private static WrapExceptionWithAttribute RetrieveWrappingExceptionAttribute(MethodBase method)<br />
    {<br />
        WrapExceptionWithAttribute wrapExceptionAttribute =<br />
        method.GetFirstCustomAttribute<WrapExceptionWithAttribute>(typeof(WrapExceptionWithAttribute),false);<br />
        return wrapExceptionAttribute;<br />
    }</p>
<p>    private static void LogException(Exception thrownException)<br />
    {<br />
        ILog log = IoC.Resolve<ILog>();<br />
        log.Error(thrownException);<br />
    }<br />
}<br />
[/sourcecode]</p>
<p>In order to not have to place this object as an attribute on all the different task classes I can use the assembly attribute and give it a target using a name plus a wildcard:</p>
<p>[sourcecode language='csharp']<br />
[assembly: TaskExceptionHandler(AttributeTargetTypes="MCromwell.StaffIntranet.Task.Tasks.*")]<br />
[/sourcecode]</p>
<p>And that's it my methods are now injected with the <a href="http://www.postsharp.org/" target="_blank">PostSharp</a> code after compilation to handle exceptions and at which point it will call my custom code very cool!</p>
<p>One thing you may have noticed is the use of another attribute that can be decorated on the task methods <code>WrapExceptionWithAttribute</code> this attribute takes a Type in it's constructor this Type is the exception that should wrap the thrown exception ideally we would like this attribute to be placed on all public task class methods so that we raise applicable exceptions depending on the task be performed although how do we enforce this convention?...</p>
<p>In my next post I will be demonstrating a technique that allows to enforce these types of conventions we want for our systems.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Using LogFactory warp up log4net, entlib and other logging service]]></title>
<link>http://maonet.wordpress.com/?p=124</link>
<pubDate>Fri, 30 May 2008 15:05:25 +0000</pubDate>
<dc:creator>Frank Mao</dc:creator>
<guid>http://maonet.wordpress.com/?p=124</guid>
<description><![CDATA[JP provides a great solution to warp log4net, textwritter and other logging service, the basic idea ]]></description>
<content:encoded><![CDATA[<p><a href="http://maonet.wordpress.com/files/2008/05/logging_arch.jpg"><img class="alignleft size-full wp-image-125" src="http://maonet.wordpress.com/files/2008/05/logging_arch.jpg" alt="" width="219" height="271" /></a>JP provides <a href="http://www.jpboodhoo.com/blog/TheStaticGatewayPattern.aspx">a great solution to warp log4net, textwritter and other logging service</a>, the basic idea is to create a common interface and a common Log class used by application directly.</p>
<p>In Application:</p>
<p>Log.For(this).Info(...)</p>
<p>And Log class initialize different logging service might be passed in.</p>
<p>[sourcecode language="CSharp"]</p>
<p>public class Log<br />
{<br />
private static ILogFactory logFactory;</p>
<p>public static void InitializeLogFactory(ILogFactory logFactory)<br />
{<br />
Log.logFactory = logFactory;<br />
}</p>
<p>public static ILog For(object itemThatRequiresLoggingServices)<br />
{<br />
return For(itemThatRequiresLoggingServices.GetType());<br />
}</p>
<p>public static ILog For(Type type){</p>
<p>// This is IOC style, then we should not use logFactory field which needs to be passed in when using log.<br />
//            return DependencyResolver.GetImplementationOf().CreateFor(type);</p>
<p>return logFactory.CreateFor(type); ;<br />
}<br />
}</p>
<p>[/sourcecode]</p>
<p>If it's a simple console logging service, the implementation will be like this:</p>
<p>[sourcecode language="CSharp"]</p>
<p>    public class ConsoleLogFactory : ILogFactory<br />
    {<br />
        public ILog CreateFor(Type type)<br />
        {<br />
            return new ConsoleLogger();<br />
        }</p>
<p>        private class ConsoleLogger : ILog<br />
        {<br />
            public void Informational(string message)<br />
            {<br />
                System.Console.Out.WriteLine(message);<br />
            }</p>
<p>            public void Informational(string messageFormat, params object[] args)<br />
            {<br />
                System.Console.Out.WriteLine(messageFormat, args);<br />
            }</p>
<p>[/sourcecode]</p>
<p>And the log4net factory will be this,  in which the WireUpConfiguration() method is using singleton pattern.</p>
<p>[sourcecode language="CSharp"]<br />
    public class Log4NetLogFactory : ILogFactory<br />
    {<br />
        private ILog4NetInitialization initialization;<br />
        private bool initialized;</p>
<p>        public Log4NetLogFactory(): this(new Log4NetInitialization())<br />
        {<br />
        }</p>
<p>        public Log4NetLogFactory(string filename): this(new Log4NetInitialization(filename))<br />
        {<br />
        }</p>
<p>        // using ILog4NetInitialization can enable logFactory read from different app config file.<br />
        public Log4NetLogFactory(ILog4NetInitialization initialization)<br />
        {<br />
            this.initialization = initialization;<br />
        }</p>
<p>        public ILog CreateFor(Type typeThatRequiresLoggingServices)<br />
        {<br />
            WireUpConfiguration();<br />
            return new Log4NetLog(LogManager.GetLogger(typeThatRequiresLoggingServices));<br />
        }</p>
<p>        private void WireUpConfiguration()<br />
        {<br />
            if (initialized) return;</p>
<p>            initialization.Execute();<br />
            initialized = true;<br />
        }<br />
    }</p>
<p>[/sourcecode]</p>
<p>Finally, the log4netINitialization is this: (I don't think ILog4NetInitialization is necessary, in fact the whole Log4NetInitialization can also be moved into log4net Factory class even.)</p>
<p>[sourcecode language="CSharp"]<br />
    public class Log4NetInitialization : ILog4NetInitialization<br />
    {<br />
        private readonly XmlElement configuration;<br />
        public Log4NetInitialization(){}</p>
<p>        public Log4NetInitialization(string filename)<br />
        {<br />
            XmlDocument document = new XmlDocument();<br />
            document.Load(filename);<br />
            configuration = document.DocumentElement; </p>
<p>        }<br />
        public Log4NetInitialization(XmlElement configuration)<br />
        {<br />
            this.configuration = configuration;<br />
        }</p>
<p>        public void Execute()<br />
        {<br />
            if (configuration == null) XmlConfigurator.Configure();<br />
            else XmlConfigurator.Configure(configuration);<br />
        }<br />
    }<br />
[/sourcecode]</p>
<p>The benefit of all those work is, the front end is same based on different logging service implementation,</p>
<blockquote><p>Log.For(this).Info(...)</p>
<p>Log.For(this).Debug(...)</p>
<p>Log.For(this).Fatal(...)</p>
<p>Log.For(this).Warn(...)</p>
<p>Log.For(this).Error(...)</p></blockquote>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Programação Orientada a Aspectos – Aplicação em ambientes corporativos]]></title>
<link>http://thicow.wordpress.com/2008/05/23/programacao-orientada-a-aspectos-%e2%80%93-aplicacao-em-ambientes-corporativos/</link>
<pubDate>Fri, 23 May 2008 17:46:17 +0000</pubDate>
<dc:creator>Thiago Tavares</dc:creator>
<guid>http://thicow.wordpress.com/2008/05/23/programacao-orientada-a-aspectos-%e2%80%93-aplicacao-em-ambientes-corporativos/</guid>
<description><![CDATA[
]]></description>
<content:encoded><![CDATA[<br />
]]></content:encoded>
</item>
<item>
<title><![CDATA[Use WCF FaultException LogBook in CSLA]]></title>
<link>http://maonet.wordpress.com/?p=119</link>
<pubDate>Thu, 22 May 2008 20:46:34 +0000</pubDate>
<dc:creator>Frank Mao</dc:creator>
<guid>http://maonet.wordpress.com/?p=119</guid>
<description><![CDATA[Juval Lowy, the author of Programming WCF, has a very good logbook sample application in the attache]]></description>
<content:encoded><![CDATA[<p><a href="http://www.idesign.net/idesign/DesktopDefault.aspx?tabindex=3&#38;tabid=5">Juval Lowy</a>, the author of Programming WCF, has a very good logbook sample application in the <a href="http://examples.oreilly.com/9780596526993/PWS-Sources.zip">attached source code</a>, which can log all the WCF FaultException into a database table.</p>
<p>To make it work with CSLA, I figured out there is a minor change needed. (The version I am working on in 3.0) The reason is WcfPortal actually doesn't throw exception, instead, it casts the exception to an object returning to WcfProxy. This means, It's WcfProxy at the client side throwing the exception. Apparently, Juval's logbook can only monitor exceptions on Wcf Host, not at the client. I had to add an</p>
<blockquote><p>throw ex;</p></blockquote>
<p>into WcfPortal's catching block to make CSLA framework can use this handy logBook tools.</p>
<p>[sourcecode language="CSharp"]<br />
WcfPortal:<br />
    public WcfResponse Fetch(FetchRequest request)<br />
    {<br />
      Csla.Server.DataPortal portal = new Csla.Server.DataPortal();<br />
      object result;<br />
      try<br />
      {<br />
        result = portal.Fetch(request.ObjectType, request.Criteria, request.Context);<br />
      }<br />
      catch (Exception ex)<br />
      {<br />
        result = ex;<br />
      }<br />
      return new WcfResponse(result);<br />
    }</p>
<p>WcfProxy:<br />
    public DataPortalResult Fetch(Type objectType, object criteria, DataPortalContext context)<br />
    {<br />
      ChannelFactory cf = new ChannelFactory(_endPoint);<br />
      IWcfPortal svr = cf.CreateChannel();<br />
      WcfResponse response =<br />
        svr.Fetch(new FetchRequest(objectType, criteria, context));<br />
      cf.Close();</p>
<p>      object result = response.Result;<br />
      if (result is Exception)<br />
        throw (Exception)result;<br />
      return (DataPortalResult)result;<br />
    }<br />
[/sourcecode]</p>
<p><a href="http://maonet.wordpress.com/files/2008/05/wcf_csla_logviewer.jpg"><img class="aligncenter size-medium wp-image-120" src="http://maonet.wordpress.com/files/2008/05/wcf_csla_logviewer.jpg?w=300" alt="" width="300" height="178" /></a></p>
<p>Thanks to Juval, this is almost exactly what our boss wants, the only thing missing is UserName and Client Machine information, and exception stack?</p>
<p>Most important, what's the reason WcfPortal doesn't throw exception? The explanation back from Rocky is, he wants to display the full stack of the error/exception so the exception on the server side is caught but not thrown out, instead this exception is passed to client as an parameter to the client side. Another ward, no exception will be thrown from CSLA at all! There is no way to use LogBook, unless we change CSLA framework.</p>
<p>Here is <a href="http://forums.lhotka.net/forums/thread/25167.aspx">Andy's solution</a> from CLSA forum:</p>
<blockquote><p>That's what I do.. override OnDataPortalException.  You can do this in something like MyCompanyBusinessBase, and have all your classes inherit that subclass.  Rocky recommends creating such a subclass even if initially it doesn't add any behavior at all, because someday you will.</p>
<p>One thing to watch is that if you're doign different logging on server vs. client you need to check ExecutionLocation.  But it works great.</p>
<p>My exception handling actually builds up a message, drilling down to all InnerExceptions and emails the whole thing to me.  Very helpful to finding out where the exception is occuring.  If the email fails to send for some reason, my fallback is to log a message to the Windows Event Log.  This can be tricky to get going at first, because if you're remoting you'll need to manually add the Application Name to the registry so that your application can use that name (and you'll want to do this to distingish between your remoting application and other asp.net errors).</p>
<p>HTH<br />
Andy</p></blockquote>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Lån penge online - Her er alt om lån og låne penge ]]></title>
<link>http://boligandel.wordpress.com/?p=4</link>
<pubDate>Sat, 17 May 2008 16:33:47 +0000</pubDate>
<dc:creator>boligandel</dc:creator>
<guid>http://boligandel.wordpress.com/?p=4</guid>
<description><![CDATA[Lån penge
Bankerne har i stigende grad begyndt at flytte deres ydelser fra at være ren bankkontors]]></description>
<content:encoded><![CDATA[<h1><a title="Lån penge" href="http://kreditkredit.dk/laan-penge/"><em><strong><span style="color:#ff6600;">Lån penge</span></strong></em></a></h1>
<p>Bankerne har i stigende grad begyndt at flytte deres ydelser fra at være ren bankkontors tjenester på internettet. Dette er et naturligt skridt, da vi lever i et IT-samfundet. En af disse tjenester er at låne penge. De fleste lånegivare har åbnet muligheden for at bruge en hjemmeside til at anvende og prisen på forskellige lån.<br />
Denne side vil fokus på at låne penge, men endnu mere om, hvordan det er muligt at låne penge online. Vi vil beskæftige sig med forskellige betingelser, omkostninger, at de fleste lånegivare have. Men vi altid anbefaler, at du altid læse alle de betingelser, samt data fra lånegivaren.</p>
<h3><a title="lån penge online" href="http://kreditkredit.dk/laan-penge-online/"> Lån penge online</a></h3>
<p>Der er en række aktører på gæld markedet i dag, nogle er større långivere, mens andre er mindre og fokuserede på SMS, små lån.<br />
Dette gør det vanskeligere at vælge, hvor de skal sætte deres lån. Hver långiver har forskellige betingelser, omkostninger og amorteringssätt på de lån, de yder.<br />
Når alt kommer til alt, er det heller ikke sikkert, at denne særlige långiver du ønsker at have lån med tilskud netop dit lån.<br />
Derfor kunne det være smart at forhøre behovene hos de mange lånegivare på samme tid, og sammenligne lån vil være billigst for dig.<br />
Noget vigtigt, når du tager lån er, at man ser på de samlede omkostninger, de betingelser også bør læses i både en og to gange for at være sikker på at alt er igenomgått.</p>
<p>Når du ønsker at låne penge, hvad enten det er at låne penge online eller at gå til din lokale filial og få et lån, disse forskellige lånegivare forskellige krav til lånetagaren. Disse krav er, at lånegivaren ønsker at kunne se, at lånetagaren have mulighed for på en eller anden måde være i stand til at betale sagens omkostninger og renter på lånet, men også at det betaler sig / amortiseret i rette tid.<br />
En person, der ikke behøver at have mulighed for at betale sagens omkostninger og tilbagebetalingstid på lånet er normalt ikke få et lån. Men der er visse formildende tidspunkter, hvor kan det stadig være muligt. Det er hvis du har en kautionist der kan give en garanti for lånet. Denne person indvilger i at tilbagebetale lån på mandag i det usandsynlige skulle løbe ind i finansielle trångsmål.</p>
<p>De personer, der har dårlig kreditværdighed kan også have problemer med at optage et lån, men vi ser på nogle långivere, der kan hjælpe dig med lån, selv om der er betalingsforsømmelse.</p>
<p>Forskellige typer af lån<br />
Der er flere typer af obligationsmarkedet i Sverige. Her vil vi nævne et par af disse. Vi vil mere specifikt at gå i detaljer i hvert af de underordnede kan du finde her.</p>
<p>Lån penge online<br />
I de sidste mange selv vidste, hvad der blev kaldt bankmand, og det gjorde sin bankärrende direkte på grenen. Men i dagens informationssamfund, så går mere og mere hyppigt til banken til at udføre deres bankärrende. Dette har banker / lånegivare opmærksomhed og er derfor begyndt at tilbyde tjenester til at låne penge online.<br />
<a title="Andelsboliglån" href="http://kreditkredit.dk/andelsboliglaan/"><br />
</a></p>
<h2><a title="Andelsboliglån" href="http://kreditkredit.dk/andelsboliglaan/"><strong>billigt Andelsboliglån</strong></a></h2>
<p>Ejendom Kredit er en af de mest almindelige lån i Sverige. De fleste af de mennesker, der køber et hjem tager en ejendom lån til at finansiere bostadsköpet.<br />
En ejendomslån tendens til at være lånet blev ydet til den laveste rente, at når banken / lånegivaren har hjemme som sikkerhed, hvis det ikke er muligt at foretage betalinger.<br />
Ejendom pengeinstitutter er normalt opdelt i Topplån, Bottenlån.</p>
<p>Kreditkort - Kreditlån<br />
Kreditkort er mange der ikke ser som et lån, men det er en form for lån. Den låner penge fra kreditkortsbolaget i en vis periode til sent betale lånet tilbage.<br />
Dette, sammen med ejendomslån er de mest almindelige typer af lån finner. Det er også det lån, der er mest er den letteste at gå glip af.</p>
<p>Låne penge på trods af betaling standard<br />
Personer, der har dårlig kreditværdighed kan have store problemer at få større lån, for eksempel, bolig, bil eller andre lån til andre objekter. Der er én og andre långivere i danmark, der gør det muligt at opnå et lån er fastsat betalingsforsømmelse. Kravet fra lånegivaren i disse tilfælde er tilbøjelig til at være en garant og / eller at du kan vise, at der er kapital til at være i stand til at tilbagebetale lånet.</p>
<p>Vi håber du vil finde svarene her for at skitsere bekymring for, at <a title="lån penge online" href="http://kreditkredit.dk/laan-penge-online/">lån penge online.</a></p>
<table border="0" cellspacing="0" cellpadding="0" width="271">
<tbody>
<tr>
<td width="271" valign="bottom"><span style="text-decoration:underline;"><a href="http://kreditkredit.dk/" target="_blank">http://kreditkredit.dk/</a></span></td>
</tr>
<tr>
<td width="271" valign="bottom"><span style="text-decoration:underline;"><a href="http://kreditkredit.dk/bil-laan" target="_blank">http://kreditkredit.dk/bil-laan</a></span></td>
</tr>
<tr>
<td width="271" valign="bottom"><span style="text-decoration:underline;"><a href="http://kreditkredit.dk/Kreditlaan" target="_blank">http://kreditkredit.dk/Kreditlaan</a></span></td>
</tr>
<tr>
<td width="271" valign="bottom"><span style="text-decoration:underline;"><a href="http://kreditkredit.dk/obligationslaan" target="_blank">http://kreditkredit.dk/obligationslaan</a></span></td>
</tr>
<tr>
<td width="271" valign="bottom"><span style="text-decoration:underline;"><a href="http://kreditkredit.dk/kontantlaan" target="_blank">http://kreditkredit.dk/kontantlaan</a></span></td>
</tr>
<tr>
<td width="271" valign="bottom"><span style="text-decoration:underline;"><a href="http://kreditkredit.dk/forbrugslaan" target="_blank">http://kreditkredit.dk/forbrugslaan</a></span></td>
</tr>
<tr>
<td width="271" valign="bottom"><span style="text-decoration:underline;"><a href="http://kreditkredit.dk/boliglaan" target="_blank">http://kreditkredit.dk/boliglaan</a></span></td>
</tr>
<tr>
<td width="271" valign="bottom"><span style="text-decoration:underline;"><a href="http://kreditkredit.dk/afdragsfrie-laan" target="_blank">http://kreditkredit.dk/afdragsfrie-laan</a></span></td>
</tr>
<tr>
<td width="271" valign="bottom"><span style="text-decoration:underline;"><a href="http://kreditkredit.dk/andelsboliglaan" target="_blank">http://kreditkredit.dk/andelsboliglaan</a></span></td>
</tr>
<tr>
<td width="271" valign="bottom"><span style="text-decoration:underline;"><a href="http://kreditkredit.dk/laan-penge-online" target="_blank">http://kreditkredit.dk/laan-penge-online</a></span></td>
</tr>
<tr>
<td width="271" valign="bottom"><span style="text-decoration:underline;"><a href="http://kreditkredit.dk/Realkreditlaan" target="_blank">http://kreditkredit.dk/Realkreditlaan</a></span></td>
</tr>
<tr>
<td width="271" valign="bottom"><span style="text-decoration:underline;"><a href="http://kreditkredit.dk/sitemap" target="_blank">http://kreditkredit.dk/sitemap</a></span></td>
</tr>
<tr>
<td width="271" valign="bottom"><span style="text-decoration:underline;"><a href="http://kreditkredit.dk/realkreditlaan" target="_blank">http://kreditkredit.dk/realkreditlaan</a></span></td>
</tr>
<tr>
<td width="271" valign="bottom"><span style="text-decoration:underline;"><a href="http://kreditkredit.dk/laan-penge" target="_blank">http://kreditkredit.dk/laan-penge</a></span></td>
</tr>
</tbody>
</table>
]]></content:encoded>
</item>
<item>
<title><![CDATA[The Walrus Magazine discusses O'Regan's Heart of Darkness]]></title>
<link>http://operaprojects2.wordpress.com/?p=69</link>
<pubDate>Tue, 13 May 2008 16:11:58 +0000</pubDate>
<dc:creator>operaprojects2</dc:creator>
<guid>http://operaprojects2.wordpress.com/?p=69</guid>
<description><![CDATA[Arias of Darkness
Setting Joseph Conrad’s classic novel to music.
by Siobhan Roberts
Published in ]]></description>
<content:encoded><![CDATA[<h1>Arias of Darkness</h1>
<p><em>Setting Joseph Conrad’s classic novel to music.</em></p>
<h3>by Siobhan Roberts</h3>
<h5>Published in the <a href="http://www.walrusmagazine.com/archives/2008.06/">June 2008</a> issue.</h5>
<p><span class="smallcaps">brooklyn</span> — On a November night, an audience gathered in the Great Room at American Opera Projects headquarters to get an early glimpse of an unlikely addition to the cultural canon: an opera based on Joseph Conrad’s <em>Heart of Darkness</em>. The librettist, London artist Tom Phillips (whose portrait of Iris Murdoch hangs in Britain’s National PortraitGallery), introduced the performance by offering interpretative outtakes from his umpteen readings of the classic novella, published in 1902.</p>
<p>Read full article: <a href="http://www.walrusmagazine.com/articles/2008.06-field-notes-heart-of-darkness-musical-tom-phillips=siobhan-roberts/">The Walrus Magazine » Joseph Conrad Heart of Darkness Musical » By Siobhan Roberts » Tom Phillips</a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Springmodules cache]]></title>
<link>http://cygni.wordpress.com/?p=230</link>
<pubDate>Wed, 07 May 2008 11:53:55 +0000</pubDate>
<dc:creator>Johan Risén</dc:creator>
<guid>http://cygni.wordpress.com/?p=230</guid>
<description><![CDATA[Springmodules cache
Springmodules är en samling av verktyg och tillägg till Spring Framework. Jag ]]></description>
<content:encoded><![CDATA[<p><strong>Springmodules cache</strong><br />
Springmodules är en samling av verktyg och tillägg till Spring Framework. Jag halkade in på att använda detta då vi i mitt projekt använde OSCache programatiskt och vi insåg att det blev mycket boilerplate kod. Här är ett typiskt <a href="http://www.opensymphony.com/oscache/wiki/API%20Usage.html">användande av OSCache</a>.<br />
<!--more--><br />
En lösning är att använda springmodules cache-stöd för OSCache, EHCache m.fl. Det är en AOP lösning där målobjektet får en proxy som fångar anrop till utvalda metoder, gör en nyckel av anropet och cachar resultatet. Mycket bekvämt!<br />
I sin annotering anger man vilken cache/flush modell som skall användas, modellerna skapar man med fördel i sin spring applicationcontext och innehåller konfiguration för exempelvis hur länge ett objekt ska stanna i cachen. Modellerna skiljer sig lite beroende på val av cache.</p>
<p>Man kan låta proxies automatgenereras utifrån cache/flush annotations eller så kan man explicit skapa proxies per böna. </p>
<p>Ett varningens finger dock, även om det var mycket bekvämt kändes det inte helt moget. Ett ex är att det ännu (v0.9) inte går att flusha cachen på lägre nivå än cache/grupp nivå. Ännu allvarligare är att jag upplevde en minnesläcka i ramverkets interna metadata cachning, dvs cachningen av annotations. Att sluta använda annotations och istället använda proxy-konfiguration i xml går runt problemet. Ytterligare en frustration som tyder på att lösningen inte är helt genomarbetat beskrivs <a href="http://www.jroller.com/habuma/entry/fixing_spring_modules_xsd_errors">här</a><br />
Sammanfattningsvis, bra tänkt men vänta gärna några versioner.</p>
]]></content:encoded>
</item>

</channel>
</rss>
