1 package org.umu.cops.ospep;
3 import org.slf4j.Logger;
4 import org.slf4j.LoggerFactory;
5 import org.umu.cops.prpep.COPSPepAgent;
6 import org.umu.cops.prpep.COPSPepConnection;
7 import org.umu.cops.prpep.COPSPepReqStateMan;
8 import org.umu.cops.stack.COPSClientSI;
9 import org.umu.cops.stack.COPSException;
10 import org.umu.cops.stack.COPSHandle;
11 import org.umu.cops.stack.COPSPepId;
13 import java.net.Socket;
14 import java.util.List;
17 * This is a outsourcing COPS PEP. Responsible for making
18 * connection to the PDP and maintaining it
20 public class COPSPepOSAgent extends COPSPepAgent {
22 public final static Logger logger = LoggerFactory.getLogger(COPSPepOSAgent.class);
25 * Policy data processor class
27 private transient COPSPepOSDataProcess _process;
31 * @param clientType Client-type
33 * @param port The port to begin listening
35 public COPSPepOSAgent(final short clientType, final COPSPepId pepID, final int port,
36 final COPSPepOSDataProcess process) {
37 super(clientType, pepID, port);
38 this._process = process;
42 * Adds a request state to the connection manager.
43 * @param clientSIs The client data from the outsourcing event
44 * @return The newly created connection manager
45 * @throws COPSPepException
46 * @throws COPSException
48 public COPSPepReqStateMan addRequestState(final COPSHandle handle, final List<COPSClientSI> clientSIs)
49 throws COPSException {
51 return ((COPSPepOSConnection)_conn).addRequestState(handle, _process, clientSIs);
57 protected COPSPepConnection createPepConnection(final Socket socket) {
58 return new COPSPepOSConnection(_clientType, socket);
62 * Creates a new request state when the outsourcing event is detected.
63 * @param handle The COPS handle for this request
64 * @param clientSIs The client specific data for this request
66 public void dispatchEvent(final COPSHandle handle, final List<COPSClientSI> clientSIs) {
68 addRequestState(handle, clientSIs);
69 } catch (Exception e) {
70 logger.error("Error adding request state", e);