You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2007/10/15 21:38:46 UTC
svn commit: r584868 - in /directory/apacheds/branches/bigbang:
protocol-ntp/src/main/java/org/apache/directory/server/ntp/ protocol-shared/
protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/
Author: akarasulu
Date: Mon Oct 15 12:38:45 2007
New Revision: 584868
URL: http://svn.apache.org/viewvc?rev=584868&view=rev
Log:
minimal interfaces for protocol services
Added:
directory/apacheds/branches/bigbang/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/AbstractProtocolService.java
directory/apacheds/branches/bigbang/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/ProtocolService.java
directory/apacheds/branches/bigbang/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/TransportProtocol.java
Modified:
directory/apacheds/branches/bigbang/protocol-ntp/src/main/java/org/apache/directory/server/ntp/NtpServer.java
directory/apacheds/branches/bigbang/protocol-shared/pom.xml
Modified: directory/apacheds/branches/bigbang/protocol-ntp/src/main/java/org/apache/directory/server/ntp/NtpServer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ntp/src/main/java/org/apache/directory/server/ntp/NtpServer.java?rev=584868&r1=584867&r2=584868&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ntp/src/main/java/org/apache/directory/server/ntp/NtpServer.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ntp/src/main/java/org/apache/directory/server/ntp/NtpServer.java Mon Oct 15 12:38:45 2007
@@ -25,7 +25,6 @@
import org.apache.directory.server.ntp.protocol.NtpProtocolHandler;
import org.apache.directory.server.protocol.shared.ServiceConfiguration;
-import org.apache.mina.common.ThreadModel;
import org.apache.mina.transport.socket.nio.DatagramAcceptor;
import org.apache.mina.transport.socket.nio.DatagramAcceptorConfig;
import org.apache.mina.transport.socket.nio.SocketAcceptor;
@@ -41,6 +40,7 @@
*/
public class NtpServer extends ServiceConfiguration
{
+ @SuppressWarnings ( { "UnusedDeclaration" } )
private static final long serialVersionUID = 2961795205765175775L;
/**
@@ -75,6 +75,7 @@
super.setServiceName( SERVICE_NAME_DEFAULT );
}
+
/**
* Returns the DatagramAcceptor input for this server
* @return DatagramAcceptor input for this server
@@ -84,6 +85,7 @@
return datagramAcceptor;
}
+
/**
* Set the DatagramAcceptor for this server
* @param datagramAcceptor the DatagramAcceptor input for this server
@@ -93,6 +95,7 @@
this.datagramAcceptor = datagramAcceptor;
}
+
/**
* Returns the SocketAcceptor for this server
* @return SocketAcceptor input for this server
@@ -102,6 +105,7 @@
return socketAcceptor;
}
+
/**
* Set the SocketAcceptor for this server
* @param socketAcceptor the SocketAcceptor input for this server
@@ -110,8 +114,11 @@
{
this.socketAcceptor = socketAcceptor;
}
+
+
/**
* @org.apache.xbean.InitMethod
+ * @throws IOException if there are issues binding
*/
public void start() throws IOException
{
@@ -131,6 +138,7 @@
}
}
+
/**
* @org.apache.xbean.DestroyMethod
*/
Modified: directory/apacheds/branches/bigbang/protocol-shared/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-shared/pom.xml?rev=584868&r1=584867&r2=584868&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-shared/pom.xml (original)
+++ directory/apacheds/branches/bigbang/protocol-shared/pom.xml Mon Oct 15 12:38:45 2007
@@ -36,9 +36,10 @@
<dependencies>
<dependency>
<groupId>org.apache.directory.server</groupId>
- <artifactId>apacheds-constants</artifactId>
+ <artifactId>apacheds-core</artifactId>
<version>${pom.version}</version>
</dependency>
+
<dependency>
<groupId>org.apache.mina</groupId>
<artifactId>mina-core</artifactId>
Added: directory/apacheds/branches/bigbang/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/AbstractProtocolService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/AbstractProtocolService.java?rev=584868&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/AbstractProtocolService.java (added)
+++ directory/apacheds/branches/bigbang/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/AbstractProtocolService.java Mon Oct 15 12:38:45 2007
@@ -0,0 +1,162 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.directory.server.protocol.shared;
+
+
+import org.apache.directory.server.core.DirectoryService;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+
+/**
+ * An abstract base class for a ProtocolService. The start/stop methods have
+ * not been implemented.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public abstract class AbstractProtocolService implements ProtocolService
+{
+ private boolean enabled;
+ private String serviceId;
+ private String serviceName;
+ private String ipAddress;
+ private int ipPort = -1;
+ private Set<TransportProtocol> transportProtocols;
+ private DirectoryService directoryService;
+ private DatagramAcceptor datagramAcceptor;
+ private SocketAcceptor socketAcceptor;
+
+
+ public boolean isEnabled()
+ {
+ return enabled;
+ }
+
+
+ public void setEnabled( boolean enabled )
+ {
+ this.enabled = enabled;
+ }
+
+
+ public String getServiceId()
+ {
+ return serviceId;
+ }
+
+
+ public void setServiceId( String serviceId )
+ {
+ this.serviceId = serviceId;
+ }
+
+
+ public String getServiceName()
+ {
+ return serviceName;
+ }
+
+
+ public void setServiceName( String name )
+ {
+ this.serviceName = name;
+ }
+
+
+ public String getIpAddress()
+ {
+ return ipAddress;
+ }
+
+
+ public void setIpAddress( String ipAddress )
+ {
+ this.ipAddress = ipAddress;
+ }
+
+
+ public int getIpPort()
+ {
+ return ipPort;
+ }
+
+
+ public void setIpPort( int ipPort )
+ {
+ if ( ipPort < 0 || ipPort > 65535 )
+ {
+ throw new IllegalArgumentException( "Invalid port number: " + ipPort );
+ }
+
+ this.ipPort = ipPort;
+ }
+
+
+ public Set<TransportProtocol> getTransportProtocols()
+ {
+ return transportProtocols;
+ }
+
+
+ public void setTransportProtocols( Set<TransportProtocol> transportProtocols )
+ {
+ Set<TransportProtocol> copy = new HashSet<TransportProtocol>( transportProtocols.size() );
+ copy.addAll( transportProtocols );
+ this.transportProtocols = Collections.unmodifiableSet( copy );
+ }
+
+
+ public DirectoryService getDirectoryService()
+ {
+ return directoryService;
+ }
+
+
+ public void setDirectoryService( DirectoryService directoryService )
+ {
+ this.directoryService = directoryService;
+ }
+
+
+ public DatagramAcceptor getDatagramAcceptor()
+ {
+ return datagramAcceptor;
+ }
+
+
+ public void setDatagramAcceptor( DatagramAcceptor datagramAcceptor )
+ {
+ this.datagramAcceptor = datagramAcceptor;
+ }
+
+
+ public SocketAcceptor getSocketAcceptor()
+ {
+ return socketAcceptor;
+ }
+
+
+ public void setSocketAcceptor( SocketAcceptor socketAcceptor )
+ {
+ this.socketAcceptor = socketAcceptor;
+ }
+}
Added: directory/apacheds/branches/bigbang/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/ProtocolService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/ProtocolService.java?rev=584868&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/ProtocolService.java (added)
+++ directory/apacheds/branches/bigbang/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/ProtocolService.java Mon Oct 15 12:38:45 2007
@@ -0,0 +1,203 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.directory.server.protocol.shared;
+
+
+import org.apache.directory.server.core.DirectoryService;
+
+import java.util.Set;
+
+
+/**
+ * Minimum functionality required by an ApacheDS protocol service.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface ProtocolService
+{
+ /**
+ * Stops this ProtocolService which unbinds acceptors on the protocol port.
+ *
+ * @throws Exception if there are problems stopping this service
+ */
+ void stop() throws Exception;
+
+
+ /**
+ * Starts this ProtocolService which binds acceptors on the protocol port.
+ *
+ * @throws Exception if there are problems starting this service
+ */
+ void start() throws Exception;
+
+
+ /**
+ * If this protocol service supports UDP transport then this gets the
+ * non-null MINA DatagramAcceptor it uses.
+ *
+ * @return the MINA DatagramAcceptor used for UDP transports
+ */
+ DatagramAcceptor getDatagramAcceptor();
+
+
+ /**
+ * If this protocol service supports UDP transport then this sets the
+ * MINA DatagramAcceptor it uses.
+ *
+ * @param datagramAcceptor the MINA DatagramAcceptor used for UDP transport
+ */
+ void setDatagramAcceptor( DatagramAcceptor datagramAcceptor );
+
+
+ /**
+ * If this protocol service support TCP transport then this gets the
+ * MINA SocketAcceptor it uses.
+ *
+ * @return the MINA SocketAcceptor used for TCP transport
+ */
+ SocketAcceptor getSocketAcceptor();
+
+
+ /**
+ * If this protocol service support TCP transport then this sets the
+ * MINA SocketAcceptor it uses.
+ *
+ * @param socketAcceptor the MINA SocketAcceptor used for TCP transport
+ */
+ void setSocketAcceptor( SocketAcceptor socketAcceptor );
+
+
+ /**
+ * Services can be enabled or disabled. If enabled they will be started, if
+ * not they will not.
+ *
+ * @return true if this service is to be started, false otherwise
+ */
+ boolean isEnabled();
+
+
+ /**
+ * Sets whether or not this ProtocolService is enabled.
+ *
+ * @param enabled true to enable, false to disable
+ */
+ void setEnabled( boolean enabled );
+
+
+ /**
+ * Gets the instance identifier for this ProtocolService.
+ *
+ * @return the identifier for the service instance
+ */
+ String getServiceId();
+
+
+ /**
+ * Sets the instance identifier for this ProtocolService.
+ *
+ * @param serviceId an identifier for the service instance
+ */
+ void setServiceId( String serviceId );
+
+
+ /**
+ * Gets a descriptive name for the kind of service this represents.
+ * This name is constant across instances of this ProtocolService.
+ *
+ * @return a descriptive name for the kind of this service
+ */
+ String getServiceName();
+
+
+ /**
+ * Sets the descriptive name for the kind of service this represents.
+ * This name is constant across instances of this ProtocolService.
+ *
+ * @param name a descriptive name for the kind of this service
+ */
+ void setServiceName( String name );
+
+
+ /**
+ * Gets the IP address of this service.
+ *
+ * @return the IP address for this service.
+ */
+ String getIpAddress();
+
+
+ /**
+ * Gets the IP address of this service.
+ *
+ * @param ipAddress the Internet Protocol address for this service.
+ */
+ void setIpAddress( String ipAddress );
+
+
+ /**
+ * Gets the IP port for this service.
+ *
+ * @return the IP port for this service
+ */
+ int getIpPort();
+
+
+ /**
+ * Sets the IP port for this service.
+ *
+ * @param ipPort the ip port for this service
+ * @throws IllegalArgumentException if the port number is not within a valid range
+ */
+ void setIpPort( int ipPort );
+
+
+ /**
+ * Gets the transport protocols used by this service. At this point services
+ * which support more than one transport are configured to bind to that transport
+ * on the same port.
+ *
+ * @return the transport protocols used by this service
+ */
+ Set<TransportProtocol> getTransportProtocols();
+
+
+ /**
+ * Sets the transport protocols used by this service.
+ *
+ * @param transportProtocols the transport protocols to be used by this service
+ */
+ void setTransportProtocols( TransportProtocol[] transportProtocols );
+
+
+ /**
+ * Gets the DirectoryService assigned to this ProtocolService.
+ *
+ * @return the directory service core assigned to this service
+ */
+ DirectoryService getDirectoryService();
+
+
+ /**
+ * Sets the DirectoryService assigned to this ProtocolService.
+ *
+ * @param directoryService the directory service core assigned to this service
+ */
+ void setDirectoryService( DirectoryService directoryService );
+}
Added: directory/apacheds/branches/bigbang/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/TransportProtocol.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/TransportProtocol.java?rev=584868&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/TransportProtocol.java (added)
+++ directory/apacheds/branches/bigbang/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/TransportProtocol.java Mon Oct 15 12:38:45 2007
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.directory.server.protocol.shared;
+
+
+/**
+ * Type safe enumeration for the transport protocol.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public enum TransportProtocol
+{
+ TCP( 0, "TCP" ), UDP( 1, "UDP" );
+
+
+ private final int intValue;
+ private final String stringValue;
+
+
+ private TransportProtocol( int intValue, String stringValue )
+ {
+ this.intValue = intValue;
+ this.stringValue = stringValue;
+ }
+
+
+ /**
+ * Gets an integer value for switches.
+ *
+ * @return ordinal integer value
+ */
+ public int getIntValue()
+ {
+ return intValue;
+ }
+
+
+ public String toString()
+ {
+ return stringValue;
+ }
+}