src-java/kilda-persistence-api/src/main/java/org/openkilda/persistence/context/PersistenceContextInitializer.java
/**
     * Wraps annotated method with init/close operations for the persistence context.
     */
Wraps annotated method with init/close operations for the persistence context.
Wraps annotated method with init / close operations for the persistence context .
@Around("@annotation(persistenceContextRequired)")
    public Object aroundAdvice(ProceedingJoinPoint joinPoint,
                               PersistenceContextRequired persistenceContextRequired) throws Throwable {
        PersistenceContextManager persistenceContextManager = persistenceProvider.getPersistenceContextManager();
        boolean isNewContext = !persistenceContextManager.isContextInitialized()
                || persistenceContextRequired.requiresNew();
        if (isNewContext) {
            persistenceContextManager.initContext();
        }
        try {
            return joinPoint.proceed(joinPoint.getArgs());
        } finally {
            if (isNewContext) {
                persistenceContextManager.closeContext();
            }
        }
    }
@ Around ( "@annotation(persistenceContextRequired)" ) public Object aroundAdvice ( ProceedingJoinPoint joinPoint , PersistenceContextRequired persistenceContextRequired ) throws Throwable { PersistenceContextManager persistenceContextManager = persistenceProvider . getPersistenceContextManager ( ) ; boolean isNewContext = ! persistenceContextManager . isContextInitialized ( ) || persistenceContextRequired . requiresNew ( ) ; if ( isNewContext ) { persistenceContextManager . initContext ( ) ; } try { return joinPoint . proceed ( joinPoint . getArgs ( ) ) ; } finally { if ( isNewContext ) { persistenceContextManager . closeContext ( ) ; } } }
Wraps annotated method with init/close operations for the persistence context.
Wraps annotated method with init / close operations for the persistence context .