KickJava   Java API By Example, From Geeks To Geeks.

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


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.CosNaming.*;
27 import org.omg.IOP.Codec JavaDoc;
28 import org.omg.IOP.CodecFactory JavaDoc;
29 import org.omg.IOP.CodecFactoryHelper JavaDoc;
30 import org.omg.IOP.Encoding JavaDoc;
31 import org.omg.IOP.ENCODING_CDR_ENCAPS JavaDoc;
32 import org.omg.PortableInterceptor.ORBInitializer JavaDoc;
33 import org.omg.PortableInterceptor.ORBInitInfo JavaDoc;
34 import org.omg.PortableInterceptor.ORBInitInfoPackage.InvalidName JavaDoc;
35 import org.omg.PortableInterceptor.ORBInitInfoPackage.DuplicateName JavaDoc;
36
37 import java.util.logging.*;
38 import com.sun.logging.*;
39
40 /**
41  * This class is used to add IOR interceptors for supporting IN_ADDR_ANY
42  * functionality in the ORB
43  */

44 public class IORAddrAnyInitializer extends org.omg.CORBA.LocalObject JavaDoc
45                                 implements ORBInitializer JavaDoc{
46                                     
47     private static Logger _logger=null;
48     static {
49        _logger=LogDomains.getLogger(LogDomains.CORBA_LOGGER);
50     }
51     
52     public static final String JavaDoc baseMsg = IORAddrAnyInitializer.class.getName();
53     
54     /** Creates a new instance of IORAddrAnyInitializer */
55     public IORAddrAnyInitializer() {
56     }
57     
58     /**
59      * Called during ORB initialization. If it is expected that initial
60      * services registered by an interceptor will be used by other
61      * interceptors, then those initial services shall be registered at
62      * this point via calls to
63      * <code>ORBInitInfo.register_initial_reference</code>.
64      *
65      * @param info provides initialization attributes and operations by
66      * which Interceptors can be registered.
67      */

68     public void pre_init(org.omg.PortableInterceptor.ORBInitInfo JavaDoc info) {
69     }
70     
71     /**
72      * Called during ORB initialization. If a service must resolve initial
73      * references as part of its initialization, it can assume that all
74      * initial references will be available at this point.
75      * <p>
76      * Calling the <code>post_init</code> operations is not the final
77      * task of ORB initialization. The final task, following the
78      * <code>post_init</code> calls, is attaching the lists of registered
79      * interceptors to the ORB. Therefore, the ORB does not contain the
80      * interceptors during calls to <code>post_init</code>. If an
81      * ORB-mediated call is made from within <code>post_init</code>, no
82      * request interceptors will be invoked on that call.
83      * Likewise, if an operation is performed which causes an IOR to be
84      * created, no IOR interceptors will be invoked.
85      *
86      * @param info provides initialization attributes and
87      * operations by which Interceptors can be registered.
88      */

89     public void post_init(org.omg.PortableInterceptor.ORBInitInfo JavaDoc info) {
90         Codec JavaDoc codec = null;
91         CodecFactory JavaDoc cf = info.codec_factory();
92   
93         byte major_version = 1;
94         byte minor_version = 2;
95         Encoding JavaDoc encoding = new Encoding JavaDoc(ENCODING_CDR_ENCAPS.value,
96                                          major_version, minor_version);
97         try {
98             codec = cf.create_codec(encoding);
99         } catch (org.omg.IOP.CodecFactoryPackage.UnknownEncoding JavaDoc e) {
100             _logger.log(Level.WARNING,"UnknownEncoding from " + baseMsg,e);
101         }
102         try {
103             info.add_ior_interceptor(new IORAddrAnyInterceptor(codec));
104         } catch (DuplicateName JavaDoc ex) {
105             _logger.log(Level.WARNING,"DuplicateName from " + baseMsg,ex);
106         }
107     }
108     
109 }
110
Popular Tags