Cleanup of state managers' interfaces (constructor and init).
[packetcable.git] / packetcable-driver / src / main / java / org / umu / cops / COPSStateMan.java
index 2b742f6c70f766e7543188fec033ed00e9215088..c6d6a252c08f6ffb07bcc44190ff91cc7b2c988e 100644 (file)
@@ -24,6 +24,11 @@ public abstract class COPSStateMan {
      */
     protected final COPSHandle _handle;
 
+    /**
+     * The socket connection. Value set when initRequestState is called
+     */
+    protected final Socket _socket;
+
     /**
      *  Current state of the request being managed
      */
@@ -34,9 +39,13 @@ public abstract class COPSStateMan {
      * @param clientType - the client type
      * @param clientHandle - the unique handle to the client
      */
-    public COPSStateMan(final short clientType, final COPSHandle clientHandle) {
+    protected COPSStateMan(final short clientType, final COPSHandle clientHandle, final Socket socket) {
+        if (clientHandle == null) throw new IllegalArgumentException("Client handle must not be null");
+        if (socket == null) throw new IllegalArgumentException("Socket connection must not be null");
+        if (!socket.isConnected()) throw new IllegalArgumentException("Socket connection must be connected");
         this._clientType = clientType;
         this._handle = clientHandle;
+        this._socket = socket;
         this._status = Status.ST_CREATE;
     }
 
@@ -74,13 +83,6 @@ public abstract class COPSStateMan {
         // TODO - maybe we should notifySyncComplete ...
     }
 
-    /**
-     * Initializes a new request state over a socket
-     * @param sock  Socket to the PEP
-     * @throws COPSPdpException
-     */
-    protected abstract void initRequestState(final Socket sock) throws COPSException;
-
     /**
      * The different state manager statuses
      */