View Javadoc

1   /**
2    * Copyright 2005-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.ksb.messaging;
17  
18  import org.kuali.rice.core.api.util.io.SerializationUtils;
19  import org.kuali.rice.ksb.api.messaging.AsynchronousCall;
20  
21  import javax.persistence.*;
22  import java.io.Serializable;
23  
24  /**
25   * Holds message payload content.  Needed to proxy the content so we don't have to 
26   * take the hit when grabbing large amounts of persisted messages at time.
27   * 
28   * @author Kuali Rice Team (rice.collab@kuali.org)
29   *
30   */
31  @Entity
32  @Table(name="KRSB_MSG_PYLD_T")
33  public class PersistedMessagePayload implements Serializable {
34      
35      private static final long serialVersionUID = 508778527504899029L;
36      
37      @Id
38  	@Column(name="MSG_QUE_ID")
39  	private Long routeQueueId;
40      @Lob
41  	@Basic(fetch=FetchType.LAZY)
42  	@Column(name="MSG_PYLD", length=4000)
43  	private String payload;
44      @Transient
45      private AsynchronousCall methodCall;
46      @Transient
47      private PersistedMessageBO message;
48      
49      public PersistedMessagePayload() {}
50      
51      public PersistedMessagePayload (AsynchronousCall methodCall, PersistedMessageBO message) {
52  	this.setPayload(SerializationUtils.serializeToBase64(methodCall));
53  	this.methodCall = methodCall;
54  	this.message = message;
55      }
56      
57      public String getPayload() {
58          return this.payload;
59      }
60      public void setPayload(String payload) {
61          this.payload = payload;
62      }
63      public Long getRouteQueueId() {
64          return this.routeQueueId;
65      }
66      public void setRouteQueueId(Long routeQueueId) {
67          this.routeQueueId = routeQueueId;
68      }
69      public AsynchronousCall getMethodCall() {
70  	if (this.methodCall != null) {
71  	    return this.methodCall;
72  	} 
73  	this.methodCall = (AsynchronousCall) SerializationUtils.deserializeFromBase64(getPayload());
74  	return this.methodCall;
75      }
76  
77      public PersistedMessageBO getMessage() {
78          return this.message;
79      }
80  
81      public void setMessage(PersistedMessageBO message) {
82          this.message = message;
83      }
84  
85      public void setMethodCall(AsynchronousCall methodCall) {
86          this.methodCall = methodCall;
87      }
88      
89  
90  }
91