Added integration-test provided by Erik-Berndt Scheper <erik.berndt.scheper@gmail...
[hibernate4-maven-plugin] / src / it / hibernate4-maven-plugin-envers-sample / src / main / java / org / bitbucket / fbascheper / tutorial / envers / AuditRevisionListener.java
1 /**
2  * Copyright 2013 F.B.A. Scheper.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License. *
15  */
16 package org.bitbucket.fbascheper.tutorial.envers;
17
18 import org.hibernate.envers.RevisionListener;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
21
22 import java.util.Date;
23
24 /**
25  * The {@link org.hibernate.envers.RevisionListener}-implementation used to initialize an {@link AuditRevision}.
26  *
27  * @author Erik-Berndt Scheper
28  * @see AuditRevision
29  * @since 11-09-2013
30  */
31 public class AuditRevisionListener implements RevisionListener {
32
33     private final Logger logger = LoggerFactory.getLogger(this.getClass());
34
35     @Override
36     public void newRevision(Object revisionEntity) {
37
38         AuditRevision auditRevision = (AuditRevision) revisionEntity;
39         auditRevision.setRevisionTimeStamp(new Date());
40
41         auditRevision.setUserName("EXAMPLE_USER");
42
43
44     }
45
46 }