01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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: */package org.apache.geronimo.yoko;
17:
18: import org.apache.commons.logging.Log;
19: import org.apache.commons.logging.LogFactory;
20: import org.omg.CORBA.LocalObject;
21: import org.omg.PortableInterceptor.ORBInitInfo;
22: import org.omg.PortableInterceptor.ORBInitInfoPackage.DuplicateName;
23:
24: /**
25: * @version $Revision: 452600 $ $Date: 2006-10-03 12:29:42 -0700 (Tue, 03 Oct 2006) $
26: */
27: public class ORBInitializer extends LocalObject implements
28: org.omg.PortableInterceptor.ORBInitializer {
29:
30: private final Log log = LogFactory.getLog(ORBInitializer.class);
31:
32: public ORBInitializer() {
33: if (log.isDebugEnabled())
34: log.debug("ORBInitializer.<init>");
35: }
36:
37: /**
38: * Called during ORB initialization. If it is expected that initial
39: * services registered by an interceptor will be used by other
40: * interceptors, then those initial services shall be registered at
41: * this point via calls to
42: * <code>ORBInitInfo.register_initial_reference</code>.
43: *
44: * @param info provides initialization attributes and operations by
45: * which Interceptors can be registered.
46: */
47: public void pre_init(ORBInitInfo info) {
48: }
49:
50: /**
51: * Called during ORB initialization. If a service must resolve initial
52: * references as part of its initialization, it can assume that all
53: * initial references will be available at this point.
54: * <p/>
55: * Calling the <code>post_init</code> operations is not the final
56: * task of ORB initialization. The final task, following the
57: * <code>post_init</code> calls, is attaching the lists of registered
58: * interceptors to the ORB. Therefore, the ORB does not contain the
59: * interceptors during calls to <code>post_init</code>. If an
60: * ORB-mediated call is made from within <code>post_init</code>, no
61: * request interceptors will be invoked on that call.
62: * Likewise, if an operation is performed which causes an IOR to be
63: * created, no IOR interceptors will be invoked.
64: *
65: * @param info provides initialization attributes and
66: * operations by which Interceptors can be registered.
67: */
68: public void post_init(ORBInitInfo info) {
69:
70: try {
71: if (log.isDebugEnabled())
72: log.debug("Registering IOR interceptor");
73:
74: try {
75: info
76: .add_server_request_interceptor(new ServiceContextInterceptor());
77: } catch (DuplicateName dn) {
78: log.error("Error registering interceptor", dn);
79: }
80: } catch (RuntimeException re) {
81: log.error("Error registering interceptor", re);
82: throw re;
83: }
84: }
85: }
|