Hi
What version of Camel are you using?
There was an issue with 1.6.0 or older not being able to be IoC in
some circumstances if the bean was a RouteBuilder instance.
And thats the case with your route builder.
However when using proxy it can be on interface or class level. And
aspectj looks like it does at classlevel so hence something can go
wrong when Camel is not able to see it as a RouteBuilder instance.
On Thu, Jul 2, 2009 at 3:46 PM, akshay-ajmani<akshay.ajmani@gmail.com> wrot=
e:
>
> Hi,
>
> =A0 =A0I 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 questio=
n
> is , is it possible to add spring aspects to camel-context.xml i.e
>
> <?xml version=3D"1.0" encoding=3D"UTF-8"?>
>
> <beans xmlns=3D"http://www.springframework.org/schema/beans"
> =A0 =A0 =A0 xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance"
> =A0 =A0 =A0 xmlns:aop=3D"http://www.springframework.org/schema/aop"
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0xmlns:context=3D"http://www.springframewor=
k.org/schema/context"
> =A0 =A0 =A0 xsi:schemaLocation=3D"
> =A0 =A0 =A0 http://www.springframework.org/schema/beans
> =A0 =A0 =A0 http://www.springframework.org/schema/beans/spring-beans-2.5.=
xsd
> =A0 =A0 =A0 http://activemq.apache.org/camel/schema/spring
> =A0 =A0 =A0 http://activemq.apache.org/camel/schema/spring/camel-spring.x=
sd
> =A0 =A0 =A0 http://www.springframework.org/schema/aop
> =A0 =A0 =A0 http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
> =A0 =A0 =A0 http://www.springframework.org/schema/context
>
> http://www.springframework.org/schema/context/spring-context-2.5.xsd">
>
>
> =A0 =A0 =A0 <context:annotation-config />
>
> =A0 =A0 =A0 =A0<aop:aspectj-autoproxy/>
>
>
>
> =A0<camelContext id=3D"camel"
> xmlns=3D"http://activemq.apache.org/camel/schema/spring">
> =A0 =A0 =A0 =A0 =A0 <package>org.camel.su</package>
> =A0</camelContext>
> =A0<bean id=3D"firstAspect" class=3D"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 {
>
>
>
> =A0 =A0 =A0 =A0@Pointcut("execution(* *(..))")
> =A0 =A0 =A0 =A0public void myFirstPointCut()
> =A0 =A0 =A0 =A0{
>
> =A0 =A0 =A0 =A0}
>
> }
>
> package org.aspect;
>
> import org.aspectj.lang.ProceedingJoinPoint;
> import org.aspectj.lang.annotation.Around;
> import org.aspectj.lang.annotation.Aspect;
>
> @Aspect
> public class FirstAspect {
>
>
> =A0 =A0 =A0 =A0@Around("SystemArchitecture.myFirstPointCut()")
> =A0 =A0 =A0 =A0public void firstAspect(ProceedingJoinPoint joinPoint)
> =A0 =A0 =A0 =A0{
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0System.out.println("PRINTING FIRST ASPECT"=
);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0try {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0joinPoint.=
proceed();
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} catch (Throwable e) {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0// TODO Auto-generated cat=
ch block
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0e.printStackTrace();
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
> =A0 =A0 =A0 =A0}
> }
>
>
>
>
> If defining aspects in camel-context.xml is possible, then how do I defin=
e
> aspects on my RouteBuilder class.Because I want a particular piece of cod=
e
> to be always executed before my route builder class is called and I do no=
t
> want to embed that code in the routebuilder class.
>
> For ex: If I do some thing like this below,
> <?xml version=3D"1.0" encoding=3D"UTF-8"?>
>
> <beans xmlns=3D"http://www.springframework.org/schema/beans"
> =A0 =A0 =A0 xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance"
> =A0 =A0 =A0 xmlns:aop=3D"http://www.springframework.org/schema/aop"
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0xmlns:context=3D"http://www.springframewor=
k.org/schema/context"
> =A0 =A0 =A0 xsi:schemaLocation=3D"
> =A0 =A0 =A0 http://www.springframework.org/schema/beans
> =A0 =A0 =A0 http://www.springframework.org/schema/beans/spring-beans-2.5.=
xsd
> =A0 =A0 =A0 http://activemq.apache.org/camel/schema/spring
> =A0 =A0 =A0 http://activemq.apache.org/camel/schema/spring/camel-spring.x=
sd
> =A0 =A0 =A0 http://www.springframework.org/schema/aop
> =A0 =A0 =A0 http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
> =A0 =A0 =A0 http://www.springframework.org/schema/context
>
> http://www.springframework.org/schema/context/spring-context-2.5.xsd">
>
>
> =A0 =A0 =A0 <context:annotation-config />
>
> =A0 =A0 =A0 =A0<aop:aspectj-autoproxy/>
>
>
>
> =A0<camelContext id=3D"camel"
> xmlns=3D"http://activemq.apache.org/camel/schema/spring">
> <routeBuilder ref=3D"someRouterBuilder"/>
> =A0</camelContext>
> =A0<bean id=3D"firstAspect" class=3D"org.aspect.FirstAspect"/>
> =A0<bean id=3D"someRouterBuilder" class=3D"org.camel.su.MyRouteBuilder"/>
> </beans>
>
> public class MyRouteBuilder extends RouteBuilder {
>
> =A0 =A0 =A0 =A0@Override
> =A0 =A0 =A0 =A0public void configure() throws Exception {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0System.out.println("IN ROUTE BUILDER#####"=
);
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0// from our camelService which is called b=
y the file poller
>
> from("jbi:service:http://servicemix.apache.org/example/orderProcessing")
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 // we process the received order xml
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 .process(new OrderProcessor())
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 // and send the result xml back to th=
e file sender
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 .to("jbi:service:http://servicemix.ap=
ache.org/example/fileSender");
>
>
> =A0 =A0 =A0 =A0}
>
>
> =A0 =A0 =A0 =A0}
>
>
>
> I get an exception is saying that routeBuilder should of type
> org.apache.camel.builder.RouteBuilder. I do not understand why I am getti=
ng
> 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.
>
>
>
>
>
>
>
>