« Return to Thread: Service mix + camel + spring aop aspects
Gert Vanthienen wrote:L.S.,
We should be able to get this to work, but I guess the way classes are
loaded in JBI can make this just a bit harder -- some of the Spring
AOP bits are being loaded from the JBI container classloader so we
might have to add things there. Just a few informational questions
before we start digging into this:
- what version of servicemix are you using and which version of the
servicemix-camel component?
- could you make sure that you're using the same version of Camel in
your own pom.xml (e.g. when defining extra components etc)?
- can you send us the complete stack trace that you're seeing?
Regards,
Gert Vanthienen
------------------------
Open Source SOA: http://fusesource.com
Blog: http://gertvanthienen.blogspot.com/
2009/7/2 akshay_ajmani <akshay.ajmani@gmail.com>:
>
> Hi,
>
> I have implemented the following example
> http://cwiki.apache.org/SM/order-file-processing.html and it is working
> fine. I need to add few modifications to my camel context.xml. My question
> is , is it possible to add spring aspects to camel-context.xml i.e
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <beans xmlns="http://www.springframework.org/schema/beans"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:aop="http://www.springframework.org/schema/aop"
> xmlns:context="http://www.springframework.org/schema/context"
> xsi:schemaLocation="
> http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
> http://activemq.apache.org/camel/schema/spring
> http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
> http://www.springframework.org/schema/aop
> http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
> http://www.springframework.org/schema/context
>
> http://www.springframework.org/schema/context/spring-context-2.5.xsd">
>
>
> <context:annotation-config />
>
> <aop:aspectj-autoproxy/>
>
>
>
> <camelContext id="camel"
> xmlns="http://activemq.apache.org/camel/schema/spring">
> <package>org.camel.su</package>
> </camelContext>
> <bean id="firstAspect" class="org.aspect.FirstAspect"/>
>
> </beans>
>
>
>
> I have my pointcuts defined in the java code using spring annotations.
>
> The code is as follows:
>
> @Aspect
> public class SystemArchitecture {
>
>
>
> @Pointcut("execution(* *(..))")
> public void myFirstPointCut()
> {
>
> }
>
> }
>
> package org.aspect;
>
> import org.aspectj.lang.ProceedingJoinPoint;
> import org.aspectj.lang.annotation.Around;
> import org.aspectj.lang.annotation.Aspect;
>
> @Aspect
> public class FirstAspect {
>
>
> @Around("SystemArchitecture.myFirstPointCut()")
> public void firstAspect(ProceedingJoinPoint joinPoint)
> {
> System.out.println("PRINTING FIRST ASPECT");
> try {
> joinPoint.proceed();
> } catch (Throwable e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
> }
> }
>
>
>
>
> If defining aspects in camel-context.xml is possible, then how do I define
> aspects on my RouteBuilder class.Because I want a particular piece of code
> to be always executed before my route builder class is called and I do not
> want to embed that code in the routebuilder class.
>
> For ex: If I do some thing like this below,
> <?xml version="1.0" encoding="UTF-8"?>
>
> <beans xmlns="http://www.springframework.org/schema/beans"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:aop="http://www.springframework.org/schema/aop"
> xmlns:context="http://www.springframework.org/schema/context"
> xsi:schemaLocation="
> http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
> http://activemq.apache.org/camel/schema/spring
> http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
> http://www.springframework.org/schema/aop
> http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
> http://www.springframework.org/schema/context
>
> http://www.springframework.org/schema/context/spring-context-2.5.xsd">
>
>
> <context:annotation-config />
>
> <aop:aspectj-autoproxy/>
>
>
>
> <camelContext id="camel"
> xmlns="http://activemq.apache.org/camel/schema/spring">
> <routeBuilder ref="someRouterBuilder"/>
> </camelContext>
> <bean id="firstAspect" class="org.aspect.FirstAspect"/>
> <bean id="someRouterBuilder" class="org.camel.su.MyRouteBuilder"/>
> </beans>
>
> public class MyRouteBuilder extends RouteBuilder {
>
> @Override
> public void configure() throws Exception {
> System.out.println("IN ROUTE BUILDER#####");
>
> // from our camelService which is called by the file poller
>
> from("jbi:service:http://servicemix.apache.org/example/orderProcessing")
> // we process the received order xml
> .process(new OrderProcessor())
> // and send the result xml back to the file sender
> .to("jbi:service:http://servicemix.apache.org/example/fileSender");
>
>
> }
>
>
> }
>
>
>
> I get an exception is saying that routeBuilder should of type
> org.apache.camel.builder.RouteBuilder. I do not understand why I am getting
> this exception as my RouteBuilder class is already extending the camel
> RouteBuilder class.
>
>
> Please help me these queries.I thank you all for your time.
>
>
>
>
>
>
>
> --
> View this message in context: http://www.nabble.com/Service-mix-%2B-camel-%2B-spring-aop-aspects-tp24307006p24307006.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>
-----
---
Gert Vanthienen
http://gertvanthienen.blogspot.com
« Return to Thread: Service mix + camel + spring aop aspects
| Free embeddable forum powered by Nabble | Forum Help |