Re: [aspectwerkz-user] Hot deployment questions
Alexandre Vasseur <[email protected]>
| Newsgroups | gmane.comp.java.aspectwerkz.user |
|---|---|
| Message-ID | <[email protected]> |
Hi Vincent inlined.. On Apr 10, 2005 11:00 AM, Vincent Massol <[email protected]> wrote: > 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? > 1/ accessing the definition model to get the scope should be : DeploymentScope scope = SystemDefinitionCONTAINER.getDefinitionFor(loader, systemId).getDeploymentScope("toString"); No new() - that would not do anything. > 2/ In > http://blogs.codehaus.org/people/jboner/archives/000913_aspect_hot_deploymen > 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" > 2/ aop.xml is mandatory in all cases If the scope is defined as an annotation, ie in an aspect, then it is mandatory to declare the aspect in aop.xml > Thus it seems possible not to have anything defined in aop.xml. Thus > something like this would work, right? > > <aspectwerkz> > <system id="cactus2"/> > </aspectwerkz> > No, won't work (nothing would be prepared for the scope to be further used) > 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> > 3/ generic scope is supported (and that s the motivation of it: allow deployment to a subset of that scope upon user/app needs but thus under control by the deployer) Yes, very generic scope should work. The idea there would be to deploy to a subset of this wide scope > 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. > 4/ unrelated aop.xml may contain a scope or an aspect that defines a scope - among other things. Then using this deploy(aspectClass, xmlDefThatRefineAspectClassAnnotationIfAny) will deploy according to the usual deployment rule (annotation + xml override) You should actually use the "scoped" version of this method: public static DeploymentHandle deploy(final Class aspect, final String xmlDef, final DeploymentScope deploymentScope) { > > 5/ If the aop.xml file is empty, do I still need one? > From the previous answer, yes, one is mandatory, and it is actually not empty. > 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 :-) Should we write a more comprehensice tutorial on that ? > > Thanks > -Vincent > Alex