KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > iiop > ClientConnectionInterceptor


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.enterprise.iiop;
25
26 import org.omg.PortableInterceptor.ClientRequestInfo JavaDoc;
27
28 import com.sun.enterprise.*;
29 import com.sun.corba.ee.spi.legacy.interceptor.RequestInfoExt;
30 import com.sun.corba.ee.spi.legacy.connection.Connection;
31 import com.sun.enterprise.iiop.security.SecurityMechanismSelector;
32 import com.sun.enterprise.iiop.security.ConnectionContext;
33 import com.sun.corba.ee.spi.presentation.rmi.StubAdapter;
34 import java.util.logging.*;
35 import com.sun.logging.*;
36
37 public class ClientConnectionInterceptor extends org.omg.CORBA.LocalObject JavaDoc
38     implements org.omg.PortableInterceptor.ClientRequestInterceptor JavaDoc,
39         Comparable JavaDoc
40 {
41     private static Logger _logger=null;
42     static{
43        _logger=LogDomains.getLogger(LogDomains.CORBA_LOGGER);
44         }
45     public String JavaDoc name;
46     public int order;
47
48     /**
49      * Create the interceptor.
50      * @param the name of the interceptor.
51      * @param the order in which the interceptor should be invoked.
52      */

53     public ClientConnectionInterceptor(String JavaDoc name, int order)
54     {
55     this.name = name;
56     this.order = order;
57     }
58
59     public int compareTo(Object JavaDoc o)
60     {
61     int otherOrder = -1;
62     if(o instanceof ClientConnectionInterceptor) {
63         otherOrder = ((ClientConnectionInterceptor)o).order;
64     }
65     if (order < otherOrder) {
66         return -1;
67     } else if (order == otherOrder) {
68         return 0;
69     }
70     return 1;
71     }
72
73     /**
74      * Return the name of the interceptor.
75      * @return the name of the interceptor.
76      */

77     public String JavaDoc name() {
78     return name;
79     }
80
81
82     public void send_request(ClientRequestInfo JavaDoc cri)
83     {
84     // Check if there is an exportable transaction on current thread
85
Object JavaDoc target = cri.effective_target();
86     J2EETransactionManager tm = Switch.getSwitch().getTransactionManager();
87     if ( tm != null )
88         tm.checkTransactionExport(StubAdapter.isLocal(target));
89
90     // Get connection information and store it in ConnectionContext
91
Connection c = ((RequestInfoExt)cri).connection();
92     if(c != null) {
93         SecurityMechanismSelector sms = new SecurityMechanismSelector();
94         ConnectionContext cc = sms.getClientConnectionContext();
95         if(_logger.isLoggable(Level.FINE)){
96          _logger.log(Level.FINE,"SENDING request on connection: " + c);
97         }
98         if(cc != null) {
99             cc.setSocket(c.getSocket());
100         }
101     }
102     }
103
104     public void destroy() {
105     }
106
107     public void send_poll(ClientRequestInfo JavaDoc cri) {
108     }
109
110     public void receive_reply(ClientRequestInfo JavaDoc cri) {
111     }
112
113     public void receive_exception(ClientRequestInfo JavaDoc cri) {
114     }
115
116     public void receive_other(ClientRequestInfo JavaDoc cri) {
117     }
118 }
119
120
Popular Tags