KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > test > interfaceproxy > DocumentInterceptor


1 //$Id: DocumentInterceptor.java,v 1.5 2005/02/12 07:27:26 steveebersole Exp $
2
package org.hibernate.test.interfaceproxy;
3
4 import java.io.Serializable JavaDoc;
5 import java.util.Calendar JavaDoc;
6 import java.util.Iterator JavaDoc;
7
8 import org.hibernate.CallbackException;
9 import org.hibernate.Interceptor;
10 import org.hibernate.Transaction;
11 import org.hibernate.EntityMode;
12 import org.hibernate.type.Type;
13
14 /**
15  * @author Gavin King
16  */

17 public class DocumentInterceptor implements Interceptor {
18
19
20     public boolean onLoad(Object JavaDoc entity, Serializable JavaDoc id, Object JavaDoc[] state,
21             String JavaDoc[] propertyNames, Type[] types) throws CallbackException {
22         return false;
23     }
24
25     public boolean onFlushDirty(Object JavaDoc entity, Serializable JavaDoc id,
26             Object JavaDoc[] currentState, Object JavaDoc[] previousState,
27             String JavaDoc[] propertyNames, Type[] types) throws CallbackException {
28         if ( entity instanceof Document ) {
29             currentState[2] = Calendar.getInstance();
30             return true;
31         }
32         else {
33             return false;
34         }
35     }
36
37     public boolean onSave(Object JavaDoc entity, Serializable JavaDoc id, Object JavaDoc[] state,
38             String JavaDoc[] propertyNames, Type[] types) throws CallbackException {
39         if ( entity instanceof Document ) {
40             state[3] = state[2] = Calendar.getInstance();
41             return true;
42         }
43         else {
44             return false;
45         }
46     }
47
48     public void onDelete(Object JavaDoc entity, Serializable JavaDoc id, Object JavaDoc[] state,
49             String JavaDoc[] propertyNames, Type[] types) throws CallbackException {
50
51     }
52
53     public void preFlush(Iterator JavaDoc entities) throws CallbackException {
54
55     }
56
57     public void postFlush(Iterator JavaDoc entities) throws CallbackException {
58
59     }
60
61     public Boolean JavaDoc isTransient(Object JavaDoc entity) {
62         return null;
63     }
64
65     public int[] findDirty(Object JavaDoc entity, Serializable JavaDoc id,
66             Object JavaDoc[] currentState, Object JavaDoc[] previousState,
67             String JavaDoc[] propertyNames, Type[] types) {
68         return null;
69     }
70
71     public Object JavaDoc instantiate(String JavaDoc entityName, EntityMode entityMode, Serializable JavaDoc id) throws CallbackException {
72         return null;
73     }
74
75     public String JavaDoc getEntityName(Object JavaDoc object) throws CallbackException {
76         return null;
77     }
78
79     public Object JavaDoc getEntity(String JavaDoc entityName, Serializable JavaDoc id)
80             throws CallbackException {
81         return null;
82     }
83
84     public void afterTransactionBegin(Transaction tx) {}
85     public void afterTransactionCompletion(Transaction tx) {}
86     public void beforeTransactionCompletion(Transaction tx) {}
87 }
88
Popular Tags