1. /*
  2. * @(#)ORBDataParserImpl.java 1.30 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. package com.sun.corba.se.impl.orb ;
  8. import java.net.URL ;
  9. import org.omg.CORBA.CompletionStatus ;
  10. import org.omg.PortableInterceptor.ORBInitializer ;
  11. import com.sun.corba.se.pept.transport.Acceptor;
  12. import com.sun.corba.se.spi.ior.iiop.GIOPVersion ;
  13. import com.sun.corba.se.spi.logging.CORBALogDomains ;
  14. import com.sun.corba.se.spi.orb.DataCollector ;
  15. import com.sun.corba.se.spi.orb.ORB ;
  16. import com.sun.corba.se.spi.orb.ORBData ;
  17. import com.sun.corba.se.spi.orb.ParserImplTableBase ;
  18. import com.sun.corba.se.spi.orb.StringPair ;
  19. import com.sun.corba.se.spi.transport.CorbaContactInfoListFactory;
  20. import com.sun.corba.se.spi.transport.CorbaTransportManager;
  21. import com.sun.corba.se.spi.transport.IORToSocketInfo;
  22. import com.sun.corba.se.spi.transport.IIOPPrimaryToContactInfo;
  23. import com.sun.corba.se.spi.transport.ReadTimeouts;
  24. import com.sun.corba.se.impl.encoding.CodeSetComponentInfo ;
  25. import com.sun.corba.se.impl.legacy.connection.USLPort;
  26. import com.sun.corba.se.impl.orbutil.ORBClassLoader ;
  27. import com.sun.corba.se.impl.orbutil.ORBConstants ;
  28. import com.sun.corba.se.impl.logging.ORBUtilSystemException ;
  29. public class ORBDataParserImpl extends ParserImplTableBase implements ORBData
  30. {
  31. private ORB orb ;
  32. private ORBUtilSystemException wrapper ;
  33. private String ORBInitialHost ;
  34. private int ORBInitialPort ;
  35. private String ORBServerHost ;
  36. private int ORBServerPort ;
  37. private String listenOnAllInterfaces;
  38. private com.sun.corba.se.spi.legacy.connection.ORBSocketFactory legacySocketFactory ;
  39. private com.sun.corba.se.spi.transport.ORBSocketFactory socketFactory;
  40. private USLPort[] userSpecifiedListenPorts ;
  41. private IORToSocketInfo iorToSocketInfo;
  42. private IIOPPrimaryToContactInfo iiopPrimaryToContactInfo;
  43. private String orbId ;
  44. private boolean orbServerIdPropertySpecified ;
  45. private URL servicesURL ;
  46. private String propertyInitRef ;
  47. private boolean allowLocalOptimization ;
  48. private GIOPVersion giopVersion ;
  49. private int highWaterMark ;
  50. private int lowWaterMark ;
  51. private int numberToReclaim ;
  52. private int giopFragmentSize ;
  53. private int giopBufferSize ;
  54. private int giop11BuffMgr ;
  55. private int giop12BuffMgr ;
  56. private short giopTargetAddressPreference ;
  57. private short giopAddressDisposition ;
  58. private boolean useByteOrderMarkers ;
  59. private boolean useByteOrderMarkersInEncaps ;
  60. private boolean alwaysSendCodeSetCtx ;
  61. private boolean persistentPortInitialized ;
  62. private int persistentServerPort ;
  63. private boolean persistentServerIdInitialized ;
  64. private int persistentServerId ;
  65. private boolean serverIsORBActivated ;
  66. private Class badServerIdHandlerClass ;
  67. private CodeSetComponentInfo.CodeSetComponent charData ;
  68. private CodeSetComponentInfo.CodeSetComponent wcharData ;
  69. private ORBInitializer[] orbInitializers ;
  70. private StringPair[] orbInitialReferences ;
  71. private String defaultInitRef ;
  72. private String[] debugFlags ;
  73. private Acceptor[] acceptors;
  74. private CorbaContactInfoListFactory corbaContactInfoListFactory;
  75. private String acceptorSocketType;
  76. private boolean acceptorSocketUseSelectThreadToWait;
  77. private boolean acceptorSocketUseWorkerThreadForEvent;
  78. private String connectionSocketType;
  79. private boolean connectionSocketUseSelectThreadToWait;
  80. private boolean connectionSocketUseWorkerThreadForEvent;
  81. private ReadTimeouts readTimeouts;
  82. private boolean disableDirectByteBufferUse;
  83. private boolean enableJavaSerialization;
  84. // This is not initialized from ParserTable.
  85. private CodeSetComponentInfo codesets ;
  86. // Public accessor methods ========================================================================
  87. public String getORBInitialHost()
  88. {
  89. return ORBInitialHost;
  90. }
  91. public int getORBInitialPort()
  92. {
  93. return ORBInitialPort;
  94. }
  95. public String getORBServerHost()
  96. {
  97. return ORBServerHost;
  98. }
  99. public String getListenOnAllInterfaces()
  100. {
  101. return listenOnAllInterfaces;
  102. }
  103. public int getORBServerPort()
  104. {
  105. return ORBServerPort;
  106. }
  107. public com.sun.corba.se.spi.legacy.connection.ORBSocketFactory getLegacySocketFactory()
  108. {
  109. return legacySocketFactory;
  110. }
  111. public com.sun.corba.se.spi.transport.ORBSocketFactory getSocketFactory()
  112. {
  113. return socketFactory;
  114. }
  115. public USLPort[] getUserSpecifiedListenPorts ()
  116. {
  117. return userSpecifiedListenPorts;
  118. }
  119. public IORToSocketInfo getIORToSocketInfo()
  120. {
  121. return iorToSocketInfo;
  122. }
  123. public IIOPPrimaryToContactInfo getIIOPPrimaryToContactInfo()
  124. {
  125. return iiopPrimaryToContactInfo;
  126. }
  127. public String getORBId()
  128. {
  129. return orbId;
  130. }
  131. public boolean getORBServerIdPropertySpecified()
  132. {
  133. return orbServerIdPropertySpecified;
  134. }
  135. public boolean isLocalOptimizationAllowed()
  136. {
  137. return allowLocalOptimization ;
  138. }
  139. public GIOPVersion getGIOPVersion()
  140. {
  141. return giopVersion;
  142. }
  143. public int getHighWaterMark()
  144. {
  145. return highWaterMark;
  146. }
  147. public int getLowWaterMark()
  148. {
  149. return lowWaterMark;
  150. }
  151. public int getNumberToReclaim()
  152. {
  153. return numberToReclaim;
  154. }
  155. public int getGIOPFragmentSize()
  156. {
  157. return giopFragmentSize;
  158. }
  159. public int getGIOPBufferSize()
  160. {
  161. return giopBufferSize;
  162. }
  163. public int getGIOPBuffMgrStrategy(GIOPVersion gv)
  164. {
  165. if(gv!=null){
  166. if (gv.equals(GIOPVersion.V1_0)) return 0; //Always grow for 1.0
  167. if (gv.equals(GIOPVersion.V1_1)) return giop11BuffMgr;
  168. if (gv.equals(GIOPVersion.V1_2)) return giop12BuffMgr;
  169. }
  170. //If a "faulty" GIOPVersion is passed, it's going to return 0;
  171. return 0;
  172. }
  173. /**
  174. * @return the GIOP Target Addressing preference of the ORB.
  175. * This ORB by default supports all addressing dispositions unless specified
  176. * otherwise via a java system property ORBConstants.GIOP_TARGET_ADDRESSING
  177. */
  178. public short getGIOPTargetAddressPreference()
  179. {
  180. return giopTargetAddressPreference;
  181. }
  182. public short getGIOPAddressDisposition()
  183. {
  184. return giopAddressDisposition;
  185. }
  186. public boolean useByteOrderMarkers()
  187. {
  188. return useByteOrderMarkers;
  189. }
  190. public boolean useByteOrderMarkersInEncapsulations()
  191. {
  192. return useByteOrderMarkersInEncaps;
  193. }
  194. public boolean alwaysSendCodeSetServiceContext()
  195. {
  196. return alwaysSendCodeSetCtx;
  197. }
  198. public boolean getPersistentPortInitialized()
  199. {
  200. return persistentPortInitialized ;
  201. }
  202. //public void setPersistentServerPort(int sp)
  203. //{
  204. //persistentServerPort = sp;
  205. //persistentPortInitialized = true;
  206. //}
  207. public int getPersistentServerPort()
  208. {
  209. if ( persistentPortInitialized ) // this is a user-activated server
  210. return persistentServerPort;
  211. else {
  212. throw wrapper.persistentServerportNotSet(
  213. CompletionStatus.COMPLETED_MAYBE );
  214. }
  215. }
  216. public boolean getPersistentServerIdInitialized()
  217. {
  218. return persistentServerIdInitialized;
  219. }
  220. /** Set the persistent-server-id of this server. This id is the same
  221. * across multiple activations of this server. The id can be set to any
  222. * integer value other than 0. This id must be set before any persistent
  223. * objects can be created.
  224. */
  225. //public void setPersistentServerId(int id)
  226. //{
  227. //persistentServerId = id;
  228. //persistentServerIdInitialized = true;
  229. //}
  230. /** Return the persistent-server-id of this server. This id is the same
  231. * across multiple activations of this server. This is in contrast to
  232. * com.sun.corba.se.impl.iiop.ORB.getTransientServerId() which
  233. * returns a transient id that is guaranteed to be different
  234. * across multiple activations of
  235. * this server. The user/environment is required to supply the
  236. * persistent-server-id every time this server is started, in
  237. * the ORBServerId parameter, System properties, or other means.
  238. * The user is also required to ensure that no two persistent servers
  239. * on the same host have the same server-id.
  240. */
  241. public int getPersistentServerId()
  242. {
  243. if ( persistentServerIdInitialized ) {
  244. return persistentServerId;
  245. } else {
  246. throw wrapper.persistentServeridNotSet(
  247. CompletionStatus.COMPLETED_MAYBE);
  248. }
  249. }
  250. public boolean getServerIsORBActivated()
  251. {
  252. return serverIsORBActivated ;
  253. }
  254. public Class getBadServerIdHandler()
  255. {
  256. return badServerIdHandlerClass ;
  257. }
  258. /**
  259. * Get the prefered code sets for connections. Should the client send the code set service context on every
  260. * request?
  261. */
  262. public CodeSetComponentInfo getCodeSetComponentInfo()
  263. {
  264. return codesets;
  265. }
  266. public ORBInitializer[] getORBInitializers()
  267. {
  268. return orbInitializers ;
  269. }
  270. public StringPair[] getORBInitialReferences()
  271. {
  272. return orbInitialReferences ;
  273. }
  274. public String getORBDefaultInitialReference()
  275. {
  276. return defaultInitRef ;
  277. }
  278. public String[] getORBDebugFlags()
  279. {
  280. return debugFlags ;
  281. }
  282. public Acceptor[] getAcceptors()
  283. {
  284. return acceptors;
  285. }
  286. public CorbaContactInfoListFactory getCorbaContactInfoListFactory()
  287. {
  288. return corbaContactInfoListFactory;
  289. }
  290. public String acceptorSocketType()
  291. {
  292. return acceptorSocketType;
  293. }
  294. public boolean acceptorSocketUseSelectThreadToWait()
  295. {
  296. return acceptorSocketUseSelectThreadToWait;
  297. }
  298. public boolean acceptorSocketUseWorkerThreadForEvent()
  299. {
  300. return acceptorSocketUseWorkerThreadForEvent;
  301. }
  302. public String connectionSocketType()
  303. {
  304. return connectionSocketType;
  305. }
  306. public boolean connectionSocketUseSelectThreadToWait()
  307. {
  308. return connectionSocketUseSelectThreadToWait;
  309. }
  310. public boolean connectionSocketUseWorkerThreadForEvent()
  311. {
  312. return connectionSocketUseWorkerThreadForEvent;
  313. }
  314. public boolean isJavaSerializationEnabled()
  315. {
  316. return enableJavaSerialization;
  317. }
  318. public ReadTimeouts getTransportTCPReadTimeouts()
  319. {
  320. return readTimeouts;
  321. }
  322. public boolean disableDirectByteBufferUse()
  323. {
  324. return disableDirectByteBufferUse ;
  325. }
  326. // Methods for constructing and initializing this object ===========================================
  327. public ORBDataParserImpl( ORB orb, DataCollector coll )
  328. {
  329. super( ParserTable.get().getParserData() ) ;
  330. this.orb = orb ;
  331. wrapper = ORBUtilSystemException.get( orb, CORBALogDomains.ORB_LIFECYCLE ) ;
  332. init( coll ) ;
  333. complete() ;
  334. }
  335. public void complete()
  336. {
  337. codesets = new CodeSetComponentInfo(charData, wcharData);
  338. }
  339. }
  340. // End of file.