Announcement Announcement Module
Collapse
No announcement yet.
why is my joinpoint not working? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • why is my joinpoint not working?

    Hi!
    I got a joinpoint that uses custom annotation and it goes like this:
    Code:
        @AfterReturning(pointcut = "execution(@com.praxis.desvucem.annotation.LogMe(com.praxis.desvucem.annotation.LoggingType.INSERT) * *(..))", returning = "result")
    	public void logAfterReturningInsert(JoinPoint jp, Object result)
    			throws Throwable {
    		final Logger logger = getLoggerForClass(jp);
    		System.out.println("AfterInsert");
    		logger.info(buildLogging(jp, result));
    	}
    and in my database interaction where I want to log my data base operations Ive:
    Code:
    @Repository
    public class SpringDataCContactosSMSRepository implements CContactosSMSRepository {
    
        private Logger log = LoggerFactory.getLogger(SpringDataCContactosSMSRepository.class);
    
        private final QMfCContactosSMS qContactoSMS = QMfCContactosSMS.contactoSMS;
    
        /**
         * template para acceso a BD.
         */
        private QueryDslJdbcTemplate template;
    
        @Autowired
        @Qualifier("dataSource")
        private DataSource dataSource;
    
        @Autowired
        public void setDataSourceBroker(DataSource dataSource) {
            this.template = new QueryDslJdbcTemplate(dataSource);
            this.dataSource = dataSource;
        }
    
        @Override
        public void guardarContactoSMS(ContactoSMS contactoSMS) {
            AgregarContactoSMSProcedure sproc = new AgregarContactoSMSProcedure(dataSource);
            Long id = sproc.execute(contactoSMS.getIdContacto(), contactoSMS.getNombreContacto(),
                    contactoSMS.getApellidoPaternoContacto(), contactoSMS.getApellidoMaternoContacto(),
                    contactoSMS.getTelefono(), contactoSMS.getIdUsuario(), contactoSMS.getStatus());
            contactoSMS.setIdContacto(id.intValue());
        }
    
        private static class AgregarContactoSMSProcedure extends StoredProcedure {
            private static final String SPROC_NAME = "AGREGAR_CONTACTO_SMS";
    
            private static final String ID_CONTACTO = "ID_CONTACTO";
    
            private static final String NOMBRE = "NOMBRE";
    
            private static final String APELLIDO_PATERNO = "APELLIDO_PATERNO";
    
            private static final String APELLIDO_MATERNO = "APELLIDO_MATERNO";
    
            private static final String TELEFONO = "TELEFONO";
    
            private static final String ID_USUARIO = "ID_USUARIO";
    
            private static final String ESTATUS = "ESTATUS";
    
            public AgregarContactoSMSProcedure(DataSource dataSource) {
                super(dataSource, SPROC_NAME);
                declareParameter(new SqlOutParameter(ID_CONTACTO, OracleTypes.NUMBER));
                declareParameter(new SqlParameter(NOMBRE, OracleTypes.VARCHAR));
                declareParameter(new SqlParameter(APELLIDO_PATERNO, OracleTypes.VARCHAR));
                declareParameter(new SqlParameter(APELLIDO_MATERNO, OracleTypes.VARCHAR));
                declareParameter(new SqlParameter(TELEFONO, OracleTypes.NUMBER));
                declareParameter(new SqlParameter(ID_USUARIO, OracleTypes.VARCHAR));
                compile();
            }
    
            @SuppressWarnings({ "rawtypes", "unchecked" })
            @LogMe(LoggingType.INSERT)
            public Long execute(Integer idContacto, String nombreContacto, String apellidoPaternoContacto,
                    String apellidoMaternoContacto, Long telefonoContacto, String idUsuario, String estatusContacto) {
    
                Map inputs = new HashMap();
                inputs.put(ID_CONTACTO, idContacto);
                inputs.put(NOMBRE, nombreContacto);
                inputs.put(APELLIDO_PATERNO, apellidoPaternoContacto);
                inputs.put(APELLIDO_MATERNO, apellidoMaternoContacto);
                inputs.put(TELEFONO, telefonoContacto);
                inputs.put(ID_USUARIO, idUsuario);
                inputs.put(ESTATUS, estatusContacto);
                Map outputs = super.execute(inputs);
                BigDecimal idRegistrado = (BigDecimal) outputs.get(ID_CONTACTO);
                return idRegistrado.longValue();
            }
        }
    
    }
    as you can see Ive got an internal class to handle the procedure but when I run it I dont get my code to enter into the joinpoint unless I put my annotation in the method "public void guardarContactoSMS(ContactoSMS contactoSMS)".
    Is there a way to fix it so my annotations can be registered in an internal class?
    Thanks in advance.
Working...
X