1: First, declare your custom annotations
@Retention (retentionpolicy.runtime) @Target ({Elementtype.method}) Public@Interfacedttransactional {/** Whether need to rollback*/ Public BooleanIncludelocaltransaction ()default true; Public BooleanConfirmmethodexist ()default true; /** Allow [Confirmmethod] was null if [Confirmmethodexist] is false*/ PublicString Confirmmethod ()default""; PublicString Cancelmethod (); }
2: Defining the Slice processing class
@Aspect @component@slf4j Public classDistributedtransactionaspectImplementsordered{@AutowiredPrivateDistributedtransactioninterceptor Distributedtransactioninterceptor; @Pointcut ("@annotation (com.sysware.cloud.commons.dts.annotation.DtTransactional)") Public voidDistributedtransactionservice () {} @Around ("Distributedtransactionservice ()") PublicObject Interceptdttransactionalmethod (Proceedingjoinpoint PJP)throwsthrowable {log.debug ("Interface-itransactionrunning-start---->"); Object obj=Distributedtransactioninterceptor.interceptdttransactionalmethod (PJP); Log.debug ("Interface-itransactionrunning-end---->"); returnobj; } @Override Public intGetOrder () {returnhighest_precedence; }}
Defining the Facets processing class key:
- Class with @Aspect
Spring-Custom annotations (with @aspect)