View Javadoc

1   /*
2    * Copyright 2007-2008 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 java.io.Serializable;
19  
20  import javax.persistence.Basic;
21  import javax.persistence.Column;
22  import javax.persistence.Entity;
23  import javax.persistence.FetchType;
24  import javax.persistence.Id;
25  import javax.persistence.Lob;
26  import javax.persistence.Table;
27  import javax.persistence.Transient;
28  
29  import org.kuali.rice.ksb.service.KSBServiceLocator;
30  
31  /**
32   * Holds message payload content.  Needed to proxy the content so we don't have to 
33   * take the hit when grabbing large amounts of persisted messages at time.
34   * 
35   * @author Kuali Rice Team (rice.collab@kuali.org)
36   *
37   */
38  @Entity
39  @Table(name="KRSB_MSG_PYLD_T")
40  public class PersistedMessagePayload implements Serializable {
41      
42      private static final long serialVersionUID = 508778527504899029L;
43      
44      @Id
45  	@Column(name="MSG_QUE_ID")
46  	private Long routeQueueId;
47      @Lob
48  	@Basic(fetch=FetchType.LAZY)
49  	@Column(name="MSG_PYLD", length=4000)
50  	private String payload;
51      @Transient
52      private AsynchronousCall methodCall;
53      @Transient
54      private PersistedMessage message;
55      
56      public PersistedMessagePayload() {}
57      
58      public PersistedMessagePayload (AsynchronousCall methodCall, PersistedMessage message) {
59  	this.setPayload(KSBServiceLocator.getMessageHelper().serializeObject(methodCall));
60  	this.methodCall = methodCall;
61  	this.message = message;
62      }
63      
64      public String getPayload() {
65          return this.payload;
66      }
67      public void setPayload(String payload) {
68          this.payload = payload;
69      }
70      public Long getRouteQueueId() {
71          return this.routeQueueId;
72      }
73      public void setRouteQueueId(Long routeQueueId) {
74          this.routeQueueId = routeQueueId;
75      }
76      public AsynchronousCall getMethodCall() {
77  	if (this.methodCall != null) {
78  	    return this.methodCall;
79  	} 
80  	this.methodCall = (AsynchronousCall)KSBServiceLocator.getMessageHelper().deserializeObject(getPayload());
81  	return this.methodCall;
82      }
83  
84      public PersistedMessage getMessage() {
85          return this.message;
86      }
87  
88      public void setMessage(PersistedMessage message) {
89          this.message = message;
90      }
91  
92      public void setMethodCall(AsynchronousCall methodCall) {
93          this.methodCall = methodCall;
94      }
95      
96  
97  }
98