More Related Content
Similar to AOP sec3.pptx (20)
More from NourhanTarek23 (15)
AOP sec3.pptx
- 8.
package com.Aspect.Lab3;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.Aspect.Lab3.service.Shapeservice;
public class App
{
public static void main( String[] args )
{
ApplicationContext context = new
ClassPathXmlApplicationContext("NewFile.xml");
Shapeservice shapeService = context.getBean("shapeService",
Shapeservice.class);
System.out.println(shapeService.getTriangle1().getName());
}
}
- 17. package com.Aspect.Lab3.Aspect;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
@Aspect
public class LoggingAspect {
@Before("allGetters()")
private void logAdvice() {
System.out.println("The log advice is running");
}
@Before("allGetters()")
public void SecondAdvice() {
System.out.println("The second advice is running");
}
@Pointcut("execution( * get*(..))")
public void allGetters() {}
}