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: */package org.apache.geronimo.corba.transaction;
017:
018: import org.apache.commons.logging.Log;
019: import org.apache.commons.logging.LogFactory;
020: import org.omg.CORBA.LocalObject;
021: import org.omg.PortableInterceptor.ORBInitInfo;
022: import org.omg.PortableInterceptor.ORBInitInfoPackage.DuplicateName;
023: import org.omg.PortableInterceptor.ORBInitializer;
024:
025: /**
026: * @version $Revision: 451417 $ $Date: 2006-09-29 13:13:22 -0700 (Fri, 29 Sep 2006) $
027: */
028: public class TransactionInitializer extends LocalObject implements
029: ORBInitializer {
030:
031: private final Log log = LogFactory
032: .getLog(TransactionInitializer.class);
033:
034: public TransactionInitializer() {
035: if (log.isDebugEnabled())
036: log.debug("TransactionInitializer.<init>");
037: }
038:
039: /**
040: * Called during ORB initialization. If it is expected that initial
041: * services registered by an interceptor will be used by other
042: * interceptors, then those initial services shall be registered at
043: * this point via calls to
044: * <code>ORBInitInfo.register_initial_reference</code>.
045: *
046: * @param orbInitInfo provides initialization attributes and operations by
047: * which Interceptors can be registered.
048: */
049: public void pre_init(ORBInitInfo orbInitInfo) {
050:
051: }
052:
053: /**
054: * Called during ORB initialization. If a service must resolve initial
055: * references as part of its initialization, it can assume that all
056: * initial references will be available at this point.
057: * <p/>
058: * Calling the <code>post_init</code> operations is not the final
059: * task of ORB initialization. The final task, following the
060: * <code>post_init</code> calls, is attaching the lists of registered
061: * interceptors to the ORB. Therefore, the ORB does not contain the
062: * interceptors during calls to <code>post_init</code>. If an
063: * ORB-mediated call is made from within <code>post_init</code>, no
064: * request interceptors will be invoked on that call.
065: * Likewise, if an operation is performed which causes an IOR to be
066: * created, no IOR interceptors will be invoked.
067: *
068: * @param orbInitInfo provides initialization attributes and
069: * operations by which Interceptors can be registered.
070: */
071: public void post_init(ORBInitInfo orbInitInfo) {
072: try {
073: if (log.isDebugEnabled())
074: log
075: .debug("Registering interceptors and policy factories");
076:
077: try {
078: orbInitInfo
079: .add_client_request_interceptor(new ClientTransactionInterceptor());
080: orbInitInfo
081: .add_server_request_interceptor(new ServerTransactionInterceptor());
082: orbInitInfo
083: .add_ior_interceptor(new IORTransactionInterceptor());
084: } catch (DuplicateName duplicateName) {
085: log.error("Duplicate name", duplicateName);
086: }
087:
088: orbInitInfo.register_policy_factory(
089: ClientTransactionPolicyFactory.POLICY_TYPE,
090: new ClientTransactionPolicyFactory());
091: orbInitInfo.register_policy_factory(
092: ServerTransactionPolicyFactory.POLICY_TYPE,
093: new ServerTransactionPolicyFactory());
094: } catch (RuntimeException re) {
095: log.error("Error registering interceptor", re);
096: throw re;
097: }
098: }
099:
100: }
|