summaryrefslogtreecommitdiffstats
path: root/simple/simple-http/src/test/java/org/simpleframework/http/core/TicketProcessor.java
blob: 4636cc7f2f931686ad2c5fbef4b32984af3976c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package org.simpleframework.http.core;

import java.io.IOException;
import java.nio.channels.SocketChannel;

import org.simpleframework.transport.SocketProcessor;
import org.simpleframework.transport.Socket;

class TicketProcessor implements SocketProcessor {
   
   private SocketProcessor delegate;

   public TicketProcessor(SocketProcessor delegate) {
      this.delegate = delegate;
   }

   public void process(Socket pipe) throws IOException {
      SocketChannel channel = pipe.getChannel();
      int port = channel.socket().getPort();

      pipe.getAttributes().put(Ticket.KEY,new Ticket(port));
      delegate.process(pipe);
   }

   public void stop() throws IOException {
      delegate.stop();
   }
}