spring-aspects

IntelliJ IDEA “Cannot resolve method” on aspect-defined method

流过昼夜 提交于 2019-12-12 02:39:58
问题 I am using spring-data-neo4j 3.4.2, which is (optionally) using AspectJ. My IDE is IntelliJ IDEA 16 (EAP, IU-144.3891.8). I have had the same problem using latest IntelliJ IDEA 15. Everything works fine so far within IntelliJ, I can compile, run my Unit-Tests, deploy and run my web-application to/on Wildfly and so on. When building my project in IntelliJ, I can see usage of the required aspects (the following warning is ok). org.springframework.data.neo4j.aspects.support.node.Neo4jNodeBacking

Spring MVC and AOP: @Pointcuts only apply for Rest Controllers and not for common Web Controllers

主宰稳场 提交于 2019-12-11 04:38:39
问题 I am working with Spring Framework 4.3.3 in a web environment. I have a @Controller used for Web requests through a Web Browser that uses how dependency other @Controller but for Rest purposes. It latter mentioned uses a @Service etc... This approach about a 'Web' using a 'Rest' how a dependency is explained in Content Negotiation using Spring MVC for the Combining Data and Presentation Formats section. Until here for development/testing and production works fine. It is a valuable approach.

Spring AOP: How exclude an unnecessary @Pointcut (@Around advice) execution due the execution from others @Pointcuts/advices

旧时模样 提交于 2019-12-11 04:02:22
问题 I am working with: Spring Framework 4.3.3 AspectJ 1.8.9 I have the following normal process: @Controller -> @Service -> @Repository I have the following pair about AOP : PersonaServicePointcut PersonaServiceAspect The scenario is the following: The @Service class has some methods such as: delete , save , update and findOneById . They are declared together within the same class. For the methods such as delete and update through AOP I am using a @Before or @Around advice to call the findOneById

Load time weaving for non-spring beans in a spring application

帅比萌擦擦* 提交于 2019-12-11 03:34:49
问题 I have a spring boot application with some REST controllers, service classes and helper classes. The controllers and service classes are spring managed while helper classes are not spring managed and mostly contain static methods. The AspectJ configuration is present in java configuration as follows @Configuration @EnableLoadTimeWeaving(aspectjWeaving = AspectJWeaving.ENABLED) public class AspectConfig { @Bean public LoggingAspect loggingAspect() { return new LoggingAspect(); } } The

Spring MVC and AOP: @Pointcuts for @Controllers only works in Testing and not for Production

无人久伴 提交于 2019-12-11 03:09:23
问题 I am working with Spring Framework 4.3.3 in a Web Environment: I have two contexts: RootApplicationContext ServletApplicationContext I know the ServletApplicationContext contains all the beans about the web side, for example @Controller . Furthermore ServletApplicationContext is able to access all the context or beans from the RootApplicationContext for example @Service, @Repository etc. Until here I am fine. Note it applies for @Configuration classes too. (Infrastructure) Therefore with the

Get all exceptions in Java and send them remotely

旧时模样 提交于 2019-12-05 02:27:29
I have a huge Java application. I want to intercept all Java Exceptions adn send them by e-mail. I can't add everywhere code for sending the code via try-catch so is it possible to use for example Aspect to intercept the exception into low level classes and get the exception content? Or is there some way to override some internal Java Class and get the exception payload? What is possible? You can use the @AfterThrowing advice of spring-aop . @Aspect @Component public class MailExceptionAspect { @AfterThrowing(value="execution(* com.example..*.*(..))", throwing="ex" ) public void

Spring AOP Exclude Some Classes

断了今生、忘了曾经 提交于 2019-12-04 10:19:06
问题 I'm using Spring AspectJ for logging method execution statistics, however, I want to exclude some classes and methods from this without changing the pointcut expression. To exclude certain methods I created a custom annotation which I use to filter out. However I'm unable to do the same with classes. Here is my aspect definition - @Around("execution(* com.foo.bar.web.controller.*.*(..)) " + "&& !@annotation(com.foo.bar.util.NoLogging)") public Object log(ProceedingJoinPoint

Retrieve parameter value from ProceedingJoinPoint

强颜欢笑 提交于 2019-12-03 17:36:59
问题 In my Request i have a parameter name "accessToken", how do i get request parameter value from ProceedingJoinPoint ? public Object handleAccessToken(ProceedingJoinPoint joinPoint) throws Throwable { final Signature signature = joinPoint.getStaticPart().getSignature(); if (signature instanceof MethodSignature) { final MethodSignature ms = (MethodSignature) signature; String[] params = ms.getParameterNames(); for (String param : params) { System.out.println(param); // here how do i get

Java AOP JoinPoint does not get parameter names

二次信任 提交于 2019-12-03 17:18:23
I'm using Java Spring Mvc and Spring AOP to find the parameter names from the user. I have a controller which get parameters from user and call a service. I have an aspect that running before the service. The aspect should check if username and apiKey parameters are exist. Here is my code : Controller : @RequestMapping(method = RequestMethod.POST, produces=MediaType.APPLICATION_JSON_VALUE) public @ResponseBody String getDomainWithFoundIn(@RequestParam (value="domain") String domain, @RequestParam (value="user") String user, @RequestParam (value="apiKey") String apiKey) throws

Spring AOP Exclude Some Classes

混江龙づ霸主 提交于 2019-12-03 05:29:49
I'm using Spring AspectJ for logging method execution statistics, however, I want to exclude some classes and methods from this without changing the pointcut expression. To exclude certain methods I created a custom annotation which I use to filter out. However I'm unable to do the same with classes. Here is my aspect definition - @Around("execution(* com.foo.bar.web.controller.*.*(..)) " + "&& !@annotation(com.foo.bar.util.NoLogging)") public Object log(ProceedingJoinPoint proceedingJoinPoint) throws Throwable { // logging logic here } NoLogging is my custom annotation for excluding methods.