Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] DI Constructor issue

Hi,

You might have more luck with this question on the Spring AOP forums at:

http://forum.springsource.org/forumdisplay.php?f=31

I'm not an expert (although I really ought to be...) on the spring
configuration with AspectJ.

cheers,
Andy

On 3 June 2010 03:54, Yetti <elliot.trussell@xxxxxxxxxxxxx> wrote:
>
> Hi,
>
> Ive just started using aop for some simple logging in a new project. Ive
> read through quite a few threads and various sites but cant seem to quite
> understand why Im getting the problem.
>
> I am using Spring 2.5.5 to inject various classes for a JMS project and also
> using the schema based spring-aop namespace due to being restricted to
> 1.4jvm. I am also using aspectJ 1.5.4.
>
> The problem is that although logging seems to work fine for any classes that
> use a default constructor, classes that have constructors with args; 1. dont
> get logging and 2. throw an error within the DI that seems to be a
> nullpointer issue, Im only guessing at this as no info is given.
>
> What I also dont understand is that I am using the method pointcut pattern
> so why is this causing a problem with the constructor?
>
> Heres my code, Hope Im not just being dumb (though most likely!)
>
> <bean id="sonicConfig"
>
> class="com.homeserve.guidewire.plugins.messaging.edi.outbound.transport.SonicConfig">
>                <constructor-arg
> value="SonicBroker=tcp://hgbsmdev02.hgb.hs.int:2531;SonicUsername=Administrator;SonicPassword=Administrator"
> />
> </bean>
>
>        <bean id="aopLogging"
>
> class="com.homeserve.guidewire.plugins.messaging.edi.logging.LoggingInterceptor">
>        </bean>
>
>        <aop:config proxy-target-class="false">
>                <aop:aspect id="aopLoggingAspect" ref="aopLogging">
>
>                        <aop:pointcut id="loggingPointCut"
>                                expression="execution( *
> com.homeserve.guidewire.plugins.messaging.edi.outbound..*.*(..))" />
>
>                        <aop:around method="aopLogging" pointcut-ref="loggingPointCut" />
>
>                </aop:aspect>
>        </aop:config>
>
>    public SonicConfig(String sonicConnectionString) throws ParseException
>    {
>        this.sonicConnectionString = sonicConnectionString;
>        parseSonicConnectionString();
>    }
>
> public class LoggingInterceptor {
>
>        public Object aopLogging(ProceedingJoinPoint pjp) throws Throwable{
>                Logger log = Logger.getLogger(LoggingInterceptor.class);
>                Object retValue = null;
>                Object[] args = pjp.getArgs();
>                try     {
>
>                        StringBuffer entering = new StringBuffer();
>                        StringBuffer leaving = new StringBuffer();
>                        Signature sig = pjp.getSignature();
>                                String clazz = pjp.getSignature().getDeclaringType().getName();
>                                entering.append(clazz.substring(clazz.lastIndexOf(".")+1,
> clazz.length()));
>                                entering.append(".");
>                                entering.append(sig.getName());
>                                entering.append("(");
>                                leaving.append(entering.toString());
>                                for (int i = 0; i < args.length; i++) {
>                                        if (i > 0) {
>                                                entering.append(", ");
>                                        }
>                                        entering.append(args[i]);
>                                }
>                                entering.append(")]");
>                                SourceLocation sl = pjp.getSourceLocation();
>                                log.info("Entering [" + entering);
>
>                        retValue =  pjp.proceed();
>
>                        leaving.append(")");
>                        log.info("Leaving [" + leaving + " Return value: " + retValue);
>
>                }
>                catch (Exception e)
>                {
>                        log.error(e);
>                }
>                return retValue;
>        }
> }
>
> Thanks
> Yetti
> --
> View this message in context: http://aspectj.2085585.n4.nabble.com/DI-Constructor-issue-tp2241500p2241500.html
> Sent from the AspectJ - users mailing list archive at Nabble.com.
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>


Back to the top