Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
https://github.com/javers/javers/issues/417
- Loading branch information
1 parent
0c93d36
commit ed2c978
Showing
13 changed files
with
125 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
javers-spring/src/main/java/org/javers/spring/auditable/aspect/JaversAuditableAspect.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package org.javers.spring.auditable.aspect; | ||
|
||
import org.aspectj.lang.JoinPoint; | ||
import org.aspectj.lang.annotation.AfterReturning; | ||
import org.aspectj.lang.annotation.Aspect; | ||
import org.javers.core.Javers; | ||
import org.javers.spring.auditable.AuthorProvider; | ||
import org.javers.spring.auditable.CommitPropertiesProvider; | ||
import org.javers.spring.auditable.EmptyPropertiesProvider; | ||
|
||
/** | ||
* Commits all arguments passed to advised methods | ||
* (only if the method exits normally, i.e. no Exception has been thrown). | ||
* | ||
* Spring @Transactional attributes (like noRollbackFor or noRollbackForClassName) | ||
* have no effects on this aspect. | ||
* <br/><br/> | ||
* | ||
* Creates the following @AfterReturning pointcuts: | ||
* <ul> | ||
* <li/>any method annotated with @JaversAuditable | ||
* <li/>all save() and delete() methods of CrudRepositories with (class-level) @JaversSpringDataAuditable | ||
* </ul> | ||
*/ | ||
@Aspect | ||
public class JaversAuditableAspect { | ||
private final JaversCommitAdvice javersCommitAdvice; | ||
|
||
public JaversAuditableAspect(Javers javers, AuthorProvider authorProvider, CommitPropertiesProvider commitPropertiesProvider) { | ||
this(new JaversCommitAdvice(javers, authorProvider, commitPropertiesProvider) ); | ||
} | ||
|
||
public JaversAuditableAspect(Javers javers, AuthorProvider authorProvider) { | ||
this(javers, authorProvider, new EmptyPropertiesProvider()); | ||
} | ||
|
||
JaversAuditableAspect(JaversCommitAdvice javersCommitAdvice) { | ||
this.javersCommitAdvice = javersCommitAdvice; | ||
} | ||
|
||
@AfterReturning("@annotation(org.javers.spring.annotation.JaversAuditable)") | ||
public void commitAdvice(JoinPoint pjp) { | ||
javersCommitAdvice.commitMethodArguments(pjp); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...le/aspect/AbstractAuditChangeHandler.java → ...pringdata/AbstractAuditChangeHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../auditable/aspect/AuditChangeHandler.java → ...aspect/springdata/AuditChangeHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...able/aspect/OnSaveAuditChangeHandler.java → .../springdata/OnSaveAuditChangeHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters