Configure Spring AOP to be on or off - spring

Is it possible to configure spring AOP for a aspect around a method to either be turned on or off through a configuration properties file. The expression for the around is
execution(* com.company.service.update(..))

If you are using spring 3.1 or 3.2 you can use spring profiles to achieve this.
If you are using spring 4 you can use profiles or conditional declarations.

Related

Spring Integration XML Configuration and Spring Boot Java Annotation Configuration

Is it possible to have spring integration xml configuration and spring boot java annotation configuration at the same time? Can you please refer with an example on this?
What is the best practice for this?
Thanks
As Marten pointed out it is fully fine to combine Spring Boot with an XML configuration. See Spring Boot docs: https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#using.configuration-classes.importing-xml-configuration
If you absolutely must use XML based configuration, we recommend that you still start with a #Configuration class. You can then use an #ImportResource annotation to load XML configuration files.
And here is the sample: https://github.com/spring-projects/spring-boot/blob/main/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-xml/src/test/java/smoketest/xml/SampleSpringXmlPlaceholderBeanDefinitionTests.java

Does Quarkus have a Spring AOP analogue?

Does Quarkus have a Spring AOP analogue? What could I use instead of Spring AOP on Quarkus?
Thank you!
Quarkus uses CDI as a dependency injection mechanism, CDI provides interceptors that can be use to implement the same functionalities as AOP provides.
What you need to do is define an annotation, annotate the method you want to intercept with this annotation then define an interceptor bind to this annotation.
This is described here: https://quarkus.io/guides/cdi#interceptors and you can find more information on interceptors here: https://docs.jboss.org/weld/reference/latest/en-US/html/interceptors.html

aspectj annotation not working with flink [duplicate]

I am writing Spring 4 application with java config. I can use AOP in this project for all spring component. But i can't use it for a normal POJO class.
what is the library I need to add and what is the configuration I need to put in my config file to get this working
Spring AOP can only be applied to Spring-managed components/beans, not to non-Spring POJOs.
If you want to apply AOP to non-Spring classes you need AspectJ, not a proxy-based "AOP lite" framework like Spring AOP. For more information about how to use AspectJ (which does not need Spring at all) in combination with Spring and how to configure load-time weaving, please read the corresponding part of the Spring manual.

Spring AOP for non spring component

I am writing Spring 4 application with java config. I can use AOP in this project for all spring component. But i can't use it for a normal POJO class.
what is the library I need to add and what is the configuration I need to put in my config file to get this working
Spring AOP can only be applied to Spring-managed components/beans, not to non-Spring POJOs.
If you want to apply AOP to non-Spring classes you need AspectJ, not a proxy-based "AOP lite" framework like Spring AOP. For more information about how to use AspectJ (which does not need Spring at all) in combination with Spring and how to configure load-time weaving, please read the corresponding part of the Spring manual.

Spring 4 using Groovy setup

Spring 4.0 has improved support for Groovy e.g. using the GroovyBeanDefinitionReader.
What would be setup to to have a full Spring MVC application using Groovy?
E.g. using GroovyBeanDefinitionReader and AnnotationConfigWebApplicationContext together.
Anyone knows if there is a sample available or some pointers on a blog site?
You might want to check out spring boot, still in milestone release behind Spring 4 but they were really pushing its groovy support at spring eXchange.
Check out the bottom of this spring-boot guide
It's not quite the use of GroovyBeanDefinitionReader and AnnotationConfigWebApplicationContext you asked for, but I can't see why you couldn't do what you are after with the opinionated approach used by spring boot and the standard configuration annotations on groovy classes.
The git hub repository shows a number of annotated groovy examples
with ui.groovy for example, showing a configuration class for the WebMvcConfigurerAdapter defining a bean.
In your main method, do SpringApplication.run(new Object[]{JavaConfig.class, "beans.groovy"}, args), where JavaConfig contains your configurations in java (like #Configuration, #ComponentScan and etc., I generally find these things are easier using annotations) and beans.groovy just contain your spring beans DSL.
Assuming beans.groovy is on classpth (i.e. under src/main/resources)

Resources