<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    Re: The reuse&&JBoss AOP
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/hsma">loupi loupi</a> in <i>JBoss AOP</i> - <a href="http://community.jboss.org/message/584755#584755">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p><span style="font-size: 11pt; background-color: white; font-family: 'Calibri','sans-serif';">Hello, </span><span style="background-color: white; font-family: 'Calibri','sans-serif'; font-size: 11pt;"><br/>Thank you for your reply,&#160; <span class="longtext">The example that I want to realise is the following(Realization of the observer design pattern with JBossAOP): </span></span></p><p><span style="font-size: 11pt; background-color: white; font-family: 'Calibri','sans-serif';">Flower (Subject ): </span></p><blockquote class="jive-quote"><p><strong style="font-size: 10pt; font-family: 'Courier New';">package</strong><span style="font-family: 'Courier New'; font-size: 10pt;"> Bee;</span></p><p><strong style="font-size: 10pt; font-family: 'Courier New';">public</strong><span style="font-family: 'Courier New'; font-size: 10pt;"> <strong>class</strong> Flower {</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-family: 'Courier New'; font-size: 10pt;">&#160;&#160;&#160;&#160;&#160; <strong>private</strong> <strong>boolean</strong> isOpen; </span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-family: 'Courier New'; font-size: 10pt;">&#160;&#160;&#160;&#160;&#160; <strong>public</strong> <strong>boolean</strong> isOpen(){<strong>returnthis</strong>.isOpen;}</span></p><p>&#160;&#160;&#160;&#160;&#160; </p><p><span style="font-family: 'Courier New'; font-size: 10pt;">&#160;&#160;&#160;&#160;&#160; <strong>public</strong> Flower(){</span></p><p><span style="font-family: 'Courier New'; font-size: 10pt;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <strong>this</strong>.isOpen=<strong>false</strong>;</span></p><p><span style="font-family: 'Courier New'; font-size: 10pt;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</span></p><p>&#160;&#160;&#160;&#160;&#160; </p><p><span style="font-family: 'Courier New'; font-size: 10pt;">&#160;&#160;&#160;&#160;&#160; <strong>public</strong> <strong>void</strong> open(){</span></p><p><span style="font-family: 'Courier New'; font-size: 10pt;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <strong>this</strong>.isOpen=<strong>true</strong>;</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </p><p><span style="font-family: 'Courier New'; font-size: 10pt;">&#160;&#160;&#160;&#160;&#160; }</span></p><p>&#160;&#160;&#160;&#160;&#160; </p><p><span style="font-family: 'Courier New'; font-size: 10pt;">&#160;&#160;&#160;&#160;&#160; <strong>public</strong> <strong>void</strong> close(){</span></p><p><span style="font-family: 'Courier New'; font-size: 10pt;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <strong>this</strong>.isOpen=<strong>false</strong>;</span></p><p><span style="font-family: 'Courier New'; font-size: 10pt;">&#160;&#160;&#160;&#160;&#160; }</span></p><p><span style="font-family: 'Courier New'; font-size: 10pt;">}</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p></blockquote><p><span class="longtext">The Bee class observe&#160; the opening and closing of Flower (attribute(isOpen)) </span><br/><span class="hps"><span lang="EN" style="font-family: 'Calibri','sans-serif'; font-size: 11pt;"> </span></span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"><strong><span class="hps"><span lang="EN" style="font-family: 'Calibri','sans-serif'; font-size: 11pt;"> </span></span></strong>&#160;</p><p><strong><span class="hps"><span lang="EN" style="font-family: 'Calibri','sans-serif'; font-size: 11pt;">PS: for</span></span><span class="shorttext"><span lang="EN" style="font-family: 'Calibri','sans-serif'; font-size: 11pt;"> </span><span class="hps"><span lang="EN" style="font-family: 'Calibri','sans-serif'; font-size: 11pt;">easier reuse</span></span> of </span><span style="font-size: 11pt; font-family: 'Calibri','sans-serif';">the Bee class, we put the Update method (observer role)in another class and we make an introduction </span></strong></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 11pt; background-color: white; font-family: 'Calibri','sans-serif';">Bee (Observer ): </span></p><pre class="jive_text_macro jive_macro_quote"><p><strong style="font-size: 10pt; font-family: 'Courier New';">package</strong><span style="font-family: 'Courier New'; font-size: 10pt;"> Bee;</span> </p><p><strong style="font-size: 10pt; font-family: 'Courier New';">public</strong><span style="font-family: 'Courier New'; font-size: 10pt;"> <strong>class</strong> Bee {</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><strong style="font-size: 10pt; font-family: 'Courier New';">private</strong><span style="font-family: 'Courier New'; font-size: 10pt;"> String name;</span></p><p>&#160;&#160;&#160;&#160;&#160; </p><p><strong style="font-size: 10pt; font-family: 'Courier New';">public</strong><span style="font-family: 'Courier New'; font-size: 10pt;"> Bee(String name){</span></p><p><span style="font-family: 'Courier New'; font-size: 10pt;">&#160;&#160;&#160;&#160;&#160; <strong>this</strong>.name = name;</span></p><p><span style="font-family: 'Courier New'; font-size: 10pt;">}</span></p><p>&#160;&#160;&#160;&#160;&#160; </p><p><strong style="font-size: 10pt; font-family: 'Courier New';">public</strong><span style="font-family: 'Courier New'; font-size: 10pt;"> <strong>void</strong> dinner(){</span></p><p><span style="font-family: 'Courier New'; font-size: 10pt;">&#160;&#160;&#160;&#160;&#160; System.<em>out</em>.println("Bee "+ name </span></p><p><span style="font-family: 'Courier New'; font-size: 10pt;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; + "'s breakfast time!");</span></p><p><span style="font-family: 'Courier New'; font-size: 10pt;">&#160;&#160;&#160;&#160;&#160; }</span></p><p>&#160;&#160;&#160;&#160;&#160; </p><p><span style="font-family: 'Courier New'; font-size: 10pt;">&#160;&#160;&#160;&#160;&#160; <strong>public</strong> <strong>void</strong> rest(){</span></p><p><span style="font-family: 'Courier New'; font-size: 10pt;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.<em>out</em>.println("Bee" + name </span></p><p><span style="font-family: 'Courier New'; font-size: 10pt;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; + "'s bed time!");</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </p><p><span style="font-family: 'Courier New'; font-size: 10pt;">&#160;&#160;&#160;&#160;&#160; }&#160;&#160;&#160;&#160; </span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </p><p><span style="font-family: 'Courier New'; font-size: 10pt;">}</span></p></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 11pt; background-color: white; font-family: 'Calibri','sans-serif';">The interface for all observers is the following:</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"><span style="font-size: 11pt; background-color: white; font-family: 'Calibri','sans-serif';"> </span>&#160;</p><pre class="jive_text_macro jive_macro_quote"><p><strong style="font-size: 10pt; font-family: 'Courier New';">package</strong><span style="font-family: 'Courier New'; font-size: 10pt;"> Bee ;</span></p><p><strong style="font-size: 10pt; font-family: 'Courier New';">public</strong><span style="font-family: 'Courier New'; font-size: 10pt;"> <strong>interface</strong>FlowerObserver {</span>&#160;&#160;&#160; </p><p><span style="font-family: 'Courier New'; font-size: 10pt;">&#160;&#160;&#160;&#160;&#160; <strong>public</strong> <strong>void</strong> update();</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-family: 'Courier New'; font-size: 10pt;">}</span></p></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 11pt; font-family: 'Calibri','sans-serif';">And Mixin class is as follows: </span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"><span style="font-size: 11pt; background-color: white; font-family: 'Calibri','sans-serif';"> </span>&#160;</p><pre class="jive_text_macro jive_macro_quote"><p><strong style="font-size: 10pt; font-family: 'Courier New';">package</strong><span style="font-family: 'Courier New'; font-size: 10pt;"> Bee;</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><strong style="font-size: 10pt; font-family: 'Courier New';">public</strong><span style="font-family: 'Courier New'; font-size: 10pt;"> <strong>class</strong> BeeObserver <strong>implements </strong>FlowerObserver{</span></p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </p><p><span style="font-family: 'Courier New'; font-size: 10pt;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; Bee bee;</span></p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </p><p><span style="font-family: 'Courier New'; font-size: 10pt;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <strong>public </strong>BeeObserver(Bee bee){<strong>this</strong>.bee=bee;}</span></p><p><span style="font-family: 'Courier New'; font-size: 10pt;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <strong>public void</strong> update(){</span></p><p><span style="font-family: 'Courier New'; font-size: 10pt;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <strong>if</strong> (<span style="text-decoration: underline;">isOpen</span>) //</span>the attribute value of Flower</p><p><span style="font-family: 'Courier New'; font-size: 10pt;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; bee.dinner(); </span></p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </p><p><span style="font-family: 'Courier New'; font-size: 10pt;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <strong>else</strong>&#160; bee.rest();</span></p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </p><p><span style="font-family: 'Courier New'; font-size: 10pt;">}}</span></p></pre><p><span style="font-size: 11pt; font-family: 'Calibri','sans-serif';">Finally the Main class: <br/></span></p><pre class="jive_text_macro jive_macro_quote"><p><strong style="font-size: 10pt; font-family: 'Courier New';">package</strong><span style="font-family: 'Courier New'; font-size: 10pt;"> Bee;</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><strong style="font-size: 10pt; font-family: 'Courier New';">public</strong><span style="font-family: 'Courier New'; font-size: 10pt;"> <strong>class</strong> Main {</span></p><p><strong style="font-size: 10pt; font-family: 'Courier New';">public</strong><span style="font-family: 'Courier New'; font-size: 10pt;"> <strong>static</strong> <strong>void</strong>main(String[] args) {</span></p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; </p><p><span style="font-family: 'Courier New'; font-size: 10pt;">&#160;&#160;&#160;&#160;&#160; Flower f = <strong>new</strong> Flower();&#160;&#160;&#160;&#160; </span></p><p><span style="font-family: 'Courier New'; font-size: 10pt;">&#160;&#160;&#160;&#160;&#160; Beeb1 = <strong>new</strong> Bee("B1");</span></p><p><span style="font-family: 'Courier New'; font-size: 10pt;">&#160;&#160;&#160;&#160;&#160; Beeb2 = <strong>new</strong> Bee("B2");</span></p><p>&#160;&#160;&#160;&#160;&#160; </p><p><span style="font-family: 'Courier New'; font-size: 10pt;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; f.open();</span></p><p><span style="font-family: 'Courier New'; font-size: 10pt;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; f.close();</span></p><p><span style="font-family: 'Courier New'; font-size: 10pt;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; f.open();</span></p><p><span style="font-family: 'Courier New'; font-size: 10pt;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.<em>out</em>.println("c'estbon");</span></p><p><span style="font-family: 'Courier New'; font-size: 10pt;">&#160;&#160;&#160; }</span></p><p><span style="font-family: 'Courier New'; font-size: 10pt;">}</span></p></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 11pt; font-family: 'Calibri','sans-serif';">theXML file: </span></p><p><span style="font-size: 11pt; font-family: 'Calibri','sans-serif';"><br/></span></p><pre class="jive_text_macro jive_macro_quote"><p><span style="font-family: 'Courier New'; font-size: 10pt;">&lt;?xmlversion="1.0" encoding="UTF-8"?&gt;</span></p><p><span style="font-family: 'Courier New'; font-size: 10pt;">&lt;aop&gt;</span></p><p>&#160;&#160; </p><p><span style="font-family: 'Courier New'; font-size: 10pt;">&#160;&#160; &lt;introductionclass="Bee.Bee"&gt;</span></p><p><span style="font-family: 'Courier New'; font-size: 10pt;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;mixin&gt;</span></p><p><span style="font-family: 'Courier New'; font-size: 10pt;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;interfaces&gt;Bee.FlowerObserver&lt;/interfaces&gt; </span></p><p><span style="font-family: 'Courier New'; font-size: 10pt;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;class&gt;Bee.BeeObserver&lt;/class&gt;</span></p><p><span style="font-family: 'Courier New'; font-size: 10pt;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;construction&gt;new Bee.BeeObserver(this)&lt;/construction&gt;</span></p><p><span style="font-family: 'Courier New'; font-size: 10pt;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/mixin&gt;</span></p><p><span style="font-family: 'Courier New'; font-size: 10pt;">&#160;&#160;&#160; &lt;/introduction&gt;&#160; </span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-family: 'Courier New'; font-size: 10pt;">&#160;&#160; &lt;aspect class="Bee.BeeObserver"/&gt;</span></p><p><span style="font-family: 'Courier New'; font-size: 10pt;">&#160;&#160; &lt;bind pointcut="set(private boolean Bee.Flower-&gt;isOpen)"&gt;</span></p><p><span style="font-family: 'Courier New'; font-size: 10pt;">&#160;&#160; &lt;after aspect="Bee.BeeObserver" name="update"/&gt;</span></p><p><span style="font-family: 'Courier New'; font-size: 10pt;">&#160;&#160; &lt;/bind&gt;</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-family: 'Courier New'; font-size: 10pt;">&lt;/aop&gt;</span></p></pre><p><span style="font-size: 11pt; font-family: 'Calibri','sans-serif';">This code contains several errors!! but I would have the following result: </span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><strong><span style="font-size: 11pt; font-family: 'Calibri','sans-serif';">B1 Bee's breakfast time! </span><span style="font-family: 'Calibri','sans-serif'; font-size: 11pt;"><br/>B2 Bee's breakfast time! <br/>B1 Bee's bed time! <br/>B2 Bee's bed time! <br/>B1 Bee's breakfast time! <br/>B2 Bee's breakfast time! </span></strong></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><strong style="font-size: 11pt; font-family: 'Calibri','sans-serif';">Tahnk's in advance <span> :) </span><br/></strong></p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/584755#584755">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in JBoss AOP at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2027">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>