Fixed formatting

This commit is contained in:
chernykhalexander 2016-08-13 18:50:10 +03:00
parent e31c07a29c
commit eb1230b865
6 changed files with 22 additions and 21 deletions

View File

@ -1,12 +1,14 @@
package com.baeldung.interceptor;
import javax.interceptor.InterceptorBinding;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import javax.interceptor.InterceptorBinding;
@InterceptorBinding
@Target( {ElementType.METHOD, ElementType.TYPE } )
@Retention(RetentionPolicy.RUNTIME )
public @interface Audited {}
@Target({ ElementType.METHOD, ElementType.TYPE })
@Retention(RetentionPolicy.RUNTIME)
public @interface Audited {
}

View File

@ -3,12 +3,13 @@ package com.baeldung.interceptor;
import javax.interceptor.AroundInvoke;
import javax.interceptor.Interceptor;
import javax.interceptor.InvocationContext;
import java.lang.reflect.Method;
@Audited @Interceptor
@Audited
@Interceptor
public class AuditedInterceptor {
public static boolean calledBefore = false;
public static boolean calledAfter = false;
@AroundInvoke
public Object auditMethod(InvocationContext ctx) throws Exception {
calledBefore = true;

View File

@ -5,6 +5,6 @@ import com.baeldung.interceptor.Audited;
public class SuperService {
@Audited
public String deliverService(String uid) {
return uid;
return uid;
}
}

View File

@ -1,15 +1,12 @@
package com.baeldung.spring.aspect;
import org.aspectj.lang.JoinPoint;
import java.util.List;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.beans.factory.annotation.Autowired;
import javax.inject.Inject;
import java.util.List;
@Aspect
public class SpringTestAspect {
@Autowired
@ -18,9 +15,9 @@ public class SpringTestAspect {
@Around("execution(* com.baeldung.spring.service.SpringSuperService.*(..))")
public Object auditMethod(ProceedingJoinPoint jp) throws Throwable {
String methodName = jp.getSignature().getName();
accumulator.add("Call to "+methodName);
accumulator.add("Call to " + methodName);
Object obj = jp.proceed();
accumulator.add("Method called successfully: "+methodName);
accumulator.add("Method called successfully: " + methodName);
return obj;
}
}

View File

@ -1,13 +1,14 @@
package com.baeldung.spring.configuration;
import com.baeldung.spring.aspect.SpringTestAspect;
import com.baeldung.spring.service.SpringSuperService;
import java.util.ArrayList;
import java.util.List;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import java.util.ArrayList;
import java.util.List;
import com.baeldung.spring.aspect.SpringTestAspect;
import com.baeldung.spring.service.SpringSuperService;
@Configuration
@EnableAspectJAutoProxy
@ -18,12 +19,12 @@ public class AppConfig {
}
@Bean
public SpringTestAspect springTestAspect(){
public SpringTestAspect springTestAspect() {
return new SpringTestAspect();
}
@Bean
public List<String> getAccumulator(){
public List<String> getAccumulator() {
return new ArrayList<String>();
}
}

View File

@ -1,7 +1,7 @@
package com.baeldung.spring.service;
public class SpringSuperService {
public String getInfoFromService(String code){
public String getInfoFromService(String code) {
return code;
}
}