directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: r328199 - in /directory/protocol-providers/dns/trunk: project.xml src/java/org/apache/dns/DnsConfiguration.java src/java/org/apache/dns/service/DnsConfiguration.java
Date Tue, 25 Oct 2005 00:31:02 GMT
Author: erodriguez
Date: Mon Oct 24 17:30:57 2005
New Revision: 328199

URL: http://svn.apache.org/viewcvs?rev=328199&view=rev
Log:
Consolidated configuration from DNS OSGi bundle to protocol provider.

Added:
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/DnsConfiguration.java
      - copied, changed from r327948, directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/DnsConfiguration.java
Removed:
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/DnsConfiguration.java
Modified:
    directory/protocol-providers/dns/trunk/project.xml

Modified: directory/protocol-providers/dns/trunk/project.xml
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/project.xml?rev=328199&r1=328198&r2=328199&view=diff
==============================================================================
--- directory/protocol-providers/dns/trunk/project.xml (original)
+++ directory/protocol-providers/dns/trunk/project.xml Mon Oct 24 17:30:57 2005
@@ -83,6 +83,11 @@
       <type>plugin</type>
     </dependency>
     <dependency>
+      <groupId>directory-shared</groupId>
+      <artifactId>protocol-common</artifactId>
+      <version>0.5.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
       <groupId>directory-network</groupId>
       <artifactId>mina</artifactId>
       <version>0.7.3-SNAPSHOT</version>
@@ -92,6 +97,12 @@
       <artifactId>nlog4j</artifactId>
       <version>1.2.17</version>
       <url>http://slf4j.org/nlog4j</url>
+    </dependency>
+    <dependency>
+      <!-- required to load Configuration and LDIFs -->
+      <groupId>directory</groupId>
+      <artifactId>apacheds-main</artifactId>
+      <version>0.9.3-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>junit</groupId>

Copied: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/DnsConfiguration.java
(from r327948, 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/DnsConfiguration.java?p2=directory/protocol-providers/dns/trunk/src/java/org/apache/dns/DnsConfiguration.java&p1=directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/DnsConfiguration.java&r1=327948&r2=328199&rev=328199&view=diff
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/service/DnsConfiguration.java
(original)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/DnsConfiguration.java Mon
Oct 24 17:30:57 2005
@@ -14,62 +14,126 @@
  *   limitations under the License.
  *
  */
-package org.apache.dns.service;
+package org.apache.dns;
 
-import java.util.Hashtable;
-import java.util.Properties;
+import java.util.Dictionary;
+import java.util.HashMap;
+import java.util.Map;
 
-public class DnsConfiguration
+import org.apache.ldap.server.DirectoryService;
+import org.apache.ldap.server.configuration.Configuration;
+import org.apache.ldap.server.configuration.ConfigurationException;
+
+public class DnsConfiguration extends Configuration
 {
-    /** the prop key const for dns.port */
+    /** the prop key const for the 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";
+    public static final String DNS_BUFFER_SIZE_KEY = "dns.buffer.size";
+
+    /** the default port */
+    private static final int DNS_DEFAULT_PORT = 53;
+
+    private static final String SERVICE_PID = "service.pid";
+    private static final String PID = "org.apache.dns";
+    private static final String name = "Apache DNS Service";
 
     /** the default dns buffer size */
     private static final int DNS_DEFAULT_BUFFER_SIZE = 1024;
 
-    private final Properties properties = new Properties();
+    private Map configuration = new HashMap();
 
+    /**
+     * Creates a new instance with default settings.
+     */
     public DnsConfiguration()
     {
+        this( getDefaultConfig() );
     }
 
-    public DnsConfiguration( Properties properties )
+    /**
+     * Creates a new instance with default settings that operates on the
+     * {@link DirectoryService} with the specified ID.
+     */
+    public DnsConfiguration( String instanceId )
     {
-        this.properties.putAll( properties );
+        this( getDefaultConfig() );
+        setInstanceId( instanceId );
     }
 
-    public Hashtable getProperties()
+    public DnsConfiguration( Map properties )
     {
-        return properties;
+        if ( properties == null )
+        {
+            configuration = getDefaultConfig();
+        }
+        else
+        {
+            configuration.putAll( properties );
+        }
+
+        int port = getPort();
+
+        if ( port < 1 || port > 0xFFFF )
+        {
+            throw new ConfigurationException( "Invalid value:  " + DNS_PORT_KEY + "=" + port
);
+        }
     }
 
-    public int getBufferSize()
+    public static Map getDefaultConfig()
     {
-        String key = DNS_BUFFER_SIZE_KEY;
+        Map defaults = new HashMap();
+
+        defaults.put( SERVICE_PID, PID );
+        defaults.put( DNS_PORT_KEY, Integer.getInteger( DNS_PORT_KEY, new Integer( DNS_DEFAULT_PORT
) ) );
+
+        return defaults;
+    }
+
+    public boolean isDifferent( Dictionary config )
+    {
+        int port = getPort();
 
-        if ( properties.containsKey( key ) )
+        if ( port == ( (Integer) config.get( DNS_PORT_KEY ) ).intValue() )
         {
-            return Integer.parseInt( properties.getProperty( key ) );
+            return false;
         }
 
-        return DNS_DEFAULT_BUFFER_SIZE;
+        return true;
+    }
+
+    public String getName()
+    {
+        return name;
     }
 
-    public int getDnsPort()
+    public int getPort()
     {
         String key = DNS_PORT_KEY;
 
-        if ( properties.containsKey( key ) )
+        if ( configuration.containsKey( key ) )
         {
-            return Integer.parseInt( properties.getProperty( key ) );
+            return Integer.parseInt( get( key ) );
         }
 
         return DNS_DEFAULT_PORT;
+    }
+
+    public int getBufferSize()
+    {
+        String key = DNS_BUFFER_SIZE_KEY;
+
+        if ( configuration.containsKey( key ) )
+        {
+            return Integer.parseInt( get( key ) );
+        }
+
+        return DNS_DEFAULT_BUFFER_SIZE;
+    }
+
+    private String get( String key )
+    {
+        return (String) configuration.get( key );
     }
 }



Mime
View raw message