001    /*
002     * Licensed to the Apache Software Foundation (ASF) under one
003     * or more contributor license agreements.  See the NOTICE file
004     * distributed with this work for additional information
005     * regarding copyright ownership.  The ASF licenses this file
006     * to you under the Apache License, Version 2.0 (the
007     * "License"); you may not use this file except in compliance
008     * with the License.  You may obtain a copy of the License at
009     *
010     *  http://www.apache.org/licenses/LICENSE-2.0
011     *
012     * Unless required by applicable law or agreed to in writing,
013     * software distributed under the License is distributed on an
014     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015     * KIND, either express or implied.  See the License for the
016     * specific language governing permissions and limitations
017     * under the License.
018     */
019    
020    package org.apache.geronimo.gshell.whisper.transport;
021    
022    import java.io.Closeable;
023    import java.io.InputStream;
024    import java.io.OutputStream;
025    import java.net.URI;
026    import java.util.EventListener;
027    
028    import org.apache.geronimo.gshell.common.Duration;
029    import org.apache.geronimo.gshell.whisper.message.Message;
030    import org.apache.mina.common.IoConnector;
031    import org.apache.mina.common.IoHandler;
032    import org.apache.mina.common.IoSession;
033    import org.apache.mina.common.ThreadModel;
034    import org.apache.mina.common.WriteFuture;
035    
036    /**
037     * Provides the client-side protocol interface.
038     *
039     * @version $Rev: 579828 $ $Date: 2007-09-26 15:15:42 -0700 (Wed, 26 Sep 2007) $
040     */
041    public interface Transport<T extends IoConnector>
042        extends Closeable
043    {
044        URI getRemote();
045    
046        URI getLocal();
047    
048        T getConnector();
049    
050        IoSession getSession();
051    
052        void close();
053    
054        // Messages
055    
056        WriteFuture send(Object msg) throws Exception;
057    
058        Message request(Message msg, Duration timeout) throws Exception;
059    
060        Message request(Message msg) throws Exception;
061    
062        //
063        // Streams
064        //
065    
066        InputStream getInputStream();
067    
068        OutputStream getOutputStream();
069    
070        OutputStream getErrorStream();
071    
072        //
073        // Listeners
074        //
075    
076        void addListener(Listener listener);
077    
078        void removeListener(Listener listener);
079    
080        interface Listener
081            extends EventListener
082        {
083            //
084            // TODO:
085            //
086        }
087        
088        //
089        // Configuration
090        //
091    
092        void setConfiguration(Configuration config);
093    
094        Configuration getConfiguration();
095    
096        interface Configuration
097        {
098            IoHandler getHandler();
099    
100            void setHandler(IoHandler handler);
101    
102            ThreadModel getThreadModel();
103    
104            void setThreadModel(ThreadModel threadModel);
105        }
106    }