1
1
/*
2
- * Copyright 2012 the original author or authors.
2
+ * Copyright 2012-2014 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
15
15
*/
16
16
package org .springframework .data .auditing ;
17
17
18
+ import java .util .Calendar ;
19
+
18
20
import org .joda .time .DateTime ;
19
21
import org .slf4j .Logger ;
20
22
import org .slf4j .LoggerFactory ;
29
31
* @author Oliver Gierke
30
32
* @since 1.5
31
33
*/
32
- public class AuditingHandler < T > implements InitializingBean {
34
+ public class AuditingHandler implements InitializingBean {
33
35
34
36
private static final Logger LOGGER = LoggerFactory .getLogger (AuditingHandler .class );
35
37
36
38
private final AuditableBeanWrapperFactory factory = new AuditableBeanWrapperFactory ();
37
39
private DateTimeProvider dateTimeProvider = CurrentDateTimeProvider .INSTANCE ;
38
- private AuditorAware <T > auditorAware ;
40
+ private AuditorAware <? > auditorAware ;
39
41
private boolean dateTimeForNow = true ;
40
42
private boolean modifyOnCreation = true ;
41
43
@@ -44,7 +46,7 @@ public class AuditingHandler<T> implements InitializingBean {
44
46
*
45
47
* @param auditorAware the auditorAware to set
46
48
*/
47
- public void setAuditorAware (final AuditorAware <T > auditorAware ) {
49
+ public void setAuditorAware (final AuditorAware <? > auditorAware ) {
48
50
49
51
Assert .notNull (auditorAware );
50
52
this .auditorAware = auditorAware ;
@@ -106,8 +108,8 @@ private void touch(Object target, boolean isNew) {
106
108
return ;
107
109
}
108
110
109
- T auditor = touchAuditor (wrapper , isNew );
110
- DateTime now = dateTimeForNow ? touchDate (wrapper , isNew ) : null ;
111
+ Object auditor = touchAuditor (wrapper , isNew );
112
+ Calendar now = dateTimeForNow ? touchDate (wrapper , isNew ) : null ;
111
113
112
114
Object defaultedNow = now == null ? "not set" : now ;
113
115
Object defaultedAuditor = auditor == null ? "unknown" : auditor ;
@@ -121,13 +123,13 @@ private void touch(Object target, boolean isNew) {
121
123
* @param auditable
122
124
* @return
123
125
*/
124
- private T touchAuditor (AuditableBeanWrapper wrapper , boolean isNew ) {
126
+ private Object touchAuditor (AuditableBeanWrapper wrapper , boolean isNew ) {
125
127
126
128
if (null == auditorAware ) {
127
129
return null ;
128
130
}
129
131
130
- T auditor = auditorAware .getCurrentAuditor ();
132
+ Object auditor = auditorAware .getCurrentAuditor ();
131
133
132
134
if (isNew ) {
133
135
wrapper .setCreatedBy (auditor );
@@ -146,9 +148,9 @@ private T touchAuditor(AuditableBeanWrapper wrapper, boolean isNew) {
146
148
* @param wrapper
147
149
* @return
148
150
*/
149
- private DateTime touchDate (AuditableBeanWrapper wrapper , boolean isNew ) {
151
+ private Calendar touchDate (AuditableBeanWrapper wrapper , boolean isNew ) {
150
152
151
- DateTime now = dateTimeProvider .getDateTime ();
153
+ Calendar now = dateTimeProvider .getNow ();
152
154
153
155
if (isNew ) {
154
156
wrapper .setCreatedDate (now );
0 commit comments