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.corba.transaction;
17:
18: import org.omg.CORBA.Any;
19: import org.omg.CORBA.BAD_PARAM;
20: import org.omg.CORBA.INTERNAL;
21: import org.omg.CORBA.SystemException;
22: import org.omg.CosTransactions.PropagationContext;
23: import org.omg.CosTransactions.PropagationContextHelper;
24: import org.omg.IOP.Codec;
25: import org.omg.IOP.CodecPackage.FormatMismatch;
26: import org.omg.IOP.CodecPackage.TypeMismatch;
27: import org.omg.IOP.ServiceContext;
28: import org.omg.IOP.TransactionService;
29: import org.omg.PortableInterceptor.ServerRequestInfo;
30: import org.apache.geronimo.corba.util.Util;
31:
32: /**
33: * @version $Rev: 451417 $ $Date: 2006-09-29 13:13:22 -0700 (Fri, 29 Sep 2006) $
34: */
35: public abstract class AbstractServerTransactionPolicyConfig implements
36: ServerTransactionPolicyConfig {
37:
38: public void importTransaction(ServerRequestInfo serverRequestInfo)
39: throws SystemException {
40: ServiceContext serviceContext = null;
41: try {
42: serviceContext = serverRequestInfo
43: .get_request_service_context(TransactionService.value);
44: } catch (BAD_PARAM e) {
45: // do nothing
46: }
47: PropagationContext propagationContext;
48: if (serviceContext == null) {
49: propagationContext = null;
50: } else {
51: byte[] encoded = serviceContext.context_data;
52: Codec codec = Util.getCodec();
53: Any any;
54: try {
55: any = codec.decode_value(encoded,
56: PropagationContextHelper.type());
57: } catch (FormatMismatch formatMismatch) {
58: throw (INTERNAL) new INTERNAL(
59: "Could not decode encoded propagation context")
60: .initCause(formatMismatch);
61: } catch (TypeMismatch typeMismatch) {
62: throw (INTERNAL) new INTERNAL(
63: "Could not decode encoded propagation context")
64: .initCause(typeMismatch);
65: }
66: propagationContext = PropagationContextHelper.extract(any);
67: }
68: //figure out what method is being invoked
69: //operation name is unique... it contains the mangled operation name + arg types.
70: String operation = serverRequestInfo.operation();
71: importTransaction(operation, propagationContext);
72: }
73:
74: protected abstract void importTransaction(String operation,
75: PropagationContext propagationContext)
76: throws SystemException;
77:
78: }
|