Package java.nio.channels

Examples of java.nio.channels.Channel


    protected void closeActiveChannels() throws IOReactorException {
        Set<SelectionKey> keys = this.selector.keys();
        for (Iterator<SelectionKey> it = keys.iterator(); it.hasNext(); ) {
            try {
                SelectionKey key = it.next();
                Channel channel = key.channel();
                if (channel != null) {
                    channel.close();
                }
            } catch (IOException ignore) {
            }
        }
        try {
View Full Code Here


        }
        this.completed = true;
        this.closed = true;
        if (this.key != null) {
            this.key.cancel();
            Channel channel = this.key.channel();
            if (channel.isOpen()) {
                try {
                    channel.close();
                } catch (IOException ignore) {}
            }
        }
        if (this.callback != null) {
            this.callback.endpointClosed(this);
View Full Code Here

            }

            @Override
            public String toString() {
                StringBuilder sb = new StringBuilder();
                Channel channel = sk.channel();
                if (channel instanceof SocketChannel) {
                    sb.append(" ").append(((SocketChannel) channel).socket().getRemoteSocketAddress()).append("[")
                    .append(Integer.toHexString(sk.interestOps())).append("](queued=").append(
                        getOutstandingRequests()).append(",recved=").append(getPacketsReceived()).append(
                            ",sent=").append(getPacketsSent()).append(")\n");
View Full Code Here

    protected void unlockFile(FileEndpoint endpoint, FileExchange exchange, File file) throws Exception {
        if (isLockFile()) {
            FileLock lock = ExchangeHelper.getMandatoryProperty(exchange, "org.apache.camel.file.lock", FileLock.class);
            String lockFileName = ExchangeHelper.getMandatoryProperty(exchange, "org.apache.camel.file.lock.name", String.class);
            Channel channel = lock.channel();
            if (LOG.isDebugEnabled()) {
                LOG.debug("Unlocking file: " + file);
            }
            try {
                lock.release();
View Full Code Here

    public ByteChannel channel() {
        return this.channel;
    }

    public SocketAddress getLocalAddress() {
        Channel channel = this.channel;
        if (channel instanceof SocketChannel) {
            return ((SocketChannel)channel).socket().getLocalSocketAddress();
        } else {
            return null;
        }
View Full Code Here

            return null;
        }
    }

    public SocketAddress getRemoteAddress() {
        Channel channel = this.channel;
        if (channel instanceof SocketChannel) {
            return ((SocketChannel)channel).socket().getRemoteSocketAddress();
        } else {
            return null;
        }
View Full Code Here

            try
            {
                Method m = System.class.getMethod("inheritedChannel",null);
                if (m!=null)
                {
                    Channel channel = (Channel)m.invoke(null,null);
                    if ( channel instanceof ServerSocketChannel )
                        _acceptChannel = (ServerSocketChannel)channel;
                }
               
                if (_acceptChannel!=null)
View Full Code Here

         * @return information about this connection
         */
        public synchronized void
        dumpConnectionInfo(PrintWriter pwriter, boolean brief)
        {
            Channel channel = sk.channel();
            if (channel instanceof SocketChannel) {
                pwriter.print(" ");
                pwriter.print(((SocketChannel)channel).socket()
                        .getRemoteSocketAddress());
                pwriter.print("[");
View Full Code Here

            }

            @Override
            public String toString() {
                StringBuilder sb = new StringBuilder();
                Channel channel = sk.channel();
                if (channel instanceof SocketChannel) {
                    sb.append(" ").append(((SocketChannel) channel).socket().getRemoteSocketAddress()).append("[")
                            .append(Integer.toHexString(sk.interestOps())).append("](queued=").append(
                                    getOutstandingRequests()).append(",recved=").append(getPacketsReceived()).append(
                                    ",sent=").append(getPacketsSent()).append(")\n");
View Full Code Here

        return true;
    }

    public void commit(FileEndpoint endpoint, FileExchange exchange, File file) throws Exception {
        if (isLockFile()) {
            Channel channel = ExchangeHelper.getMandatoryProperty(exchange, "org.apache.camel.fileChannel", Channel.class);
            String lockfile = ExchangeHelper.getMandatoryProperty(exchange, "org.apache.camel.file.lock.name", String.class);
            if (LOG.isDebugEnabled()) {
                LOG.debug("Unlocking file: " + file);
            }
            channel.close();
            File lock = new File(lockfile);
            lock.delete();
        }
    }
View Full Code Here

TOP

Related Classes of java.nio.channels.Channel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.