I'm not sure to understand all the problems. If I had to do AOP inside a SU, I would just consider the SU as a spring application (even if it has to contain a JBI endpoint). You can put additional jars needed in the SU and you should be able to use AOP. You don't really need to hack the components or the main configuration file.
Or maybe you want to do AOP without configuring it explicitely ? This is currently not possible. I think it should be doable by extending the components somehow so that they always load other spring configuration files: for example when a component creates a spring ApplicationContext when loading a xbean.xml, it could be configured to always load an aop.xml configuration file that you would provide and which would add all the needed definitions. On 6/26/07, Kuntze, Oliver (EXT) <[EMAIL PROTECTED]> wrote:
Thanks for the prompt answer, Bruce! I think I am lacking some understanding of the basics here. I am trying to advise some classes that belong to my SUs. Since my JBI components are managed by ServiceMix and ServiceMix uses the Spring container, I thought that if I am in a ServiceMix context I can only use Spring AOP by somehow telling ServiceMix "Hey, here is my aspect and her is my Spring xbean config. Now, please pass this info to the Spring container and let Spring handle the AOP stuff.". That is also the reason why I am building a shared library. I thought, if I have to pass aspects to the Spring container which in turn is "under the hood" of ServiceMix, I have to use ServiceMix "technology". I thought ServiceMix would then "see" "Ah, this is Spring AOP stuff. I have to pass this to the Spring container.". Since SAs/SUs and shared libs are the deployable ServiceMix artefacts I know, I chose a shared lib to pass my AOP stuff to ServiceMix. How should one use AOP in a ServiceMix environment? We need runtime weaving. Loadtime and compiletime weaving are no options. So I thought, let's use Spring AOP if ServiceMix uses Spring. As I can see, the latest ServiceMix uses Spring 2 with all its nice AOP improvements. Should I directly use the Spring container used by ServiceMix? I.e. is my aproach to "go through the ServiceMix layer" wrong? Are the ServiceMix components managed by the Spring container so that instead of using the "going through the ServiceMix layer" I should directly configure the Spring container used by ServieMix? Questions over questions. ;-) Again, thanks a lot in advance! Cheers, Oliver. -----Ursprüngliche Nachricht----- Von: Bruce Snyder [mailto:[EMAIL PROTECTED] Gesendet: Dienstag, 26. Juni 2007 07:01 An: [email protected] Betreff: Re: Spring AOP integration in ServiceMix On 6/25/07, okuntze <[EMAIL PROTECTED]> wrote: > > Hi, > > I'm trying to use Spring AOP in my ServiceMix runtime. > > Since I'm apparently doing something basic terribly wrong, it would be > great if you could help me out with some info. > > I have an aspect like this: > > <code> > package de.mycompany.myproject; > > import org.aspectj.lang.annotation.Aspect; > import org.aspectj.lang.annotation.Pointcut; > > @Aspect > public class MonitoringAspect { > @Pointcut("execution(* de.mycompany.myproject..*.*(..)))") > public Object doSomething() { > throw new RuntimeException("Im doSomething Advice!!!"); > } > } > </code> > > Furthermore I have a corresponding xbean file: > > <code> > <?xml version="1.0" encoding="UTF-8"?> <beans > xmlns="http://www.springframework.org/schema/beans" > xmlns:aop="http://www.springframework.org/schema/aop" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > > <aop:aspectj-autoproxy/> > <bean class="de.mycompany.myproject.MonitoringAspect" > id="swiftTransformationMonitoringAspect"/> > </beans> > </code> > > And finally I have a POM like this: > > <code> > <?xml version="1.0" encoding="UTF-8"?> <project > xmlns="http://maven.apache.org/POM/4.0.0" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> > <modelVersion>4.0.0</modelVersion> > <parent> > <groupId>oliver.osiris.playground.sandbox</groupId> > <artifactId>sandbox</artifactId> > <version>1.0</version> > </parent> > > <groupId>oliver.osiris.playground.sandbox.swifttransformation-monitoring </groupId> > <artifactId>swifttransformation-aspect</artifactId> > <name>Osiris :: sandbox :: swifttransformation-monitoring :: > swifttransformation-aspect</name> > <packaging>jbi-shared-library</packaging> > <version>1.0</version> > <url>${site.root}//sandbox/</url> > <dependencies> > <dependency> > <groupId>aspectj</groupId> > <artifactId>aspectjrt</artifactId> > <version>1.5.3</version> > </dependency> > </dependencies> > <build> > <plugins> > <plugin> > <groupId>org.apache.servicemix.tooling </groupId> > <artifactId>jbi-maven-plugin</artifactId> > <version>${servicemix-version}</version> > <extensions>true</extensions> > </plugin> > </plugins> > </build> > </project> > </code> > > So what I am doing is: Using the POM to build a ServiceMix shared > library containing the aspect class and the Spring xbean configuration. > > Unfortunately the advice ist never executed. > > What am I doing wrong? Are the beans you're trying to advise instantiated explicitly by Spring? Also, why are you building a shared library? Bruce -- perl -e 'print unpack("u30","D0G)[EMAIL PROTECTED]&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*" );' Apache Geronimo - http://geronimo.apache.org/ Apache ActiveMQ - http://activemq.org/ Apache ServiceMix - http://servicemix.org/ Castor - http://castor.org/
-- Cheers, Guillaume Nodet ------------------------ Principal Engineer, IONA Blog: http://gnodet.blogspot.com/
