View Javadoc

1   /*
2    * Copyright 2005-2007 The Kuali Foundation
3    * 
4    * 
5    * Licensed under the Educational Community License, Version 2.0 (the "License");
6    * you may not use this file except in compliance with the License.
7    * You may obtain a copy of the License at
8    * 
9    * http://www.opensource.org/licenses/ecl2.php
10   * 
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.kuali.rice.ksb.messaging.objectremoting;
18  
19  import javax.transaction.Synchronization;
20  import javax.xml.namespace.QName;
21  
22  import org.apache.log4j.Logger;
23  import org.kuali.rice.core.resourceloader.GlobalResourceLoader;
24  import org.springframework.transaction.support.TransactionSynchronization;
25  
26  /**
27   * {@link Synchronization} to cleanup any remote objects created during the
28   * current transaction.
29   * 
30   * @author Kuali Rice Team (rice.collab@kuali.org)
31   */
32  public class RemoteObjectCleanup implements TransactionSynchronization {
33  
34  	private static final Logger LOG = Logger.getLogger(RemoteObjectCleanup.class);
35  
36  	private QName objectRemoterName;
37  
38  	private QName serviceToRemove;
39  
40  	public RemoteObjectCleanup(QName objectRemoterName, QName serviceToRemove) {
41  		this.setObjectRemoterName(objectRemoterName);
42  		this.setServiceToRemove(serviceToRemove);
43  	}
44  
45  	public void afterCompletion(int status) {
46  		LOG.debug("Removing service: " + this.getServiceToRemove() + " from ObjectRemoter: " + this.getObjectRemoterName());
47  		ObjectRemoterService objectRemoter = (ObjectRemoterService) GlobalResourceLoader.getService(this.getObjectRemoterName());
48  		objectRemoter.removeService(this.getServiceToRemove());
49  	}
50  
51  	public void beforeCompletion() {
52  	    // template method
53  	}
54  
55  	public QName getObjectRemoterName() {
56  		return this.objectRemoterName;
57  	}
58  
59  	public void setObjectRemoterName(QName objectRemoterName) {
60  		this.objectRemoterName = objectRemoterName;
61  	}
62  
63  	public QName getServiceToRemove() {
64  		return this.serviceToRemove;
65  	}
66  
67  	public void setServiceToRemove(QName serviceToRemove) {
68  		this.serviceToRemove = serviceToRemove;
69  	}
70  
71  	public void afterCommit() {
72  	}
73  
74  	public void beforeCommit(boolean readOnly) {
75  	}
76  
77  	public void resume() {
78  	}
79  
80  	public void suspend() {
81  	}
82  }