001 /** 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 package org.apache.geronimo.yoko; 018 019 import org.apache.commons.logging.Log; 020 import org.apache.commons.logging.LogFactory; 021 import org.omg.CORBA.LocalObject; 022 import org.omg.PortableInterceptor.ORBInitInfo; 023 import org.omg.PortableInterceptor.ORBInitInfoPackage.DuplicateName; 024 025 /** 026 * @version $Revision: 452600 $ $Date: 2006-10-03 12:29:42 -0700 (Tue, 03 Oct 2006) $ 027 */ 028 public class ORBInitializer extends LocalObject implements org.omg.PortableInterceptor.ORBInitializer { 029 030 private final Log log = LogFactory.getLog(ORBInitializer.class); 031 032 public ORBInitializer() { 033 if (log.isDebugEnabled()) log.debug("ORBInitializer.<init>"); 034 } 035 036 /** 037 * Called during ORB initialization. If it is expected that initial 038 * services registered by an interceptor will be used by other 039 * interceptors, then those initial services shall be registered at 040 * this point via calls to 041 * <code>ORBInitInfo.register_initial_reference</code>. 042 * 043 * @param info provides initialization attributes and operations by 044 * which Interceptors can be registered. 045 */ 046 public void pre_init(ORBInitInfo info) { 047 } 048 049 /** 050 * Called during ORB initialization. If a service must resolve initial 051 * references as part of its initialization, it can assume that all 052 * initial references will be available at this point. 053 * <p/> 054 * Calling the <code>post_init</code> operations is not the final 055 * task of ORB initialization. The final task, following the 056 * <code>post_init</code> calls, is attaching the lists of registered 057 * interceptors to the ORB. Therefore, the ORB does not contain the 058 * interceptors during calls to <code>post_init</code>. If an 059 * ORB-mediated call is made from within <code>post_init</code>, no 060 * request interceptors will be invoked on that call. 061 * Likewise, if an operation is performed which causes an IOR to be 062 * created, no IOR interceptors will be invoked. 063 * 064 * @param info provides initialization attributes and 065 * operations by which Interceptors can be registered. 066 */ 067 public void post_init(ORBInitInfo info) { 068 069 try { 070 if (log.isDebugEnabled()) log.debug("Registering IOR interceptor"); 071 072 try { 073 info.add_server_request_interceptor(new ServiceContextInterceptor()); 074 } catch (DuplicateName dn) { 075 log.error("Error registering interceptor", dn); 076 } 077 } catch (RuntimeException re) { 078 log.error("Error registering interceptor", re); 079 throw re; 080 } 081 } 082 }