src/share/classes/com/sun/corba/se/impl/io/FVDCodeBaseImpl.java

Mon, 16 Oct 2017 15:59:03 +0800

author
aoqi
date
Mon, 16 Oct 2017 15:59:03 +0800
changeset 1022
6081f57a0021
parent 748
6845b95cba6b
permissions
-rw-r--r--

merge

     1 /*
     2  * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     8  * particular file as subject to the "Classpath" exception as provided
     9  * by Oracle in the LICENSE file that accompanied this code.
    10  *
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    14  * version 2 for more details (a copy is included in the LICENSE file that
    15  * accompanied this code).
    16  *
    17  * You should have received a copy of the GNU General Public License version
    18  * 2 along with this work; if not, write to the Free Software Foundation,
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    20  *
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    22  * or visit www.oracle.com if you need additional information or have any
    23  * questions.
    24  */
    25 /*
    26  * Licensed Materials - Property of IBM
    27  * RMI-IIOP v1.0
    28  * Copyright IBM Corp. 1998 1999  All Rights Reserved
    29  *
    30  */
    32 package com.sun.corba.se.impl.io;
    34 import org.omg.CORBA.ORB;
    35 import java.util.Properties;
    36 import javax.rmi.CORBA.Util;
    37 import javax.rmi.CORBA.ValueHandler;
    38 import java.util.Hashtable;
    39 import java.util.Stack;
    41 import com.sun.org.omg.CORBA.ValueDefPackage.FullValueDescription;
    42 import com.sun.org.omg.SendingContext._CodeBaseImplBase;
    43 import com.sun.org.omg.SendingContext.CodeBase;
    44 import com.sun.org.omg.SendingContext.CodeBaseHelper;
    45 import org.omg.CORBA.CompletionStatus;
    46 import org.omg.CORBA.ORB;
    48 import com.sun.corba.se.impl.logging.OMGSystemException;
    49 import com.sun.corba.se.spi.logging.CORBALogDomains;
    51 /**
    52  * This class acts as the remote interface to receivers wishing to retrieve
    53  * the information of a remote Class.
    54  */
    55 public class FVDCodeBaseImpl extends _CodeBaseImplBase
    56 {
    57     // Contains rep. ids as keys to FullValueDescriptions
    58     private static Hashtable fvds = new Hashtable();
    60     // Private ORBSingleton used when we need an ORB while not
    61     // having a delegate set.
    62     private transient ORB orb = null;
    64     private transient OMGSystemException wrapper = OMGSystemException.get(
    65         CORBALogDomains.RPC_ENCODING ) ;
    67     // backward compatability so that appropriate rep-id calculations
    68     // can take place
    69     // this needs to be transient to prevent serialization during
    70     // marshalling/unmarshalling
    71     private transient ValueHandlerImpl vhandler = null;
    73     void setValueHandler(ValueHandler vh)
    74     {
    75         vhandler = (com.sun.corba.se.impl.io.ValueHandlerImpl) vh;
    76     }
    78     // Operation to obtain the IR from the sending context
    79     public com.sun.org.omg.CORBA.Repository get_ir (){
    80         return null;
    81     }
    83     // Operations to obtain a URL to the implementation code
    84     public String implementation (String x){
    85         try{
    86             // default to using the current ORB version in case the
    87             // vhandler is not set
    88             if (vhandler == null) {
    89                 vhandler = ValueHandlerImpl.getInstance(false);
    90             }
    92             // Util.getCodebase may return null which would
    93             // cause a BAD_PARAM exception.
    94             String result = Util.getCodebase(vhandler.getClassFromType(x));
    95             if (result == null)
    96                 return "";
    97             else
    98                 return result;
    99         } catch(ClassNotFoundException cnfe){
   100             throw wrapper.missingLocalValueImpl( CompletionStatus.COMPLETED_MAYBE,
   101                 cnfe ) ;
   102         }
   103     }
   105     public String[] implementations (String[] x){
   106         String result[] = new String[x.length];
   108         for (int i = 0; i < x.length; i++)
   109             result[i] = implementation(x[i]);
   111         return result;
   112     }
   114     // the same information
   115     public FullValueDescription meta (String x){
   116         try{
   117             FullValueDescription result = (FullValueDescription)fvds.get(x);
   119             if (result == null) {
   120                 // default to using the current ORB version in case the
   121                 // vhandler is not set
   122                 if (vhandler == null) {
   123                     vhandler = ValueHandlerImpl.getInstance(false);
   124                 }
   126                 try{
   127                     result = ValueUtility.translate(_orb(),
   128                         ObjectStreamClass.lookup(vhandler.getAnyClassFromType(x)), vhandler);
   129                 } catch(Throwable t){
   130                     if (orb == null)
   131                         orb = ORB.init(); //d11638
   132                     result = ValueUtility.translate(orb,
   133                         ObjectStreamClass.lookup(vhandler.getAnyClassFromType(x)), vhandler);
   134                 }
   136                 if (result != null){
   137                     fvds.put(x, result);
   138                 } else {
   139                     throw wrapper.missingLocalValueImpl( CompletionStatus.COMPLETED_MAYBE);
   140                 }
   141             }
   143             return result;
   144         } catch(Throwable t){
   145             throw wrapper.incompatibleValueImpl(CompletionStatus.COMPLETED_MAYBE,t);
   146         }
   147     }
   149     public FullValueDescription[] metas (String[] x){
   150         FullValueDescription descriptions[] = new FullValueDescription[x.length];
   152         for (int i = 0; i < x.length; i++)
   153             descriptions[i] = meta(x[i]);
   155         return descriptions;
   156     }
   158     // information
   159     public String[] bases (String x){
   160         try {
   161             // default to using the current ORB version in case the
   162             // vhandler is not set
   163             if (vhandler == null) {
   164                 vhandler = ValueHandlerImpl.getInstance(false);
   165             }
   167             Stack repIds = new Stack();
   168             Class parent = ObjectStreamClass.lookup(vhandler.getClassFromType(x)).forClass().getSuperclass();
   170             while (!parent.equals(java.lang.Object.class)) {
   171                 repIds.push(vhandler.createForAnyType(parent));
   172                 parent = parent.getSuperclass();
   173             }
   175             String result[] = new String[repIds.size()];
   176             for (int i = result.length - 1; i >= 0; i++)
   177                 result[i] = (String)repIds.pop();
   179             return result;
   180         } catch (Throwable t) {
   181             throw wrapper.missingLocalValueImpl( CompletionStatus.COMPLETED_MAYBE, t );
   182         }
   183     }
   184 }

mercurial