diff options
Diffstat (limited to 'libjava/gnu/java/nio')
-rw-r--r-- | libjava/gnu/java/nio/SelectorImpl.java | 6 | ||||
-rw-r--r-- | libjava/gnu/java/nio/ServerSocketChannelImpl.java | 19 | ||||
-rw-r--r-- | libjava/gnu/java/nio/ServerSocketChannelSelectionKey.java | 56 | ||||
-rw-r--r-- | libjava/gnu/java/nio/natServerSocketChannelImpl.cc | 25 |
4 files changed, 101 insertions, 5 deletions
diff --git a/libjava/gnu/java/nio/SelectorImpl.java b/libjava/gnu/java/nio/SelectorImpl.java index 08531ef449a..60a81f98458 100644 --- a/libjava/gnu/java/nio/SelectorImpl.java +++ b/libjava/gnu/java/nio/SelectorImpl.java @@ -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 { diff --git a/libjava/gnu/java/nio/ServerSocketChannelImpl.java b/libjava/gnu/java/nio/ServerSocketChannelImpl.java index 05ad0aefc30..3ee0ae0849b 100644 --- a/libjava/gnu/java/nio/ServerSocketChannelImpl.java +++ b/libjava/gnu/java/nio/ServerSocketChannelImpl.java @@ -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 index 00000000000..55847e49a26 --- /dev/null +++ b/libjava/gnu/java/nio/ServerSocketChannelSelectionKey.java @@ -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 index 00000000000..a4b1ba4df01 --- /dev/null +++ b/libjava/gnu/java/nio/natServerSocketChannelImpl.cc @@ -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); +} |