You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2004/09/05 07:16:32 UTC
svn commit: rev 43366 - in incubator/directory/eve/branches/multi-listener/api/src/java/org/apache/eve: listener protocol
Author: akarasulu
Date: Sat Sep 4 22:16:31 2004
New Revision: 43366
Added:
incubator/directory/eve/branches/multi-listener/api/src/java/org/apache/eve/protocol/TransportTypeEnum.java (contents, props changed)
Modified:
incubator/directory/eve/branches/multi-listener/api/src/java/org/apache/eve/listener/ServerListener.java
incubator/directory/eve/branches/multi-listener/api/src/java/org/apache/eve/protocol/HandlerTypeEnum.java
incubator/directory/eve/branches/multi-listener/api/src/java/org/apache/eve/protocol/InetServiceEntry.java
Log:
made the transport protocol used into a type safe enum
Modified: incubator/directory/eve/branches/multi-listener/api/src/java/org/apache/eve/listener/ServerListener.java
==============================================================================
--- incubator/directory/eve/branches/multi-listener/api/src/java/org/apache/eve/listener/ServerListener.java (original)
+++ incubator/directory/eve/branches/multi-listener/api/src/java/org/apache/eve/listener/ServerListener.java Sat Sep 4 22:16:31 2004
@@ -47,7 +47,7 @@
/**
* Gets the ip interface address this ServerListener listens on.
*
- * @return the ip address octets as a String i.e. 127.0.0.1
+ * @return the ip address octets i.e. { 127,0,0,1 } for 127.0.0.1
*/
public byte[] getAddress() ;
@@ -77,7 +77,7 @@
* the tcp port number listened to. The ipaddress is resolved to a host
* name.
*
- * @return the LDAP URL like so ldap://localhost:389
+ * @return the URL with scheme like so ldap://localhost:389
*/
public String getURL() ;
}
Modified: incubator/directory/eve/branches/multi-listener/api/src/java/org/apache/eve/protocol/HandlerTypeEnum.java
==============================================================================
--- incubator/directory/eve/branches/multi-listener/api/src/java/org/apache/eve/protocol/HandlerTypeEnum.java (original)
+++ incubator/directory/eve/branches/multi-listener/api/src/java/org/apache/eve/protocol/HandlerTypeEnum.java Sat Sep 4 22:16:31 2004
@@ -22,7 +22,7 @@
/**
* Valued enumeration for the three types of handlers: NOREPLY, SINGLEREPLY,
- * and SEARCH.
+ * and MANYREPLY.
*
* @author <a href="mailto:directory-dev@incubator.apache.org">
* Apache Directory Project</a>
@@ -34,7 +34,7 @@
public static final int NOREPLY_VAL = 0 ;
/** Value for singlereply enumeration type */
public static final int SINGLEREPLY_VAL = 1 ;
- /** Value for many value enumeration type */
+ /** Value for manyreply enumeration type */
public static final int MANYREPLY_VAL = 2 ;
/** Enum for noreply type */
@@ -43,8 +43,8 @@
/** Enum for singlereply type */
public static final HandlerTypeEnum SINGLEREPLY =
new HandlerTypeEnum( "SINGLEREPLY", SINGLEREPLY_VAL ) ;
- /** Enum for search type */
- public static final HandlerTypeEnum SEARCH =
+ /** Enum for manyreply type */
+ public static final HandlerTypeEnum MANYREPLY =
new HandlerTypeEnum( "MANYREPLY", MANYREPLY_VAL ) ;
Modified: incubator/directory/eve/branches/multi-listener/api/src/java/org/apache/eve/protocol/InetServiceEntry.java
==============================================================================
--- incubator/directory/eve/branches/multi-listener/api/src/java/org/apache/eve/protocol/InetServiceEntry.java (original)
+++ incubator/directory/eve/branches/multi-listener/api/src/java/org/apache/eve/protocol/InetServiceEntry.java Sat Sep 4 22:16:31 2004
@@ -24,11 +24,6 @@
*/
public class InetServiceEntry
{
- /** constant for tcp transport protocol */
- public static final int TCP_TRANS = 0;
- /** constant for udp transport protocol */
- public static final int UDP_TRANS = 1;
-
/** an empty string array for no aliases */
private static final String[] EMPTY_ALIASES = new String[0];
@@ -39,7 +34,7 @@
/** alternative names for the service */
private final String[] aliases;
/** the transport protocol used by the service */
- private final int proto;
+ private final TransportTypeEnum proto;
/**
@@ -51,7 +46,7 @@
*/
public InetServiceEntry( String name, int port )
{
- this( name, port, TCP_TRANS, null );
+ this( name, port, TransportTypeEnum.TCP, null );
}
@@ -62,7 +57,7 @@
* @param port the port the service runs on
* @param proto the transport protocol used by the service
*/
- public InetServiceEntry( String name, int port, int proto )
+ public InetServiceEntry( String name, int port, TransportTypeEnum proto )
{
this( name, port, proto, null );
}
@@ -76,24 +71,21 @@
* @param proto the transport protocol used by the service
* @param aliases alternative names for the service
*/
- public InetServiceEntry( String name, int port, int proto, String[] aliases )
+ public InetServiceEntry( String name, int port, TransportTypeEnum proto,
+ String[] aliases )
{
if ( name == null )
{
- throw new NullPointerException( "an entry name can't be null" );
+ throw new NullPointerException( "service name can't be null" );
}
this.name = name;
this.port = port;
this.proto = proto;
- switch( proto )
+ if ( proto == null )
{
- case TCP_TRANS: break;
- case UDP_TRANS: break;
- default:
- throw new IllegalArgumentException(
- "Unrecognized transport protocol: " + proto );
+ throw new NullPointerException( "transport can't be null" );
}
if ( aliases == null )
@@ -145,7 +137,7 @@
*
* @return the transport protocol used for this service
*/
- public int getProtocol()
+ public TransportTypeEnum getProtocol()
{
return proto;
}
Added: incubator/directory/eve/branches/multi-listener/api/src/java/org/apache/eve/protocol/TransportTypeEnum.java
==============================================================================
--- (empty file)
+++ incubator/directory/eve/branches/multi-listener/api/src/java/org/apache/eve/protocol/TransportTypeEnum.java Sat Sep 4 22:16:31 2004
@@ -0,0 +1,59 @@
+/*
+ * 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.eve.protocol ;
+
+
+import org.apache.commons.lang.enum.ValuedEnum ;
+
+
+/**
+ * Valued enumeration for the types transports: TCP, UDP, and PIPE for now.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class TransportTypeEnum extends ValuedEnum
+{
+ /** Value for TCP transport enumeration type */
+ public static final int TCP_VAL = 0 ;
+ /** Value for UDP transport enumeration type */
+ public static final int UDP_VAL = 1 ;
+ /** Value for PIPE transport enumeration type */
+ public static final int PIPE_VAL = 2 ;
+
+ /** Enum for TCP type */
+ public static final TransportTypeEnum TCP =
+ new TransportTypeEnum( "TCP", TCP_VAL ) ;
+ /** Enum for UDP type */
+ public static final TransportTypeEnum UDP =
+ new TransportTypeEnum( "UDP", UDP_VAL ) ;
+ /** Enum for PIPE type */
+ public static final TransportTypeEnum PIPE =
+ new TransportTypeEnum( "PIPE", PIPE_VAL ) ;
+
+
+ /**
+ * Enables creation of constants in this class only.
+ *
+ * @param name the name of the enum
+ * @param value the value of the enum
+ */
+ private TransportTypeEnum( String name, int value )
+ {
+ super( name, value ) ;
+ }
+}