Re: [aspectwerkz-user] Re: re[aspectwerkz-user] mote weaving?

"Alexandre Vasseur" <[email protected]> Tue, 21 Oct 2008 11:10:38 +0200
Newsgroups gmane.comp.java.aspectwerkz.user
Message-ID <[email protected]>
------=_Part_1153_33350014.1224580238448
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

hot deployment MUST be in the same VM yes. Think deployment (of new aspect
but whose compiled code is already available) as a "runtime weaving"
Amex

On Sun, Oct 19, 2008 at 10:50 PM, neo anderson <[email protected]=
k
> wrote:

>
>
> I follow the example at
>
> http://blogs.codehaus.org/people/jboner/archives/000913_aspect_hot_deploy=
ment_in_practice_implementing_a_jmx_monitoring_aspect_.html
> to do hot deployment, but it fails. There is no error returned to the
> screen. It only prints message like:
>
> Deployer::INFO - deploying aspect [aspect.Observer] in class loader
> sun.misc.Launcher$AppClassLoader@1a16869]
>
> The target application does not print out anything.
>
> The code to do deployment is
>
> package action;
>
> public class Detector{
>
> ...
>        void detect(){
>                System.out.println("Enable aspect! ...");
>                Deployer.deploy(Observer.class, toXML());
>        }
> ...
>        private String toXML(){
>                return "<aspect class=3D\"Observer\"><pointcut name=3D\"co=
unt\"
> expression=3D\"execution(* sys.Server.count(..))\"/></aspect>";
> /* //this xml throws not well formed xml definition exception
>                return "<aspectwerkz>\n" +
>                        "<system id=3D\"Mock Server\">\n"+
>                        "       <package name=3D\"aspect\">\n"+
>                        "               <aspect class=3D\"Observer\">\n"+
>                        "                       <pointcut name=3D\"count\"
> expression=3D\"execution(* sys.Server.count(..))\"/>\n"+
>                        "                       <advice name=3D\"beforeCou=
nt\"
> type=3D\"before\" bind-to=3D\"count\"/>\n"+
>                        "                       <advice name=3D\"afterCoun=
t\"
> type=3D\"after\" bind-to=3D\"count\"/>\n"+
>                        "               </aspect>\n"+
>                        "       </package>\n"+
>                        "       </system>\n"+
>                        "</aspectwerkz>\n";
> */
>        }
>
> Where the Observer.java aspect and the application (Server.java) to be
> weaved is the same as
> http://www.nabble.com/Runtime-weaving-question-to20042123.html
>
> The way to test runtime weaving scenario is
> 1.) launch the server
> 2.) deploy the aspect by `java -cp
>
> "target:$ASPECTWERKZ_HOME/lib/aspectwerkz-2.0.jar:$ASPECTWERKZ_HOME/lib/a=
spectwerkz-core-2.0.jar:$ASPECTWERKZ_HOME/lib/aspectwerkz-extensions-2.0.ja=
r"
> action.Detector 1`
>
> I also have a look at the example in jdk15/test folder, in which it seems
> like the hot deployment is done on the same jvm, e.g.
>
> public class HotDeployedTest ...
>   public void testDeployment() {
> ...
>     Deployer.deploy(HotdeployableAspect.class);
>        target();
> ...
>
> I think I have done something wrong, but do not know where it is. Would
> anyone please give me some hint or advice?
>
> Thank you very much,
>
>
>
>
>
> Jonas Bon=E9r-3 wrote:
> >
> > Yes it is possible, but you will have to define a so-called
> > 'deployment scope' and preweave the classes (will just add tiny hooks,
> > but no aspects). Then you can do hot deploy and undeploy in a running
> > system.
> > Details here:
> >
> http://aspectwerkz.codehaus.org/new_features_in_2_0.html#Hot_deployment_a=
nd_undeployment_of_aspects
> >
> > /Jonas
> >
> > On 10/3/07, Dongkwan Kim <[email protected]> wrote:
> >> Does AspectWerkz support the remote weaving? Let me explain my scenari=
o
> >> in
> >> detail.
> >> Suppose there is a running Java application. It don't know AspectWerkz=
.
> I
> >> want to insert an aspect into the running application. This is called
> the
> >> remote weaving. Is there any way to weave already running Java classes=
?
> >>
> >> DK
> >>
> >
> >
> > --
> > Jonas Bon=E9r
> >
> > http://jonasboner.com
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/remote-weaving--tp13025650p20060099.html
> Sent from the AspectWerkz - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>

------=_Part_1153_33350014.1224580238448
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

hot deployment MUST be in the same VM yes. Think deployment (of new aspect =
but whose compiled code is already available) as a &quot;runtime weaving&qu=
ot;<br>Amex<br><br><div class=3D"gmail_quote">On Sun, Oct 19, 2008 at 10:50=
 PM, neo anderson <span dir=3D"ltr">&lt;<a href=3D"mailto:javadeveloper999@=
yahoo.co.uk">[email protected]</a>&gt;</span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"border-left: 1px solid rgb(204, =
204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
<br>
I follow the example at<br>
<a href=3D"http://blogs.codehaus.org/people/jboner/archives/000913_aspect_h=
ot_deployment_in_practice_implementing_a_jmx_monitoring_aspect_.html" targe=
t=3D"_blank">http://blogs.codehaus.org/people/jboner/archives/000913_aspect=
_hot_deployment_in_practice_implementing_a_jmx_monitoring_aspect_.html</a><=
br>

to do hot deployment, but it fails. There is no error returned to the<br>
screen. It only prints message like:<br>
<br>
Deployer::INFO - deploying aspect [aspect.Observer] in class loader<br>
sun.misc.Launcher$AppClassLoader@1a16869]<br>
<br>
The target application does not print out anything.<br>
<br>
The code to do deployment is<br>
<br>
package action;<br>
<br>
public class Detector{<br>
<br>
...<br>
 &nbsp; &nbsp; &nbsp; &nbsp;void detect(){<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println(=
&quot;Enable aspect! ...&quot;);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Deployer.deploy(Obs=
erver.class, toXML());<br>
 &nbsp; &nbsp; &nbsp; &nbsp;}<br>
...<br>
 &nbsp; &nbsp; &nbsp; &nbsp;private String toXML(){<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return &quot;&lt;as=
pect class=3D\&quot;Observer\&quot;&gt;&lt;pointcut name=3D\&quot;count\&qu=
ot;<br>
expression=3D\&quot;execution(* sys.Server.count(..))\&quot;/&gt;&lt;/aspec=
t&gt;&quot;;<br>
/* //this xml throws not well formed xml definition exception<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return &quot;&lt;as=
pectwerkz&gt;\n&quot; +<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbs=
p; &nbsp;&quot;&lt;system id=3D\&quot;Mock Server\&quot;&gt;\n&quot;+<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbs=
p; &nbsp;&quot; &nbsp; &nbsp; &nbsp; &lt;package name=3D\&quot;aspect\&quot=
;&gt;\n&quot;+<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbs=
p; &nbsp;&quot; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;aspect=
 class=3D\&quot;Observer\&quot;&gt;\n&quot;+<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbs=
p; &nbsp;&quot; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nb=
sp; &nbsp; &nbsp; &lt;pointcut name=3D\&quot;count\&quot;<br>
expression=3D\&quot;execution(* sys.Server.count(..))\&quot;/&gt;\n&quot;+<=
br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbs=
p; &nbsp;&quot; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nb=
sp; &nbsp; &nbsp; &lt;advice name=3D\&quot;beforeCount\&quot;<br>
type=3D\&quot;before\&quot; bind-to=3D\&quot;count\&quot;/&gt;\n&quot;+<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbs=
p; &nbsp;&quot; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nb=
sp; &nbsp; &nbsp; &lt;advice name=3D\&quot;afterCount\&quot;<br>
type=3D\&quot;after\&quot; bind-to=3D\&quot;count\&quot;/&gt;\n&quot;+<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbs=
p; &nbsp;&quot; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/aspec=
t&gt;\n&quot;+<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbs=
p; &nbsp;&quot; &nbsp; &nbsp; &nbsp; &lt;/package&gt;\n&quot;+<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbs=
p; &nbsp;&quot; &nbsp; &nbsp; &nbsp; &lt;/system&gt;\n&quot;+<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbs=
p; &nbsp;&quot;&lt;/aspectwerkz&gt;\n&quot;;<br>
*/<br>
 &nbsp; &nbsp; &nbsp; &nbsp;}<br>
<br>
Where the Observer.java aspect and the application (Server.java) to be<br>
weaved is the same as<br>
<a href=3D"http://www.nabble.com/Runtime-weaving-question-to20042123.html" =
target=3D"_blank">http://www.nabble.com/Runtime-weaving-question-to20042123=
.html</a><br>
<br>
The way to test runtime weaving scenario is<br>
1.) launch the server<br>
2.) deploy the aspect by `java -cp<br>
&quot;target:$ASPECTWERKZ_HOME/lib/aspectwerkz-2.0.jar:$ASPECTWERKZ_HOME/li=
b/aspectwerkz-core-2.0.jar:$ASPECTWERKZ_HOME/lib/aspectwerkz-extensions-2.0=
.jar&quot;<br>
action.Detector 1`<br>
<br>
I also have a look at the example in jdk15/test folder, in which it seems<b=
r>
like the hot deployment is done on the same jvm, e.g.<br>
<br>
public class HotDeployedTest ...<br>
 &nbsp; public void testDeployment() {<br>
...<br>
 &nbsp; &nbsp; Deployer.deploy(HotdeployableAspect.class);<br>
 &nbsp; &nbsp; &nbsp; &nbsp;target();<br>
...<br>
<br>
I think I have done something wrong, but do not know where it is. Would<br>
anyone please give me some hint or advice?<br>
<br>
Thank you very much,<br>
<br>
<br>
<br>
<br>
<br>
Jonas Bon=E9r-3 wrote:<br>
&gt;<br>
&gt; Yes it is possible, but you will have to define a so-called<br>
&gt; &#39;deployment scope&#39; and preweave the classes (will just add tin=
y hooks,<br>
&gt; but no aspects). Then you can do hot deploy and undeploy in a running<=
br>
&gt; system.<br>
&gt; Details here:<br>
&gt; <a href=3D"http://aspectwerkz.codehaus.org/new_features_in_2_0.html#Ho=
t_deployment_and_undeployment_of_aspects" target=3D"_blank">http://aspectwe=
rkz.codehaus.org/new_features_in_2_0.html#Hot_deployment_and_undeployment_o=
f_aspects</a><br>

&gt;<br>
&gt; /Jonas<br>
&gt;<br>
&gt; On 10/3/07, Dongkwan Kim &lt;<a href=3D"mailto:[email protected]">v=
[email protected]</a>&gt; wrote:<br>
&gt;&gt; Does AspectWerkz support the remote weaving? Let me explain my sce=
nario<br>
&gt;&gt; in<br>
&gt;&gt; detail.<br>
&gt;&gt; Suppose there is a running Java application. It don&#39;t know Asp=
ectWerkz. I<br>
&gt;&gt; want to insert an aspect into the running application. This is cal=
led the<br>
&gt;&gt; remote weaving. Is there any way to weave already running Java cla=
sses?<br>
&gt;&gt;<br>
&gt;&gt; DK<br>
&gt;&gt;<br>
&gt;<br>
&gt;<br>
&gt; --<br>
&gt; Jonas Bon=E9r<br>
&gt;<br>
&gt; <a href=3D"http://jonasboner.com" target=3D"_blank">http://jonasboner.=
com</a><br>
&gt;<br>
&gt;<br>
<br>
--<br>
View this message in context: <a href=3D"http://www.nabble.com/remote-weavi=
ng--tp13025650p20060099.html" target=3D"_blank">http://www.nabble.com/remot=
e-weaving--tp13025650p20060099.html</a><br>
Sent from the AspectWerkz - User mailing list archive at Nabble.com.<br>
<br>
<br>
---------------------------------------------------------------------<br>
To unsubscribe from this list, please visit:<br>
<br>
 &nbsp; &nbsp;<a href=3D"http://xircles.codehaus.org/manage_email" target=
=3D"_blank">http://xircles.codehaus.org/manage_email</a><br>
<br>
<br>
</blockquote></div><br>

------=_Part_1153_33350014.1224580238448--