01: /*
02: * JacORB - a free Java ORB
03: *
04: * Copyright (C) 1997-2004 Gerald Brose.
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Library General Public
08: * License as published by the Free Software Foundation; either
09: * version 2 of the License, or (at your option) 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: * Library General Public License for more details.
15: *
16: * You should have received a copy of the GNU Library General Public
17: * License along with this library; if not, write to the Free
18: * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19: */
20:
21: package org.jacorb.orb.giop;
22:
23: import org.apache.avalon.framework.logger.Logger;
24:
25: import org.omg.GIOP.ReplyStatusType_1_2;
26: import org.omg.CORBA.INV_POLICY;
27: import org.omg.CORBA.CompletionStatus;
28:
29: import org.jacorb.orb.SystemExceptionHelper;
30:
31: import java.io.IOException;
32:
33: /**
34: * @author Nicolas Noffke
35: * @version $Id: NoBiDirClientRequestListener.java,v 1.12 2006/07/26 08:02:25 alphonse.bendt Exp $
36: */
37:
38: public class NoBiDirClientRequestListener implements RequestListener {
39: private final Logger logger;
40:
41: public NoBiDirClientRequestListener(Logger logger) {
42: this .logger = logger;
43: }
44:
45: public void requestReceived(byte[] request,
46: GIOPConnection connection) {
47: logger.warn("Received a request on a non-bidir connection");
48:
49: connection.incPendingMessages();
50: replyException(request, connection);
51: }
52:
53: public void locateRequestReceived(byte[] request,
54: GIOPConnection connection) {
55: logger
56: .warn("Received a locate request on a non-bidir connection");
57:
58: connection.incPendingMessages();
59: replyException(request, connection);
60: }
61:
62: public void cancelRequestReceived(byte[] request,
63: GIOPConnection connection) {
64: logger
65: .warn("Received a cancel request on a non-bidir connection");
66:
67: connection.incPendingMessages();
68: replyException(request, connection);
69: }
70:
71: private void replyException(byte[] request,
72: GIOPConnection connection) {
73:
74: int giop_minor = Messages.getGIOPMinor(request);
75:
76: ReplyOutputStream out = new ReplyOutputStream(Messages
77: .getRequestId(request),
78: ReplyStatusType_1_2.SYSTEM_EXCEPTION, giop_minor,
79: false, logger);//no locate reply
80:
81: SystemExceptionHelper.write(out, new INV_POLICY(0,
82: CompletionStatus.COMPLETED_NO));
83:
84: try {
85: connection.sendReply(out);
86: } catch (IOException e) {
87: logger.error("Exception", e);
88: }
89: }
90: }
|