directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r330764 - in /directory/protocol-providers/dns/trunk: ./ src/main/java/org/apache/dns/ src/main/java/org/apache/dns/protocol/ src/main/java/org/apache/dns/service/ src/main/java/org/apache/dns/store/operations/
Date Fri, 04 Nov 2005 09:00:20 GMT
Author: trustin
Date: Fri Nov  4 01:00:09 2005
New Revision: 330764

URL: http://svn.apache.org/viewcvs?rev=330764&view=rev
Log:
Related issue: DIR-114 Migrate all protocol providers to MINA 0.9.
* Migrated protocol-provider for DNS protocol to MINA 0.9.

Added:
    directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/protocol/DnsProtocolCodecFactory.java
      - copied, changed from r330736, directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/protocol/DnsProtocolProvider.java
Removed:
    directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/protocol/DnsProtocolProvider.java
Modified:
    directory/protocol-providers/dns/trunk/project.xml
    directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/DnsConfiguration.java
    directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/DnsException.java
    directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/DnsServer.java
    directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/protocol/DnsDecoder.java
    directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/protocol/DnsEncoder.java
    directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/protocol/DnsProtocolHandler.java
    directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/service/DnsContext.java
    directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/store/operations/GetFlatRecord.java
    directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/store/operations/GetRecords.java

Modified: directory/protocol-providers/dns/trunk/project.xml
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/project.xml?rev=330764&r1=330763&r2=330764&view=diff
==============================================================================
--- directory/protocol-providers/dns/trunk/project.xml (original)
+++ directory/protocol-providers/dns/trunk/project.xml Fri Nov  4 01:00:09 2005
@@ -90,7 +90,7 @@
     <dependency>
       <groupId>directory-network</groupId>
       <artifactId>mina</artifactId>
-      <version>0.8.0</version>
+      <version>0.9.0-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>org.slf4j</groupId>
@@ -115,7 +115,7 @@
   <build>
     <nagEmailAddress>dev@directory.apache.org</nagEmailAddress>
     <sourceDirectory>${basedir}/src/main/java</sourceDirectory>
-    <unitTestSourceDirectory>${basedir}/src/test</unitTestSourceDirectory>
+    <unitTestSourceDirectory>${basedir}/src/test/java</unitTestSourceDirectory>
     <unitTest>
       <includes>
         <include>**/*Test*</include>
@@ -127,7 +127,7 @@
       </excludes>
       <resources>
         <resource>
-          <directory>${basedir}/src/test</directory>
+          <directory>${basedir}/src/test/java</directory>
           <includes>
             <include>**/*.dtd</include>
             <include>**/*.ldif</include>

Modified: directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/DnsConfiguration.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/DnsConfiguration.java?rev=330764&r1=330763&r2=330764&view=diff
==============================================================================
--- directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/DnsConfiguration.java
(original)
+++ directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/DnsConfiguration.java
Fri Nov  4 01:00:09 2005
@@ -27,6 +27,8 @@
 
 public class DnsConfiguration extends ServiceConfiguration
 {
+    private static final long serialVersionUID = 6943138644427163149L;
+
     /** the default port */
     private static final String DEFAULT_IP_PORT = "53";
 

Modified: directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/DnsException.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/DnsException.java?rev=330764&r1=330763&r2=330764&view=diff
==============================================================================
--- directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/DnsException.java
(original)
+++ directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/DnsException.java
Fri Nov  4 01:00:09 2005
@@ -27,6 +27,8 @@
  */
 public class DnsException extends Exception
 {
+    private static final long serialVersionUID = 7493573233290707069L;
+
     /**
      * The DNS response code associated with this exception
      */

Modified: directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/DnsServer.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/DnsServer.java?rev=330764&r1=330763&r2=330764&view=diff
==============================================================================
--- directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/DnsServer.java (original)
+++ directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/DnsServer.java Fri
Nov  4 01:00:09 2005
@@ -20,10 +20,10 @@
 import java.io.IOException;
 import java.util.Dictionary;
 
-import org.apache.dns.protocol.DnsProtocolProvider;
+import org.apache.dns.protocol.DnsProtocolHandler;
 import org.apache.dns.store.RecordStore;
+import org.apache.mina.common.IoHandler;
 import org.apache.mina.common.TransportType;
-import org.apache.mina.protocol.ProtocolProvider;
 import org.apache.mina.registry.Service;
 import org.apache.mina.registry.ServiceRegistry;
 import org.slf4j.Logger;
@@ -38,7 +38,7 @@
     private ServiceRegistry registry;
     private RecordStore store;
 
-    private ProtocolProvider provider;
+    private IoHandler handler;
     private Service tcpService;
     private Service udpService;
 
@@ -53,13 +53,13 @@
 
         try
         {
-            provider = new DnsProtocolProvider( config, this.store );
+            handler = new DnsProtocolHandler( config, this.store );
 
             udpService = new Service( name, TransportType.DATAGRAM, port );
             tcpService = new Service( name, TransportType.SOCKET, port );
 
-            registry.bind( udpService, provider );
-            registry.bind( tcpService, provider );
+            registry.bind( udpService, handler );
+            registry.bind( tcpService, handler );
 
             log.debug( name + " listening on port " + port );
         }
@@ -80,7 +80,7 @@
         registry.unbind( tcpService );
 
         registry = null;
-        provider = null;
+        handler = null;
         udpService = null;
         tcpService = null;
 

Modified: directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/protocol/DnsDecoder.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/protocol/DnsDecoder.java?rev=330764&r1=330763&r2=330764&view=diff
==============================================================================
--- directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/protocol/DnsDecoder.java
(original)
+++ directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/protocol/DnsDecoder.java
Fri Nov  4 01:00:09 2005
@@ -35,10 +35,9 @@
 import org.apache.dns.messages.ResourceRecords;
 import org.apache.dns.messages.ResponseCode;
 import org.apache.mina.common.ByteBuffer;
-import org.apache.mina.protocol.ProtocolDecoder;
-import org.apache.mina.protocol.ProtocolDecoderOutput;
-import org.apache.mina.protocol.ProtocolSession;
-import org.apache.mina.protocol.ProtocolViolationException;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.filter.codec.ProtocolDecoder;
+import org.apache.mina.filter.codec.ProtocolDecoderOutput;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -61,8 +60,7 @@
         DEFAULT_DECODERS = Collections.unmodifiableMap( map );
     }
 
-    public void decode( ProtocolSession session, ByteBuffer in, ProtocolDecoderOutput out
)
-            throws ProtocolViolationException
+    public void decode( IoSession session, ByteBuffer in, ProtocolDecoderOutput out )
     {
         out.write( decode( in ) );
     }
@@ -240,5 +238,9 @@
     private ResponseCode decodeResponseCode( byte header )
     {
         return ResponseCode.getTypeByOrdinal( header & 0x0F );
+    }
+
+    public void dispose( IoSession arg0 ) throws Exception
+    {
     }
 }

Modified: directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/protocol/DnsEncoder.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/protocol/DnsEncoder.java?rev=330764&r1=330763&r2=330764&view=diff
==============================================================================
--- directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/protocol/DnsEncoder.java
(original)
+++ directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/protocol/DnsEncoder.java
Fri Nov  4 01:00:09 2005
@@ -43,10 +43,9 @@
 import org.apache.dns.messages.ResourceRecords;
 import org.apache.dns.messages.ResponseCode;
 import org.apache.mina.common.ByteBuffer;
-import org.apache.mina.protocol.ProtocolEncoder;
-import org.apache.mina.protocol.ProtocolEncoderOutput;
-import org.apache.mina.protocol.ProtocolSession;
-import org.apache.mina.protocol.ProtocolViolationException;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.filter.codec.ProtocolEncoder;
+import org.apache.mina.filter.codec.ProtocolEncoderOutput;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -76,8 +75,7 @@
         DEFAULT_ENCODERS = Collections.unmodifiableMap( map );
     }
 
-    public void encode( ProtocolSession session, Object message, ProtocolEncoderOutput out
)
-            throws ProtocolViolationException
+    public void encode( IoSession session, Object message, ProtocolEncoderOutput out )
     {
         ByteBuffer buf = ByteBuffer.allocate( 1024 );
         encode( buf, (DnsMessage) message );
@@ -213,5 +211,9 @@
     {
         byte fourBits = (byte) ( responseCode.getOrdinal() & 0x0F );
         return (byte) ( fourBits | header );
+    }
+
+    public void dispose( IoSession arg0 ) throws Exception
+    {
     }
 }

Copied: directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/protocol/DnsProtocolCodecFactory.java
(from r330736, directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/protocol/DnsProtocolProvider.java)
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/protocol/DnsProtocolCodecFactory.java?p2=directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/protocol/DnsProtocolCodecFactory.java&p1=directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/protocol/DnsProtocolProvider.java&r1=330736&r2=330764&rev=330764&view=diff
==============================================================================
--- directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/protocol/DnsProtocolProvider.java
(original)
+++ directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/protocol/DnsProtocolCodecFactory.java
Fri Nov  4 01:00:09 2005
@@ -17,47 +17,33 @@
 
 package org.apache.dns.protocol;
 
-import org.apache.dns.DnsConfiguration;
-import org.apache.dns.store.RecordStore;
-import org.apache.mina.protocol.ProtocolCodecFactory;
-import org.apache.mina.protocol.ProtocolDecoder;
-import org.apache.mina.protocol.ProtocolEncoder;
-import org.apache.mina.protocol.ProtocolHandler;
-import org.apache.mina.protocol.ProtocolProvider;
+import org.apache.mina.filter.codec.ProtocolCodecFactory;
+import org.apache.mina.filter.codec.ProtocolDecoder;
+import org.apache.mina.filter.codec.ProtocolEncoder;
 
-public class DnsProtocolProvider implements ProtocolProvider
+public class DnsProtocolCodecFactory implements ProtocolCodecFactory
 {
-    // Protocol handler is usually a singleton.
-    private static ProtocolHandler HANDLER;
-
-    // Codec factory is also usually a singleton.
-    private static ProtocolCodecFactory CODEC_FACTORY = new ProtocolCodecFactory()
+    private static final DnsProtocolCodecFactory INSTANCE = 
+        new DnsProtocolCodecFactory();
+    
+    public static DnsProtocolCodecFactory getInstance()
     {
-        public ProtocolEncoder newEncoder()
-        {
-            // Create a new encoder.
-            return new DnsEncoder();
-        }
-
-        public ProtocolDecoder newDecoder()
-        {
-            // Create a new decoder.
-            return new DnsDecoder();
-        }
-    };
+        return INSTANCE;
+    }
 
-    public DnsProtocolProvider( DnsConfiguration config, RecordStore store )
+    private DnsProtocolCodecFactory()
     {
-        HANDLER = new DnsProtocolHandler( config, store );
     }
 
-    public ProtocolCodecFactory getCodecFactory()
+    public ProtocolEncoder getEncoder()
     {
-        return CODEC_FACTORY;
+        // Create a new encoder.
+        return new DnsEncoder();
     }
 
-    public ProtocolHandler getHandler()
+    public ProtocolDecoder getDecoder()
     {
-        return HANDLER;
+        // Create a new decoder.
+        return new DnsDecoder();
     }
 }

Modified: directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/protocol/DnsProtocolHandler.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/protocol/DnsProtocolHandler.java?rev=330764&r1=330763&r2=330764&view=diff
==============================================================================
--- directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/protocol/DnsProtocolHandler.java
(original)
+++ directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/protocol/DnsProtocolHandler.java
Fri Nov  4 01:00:09 2005
@@ -23,13 +23,14 @@
 import org.apache.dns.service.DomainNameServiceChain;
 import org.apache.dns.store.RecordStore;
 import org.apache.mina.common.IdleStatus;
-import org.apache.mina.protocol.ProtocolHandler;
-import org.apache.mina.protocol.ProtocolSession;
+import org.apache.mina.common.IoHandler;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.filter.codec.ProtocolCodecFilter;
 import org.apache.protocol.common.chain.Command;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class DnsProtocolHandler implements ProtocolHandler
+public class DnsProtocolHandler implements IoHandler
 {
     private static final Logger log = LoggerFactory.getLogger( DnsProtocolHandler.class );
 
@@ -46,15 +47,19 @@
         dnsService = new DomainNameServiceChain();
     }
 
-    public void sessionCreated( ProtocolSession session )
+    public void sessionCreated( IoSession session ) throws Exception
     {
         if ( log.isDebugEnabled() )
         {
             log.debug( session.getRemoteAddress() + " CREATED" );
         }
+        
+        session.getFilterChain().addFirst(
+                "codec",
+                new ProtocolCodecFilter( DnsProtocolCodecFactory.getInstance() ) );
     }
 
-    public void sessionOpened( ProtocolSession session )
+    public void sessionOpened( IoSession session )
     {
         if ( log.isDebugEnabled() )
         {
@@ -62,7 +67,7 @@
         }
     }
 
-    public void sessionClosed( ProtocolSession session )
+    public void sessionClosed( IoSession session )
     {
         if ( log.isDebugEnabled() )
         {
@@ -70,7 +75,7 @@
         }
     }
 
-    public void sessionIdle( ProtocolSession session, IdleStatus status )
+    public void sessionIdle( IoSession session, IdleStatus status )
     {
         if ( log.isDebugEnabled() )
         {
@@ -78,13 +83,13 @@
         }
     }
 
-    public void exceptionCaught( ProtocolSession session, Throwable cause )
+    public void exceptionCaught( IoSession session, Throwable cause )
     {
         log.error( session.getRemoteAddress() + " EXCEPTION", cause );
         session.close();
     }
 
-    public void messageReceived( ProtocolSession session, Object message )
+    public void messageReceived( IoSession session, Object message )
     {
         if ( log.isDebugEnabled() )
         {
@@ -110,7 +115,7 @@
         }
     }
 
-    public void messageSent( ProtocolSession session, Object message )
+    public void messageSent( IoSession session, Object message )
     {
         if ( log.isDebugEnabled() )
         {

Modified: directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/service/DnsContext.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/service/DnsContext.java?rev=330764&r1=330763&r2=330764&view=diff
==============================================================================
--- directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/service/DnsContext.java
(original)
+++ directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/service/DnsContext.java
Fri Nov  4 01:00:09 2005
@@ -27,6 +27,8 @@
 
 public class DnsContext extends ContextBase
 {
+    private static final long serialVersionUID = -5911142975867852436L;
+
     private DnsConfiguration config;
     private RecordStore store;
     private DnsMessage request;

Modified: directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/store/operations/GetFlatRecord.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/store/operations/GetFlatRecord.java?rev=330764&r1=330763&r2=330764&view=diff
==============================================================================
--- directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/store/operations/GetFlatRecord.java
(original)
+++ directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/store/operations/GetFlatRecord.java
Fri Nov  4 01:00:09 2005
@@ -42,6 +42,8 @@
  */
 public class GetFlatRecord implements ContextOperation
 {
+    private static final long serialVersionUID = 4931303293468915435L;
+
     /** The name of the question to get. */
     private final QuestionRecord question;
 

Modified: directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/store/operations/GetRecords.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/store/operations/GetRecords.java?rev=330764&r1=330763&r2=330764&view=diff
==============================================================================
--- directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/store/operations/GetRecords.java
(original)
+++ directory/protocol-providers/dns/trunk/src/main/java/org/apache/dns/store/operations/GetRecords.java
Fri Nov  4 01:00:09 2005
@@ -50,6 +50,8 @@
  */
 public class GetRecords implements ContextOperation
 {
+    private static final long serialVersionUID = 1077580995617778894L;
+
     /** The name of the question to get. */
     private final QuestionRecord question;
 



Mime
View raw message