Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Programming \ In Spring AOP example explanation     - Redis 3.0.3 Cluster Setup (Database)

- VMware virtual machine operating system log Error in the RPC receive loop resolve (Linux)

- Grep how to find files based on file contents in UNIX (Linux)

- To remove those IP is prohibited Fail2ban on CentOS 6/7 (Server)

- 256 with rich colors decorate your terminal (Linux)

- Installation on the way to the root source Ubuntu Server 14.04 LTS version Odoo8.0 (Server)

- Use PDFBox processing PDF documents (Linux)

- Install the system cleaning software under Linux: BleachBit 1.4 (Linux)

- Linux Shell Understanding and Learning (Linux)

- How to view the Linux QPS (Linux)

- RedHat6.4 installation tutorial --- Minimal Edition (Linux)

- Java reflection Introduction (Programming)

- These days have been tossing in the Linux under the ASP.NET 5, on the next in the other operating systems in the ASP.NET 5 or. NET applications, in order to complete the MS VM (CoreCLR) run is not far Reach, the effect of the application.


- CentOS install SystemTap-2.6 (Linux)

- OpenDaylight Helium version installed (Linux)

- Vagrant build LNMP environment (Server)

- Linux Tutorial Share: How to sudo command to define the PATH environment variable (Linux)

- Batch download files using the explorer under Windows Server 2008 R2 (Server)

- Hadoop 2.7.1 installation configuration based on availability QJM (Server)

- iOS constants, variables, properties and characteristics (Programming)

  In Spring AOP example explanation
  Add Date : 2017-01-08      
  In Spring AOP example explanation

Need enhanced services

If there is less service, his function is very simple, enter the print parameters and return parameters.
public class SimpleService {
    public String getName (String name) {
        System.out.println (get name is: + name);
        return name;

Definitions section and cut-off point
public class L
ogAspect {
    // Define the cut-off point
    @Pointcut (Within (com.ydoing.service .. *))
    // @Pointcut (Execution (* com.ydoing.service. *. * (..)))
    public void pointCut () {

Before enhancement
    // Define Before enhancement
    // Perform enhancement processing before the target method invocation
    @Before (PointCut ())
    public void before (JoinPoint jp) {
        // Get the connection point of the incoming parameters
        // Object args = jp.getArgs ();
        System.out.println (Before enhancement processing --execute before target method call);

-------------------------------------------------- ------------------------------

Test output:
Before enhancement --execute before target method call
get name is: Bob

Enhanced AfterReturning
    // Perform an enhanced process after the target method invocation
    @AfterReturning (Pointcut = pointCut (), returning = ret)
    public void afterReturning (JoinPoint jp, Object ret) {
        System.out.println (AfterReturnin enhancement processing --execute after target method call, return value is: + ret);

-------------------------------------------------- ------------------------------

Test output:
get name is: Bob
AfterReturnin enhancement --execute after target method call, return value is: Bob

Around Enhanced
    @Around (PointCut ())
    public void around (ProceedingJoinPoint jp) {
        System.out.println (Around enhanced --around start ...);
        Object [] args = jp.getArgs ();

        // Modify the target method arguments passed
        args [0] = around_add_ + args [0];
        try {
            System.out.println (revised parameters passed to perform output :);
            jp.proceed (args);
        } Catch (Throwable e) {
            // TODO Auto-generated catch block
            e.printStackTrace ();

        System.out.println (Around enhanced --around end);

-------------------------------------------------- ------------------------------

Around enhanced --around start ...
After modifying the parameters passed to perform output:
get name is: around_add_Bob
Around enhanced --around end

After enhancement
    // Exception handling will occur regardless of whether
    @After (PointCut ())
    public void after () {
        System.out.println (After enhancement --always do no matter what happen);

-------------------------------------------------- ------------------------------

get name is: Bob
After reinforcing --always do no matter what happen

Enhanced AfterThrowing
    @AfterThrowing (Pointcut = pointCut (), throwing = ex)
    public void afterThrowing (JoinPoint jp, Throwable ex) {
        System.out.println (error is: + ex);

Here not throw an exception, there is no output of the

Test code as follows
@ComponentScan (BasePackages = com.ydoing.service, com.ydoing.aspect)
public class AppConfig {
    public static void main (String [] args) {
        @SuppressWarnings (Resource)
        ApplicationContext ctx = new AnnotationConfigApplicationContext (AppConfig.class);
        SimpleService service = ctx.getBean (SimpleService.class);
        service.getName (Bob);
- C ++ Supplements - Virtual Function Principle (Programming)
- MySQL event table to achieve timing build a small note (Database)
- Perl loop (Programming)
- Setting up Linux machine through a proxy firewall (Linux)
- MySQL & NoSQL - Memcached widget (Database)
- C ++ Supplements - malloc free and new delete the same and different (Programming)
- How to use Android Studio to play more package names APK (Programming)
- Java Virtual Machine Basics (Programming)
- Android Notification (Programming)
- C / C ++ language usage summary of const (Programming)
- MySQL high availability cluster fragmentation of deployment uses Cobar (Database)
- Oracle 11g tracking and monitoring system-level triggers to drop misuse (Database)
- Oracle to use full-text indexing (Database)
- Oracle table of nested loop connection (Database)
- How to upgrade the kernel to 3.13.7 on Ubuntu / Linux Mint (Linux)
- Java Set and List in the relationship and difference (Programming)
- Macro Analysis Performance: PHP Performance Analysis and Experiment (Programming)
- Ubuntu Slingscold (Linux)
- Linux Shell Scripting (Programming)
- CentOS Linux Optimization and real production environment (Linux)
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.