KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > dream > protocol > causality > CausalityChunkImpl


1 /**
2  * Dream
3  * Copyright (C) 2003-2004 INRIA Rhone-Alpes
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Contact : dream@objectweb.org
20  *
21  * Initial developer(s): Matthieu Leclercq
22  * Contributor(s): Vivien Quema
23  */

24
25 package org.objectweb.dream.protocol.causality;
26
27 import java.io.Externalizable JavaDoc;
28 import java.io.IOException JavaDoc;
29 import java.io.ObjectInput JavaDoc;
30 import java.io.ObjectOutput JavaDoc;
31
32 import org.objectweb.dream.message.AbstractChunk;
33 import org.objectweb.dream.message.Chunk;
34 import org.objectweb.dream.message.ChunkType;
35 import org.objectweb.dream.util.Util;
36
37 /**
38  * Basic implementation of {@link CausalityChunk}
39  */

40 public class CausalityChunkImpl extends AbstractChunk
41     implements
42       CausalityChunk,
43       Externalizable JavaDoc
44 {
45
46   private Object JavaDoc causalityStamp;
47
48   // ---------------------------------------------------------------------------
49
// Implementation of the CausalityChunk interface
50
// ---------------------------------------------------------------------------
51

52   /**
53    * @see org.objectweb.dream.protocol.causality.CausalityChunk#getCausalityStamp()
54    */

55   public Object JavaDoc getCausalityStamp()
56   {
57     return causalityStamp;
58   }
59
60   /**
61    * @see org.objectweb.dream.protocol.causality.CausalityChunk#setCausalityStamp(java.lang.Object)
62    */

63   public void setCausalityStamp(Object JavaDoc stamp)
64   {
65     causalityStamp = stamp;
66   }
67
68   // ---------------------------------------------------------------------------
69
// Implementation of the Chunk interface
70
// ---------------------------------------------------------------------------
71
/**
72    * @see org.objectweb.dream.message.Chunk#getType()
73    */

74   public ChunkType getType()
75   {
76     return TYPE;
77   }
78
79   /**
80    * @see org.objectweb.dream.message.Chunk#transfertState(org.objectweb.dream.message.Chunk)
81    */

82   public void transfertState(Chunk newInstance)
83   {
84     ((CausalityChunk) newInstance).setCausalityStamp(getCausalityStamp());
85   }
86
87   /**
88    * @see org.objectweb.dream.message.Chunk#recycle()
89    */

90   public void recycle()
91   {
92     causalityStamp = null;
93   }
94
95   // ---------------------------------------------------------------------------
96
// Implementation of the serialization methods
97
// ---------------------------------------------------------------------------
98

99   /**
100    * @see Externalizable#readExternal(ObjectInput)
101    */

102   public void readExternal(ObjectInput JavaDoc in) throws IOException JavaDoc,
103       ClassNotFoundException JavaDoc
104   {
105     causalityStamp = Util.readObject(in);
106   }
107
108   /**
109    * @see Externalizable#writeExternal(ObjectOutput)
110    */

111   public void writeExternal(ObjectOutput JavaDoc out) throws IOException JavaDoc
112   {
113     Util.writeObject(out, causalityStamp);
114   }
115
116 }
Popular Tags