directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: r265744 - in /directory/protocol-providers/dns/trunk: ./ src/java/org/apache/dns/ src/java/org/apache/dns/io/ src/java/org/apache/dns/messages/ src/java/org/apache/dns/protocol/ src/java/org/apache/dns/records/ src/java/org/apache/dns/service/
Date Thu, 01 Sep 2005 15:26:24 GMT
Author: erodriguez
Date: Thu Sep  1 08:26:11 2005
New Revision: 265744

URL: http://svn.apache.org/viewcvs?rev=265744&view=rev
Log:
Updates to dns protocol:
o  bump up version to 0.3-SNAPSHOT to refactor to chain and enable backing store with DIT
o  initial configuration (port and buffer size)
o  refactor to chain
o  enable return of error messages
o  initial use of SLF4J logging, library dependency to POM

Added:
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/BuildReply.java
  (with props)
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/DnsConfiguration.java
  (with props)
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/DnsContext.java
  (with props)
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/DnsExceptionHandler.java
  (with props)
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/DomainNameServiceChain.java
  (with props)
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/GetRecordEntry.java
  (with props)
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/MonitorMessage.java
  (with props)
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/MonitorReply.java
  (with props)
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/MonitorRequest.java
  (with props)
Removed:
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/DomainNameService.java
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/DomainNameServiceImpl.java
Modified:
    directory/protocol-providers/dns/trunk/project.xml
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/DnsException.java
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/ResourceRecordDecoder.java
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/messages/DnsMessageModifier.java
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/messages/ResponseCode.java
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/protocol/DnsProtocolHandler.java
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/protocol/DnsProtocolProvider.java
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/QuestionRecord.java

Modified: directory/protocol-providers/dns/trunk/project.xml
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/project.xml?rev=265744&r1=265743&r2=265744&view=diff
==============================================================================
--- directory/protocol-providers/dns/trunk/project.xml (original)
+++ directory/protocol-providers/dns/trunk/project.xml Thu Sep  1 08:26:11 2005
@@ -5,7 +5,7 @@
   <distributionSite>http://cvs.apache.org/dist/directory/</distributionSite>
   <artifactId>dns-protocol</artifactId>
   <name>ApacheDS DNS Provider</name>
-  <currentVersion>0.1-SNAPSHOT</currentVersion>
+  <currentVersion>0.3-SNAPSHOT</currentVersion>
   <inceptionYear>2005</inceptionYear>
   <package>org.apache.dns</package>
   <issueTrackingUrl>http://nagoya.apache.org/jira/browse/DIR</issueTrackingUrl>
@@ -80,6 +80,12 @@
       <groupId>directory-network</groupId>
       <artifactId>mina</artifactId>
       <version>0.7.3-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>nlog4j</artifactId>
+      <version>1.2.14</version>
+      <url>http://slf4j.org/nlog4j</url>
     </dependency>
     <dependency>
       <groupId>junit</groupId>

Modified: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/DnsException.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/DnsException.java?rev=265744&r1=265743&r2=265744&view=diff
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/DnsException.java (original)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/DnsException.java Thu Sep
 1 08:26:11 2005
@@ -17,25 +17,40 @@
 
 package org.apache.dns;
 
+import org.apache.dns.messages.ResponseCode;
+
+/**
+ * The root of the DNS exception hierarchy.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
 public class DnsException extends Exception
 {
     /**
-     * This empty constructor is used if no 
-     * explanation of the DNS exception is required.
+     * The DNS response code associated with this exception
      */
-    public DnsException()
+    private final int responseCode;
+
+    /**
+     * Creates a DnsException with a response code.
+     *
+     * @param responseCode the response code associated with this DnsException
+     */
+    public DnsException( ResponseCode responseCode )
     {
-        super();
+        super( responseCode.getMessage() );
+
+        this.responseCode = responseCode.getOrdinal();
     }
 
     /**
-     * This constructor is used if a description of the event
-     * that caused the exception is required.
-     * 
-     * @param description this is a description of the exception
+     * Gets the protocol response code associated with this DnsException.
+     *
+     * @return the response code associated with this DnsException
      */
-    public DnsException( String description )
+    public int getResponseCode()
     {
-        super( description );
+        return this.responseCode;
     }
 }

Modified: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/ResourceRecordDecoder.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/ResourceRecordDecoder.java?rev=265744&r1=265743&r2=265744&view=diff
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/ResourceRecordDecoder.java
(original)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/io/ResourceRecordDecoder.java
Thu Sep  1 08:26:11 2005
@@ -18,6 +18,7 @@
 package org.apache.dns.io;
 
 import org.apache.dns.DnsException;
+import org.apache.dns.messages.ResponseCode;
 import org.apache.dns.records.RecordClass;
 import org.apache.dns.records.RecordType;
 import org.apache.dns.records.ResourceRecord;
@@ -31,15 +32,21 @@
 import org.apache.dns.records.standard.PointerRecord;
 import org.apache.dns.records.standard.StartOfAuthorityRecord;
 import org.apache.dns.records.standard.TextRecord;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class ResourceRecordDecoder
 {
+    /** the log for this class */
+    private static final Logger log = LoggerFactory.getLogger( ResourceRecordDecoder.class
);
+
     public static ResourceRecord getInstance( String domainName, RecordType recordType, RecordClass
recordClass,
             int timeToLive, byte[] resourceData ) throws DnsException
     {
         if ( recordClass != RecordClass.IN )
         {
-            throw new DnsException( "Unsupported record class:  " + recordClass );
+            log.info( "Unsupported record class:  " + recordClass );
+            throw new DnsException( ResponseCode.NOT_IMPLEMENTED );
         }
 
         int tag = recordType.getOrdinal();
@@ -67,7 +74,8 @@
             case 16:
                 return new TextRecord( domainName, timeToLive, resourceData );
             default:
-                throw new DnsException( "Unsupported or bad option code:  " + tag );
+                log.info( "Unsupported option code:  " + tag );
+                throw new DnsException( ResponseCode.NOT_IMPLEMENTED );
         }
     }
 }

Modified: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/messages/DnsMessageModifier.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/messages/DnsMessageModifier.java?rev=265744&r1=265743&r2=265744&view=diff
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/messages/DnsMessageModifier.java
(original)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/messages/DnsMessageModifier.java
Thu Sep  1 08:26:11 2005
@@ -78,7 +78,7 @@
     }
 
     /**
-     * @param additional The additional to set.
+     * @param additionalRecords The additional to set.
      */
     public void setAdditionalRecords( ResourceRecord[] additionalRecords )
     {
@@ -86,7 +86,7 @@
     }
 
     /**
-     * @param answer The answer to set.
+     * @param answerRecords The answer to set.
      */
     public void setAnswerRecords( ResourceRecord[] answerRecords )
     {
@@ -102,7 +102,7 @@
     }
 
     /**
-     * @param authority The authority to set.
+     * @param authorityRecords The authority to set.
      */
     public void setAuthorityRecords( ResourceRecord[] authorityRecords )
     {
@@ -126,7 +126,7 @@
     }
 
     /**
-     * @param question The question to set.
+     * @param questionRecords The question to set.
      */
     public void setQuestionRecords( QuestionRecord[] questionRecords )
     {

Modified: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/messages/ResponseCode.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/messages/ResponseCode.java?rev=265744&r1=265743&r2=265744&view=diff
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/messages/ResponseCode.java
(original)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/messages/ResponseCode.java
Thu Sep  1 08:26:11 2005
@@ -59,6 +59,11 @@
         this.name = name;
     }
 
+    public String getMessage()
+    {
+        return name;
+    }
+
     public String toString()
     {
         return name;

Modified: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/protocol/DnsProtocolHandler.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/protocol/DnsProtocolHandler.java?rev=265744&r1=265743&r2=265744&view=diff
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/protocol/DnsProtocolHandler.java
(original)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/protocol/DnsProtocolHandler.java
Thu Sep  1 08:26:11 2005
@@ -17,55 +17,104 @@
 
 package org.apache.dns.protocol;
 
-import org.apache.dns.DomainNameService;
+import org.apache.dns.chain.Command;
 import org.apache.dns.messages.DnsMessage;
-import org.apache.dns.service.DomainNameServiceImpl;
+import org.apache.dns.service.DnsConfiguration;
+import org.apache.dns.service.DnsContext;
+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.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class DnsProtocolHandler implements ProtocolHandler
 {
+    private static final Logger log = LoggerFactory.getLogger( DnsProtocolHandler.class );
+
+    private DnsConfiguration config;
+    private RecordStore store;
+
+    private Command dnsService;
+
+    public DnsProtocolHandler( DnsConfiguration config, RecordStore store )
+    {
+        this.config = config;
+        this.store = store;
+
+        dnsService = new DomainNameServiceChain();
+    }
+
     public void sessionCreated( ProtocolSession session )
     {
-        System.out.println( session.getRemoteAddress() + " CREATED" );
+        if ( log.isDebugEnabled() )
+        {
+            log.debug( session.getRemoteAddress() + " CREATED" );
+        }
     }
 
     public void sessionOpened( ProtocolSession session )
     {
-        System.out.println( session.getRemoteAddress() + " OPENED" );
+        if ( log.isDebugEnabled() )
+        {
+            log.debug( session.getRemoteAddress() + " OPENED" );
+        }
     }
 
     public void sessionClosed( ProtocolSession session )
     {
-        System.out.println( session.getRemoteAddress() + " CLOSED" );
+        if ( log.isDebugEnabled() )
+        {
+            log.debug( session.getRemoteAddress() + " CLOSED" );
+        }
     }
 
     public void sessionIdle( ProtocolSession session, IdleStatus status )
     {
-        System.out.println( session.getRemoteAddress() + " IDLE(" + status + ")" );
+        if ( log.isDebugEnabled() )
+        {
+            log.debug( session.getRemoteAddress() + " IDLE(" + status + ")" );
+        }
     }
 
     public void exceptionCaught( ProtocolSession session, Throwable cause )
     {
-        System.out.println( session.getRemoteAddress() + " EXCEPTION" );
-        cause.printStackTrace( System.out );
-
+        log.error( session.getRemoteAddress() + " EXCEPTION", cause );
         session.close();
     }
 
     public void messageReceived( ProtocolSession session, Object message )
     {
-        System.out.println( session.getRemoteAddress() + " RCVD: " + message );
-
-        DomainNameService dnsService = new DomainNameServiceImpl();
-        DnsMessage reply = dnsService.getReplyFor( (DnsMessage) message );
-
-        session.write( reply );
+        if ( log.isDebugEnabled() )
+        {
+            log.debug( session.getRemoteAddress() + " RCVD: " + message );
+        }
+
+        DnsMessage request = (DnsMessage) message;
+
+        try
+        {
+            DnsContext dnsContext = new DnsContext();
+            dnsContext.setConfig( config );
+            dnsContext.setStore( store );
+            dnsContext.setRequest( request );
+
+            dnsService.execute( dnsContext );
+
+            session.write( dnsContext.getReply() );
+        }
+        catch ( Exception e )
+        {
+            log.error( e.getMessage() );
+        }
     }
 
     public void messageSent( ProtocolSession session, Object message )
     {
-        System.out.println( session.getRemoteAddress() + " SENT: " + message );
+        if ( log.isDebugEnabled() )
+        {
+            log.debug( session.getRemoteAddress() + " SENT: " + message );
+        }
     }
 }

Modified: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/protocol/DnsProtocolProvider.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/protocol/DnsProtocolProvider.java?rev=265744&r1=265743&r2=265744&view=diff
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/protocol/DnsProtocolProvider.java
(original)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/protocol/DnsProtocolProvider.java
Thu Sep  1 08:26:11 2005
@@ -17,6 +17,8 @@
 
 package org.apache.dns.protocol;
 
+import org.apache.dns.service.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;
@@ -26,7 +28,7 @@
 public class DnsProtocolProvider implements ProtocolProvider
 {
     // Protocol handler is usually a singleton.
-    private static ProtocolHandler HANDLER = new DnsProtocolHandler();
+    private static ProtocolHandler HANDLER;
 
     // Codec factory is also usually a singleton.
     private static ProtocolCodecFactory CODEC_FACTORY = new ProtocolCodecFactory()
@@ -43,6 +45,11 @@
             return new DnsDecoder();
         }
     };
+
+    public DnsProtocolProvider( DnsConfiguration config, RecordStore store )
+    {
+        HANDLER = new DnsProtocolHandler( config, store );
+    }
 
     public ProtocolCodecFactory getCodecFactory()
     {

Modified: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/QuestionRecord.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/QuestionRecord.java?rev=265744&r1=265743&r2=265744&view=diff
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/QuestionRecord.java
(original)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/records/QuestionRecord.java
Thu Sep  1 08:26:11 2005
@@ -41,6 +41,33 @@
         super( domainName, recordType, recordClass );
     }
 
+    /**
+     * The domain name of this query.
+     * For example, www.example.com.
+     */
+    public String getDomainName()
+    {
+        return domainName;
+    }
+
+    /**
+     * The type of the query.
+     * For example, the type is A for address records.
+     */
+    public RecordType getRecordType()
+    {
+        return recordType;
+    }
+
+    /**
+     * The class for this query.
+     * For example, the class is IN for the Internet.
+     */
+    public RecordClass getRecordClass()
+    {
+        return recordClass;
+    }
+
     public String toString()
     {
         return getClass().getName() + " [ " + domainName + " ( " + recordClass + " " + recordType
+ " ) ]";

Added: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/BuildReply.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/BuildReply.java?rev=265744&view=auto
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/BuildReply.java
(added)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/BuildReply.java
Thu Sep  1 08:26:11 2005
@@ -0,0 +1,33 @@
+/*
+ *   Copyright 2005 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.dns.service;
+
+import org.apache.dns.chain.Context;
+import org.apache.dns.chain.impl.CommandBase;
+
+public class BuildReply extends CommandBase
+{
+    public boolean execute( Context context ) throws Exception
+    {
+        DnsContext dnsContext = (DnsContext) context;
+
+        // TODO - enable store; currently echoing request
+        dnsContext.setReply( dnsContext.getRequest() );
+
+        return CONTINUE_CHAIN;
+    }
+}

Propchange: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/BuildReply.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/DnsConfiguration.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/DnsConfiguration.java?rev=265744&view=auto
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/DnsConfiguration.java
(added)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/DnsConfiguration.java
Thu Sep  1 08:26:11 2005
@@ -0,0 +1,75 @@
+/*
+ *   Copyright 2005 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.dns.service;
+
+import java.util.Hashtable;
+import java.util.Properties;
+
+public class DnsConfiguration
+{
+    /** the prop key const for dns.port */
+    public static final String DNS_PORT_KEY = "dns.port";
+
+    /** the default dns port */
+    public static final int DNS_DEFAULT_PORT = 53;
+
+    /** the prop key const for dns.buffer.size */
+    private static final String DNS_BUFFER_SIZE_KEY = "dns.buffer.size";
+
+    /** the default dns buffer size */
+    private static final int DNS_DEFAULT_BUFFER_SIZE = 1024;
+
+    private final Properties properties = new Properties();
+
+    public DnsConfiguration()
+    {
+    }
+
+    public DnsConfiguration( Properties properties )
+    {
+        this.properties.putAll( properties );
+    }
+
+    public Hashtable getProperties()
+    {
+        return properties;
+    }
+
+    public int getBufferSize()
+    {
+        String key = DNS_BUFFER_SIZE_KEY;
+
+        if ( properties.containsKey( key ) )
+        {
+            return Integer.parseInt( properties.getProperty( key ) );
+        }
+
+        return DNS_DEFAULT_BUFFER_SIZE;
+    }
+
+    public int getDnsPort()
+    {
+        String key = DNS_PORT_KEY;
+
+        if ( properties.containsKey( key ) )
+        {
+            return Integer.parseInt( properties.getProperty( key ) );
+        }
+
+        return DNS_DEFAULT_PORT;
+    }
+}

Propchange: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/DnsConfiguration.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/DnsContext.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/DnsContext.java?rev=265744&view=auto
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/DnsContext.java
(added)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/DnsContext.java
Thu Sep  1 08:26:11 2005
@@ -0,0 +1,111 @@
+/*
+ *   Copyright 2005 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.dns.service;
+
+import org.apache.dns.chain.impl.ContextBase;
+import org.apache.dns.messages.DnsMessage;
+import org.apache.dns.store.RecordStore;
+import org.apache.dns.store.RecordStoreEntry;
+
+public class DnsContext extends ContextBase
+{
+    private DnsConfiguration config;
+    private RecordStore store;
+    private DnsMessage request;
+    private DnsMessage reply;
+    private RecordStoreEntry recordEntry;
+
+    /**
+     * @return Returns the recordEntry.
+     */
+    public RecordStoreEntry getRecordEntry()
+    {
+        return recordEntry;
+    }
+
+    /**
+     * @param recordEntry The recordEntry to set.
+     */
+    public void setRecordEntry( RecordStoreEntry recordEntry )
+    {
+        this.recordEntry = recordEntry;
+    }
+
+    /**
+     * @return Returns the config.
+     */
+    public DnsConfiguration getConfig()
+    {
+        return config;
+    }
+
+    /**
+     * @param config The config to set.
+     */
+    public void setConfig( DnsConfiguration config )
+    {
+        this.config = config;
+    }
+
+    /**
+     * @return Returns the reply.
+     */
+    public DnsMessage getReply()
+    {
+        return reply;
+    }
+
+    /**
+     * @param reply The reply to set.
+     */
+    public void setReply( DnsMessage reply )
+    {
+        this.reply = reply;
+    }
+
+    /**
+     * @return Returns the request.
+     */
+    public DnsMessage getRequest()
+    {
+        return request;
+    }
+
+    /**
+     * @param request The request to set.
+     */
+    public void setRequest( DnsMessage request )
+    {
+        this.request = request;
+    }
+
+    /**
+     * @return Returns the store.
+     */
+    public RecordStore getStore()
+    {
+        return store;
+    }
+
+    /**
+     * @param store The store to set.
+     */
+    public void setStore( RecordStore store )
+    {
+        this.store = store;
+    }
+}

Propchange: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/DnsContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/DnsExceptionHandler.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/DnsExceptionHandler.java?rev=265744&view=auto
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/DnsExceptionHandler.java
(added)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/DnsExceptionHandler.java
Thu Sep  1 08:26:11 2005
@@ -0,0 +1,57 @@
+/*
+ *   Copyright 2005 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.dns.service;
+
+import org.apache.dns.DnsException;
+import org.apache.dns.chain.Context;
+import org.apache.dns.chain.Filter;
+import org.apache.dns.chain.impl.CommandBase;
+import org.apache.dns.messages.DnsMessageModifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DnsExceptionHandler extends CommandBase implements Filter
+{
+    /** the log for this class */
+    private static final Logger log = LoggerFactory.getLogger( DnsExceptionHandler.class
);
+
+    public boolean execute( Context context ) throws Exception
+    {
+        return CONTINUE_CHAIN;
+    }
+
+    public boolean postprocess( Context context, Exception exception )
+    {
+        if ( exception == null )
+        {
+            return CONTINUE_CHAIN;
+        }
+
+        DnsContext dnsContext = (DnsContext) context;
+        DnsException de = (DnsException) exception;
+
+        log.debug( "Exception " + de.getMessage() + " occurred." );
+
+        DnsMessageModifier modifier = new DnsMessageModifier();
+
+        // TODO - figure out what to put in the error response
+
+        dnsContext.setReply( modifier.getDnsMessage() );
+
+        return STOP_CHAIN;
+    }
+}

Propchange: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/DnsExceptionHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/DomainNameServiceChain.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/DomainNameServiceChain.java?rev=265744&view=auto
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/DomainNameServiceChain.java
(added)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/DomainNameServiceChain.java
Thu Sep  1 08:26:11 2005
@@ -0,0 +1,38 @@
+/*
+ *   Copyright 2005 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.dns.service;
+
+import org.apache.dns.chain.impl.ChainBase;
+
+/**
+ * Domain Name Service (DNS) Protocol (RFC 1034, 1035)
+ */
+public class DomainNameServiceChain extends ChainBase
+{
+    public DomainNameServiceChain()
+    {
+        super();
+        addCommand( new DnsExceptionHandler() );
+        addCommand( new MonitorRequest() );
+
+        // TODO - enable store
+        // addCommand( new GetRecordEntry() );
+
+        addCommand( new BuildReply() );
+        addCommand( new MonitorReply() );
+    }
+}

Propchange: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/DomainNameServiceChain.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/GetRecordEntry.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/GetRecordEntry.java?rev=265744&view=auto
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/GetRecordEntry.java
(added)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/GetRecordEntry.java
Thu Sep  1 08:26:11 2005
@@ -0,0 +1,65 @@
+/*
+ *   Copyright 2005 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.dns.service;
+
+import org.apache.dns.DnsException;
+import org.apache.dns.chain.Context;
+import org.apache.dns.chain.impl.CommandBase;
+import org.apache.dns.messages.ResponseCode;
+import org.apache.dns.records.QuestionRecord;
+import org.apache.dns.store.RecordStore;
+import org.apache.dns.store.RecordStoreEntry;
+import org.apache.dns.store.operations.GetRecord;
+
+public class GetRecordEntry extends CommandBase
+{
+    public boolean execute( Context context ) throws Exception
+    {
+        System.out.println( "Getting server entry." );
+
+        DnsContext dnsContext = (DnsContext) context;
+        RecordStore store = dnsContext.getStore();
+
+        // TODO - major stub to make this compile
+        QuestionRecord question = dnsContext.getRequest().getQuestionRecords()[ 0 ];
+
+        dnsContext.setRecordEntry( getEntry( store, question ) );
+
+        return CONTINUE_CHAIN;
+    }
+
+    public RecordStoreEntry getEntry( RecordStore store, QuestionRecord question ) throws
Exception
+    {
+        RecordStoreEntry entry = null;
+
+        try
+        {
+            entry = (RecordStoreEntry) store.execute( new GetRecord( question ) );
+        }
+        catch ( Exception e )
+        {
+            throw new DnsException( ResponseCode.SERVER_FAILURE );
+        }
+
+        if ( entry == null )
+        {
+            throw new DnsException( ResponseCode.NAME_ERROR );
+        }
+
+        return entry;
+    }
+}

Propchange: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/GetRecordEntry.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/MonitorMessage.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/MonitorMessage.java?rev=265744&view=auto
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/MonitorMessage.java
(added)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/MonitorMessage.java
Thu Sep  1 08:26:11 2005
@@ -0,0 +1,45 @@
+/*
+ *   Copyright 2005 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.dns.service;
+
+import org.apache.dns.chain.impl.CommandBase;
+import org.apache.dns.messages.DnsMessage;
+import org.apache.dns.messages.MessageType;
+import org.apache.dns.messages.OpCode;
+import org.apache.dns.messages.ResponseCode;
+
+public abstract class MonitorMessage extends CommandBase
+{
+    protected String monitorMessage( DnsContext dnsContext, String direction )
+    {
+        DnsMessage message = dnsContext.getRequest();
+
+        MessageType messageType = message.getMessageType();
+        OpCode opCode = message.getOpCode();
+        ResponseCode responseCode = message.getResponseCode();
+        short transactionId = message.getTransactionId();
+
+        StringBuffer sb = new StringBuffer();
+        sb.append( "Monitoring " + direction + ":" );
+        sb.append( "\n\t" + "messageType    " + messageType );
+        sb.append( "\n\t" + "opCode         " + opCode );
+        sb.append( "\n\t" + "responseCode   " + responseCode );
+        sb.append( "\n\t" + "transactionId  " + transactionId );
+
+        return sb.toString();
+    }
+}

Propchange: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/MonitorMessage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/MonitorReply.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/MonitorReply.java?rev=265744&view=auto
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/MonitorReply.java
(added)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/MonitorReply.java
Thu Sep  1 08:26:11 2005
@@ -0,0 +1,47 @@
+/*
+ *   Copyright 2005 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.dns.service;
+
+import org.apache.dns.chain.Context;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class MonitorReply extends MonitorMessage
+{
+    /** the log for this class */
+    private static final Logger log = LoggerFactory.getLogger( MonitorReply.class );
+
+    public boolean execute( Context context ) throws Exception
+    {
+        if ( log.isDebugEnabled() )
+        {
+            try
+            {
+                DnsContext dnsContext = (DnsContext) context;
+
+                log.debug( monitorMessage( dnsContext, "reply" ) );
+            }
+            catch ( Exception e )
+            {
+                // This is a monitor.  No exceptions should bubble up.
+                log.error( "Error in reply monitor", e );
+            }
+        }
+
+        return CONTINUE_CHAIN;
+    }
+}

Propchange: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/MonitorReply.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/MonitorRequest.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/MonitorRequest.java?rev=265744&view=auto
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/MonitorRequest.java
(added)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/MonitorRequest.java
Thu Sep  1 08:26:11 2005
@@ -0,0 +1,47 @@
+/*
+ *   Copyright 2005 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.dns.service;
+
+import org.apache.dns.chain.Context;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class MonitorRequest extends MonitorMessage
+{
+    /** the log for this class */
+    private static final Logger log = LoggerFactory.getLogger( MonitorRequest.class );
+
+    public boolean execute( Context context ) throws Exception
+    {
+        if ( log.isDebugEnabled() )
+        {
+            try
+            {
+                DnsContext dnsContext = (DnsContext) context;
+
+                log.debug( monitorMessage( dnsContext, "request" ) );
+            }
+            catch ( Exception e )
+            {
+                // This is a monitor.  No exceptions should bubble up.
+                log.error( "Error in request monitor", e );
+            }
+        }
+
+        return CONTINUE_CHAIN;
+    }
+}

Propchange: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/MonitorRequest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message