You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by er...@apache.org on 2005/09/04 19:15:01 UTC
svn commit: r278614 - in
/directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp: io/
messages/ protocol/
Author: erodriguez
Date: Sun Sep 4 10:14:53 2005
New Revision: 278614
URL: http://svn.apache.org/viewcvs?rev=278614&view=rev
Log:
Formatting: imports, whitespace, line breaks, or other code convention.
Modified:
directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/io/NtpMessageDecoder.java
directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/io/NtpMessageEncoder.java
directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/messages/LeapIndicatorType.java
directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/messages/ModeType.java
directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/messages/NtpMessage.java
directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/messages/NtpMessageModifier.java
directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/messages/NtpTimeStamp.java
directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/messages/ReferenceIdentifier.java
directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/messages/StratumType.java
directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/protocol/NtpDecoder.java
directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/protocol/NtpEncoder.java
directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/protocol/NtpProtocolHandler.java
directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/protocol/NtpProtocolProvider.java
Modified: directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/io/NtpMessageDecoder.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/io/NtpMessageDecoder.java?rev=278614&r1=278613&r2=278614&view=diff
==============================================================================
--- directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/io/NtpMessageDecoder.java (original)
+++ directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/io/NtpMessageDecoder.java Sun Sep 4 10:14:53 2005
@@ -27,80 +27,71 @@
import org.apache.ntp.messages.ReferenceIdentifier;
import org.apache.ntp.messages.StratumType;
-
public class NtpMessageDecoder
{
- public NtpMessage decode( ByteBuffer request )
- {
- NtpMessageModifier modifier = new NtpMessageModifier();
-
- byte header = request.get();
- modifier.setLeapIndicator( parseLeapIndicator( header ) );
- modifier.setVersionNumber( parseVersionNumber( header ) );
- modifier.setMode( parseMode( header ) );
-
- modifier.setStratum( parseStratum( request ) );
-
- modifier.setPollInterval( parsePollInterval( request ) );
-
- modifier.setPrecision( parsePrecision( request ) );
-
- modifier.setRootDelay( parseRootDelay( request ) );
-
- modifier.setRootDispersion( parseRootDispersion( request ) );
-
- modifier.setReferenceIdentifier( parseReferenceIdentifier( request ) );
-
- modifier.setReferenceTimestamp( new NtpTimeStamp( request ) );
- modifier.setOriginateTimestamp( new NtpTimeStamp( request ) );
-
- byte[] unneededBytes = new byte[ 8 ];
- request.get( unneededBytes );
-
- modifier.setReceiveTimestamp( new NtpTimeStamp() );
-
- modifier.setTransmitTimestamp( new NtpTimeStamp( request ) );
-
- return modifier.getNtpMessage();
- }
-
- private LeapIndicatorType parseLeapIndicator( byte header )
- {
- return LeapIndicatorType.getTypeByOrdinal( ( header & 0xc0 ) >>> 6 );
- }
-
- private int parseVersionNumber( byte header )
- {
- return ( header & 0x38 ) >>> 3;
- }
-
- private ModeType parseMode( byte header )
- {
- return ModeType.getTypeByOrdinal( header & 0x07 );
- }
-
- private StratumType parseStratum( ByteBuffer request )
- {
- return StratumType.getTypeByOrdinal( request.get() );
- }
-
- private byte parsePollInterval( ByteBuffer bytes )
- {
- return (byte)Math.round( Math.pow( 2, bytes.get() ) );
- }
-
- private byte parsePrecision( ByteBuffer bytes )
- {
- return (byte)( 1000 * Math.pow( 2, bytes.get() ) );
- }
-
- private ReferenceIdentifier parseReferenceIdentifier( ByteBuffer request )
- {
- byte[] nextFourBytes = new byte[ 4 ];
- request.get( nextFourBytes );
- return ReferenceIdentifier.getTypeByName( new String( nextFourBytes ) );
- }
-
+ public NtpMessage decode( ByteBuffer request )
+ {
+ NtpMessageModifier modifier = new NtpMessageModifier();
+
+ byte header = request.get();
+ modifier.setLeapIndicator( parseLeapIndicator( header ) );
+ modifier.setVersionNumber( parseVersionNumber( header ) );
+ modifier.setMode( parseMode( header ) );
+ modifier.setStratum( parseStratum( request ) );
+ modifier.setPollInterval( parsePollInterval( request ) );
+ modifier.setPrecision( parsePrecision( request ) );
+ modifier.setRootDelay( parseRootDelay( request ) );
+ modifier.setRootDispersion( parseRootDispersion( request ) );
+ modifier.setReferenceIdentifier( parseReferenceIdentifier( request ) );
+ modifier.setReferenceTimestamp( new NtpTimeStamp( request ) );
+ modifier.setOriginateTimestamp( new NtpTimeStamp( request ) );
+
+ byte[] unneededBytes = new byte[ 8 ];
+ request.get( unneededBytes );
+
+ modifier.setReceiveTimestamp( new NtpTimeStamp() );
+ modifier.setTransmitTimestamp( new NtpTimeStamp( request ) );
+
+ return modifier.getNtpMessage();
+ }
+
+ private LeapIndicatorType parseLeapIndicator( byte header )
+ {
+ return LeapIndicatorType.getTypeByOrdinal( ( header & 0xc0 ) >>> 6 );
+ }
+
+ private int parseVersionNumber( byte header )
+ {
+ return ( header & 0x38 ) >>> 3;
+ }
+
+ private ModeType parseMode( byte header )
+ {
+ return ModeType.getTypeByOrdinal( header & 0x07 );
+ }
+
+ private StratumType parseStratum( ByteBuffer request )
+ {
+ return StratumType.getTypeByOrdinal( request.get() );
+ }
+
+ private byte parsePollInterval( ByteBuffer bytes )
+ {
+ return (byte) Math.round( Math.pow( 2, bytes.get() ) );
+ }
+
+ private byte parsePrecision( ByteBuffer bytes )
+ {
+ return (byte) ( 1000 * Math.pow( 2, bytes.get() ) );
+ }
+
+ private ReferenceIdentifier parseReferenceIdentifier( ByteBuffer request )
+ {
+ byte[] nextFourBytes = new byte[ 4 ];
+ request.get( nextFourBytes );
+ return ReferenceIdentifier.getTypeByName( new String( nextFourBytes ) );
+ }
+
private int parseRootDelay( ByteBuffer bytes )
{
int temp = 256 * ( 256 * ( 256 * bytes.get() + bytes.get() ) + bytes.get() ) + bytes.get();
@@ -113,4 +104,3 @@
return 1000 * ( temp / 0x10000 );
}
}
-
Modified: directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/io/NtpMessageEncoder.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/io/NtpMessageEncoder.java?rev=278614&r1=278613&r2=278614&view=diff
==============================================================================
--- directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/io/NtpMessageEncoder.java (original)
+++ directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/io/NtpMessageEncoder.java Sun Sep 4 10:14:53 2005
@@ -24,58 +24,56 @@
import org.apache.ntp.messages.NtpMessage;
import org.apache.ntp.messages.ReferenceIdentifier;
-
public class NtpMessageEncoder
{
- public void encode( ByteBuffer byteBuffer, NtpMessage message )
- {
- byte header = 0x00;
- header = encodeLeapIndicator( message.getLeapIndicator(), header );
- header = encodeVersionNumber( message.getVersionNumber(), header );
- header = encodeMode( message.getMode(), header );
- byteBuffer.put( header );
-
- byteBuffer.put( (byte)( message.getStratum().getOrdinal() & 0xFF ) );
- byteBuffer.put( (byte)( message.getPollInterval() & 0xFF ) );
- byteBuffer.put( (byte)( message.getPrecision() & 0xFF ) );
-
- byteBuffer.putInt( message.getRootDelay() );
- byteBuffer.putInt( message.getRootDispersion() );
-
- encodeReferenceIdentifier( message.getReferenceIdentifier(), byteBuffer );
-
- message.getReferenceTimestamp().writeTo( byteBuffer );
- message.getOriginateTimestamp().writeTo( byteBuffer );
- message.getReceiveTimestamp().writeTo( byteBuffer );
- message.getTransmitTimestamp().writeTo( byteBuffer );
- }
-
- private byte encodeLeapIndicator( LeapIndicatorType leapIndicator, byte header )
- {
- byte twoBits = (byte)(leapIndicator.getOrdinal() & 0x03);
- return (byte)( ( twoBits << 6 ) | header);
- }
-
- private byte encodeVersionNumber( int versionNumber, byte header )
- {
- byte threeBits = (byte)( versionNumber & 0x07 );
- return (byte)( ( threeBits << 3 ) | header );
- }
-
- private byte encodeMode( ModeType mode, byte header )
- {
- byte threeBits = (byte)( mode.getOrdinal() & 0x07 );
- return (byte)( threeBits | header );
- }
-
- private void encodeReferenceIdentifier( ReferenceIdentifier identifier, ByteBuffer byteBuffer )
- {
- char[] characters = identifier.getCode().toCharArray();
-
- for ( int ii = 0; ii < characters.length; ii++ )
- {
- byteBuffer.put( (byte)characters[ ii ] );
- }
- }
-}
+ public void encode( ByteBuffer byteBuffer, NtpMessage message )
+ {
+ byte header = 0x00;
+ header = encodeLeapIndicator( message.getLeapIndicator(), header );
+ header = encodeVersionNumber( message.getVersionNumber(), header );
+ header = encodeMode( message.getMode(), header );
+ byteBuffer.put( header );
+
+ byteBuffer.put( (byte) ( message.getStratum().getOrdinal() & 0xFF ) );
+ byteBuffer.put( (byte) ( message.getPollInterval() & 0xFF ) );
+ byteBuffer.put( (byte) ( message.getPrecision() & 0xFF ) );
+
+ byteBuffer.putInt( message.getRootDelay() );
+ byteBuffer.putInt( message.getRootDispersion() );
+
+ encodeReferenceIdentifier( message.getReferenceIdentifier(), byteBuffer );
+
+ message.getReferenceTimestamp().writeTo( byteBuffer );
+ message.getOriginateTimestamp().writeTo( byteBuffer );
+ message.getReceiveTimestamp().writeTo( byteBuffer );
+ message.getTransmitTimestamp().writeTo( byteBuffer );
+ }
+ private byte encodeLeapIndicator( LeapIndicatorType leapIndicator, byte header )
+ {
+ byte twoBits = (byte) ( leapIndicator.getOrdinal() & 0x03 );
+ return (byte) ( ( twoBits << 6 ) | header );
+ }
+
+ private byte encodeVersionNumber( int versionNumber, byte header )
+ {
+ byte threeBits = (byte) ( versionNumber & 0x07 );
+ return (byte) ( ( threeBits << 3 ) | header );
+ }
+
+ private byte encodeMode( ModeType mode, byte header )
+ {
+ byte threeBits = (byte) ( mode.getOrdinal() & 0x07 );
+ return (byte) ( threeBits | header );
+ }
+
+ private void encodeReferenceIdentifier( ReferenceIdentifier identifier, ByteBuffer byteBuffer )
+ {
+ char[] characters = identifier.getCode().toCharArray();
+
+ for ( int ii = 0; ii < characters.length; ii++ )
+ {
+ byteBuffer.put( (byte) characters[ ii ] );
+ }
+ }
+}
Modified: directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/messages/LeapIndicatorType.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/messages/LeapIndicatorType.java?rev=278614&r1=278613&r2=278614&view=diff
==============================================================================
--- directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/messages/LeapIndicatorType.java (original)
+++ directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/messages/LeapIndicatorType.java Sun Sep 4 10:14:53 2005
@@ -44,48 +44,51 @@
public static final LeapIndicatorType NEGATIVE_LEAP_SECOND = new LeapIndicatorType(2, "Last minute has 59 seconds.");
public static final LeapIndicatorType ALARM_CONDITION = new LeapIndicatorType(3, "Alarm condition (clock not synchronized).");
- public String toString()
+ /**
+ * These two lines are all that's necessary to export a List of VALUES.
+ */
+ private static final LeapIndicatorType[] values = { NO_WARNING, POSITIVE_LEAP_SECOND, NEGATIVE_LEAP_SECOND,
+ ALARM_CONDITION };
+ // VALUES needs to be located here, otherwise illegal forward reference
+ public static final List VALUES = Collections.unmodifiableList( Arrays.asList( values ) );
+
+ private final String name;
+ private final int ordinal;
+
+ /**
+ * Private constructor prevents construction outside of this class.
+ */
+ private LeapIndicatorType( int ordinal, String name )
{
- return name;
- }
+ this.ordinal = ordinal;
+ this.name = name;
+ }
- public int compareTo( Object that )
+ public static LeapIndicatorType getTypeByOrdinal( int type )
{
- return ordinal - ( (LeapIndicatorType) that ).ordinal;
- }
+ for ( int ii = 0; ii < values.length; ii++ )
+ {
+ if ( values[ ii ].ordinal == type )
+ {
+ return values[ ii ];
+ }
+ }
- public static LeapIndicatorType getTypeByOrdinal( int type )
- {
- for ( int ii = 0; ii < values.length; ii++ )
- if ( values[ ii ].ordinal == type )
- return values[ ii ];
- return NO_WARNING;
- }
-
- public int getOrdinal()
+ return NO_WARNING;
+ }
+
+ public int getOrdinal()
{
- return ordinal;
- }
+ return ordinal;
+ }
- /// PRIVATE /////
- private final String name;
- private final int ordinal;
-
- /**
- * Private constructor prevents construction outside of this class.
- */
- private LeapIndicatorType( int ordinal, String name )
+ public int compareTo( Object that )
{
- this.ordinal = ordinal;
- this.name = name;
- }
+ return ordinal - ( (LeapIndicatorType) that ).ordinal;
+ }
- /**
- * These two lines are all that's necessary to export a List of VALUES.
- */
- private static final LeapIndicatorType[] values = { NO_WARNING, POSITIVE_LEAP_SECOND,
- NEGATIVE_LEAP_SECOND, ALARM_CONDITION };
- // VALUES needs to be located here, otherwise illegal forward reference
- public static final List VALUES = Collections.unmodifiableList( Arrays.asList( values ) );
+ public String toString()
+ {
+ return name;
+ }
}
-
Modified: directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/messages/ModeType.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/messages/ModeType.java?rev=278614&r1=278613&r2=278614&view=diff
==============================================================================
--- directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/messages/ModeType.java (original)
+++ directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/messages/ModeType.java Sun Sep 4 10:14:53 2005
@@ -50,49 +50,51 @@
public static final ModeType BROADCAST = new ModeType(5, "Broadcast mode.");
public static final ModeType RESERVED_FOR_NTP_CONTROL = new ModeType(6, "Reserved for NTP control message.");
public static final ModeType RESERVED_FOR_PRIVATE_USE = new ModeType(7, "Reserved for private use.");
-
- public String toString()
- {
- return name;
- }
- public int compareTo( Object that )
+ /**
+ * These two lines are all that's necessary to export a List of VALUES.
+ */
+ private static final ModeType[] values = { RESERVED, SYMMETRIC_ACTIVE, RESERVED_PASSIVE, CLIENT, SERVER, BROADCAST,
+ RESERVED_FOR_NTP_CONTROL, RESERVED_FOR_PRIVATE_USE };
+ // VALUES needs to be located here, otherwise illegal forward reference
+ public static final List VALUES = Collections.unmodifiableList( Arrays.asList( values ) );
+
+ private final String name;
+ private final int ordinal;
+
+ /**
+ * Private constructor prevents construction outside of this class.
+ */
+ private ModeType( int ordinal, String name )
{
- return ordinal - ( (ModeType) that ).ordinal;
- }
+ this.ordinal = ordinal;
+ this.name = name;
+ }
- public static ModeType getTypeByOrdinal( int type )
+ public static ModeType getTypeByOrdinal( int type )
{
- for ( int ii = 0; ii < values.length; ii++ )
- if ( values[ ii ].ordinal == type )
- return values[ ii ];
- return SERVER;
- }
-
- public int getOrdinal()
+ for ( int ii = 0; ii < values.length; ii++ )
+ {
+ if ( values[ ii ].ordinal == type )
+ {
+ return values[ ii ];
+ }
+ }
+ return SERVER;
+ }
+
+ public int getOrdinal()
{
- return ordinal;
- }
+ return ordinal;
+ }
- /// PRIVATE /////
- private final String name;
- private final int ordinal;
-
- /**
- * Private constructor prevents construction outside of this class.
- */
- private ModeType( int ordinal, String name )
+ public int compareTo( Object that )
{
- this.ordinal = ordinal;
- this.name = name;
- }
+ return ordinal - ( (ModeType) that ).ordinal;
+ }
- /**
- * These two lines are all that's necessary to export a List of VALUES.
- */
- private static final ModeType[] values = { RESERVED, SYMMETRIC_ACTIVE, RESERVED_PASSIVE,
- CLIENT, SERVER, BROADCAST, RESERVED_FOR_NTP_CONTROL, RESERVED_FOR_PRIVATE_USE };
- // VALUES needs to be located here, otherwise illegal forward reference
- public static final List VALUES = Collections.unmodifiableList( Arrays.asList( values ) );
+ public String toString()
+ {
+ return name;
+ }
}
-
Modified: directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/messages/NtpMessage.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/messages/NtpMessage.java?rev=278614&r1=278613&r2=278614&view=diff
==============================================================================
--- directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/messages/NtpMessage.java (original)
+++ directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/messages/NtpMessage.java Sun Sep 4 10:14:53 2005
@@ -17,151 +17,145 @@
package org.apache.ntp.messages;
-
public class NtpMessage
{
- private LeapIndicatorType leapIndicator;
- private int versionNumber;
- private ModeType mode;
- private StratumType stratumType;
- private byte pollInterval;
- private byte precision;
- private int rootDelay;
- private int rootDispersion;
-
- private ReferenceIdentifier referenceIdentifier;
-
- private NtpTimeStamp referenceTimestamp;
- private NtpTimeStamp originateTimestamp;
- private NtpTimeStamp receiveTimestamp;
- private NtpTimeStamp transmitTimestamp;
-
-
- public NtpMessage( LeapIndicatorType leapIndicator, int versionNumber,
- ModeType mode, StratumType stratumType, byte pollInterval,
- byte precision, int rootDelay, int rootDispersion,
- ReferenceIdentifier referenceIdentifier, NtpTimeStamp referenceTimestamp,
- NtpTimeStamp originateTimestamp, NtpTimeStamp receiveTimestamp,
- NtpTimeStamp transmitTimestamp )
- {
- this.leapIndicator = leapIndicator;
- this.versionNumber = versionNumber;
- this.mode = mode;
- this.stratumType = stratumType;
- this.pollInterval = pollInterval;
- this.precision = precision;
- this.rootDelay = rootDelay;
- this.rootDispersion = rootDispersion;
- this.referenceIdentifier = referenceIdentifier;
- this.referenceTimestamp = referenceTimestamp;
- this.originateTimestamp = originateTimestamp;
- this.receiveTimestamp = receiveTimestamp;
- this.transmitTimestamp = transmitTimestamp;
- }
-
-
- /**
- * @return Returns the Leap Indicator.
- */
- public LeapIndicatorType getLeapIndicator()
- {
- return leapIndicator;
- }
-
- /**
- * @return Returns the Mode.
- */
- public ModeType getMode()
- {
- return mode;
- }
-
- /**
- * @return Returns the Originate Timestamp.
- */
- public NtpTimeStamp getOriginateTimestamp()
- {
- return originateTimestamp;
- }
-
- /**
- * @return Returns the Poll Interval.
- */
- public byte getPollInterval()
- {
- return pollInterval;
- }
-
- /**
- * @return Returns the Precision.
- */
- public byte getPrecision()
- {
- return precision;
- }
-
- /**
- * @return Returns the Receive Timestamp.
- */
- public NtpTimeStamp getReceiveTimestamp()
- {
- return receiveTimestamp;
- }
-
- /**
- * @return Returns the Reference Identifier.
- */
- public ReferenceIdentifier getReferenceIdentifier()
- {
- return referenceIdentifier;
- }
-
- /**
- * @return Returns the Reference Timestamp.
- */
- public NtpTimeStamp getReferenceTimestamp()
- {
- return referenceTimestamp;
- }
-
- /**
- * @return Returns the Root Delay.
- */
- public int getRootDelay()
- {
- return rootDelay;
- }
-
- /**
- * @return Returns the Root Dispersion.
- */
- public int getRootDispersion()
- {
- return rootDispersion;
- }
-
- /**
- * @return Returns the Stratum.
- */
- public StratumType getStratum()
- {
- return stratumType;
- }
-
- /**
- * @return Returns the Transmit Timestamp.
- */
- public NtpTimeStamp getTransmitTimestamp()
- {
- return transmitTimestamp;
- }
-
- /**
- * @return Returns the Version Number.
- */
- public int getVersionNumber()
- {
- return versionNumber;
- }
-}
+ private LeapIndicatorType leapIndicator;
+ private int versionNumber;
+ private ModeType mode;
+ private StratumType stratumType;
+ private byte pollInterval;
+ private byte precision;
+ private int rootDelay;
+ private int rootDispersion;
+
+ private ReferenceIdentifier referenceIdentifier;
+
+ private NtpTimeStamp referenceTimestamp;
+ private NtpTimeStamp originateTimestamp;
+ private NtpTimeStamp receiveTimestamp;
+ private NtpTimeStamp transmitTimestamp;
+
+ public NtpMessage( LeapIndicatorType leapIndicator, int versionNumber, ModeType mode, StratumType stratumType,
+ byte pollInterval, byte precision, int rootDelay, int rootDispersion,
+ ReferenceIdentifier referenceIdentifier, NtpTimeStamp referenceTimestamp, NtpTimeStamp originateTimestamp,
+ NtpTimeStamp receiveTimestamp, NtpTimeStamp transmitTimestamp )
+ {
+ this.leapIndicator = leapIndicator;
+ this.versionNumber = versionNumber;
+ this.mode = mode;
+ this.stratumType = stratumType;
+ this.pollInterval = pollInterval;
+ this.precision = precision;
+ this.rootDelay = rootDelay;
+ this.rootDispersion = rootDispersion;
+ this.referenceIdentifier = referenceIdentifier;
+ this.referenceTimestamp = referenceTimestamp;
+ this.originateTimestamp = originateTimestamp;
+ this.receiveTimestamp = receiveTimestamp;
+ this.transmitTimestamp = transmitTimestamp;
+ }
+
+ /**
+ * @return Returns the Leap Indicator.
+ */
+ public LeapIndicatorType getLeapIndicator()
+ {
+ return leapIndicator;
+ }
+
+ /**
+ * @return Returns the Mode.
+ */
+ public ModeType getMode()
+ {
+ return mode;
+ }
+
+ /**
+ * @return Returns the Originate Timestamp.
+ */
+ public NtpTimeStamp getOriginateTimestamp()
+ {
+ return originateTimestamp;
+ }
+
+ /**
+ * @return Returns the Poll Interval.
+ */
+ public byte getPollInterval()
+ {
+ return pollInterval;
+ }
+ /**
+ * @return Returns the Precision.
+ */
+ public byte getPrecision()
+ {
+ return precision;
+ }
+
+ /**
+ * @return Returns the Receive Timestamp.
+ */
+ public NtpTimeStamp getReceiveTimestamp()
+ {
+ return receiveTimestamp;
+ }
+
+ /**
+ * @return Returns the Reference Identifier.
+ */
+ public ReferenceIdentifier getReferenceIdentifier()
+ {
+ return referenceIdentifier;
+ }
+
+ /**
+ * @return Returns the Reference Timestamp.
+ */
+ public NtpTimeStamp getReferenceTimestamp()
+ {
+ return referenceTimestamp;
+ }
+
+ /**
+ * @return Returns the Root Delay.
+ */
+ public int getRootDelay()
+ {
+ return rootDelay;
+ }
+
+ /**
+ * @return Returns the Root Dispersion.
+ */
+ public int getRootDispersion()
+ {
+ return rootDispersion;
+ }
+
+ /**
+ * @return Returns the Stratum.
+ */
+ public StratumType getStratum()
+ {
+ return stratumType;
+ }
+
+ /**
+ * @return Returns the Transmit Timestamp.
+ */
+ public NtpTimeStamp getTransmitTimestamp()
+ {
+ return transmitTimestamp;
+ }
+
+ /**
+ * @return Returns the Version Number.
+ */
+ public int getVersionNumber()
+ {
+ return versionNumber;
+ }
+}
Modified: directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/messages/NtpMessageModifier.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/messages/NtpMessageModifier.java?rev=278614&r1=278613&r2=278614&view=diff
==============================================================================
--- directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/messages/NtpMessageModifier.java (original)
+++ directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/messages/NtpMessageModifier.java Sun Sep 4 10:14:53 2005
@@ -17,137 +17,132 @@
package org.apache.ntp.messages;
-
public class NtpMessageModifier
{
- private LeapIndicatorType leapIndicator;
- private int versionNumber;
- private ModeType mode;
- private StratumType stratumType;
- private byte pollInterval;
- private byte precision;
- private int rootDelay;
- private int rootDispersion;
-
- private ReferenceIdentifier referenceIdentifier;
-
- private NtpTimeStamp referenceTimestamp;
- private NtpTimeStamp originateTimestamp;
- private NtpTimeStamp receiveTimestamp;
- private NtpTimeStamp transmitTimestamp;
-
-
- public NtpMessage getNtpMessage()
- {
- return new NtpMessage( leapIndicator, versionNumber, mode, stratumType,
- pollInterval, precision, rootDelay, rootDispersion, referenceIdentifier,
- referenceTimestamp, originateTimestamp, receiveTimestamp,
- transmitTimestamp );
- }
-
-
- /**
- * @param leapIndicator The Leap Indicator to set.
- */
- public void setLeapIndicator(LeapIndicatorType leapIndicator)
- {
- this.leapIndicator = leapIndicator;
- }
-
- /**
- * @param mode The Mode to set.
- */
- public void setMode(ModeType mode)
- {
- this.mode = mode;
- }
-
- /**
- * @param originateTimestamp The Originate Timestamp to set.
- */
- public void setOriginateTimestamp(NtpTimeStamp originateTimestamp)
- {
- this.originateTimestamp = originateTimestamp;
- }
-
- /**
- * @param pollInterval The Poll Interval to set.
- */
- public void setPollInterval(byte pollInterval)
- {
- this.pollInterval = pollInterval;
- }
-
- /**
- * @param precision The Precision to set.
- */
- public void setPrecision(byte precision)
- {
- this.precision = precision;
- }
-
- /**
- * @param receiveTimestamp The Receive Timestamp to set.
- */
- public void setReceiveTimestamp(NtpTimeStamp receiveTimestamp)
- {
- this.receiveTimestamp = receiveTimestamp;
- }
-
- /**
- * @param referenceIdentifier The Reference Identifier to set.
- */
- public void setReferenceIdentifier( ReferenceIdentifier referenceIdentifier )
- {
- this.referenceIdentifier = referenceIdentifier;
- }
-
- /**
- * @param referenceTimestamp The Reference Timestamp to set.
- */
- public void setReferenceTimestamp(NtpTimeStamp referenceTimestamp)
- {
- this.referenceTimestamp = referenceTimestamp;
- }
-
- /**
- * @param rootDelay The Root Delay to set.
- */
- public void setRootDelay(int rootDelay)
- {
- this.rootDelay = rootDelay;
- }
-
- /**
- * @param rootDispersion The Root Dispersion to set.
- */
- public void setRootDispersion(int rootDispersion)
- {
- this.rootDispersion = rootDispersion;
- }
-
- /**
- * @param stratumType The Stratum to set.
- */
- public void setStratum(StratumType stratumType)
- {
- this.stratumType = stratumType;
- }
-
- /**
- * @param transmitTimestamp The Transmit Timestamp to set.
- */
- public void setTransmitTimestamp(NtpTimeStamp transmitTimestamp)
- {
- this.transmitTimestamp = transmitTimestamp;
- }
-
- /**
- * @param versionNumber The Version Number to set.
- */
- public void setVersionNumber(int versionNumber)
- {
- this.versionNumber = versionNumber;
- }
-}
+ private LeapIndicatorType leapIndicator;
+ private int versionNumber;
+ private ModeType mode;
+ private StratumType stratumType;
+ private byte pollInterval;
+ private byte precision;
+ private int rootDelay;
+ private int rootDispersion;
+
+ private ReferenceIdentifier referenceIdentifier;
+
+ private NtpTimeStamp referenceTimestamp;
+ private NtpTimeStamp originateTimestamp;
+ private NtpTimeStamp receiveTimestamp;
+ private NtpTimeStamp transmitTimestamp;
+
+ public NtpMessage getNtpMessage()
+ {
+ return new NtpMessage( leapIndicator, versionNumber, mode, stratumType, pollInterval, precision, rootDelay,
+ rootDispersion, referenceIdentifier, referenceTimestamp, originateTimestamp, receiveTimestamp,
+ transmitTimestamp );
+ }
+
+ /**
+ * @param leapIndicator The Leap Indicator to set.
+ */
+ public void setLeapIndicator( LeapIndicatorType leapIndicator )
+ {
+ this.leapIndicator = leapIndicator;
+ }
+
+ /**
+ * @param mode The Mode to set.
+ */
+ public void setMode( ModeType mode )
+ {
+ this.mode = mode;
+ }
+
+ /**
+ * @param originateTimestamp The Originate Timestamp to set.
+ */
+ public void setOriginateTimestamp( NtpTimeStamp originateTimestamp )
+ {
+ this.originateTimestamp = originateTimestamp;
+ }
+
+ /**
+ * @param pollInterval The Poll Interval to set.
+ */
+ public void setPollInterval( byte pollInterval )
+ {
+ this.pollInterval = pollInterval;
+ }
+ /**
+ * @param precision The Precision to set.
+ */
+ public void setPrecision( byte precision )
+ {
+ this.precision = precision;
+ }
+
+ /**
+ * @param receiveTimestamp The Receive Timestamp to set.
+ */
+ public void setReceiveTimestamp( NtpTimeStamp receiveTimestamp )
+ {
+ this.receiveTimestamp = receiveTimestamp;
+ }
+
+ /**
+ * @param referenceIdentifier The Reference Identifier to set.
+ */
+ public void setReferenceIdentifier( ReferenceIdentifier referenceIdentifier )
+ {
+ this.referenceIdentifier = referenceIdentifier;
+ }
+
+ /**
+ * @param referenceTimestamp The Reference Timestamp to set.
+ */
+ public void setReferenceTimestamp( NtpTimeStamp referenceTimestamp )
+ {
+ this.referenceTimestamp = referenceTimestamp;
+ }
+
+ /**
+ * @param rootDelay The Root Delay to set.
+ */
+ public void setRootDelay( int rootDelay )
+ {
+ this.rootDelay = rootDelay;
+ }
+
+ /**
+ * @param rootDispersion The Root Dispersion to set.
+ */
+ public void setRootDispersion( int rootDispersion )
+ {
+ this.rootDispersion = rootDispersion;
+ }
+
+ /**
+ * @param stratumType The Stratum to set.
+ */
+ public void setStratum( StratumType stratumType )
+ {
+ this.stratumType = stratumType;
+ }
+
+ /**
+ * @param transmitTimestamp The Transmit Timestamp to set.
+ */
+ public void setTransmitTimestamp( NtpTimeStamp transmitTimestamp )
+ {
+ this.transmitTimestamp = transmitTimestamp;
+ }
+
+ /**
+ * @param versionNumber The Version Number to set.
+ */
+ public void setVersionNumber( int versionNumber )
+ {
+ this.versionNumber = versionNumber;
+ }
+}
Modified: directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/messages/NtpTimeStamp.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/messages/NtpTimeStamp.java?rev=278614&r1=278613&r2=278614&view=diff
==============================================================================
--- directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/messages/NtpTimeStamp.java (original)
+++ directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/messages/NtpTimeStamp.java Sun Sep 4 10:14:53 2005
@@ -30,97 +30,100 @@
*/
public class NtpTimeStamp
{
- /**
- * The number of milliseconds difference between the Java epoch and
- * the NTP epoch ( January 1, 1900, 00:00:00 GMT ).
- */
- private static final long NTP_EPOCH_DIFFERENCE = -2208988800000L;
-
- private static final TimeZone UTC_TIME_ZONE = TimeZone.getTimeZone( "UTC" );
+ /**
+ * The number of milliseconds difference between the Java epoch and
+ * the NTP epoch ( January 1, 1900, 00:00:00 GMT ).
+ */
+ private static final long NTP_EPOCH_DIFFERENCE = -2208988800000L;
+
+ private static final TimeZone UTC_TIME_ZONE = TimeZone.getTimeZone( "UTC" );
private static final SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss.SSS z" );
-
- static
- {
- dateFormat.setTimeZone( UTC_TIME_ZONE );
- }
-
- private long seconds = 0;
- private long fraction = 0;
-
- public NtpTimeStamp()
- {
- this( new Date() );
- }
-
- public NtpTimeStamp( Date date )
- {
- long msSinceStartOfNtpEpoch = date.getTime() - NTP_EPOCH_DIFFERENCE;
-
- seconds = msSinceStartOfNtpEpoch / 1000;
- fraction = ( ( msSinceStartOfNtpEpoch % 1000 ) * 0x100000000L ) / 1000;
- }
-
+
+ static
+ {
+ dateFormat.setTimeZone( UTC_TIME_ZONE );
+ }
+
+ private long seconds = 0;
+ private long fraction = 0;
+
+ public NtpTimeStamp()
+ {
+ this( new Date() );
+ }
+
+ public NtpTimeStamp( Date date )
+ {
+ long msSinceStartOfNtpEpoch = date.getTime() - NTP_EPOCH_DIFFERENCE;
+
+ seconds = msSinceStartOfNtpEpoch / 1000;
+ fraction = ( ( msSinceStartOfNtpEpoch % 1000 ) * 0x100000000L ) / 1000;
+ }
+
public NtpTimeStamp( ByteBuffer data )
{
for ( int ii = 0; ii < 4; ii++ )
{
seconds = 256 * seconds + makePositive( data.get() );
}
-
+
for ( int ii = 4; ii < 8; ii++ )
{
fraction = 256 * fraction + makePositive( data.get() );
}
}
-
+
public void writeTo( ByteBuffer buffer )
{
- byte[] bytes = new byte[ 8 ];
-
- long temp = seconds;
+ byte[] bytes = new byte[ 8 ];
+
+ long temp = seconds;
for ( int ii = 3; ii >= 0; ii-- )
{
- bytes[ ii ] = (byte)( temp % 256 );
+ bytes[ ii ] = (byte) ( temp % 256 );
temp = temp / 256;
}
-
+
temp = fraction;
for ( int ii = 7; ii >= 4; ii-- )
{
- bytes[ ii ] = (byte)( temp % 256 );
+ bytes[ ii ] = (byte) ( temp % 256 );
temp = temp / 256;
}
-
+
buffer.put( bytes );
}
-
- public String toString()
- {
+
+ public String toString()
+ {
long msSinceStartOfNtpEpoch = seconds * 1000 + ( fraction * 1000 ) / 0x100000000L;
Date date = new Date( msSinceStartOfNtpEpoch + NTP_EPOCH_DIFFERENCE );
-
- synchronized (dateFormat)
+
+ synchronized ( dateFormat )
+ {
+ return "org.apache.ntp.message.NtpTimeStamp[ date = " + dateFormat.format( date ) + " ]";
+ }
+ }
+
+ public boolean equals( Object o )
+ {
+ if ( this == o )
+ {
+ return true;
+ }
+
+ if ( !( o instanceof NtpTimeStamp ) )
{
- return "org.apache.ntp.message.NtpTimeStamp[ date = " + dateFormat.format( date ) + " ]";
+ return false;
}
- }
-
- public boolean equals( Object o )
- {
- if ( this == o )
- return true;
- if ( !( o instanceof NtpTimeStamp ) )
- return false;
-
- NtpTimeStamp that = (NtpTimeStamp) o;
- return ( this.seconds == that.seconds )
- && ( this.fraction == that.fraction );
- }
-
+
+ NtpTimeStamp that = (NtpTimeStamp) o;
+ return ( this.seconds == that.seconds ) && ( this.fraction == that.fraction );
+ }
+
private int makePositive( byte b )
{
int byteAsInt = b;
return ( byteAsInt < 0 ) ? 256 + byteAsInt : byteAsInt;
}
}
-
Modified: directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/messages/ReferenceIdentifier.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/messages/ReferenceIdentifier.java?rev=278614&r1=278613&r2=278614&view=diff
==============================================================================
--- directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/messages/ReferenceIdentifier.java (original)
+++ directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/messages/ReferenceIdentifier.java Sun Sep 4 10:14:53 2005
@@ -59,64 +59,72 @@
public static final ReferenceIdentifier GPS = new ReferenceIdentifier(15, "GPS", "Global Positioning Service");
public static final ReferenceIdentifier GOES = new ReferenceIdentifier(16, "GOES", "Geostationary Orbit Environment Satellite");
public static final ReferenceIdentifier CDMA = new ReferenceIdentifier(17, "CDMA", "CDMA mobile cellular/PCS telephone system");
-
- public String toString()
+
+ /**
+ * These two lines are all that's necessary to export a List of VALUES.
+ */
+ private static final ReferenceIdentifier[] values = { INIT, LOCL, PPS, ACTS, USNO, PTB, TDF, DCF, MSF, WWV, WWVB,
+ WWVH, CHU, LORC, OMEG, GPS, GOES, CDMA };
+ // VALUES needs to be located here, otherwise illegal forward reference
+ public static final List VALUES = Collections.unmodifiableList( Arrays.asList( values ) );
+
+ private final int ordinal;
+ private final String name;
+ private final String code;
+
+ /**
+ * Private constructor prevents construction outside of this class.
+ */
+ private ReferenceIdentifier( int ordinal, String code, String name )
{
- return name;
- }
+ this.ordinal = ordinal;
+ this.code = code;
+ this.name = name;
+ }
- public int compareTo( Object that )
+ public static ReferenceIdentifier getTypeByOrdinal( int type )
{
- return ordinal - ( (ReferenceIdentifier) that ).ordinal;
- }
-
- public static ReferenceIdentifier getTypeByOrdinal( int type )
- {
- for ( int ii = 0; ii < values.length; ii++ )
- if ( values[ ii ].ordinal == type )
- return values[ ii ];
- return LOCL;
- }
-
- public static ReferenceIdentifier getTypeByName( String type )
- {
- for ( int ii = 0; ii < values.length; ii++ )
- if ( values[ ii ].code.equalsIgnoreCase( type ) )
- return values[ ii ];
- return LOCL;
- }
-
- public int getOrdinal()
- {
- return ordinal;
- }
-
- public String getCode()
- {
- return code;
- }
-
- /// PRIVATE /////
- private final String name;
- private final String code;
- private final int ordinal;
-
- /**
- * Private constructor prevents construction outside of this class.
- */
- private ReferenceIdentifier( int ordinal, String code, String name )
+ for ( int ii = 0; ii < values.length; ii++ )
+ {
+ if ( values[ ii ].ordinal == type )
+ {
+ return values[ ii ];
+ }
+ }
+
+ return LOCL;
+ }
+
+ public static ReferenceIdentifier getTypeByName( String type )
{
- this.ordinal = ordinal;
- this.code = code;
- this.name = name;
- }
-
- /**
- * These two lines are all that's necessary to export a List of VALUES.
- */
- private static final ReferenceIdentifier[] values = { INIT, LOCL, PPS, ACTS, USNO, PTB, TDF,
- DCF, MSF, WWV, WWVB, WWVH, CHU, LORC, OMEG, GPS, GOES, CDMA };
- // VALUES needs to be located here, otherwise illegal forward reference
- public static final List VALUES = Collections.unmodifiableList( Arrays.asList( values ) );
-}
+ for ( int ii = 0; ii < values.length; ii++ )
+ {
+ if ( values[ ii ].code.equalsIgnoreCase( type ) )
+ {
+ return values[ ii ];
+ }
+ }
+
+ return LOCL;
+ }
+ public int getOrdinal()
+ {
+ return ordinal;
+ }
+
+ public String getCode()
+ {
+ return code;
+ }
+
+ public int compareTo( Object that )
+ {
+ return ordinal - ( (ReferenceIdentifier) that ).ordinal;
+ }
+
+ public String toString()
+ {
+ return name;
+ }
+}
Modified: directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/messages/StratumType.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/messages/StratumType.java?rev=278614&r1=278613&r2=278614&view=diff
==============================================================================
--- directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/messages/StratumType.java (original)
+++ directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/messages/StratumType.java Sun Sep 4 10:14:53 2005
@@ -41,49 +41,51 @@
public static final StratumType UNSPECIFIED = new StratumType(0, "Unspecified or unavailable.");
public static final StratumType PRIMARY_REFERENCE = new StratumType(1, "Primary reference.");
public static final StratumType SECONDARY_REFERENCE = new StratumType(2, "Secondary reference.");
-
- public String toString()
- {
- return name;
- }
- public int compareTo( Object that )
+ /**
+ * These two lines are all that's necessary to export a List of VALUES.
+ */
+ private static final StratumType[] values = { UNSPECIFIED, PRIMARY_REFERENCE, SECONDARY_REFERENCE };
+ // VALUES needs to be located here, otherwise illegal forward reference
+ public static final List VALUES = Collections.unmodifiableList( Arrays.asList( values ) );
+
+ private final int ordinal;
+ private final String name;
+
+ /**
+ * Private constructor prevents construction outside of this class.
+ */
+ private StratumType( int ordinal, String name )
{
- return ordinal - ( (StratumType) that ).ordinal;
- }
+ this.ordinal = ordinal;
+ this.name = name;
+ }
- public static StratumType getTypeByOrdinal( int type )
+ public static StratumType getTypeByOrdinal( int type )
{
- for ( int ii = 0; ii < values.length; ii++ )
- if ( values[ ii ].ordinal == type )
- return values[ ii ];
- return UNSPECIFIED;
- }
-
- public int getOrdinal()
+ for ( int ii = 0; ii < values.length; ii++ )
+ {
+ if ( values[ ii ].ordinal == type )
+ {
+ return values[ ii ];
+ }
+ }
+
+ return UNSPECIFIED;
+ }
+
+ public int getOrdinal()
{
- return ordinal;
- }
+ return ordinal;
+ }
- /// PRIVATE /////
- private final String name;
- private final int ordinal;
-
- /**
- * Private constructor prevents construction outside of this class.
- */
- private StratumType( int ordinal, String name )
+ public int compareTo( Object that )
{
- this.ordinal = ordinal;
- this.name = name;
- }
+ return ordinal - ( (StratumType) that ).ordinal;
+ }
- /**
- * These two lines are all that's necessary to export a List of VALUES.
- */
- private static final StratumType[] values = { UNSPECIFIED, PRIMARY_REFERENCE,
- SECONDARY_REFERENCE };
- // VALUES needs to be located here, otherwise illegal forward reference
- public static final List VALUES = Collections.unmodifiableList( Arrays.asList( values ) );
+ public String toString()
+ {
+ return name;
+ }
}
-
Modified: directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/protocol/NtpDecoder.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/protocol/NtpDecoder.java?rev=278614&r1=278613&r2=278614&view=diff
==============================================================================
--- directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/protocol/NtpDecoder.java (original)
+++ directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/protocol/NtpDecoder.java Sun Sep 4 10:14:53 2005
@@ -24,14 +24,12 @@
import org.apache.mina.protocol.ProtocolViolationException;
import org.apache.ntp.io.NtpMessageDecoder;
-
public class NtpDecoder implements ProtocolDecoder
{
public void decode( ProtocolSession session, ByteBuffer in, ProtocolDecoderOutput out )
throws ProtocolViolationException
{
- NtpMessageDecoder decoder = new NtpMessageDecoder();
- out.write( decoder.decode( in.buf() ) );
+ NtpMessageDecoder decoder = new NtpMessageDecoder();
+ out.write( decoder.decode( in.buf() ) );
}
}
-
Modified: directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/protocol/NtpEncoder.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/protocol/NtpEncoder.java?rev=278614&r1=278613&r2=278614&view=diff
==============================================================================
--- directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/protocol/NtpEncoder.java (original)
+++ directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/protocol/NtpEncoder.java Sun Sep 4 10:14:53 2005
@@ -25,20 +25,18 @@
import org.apache.ntp.io.NtpMessageEncoder;
import org.apache.ntp.messages.NtpMessage;
-
public class NtpEncoder implements ProtocolEncoder
{
public void encode( ProtocolSession session, Object message, ProtocolEncoderOutput out )
throws ProtocolViolationException
{
NtpMessageEncoder encoder = new NtpMessageEncoder();
-
+
ByteBuffer buf = ByteBuffer.allocate( 1024 );
- encoder.encode( buf.buf(), (NtpMessage)message );
-
+ encoder.encode( buf.buf(), (NtpMessage) message );
+
buf.flip();
-
+
out.write( buf );
}
}
-
Modified: directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/protocol/NtpProtocolHandler.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/protocol/NtpProtocolHandler.java?rev=278614&r1=278613&r2=278614&view=diff
==============================================================================
--- directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/protocol/NtpProtocolHandler.java (original)
+++ directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/protocol/NtpProtocolHandler.java Sun Sep 4 10:14:53 2005
@@ -24,7 +24,6 @@
import org.apache.ntp.messages.NtpMessage;
import org.apache.ntp.service.NtpServiceImpl;
-
public class NtpProtocolHandler implements ProtocolHandler
{
public void sessionCreated( ProtocolSession session )
@@ -58,10 +57,10 @@
public void messageReceived( ProtocolSession session, Object message )
{
System.out.println( session.getRemoteAddress() + " RCVD: " + message );
-
+
NtpService ntpService = new NtpServiceImpl();
- NtpMessage reply = ntpService.getReplyFor( (NtpMessage)message );
-
+ NtpMessage reply = ntpService.getReplyFor( (NtpMessage) message );
+
session.write( reply );
}
@@ -70,4 +69,3 @@
System.out.println( session.getRemoteAddress() + " SENT: " + message );
}
}
-
Modified: directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/protocol/NtpProtocolProvider.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/protocol/NtpProtocolProvider.java?rev=278614&r1=278613&r2=278614&view=diff
==============================================================================
--- directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/protocol/NtpProtocolProvider.java (original)
+++ directory/protocol-providers/ntp/trunk/src/java/org/apache/ntp/protocol/NtpProtocolProvider.java Sun Sep 4 10:14:53 2005
@@ -23,7 +23,6 @@
import org.apache.mina.protocol.ProtocolHandler;
import org.apache.mina.protocol.ProtocolProvider;
-
public class NtpProtocolProvider implements ProtocolProvider
{
// Protocol handler is usually a singleton.
@@ -55,4 +54,3 @@
return HANDLER;
}
}
-