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.util;
17:
18: import javax.naming.Context;
19: import javax.naming.InitialContext;
20: import javax.rmi.CORBA.Stub;
21: import javax.ejb.EJBHome;
22:
23: import org.omg.CORBA.ORB;
24: import org.apache.geronimo.corba.CORBAEJBMemento;
25:
26: /**
27: * @version $Revision: 502310 $ $Date: 2007-02-01 10:34:57 -0800 (Thu, 01 Feb 2007) $
28: */
29: public abstract class ClientContextHolderStub extends Stub {
30:
31: protected ClientContextHolderStub() {
32: }
33:
34: public final Object writeReplace() {
35: String ior = getOrb().object_to_string(this );
36: return new CORBAEJBMemento(ior, this instanceof EJBHome);
37: }
38:
39: private static ORB getOrb() {
40: try {
41: Context context = new InitialContext();
42: ORB orb = (ORB) context.lookup("java:comp/ORB");
43: return orb;
44: } catch (Throwable e) {
45: throw (org.omg.CORBA.MARSHAL) new org.omg.CORBA.MARSHAL(
46: "Could not find ORB in jndi at java:comp/ORB", 0,
47: org.omg.CORBA.CompletionStatus.COMPLETED_YES)
48: .initCause(e);
49: }
50: }
51: }
|