Thu, 31 Aug 2017 18:10:36 +0800
merge
1 /*
2 * Copyright (c) 1997, 2013, 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.Collection;
35 import java.util.Properties;
36 import java.util.Hashtable;
38 import java.applet.Applet;
40 import java.net.URL;
42 import java.io.IOException ;
44 import java.util.logging.Logger ;
46 import org.omg.CORBA.Context;
47 import org.omg.CORBA.ContextList;
48 import org.omg.CORBA.Environment;
49 import org.omg.CORBA.ExceptionList;
50 import org.omg.CORBA.ORBPackage.InvalidName;
51 import org.omg.CORBA.NVList;
52 import org.omg.CORBA.TCKind;
53 import org.omg.CORBA.NamedValue;
54 import org.omg.CORBA.NO_IMPLEMENT;
55 import org.omg.CORBA.Object;
56 import org.omg.CORBA.Request;
57 import org.omg.CORBA.TypeCode;
58 import org.omg.CORBA.Any;
59 import org.omg.CORBA.StructMember;
60 import org.omg.CORBA.UnionMember;
61 import org.omg.CORBA.ValueMember;
62 import org.omg.CORBA.Policy;
63 import org.omg.CORBA.PolicyError;
65 import org.omg.CORBA.portable.OutputStream;
66 import org.omg.CORBA.portable.RemarshalException;
68 import com.sun.corba.se.pept.protocol.ClientInvocationInfo ;
69 import com.sun.corba.se.pept.transport.ContactInfo;
70 import com.sun.corba.se.pept.transport.ConnectionCache;
71 import com.sun.corba.se.pept.transport.Selector ;
72 import com.sun.corba.se.pept.transport.TransportManager;
74 import com.sun.corba.se.spi.legacy.connection.ORBSocketFactory;
75 import com.sun.corba.se.spi.orb.ORBData;
76 import com.sun.corba.se.spi.orb.Operation;
77 import com.sun.corba.se.spi.orb.ORB;
78 import com.sun.corba.se.spi.orb.ORBVersion;
79 import com.sun.corba.se.spi.orb.ORBVersionFactory;
80 import com.sun.corba.se.spi.oa.OAInvocationInfo;
81 import com.sun.corba.se.spi.oa.ObjectAdapter;
82 import com.sun.corba.se.spi.protocol.CorbaMessageMediator;
83 import com.sun.corba.se.spi.protocol.ClientDelegateFactory;
84 import com.sun.corba.se.spi.protocol.RequestDispatcherRegistry;
85 import com.sun.corba.se.spi.protocol.CorbaServerRequestDispatcher;
86 import com.sun.corba.se.spi.protocol.PIHandler;
87 import com.sun.corba.se.spi.resolver.Resolver;
88 import com.sun.corba.se.spi.resolver.LocalResolver;
89 import com.sun.corba.se.spi.ior.IOR;
90 import com.sun.corba.se.spi.ior.IdentifiableFactoryFinder;
91 import com.sun.corba.se.spi.ior.TaggedComponentFactoryFinder;
92 import com.sun.corba.se.spi.ior.ObjectKey;
93 import com.sun.corba.se.spi.ior.ObjectKeyFactory;
94 import com.sun.corba.se.spi.ior.iiop.GIOPVersion;
95 import com.sun.corba.se.pept.transport.ByteBufferPool ;
96 import com.sun.corba.se.spi.transport.CorbaContactInfoListFactory ;
97 import com.sun.corba.se.spi.transport.CorbaTransportManager;
98 import com.sun.corba.se.spi.legacy.connection.LegacyServerSocketManager;
99 import com.sun.corba.se.spi.orbutil.closure.Closure;
100 import com.sun.corba.se.spi.orbutil.threadpool.ThreadPoolManager;
101 import com.sun.corba.se.spi.logging.LogWrapperFactory;
102 import com.sun.corba.se.spi.logging.LogWrapperBase;
103 import com.sun.corba.se.spi.copyobject.CopierManager;
104 import com.sun.corba.se.spi.presentation.rmi.PresentationManager;
105 import com.sun.corba.se.spi.presentation.rmi.PresentationDefaults;
107 import com.sun.corba.se.spi.servicecontext.ServiceContextRegistry;
108 import com.sun.corba.se.spi.servicecontext.ServiceContexts;
110 import com.sun.corba.se.impl.corba.TypeCodeFactory;
111 import com.sun.corba.se.impl.corba.TypeCodeImpl;
112 import com.sun.corba.se.impl.corba.NVListImpl;
113 import com.sun.corba.se.impl.corba.NamedValueImpl;
114 import com.sun.corba.se.impl.corba.ExceptionListImpl;
115 import com.sun.corba.se.impl.corba.ContextListImpl;
116 import com.sun.corba.se.impl.corba.EnvironmentImpl;
117 import com.sun.corba.se.impl.corba.AnyImpl;
118 import com.sun.corba.se.impl.encoding.BufferManagerFactory;
119 import com.sun.corba.se.impl.encoding.CodeSetComponentInfo;
120 import com.sun.corba.se.impl.encoding.MarshalInputStream;
121 import com.sun.corba.se.impl.encoding.EncapsOutputStream;
122 import com.sun.corba.se.impl.encoding.MarshalOutputStream;
123 import com.sun.corba.se.impl.oa.poa.BadServerIdHandler;
124 import com.sun.corba.se.impl.orbutil.ORBConstants;
125 import com.sun.corba.se.spi.legacy.connection.LegacyServerSocketEndPointInfo;
127 /*
128 * The restricted singleton ORB implementation.
129 *
130 * For now, this class must implement just enough functionality to be
131 * used as a factory for immutable TypeCode instances.
132 *
133 * See ORBImpl.java for the real ORB implementation.
134 */
135 public class ORBSingleton extends ORB
136 {
137 // This is used to support read_Object.
138 private ORB fullORB;
139 private static PresentationManager.StubFactoryFactory staticStubFactoryFactory =
140 PresentationDefaults.getStaticStubFactoryFactory() ;
142 public void set_parameters( Properties props ) {
143 }
145 protected void set_parameters(Applet app, Properties props) {
146 }
148 protected void set_parameters (String params[], Properties props) {
149 }
151 public OutputStream create_output_stream() {
152 return sun.corba.OutputStreamFactory.newEncapsOutputStream(this);
153 }
155 public TypeCode create_struct_tc(String id,
156 String name,
157 StructMember[] members)
158 {
159 return new TypeCodeImpl(this, TCKind._tk_struct, id, name, members);
160 }
162 public TypeCode create_union_tc(String id,
163 String name,
164 TypeCode discriminator_type,
165 UnionMember[] members)
166 {
167 return new TypeCodeImpl(this,
168 TCKind._tk_union,
169 id,
170 name,
171 discriminator_type,
172 members);
173 }
175 public TypeCode create_enum_tc(String id,
176 String name,
177 String[] members)
178 {
179 return new TypeCodeImpl(this, TCKind._tk_enum, id, name, members);
180 }
182 public TypeCode create_alias_tc(String id,
183 String name,
184 TypeCode original_type)
185 {
186 return new TypeCodeImpl(this, TCKind._tk_alias, id, name, original_type);
187 }
189 public TypeCode create_exception_tc(String id,
190 String name,
191 StructMember[] members)
192 {
193 return new TypeCodeImpl(this, TCKind._tk_except, id, name, members);
194 }
196 public TypeCode create_interface_tc(String id,
197 String name)
198 {
199 return new TypeCodeImpl(this, TCKind._tk_objref, id, name);
200 }
202 public TypeCode create_string_tc(int bound) {
203 return new TypeCodeImpl(this, TCKind._tk_string, bound);
204 }
206 public TypeCode create_wstring_tc(int bound) {
207 return new TypeCodeImpl(this, TCKind._tk_wstring, bound);
208 }
210 public TypeCode create_sequence_tc(int bound,
211 TypeCode element_type)
212 {
213 return new TypeCodeImpl(this, TCKind._tk_sequence, bound, element_type);
214 }
216 public TypeCode create_recursive_sequence_tc(int bound,
217 int offset)
218 {
219 return new TypeCodeImpl(this, TCKind._tk_sequence, bound, offset);
220 }
222 public TypeCode create_array_tc(int length,
223 TypeCode element_type)
224 {
225 return new TypeCodeImpl(this, TCKind._tk_array, length, element_type);
226 }
228 public org.omg.CORBA.TypeCode create_native_tc(String id,
229 String name)
230 {
231 return new TypeCodeImpl(this, TCKind._tk_native, id, name);
232 }
234 public org.omg.CORBA.TypeCode create_abstract_interface_tc(
235 String id,
236 String name)
237 {
238 return new TypeCodeImpl(this, TCKind._tk_abstract_interface, id, name);
239 }
241 public org.omg.CORBA.TypeCode create_fixed_tc(short digits, short scale)
242 {
243 return new TypeCodeImpl(this, TCKind._tk_fixed, digits, scale);
244 }
246 // orbos 98-01-18: Objects By Value -- begin
248 public org.omg.CORBA.TypeCode create_value_tc(String id,
249 String name,
250 short type_modifier,
251 TypeCode concrete_base,
252 ValueMember[] members)
253 {
254 return new TypeCodeImpl(this, TCKind._tk_value, id, name,
255 type_modifier, concrete_base, members);
256 }
258 public org.omg.CORBA.TypeCode create_recursive_tc(String id) {
259 return new TypeCodeImpl(this, id);
260 }
262 public org.omg.CORBA.TypeCode create_value_box_tc(String id,
263 String name,
264 TypeCode boxed_type)
265 {
266 return new TypeCodeImpl(this, TCKind._tk_value_box, id, name, boxed_type);
267 }
269 public TypeCode get_primitive_tc( TCKind tckind )
270 {
271 return get_primitive_tc( tckind.value() ) ;
272 }
274 public Any create_any() {
275 return new AnyImpl(this);
276 }
278 // TypeCodeFactory interface methods.
279 // Keeping track of type codes by repository id.
280 /*
281 * Not strictly needed for TypeCode factory duty but these seem
282 * harmless enough.
283 */
285 public NVList create_list(int count) {
286 return new NVListImpl(this, count);
287 }
289 public org.omg.CORBA.NVList
290 create_operation_list(org.omg.CORBA.Object oper) {
291 throw wrapper.genericNoImpl() ;
292 }
294 public org.omg.CORBA.NamedValue
295 create_named_value(String s, Any any, int flags) {
296 return new NamedValueImpl(this, s, any, flags);
297 }
299 public org.omg.CORBA.ExceptionList create_exception_list() {
300 return new ExceptionListImpl();
301 }
303 public org.omg.CORBA.ContextList create_context_list() {
304 return new ContextListImpl(this);
305 }
307 public org.omg.CORBA.Context get_default_context()
308 {
309 throw wrapper.genericNoImpl() ;
310 }
312 public org.omg.CORBA.Environment create_environment()
313 {
314 return new EnvironmentImpl();
315 }
317 public org.omg.CORBA.Current get_current()
318 {
319 throw wrapper.genericNoImpl() ;
320 }
322 /*
323 * Things that aren't allowed.
324 */
326 public String[] list_initial_services ()
327 {
328 throw wrapper.genericNoImpl() ;
329 }
331 public org.omg.CORBA.Object resolve_initial_references(String identifier)
332 throws InvalidName
333 {
334 throw wrapper.genericNoImpl() ;
335 }
337 public void register_initial_reference(
338 String id, org.omg.CORBA.Object obj ) throws InvalidName
339 {
340 throw wrapper.genericNoImpl() ;
341 }
343 public void send_multiple_requests_oneway(Request[] req) {
344 throw new SecurityException("ORBSingleton: access denied");
345 }
347 public void send_multiple_requests_deferred(Request[] req) {
348 throw new SecurityException("ORBSingleton: access denied");
349 }
351 public boolean poll_next_response() {
352 throw new SecurityException("ORBSingleton: access denied");
353 }
355 public org.omg.CORBA.Request get_next_response() {
356 throw new SecurityException("ORBSingleton: access denied");
357 }
359 public String object_to_string(org.omg.CORBA.Object obj) {
360 throw new SecurityException("ORBSingleton: access denied");
361 }
363 public org.omg.CORBA.Object string_to_object(String s) {
364 throw new SecurityException("ORBSingleton: access denied");
365 }
367 public java.rmi.Remote string_to_remote(String s)
368 throws java.rmi.RemoteException
369 {
370 throw new SecurityException("ORBSingleton: access denied");
371 }
373 public void connect(org.omg.CORBA.Object servant) {
374 throw new SecurityException("ORBSingleton: access denied");
375 }
377 public void disconnect(org.omg.CORBA.Object obj) {
378 throw new SecurityException("ORBSingleton: access denied");
379 }
381 public void run()
382 {
383 throw new SecurityException("ORBSingleton: access denied");
384 }
386 public void shutdown(boolean wait_for_completion)
387 {
388 throw new SecurityException("ORBSingleton: access denied");
389 }
391 protected void shutdownServants(boolean wait_for_completion) {
392 throw new SecurityException("ORBSingleton: access denied");
393 }
395 protected void destroyConnections() {
396 throw new SecurityException("ORBSingleton: access denied");
397 }
399 public void destroy() {
400 throw new SecurityException("ORBSingleton: access denied");
401 }
403 public boolean work_pending()
404 {
405 throw new SecurityException("ORBSingleton: access denied");
406 }
408 public void perform_work()
409 {
410 throw new SecurityException("ORBSingleton: access denied");
411 }
413 public org.omg.CORBA.portable.ValueFactory register_value_factory(String repositoryID,
414 org.omg.CORBA.portable.ValueFactory factory)
415 {
416 throw new SecurityException("ORBSingleton: access denied");
417 }
419 public void unregister_value_factory(String repositoryID)
420 {
421 throw new SecurityException("ORBSingleton: access denied");
422 }
424 public org.omg.CORBA.portable.ValueFactory lookup_value_factory(String repositoryID)
425 {
426 throw new SecurityException("ORBSingleton: access denied");
427 }
429 public TransportManager getTransportManager()
430 {
431 throw new SecurityException("ORBSingleton: access denied");
432 }
434 public CorbaTransportManager getCorbaTransportManager()
435 {
436 throw new SecurityException("ORBSingleton: access denied");
437 }
439 public LegacyServerSocketManager getLegacyServerSocketManager()
440 {
441 throw new SecurityException("ORBSingleton: access denied");
442 }
444 /*************************************************************************
445 These are methods from com.sun.corba.se.impl.se.core.ORB
446 ************************************************************************/
448 private synchronized ORB getFullORB()
449 {
450 if (fullORB == null) {
451 Properties props = new Properties() ;
452 fullORB = new ORBImpl() ;
453 fullORB.set_parameters( props ) ;
454 }
456 return fullORB ;
457 }
459 public RequestDispatcherRegistry getRequestDispatcherRegistry()
460 {
461 // To enable read_Object.
463 return getFullORB().getRequestDispatcherRegistry();
464 }
466 /**
467 * Return the service context registry
468 */
469 public ServiceContextRegistry getServiceContextRegistry()
470 {
471 throw new SecurityException("ORBSingleton: access denied");
472 }
474 /**
475 * Get the transient server ID
476 */
477 public int getTransientServerId()
478 {
479 throw new SecurityException("ORBSingleton: access denied");
480 }
482 /**
483 * Return the bootstrap naming port specified in the ORBInitialPort param.
484 */
485 public int getORBInitialPort()
486 {
487 throw new SecurityException("ORBSingleton: access denied");
488 }
490 /**
491 * Return the bootstrap naming host specified in the ORBInitialHost param.
492 */
493 public String getORBInitialHost()
494 {
495 throw new SecurityException("ORBSingleton: access denied");
496 }
498 public String getORBServerHost()
499 {
500 throw new SecurityException("ORBSingleton: access denied");
501 }
503 public int getORBServerPort()
504 {
505 throw new SecurityException("ORBSingleton: access denied");
506 }
508 public CodeSetComponentInfo getCodeSetComponentInfo()
509 {
510 return new CodeSetComponentInfo();
511 }
513 public boolean isLocalHost( String host )
514 {
515 // To enable read_Object.
516 return false;
517 }
519 public boolean isLocalServerId( int subcontractId, int serverId )
520 {
521 // To enable read_Object.
522 return false;
523 }
525 /*
526 * Things from corba.ORB.
527 */
529 public ORBVersion getORBVersion()
530 {
531 // Always use our latest ORB version (latest fixes, etc)
532 return ORBVersionFactory.getORBVersion();
533 }
535 public void setORBVersion(ORBVersion verObj)
536 {
537 throw new SecurityException("ORBSingleton: access denied");
538 }
540 public String getAppletHost()
541 {
542 throw new SecurityException("ORBSingleton: access denied");
543 }
545 public URL getAppletCodeBase()
546 {
547 throw new SecurityException("ORBSingleton: access denied");
548 }
550 public int getHighWaterMark(){
551 throw new SecurityException("ORBSingleton: access denied");
552 }
554 public int getLowWaterMark(){
555 throw new SecurityException("ORBSingleton: access denied");
556 }
558 public int getNumberToReclaim(){
559 throw new SecurityException("ORBSingleton: access denied");
560 }
562 public int getGIOPFragmentSize() {
563 return ORBConstants.GIOP_DEFAULT_BUFFER_SIZE;
564 }
566 public int getGIOPBuffMgrStrategy(GIOPVersion gv) {
567 return BufferManagerFactory.GROW;
568 }
570 public IOR getFVDCodeBaseIOR(){
571 throw new SecurityException("ORBSingleton: access denied");
572 }
574 public Policy create_policy( int type, Any val ) throws PolicyError
575 {
576 throw new NO_IMPLEMENT();
577 }
579 public LegacyServerSocketEndPointInfo getServerEndpoint()
580 {
581 return null ;
582 }
584 public void setPersistentServerId( int id )
585 {
586 }
588 public TypeCodeImpl getTypeCodeForClass( Class c )
589 {
590 return null ;
591 }
593 public void setTypeCodeForClass( Class c, TypeCodeImpl tcimpl )
594 {
595 }
597 public boolean alwaysSendCodeSetServiceContext()
598 {
599 return true ;
600 }
602 public boolean isDuringDispatch()
603 {
604 return false ;
605 }
607 public void notifyORB() { }
609 public PIHandler getPIHandler()
610 {
611 return null ;
612 }
614 public void checkShutdownState()
615 {
616 }
618 public void startingDispatch()
619 {
620 }
622 public void finishedDispatch()
623 {
624 }
626 public void registerInitialReference( String id, Closure closure )
627 {
628 }
630 public ORBData getORBData()
631 {
632 return getFullORB().getORBData() ;
633 }
635 public void setClientDelegateFactory( ClientDelegateFactory factory )
636 {
637 }
639 public ClientDelegateFactory getClientDelegateFactory()
640 {
641 return getFullORB().getClientDelegateFactory() ;
642 }
644 public void setCorbaContactInfoListFactory( CorbaContactInfoListFactory factory )
645 {
646 }
648 public CorbaContactInfoListFactory getCorbaContactInfoListFactory()
649 {
650 return getFullORB().getCorbaContactInfoListFactory() ;
651 }
653 public Operation getURLOperation()
654 {
655 return null ;
656 }
658 public void setINSDelegate( CorbaServerRequestDispatcher sdel )
659 {
660 }
662 public TaggedComponentFactoryFinder getTaggedComponentFactoryFinder()
663 {
664 return getFullORB().getTaggedComponentFactoryFinder() ;
665 }
667 public IdentifiableFactoryFinder getTaggedProfileFactoryFinder()
668 {
669 return getFullORB().getTaggedProfileFactoryFinder() ;
670 }
672 public IdentifiableFactoryFinder getTaggedProfileTemplateFactoryFinder()
673 {
674 return getFullORB().getTaggedProfileTemplateFactoryFinder() ;
675 }
677 public ObjectKeyFactory getObjectKeyFactory()
678 {
679 return getFullORB().getObjectKeyFactory() ;
680 }
682 public void setObjectKeyFactory( ObjectKeyFactory factory )
683 {
684 throw new SecurityException("ORBSingleton: access denied");
685 }
687 public void handleBadServerId( ObjectKey okey )
688 {
689 }
691 public OAInvocationInfo peekInvocationInfo()
692 {
693 return null ;
694 }
696 public void pushInvocationInfo( OAInvocationInfo info )
697 {
698 }
700 public OAInvocationInfo popInvocationInfo()
701 {
702 return null ;
703 }
705 public ClientInvocationInfo createOrIncrementInvocationInfo()
706 {
707 return null ;
708 }
710 public void releaseOrDecrementInvocationInfo()
711 {
712 }
714 public ClientInvocationInfo getInvocationInfo()
715 {
716 return null ;
717 }
719 public ConnectionCache getConnectionCache(ContactInfo contactInfo)
720 {
721 return null;
722 }
724 public void setResolver( Resolver resolver )
725 {
726 }
728 public Resolver getResolver()
729 {
730 return null ;
731 }
733 public void setLocalResolver( LocalResolver resolver )
734 {
735 }
737 public LocalResolver getLocalResolver()
738 {
739 return null ;
740 }
742 public void setURLOperation( Operation stringToObject )
743 {
744 }
746 // NOTE: REMOVE THIS METHOD ONCE WE HAVE A ORT BASED ORBD
747 public void setBadServerIdHandler( BadServerIdHandler handler )
748 {
749 }
751 // NOTE: REMOVE THIS METHOD ONCE WE HAVE A ORT BASED ORBD
752 public void initBadServerIdHandler()
753 {
754 }
756 public Selector getSelector(int x)
757 {
758 return null;
759 }
761 public void setThreadPoolManager(ThreadPoolManager mgr) {
762 }
764 public ThreadPoolManager getThreadPoolManager() {
765 return null;
766 }
768 public CopierManager getCopierManager() {
769 return null ;
770 }
771 }
773 // End of file.