KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > fr > dyade > aaa > jndi2 > server > TcpEntryPoint


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

23 package fr.dyade.aaa.jndi2.server;
24
25 import fr.dyade.aaa.agent.*;
26 import fr.dyade.aaa.jndi2.msg.*;
27
28 import org.objectweb.util.monolog.api.BasicLevel;
29 import org.objectweb.util.monolog.api.Logger;
30
31 public class TcpEntryPoint implements EntryPoint {
32
33   private RequestManager manager;
34
35   public void setRequestManager(RequestManager manager) {
36     this.manager = manager;
37   }
38
39   public boolean accept(AgentId from, Notification not) throws Exception JavaDoc {
40     if (not instanceof TcpRequestNot) {
41       doReact((TcpRequestNot)not);
42     } else return false;
43     return true;
44   }
45
46   /**
47    * Reacts to a TCP connection request. This is the
48    * TCP entry point.
49    *
50    * @param not the TCP connection request
51    */

52   private void doReact(TcpRequestNot not) throws Exception JavaDoc {
53     if (Trace.logger.isLoggable(BasicLevel.DEBUG))
54       Trace.logger.log(BasicLevel.DEBUG,
55                        "JndiServer.doReact((TcpRequestNot)" +
56                        not + ')');
57     RequestContext reqCtx = not.getRequestContext();
58     JndiReply reply = manager.invoke(reqCtx);
59     if (reply != null) {
60       reqCtx.reply(reply);
61     }
62   }
63 }
64
Popular Tags