1. /*
  2. * @(#)ORBSingleton.java 1.42 04/06/21
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. /*
  8. * Licensed Materials - Property of IBM
  9. * RMI-IIOP v1.0
  10. * Copyright IBM Corp. 1998 1999 All Rights Reserved
  11. *
  12. * US Government Users Restricted Rights - Use, duplication or
  13. * disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  14. */
  15. package com.sun.corba.se.impl.orb;
  16. import java.util.Collection;
  17. import java.util.Properties;
  18. import java.util.Hashtable;
  19. import java.applet.Applet;
  20. import java.net.URL;
  21. import java.io.IOException ;
  22. import java.util.logging.Logger ;
  23. import org.omg.CORBA.Context;
  24. import org.omg.CORBA.ContextList;
  25. import org.omg.CORBA.Environment;
  26. import org.omg.CORBA.ExceptionList;
  27. import org.omg.CORBA.ORBPackage.InvalidName;
  28. import org.omg.CORBA.NVList;
  29. import org.omg.CORBA.TCKind;
  30. import org.omg.CORBA.NamedValue;
  31. import org.omg.CORBA.NO_IMPLEMENT;
  32. import org.omg.CORBA.Object;
  33. import org.omg.CORBA.Request;
  34. import org.omg.CORBA.TypeCode;
  35. import org.omg.CORBA.Any;
  36. import org.omg.CORBA.StructMember;
  37. import org.omg.CORBA.UnionMember;
  38. import org.omg.CORBA.ValueMember;
  39. import org.omg.CORBA.Policy;
  40. import org.omg.CORBA.PolicyError;
  41. import org.omg.CORBA.portable.OutputStream;
  42. import org.omg.CORBA.portable.RemarshalException;
  43. import com.sun.corba.se.pept.protocol.ClientInvocationInfo ;
  44. import com.sun.corba.se.pept.transport.ContactInfo;
  45. import com.sun.corba.se.pept.transport.ConnectionCache;
  46. import com.sun.corba.se.pept.transport.Selector ;
  47. import com.sun.corba.se.pept.transport.TransportManager;
  48. import com.sun.corba.se.spi.legacy.connection.ORBSocketFactory;
  49. import com.sun.corba.se.spi.orb.ORBData;
  50. import com.sun.corba.se.spi.orb.Operation;
  51. import com.sun.corba.se.spi.orb.ORB;
  52. import com.sun.corba.se.spi.orb.ORBVersion;
  53. import com.sun.corba.se.spi.orb.ORBVersionFactory;
  54. import com.sun.corba.se.spi.oa.OAInvocationInfo;
  55. import com.sun.corba.se.spi.oa.ObjectAdapter;
  56. import com.sun.corba.se.spi.protocol.CorbaMessageMediator;
  57. import com.sun.corba.se.spi.protocol.ClientDelegateFactory;
  58. import com.sun.corba.se.spi.protocol.RequestDispatcherRegistry;
  59. import com.sun.corba.se.spi.protocol.CorbaServerRequestDispatcher;
  60. import com.sun.corba.se.spi.protocol.PIHandler;
  61. import com.sun.corba.se.spi.resolver.Resolver;
  62. import com.sun.corba.se.spi.resolver.LocalResolver;
  63. import com.sun.corba.se.spi.ior.IOR;
  64. import com.sun.corba.se.spi.ior.IdentifiableFactoryFinder;
  65. import com.sun.corba.se.spi.ior.TaggedComponentFactoryFinder;
  66. import com.sun.corba.se.spi.ior.ObjectKey;
  67. import com.sun.corba.se.spi.ior.ObjectKeyFactory;
  68. import com.sun.corba.se.spi.ior.iiop.GIOPVersion;
  69. import com.sun.corba.se.pept.transport.ByteBufferPool ;
  70. import com.sun.corba.se.spi.transport.CorbaContactInfoListFactory ;
  71. import com.sun.corba.se.spi.transport.CorbaTransportManager;
  72. import com.sun.corba.se.spi.legacy.connection.LegacyServerSocketManager;
  73. import com.sun.corba.se.spi.orbutil.closure.Closure;
  74. import com.sun.corba.se.spi.orbutil.threadpool.ThreadPoolManager;
  75. import com.sun.corba.se.spi.logging.LogWrapperFactory;
  76. import com.sun.corba.se.spi.logging.LogWrapperBase;
  77. import com.sun.corba.se.spi.copyobject.CopierManager;
  78. import com.sun.corba.se.spi.presentation.rmi.PresentationManager;
  79. import com.sun.corba.se.spi.presentation.rmi.PresentationDefaults;
  80. import com.sun.corba.se.spi.servicecontext.ServiceContextRegistry;
  81. import com.sun.corba.se.spi.servicecontext.ServiceContexts;
  82. import com.sun.corba.se.impl.corba.TypeCodeFactory;
  83. import com.sun.corba.se.impl.corba.TypeCodeImpl;
  84. import com.sun.corba.se.impl.corba.NVListImpl;
  85. import com.sun.corba.se.impl.corba.NamedValueImpl;
  86. import com.sun.corba.se.impl.corba.ExceptionListImpl;
  87. import com.sun.corba.se.impl.corba.ContextListImpl;
  88. import com.sun.corba.se.impl.corba.EnvironmentImpl;
  89. import com.sun.corba.se.impl.corba.AnyImpl;
  90. import com.sun.corba.se.impl.encoding.BufferManagerFactory;
  91. import com.sun.corba.se.impl.encoding.CodeSetComponentInfo;
  92. import com.sun.corba.se.impl.encoding.MarshalInputStream;
  93. import com.sun.corba.se.impl.encoding.EncapsOutputStream;
  94. import com.sun.corba.se.impl.encoding.MarshalOutputStream;
  95. import com.sun.corba.se.impl.oa.poa.BadServerIdHandler;
  96. import com.sun.corba.se.impl.orbutil.ORBConstants;
  97. import com.sun.corba.se.spi.legacy.connection.LegacyServerSocketEndPointInfo;
  98. /*
  99. * The restricted singleton ORB implementation.
  100. *
  101. * For now, this class must implement just enough functionality to be
  102. * used as a factory for immutable TypeCode instances.
  103. *
  104. * See ORBImpl.java for the real ORB implementation.
  105. */
  106. public class ORBSingleton extends ORB
  107. {
  108. // This is used to support read_Object.
  109. private static ORB fullORB;
  110. private static PresentationManager.StubFactoryFactory staticStubFactoryFactory =
  111. PresentationDefaults.getStaticStubFactoryFactory() ;
  112. public void set_parameters( Properties props ) {
  113. }
  114. protected void set_parameters(Applet app, Properties props) {
  115. }
  116. protected void set_parameters (String params[], Properties props) {
  117. }
  118. public OutputStream create_output_stream() {
  119. return new EncapsOutputStream(this);
  120. }
  121. public TypeCode create_struct_tc(String id,
  122. String name,
  123. StructMember[] members)
  124. {
  125. return new TypeCodeImpl(this, TCKind._tk_struct, id, name, members);
  126. }
  127. public TypeCode create_union_tc(String id,
  128. String name,
  129. TypeCode discriminator_type,
  130. UnionMember[] members)
  131. {
  132. return new TypeCodeImpl(this,
  133. TCKind._tk_union,
  134. id,
  135. name,
  136. discriminator_type,
  137. members);
  138. }
  139. public TypeCode create_enum_tc(String id,
  140. String name,
  141. String[] members)
  142. {
  143. return new TypeCodeImpl(this, TCKind._tk_enum, id, name, members);
  144. }
  145. public TypeCode create_alias_tc(String id,
  146. String name,
  147. TypeCode original_type)
  148. {
  149. return new TypeCodeImpl(this, TCKind._tk_alias, id, name, original_type);
  150. }
  151. public TypeCode create_exception_tc(String id,
  152. String name,
  153. StructMember[] members)
  154. {
  155. return new TypeCodeImpl(this, TCKind._tk_except, id, name, members);
  156. }
  157. public TypeCode create_interface_tc(String id,
  158. String name)
  159. {
  160. return new TypeCodeImpl(this, TCKind._tk_objref, id, name);
  161. }
  162. public TypeCode create_string_tc(int bound) {
  163. return new TypeCodeImpl(this, TCKind._tk_string, bound);
  164. }
  165. public TypeCode create_wstring_tc(int bound) {
  166. return new TypeCodeImpl(this, TCKind._tk_wstring, bound);
  167. }
  168. public TypeCode create_sequence_tc(int bound,
  169. TypeCode element_type)
  170. {
  171. return new TypeCodeImpl(this, TCKind._tk_sequence, bound, element_type);
  172. }
  173. public TypeCode create_recursive_sequence_tc(int bound,
  174. int offset)
  175. {
  176. return new TypeCodeImpl(this, TCKind._tk_sequence, bound, offset);
  177. }
  178. public TypeCode create_array_tc(int length,
  179. TypeCode element_type)
  180. {
  181. return new TypeCodeImpl(this, TCKind._tk_array, length, element_type);
  182. }
  183. public org.omg.CORBA.TypeCode create_native_tc(String id,
  184. String name)
  185. {
  186. return new TypeCodeImpl(this, TCKind._tk_native, id, name);
  187. }
  188. public org.omg.CORBA.TypeCode create_abstract_interface_tc(
  189. String id,
  190. String name)
  191. {
  192. return new TypeCodeImpl(this, TCKind._tk_abstract_interface, id, name);
  193. }
  194. public org.omg.CORBA.TypeCode create_fixed_tc(short digits, short scale)
  195. {
  196. return new TypeCodeImpl(this, TCKind._tk_fixed, digits, scale);
  197. }
  198. // orbos 98-01-18: Objects By Value -- begin
  199. public org.omg.CORBA.TypeCode create_value_tc(String id,
  200. String name,
  201. short type_modifier,
  202. TypeCode concrete_base,
  203. ValueMember[] members)
  204. {
  205. return new TypeCodeImpl(this, TCKind._tk_value, id, name,
  206. type_modifier, concrete_base, members);
  207. }
  208. public org.omg.CORBA.TypeCode create_recursive_tc(String id) {
  209. return new TypeCodeImpl(this, id);
  210. }
  211. public org.omg.CORBA.TypeCode create_value_box_tc(String id,
  212. String name,
  213. TypeCode boxed_type)
  214. {
  215. return new TypeCodeImpl(this, TCKind._tk_value_box, id, name, boxed_type);
  216. }
  217. public TypeCode get_primitive_tc( TCKind tckind )
  218. {
  219. return get_primitive_tc( tckind.value() ) ;
  220. }
  221. public Any create_any() {
  222. return new AnyImpl(this);
  223. }
  224. // TypeCodeFactory interface methods.
  225. // Keeping track of type codes by repository id.
  226. /*
  227. * Not strictly needed for TypeCode factory duty but these seem
  228. * harmless enough.
  229. */
  230. public NVList create_list(int count) {
  231. return new NVListImpl(this, count);
  232. }
  233. public org.omg.CORBA.NVList
  234. create_operation_list(org.omg.CORBA.Object oper) {
  235. throw wrapper.genericNoImpl() ;
  236. }
  237. public org.omg.CORBA.NamedValue
  238. create_named_value(String s, Any any, int flags) {
  239. return new NamedValueImpl(this, s, any, flags);
  240. }
  241. public org.omg.CORBA.ExceptionList create_exception_list() {
  242. return new ExceptionListImpl();
  243. }
  244. public org.omg.CORBA.ContextList create_context_list() {
  245. return new ContextListImpl(this);
  246. }
  247. public org.omg.CORBA.Context get_default_context()
  248. {
  249. throw wrapper.genericNoImpl() ;
  250. }
  251. public org.omg.CORBA.Environment create_environment()
  252. {
  253. return new EnvironmentImpl();
  254. }
  255. public org.omg.CORBA.Current get_current()
  256. {
  257. throw wrapper.genericNoImpl() ;
  258. }
  259. /*
  260. * Things that aren't allowed.
  261. */
  262. public String[] list_initial_services ()
  263. {
  264. throw wrapper.genericNoImpl() ;
  265. }
  266. public org.omg.CORBA.Object resolve_initial_references(String identifier)
  267. throws InvalidName
  268. {
  269. throw wrapper.genericNoImpl() ;
  270. }
  271. public void register_initial_reference(
  272. String id, org.omg.CORBA.Object obj ) throws InvalidName
  273. {
  274. throw wrapper.genericNoImpl() ;
  275. }
  276. public void send_multiple_requests_oneway(Request[] req) {
  277. throw new SecurityException("ORBSingleton: access denied");
  278. }
  279. public void send_multiple_requests_deferred(Request[] req) {
  280. throw new SecurityException("ORBSingleton: access denied");
  281. }
  282. public boolean poll_next_response() {
  283. throw new SecurityException("ORBSingleton: access denied");
  284. }
  285. public org.omg.CORBA.Request get_next_response() {
  286. throw new SecurityException("ORBSingleton: access denied");
  287. }
  288. public String object_to_string(org.omg.CORBA.Object obj) {
  289. throw new SecurityException("ORBSingleton: access denied");
  290. }
  291. public org.omg.CORBA.Object string_to_object(String s) {
  292. throw new SecurityException("ORBSingleton: access denied");
  293. }
  294. public java.rmi.Remote string_to_remote(String s)
  295. throws java.rmi.RemoteException
  296. {
  297. throw new SecurityException("ORBSingleton: access denied");
  298. }
  299. public void connect(org.omg.CORBA.Object servant) {
  300. throw new SecurityException("ORBSingleton: access denied");
  301. }
  302. public void disconnect(org.omg.CORBA.Object obj) {
  303. throw new SecurityException("ORBSingleton: access denied");
  304. }
  305. public void run()
  306. {
  307. throw new SecurityException("ORBSingleton: access denied");
  308. }
  309. public void shutdown(boolean wait_for_completion)
  310. {
  311. throw new SecurityException("ORBSingleton: access denied");
  312. }
  313. protected void shutdownServants(boolean wait_for_completion) {
  314. throw new SecurityException("ORBSingleton: access denied");
  315. }
  316. protected void destroyConnections() {
  317. throw new SecurityException("ORBSingleton: access denied");
  318. }
  319. public void destroy() {
  320. throw new SecurityException("ORBSingleton: access denied");
  321. }
  322. public boolean work_pending()
  323. {
  324. throw new SecurityException("ORBSingleton: access denied");
  325. }
  326. public void perform_work()
  327. {
  328. throw new SecurityException("ORBSingleton: access denied");
  329. }
  330. public org.omg.CORBA.portable.ValueFactory register_value_factory(String repositoryID,
  331. org.omg.CORBA.portable.ValueFactory factory)
  332. {
  333. throw new SecurityException("ORBSingleton: access denied");
  334. }
  335. public void unregister_value_factory(String repositoryID)
  336. {
  337. throw new SecurityException("ORBSingleton: access denied");
  338. }
  339. public org.omg.CORBA.portable.ValueFactory lookup_value_factory(String repositoryID)
  340. {
  341. throw new SecurityException("ORBSingleton: access denied");
  342. }
  343. public TransportManager getTransportManager()
  344. {
  345. throw new SecurityException("ORBSingleton: access denied");
  346. }
  347. public CorbaTransportManager getCorbaTransportManager()
  348. {
  349. throw new SecurityException("ORBSingleton: access denied");
  350. }
  351. public LegacyServerSocketManager getLegacyServerSocketManager()
  352. {
  353. throw new SecurityException("ORBSingleton: access denied");
  354. }
  355. /*************************************************************************
  356. These are methods from com.sun.corba.se.impl.se.core.ORB
  357. ************************************************************************/
  358. private synchronized ORB getFullORB()
  359. {
  360. if (fullORB == null) {
  361. Properties props = new Properties() ;
  362. fullORB = new ORBImpl() ;
  363. fullORB.set_parameters( props ) ;
  364. }
  365. return fullORB ;
  366. }
  367. public RequestDispatcherRegistry getRequestDispatcherRegistry()
  368. {
  369. // To enable read_Object.
  370. return getFullORB().getRequestDispatcherRegistry();
  371. }
  372. /**
  373. * Return the service context registry
  374. */
  375. public ServiceContextRegistry getServiceContextRegistry()
  376. {
  377. throw new SecurityException("ORBSingleton: access denied");
  378. }
  379. /**
  380. * Get the transient server ID
  381. */
  382. public int getTransientServerId()
  383. {
  384. throw new SecurityException("ORBSingleton: access denied");
  385. }
  386. /**
  387. * Return the bootstrap naming port specified in the ORBInitialPort param.
  388. */
  389. public int getORBInitialPort()
  390. {
  391. throw new SecurityException("ORBSingleton: access denied");
  392. }
  393. /**
  394. * Return the bootstrap naming host specified in the ORBInitialHost param.
  395. */
  396. public String getORBInitialHost()
  397. {
  398. throw new SecurityException("ORBSingleton: access denied");
  399. }
  400. public String getORBServerHost()
  401. {
  402. throw new SecurityException("ORBSingleton: access denied");
  403. }
  404. public int getORBServerPort()
  405. {
  406. throw new SecurityException("ORBSingleton: access denied");
  407. }
  408. public CodeSetComponentInfo getCodeSetComponentInfo()
  409. {
  410. return new CodeSetComponentInfo();
  411. }
  412. public boolean isLocalHost( String host )
  413. {
  414. // To enable read_Object.
  415. return false;
  416. }
  417. public boolean isLocalServerId( int subcontractId, int serverId )
  418. {
  419. // To enable read_Object.
  420. return false;
  421. }
  422. /*
  423. * Things from corba.ORB.
  424. */
  425. public ORBVersion getORBVersion()
  426. {
  427. // Always use our latest ORB version (latest fixes, etc)
  428. return ORBVersionFactory.getORBVersion();
  429. }
  430. public void setORBVersion(ORBVersion verObj)
  431. {
  432. throw new SecurityException("ORBSingleton: access denied");
  433. }
  434. public String getAppletHost()
  435. {
  436. throw new SecurityException("ORBSingleton: access denied");
  437. }
  438. public URL getAppletCodeBase()
  439. {
  440. throw new SecurityException("ORBSingleton: access denied");
  441. }
  442. public int getHighWaterMark(){
  443. throw new SecurityException("ORBSingleton: access denied");
  444. }
  445. public int getLowWaterMark(){
  446. throw new SecurityException("ORBSingleton: access denied");
  447. }
  448. public int getNumberToReclaim(){
  449. throw new SecurityException("ORBSingleton: access denied");
  450. }
  451. public int getGIOPFragmentSize() {
  452. return ORBConstants.GIOP_DEFAULT_BUFFER_SIZE;
  453. }
  454. public int getGIOPBuffMgrStrategy(GIOPVersion gv) {
  455. return BufferManagerFactory.GROW;
  456. }
  457. public IOR getFVDCodeBaseIOR(){
  458. throw new SecurityException("ORBSingleton: access denied");
  459. }
  460. public Policy create_policy( int type, Any val ) throws PolicyError
  461. {
  462. throw new NO_IMPLEMENT();
  463. }
  464. public LegacyServerSocketEndPointInfo getServerEndpoint()
  465. {
  466. return null ;
  467. }
  468. public void setPersistentServerId( int id )
  469. {
  470. }
  471. public TypeCodeImpl getTypeCodeForClass( Class c )
  472. {
  473. return null ;
  474. }
  475. public void setTypeCodeForClass( Class c, TypeCodeImpl tcimpl )
  476. {
  477. }
  478. public boolean alwaysSendCodeSetServiceContext()
  479. {
  480. return true ;
  481. }
  482. public boolean isDuringDispatch()
  483. {
  484. return false ;
  485. }
  486. public void notifyORB() { }
  487. public PIHandler getPIHandler()
  488. {
  489. return null ;
  490. }
  491. public void checkShutdownState()
  492. {
  493. }
  494. public void startingDispatch()
  495. {
  496. }
  497. public void finishedDispatch()
  498. {
  499. }
  500. public void registerInitialReference( String id, Closure closure )
  501. {
  502. }
  503. public ORBData getORBData()
  504. {
  505. return getFullORB().getORBData() ;
  506. }
  507. public void setClientDelegateFactory( ClientDelegateFactory factory )
  508. {
  509. }
  510. public ClientDelegateFactory getClientDelegateFactory()
  511. {
  512. return getFullORB().getClientDelegateFactory() ;
  513. }
  514. public void setCorbaContactInfoListFactory( CorbaContactInfoListFactory factory )
  515. {
  516. }
  517. public CorbaContactInfoListFactory getCorbaContactInfoListFactory()
  518. {
  519. return getFullORB().getCorbaContactInfoListFactory() ;
  520. }
  521. public Operation getURLOperation()
  522. {
  523. return null ;
  524. }
  525. public void setINSDelegate( CorbaServerRequestDispatcher sdel )
  526. {
  527. }
  528. public TaggedComponentFactoryFinder getTaggedComponentFactoryFinder()
  529. {
  530. return getFullORB().getTaggedComponentFactoryFinder() ;
  531. }
  532. public IdentifiableFactoryFinder getTaggedProfileFactoryFinder()
  533. {
  534. return getFullORB().getTaggedProfileFactoryFinder() ;
  535. }
  536. public IdentifiableFactoryFinder getTaggedProfileTemplateFactoryFinder()
  537. {
  538. return getFullORB().getTaggedProfileTemplateFactoryFinder() ;
  539. }
  540. public ObjectKeyFactory getObjectKeyFactory()
  541. {
  542. return getFullORB().getObjectKeyFactory() ;
  543. }
  544. public void setObjectKeyFactory( ObjectKeyFactory factory )
  545. {
  546. throw new SecurityException("ORBSingleton: access denied");
  547. }
  548. public void handleBadServerId( ObjectKey okey )
  549. {
  550. }
  551. public OAInvocationInfo peekInvocationInfo()
  552. {
  553. return null ;
  554. }
  555. public void pushInvocationInfo( OAInvocationInfo info )
  556. {
  557. }
  558. public OAInvocationInfo popInvocationInfo()
  559. {
  560. return null ;
  561. }
  562. public ClientInvocationInfo createOrIncrementInvocationInfo()
  563. {
  564. return null ;
  565. }
  566. public void releaseOrDecrementInvocationInfo()
  567. {
  568. }
  569. public ClientInvocationInfo getInvocationInfo()
  570. {
  571. return null ;
  572. }
  573. public ConnectionCache getConnectionCache(ContactInfo contactInfo)
  574. {
  575. return null;
  576. }
  577. public void setResolver( Resolver resolver )
  578. {
  579. }
  580. public Resolver getResolver()
  581. {
  582. return null ;
  583. }
  584. public void setLocalResolver( LocalResolver resolver )
  585. {
  586. }
  587. public LocalResolver getLocalResolver()
  588. {
  589. return null ;
  590. }
  591. public void setURLOperation( Operation stringToObject )
  592. {
  593. }
  594. // NOTE: REMOVE THIS METHOD ONCE WE HAVE A ORT BASED ORBD
  595. public void setBadServerIdHandler( BadServerIdHandler handler )
  596. {
  597. }
  598. // NOTE: REMOVE THIS METHOD ONCE WE HAVE A ORT BASED ORBD
  599. public void initBadServerIdHandler()
  600. {
  601. }
  602. public Selector getSelector(int x)
  603. {
  604. return null;
  605. }
  606. public void setThreadPoolManager(ThreadPoolManager mgr) {
  607. }
  608. public ThreadPoolManager getThreadPoolManager() {
  609. return null;
  610. }
  611. public CopierManager getCopierManager() {
  612. return null ;
  613. }
  614. }
  615. // End of file.