RE: [aspectwerkz-user] Hot deployment questions

"Mihir Mehta" <[email protected]>
Newsgroups gmane.comp.java.aspectwerkz.user
Message-ID <000001c53de4$c4c48b20$bc02a8c0@vhalu>
Here is what I have found through some help and investigation:

Getting deployment scope:
        	SystemDefinition sysDef =
SystemDefinitionContainer.getDefinitionFor(this.getClass().getClassLoade
r(),"webapp");

Where "webapp" is the systemid from aop.xml.

Am not sure about which classloader, but in a web application the
webappclassloader seems to work when the aop.xml is in META-INF dir of
one of the jars in WEB-INF/lib dir.


The deployment scope defines all the possible join points where you want
the aspect to be deployed. So if you have planned to provide hot
deployment capability for all your code and it resides in org.mycode.*,
then you would define a deployment scope as such.

You also have to have all your aspects defined (am not too sure about
this).

Now, when you want to instrument some part of your code and apply some
aspect to it using hot deployment, you would have something in the
application that can take the xmldefinition and aspect classname as
argument and then do the following:

- assume your aop.xml is 
<aspectwerkz>
    <system id="webapp">
            <deployment-scope name="myscope"
expression="execution(public * org.mypackage..*.*(..))"/>
    </system>
</aspectwerkz>

- to get system definition:
        	SystemDefinition sysDef =
SystemDefinitionContainer.getDefinitionFor(this.getClass().getClassLoade
r(),"webapp");

- to get deployment scope (e.g. if your aop.xml was 
             DeploymentScope scope =
sysDef.getDeploymentScope("name_of_your_scope_from_aop.xml i.e.
myscope");
                System.out.println("Scope is: "+scope.getExpression());

- now deploy the aspect you want
    	    
     DeploymentHandle handle = 
     	    	Deployer.deploy(YOUR_ASPECT_CLASS.class,
"<aspect name='measureTime'>" +
      "<pointcut name='usermanager' " +
"expression='execution(public *
org.mypackage.subpackage_to_instrument.*.*(..))'/> " +
	"<advice name='trace' type='around' bind-to='usermanager'/> " +
	
"</aspect>",
	scope);






-----Original Message-----
From: Vincent Massol [mailto:[email protected]] 
Sent: Sunday, April 10, 2005 2:00 AM
To: [email protected]
Subject: [aspectwerkz-user] Hot deployment questions

Hi,

I'm still trying to get hot deployment to work for Cactus2... I have now
decided to try using JDK 5.0 to get started.

I have some questions:

1/ On http://aspectwerkz.codehaus.org/dynamic_aop.html it says to use
the
following to get a deployment scope:

DeploymentScope scope = SystemDefinition.getDefinitionFor(loader,
systemId).getDeploymentScope("toString");

However the SystemDefinition object does not have a static
getDefinition()
method. It does have a non-static method of this name though. How do I
get a
SystemDefinition object? Do I need to create one using "new"? If so what
string should I pass? The same as the systemId defined in aop.xml?

2/ In
http://blogs.codehaus.org/people/jboner/archives/000913_aspect_hot_deplo
ymen
t_in_practice_implementing_a_jmx_monitoring_aspect_.html, Jonas says, in
the
"Define a deployment scope" section:

"This can be done either in the META-INF/aop.xml file or using
annotations
in the aspect class"

Thus it seems possible not to have anything defined in aop.xml. Thus
something like this would work, right?

<aspectwerkz>
  <system id="cactus2"/>
</aspectwerkz>

3/ Would it also work if I have a generic deployment scope such as:

<aspectwerkz>
  <system id="cactus2">
    <deployment-scope name="allcode" expression="within(..)"/>
  </system>
</aspectwerkz>

4/ If I use the Deployer.deploy(class, xmlDef) method, do I also need to
define the xmlDef in the aop.xml file or can it be empty.

5/ If the aop.xml file is empty, do I still need one?

Thanks and sorry for all those newbie questions but I really have a hard
time understanding all this even though I have read and re-read at least
5
times the docs on the web site ;-) I should probably read the source
code to
try to understand how it all works but then this is a bigger task which
I
would prefer not to start now :-)

Thanks
-Vincent



-- 
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.9.5 - Release Date: 4/7/2005
 

-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.9.5 - Release Date: 4/7/2005
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.