[Beepcore-java-commits] CVS: beepcore-java/src/org/beepcore/beep/lib SharedChannel.java,1.10,1.11 Ch
Status: Beta
Brought to you by:
huston
|
From: Huston F. <hu...@us...> - 2003-06-10 18:59:56
|
Update of /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/lib
In directory sc8-pr-cvs1:/tmp/cvs-serv21972/src/org/beepcore/beep/lib
Modified Files:
SharedChannel.java ChannelPool.java
Log Message:
More interface cleanup, added RequestHandler to replace MessageListener.
Index: SharedChannel.java
===================================================================
RCS file: /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/lib/SharedChannel.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** SharedChannel.java 23 Apr 2003 15:23:02 -0000 1.10
--- SharedChannel.java 10 Jun 2003 18:59:22 -0000 1.11
***************
*** 23,26 ****
--- 23,27 ----
import org.beepcore.beep.core.MessageListener;
import org.beepcore.beep.core.MessageStatus;
+ import org.beepcore.beep.core.RequestHandler;
import org.beepcore.beep.core.OutputDataStream;
import org.beepcore.beep.core.ReplyListener;
***************
*** 118,121 ****
--- 119,138 ----
{
return channel.getMessageListener();
+ }
+
+ public RequestHandler getRequestHandler()
+ {
+ return channel.getRequestHandler();
+ }
+
+ public RequestHandler setRequestHandler(RequestHandler handler)
+ {
+ return channel.setRequestHandler(handler);
+ }
+
+ public RequestHandler setRequestHandler(RequestHandler handler,
+ boolean tuningReset)
+ {
+ return channel.setRequestHandler(handler, tuningReset);
}
Index: ChannelPool.java
===================================================================
RCS file: /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/lib/ChannelPool.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** ChannelPool.java 23 Apr 2003 15:23:02 -0000 1.8
--- ChannelPool.java 10 Jun 2003 18:59:22 -0000 1.9
***************
*** 3,7 ****
*
* Copyright (c) 2001 Invisible Worlds, Inc. All rights reserved.
! * Copyright (c) 2002 Huston Franklin. All rights reserved.
*
* The contents of this file are subject to the Blocks Public License (the
--- 3,7 ----
*
* Copyright (c) 2001 Invisible Worlds, Inc. All rights reserved.
! * Copyright (c) 2002,2003 Huston Franklin. All rights reserved.
*
* The contents of this file are subject to the Blocks Public License (the
***************
*** 21,24 ****
--- 21,25 ----
import org.beepcore.beep.core.BEEPException;
import org.beepcore.beep.core.MessageListener;
+ import org.beepcore.beep.core.RequestHandler;
import org.beepcore.beep.core.Session;
***************
*** 125,131 ****
// nothing found, so create one and return it
if (!found) {
! sharedCh =
! new SharedChannel(this.session.startChannel(profile, null),
! this);
}
--- 126,131 ----
// nothing found, so create one and return it
if (!found) {
! sharedCh = new SharedChannel(this.session.startChannel(profile),
! this);
}
***************
*** 157,160 ****
--- 157,161 ----
*
* @throws BEEPException
+ * @deprecated
*/
synchronized public SharedChannel
***************
*** 198,201 ****
--- 199,261 ----
}
+ /**
+ * Returns a <code>SharedChannel</code> which supports the specified
+ * <code>profile</code> and calls back on the specified
+ * <code>DataListener</code>. Once it is no longer needed, call
+ * <code>release</code> on the <code>SharedChannel</code>
+ * to return it to the pool of available channels.
+ *
+ * @param profile Name of profile for the requested
+ * <code>SharedChannel</code>.
+ * @param listener <code>DataListener</code> for the requested
+ * <code>SharedChannel</code>.
+ *
+ * @return A <code>SharedChannel</code>.
+ *
+ * @see MessageListener
+ * @see SharedChannel
+ *
+ * @throws BEEPException
+ * @deprecated
+ */
+ synchronized
+ public SharedChannel getSharedChannel(String profile, RequestHandler handler)
+ throws BEEPException
+ {
+ SharedChannel sharedCh = null;
+ boolean found = false;
+
+ synchronized (availableChannels) {
+ Iterator i = availableChannels.iterator();
+
+ while (i.hasNext()) {
+ sharedCh = (SharedChannel) i.next();
+
+ if (sharedCh.getProfile().equals(profile)) {
+ log.trace("Found an available channel for sharing");
+ i.remove();
+
+ found = true;
+
+ break;
+ }
+ }
+ }
+
+ // nothing found, so create one and return it
+ if (!found) {
+ sharedCh =
+ new SharedChannel(this.session.startChannel(profile, handler),
+ this);
+ }
+
+ // clean up channels that have expired
+ garbageCollect();
+ if (log.isTraceEnabled()) {
+ log.trace("Sharing channel number:" + sharedCh.getNumber());
+ }
+
+ return sharedCh;
+ }
/**
* Called from <code>SharedChannel</code>. Releases the sharedCh and adds
|