directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: r519812 - in /directory/apacheds/branches/apacheds-sasl-branch/protocol-ntp/src/main/java/org/apache/directory/server/ntp: NtpConfiguration.java NtpServer.java
Date Mon, 19 Mar 2007 03:15:20 GMT
Author: erodriguez
Date: Sun Mar 18 20:15:19 2007
New Revision: 519812

URL: http://svn.apache.org/viewvc?view=rev&rev=519812
Log:
Clean-up of NTP protocol configuration.
o  Enhancements to support Spring.
o  Removal of all code related to map-based configuration.
o  Some parameter names standardized with other protocol providers.

Modified:
    directory/apacheds/branches/apacheds-sasl-branch/protocol-ntp/src/main/java/org/apache/directory/server/ntp/NtpConfiguration.java
    directory/apacheds/branches/apacheds-sasl-branch/protocol-ntp/src/main/java/org/apache/directory/server/ntp/NtpServer.java

Modified: directory/apacheds/branches/apacheds-sasl-branch/protocol-ntp/src/main/java/org/apache/directory/server/ntp/NtpConfiguration.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-sasl-branch/protocol-ntp/src/main/java/org/apache/directory/server/ntp/NtpConfiguration.java?view=diff&rev=519812&r1=519811&r2=519812
==============================================================================
--- directory/apacheds/branches/apacheds-sasl-branch/protocol-ntp/src/main/java/org/apache/directory/server/ntp/NtpConfiguration.java
(original)
+++ directory/apacheds/branches/apacheds-sasl-branch/protocol-ntp/src/main/java/org/apache/directory/server/ntp/NtpConfiguration.java
Sun Mar 18 20:15:19 2007
@@ -17,21 +17,15 @@
  *  under the License. 
  *  
  */
-
 package org.apache.directory.server.ntp;
 
 
-import java.util.Dictionary;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.directory.server.core.DirectoryService;
-import org.apache.directory.server.core.configuration.ConfigurationException;
-import org.apache.directory.server.protocol.shared.LoadStrategy;
 import org.apache.directory.server.protocol.shared.ServiceConfiguration;
 
 
 /**
+ * Contains the configuration parameters for the NTP protocol provider.
+ * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
@@ -39,104 +33,23 @@
 {
     private static final long serialVersionUID = 2961795205765175775L;
 
-    /** the default port */
-    private static final String DEFAULT_IP_PORT = "123";
-
-    /** the default pid */
-    private static final String DEFAULT_PID = "org.apache.ntp";
+    /** The default IP port. */
+    private static final int IP_PORT_DEFAULT = 123;
 
-    /** the default name */
-    private static final String DEFAULT_NAME = "Apache NTP Service";
+    /** The default service pid. */
+    private static final String SERVICE_PID_DEFAULT = "org.apache.ntp";
 
-    /** the default prefix */
-    private static final String DEFAULT_PREFIX = "ntp.";
+    /** The default service name. */
+    private static final String SERVICE_NAME_DEFAULT = "Apache NTP Service";
 
 
     /**
-     * Creates a new instance with default settings.
+     * Creates a new instance of NtpConfiguration.
      */
     public NtpConfiguration()
     {
-        this( getDefaultConfig(), LoadStrategy.LDAP );
-    }
-
-
-    /**
-     * Creates a new instance with default settings that operates on the
-     * {@link DirectoryService} with the specified ID.
-     */
-    public NtpConfiguration(String instanceId)
-    {
-        this( getDefaultConfig(), LoadStrategy.LDAP );
-        setInstanceId( instanceId );
-    }
-
-
-    public NtpConfiguration( Map<String, String> properties )
-    {
-        this( properties, LoadStrategy.LDAP );
-    }
-
-
-    public NtpConfiguration( Map<String, String> properties, int strategy )
-    {
-        if ( properties == null )
-        {
-            configuration = getDefaultConfig();
-        }
-        else
-        {
-            loadProperties( DEFAULT_PREFIX, properties, strategy );
-        }
-
-        int port = getPort();
-
-        if ( port < 1 || port > 0xFFFF )
-        {
-            throw new ConfigurationException( "Invalid value:  " + IP_PORT_KEY + "=" + port
);
-        }
-    }
-
-
-    public static Map<String, String> getDefaultConfig()
-    {
-        Map<String, String> defaults = new HashMap<String, String>();
-
-        defaults.put( SERVICE_PID, DEFAULT_PID );
-        defaults.put( IP_PORT_KEY, DEFAULT_IP_PORT );
-
-        return defaults;
-    }
-
-
-    public boolean isDifferent( Dictionary config )
-    {
-        int port = getPort();
-
-        if ( port == Integer.parseInt( ( String ) config.get( IP_PORT_KEY ) ) )
-        {
-            return false;
-        }
-
-        return true;
-    }
-
-
-    public String getName()
-    {
-        return DEFAULT_NAME;
-    }
-
-
-    public int getPort()
-    {
-        String key = IP_PORT_KEY;
-
-        if ( configuration.containsKey( key ) )
-        {
-            return Integer.parseInt( get( key ) );
-        }
-
-        return Integer.parseInt( DEFAULT_IP_PORT );
+        super.setIpPort( IP_PORT_DEFAULT );
+        super.setServicePid( SERVICE_PID_DEFAULT );
+        super.setServiceName( SERVICE_NAME_DEFAULT );
     }
 }

Modified: directory/apacheds/branches/apacheds-sasl-branch/protocol-ntp/src/main/java/org/apache/directory/server/ntp/NtpServer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-sasl-branch/protocol-ntp/src/main/java/org/apache/directory/server/ntp/NtpServer.java?view=diff&rev=519812&r1=519811&r2=519812
==============================================================================
--- directory/apacheds/branches/apacheds-sasl-branch/protocol-ntp/src/main/java/org/apache/directory/server/ntp/NtpServer.java
(original)
+++ directory/apacheds/branches/apacheds-sasl-branch/protocol-ntp/src/main/java/org/apache/directory/server/ntp/NtpServer.java
Sun Mar 18 20:15:19 2007
@@ -53,8 +53,8 @@
         this.config = config;
         this.acceptor = acceptor;
 
-        String name = config.getName();
-        int port = config.getPort();
+        String name = config.getServiceName();
+        int port = config.getIpPort();
 
         try
         {
@@ -79,11 +79,11 @@
 
     public void destroy()
     {
-        acceptor.unbind( new InetSocketAddress( config.getPort() ) );
+        acceptor.unbind( new InetSocketAddress( config.getIpPort() ) );
 
         acceptor = null;
         handler = null;
 
-        log.debug( config.getName() + " has stopped listening on port " + config.getPort()
);
+        log.debug( config.getServiceName() + " has stopped listening on port " + config.getIpPort()
);
     }
 }



Mime
View raw message