KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > repo > rule > RuleTransactionListener


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.repo.rule;
18
19 import org.alfresco.repo.transaction.TransactionListener;
20 import org.alfresco.util.GUID;
21
22 /**
23  * The rule service transaction listener
24  *
25  * @author Roy Wetherall
26  */

27 public class RuleTransactionListener implements TransactionListener
28 {
29     /**
30      * Id used in equals and hash
31      */

32     private String JavaDoc id = GUID.generate();
33     
34     /**
35      * The rule service (runtime interface)
36      */

37     private RuntimeRuleService ruleService;
38     
39     /**
40      * Constructor
41      *
42      * @param
43      */

44     public RuleTransactionListener(RuntimeRuleService ruleService)
45     {
46         this.ruleService = ruleService;
47     }
48     
49     /**
50      * @see org.alfresco.repo.transaction.TransactionListener#flush()
51      */

52     public void flush()
53     {
54     }
55
56     /**
57      * @see org.alfresco.repo.transaction.TransactionListener#beforeCommit(boolean)
58      */

59     public void beforeCommit(boolean readOnly)
60     {
61         this.ruleService.executePendingRules();
62     }
63
64     /**
65      * @see org.alfresco.repo.transaction.TransactionListener#beforeCompletion()
66      */

67     public void beforeCompletion()
68     {
69     }
70
71     /**
72      * @see org.alfresco.repo.transaction.TransactionListener#afterCommit()
73      */

74     public void afterCommit()
75     {
76     }
77
78     /**
79      * @see org.alfresco.repo.transaction.TransactionListener#afterRollback()
80      */

81     public void afterRollback()
82     {
83     }
84     
85     /**
86      * @see java.lang.Object#hashCode()
87      */

88     @Override JavaDoc
89     public int hashCode()
90     {
91         return this.id.hashCode();
92     }
93     
94     /**
95      * @see java.lang.Object#equals(java.lang.Object)
96      */

97     @Override JavaDoc
98     public boolean equals(Object JavaDoc obj)
99     {
100         if (this == obj)
101         {
102             return true;
103         }
104         if (obj instanceof RuleTransactionListener)
105         {
106             RuleTransactionListener that = (RuleTransactionListener) obj;
107             return (this.id.equals(that.id));
108         }
109         else
110         {
111             return false;
112         }
113     }
114
115 }
116
Popular Tags