001 /**
002 * Copyright 2005-2012 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.kuali.rice.ksb.messaging;
017
018 import org.kuali.rice.core.api.util.io.SerializationUtils;
019 import org.kuali.rice.ksb.api.KsbApiServiceLocator;
020 import org.kuali.rice.ksb.api.messaging.AsynchronousCall;
021
022 import javax.persistence.*;
023 import java.io.Serializable;
024
025 /**
026 * Holds message payload content. Needed to proxy the content so we don't have to
027 * take the hit when grabbing large amounts of persisted messages at time.
028 *
029 * @author Kuali Rice Team (rice.collab@kuali.org)
030 *
031 */
032 @Entity
033 @Table(name="KRSB_MSG_PYLD_T")
034 public class PersistedMessagePayload implements Serializable {
035
036 private static final long serialVersionUID = 508778527504899029L;
037
038 @Id
039 @Column(name="MSG_QUE_ID")
040 private Long routeQueueId;
041 @Lob
042 @Basic(fetch=FetchType.LAZY)
043 @Column(name="MSG_PYLD", length=4000)
044 private String payload;
045 @Transient
046 private AsynchronousCall methodCall;
047 @Transient
048 private PersistedMessageBO message;
049
050 public PersistedMessagePayload() {}
051
052 public PersistedMessagePayload (AsynchronousCall methodCall, PersistedMessageBO message) {
053 this.setPayload(SerializationUtils.serializeToBase64(methodCall));
054 this.methodCall = methodCall;
055 this.message = message;
056 }
057
058 public String getPayload() {
059 return this.payload;
060 }
061 public void setPayload(String payload) {
062 this.payload = payload;
063 }
064 public Long getRouteQueueId() {
065 return this.routeQueueId;
066 }
067 public void setRouteQueueId(Long routeQueueId) {
068 this.routeQueueId = routeQueueId;
069 }
070 public AsynchronousCall getMethodCall() {
071 if (this.methodCall != null) {
072 return this.methodCall;
073 }
074 this.methodCall = (AsynchronousCall) SerializationUtils.deserializeFromBase64(getPayload());
075 return this.methodCall;
076 }
077
078 public PersistedMessageBO getMessage() {
079 return this.message;
080 }
081
082 public void setMessage(PersistedMessageBO message) {
083 this.message = message;
084 }
085
086 public void setMethodCall(AsynchronousCall methodCall) {
087 this.methodCall = methodCall;
088 }
089
090
091 }
092