KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > proxy > ejb > ReadAheadResult


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.proxy.ejb;
23
24 import java.io.Externalizable JavaDoc;
25 import java.io.ObjectOutput JavaDoc;
26 import java.io.ObjectInput JavaDoc;
27 import java.io.IOException JavaDoc;
28 import java.util.ArrayList JavaDoc;
29
30 /**
31  * A result of get-method invocation of CMP 2.0 entity bean in the case where read ahead is turned on.
32  * Usage: on server set main result via {@link #setMainResult(java.lang.Object)} and add ahead results via
33  * {@link #addAheadResult(java.lang.Object)}. On client get main result via {@link #getMainResult()} and
34  * array of ahead results via {@link #getAheadResults()}.
35  *
36  * @author <a HREF="mailto:on@ibis.odessa.ua">Oleg Nitz</a>
37  * @version $Revision: 37459 $
38  */

39 public class ReadAheadResult
40       implements Externalizable JavaDoc
41 {
42    /** Serial Version Identifier. @since 1.1 */
43    private static final long serialVersionUID = -4041516583763000658L;
44
45    // Attributes ----------------------------------------------------
46

47    /**
48     * A List of read ahead values, during externalization is replaces by array
49     */

50    private ArrayList JavaDoc aheadList = new ArrayList JavaDoc();
51
52    /**
53     * A List of read ahead values, during externalization is replaces by array
54     */

55    private Object JavaDoc[] aheadArray;
56
57    /**
58     * A hash map of read ahead values, maps Methods to values.
59     */

60    private Object JavaDoc mainResult;
61
62    // Static --------------------------------------------------------
63

64    // Constructors --------------------------------------------------
65

66    public ReadAheadResult()
67    {
68    }
69
70    // Static --------------------------------------------------------
71

72    // Public --------------------------------------------------------
73

74    public void setMainResult(Object JavaDoc mainResult)
75    {
76       this.mainResult = mainResult;
77    }
78
79    public void addAheadResult(Object JavaDoc aheadResult)
80    {
81       aheadList.add(aheadResult);
82    }
83
84    public Object JavaDoc getMainResult()
85    {
86       return mainResult;
87    }
88
89    public Object JavaDoc[] getAheadResult()
90    {
91       if (aheadArray == null)
92       {
93          aheadArray = aheadList.toArray(new Object JavaDoc[aheadList.size()]);
94          aheadList = null;
95       }
96       return aheadArray;
97    }
98
99    // Package protected ---------------------------------------------
100

101    // Protected -----------------------------------------------------
102

103
104    // Private -------------------------------------------------------
105

106    public void writeExternal(ObjectOutput JavaDoc out)
107          throws IOException JavaDoc
108    {
109       out.writeObject(mainResult);
110       out.writeObject(getAheadResult());
111    }
112
113    public void readExternal(ObjectInput JavaDoc in)
114          throws IOException JavaDoc, ClassNotFoundException JavaDoc
115    {
116       mainResult = in.readObject();
117       aheadArray = (Object JavaDoc[]) in.readObject();
118    }
119
120    // Inner classes -------------------------------------------------
121
}
122
123
Popular Tags