1 /** 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 package org.apache.geronimo.yoko; 18 19 import org.slf4j.Logger; 20 import org.slf4j.LoggerFactory; 21 import org.omg.CORBA.LocalObject; 22 import org.omg.PortableInterceptor.ORBInitInfo; 23 import org.omg.PortableInterceptor.ORBInitInfoPackage.DuplicateName; 24 25 /** 26 * @version $Revision: 452600 $ $Date: 2006-10-03 12:29:42 -0700 (Tue, 03 Oct 2006) $ 27 */ 28 public class ORBInitializer extends LocalObject implements org.omg.PortableInterceptor.ORBInitializer { 29 30 private final Logger log = LoggerFactory.getLogger(ORBInitializer.class); 31 32 public ORBInitializer() { 33 if (log.isDebugEnabled()) log.debug("ORBInitializer.<init>"); 34 } 35 36 /** 37 * Called during ORB initialization. If it is expected that initial 38 * services registered by an interceptor will be used by other 39 * interceptors, then those initial services shall be registered at 40 * this point via calls to 41 * <code>ORBInitInfo.register_initial_reference</code>. 42 * 43 * @param info provides initialization attributes and operations by 44 * which Interceptors can be registered. 45 */ 46 public void pre_init(ORBInitInfo info) { 47 } 48 49 /** 50 * Called during ORB initialization. If a service must resolve initial 51 * references as part of its initialization, it can assume that all 52 * initial references will be available at this point. 53 * <p/> 54 * Calling the <code>post_init</code> operations is not the final 55 * task of ORB initialization. The final task, following the 56 * <code>post_init</code> calls, is attaching the lists of registered 57 * interceptors to the ORB. Therefore, the ORB does not contain the 58 * interceptors during calls to <code>post_init</code>. If an 59 * ORB-mediated call is made from within <code>post_init</code>, no 60 * request interceptors will be invoked on that call. 61 * Likewise, if an operation is performed which causes an IOR to be 62 * created, no IOR interceptors will be invoked. 63 * 64 * @param info provides initialization attributes and 65 * operations by which Interceptors can be registered. 66 */ 67 public void post_init(ORBInitInfo info) { 68 69 try { 70 if (log.isDebugEnabled()) log.debug("Registering IOR interceptor"); 71 72 try { 73 info.add_server_request_interceptor(new ServiceContextInterceptor()); 74 } catch (DuplicateName dn) { 75 log.error("Error registering interceptor", dn); 76 } 77 } catch (RuntimeException re) { 78 log.error("Error registering interceptor", re); 79 throw re; 80 } 81 } 82 }