01: /**
02: *
03: * Licensed to the Apache Software Foundation (ASF) under one or more
04: * contributor license agreements. See the NOTICE file distributed with
05: * this work for additional information regarding copyright ownership.
06: * The ASF licenses this file to You under the Apache License, Version 2.0
07: * (the "License"); you may not use this file except in compliance with
08: * the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */package org.apache.geronimo.yoko;
18:
19: import org.apache.geronimo.corba.CorbaApplicationServer;
20: import org.apache.openejb.core.ServerFederation;
21: import org.apache.openejb.spi.ApplicationServer;
22: import org.apache.yoko.rmi.impl.MethodDescriptor;
23: import org.apache.yoko.rmi.impl.RMIStub;
24:
25: /**
26: * This class is the InvocationHandler for instances of POAStub. When a client
27: * calls a remote method, this is translated to a call to the invoke() method in
28: * this class.
29: */
30: public class RMIStubHandler extends
31: org.apache.yoko.rmi.impl.RMIStubHandler {
32: // the application server singleton
33: private static CorbaApplicationServer corbaApplicationServer = new CorbaApplicationServer();
34:
35: public Object invoke(RMIStub stub, MethodDescriptor method,
36: Object[] args) throws Throwable {
37: // object types must bbe written in the context of the corba application server
38: // which properly write replaces our objects for corba
39: ApplicationServer oldApplicationServer = ServerFederation
40: .getApplicationServer();
41:
42: ServerFederation.setApplicationServer(corbaApplicationServer);
43:
44: try {
45: // let the super class handle everything. We just need to wrap the context
46: return super.invoke(stub, method, args);
47:
48: } finally {
49: ServerFederation.setApplicationServer(oldApplicationServer);
50: }
51: }
52:
53: }
|