SelectorImpl.java (register): Use ServerSocketChannelSelectionKey for server socket...
authorMichael Koch <konqueror@gmx.de>
Thu, 9 Oct 2003 18:01:08 +0000 (18:01 +0000)
committerMichael Koch <mkoch@gcc.gnu.org>
Thu, 9 Oct 2003 18:01:08 +0000 (18:01 +0000)
2003-10-09  Michael Koch  <konqueror@gmx.de>

* gnu/java/nio/SelectorImpl.java (register):
Use ServerSocketChannelSelectionKey for server socket channels,
removed unneeded comments.
* gnu/java/nio/ServerSocketChannelImpl.java
(ServerSocketChannelImpl): Made class public final.
(impl): New member variable.
(ServerSocketChannelImpl): Initialize member variables correctly.
(initServerSocket): New method.
(getNativeFD): Likewise.
* gnu/java/nio/ServerSocketChannelSelectionKey.java,
gnu/java/nio/natServerSocketChannelImpl.cc: New files.
* Makefile.am (ordinary_java_source_files):
Added gnu/java/nio/ServerSocketChannelSelectionKey.java.
(nat_source_files): Added gnu/java/nio/natServerSocketChannelImpl.cc.
* Makefile.in: Regenrated.

From-SVN: r72277

libjava/ChangeLog
libjava/Makefile.am
libjava/Makefile.in
libjava/gnu/java/nio/SelectorImpl.java
libjava/gnu/java/nio/ServerSocketChannelImpl.java
libjava/gnu/java/nio/ServerSocketChannelSelectionKey.java [new file with mode: 0644]
libjava/gnu/java/nio/natServerSocketChannelImpl.cc [new file with mode: 0644]

index 35238540e1482ac3a2ad4ec550ed546ea04c2e20..f652234fb4524fede8c2f5b24cb7d2711993b8b1 100644 (file)
@@ -1,3 +1,21 @@
+2003-10-09  Michael Koch  <konqueror@gmx.de>
+
+       * gnu/java/nio/SelectorImpl.java (register):
+       Use ServerSocketChannelSelectionKey for server socket channels,
+       removed unneeded comments.
+       * gnu/java/nio/ServerSocketChannelImpl.java
+       (ServerSocketChannelImpl): Made class public final.
+       (impl): New member variable.
+       (ServerSocketChannelImpl): Initialize member variables correctly.
+       (initServerSocket): New method.
+       (getNativeFD): Likewise.
+       * gnu/java/nio/ServerSocketChannelSelectionKey.java,
+       gnu/java/nio/natServerSocketChannelImpl.cc: New files.
+       * Makefile.am (ordinary_java_source_files):
+       Added gnu/java/nio/ServerSocketChannelSelectionKey.java.
+       (nat_source_files): Added gnu/java/nio/natServerSocketChannelImpl.cc.
+       * Makefile.in: Regenrated.
+
 2003-10-09  Michael Koch  <konqueror@gmx.de>
 
        * java/nio/channels/spi/AbstractSelectableChannel.java
index 8160ec416b2fdd007fec1fe90a501db1e711c40b..c2588eb2bb63e2d1ec8701245f2debcdaaf9c7e9 100644 (file)
@@ -2193,6 +2193,7 @@ gnu/java/nio/SelectionKeyImpl.java \
 gnu/java/nio/SelectorImpl.java \
 gnu/java/nio/SelectorProviderImpl.java \
 gnu/java/nio/ServerSocketChannelImpl.java \
+gnu/java/nio/ServerSocketChannelSelectionKey.java \
 gnu/java/nio/SocketChannelImpl.java \
 gnu/java/nio/SocketChannelSelectionKey.java \
 gnu/java/nio/charset/ISO_8859_1.java \
@@ -2658,6 +2659,7 @@ gnu/java/net/natPlainSocketImpl.cc \
 gnu/java/net/protocol/core/natCoreInputStream.cc \
 gnu/java/nio/natFileLockImpl.cc \
 gnu/java/nio/natSelectorImpl.cc \
+gnu/java/nio/natServerSocketChannelImpl.cc \
 java/io/natFile.cc \
 java/io/natFileDescriptor.cc \
 java/io/natObjectInputStream.cc \
index 3d2754c5eab77113d1f69ce9aae96cbe1bc24272..cbebfe6dbb151bdc57f80f046b416c9c43f0212c 100644 (file)
@@ -1912,6 +1912,7 @@ gnu/java/nio/SelectionKeyImpl.java \
 gnu/java/nio/SelectorImpl.java \
 gnu/java/nio/SelectorProviderImpl.java \
 gnu/java/nio/ServerSocketChannelImpl.java \
+gnu/java/nio/ServerSocketChannelSelectionKey.java \
 gnu/java/nio/SocketChannelImpl.java \
 gnu/java/nio/SocketChannelSelectionKey.java \
 gnu/java/nio/charset/ISO_8859_1.java \
@@ -2376,6 +2377,7 @@ gnu/java/net/natPlainSocketImpl.cc \
 gnu/java/net/protocol/core/natCoreInputStream.cc \
 gnu/java/nio/natFileLockImpl.cc \
 gnu/java/nio/natSelectorImpl.cc \
+gnu/java/nio/natServerSocketChannelImpl.cc \
 java/io/natFile.cc \
 java/io/natFileDescriptor.cc \
 java/io/natObjectInputStream.cc \
@@ -2553,12 +2555,13 @@ gnu/java/net/natPlainDatagramSocketImpl.lo \
 gnu/java/net/natPlainSocketImpl.lo \
 gnu/java/net/protocol/core/natCoreInputStream.lo \
 gnu/java/nio/natFileLockImpl.lo gnu/java/nio/natSelectorImpl.lo \
-java/io/natFile.lo java/io/natFileDescriptor.lo \
-java/io/natObjectInputStream.lo java/io/natVMObjectStreamClass.lo \
-java/lang/natCharacter.lo java/lang/natClass.lo \
-java/lang/natClassLoader.lo java/lang/natConcreteProcess.lo \
-java/lang/natDouble.lo java/lang/natFloat.lo java/lang/natMath.lo \
-java/lang/natObject.lo java/lang/natRuntime.lo java/lang/natString.lo \
+gnu/java/nio/natServerSocketChannelImpl.lo java/io/natFile.lo \
+java/io/natFileDescriptor.lo java/io/natObjectInputStream.lo \
+java/io/natVMObjectStreamClass.lo java/lang/natCharacter.lo \
+java/lang/natClass.lo java/lang/natClassLoader.lo \
+java/lang/natConcreteProcess.lo java/lang/natDouble.lo \
+java/lang/natFloat.lo java/lang/natMath.lo java/lang/natObject.lo \
+java/lang/natRuntime.lo java/lang/natString.lo \
 java/lang/natStringBuffer.lo java/lang/natSystem.lo \
 java/lang/natThread.lo java/lang/natVMSecurityManager.lo \
 java/lang/ref/natReference.lo java/lang/reflect/natArray.lo \
@@ -3037,6 +3040,7 @@ DEP_FILES =  .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
 .deps/gnu/java/nio/SelectorImpl.P \
 .deps/gnu/java/nio/SelectorProviderImpl.P \
 .deps/gnu/java/nio/ServerSocketChannelImpl.P \
+.deps/gnu/java/nio/ServerSocketChannelSelectionKey.P \
 .deps/gnu/java/nio/SocketChannelImpl.P \
 .deps/gnu/java/nio/SocketChannelSelectionKey.P \
 .deps/gnu/java/nio/charset/ISO_8859_1.P \
@@ -3049,6 +3053,7 @@ DEP_FILES =  .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
 .deps/gnu/java/nio/charset/UTF_16LE.P \
 .deps/gnu/java/nio/charset/UTF_8.P .deps/gnu/java/nio/natFileLockImpl.P \
 .deps/gnu/java/nio/natSelectorImpl.P \
+.deps/gnu/java/nio/natServerSocketChannelImpl.P \
 .deps/gnu/java/rmi/RMIMarshalledObjectInputStream.P \
 .deps/gnu/java/rmi/RMIMarshalledObjectOutputStream.P \
 .deps/gnu/java/rmi/dgc/DGCImpl.P .deps/gnu/java/rmi/dgc/DGCImpl_Skel.P \
index 08531ef449a4bfef0585518d09482fbc0bd48fe2..60a81f984587f34383d5ec57b8110ebdaa0ca836 100644 (file)
@@ -253,17 +253,17 @@ public class SelectorImpl extends AbstractSelector
     if (ch instanceof SocketChannelImpl)
       {
         SocketChannelImpl sc = (SocketChannelImpl) ch;
-        result = new SocketChannelSelectionKey (ch, this); // FIXME: last argument
+        result = new SocketChannelSelectionKey (ch, this);
       }
     else if (ch instanceof DatagramChannelImpl)
       {
         DatagramChannelImpl dc = (DatagramChannelImpl) ch;
-        result = new DatagramChannelSelectionKey (ch, this); // FIXME: last argument
+        result = new DatagramChannelSelectionKey (ch, this);
       }
     else if (ch instanceof ServerSocketChannelImpl)
       {
         ServerSocketChannelImpl ssc = (ServerSocketChannelImpl) ch;
-        result = new SocketChannelSelectionKey (ch, this); // FIXME: last argument
+        result = new ServerSocketChannelSelectionKey (ch, this);
       }
     else
       {
index 05ad0aefc309892d63072be7023b801c729f41f7..3ee0ae0849b4208856962918ae88b25f58bb40c5 100644 (file)
@@ -38,6 +38,7 @@ exception statement from your version. */
 
 package gnu.java.nio;
 
+import gnu.java.net.PlainSocketImpl;
 import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.net.ServerSocket;
@@ -47,9 +48,10 @@ import java.nio.channels.ServerSocketChannel;
 import java.nio.channels.SocketChannel;
 import java.nio.channels.spi.SelectorProvider;
 
-class ServerSocketChannelImpl extends ServerSocketChannel
+public final class ServerSocketChannelImpl extends ServerSocketChannel
 {
   ServerSocket serverSocket;
+  PlainSocketImpl impl;
   boolean blocking = true;
   boolean connected = false;
 
@@ -57,7 +59,20 @@ class ServerSocketChannelImpl extends ServerSocketChannel
     throws IOException
   {
     super (provider);
-    serverSocket = new ServerSocket ();
+    impl = new PlainSocketImpl();
+    initServerSocket();
+  }
+
+  /*
+   * This method is only need to call a package private constructor
+   * of java.net.ServerSocket. It only initializes the member variables
+   * "serverSocket".
+   */
+  private native void initServerSocket() throws IOException;
+
+  public int getNativeFD()
+  {
+    return impl.getNativeFD();
   }
  
   public void finalizer()
diff --git a/libjava/gnu/java/nio/ServerSocketChannelSelectionKey.java b/libjava/gnu/java/nio/ServerSocketChannelSelectionKey.java
new file mode 100644 (file)
index 0000000..55847e4
--- /dev/null
@@ -0,0 +1,56 @@
+/* ServerSocketChannelSelectionKey.java -- 
+   Copyright (C) 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.nio;
+
+import java.nio.channels.spi.AbstractSelectableChannel;
+
+public final class ServerSocketChannelSelectionKey
+  extends SelectionKeyImpl
+{
+  public ServerSocketChannelSelectionKey (AbstractSelectableChannel channel,
+                                          SelectorImpl selector)
+  {
+    super (channel, selector);
+  }
+
+  public int getNativeFD()
+  {
+    return ((ServerSocketChannelImpl) ch).getNativeFD();
+  }
+}
diff --git a/libjava/gnu/java/nio/natServerSocketChannelImpl.cc b/libjava/gnu/java/nio/natServerSocketChannelImpl.cc
new file mode 100644 (file)
index 0000000..a4b1ba4
--- /dev/null
@@ -0,0 +1,25 @@
+// natServerSocketChannelImpl.cc
+
+/* Copyright (C) 2003  Free Software Foundation
+
+   This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
+details.  */
+
+#include <config.h>
+#include <platform.h>
+
+#include <errno.h>
+#include <string.h>
+
+#include <gnu/java/net/PlainSocketImpl.h>
+#include <gnu/java/nio/ServerSocketChannelImpl.h>
+#include <java/net/ServerSocket.h>
+
+void
+gnu::java::nio::ServerSocketChannelImpl::initServerSocket()
+{
+  serverSocket = new ::java::net::ServerSocket (impl);
+}