src/share/classes/com/sun/corba/se/impl/orb/ORBSingleton.java

Mon, 28 May 2018 10:29:43 +0800

author
aoqi
date
Mon, 28 May 2018 10:29:43 +0800
changeset 1655
bfd167e38830
parent 1618
4145ba26d9ff
parent 748
6845b95cba6b
permissions
-rw-r--r--

Merge

     1 /*
     2  * Copyright (c) 1997, 2017, 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.orb;
    34 import java.util.Properties;
    36 import java.applet.Applet;
    38 import java.net.URL;
    40 import org.omg.CORBA.ORBPackage.InvalidName;
    41 import org.omg.CORBA.NVList;
    42 import org.omg.CORBA.TCKind;
    43 import org.omg.CORBA.NO_IMPLEMENT;
    44 import org.omg.CORBA.Request;
    45 import org.omg.CORBA.TypeCode;
    46 import org.omg.CORBA.Any;
    47 import org.omg.CORBA.StructMember;
    48 import org.omg.CORBA.UnionMember;
    49 import org.omg.CORBA.ValueMember;
    50 import org.omg.CORBA.Policy;
    51 import org.omg.CORBA.PolicyError;
    53 import org.omg.CORBA.portable.OutputStream;
    55 import com.sun.corba.se.pept.protocol.ClientInvocationInfo ;
    56 import com.sun.corba.se.pept.transport.ContactInfo;
    57 import com.sun.corba.se.pept.transport.ConnectionCache;
    58 import com.sun.corba.se.pept.transport.Selector ;
    59 import com.sun.corba.se.pept.transport.TransportManager;
    61 import com.sun.corba.se.spi.orb.ORBData;
    62 import com.sun.corba.se.spi.orb.Operation;
    63 import com.sun.corba.se.spi.orb.ORB;
    64 import com.sun.corba.se.spi.orb.ORBVersion;
    65 import com.sun.corba.se.spi.orb.ORBVersionFactory;
    66 import com.sun.corba.se.spi.oa.OAInvocationInfo;
    67 import com.sun.corba.se.spi.protocol.ClientDelegateFactory;
    68 import com.sun.corba.se.spi.protocol.RequestDispatcherRegistry;
    69 import com.sun.corba.se.spi.protocol.CorbaServerRequestDispatcher;
    70 import com.sun.corba.se.spi.protocol.PIHandler;
    71 import com.sun.corba.se.spi.resolver.Resolver;
    72 import com.sun.corba.se.spi.resolver.LocalResolver;
    73 import com.sun.corba.se.spi.ior.IOR;
    74 import com.sun.corba.se.spi.ior.IdentifiableFactoryFinder;
    75 import com.sun.corba.se.spi.ior.TaggedComponentFactoryFinder;
    76 import com.sun.corba.se.spi.ior.ObjectKey;
    77 import com.sun.corba.se.spi.ior.ObjectKeyFactory;
    78 import com.sun.corba.se.spi.ior.iiop.GIOPVersion;
    79 import com.sun.corba.se.spi.transport.CorbaContactInfoListFactory ;
    80 import com.sun.corba.se.spi.transport.CorbaTransportManager;
    81 import com.sun.corba.se.spi.legacy.connection.LegacyServerSocketManager;
    82 import com.sun.corba.se.spi.orbutil.closure.Closure;
    83 import com.sun.corba.se.spi.orbutil.threadpool.ThreadPoolManager;
    84 import com.sun.corba.se.spi.copyobject.CopierManager;
    85 import com.sun.corba.se.spi.presentation.rmi.PresentationManager;
    86 import com.sun.corba.se.spi.presentation.rmi.PresentationDefaults;
    88 import com.sun.corba.se.spi.servicecontext.ServiceContextRegistry;
    90 import com.sun.corba.se.impl.corba.TypeCodeImpl;
    91 import com.sun.corba.se.impl.corba.NVListImpl;
    92 import com.sun.corba.se.impl.corba.NamedValueImpl;
    93 import com.sun.corba.se.impl.corba.ExceptionListImpl;
    94 import com.sun.corba.se.impl.corba.ContextListImpl;
    95 import com.sun.corba.se.impl.corba.EnvironmentImpl;
    96 import com.sun.corba.se.impl.corba.AnyImpl;
    97 import com.sun.corba.se.impl.encoding.BufferManagerFactory;
    98 import com.sun.corba.se.impl.encoding.CodeSetComponentInfo;
    99 import com.sun.corba.se.impl.oa.poa.BadServerIdHandler;
   100 import com.sun.corba.se.impl.orbutil.ORBConstants;
   101 import com.sun.corba.se.spi.legacy.connection.LegacyServerSocketEndPointInfo;
   103 /*
   104  * The restricted singleton ORB implementation.
   105  *
   106  * For now, this class must implement just enough functionality to be
   107  * used as a factory for immutable TypeCode instances.
   108  *
   109  * See ORBImpl.java for the real ORB implementation.
   110  */
   111 public class ORBSingleton extends ORB
   112 {
   113     // This is used to support read_Object.
   114     private ORB fullORB;
   115     private static PresentationManager.StubFactoryFactory staticStubFactoryFactory =
   116         PresentationDefaults.getStaticStubFactoryFactory() ;
   118     public void set_parameters( Properties props ) {
   119     }
   121     protected void set_parameters(Applet app, Properties props) {
   122     }
   124     protected void set_parameters (String params[], Properties props) {
   125     }
   127     public OutputStream create_output_stream() {
   128         return sun.corba.OutputStreamFactory.newEncapsOutputStream(this);
   129     }
   131     public TypeCode create_struct_tc(String id,
   132                                      String name,
   133                                      StructMember[] members)
   134     {
   135         return new TypeCodeImpl(this, TCKind._tk_struct, id, name, members);
   136     }
   138     public TypeCode create_union_tc(String id,
   139                                     String name,
   140                                     TypeCode discriminator_type,
   141                                     UnionMember[] members)
   142     {
   143         return new TypeCodeImpl(this,
   144                                 TCKind._tk_union,
   145                                 id,
   146                                 name,
   147                                 discriminator_type,
   148                                 members);
   149     }
   151     public TypeCode create_enum_tc(String id,
   152                                    String name,
   153                                    String[] members)
   154     {
   155         return new TypeCodeImpl(this, TCKind._tk_enum, id, name, members);
   156     }
   158     public TypeCode create_alias_tc(String id,
   159                                     String name,
   160                                     TypeCode original_type)
   161     {
   162         return new TypeCodeImpl(this, TCKind._tk_alias, id, name, original_type);
   163     }
   165     public TypeCode create_exception_tc(String id,
   166                                         String name,
   167                                         StructMember[] members)
   168     {
   169         return new TypeCodeImpl(this, TCKind._tk_except, id, name, members);
   170     }
   172     public TypeCode create_interface_tc(String id,
   173                                         String name)
   174     {
   175         return new TypeCodeImpl(this, TCKind._tk_objref, id, name);
   176     }
   178     public TypeCode create_string_tc(int bound) {
   179         return new TypeCodeImpl(this, TCKind._tk_string, bound);
   180     }
   182     public TypeCode create_wstring_tc(int bound) {
   183         return new TypeCodeImpl(this, TCKind._tk_wstring, bound);
   184     }
   186     public TypeCode create_sequence_tc(int bound,
   187                                        TypeCode element_type)
   188     {
   189         return new TypeCodeImpl(this, TCKind._tk_sequence, bound, element_type);
   190     }
   192     public TypeCode create_recursive_sequence_tc(int bound,
   193                                                  int offset)
   194     {
   195         return new TypeCodeImpl(this, TCKind._tk_sequence, bound, offset);
   196     }
   198     public TypeCode create_array_tc(int length,
   199                                     TypeCode element_type)
   200     {
   201         return new TypeCodeImpl(this, TCKind._tk_array, length, element_type);
   202     }
   204     public org.omg.CORBA.TypeCode create_native_tc(String id,
   205                                                    String name)
   206     {
   207         return new TypeCodeImpl(this, TCKind._tk_native, id, name);
   208     }
   210     public org.omg.CORBA.TypeCode create_abstract_interface_tc(
   211                                                                String id,
   212                                                                String name)
   213     {
   214         return new TypeCodeImpl(this, TCKind._tk_abstract_interface, id, name);
   215     }
   217     public org.omg.CORBA.TypeCode create_fixed_tc(short digits, short scale)
   218     {
   219         return new TypeCodeImpl(this, TCKind._tk_fixed, digits, scale);
   220     }
   222     // orbos 98-01-18: Objects By Value -- begin
   224     public org.omg.CORBA.TypeCode create_value_tc(String id,
   225                                                   String name,
   226                                                   short type_modifier,
   227                                                   TypeCode concrete_base,
   228                                                   ValueMember[] members)
   229     {
   230         return new TypeCodeImpl(this, TCKind._tk_value, id, name,
   231                                 type_modifier, concrete_base, members);
   232     }
   234     public org.omg.CORBA.TypeCode create_recursive_tc(String id) {
   235         return new TypeCodeImpl(this, id);
   236     }
   238     public org.omg.CORBA.TypeCode create_value_box_tc(String id,
   239                                                       String name,
   240                                                       TypeCode boxed_type)
   241     {
   242         return new TypeCodeImpl(this, TCKind._tk_value_box, id, name, boxed_type);
   243     }
   245     public TypeCode get_primitive_tc( TCKind tckind )
   246     {
   247         return get_primitive_tc( tckind.value() ) ;
   248     }
   250     public Any create_any() {
   251         return new AnyImpl(this);
   252     }
   254     // TypeCodeFactory interface methods.
   255     // Keeping track of type codes by repository id.
   256     /*
   257      * Not strictly needed for TypeCode factory duty but these seem
   258      * harmless enough.
   259      */
   261     public NVList create_list(int count) {
   262         return new NVListImpl(this, count);
   263     }
   265     public org.omg.CORBA.NVList
   266         create_operation_list(org.omg.CORBA.Object oper) {
   267         throw wrapper.genericNoImpl() ;
   268     }
   270     public org.omg.CORBA.NamedValue
   271         create_named_value(String s, Any any, int flags) {
   272         return new NamedValueImpl(this, s, any, flags);
   273     }
   275     public org.omg.CORBA.ExceptionList create_exception_list() {
   276         return new ExceptionListImpl();
   277     }
   279     public org.omg.CORBA.ContextList create_context_list() {
   280         return new ContextListImpl(this);
   281     }
   283     public org.omg.CORBA.Context get_default_context()
   284     {
   285         throw wrapper.genericNoImpl() ;
   286     }
   288     public org.omg.CORBA.Environment create_environment()
   289     {
   290         return new EnvironmentImpl();
   291     }
   293     public org.omg.CORBA.Current get_current()
   294     {
   295         throw wrapper.genericNoImpl() ;
   296     }
   298     /*
   299      * Things that aren't allowed.
   300      */
   302     public String[] list_initial_services ()
   303     {
   304         throw wrapper.genericNoImpl() ;
   305     }
   307     public org.omg.CORBA.Object resolve_initial_references(String identifier)
   308         throws InvalidName
   309     {
   310         throw wrapper.genericNoImpl() ;
   311     }
   313     public void register_initial_reference(
   314         String id, org.omg.CORBA.Object obj ) throws InvalidName
   315     {
   316         throw wrapper.genericNoImpl() ;
   317     }
   319     public void send_multiple_requests_oneway(Request[] req) {
   320         throw new SecurityException("ORBSingleton: access denied");
   321     }
   323     public void send_multiple_requests_deferred(Request[] req) {
   324         throw new SecurityException("ORBSingleton: access denied");
   325     }
   327     public boolean poll_next_response() {
   328         throw new SecurityException("ORBSingleton: access denied");
   329     }
   331     public org.omg.CORBA.Request get_next_response() {
   332         throw new SecurityException("ORBSingleton: access denied");
   333     }
   335     public String object_to_string(org.omg.CORBA.Object obj) {
   336         throw new SecurityException("ORBSingleton: access denied");
   337     }
   339     public org.omg.CORBA.Object string_to_object(String s) {
   340         throw new SecurityException("ORBSingleton: access denied");
   341     }
   343     public java.rmi.Remote string_to_remote(String s)
   344         throws java.rmi.RemoteException
   345     {
   346         throw new SecurityException("ORBSingleton: access denied");
   347     }
   349     public void connect(org.omg.CORBA.Object servant) {
   350         throw new SecurityException("ORBSingleton: access denied");
   351     }
   353     public void disconnect(org.omg.CORBA.Object obj) {
   354         throw new SecurityException("ORBSingleton: access denied");
   355     }
   357     public void run()
   358     {
   359         throw new SecurityException("ORBSingleton: access denied");
   360     }
   362     public void shutdown(boolean wait_for_completion)
   363     {
   364         throw new SecurityException("ORBSingleton: access denied");
   365     }
   367     protected void shutdownServants(boolean wait_for_completion) {
   368         throw new SecurityException("ORBSingleton: access denied");
   369     }
   371     protected void destroyConnections() {
   372         throw new SecurityException("ORBSingleton: access denied");
   373     }
   375     public void destroy() {
   376         throw new SecurityException("ORBSingleton: access denied");
   377     }
   379     public boolean work_pending()
   380     {
   381         throw new SecurityException("ORBSingleton: access denied");
   382     }
   384     public void perform_work()
   385     {
   386         throw new SecurityException("ORBSingleton: access denied");
   387     }
   389     public org.omg.CORBA.portable.ValueFactory register_value_factory(String repositoryID,
   390                                 org.omg.CORBA.portable.ValueFactory factory)
   391     {
   392         throw new SecurityException("ORBSingleton: access denied");
   393     }
   395     public void unregister_value_factory(String repositoryID)
   396     {
   397         throw new SecurityException("ORBSingleton: access denied");
   398     }
   400     public org.omg.CORBA.portable.ValueFactory lookup_value_factory(String repositoryID)
   401     {
   402         throw new SecurityException("ORBSingleton: access denied");
   403     }
   405     public TransportManager getTransportManager()
   406     {
   407         throw new SecurityException("ORBSingleton: access denied");
   408     }
   410     public CorbaTransportManager getCorbaTransportManager()
   411     {
   412         throw new SecurityException("ORBSingleton: access denied");
   413     }
   415     public LegacyServerSocketManager getLegacyServerSocketManager()
   416     {
   417         throw new SecurityException("ORBSingleton: access denied");
   418     }
   420 /*************************************************************************
   421     These are methods from com.sun.corba.se.impl.se.core.ORB
   422  ************************************************************************/
   424     private synchronized ORB getFullORB()
   425     {
   426         if (fullORB == null) {
   427             Properties props = new Properties() ;
   428             fullORB = new ORBImpl() ;
   429             fullORB.set_parameters( props ) ;
   430         }
   432         return fullORB ;
   433     }
   435     public RequestDispatcherRegistry getRequestDispatcherRegistry()
   436     {
   437         // To enable read_Object.
   439         return getFullORB().getRequestDispatcherRegistry();
   440     }
   442     /**
   443      * Return the service context registry
   444      */
   445     public ServiceContextRegistry getServiceContextRegistry()
   446     {
   447         throw new SecurityException("ORBSingleton: access denied");
   448     }
   450     /**
   451      * Get the transient server ID
   452      */
   453     public int getTransientServerId()
   454     {
   455         throw new SecurityException("ORBSingleton: access denied");
   456     }
   458     /**
   459      * Return the bootstrap naming port specified in the ORBInitialPort param.
   460      */
   461     public int getORBInitialPort()
   462     {
   463         throw new SecurityException("ORBSingleton: access denied");
   464     }
   466     /**
   467      * Return the bootstrap naming host specified in the ORBInitialHost param.
   468      */
   469     public String getORBInitialHost()
   470     {
   471         throw new SecurityException("ORBSingleton: access denied");
   472     }
   474     public String getORBServerHost()
   475     {
   476         throw new SecurityException("ORBSingleton: access denied");
   477     }
   479     public int getORBServerPort()
   480     {
   481         throw new SecurityException("ORBSingleton: access denied");
   482     }
   484     public CodeSetComponentInfo getCodeSetComponentInfo()
   485     {
   486             return new CodeSetComponentInfo();
   487     }
   489     public boolean isLocalHost( String host )
   490     {
   491         // To enable read_Object.
   492         return false;
   493     }
   495     public boolean isLocalServerId( int subcontractId, int serverId )
   496     {
   497         // To enable read_Object.
   498         return false;
   499     }
   501     /*
   502      * Things from corba.ORB.
   503      */
   505     public ORBVersion getORBVersion()
   506     {
   507         // Always use our latest ORB version (latest fixes, etc)
   508         return ORBVersionFactory.getORBVersion();
   509     }
   511     public void setORBVersion(ORBVersion verObj)
   512     {
   513         throw new SecurityException("ORBSingleton: access denied");
   514     }
   516     public String getAppletHost()
   517     {
   518         throw new SecurityException("ORBSingleton: access denied");
   519     }
   521     public URL getAppletCodeBase()
   522     {
   523         throw new SecurityException("ORBSingleton: access denied");
   524     }
   526     public int getHighWaterMark(){
   527         throw new SecurityException("ORBSingleton: access denied");
   528     }
   530     public int getLowWaterMark(){
   531         throw new SecurityException("ORBSingleton: access denied");
   532     }
   534     public int getNumberToReclaim(){
   535         throw new SecurityException("ORBSingleton: access denied");
   536     }
   538     public int getGIOPFragmentSize() {
   539         return ORBConstants.GIOP_DEFAULT_BUFFER_SIZE;
   540     }
   542     public int getGIOPBuffMgrStrategy(GIOPVersion gv) {
   543         return BufferManagerFactory.GROW;
   544     }
   546     public IOR getFVDCodeBaseIOR(){
   547         throw new SecurityException("ORBSingleton: access denied");
   548     }
   550     public Policy create_policy( int type, Any val ) throws PolicyError
   551     {
   552         throw new NO_IMPLEMENT();
   553     }
   555     public LegacyServerSocketEndPointInfo getServerEndpoint()
   556     {
   557         return null ;
   558     }
   560     public void setPersistentServerId( int id )
   561     {
   562     }
   564     public TypeCodeImpl getTypeCodeForClass( Class c )
   565     {
   566         return null ;
   567     }
   569     public void setTypeCodeForClass( Class c, TypeCodeImpl tcimpl )
   570     {
   571     }
   573     public boolean alwaysSendCodeSetServiceContext()
   574     {
   575         return true ;
   576     }
   578     public boolean isDuringDispatch()
   579     {
   580         return false ;
   581     }
   583     public void notifyORB() { }
   585     public PIHandler getPIHandler()
   586     {
   587         return null ;
   588     }
   590     public void checkShutdownState()
   591     {
   592     }
   594     public void startingDispatch()
   595     {
   596     }
   598     public void finishedDispatch()
   599     {
   600     }
   602     public void registerInitialReference( String id, Closure closure )
   603     {
   604     }
   606     public ORBData getORBData()
   607     {
   608         return getFullORB().getORBData() ;
   609     }
   611     public void setClientDelegateFactory( ClientDelegateFactory factory )
   612     {
   613     }
   615     public ClientDelegateFactory getClientDelegateFactory()
   616     {
   617         return getFullORB().getClientDelegateFactory() ;
   618     }
   620     public void setCorbaContactInfoListFactory( CorbaContactInfoListFactory factory )
   621     {
   622     }
   624     public CorbaContactInfoListFactory getCorbaContactInfoListFactory()
   625     {
   626         return getFullORB().getCorbaContactInfoListFactory() ;
   627     }
   629     public Operation getURLOperation()
   630     {
   631         return null ;
   632     }
   634     public void setINSDelegate( CorbaServerRequestDispatcher sdel )
   635     {
   636     }
   638     public TaggedComponentFactoryFinder getTaggedComponentFactoryFinder()
   639     {
   640         return getFullORB().getTaggedComponentFactoryFinder() ;
   641     }
   643     public IdentifiableFactoryFinder getTaggedProfileFactoryFinder()
   644     {
   645         return getFullORB().getTaggedProfileFactoryFinder() ;
   646     }
   648     public IdentifiableFactoryFinder getTaggedProfileTemplateFactoryFinder()
   649     {
   650         return getFullORB().getTaggedProfileTemplateFactoryFinder() ;
   651     }
   653     public ObjectKeyFactory getObjectKeyFactory()
   654     {
   655         return getFullORB().getObjectKeyFactory() ;
   656     }
   658     public void setObjectKeyFactory( ObjectKeyFactory factory )
   659     {
   660         throw new SecurityException("ORBSingleton: access denied");
   661     }
   663     public void handleBadServerId( ObjectKey okey )
   664     {
   665     }
   667     public OAInvocationInfo peekInvocationInfo()
   668     {
   669         return null ;
   670     }
   672     public void pushInvocationInfo( OAInvocationInfo info )
   673     {
   674     }
   676     public OAInvocationInfo popInvocationInfo()
   677     {
   678         return null ;
   679     }
   681     public ClientInvocationInfo createOrIncrementInvocationInfo()
   682     {
   683         return null ;
   684     }
   686     public void releaseOrDecrementInvocationInfo()
   687     {
   688     }
   690     public ClientInvocationInfo getInvocationInfo()
   691     {
   692         return null ;
   693     }
   695     public ConnectionCache getConnectionCache(ContactInfo contactInfo)
   696     {
   697         return null;
   698     }
   700     public void setResolver( Resolver resolver )
   701     {
   702     }
   704     public Resolver getResolver()
   705     {
   706         return null ;
   707     }
   709     public void setLocalResolver( LocalResolver resolver )
   710     {
   711     }
   713     public LocalResolver getLocalResolver()
   714     {
   715         return null ;
   716     }
   718     public void setURLOperation( Operation stringToObject )
   719     {
   720     }
   722     // NOTE: REMOVE THIS METHOD ONCE WE HAVE A ORT BASED ORBD
   723     public void setBadServerIdHandler( BadServerIdHandler handler )
   724     {
   725     }
   727     // NOTE: REMOVE THIS METHOD ONCE WE HAVE A ORT BASED ORBD
   728     public void initBadServerIdHandler()
   729     {
   730     }
   732     public Selector getSelector(int x)
   733     {
   734         return null;
   735     }
   737     public void setThreadPoolManager(ThreadPoolManager mgr) {
   738     }
   740     public ThreadPoolManager getThreadPoolManager() {
   741         return null;
   742     }
   744     public CopierManager getCopierManager() {
   745         return null ;
   746     }
   748     @Override
   749     public void validateIORClass(String iorClassName) {
   750         getFullORB().validateIORClass(iorClassName);
   751     }
   753 }
   755 // End of file.

mercurial