001 /*
002 * Copyright 2005-2007 The Kuali Foundation
003 *
004 *
005 * Licensed under the Educational Community License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 * http://www.opensource.org/licenses/ecl2.php
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017 package org.kuali.rice.ksb.messaging.objectremoting;
018
019 import javax.transaction.Synchronization;
020 import javax.xml.namespace.QName;
021
022 import org.apache.log4j.Logger;
023 import org.kuali.rice.core.resourceloader.GlobalResourceLoader;
024 import org.springframework.transaction.support.TransactionSynchronization;
025
026 /**
027 * {@link Synchronization} to cleanup any remote objects created during the
028 * current transaction.
029 *
030 * @author Kuali Rice Team (rice.collab@kuali.org)
031 */
032 public class RemoteObjectCleanup implements TransactionSynchronization {
033
034 private static final Logger LOG = Logger.getLogger(RemoteObjectCleanup.class);
035
036 private QName objectRemoterName;
037
038 private QName serviceToRemove;
039
040 public RemoteObjectCleanup(QName objectRemoterName, QName serviceToRemove) {
041 this.setObjectRemoterName(objectRemoterName);
042 this.setServiceToRemove(serviceToRemove);
043 }
044
045 public void afterCompletion(int status) {
046 LOG.debug("Removing service: " + this.getServiceToRemove() + " from ObjectRemoter: " + this.getObjectRemoterName());
047 ObjectRemoterService objectRemoter = (ObjectRemoterService) GlobalResourceLoader.getService(this.getObjectRemoterName());
048 objectRemoter.removeService(this.getServiceToRemove());
049 }
050
051 public void beforeCompletion() {
052 // template method
053 }
054
055 public QName getObjectRemoterName() {
056 return this.objectRemoterName;
057 }
058
059 public void setObjectRemoterName(QName objectRemoterName) {
060 this.objectRemoterName = objectRemoterName;
061 }
062
063 public QName getServiceToRemove() {
064 return this.serviceToRemove;
065 }
066
067 public void setServiceToRemove(QName serviceToRemove) {
068 this.serviceToRemove = serviceToRemove;
069 }
070
071 public void afterCommit() {
072 }
073
074 public void beforeCommit(boolean readOnly) {
075 }
076
077 public void resume() {
078 }
079
080 public void suspend() {
081 }
082 }