KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > fr > dyade > aaa > agent > DriverConnect


1 /*
2  * Copyright (C) 1996 - 2000 BULL
3  * Copyright (C) 1996 - 2000 INRIA
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18  * USA.
19  */

20 package fr.dyade.aaa.agent;
21
22 import org.objectweb.util.monolog.api.BasicLevel;
23
24 /**
25  * The <code>DriverConnect</code> class is used by <code>ProxyAgent</code>
26  * instances for managing their connection steps.
27  */

28 class DriverConnect extends Driver {
29   protected ProxyAgent proxy = null;
30   protected boolean blockingCnx;
31   protected boolean multipleCnx;
32
33   DriverConnect(ProxyAgent proxy, boolean blockingCnx, boolean multipleCnx) {
34     this.proxy = proxy;
35     this.blockingCnx = blockingCnx;
36     this.multipleCnx = multipleCnx;
37     this.name = proxy.getName() + ".DriverConnect";
38     // Get the proxy logging monitor
39
logmon = proxy.logmon;
40   }
41
42   public void start() {
43     if (! blockingCnx)
44       run();
45     else
46       super.start();
47   }
48
49   public void run() {
50     try {
51       if (logmon.isLoggable(BasicLevel.DEBUG))
52         logmon.log(BasicLevel.DEBUG, getName() + ", started");
53
54       do {
55         proxy.createDrivers();
56       } while (isRunning && multipleCnx);
57     }
58     catch (java.net.SocketException JavaDoc exc) {
59       if (! proxy.finalizing) {
60         logmon.log(BasicLevel.WARN,
61                    "connection closed in createDrivers()",
62                    exc);
63       }
64     }
65     catch (java.io.EOFException JavaDoc exc) {
66       if (! proxy.finalizing) {
67         logmon.log(BasicLevel.WARN,
68                    "connection closed in createDrivers()",
69                    exc);
70       }
71     }
72     catch (Exception JavaDoc exc) {
73       if (! proxy.finalizing)
74         logmon.log(BasicLevel.ERROR, "error in createDrivers()", exc);
75     }
76   }
77   
78   public void close() {}
79 }
80
Popular Tags