KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > catalina > cluster > deploy > FileMessage


1 /*
2  * Copyright 1999,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache 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.apache.org/licenses/LICENSE-2.0
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
17 package org.apache.catalina.cluster.deploy;
18
19 import org.apache.catalina.cluster.ClusterMessage;
20 import org.apache.catalina.cluster.Member;
21 import java.io.Serializable JavaDoc;
22
23 /**
24  * Contains the data for a file being transferred over TCP, this is
25  * essentially a fragment of a file, read and written by the FileMessageFactory
26  * @author Filip Hanik
27  * @version 1.0
28  */

29
30 public class FileMessage implements ClusterMessage, Serializable JavaDoc {
31     private int messageNumber;
32     private byte[] data;
33     private int dataLength;
34     private org.apache.catalina.cluster.Member address;
35     
36     private long timestamp;
37     private long totalLength;
38     private long totalNrOfMsgs;
39     private String JavaDoc fileName;
40     private String JavaDoc contextPath;
41     
42     public FileMessage(Member source,
43                        String JavaDoc fileName,
44                        String JavaDoc contextPath) {
45         this.address=source;
46         this.fileName=fileName;
47         this.contextPath=contextPath;
48     }
49     
50     /*
51     public void writeExternal(ObjectOutput out) throws IOException {
52                    
53     }
54     
55     public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
56                   
57     }
58     */

59    
60     public int getMessageNumber() {
61         return messageNumber;
62     }
63     public void setMessageNumber(int messageNumber) {
64         this.messageNumber = messageNumber;
65     }
66     public long getTotalNrOfMsgs() {
67         return totalNrOfMsgs;
68     }
69     public void setTotalNrOfMsgs(long totalNrOfMsgs) {
70         this.totalNrOfMsgs = totalNrOfMsgs;
71     }
72     public byte[] getData() {
73         return data;
74     }
75     public void setData(byte[] data, int length) {
76         this.data = data;
77         this.dataLength = length;
78     }
79     public int getDataLength() {
80         return dataLength;
81     }
82     public void setDataLength(int dataLength) {
83         this.dataLength = dataLength;
84     }
85     public long getTotalLength() {
86         return totalLength;
87     }
88     public void setTotalLength(long totalLength) {
89         this.totalLength = totalLength;
90     }
91     public org.apache.catalina.cluster.Member getAddress() {
92         return address;
93     }
94     public void setAddress(org.apache.catalina.cluster.Member address) {
95         this.address = address;
96     }
97     public String JavaDoc getUniqueId() {
98         StringBuffer JavaDoc result = new StringBuffer JavaDoc(getFileName());
99         result.append("#-#");
100         result.append(getMessageNumber());
101         result.append("#-#");
102         result.append(System.currentTimeMillis());
103         return result.toString();
104     }
105
106     public long getTimestamp() {
107         return timestamp;
108     }
109     public void setTimestamp(long timestamp) {
110         this.timestamp = timestamp;
111     }
112     public String JavaDoc getFileName() {
113         return fileName;
114     }
115     public void setFileName(String JavaDoc fileName) {
116         this.fileName = fileName;
117     }
118     public String JavaDoc getContextPath() {
119         return contextPath;
120     }
121
122
123 }
124
Popular Tags