001 /** 002 * 003 * Licensed to the Apache Software Foundation (ASF) under one or more 004 * contributor license agreements. See the NOTICE file distributed with 005 * this work for additional information regarding copyright ownership. 006 * The ASF licenses this file to You under the Apache License, Version 2.0 007 * (the "License"); you may not use this file except in compliance with 008 * the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018 019 package org.apache.geronimo.yoko; 020 021 import org.apache.geronimo.corba.CorbaApplicationServer; 022 import org.apache.openejb.core.ServerFederation; 023 import org.apache.openejb.spi.ApplicationServer; 024 import org.apache.yoko.rmi.impl.MethodDescriptor; 025 import org.apache.yoko.rmi.impl.RMIStub; 026 027 /** 028 * This class is the InvocationHandler for instances of POAStub. When a client 029 * calls a remote method, this is translated to a call to the invoke() method in 030 * this class. 031 */ 032 public class RMIStubHandler extends org.apache.yoko.rmi.impl.RMIStubHandler { 033 // the application server singleton 034 private static CorbaApplicationServer corbaApplicationServer = new CorbaApplicationServer(); 035 036 public Object invoke(RMIStub stub, MethodDescriptor method, Object[] args) throws Throwable { 037 // object types must bbe written in the context of the corba application server 038 // which properly write replaces our objects for corba 039 ApplicationServer oldApplicationServer = ServerFederation.getApplicationServer(); 040 041 ServerFederation.setApplicationServer(corbaApplicationServer); 042 043 try { 044 // let the super class handle everything. We just need to wrap the context 045 return super.invoke(stub, method, args); 046 047 } finally { 048 ServerFederation.setApplicationServer(oldApplicationServer); 049 } 050 } 051 052 } 053