getConnection() メソッドへの呼び出しをインターセプトして、dbms indentifier をセットアップしようとしています。それを取得するためにアスペクトを実装しましたが、何も取得しません。何か案が?ありがとう!
import java.sql.CallableStatement;
import java.sql.Connection;
import javax.servlet.http.HttpSession;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import es.iberia.tryp.model.entities.Usuario;
@Component
@Aspect
public class ConnectionAspect {
@AfterReturning(value = "execution(java.sql.Connection javax.sql.DataSource+.getConnection(..))", returning = "connection")
//@AfterReturning(value = "execution(java.sql.Connection org.springframework.jdbc.datasource.*.*(*))", returning = "connection")
//@AfterReturning(value = "execution(java.sql.Connection java.sql.Connection *(..))", returning = "connection")
//@AfterReturning(value = "execution(java.sql.Connection org.springframework.jdbc.datasource.DriverManagerDataSource.*(..))", returning = "connection")
public void prepare (Connection connection) throws Throwable {
HttpSession httpSession = (HttpSession) RequestContextHolder.currentRequestAttributes().resolveReference(RequestAttributes.REFERENCE_SESSION);
if (httpSession!=null && (Usuario)httpSession.getAttribute("usuario")!=null && ((String)((Usuario)httpSession.getAttribute("usuario")).getNomina())!=null) {
String nomina = (String)((Usuario)httpSession.getAttribute("usuario")).getNomina();
String prepSql = "{ call DBMS_SESSION.SET_IDENTIFIER('" + nomina +"') }";
CallableStatement cs = connection.prepareCall(prepSql);
cs.execute();
cs.close();
}
}
}