Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 44999 invoked from network); 25 Oct 2005 00:27:14 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 25 Oct 2005 00:27:14 -0000 Received: (qmail 41645 invoked by uid 500); 25 Oct 2005 00:27:13 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 41589 invoked by uid 500); 25 Oct 2005 00:27:13 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 41578 invoked by uid 99); 25 Oct 2005 00:27:13 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 24 Oct 2005 17:27:13 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Mon, 24 Oct 2005 17:27:10 -0700 Received: (qmail 44905 invoked by uid 65534); 25 Oct 2005 00:26:51 -0000 Message-ID: <20051025002651.44904.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r328196 - in /directory/protocol-providers/ntp/trunk: project.xml src/java/org/apache/ntp/NtpConfiguration.java Date: Tue, 25 Oct 2005 00:26:51 -0000 To: commits@directory.apache.org From: erodriguez@apache.org X-Mailer: svnmailer-1.0.5 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: erodriguez Date: Mon Oct 24 17:26:46 2005 New Revision: 328196 URL: http://svn.apache.org/viewcvs?rev=328196&view=rev Log: Consolidated configuration from NTP OSGi bundle to protocol provider. Added: directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/NtpConfiguration.java (with props) Modified: directory/protocol-providers/ntp/trunk/project.xml Modified: directory/protocol-providers/ntp/trunk/project.xml URL: http://svn.apache.org/viewcvs/directory/protocol-providers/ntp/trunk/project.xml?rev=328196&r1=328195&r2=328196&view=diff ============================================================================== --- directory/protocol-providers/ntp/trunk/project.xml (original) +++ directory/protocol-providers/ntp/trunk/project.xml Mon Oct 24 17:26:46 2005 @@ -94,6 +94,12 @@ http://slf4j.org/nlog4j + + directory + apacheds-main + 0.9.3-SNAPSHOT + + junit junit 3.8.1 Added: directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/NtpConfiguration.java URL: http://svn.apache.org/viewcvs/directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/NtpConfiguration.java?rev=328196&view=auto ============================================================================== --- directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/NtpConfiguration.java (added) +++ directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/NtpConfiguration.java Mon Oct 24 17:26:46 2005 @@ -0,0 +1,122 @@ +/* + * 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.ntp; + +import java.util.Dictionary; +import java.util.HashMap; +import java.util.Map; + +import org.apache.ldap.server.DirectoryService; +import org.apache.ldap.server.configuration.Configuration; +import org.apache.ldap.server.configuration.ConfigurationException; + +public class NtpConfiguration extends Configuration +{ + /** the prop key const for the port */ + public static final String NTP_PORT_KEY = "ntp.port"; + + /** the default port */ + private static final String NTP_DEFAULT_PORT = "123"; + + private static final String SERVICE_PID = "service.pid"; + private static final String PID = "org.apache.ntp"; + private static final String name = "Apache NTP Service"; + + private Map configuration = new HashMap(); + + /** + * Creates a new instance with default settings. + */ + public NtpConfiguration() + { + this( getDefaultConfig() ); + } + + /** + * Creates a new instance with default settings that operates on the + * {@link DirectoryService} with the specified ID. + */ + public NtpConfiguration( String instanceId ) + { + this( getDefaultConfig() ); + setInstanceId( instanceId ); + } + + public NtpConfiguration( Map properties ) + { + if ( properties == null ) + { + configuration = getDefaultConfig(); + } + else + { + configuration.putAll( properties ); + } + + int port = getPort(); + + if ( port < 1 || port > 0xFFFF ) + { + throw new ConfigurationException( "Invalid value: " + NTP_PORT_KEY + "=" + port ); + } + } + + public static Map getDefaultConfig() + { + Map defaults = new HashMap(); + + defaults.put( SERVICE_PID, PID ); + defaults.put( NTP_PORT_KEY, NTP_DEFAULT_PORT ); + + return defaults; + } + + public boolean isDifferent( Dictionary config ) + { + int port = getPort(); + + if ( port == Integer.parseInt( (String) config.get( NTP_PORT_KEY ) ) ) + { + return false; + } + + return true; + } + + public String getName() + { + return name; + } + + public int getPort() + { + String key = NTP_PORT_KEY; + + if ( configuration.containsKey( key ) ) + { + return Integer.parseInt( get( key ) ); + } + + return Integer.parseInt( NTP_DEFAULT_PORT ); + } + + private String get( String key ) + { + return (String) configuration.get( key ); + } +} Propchange: directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/NtpConfiguration.java ------------------------------------------------------------------------------ svn:eol-style = native