Olá Pessoal!
Estou tentando modificar o log de um projeto para Spring AOP. Por isso, pesquisando na web, encontrei aqui no fórum algumas dicas. Consegui colocar pra funcionar inclusive. Mas só que quando eu configuro pra interceptar qualquer classe, ou seja, *, começo a obter conflitos com os beans criados nos daosContext.xml e nos controladoresContext.xml da vida. O código é simples:
[code]public class LoggingInterceptor implements MethodBeforeAdvice, AfterReturningAdvice {
private static org.apache.commons.logging.Log logger = null;
public LoggingInterceptor() {
}
public void before(Method arg0, Object[] arg1, Object arg2)
throws Throwable {
logger = LogFactory.getLog(arg2.getClass());
logger.info("Antes do método => " + arg0.getName());
}
public void afterReturning(Object arg0, Method arg1, Object[] arg2,
Object arg3) throws Throwable {
// TODO Auto-generated method stub
}
}[/code]
E o applicationContext.xml está assim:
[code]<?xml version="1.0" encoding="UTF-8"?>
controlador* loggingInterceptor<!-- Classe de conselho essa classe que será executada -->
<bean id="loggingInterceptor" class="com.provider.discador.util.LoggingInterceptor"/>
[/code]
Se eu mudar o valor do property “beanNames” para Action, funciona perfeito. Mas com os valores controlador ou simplesmente *, encontro erro:
[ERROR][2009-11-10:04:59:21]= (org.springframework.web.context.ContextLoader.initWebApplicationContext(215)) - Context initialization failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'controladorAgendamentoTarget' defined in ServletContext resource [/WEB-INF/controlador-config/controladorDiscadorContext.xml]: Unsatisfied dependency expressed through bean property 'controladorClienteMailing': : Error creating bean with name 'controladorClienteMailingTarget': Bean with name 'controladorClienteMailingTarget' has been injected into other beans [controladorCampanhaTarget,controladorContatoTarget,controladorBlacklistTarget] in its raw version as part of a circular reference, but has eventually been wrapped. This means that said other beans do not use the final version of the bean. This is often the result of over-eager type matching - consider using 'getBeanNamesOfType' with the 'allowEagerInit' flag turned off, for example.; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'controladorClienteMailingTarget': Bean with name 'controladorClienteMailingTarget' has been injected into other beans [controladorCampanhaTarget,controladorContatoTarget,controladorBlacklistTarget] in its raw version as part of a circular reference, but has eventually been wrapped. This means that said other beans do not use the final version of the bean. This is often the result of over-eager type matching - consider using 'getBeanNamesOfType' with the 'allowEagerInit' flag turned off, for example.
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByType(AbstractAutowireCapableBeanFactory.java:1091)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:982)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
Ou seja, alguns controladores apresentam incompatibilidade com o interceptor. Daí, não sei oq fazer pra que o meu LogginInterceptor possa interceptar e logar todos os métodos de todas as classes. Parece realmente ser um problema de conflito entre os dois…
Alguém sabe ou tem qualquer idéia pra esse problema? Qualquer idéia, sugestão ou crítica é aceita!
Vlw!