KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jgroups > service > lease > LeaseInfoReplicationHeader


1 package org.jgroups.service.lease;
2
3 import org.jgroups.Header;
4
5 import java.io.IOException JavaDoc;
6 import java.io.ObjectInput JavaDoc;
7 import java.io.ObjectOutput JavaDoc;
8
9 public class LeaseInfoReplicationHeader extends Header {
10     
11     public static final String JavaDoc HEADER_KEY = "leaseInfoReplicationHeader";
12     
13     public static final int NONE = 0;
14     
15     public static final int NEW_LEASE_TYPE =
16     LeaseFactoryService.LeaseInfo.NEW_LEASE_TYPE;
17     
18     public static final int RENEW_LEASE_TYPE =
19     LeaseFactoryService.LeaseInfo.RENEW_LEASE_TYPE;
20     
21     public static final int CANCEL_LEASE_TYPE =
22     LeaseFactoryService.LeaseInfo.CANCEL_LEASE_TYPE;
23     
24     private int headerType;
25     
26     private LeaseFactoryService.LeaseInfo leaseInfo;
27     
28     /**
29      * Construct uninitialized instance of this object.
30      */

31     public LeaseInfoReplicationHeader() {
32         this.headerType = NONE;
33     this.leaseInfo = null;
34     }
35
36     /**
37      * Create instance of this object for a specified lease info object.
38      */

39     public LeaseInfoReplicationHeader(int headerType,
40     LeaseFactoryService.LeaseInfo leaseInfo)
41     {
42     this.headerType = headerType;
43     this.leaseInfo = leaseInfo;
44     }
45     
46     /**
47      * Get header type.
48      */

49     public int getType() {
50     return headerType;
51     }
52     
53     /**
54      * Get lease info from this header.
55      */

56     public LeaseFactoryService.LeaseInfo getLeaseInfo() {
57     return leaseInfo;
58     }
59
60     /**
61      * Read state of this object from {@link ObjectInput}
62      */

63     public void readExternal(ObjectInput JavaDoc in)
64     throws IOException JavaDoc, ClassNotFoundException JavaDoc
65     {
66     headerType = in.readInt();
67     leaseInfo = (LeaseFactoryService.LeaseInfo)in.readObject();
68     }
69
70     /**
71      * Write state of this header into {@link ObjectOutput}.
72      */

73     public void writeExternal(ObjectOutput JavaDoc out) throws IOException JavaDoc {
74     out.writeInt(headerType);
75     out.writeObject(leaseInfo);
76     }
77     
78 }
Popular Tags