Sat, 01 Dec 2007 00:00:00 +0000
Initial load
duke@1 | 1 | /* |
duke@1 | 2 | * Copyright 2002-2003 Sun Microsystems, Inc. All Rights Reserved. |
duke@1 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@1 | 4 | * |
duke@1 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@1 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@1 | 7 | * published by the Free Software Foundation. Sun designates this |
duke@1 | 8 | * particular file as subject to the "Classpath" exception as provided |
duke@1 | 9 | * by Sun in the LICENSE file that accompanied this code. |
duke@1 | 10 | * |
duke@1 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@1 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@1 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@1 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@1 | 15 | * accompanied this code). |
duke@1 | 16 | * |
duke@1 | 17 | * You should have received a copy of the GNU General Public License version |
duke@1 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@1 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@1 | 20 | * |
duke@1 | 21 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
duke@1 | 22 | * CA 95054 USA or visit www.sun.com if you need additional information or |
duke@1 | 23 | * have any questions. |
duke@1 | 24 | */ |
duke@1 | 25 | |
duke@1 | 26 | package com.sun.corba.se.impl.oa.toa ; |
duke@1 | 27 | |
duke@1 | 28 | import java.util.Map ; |
duke@1 | 29 | import java.util.HashMap ; |
duke@1 | 30 | |
duke@1 | 31 | import org.omg.CORBA.INTERNAL ; |
duke@1 | 32 | import org.omg.CORBA.CompletionStatus ; |
duke@1 | 33 | |
duke@1 | 34 | import com.sun.corba.se.spi.oa.ObjectAdapterFactory ; |
duke@1 | 35 | import com.sun.corba.se.spi.oa.ObjectAdapter ; |
duke@1 | 36 | |
duke@1 | 37 | import com.sun.corba.se.spi.orb.ORB ; |
duke@1 | 38 | |
duke@1 | 39 | import com.sun.corba.se.spi.ior.ObjectAdapterId ; |
duke@1 | 40 | |
duke@1 | 41 | import com.sun.corba.se.impl.oa.toa.TOAImpl ; |
duke@1 | 42 | import com.sun.corba.se.impl.oa.toa.TransientObjectManager ; |
duke@1 | 43 | |
duke@1 | 44 | import com.sun.corba.se.impl.javax.rmi.CORBA.Util ; |
duke@1 | 45 | |
duke@1 | 46 | import com.sun.corba.se.impl.ior.ObjectKeyTemplateBase ; |
duke@1 | 47 | |
duke@1 | 48 | import com.sun.corba.se.spi.logging.CORBALogDomains ; |
duke@1 | 49 | import com.sun.corba.se.impl.logging.ORBUtilSystemException ; |
duke@1 | 50 | |
duke@1 | 51 | public class TOAFactory implements ObjectAdapterFactory |
duke@1 | 52 | { |
duke@1 | 53 | private ORB orb ; |
duke@1 | 54 | private ORBUtilSystemException wrapper ; |
duke@1 | 55 | |
duke@1 | 56 | private TOAImpl toa ; |
duke@1 | 57 | private Map codebaseToTOA ; |
duke@1 | 58 | private TransientObjectManager tom ; |
duke@1 | 59 | |
duke@1 | 60 | public ObjectAdapter find ( ObjectAdapterId oaid ) |
duke@1 | 61 | { |
duke@1 | 62 | if (oaid.equals( ObjectKeyTemplateBase.JIDL_OAID ) ) |
duke@1 | 63 | // Return the dispatch-only TOA, which can dispatch |
duke@1 | 64 | // request for objects created by any TOA. |
duke@1 | 65 | return getTOA() ; |
duke@1 | 66 | else |
duke@1 | 67 | throw wrapper.badToaOaid() ; |
duke@1 | 68 | } |
duke@1 | 69 | |
duke@1 | 70 | public void init( ORB orb ) |
duke@1 | 71 | { |
duke@1 | 72 | this.orb = orb ; |
duke@1 | 73 | wrapper = ORBUtilSystemException.get( orb, |
duke@1 | 74 | CORBALogDomains.OA_LIFECYCLE ) ; |
duke@1 | 75 | tom = new TransientObjectManager( orb ) ; |
duke@1 | 76 | codebaseToTOA = new HashMap() ; |
duke@1 | 77 | } |
duke@1 | 78 | |
duke@1 | 79 | public void shutdown( boolean waitForCompletion ) |
duke@1 | 80 | { |
duke@1 | 81 | if (Util.instance != null) { |
duke@1 | 82 | Util.instance.unregisterTargetsForORB(orb); |
duke@1 | 83 | } |
duke@1 | 84 | } |
duke@1 | 85 | |
duke@1 | 86 | public synchronized TOA getTOA( String codebase ) |
duke@1 | 87 | { |
duke@1 | 88 | TOA toa = (TOA)(codebaseToTOA.get( codebase )) ; |
duke@1 | 89 | if (toa == null) { |
duke@1 | 90 | toa = new TOAImpl( orb, tom, codebase ) ; |
duke@1 | 91 | |
duke@1 | 92 | codebaseToTOA.put( codebase, toa ) ; |
duke@1 | 93 | } |
duke@1 | 94 | |
duke@1 | 95 | return toa ; |
duke@1 | 96 | } |
duke@1 | 97 | |
duke@1 | 98 | public synchronized TOA getTOA() |
duke@1 | 99 | { |
duke@1 | 100 | if (toa == null) |
duke@1 | 101 | // The dispatch-only TOA is not used for creating |
duke@1 | 102 | // objrefs, so its codebase can be null (and must |
duke@1 | 103 | // be, since we do not have a servant at this point) |
duke@1 | 104 | toa = new TOAImpl( orb, tom, null ) ; |
duke@1 | 105 | |
duke@1 | 106 | return toa ; |
duke@1 | 107 | } |
duke@1 | 108 | |
duke@1 | 109 | public ORB getORB() |
duke@1 | 110 | { |
duke@1 | 111 | return orb ; |
duke@1 | 112 | } |
duke@1 | 113 | } ; |