Author: fhanik
Date: Fri May 5 17:22:00 2006
New Revision: 400217
URL: http://svn.apache.org/viewcvs?rev=400217&view=rev
Log:
More docs and some minor optimizations
Modified:
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/io/ListenCallback.java
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/io/ObjectReader.java
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/io/XByteBuffer.java
Modified:
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/io/ListenCallback.java
URL:
http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/io/ListenCallback.java?rev=400217&r1=400216&r2=400217&view=diff
==============================================================================
---
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/io/ListenCallback.java
(original)
+++
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/io/ListenCallback.java
Fri May 5 17:22:00 2006
@@ -21,6 +21,8 @@
/**
+ * Internal interface, similar to the MessageListener but used
+ * at the IO base
* The listen callback interface is used by the replication system
* when data has been received. The interface does not care about
* objects and marshalling and just passes the bytes straight through.
Modified:
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/io/ObjectReader.java
URL:
http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/io/ObjectReader.java?rev=400217&r1=400216&r2=400217&view=diff
==============================================================================
---
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/io/ObjectReader.java
(original)
+++
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/io/ObjectReader.java
Fri May 5 17:22:00 2006
@@ -29,8 +29,6 @@
* The object reader object is an object used in conjunction with
* java.nio TCP messages. This object stores the message bytes in a
* <code>XByteBuffer</code> until a full package has been received.
- * When a full package has been received, the append method will call
messageDataReceived
- * on the callback object associated with this object reader.<BR>
* This object uses an XByteBuffer which is an extendable object buffer that
also allows
* for message encoding and decoding.
*
@@ -44,14 +42,17 @@
private XByteBuffer buffer;
/**
- * Create XByteBuffer and store parameter
- * @param channel
- * @param selector
- * @param callback
+ * Creates an <code>ObjectReader</code> for a TCP NIO socket channel
+ * @param channel - the channel to be read.
*/
public ObjectReader(SocketChannel channel) {
this(channel.socket());
}
+
+ /**
+ * Creates an <code>ObjectReader</code> for a TCP socket
+ * @param socket Socket
+ */
public ObjectReader(Socket socket) {
try{
this.buffer = new XByteBuffer(socket.getReceiveBufferSize(), true);
Modified:
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/io/XByteBuffer.java
URL:
http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/io/XByteBuffer.java?rev=400217&r1=400216&r2=400217&view=diff
==============================================================================
---
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/io/XByteBuffer.java
(original)
+++
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/io/XByteBuffer.java
Fri May 5 17:22:00 2006
@@ -36,7 +36,6 @@
* Transfer package:
* <ul>
* <li><b>START_DATA/b> - 7 bytes - <i>FLT2002</i></li>
- * <li><b>OPTIONS</b> - 4 bytes - message options, implementation
specific</li>
* <li><b>SIZE</b> - 4 bytes - size of the data package</li>
* <li><b>DATA</b> - should be as many bytes as the prev SIZE</li>
* <li><b>END_DATA</b> - 7 bytes - <i>TLF2003</i></lI>
@@ -81,7 +80,10 @@
protected int bufSize = 0;
/**
- *
+ * Flag for discarding invalid packages
+ * If this flag is set to true, and append(byte[],...) is called,
+ * the data added will be inspected, and if it doesn't start with
+ * <code>START_DATA</code> it will be thrown away.
*
*/
protected boolean discard = true;
@@ -248,7 +250,11 @@
* within the buffer
* @return - true if a complete package (header,compress,size,data,footer)
exists within the buffer
*/
- public int countPackages()
+ public int countPackages() {
+ return countPackages(false);
+ }
+
+ public int countPackages(boolean first)
{
int cnt = 0;
int pos = START_DATA.length;
@@ -276,6 +282,8 @@
//reset the values
start = pos + END_DATA.length;
pos = start + START_DATA.length;
+ //we only want to verify that we have at least one package
+ if ( first ) break;
}
return cnt;
}
@@ -285,7 +293,7 @@
* @return - true if a complete package (header,options,size,data,footer)
exists within the buffer
*/
public boolean doesPackageExist() {
- return (countPackages()>0);
+ return (countPackages(true)>0);
}
/**
@@ -295,7 +303,7 @@
* @return - returns the actual message bytes (header, compress,size and
footer not included).
*/
public byte[] extractDataPackage(boolean clearFromBuffer) {
- int psize = countPackages();
+ int psize = countPackages(true);
if (psize == 0) throw new java.lang.IllegalStateException("No package
exists in XByteBuffer");
int size = toInt(buf, START_DATA.length);
byte[] data = new byte[size];
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]