KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > repo > action > ActionTransactionListener


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.action;
18
19 import org.alfresco.repo.action.ActionServiceImpl.PendingAction;
20 import org.alfresco.repo.transaction.TransactionListener;
21 import org.alfresco.util.GUID;
22
23 /**
24  * The action service transaction listener
25  *
26  * @author Roy Wetherall
27  */

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

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

38     private RuntimeActionService actionService;
39     
40     /**
41      * Constructor
42      *
43      * @param actionService the action service
44      */

45     public ActionTransactionListener(RuntimeActionService actionService)
46     {
47         this.actionService = actionService;
48     }
49     
50     /**
51      * @see org.alfresco.repo.transaction.TransactionListener#flush()
52      */

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

60     public void beforeCommit(boolean readOnly)
61     {
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         for (PendingAction pendingAction : this.actionService.getPostTransactionPendingActions())
77         {
78             this.actionService.getAsynchronousActionExecutionQueue().executeAction(
79                     actionService,
80                     pendingAction.getAction(),
81                     pendingAction.getActionedUponNodeRef(),
82                     pendingAction.getCheckConditions(),
83                     pendingAction.getActionChain());
84         }
85     }
86
87     /**
88      * @see org.alfresco.repo.transaction.TransactionListener#afterRollback()
89      */

90     public void afterRollback()
91     {
92     }
93     
94     /**
95      * @see java.lang.Object#hashCode()
96      */

97     @Override JavaDoc
98     public int hashCode()
99     {
100         return this.id.hashCode();
101     }
102     
103     /**
104      * @see java.lang.Object#equals(java.lang.Object)
105      */

106     @Override JavaDoc
107     public boolean equals(Object JavaDoc obj)
108     {
109         if (this == obj)
110         {
111             return true;
112         }
113         if (obj instanceof ActionTransactionListener)
114         {
115             ActionTransactionListener that = (ActionTransactionListener) obj;
116             return (this.id.equals(that.id));
117         }
118         else
119         {
120             return false;
121         }
122     }
123
124 }
125
Popular Tags