You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by tr...@apache.org on 2006/01/22 12:14:06 UTC
svn commit: r371264 - in
/directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common:
IoService.java IoServiceProvider.java IoSession.java
UnsupportedAddressException.java
Author: trustin
Date: Sun Jan 22 03:13:58 2006
New Revision: 371264
URL: http://svn.apache.org/viewcvs?rev=371264&view=rev
Log:
* Added UnsupportedAddressException
* Fixed JavaDoc errors
Added:
directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/UnsupportedAddressException.java (with props)
Modified:
directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/IoService.java
directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/IoServiceProvider.java
directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/IoSession.java
Modified: directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/IoService.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/IoService.java?rev=371264&r1=371263&r2=371264&view=diff
==============================================================================
--- directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/IoService.java (original)
+++ directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/IoService.java Sun Jan 22 03:13:58 2006
@@ -19,7 +19,6 @@
package org.apache.mina.common;
import java.io.IOException;
-import java.net.SocketAddress;
import java.util.Collection;
import java.util.Enumeration;
import java.util.HashMap;
@@ -48,8 +47,7 @@
}
/**
- * Registers all {@link Converter}s and {@link ConverterPack}s
- * found using SPI.
+ * Registers all {@link IoServiceProvider}s.
*/
private static void registerServiceProviders() {
for( Enumeration e = Service.providers( IoServiceProvider.class );
@@ -122,7 +120,7 @@
return p;
}
- throw new IllegalArgumentException( "Unsupported address: " + address );
+ throw new UnsupportedAddressException( address.toString() );
}
private static String getProviderKey( IoServiceProvider provider )
@@ -229,8 +227,6 @@
* @throws IllegalArgumentException if the specified <tt>address</tt> has
* not been bound.
* @throws UnsupportedOperationException if this operation isn't supported
- * for the particular transport type implemented by this
- * {@link IoAcceptor}.
*/
public static Collection getManagedSessions( IoAddress address )
{
@@ -247,8 +243,6 @@
* @throws IllegalArgumentException if the specified <tt>address</tt> has
* not been bound.
* @throws UnsupportedOperationException if this operation isn't supported
- * for the particular transport type implemented by this
- * {@link IoAcceptor}.
*/
public static Collection getManagedSessions( String address )
{
@@ -256,18 +250,14 @@
}
/**
- * (Optional) Returns an {@link IoSession} that is bound to the specified
+ * Returns an {@link IoSession} that is bound to the specified
* <tt>localAddress</tt> and <tt>remoteAddress</tt> which reuses
- * the <tt>localAddress</tt> that is already bound by {@link IoAcceptor}
- * via {@link #bind(SocketAddress, IoHandler)}.
- * <p>
- * This operation is optional. Please throw {@link UnsupportedOperationException}
- * if the transport type doesn't support this operation. This operation is
- * usually implemented for connectionless transport types.
+ * the <tt>localAddress</tt> that is already bound via
+ * {@link #bind(IoAddress, IoHandler)}.
*
* @throws UnsupportedOperationException if this operation is not supported
* @throws IllegalArgumentException if the specified <tt>localAddress</tt> is
- * not bound yet. (see {@link #bind(SocketAddress, IoHandler)})
+ * not bound yet. (see {@link #bind(IoAddress, IoHandler)})
*/
public static IoSession newSession( IoAddress remoteAddress, IoAddress localAddress )
{
@@ -284,18 +274,14 @@
}
/**
- * (Optional) Returns an {@link IoSession} that is bound to the specified
+ * Returns an {@link IoSession} that is bound to the specified
* <tt>localAddress</tt> and <tt>remoteAddress</tt> which reuses
- * the <tt>localAddress</tt> that is already bound by {@link IoAcceptor}
- * via {@link #bind(SocketAddress, IoHandler)}.
- * <p>
- * This operation is optional. Please throw {@link UnsupportedOperationException}
- * if the transport type doesn't support this operation. This operation is
- * usually implemented for connectionless transport types.
+ * the <tt>localAddress</tt> that is already bound via
+ * {@link #bind(IoAddress, IoHandler)}.
*
* @throws UnsupportedOperationException if this operation is not supported
* @throws IllegalArgumentException if the specified <tt>localAddress</tt> is
- * not bound yet. (see {@link #bind(SocketAddress, IoHandler)})
+ * not bound yet. (see {@link #bind(IoAddress, IoHandler)})
*/
public static IoSession newSession( String remoteAddress, String localAddress )
{
@@ -427,14 +413,19 @@
return connect( createAddress( address ), createAddress( localAddress ), handler, filterChainBuilder );
}
- private static IoAddress createAddress( String addr )
+ /**
+ * Converts the specified string into {@link IoAddress}.
+ *
+ * @return <tt>null</tt> if <tt>value</tt> is null
+ */
+ private static IoAddress createAddress( String value )
{
- if( addr == null )
+ if( value == null )
{
return null;
}
- return new IoAddress( addr );
+ return new IoAddress( value );
}
private IoService()
Modified: directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/IoServiceProvider.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/IoServiceProvider.java?rev=371264&r1=371263&r2=371264&view=diff
==============================================================================
--- directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/IoServiceProvider.java (original)
+++ directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/IoServiceProvider.java Sun Jan 22 03:13:58 2006
@@ -22,21 +22,58 @@
import java.util.Collection;
/**
- * TODO Document me
+ * Provides support for a certain transport type to {@link IoService}.
+ * {@link IoService} discovers the implementations of this interface
+ * in runtime using
+ * <a href="http://java.sun.com/j2se/1.5.0/docs/guide/jar/jar.html#Service%20Provider">Java SPI</a>,
+ * and forwards I/O requests to the implementation.
+ * <p>
+ * This interface is for transport type implementors only. Ordinary users
+ * don't need to implement this interface.
*
* @author The Apache Directory Project (dev@directory.apache.org)
* @version $Rev$, $Date$
*/
public interface IoServiceProvider
{
+ /**
+ * Returns the type of this provider (e.g. the name of the API it uses).
+ */
String getProviderType();
+
+ /**
+ * Returns the name of the transport type this provider provides.
+ */
String getTransportType();
+
+ /**
+ * Returns the type of the message this provider can use to perform I/O.
+ * (e.g. ByteBuffer)
+ */
Class getEnvelopeType();
+
+ /**
+ * Returns <tt>true</tt> if and only if the transport type this provider
+ * provides is connectionless.
+ */
boolean isConnectionless();
+ /**
+ * Returns a singleton instance of the {@link IoAcceptor} of this provider.
+ */
IoAcceptor getAcceptor();
+
+ /**
+ * Returns a singleton instance of the {@link IoConnector} of this provider.
+ */
IoConnector getConnector();
+ /**
+ * Provides server-side functionality of {@link IoServiceProvider}.
+ *
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$
+ */
public interface IoAcceptor
{
/**
@@ -74,7 +111,7 @@
* (Optional) Returns an {@link IoSession} that is bound to the specified
* <tt>localAddress</tt> and <tt>remoteAddress</tt> which reuses
* the <tt>localAddress</tt> that is already bound by {@link IoAcceptor}
- * via {@link #bind(IoAddress, IoHandler)}.
+ * via {@link #bind(IoAddress, IoHandler, IoFilterChainBuilder)}.
* <p>
* This operation is optional. Please throw {@link UnsupportedOperationException}
* if the transport type doesn't support this operation. This operation is
@@ -82,11 +119,17 @@
*
* @throws UnsupportedOperationException if this operation is not supported
* @throws IllegalArgumentException if the specified <tt>localAddress</tt> is
- * not bound yet. (see {@link #bind(IoAddress, IoHandler)})
+ * not bound yet. (see {@link #bind(IoAddress, IoHandler, IoFilterChainBuilder)})
*/
IoSession newSession( IoAddress remoteAddress, IoAddress localAddress );
}
+ /**
+ * Provides client-side functionality of {@link IoServiceProvider}.
+ *
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$
+ */
public interface IoConnector
{
/**
Modified: directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/IoSession.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/IoSession.java?rev=371264&r1=371263&r2=371264&view=diff
==============================================================================
--- directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/IoSession.java (original)
+++ directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/IoSession.java Sun Jan 22 03:13:58 2006
@@ -49,10 +49,11 @@
public interface IoSession {
/**
- * Returns the {@link IoServiceProvider} which provides transport service to this session.
+ * Returns the {@link IoServiceProvider} which actually provides transport
+ * service to this session.
*/
IoServiceProvider getProvider();
-
+
/**
* Returns the {@link IoHandler} which handles this session.
*/
@@ -203,8 +204,8 @@
/**
* Sets the {@link TrafficMask} of this session which will result
- * the parent {@link IoSessionManager} to start to control the traffic
- * of this session immediately.
+ * the {@link IoService} to start to control the traffic of this
+ * session immediately.
*/
void setTrafficMask( TrafficMask trafficMask );
Added: directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/UnsupportedAddressException.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/UnsupportedAddressException.java?rev=371264&view=auto
==============================================================================
--- directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/UnsupportedAddressException.java (added)
+++ directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/UnsupportedAddressException.java Sun Jan 22 03:13:58 2006
@@ -0,0 +1,51 @@
+/*
+ * @(#) $Id$
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.mina.common;
+
+/**
+ * A {@link RuntimeException} which is thrown when the specified {@link IoAddress}
+ * is not supported by any {@link IoServiceProvider}s.
+ *
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$
+ */
+public class UnsupportedAddressException extends RuntimeException
+{
+ private static final long serialVersionUID = -3747619326762472978L;
+
+ public UnsupportedAddressException()
+ {
+ super();
+ }
+
+ public UnsupportedAddressException( String message )
+ {
+ super( message );
+ }
+
+ public UnsupportedAddressException( String message, Throwable cause )
+ {
+ super( message, cause );
+ }
+
+ public UnsupportedAddressException( Throwable cause )
+ {
+ super( cause );
+ }
+}
Propchange: directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/UnsupportedAddressException.java
------------------------------------------------------------------------------
svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision