KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > codehaus > spice > netserve > connection > impl > ExceptOnAcceptServerSocket


1 /*
2  * Copyright (C) The Spice Group. All rights reserved.
3  *
4  * This software is published under the terms of the Spice
5  * Software License version 1.1, a copy of which has been included
6  * with this distribution in the LICENSE.txt file.
7  */

8 package org.codehaus.spice.netserve.connection.impl;
9
10 import java.io.IOException JavaDoc;
11 import java.io.InterruptedIOException JavaDoc;
12 import java.net.ServerSocket JavaDoc;
13 import java.net.Socket JavaDoc;
14
15 /**
16  *
17  * @author Peter Donald
18  * @version $Revision: 1.2 $ $Date: 2004/03/21 23:42:59 $
19  */

20 class ExceptOnAcceptServerSocket
21    extends ServerSocket JavaDoc
22 {
23    static final IOException JavaDoc ERROR_EXCEPTION = new IOException JavaDoc( "No Accept - ha ha!" );
24    static final IOException JavaDoc INTERRUPTED_EXCEPTION = new InterruptedIOException JavaDoc( "No Interuptions!" );
25
26    private boolean m_interupt;
27
28    public ExceptOnAcceptServerSocket( final boolean interupt )
29       throws IOException JavaDoc
30    {
31       m_interupt = interupt;
32    }
33
34    public Socket JavaDoc accept() throws IOException JavaDoc
35    {
36       if ( m_interupt )
37       {
38          throw INTERRUPTED_EXCEPTION;
39       }
40       else
41       {
42          throw ERROR_EXCEPTION;
43       }
44    }
45 }
46
Popular Tags