orb.java
来自「java jdk 1.4的源码」· Java 代码 · 共 1,939 行 · 第 1/5 页
JAVA
1,939 行
String value = getSystemProperty(propertyNames[i]); if (value != null) { props.put(propertyNames[i], value); if (ORBInitDebug) dprint( "Found property " + propertyNames[i] + "=" + value + " in system properties" ) ; } } } // Any bad apples spoil the whole bunch. for (int i = 0; i < propertyNamePrefixes.length; i++) { if (! propertyNamePrefixes[i].startsWith( ORBConstants.PI_ORB_INITIALIZER_CLASS_PREFIX ) ) { throw new INTERNAL("findORBPropertiesFromSystem: illegal prefix: " + propertyNamePrefixes[i]); } } Enumeration systemPropertyNames = getSystemPropertyNames(); findPropertiesWithPrefix( propertyNamePrefixes, systemPropertyNames, new GetPropertyCallback() { public String get(String name) { return getSystemProperty(name); } }, "system properties", props); } // // Map/copy the properties argument from set_properties() into our // ORB properties object. // protected void findPropertiesFromProperties(Properties props, Properties arg, String[] propertyNames, String[] propertyNamePrefixes) { if (ORBInitDebug) dprint( "FindPropertiesFromProperties called with args = " + ORBUtility.objectToString( arg ) + "propertytNames = " + ORBUtility.objectToString( propertyNames ) ) ; if (arg == null) return; for (int i=0; i < propertyNames.length; i++) { String value; value = arg.getProperty(propertyNames[i]); if (value == null) continue; props.put(propertyNames[i], value); if (ORBInitDebug) dprint( "Found property " + propertyNames[i] + "=" + value + " in properties argument" ) ; } final Properties finalArg = arg; findPropertiesWithPrefix( propertyNamePrefixes, arg.propertyNames(), new GetPropertyCallback() { public String get(String name) { return finalArg.getProperty(name); } }, "properties argument", props); } // Set appropriate defaults for an applet ORB. private void checkAppletPropertyDefaults(Properties props) { String host = props.getProperty( ORBConstants.INITIAL_HOST_PROPERTY ) ; if ((host == null) || (host.equals(""))) { props.put( ORBConstants.INITIAL_HOST_PROPERTY, appletHost); } String serverHost = props.getProperty( ORBConstants.SERVER_HOST_PROPERTY ) ; if ((serverHost == null) || (serverHost.equals(""))) { props.put( ORBConstants.SERVER_HOST_PROPERTY, getLocalHostName()); } } // Set appropriate defaults for an application ORB. private void checkApplicationPropertyDefaults(Properties props) { String host = props.getProperty( ORBConstants.INITIAL_HOST_PROPERTY ) ; if ((host == null) || (host.equals(""))) { props.put( ORBConstants.INITIAL_HOST_PROPERTY, getLocalHostName()); } String serverHost = props.getProperty( ORBConstants.SERVER_HOST_PROPERTY ) ; if ((serverHost == null) || (serverHost.equals(""))) { props.put( ORBConstants.SERVER_HOST_PROPERTY, getLocalHostName()); } } /* keeping a copy of the getLocalHostName so that it can only be called * internally and the unauthorized clients cannot have access to the * localHost information, originally, the above code was calling getLocalHostName * from Connection.java. If the hostname is cached in Connection.java, then * it is a security hole, since any unauthorized client has access to * the host information. With this change it is used internally so the * security problem is resolved. Also in Connection.java, the getLocalHost() * implementation has changed to always call the * InetAddress.getLocalHost().getHostAddress() */ /* * getLocalHostName is private in this class. * Eventually, it should be protected, similar methods * in the subclasses removed and security check made here. * */ private static String localHostString = null; private String getLocalHostName() { if (localHostString != null) { return localHostString; } else { try { synchronized (com.sun.corba.se.internal.corba.ORB.class){ if ( localHostString == null ) localHostString = InetAddress.getLocalHost().getHostAddress(); return localHostString; } } catch (Exception ex) { throw new INTERNAL( MinorCodes.GET_LOCAL_HOST_FAILED, CompletionStatus.COMPLETED_NO ); } } } protected void setDebugFlags( String args ) { StringTokenizer st = new StringTokenizer( args, "," ) ; while (st.hasMoreTokens()) { String token = st.nextToken() ; // If there is a public boolean data member in this class // named token + "DebugFlag", set it to true. try { Field fld = this.getClass().getField( token + "DebugFlag" ) ; int mod = fld.getModifiers() ; if (Modifier.isPublic( mod ) && !Modifier.isStatic( mod )) if (fld.getType() == boolean.class) fld.setBoolean( this, true ) ; } catch (Exception exc) { // ignore it } } } /** Use the properties object to configure ORB state. * This may be overridden by subclasses, but they must call * super.parseProperties() to allow this class to set its state. */ protected void parseProperties(Properties props) { // get server debug flags String debugFlags = props.getProperty( ORBConstants.DEBUG_PROPERTY ) ; if (debugFlags != null) { if (ORBInitDebug) dprint( "Setting debug flags to " + debugFlags ) ; setDebugFlags(debugFlags) ; } String param = props.getProperty( ORBConstants.INITIAL_HOST_PROPERTY ) ; if (param != null) { if (ORBInitDebug) dprint( "setting initial host to " + param ) ; ORBInitialHost = param; } param = props.getProperty( ORBConstants.INITIAL_PORT_PROPERTY ) ; if (param != null) { try { ORBInitialPort = Integer.parseInt(param); if (ORBInitDebug) dprint( "setting initial services port to " + ORBInitialPort ) ; initialNamingClient.setInitialServicesPort(ORBInitialPort); } catch (java.lang.NumberFormatException e) {} } param = props.getProperty( ORBConstants.SERVER_HOST_PROPERTY ) ; if (param != null) { if (ORBInitDebug) dprint( "setting ORB server host to " + param ) ; ORBServerHost = param; } param = props.getProperty( ORBConstants.SERVER_PORT_PROPERTY ) ; if (param != null) { try { ORBServerPort = Integer.parseInt(param); if (ORBInitDebug) dprint( "setting ORB server port to " + ORBServerPort ) ; } catch (java.lang.NumberFormatException e) { } } param = props.getProperty( ORBConstants.ORB_ID_PROPERTY ) ; if (param != null) { if (ORBInitDebug) dprint( "setting ORB Id to " + param ) ; orbId = param; } param = props.getProperty( ORBConstants.INITIAL_SERVICES_PROPERTY ) ; if (param != null) { try { if (ORBInitDebug) dprint( "setting initial services URL to " + param ) ; initialNamingClient.setServicesURL(new URL(param)); } catch (java.io.IOException ex) { // Fallthrough } } param = props.getProperty( ORBConstants.ORB_INIT_REF_PROPERTY ); if (param != null) { try { if (ORBInitDebug) dprint( "setting ORBInitRef to " + param ) ; initialNamingClient.addORBInitRef(param); } catch (Exception ex) { // Fallthrough } } param = props.getProperty( ORBConstants.DEFAULT_INIT_REF_PROPERTY ) ; if (param != null) { try { if (ORBInitDebug) dprint( "setting ORBDefaultInitRef to " + param ) ; initialNamingClient.setORBDefaultInitRef(param); } catch (Exception ex) { // Fallthrough } } //...//The following 3 parameters are there for connection management. param = props.getProperty( ORBConstants.HIGH_WATER_MARK_PROPERTY ) ; if (param != null) { try { highWaterMark = Integer.parseInt(param); if (ORBInitDebug) dprint( "setting high water mark for connections " + highWaterMark ) ; } catch (java.lang.NumberFormatException e) {} } param = props.getProperty( ORBConstants.LOW_WATER_MARK_PROPERTY ) ; if (param != null) { try { lowWaterMark = Integer.parseInt(param); if (ORBInitDebug) dprint( "setting low water mark for connections " + lowWaterMark ) ; } catch (java.lang.NumberFormatException e) {} } param = props.getProperty( ORBConstants.NUMBER_TO_RECLAIM_PROPERTY ) ; if (param != null) { try { numberToReclaim = Integer.parseInt(param); if (ORBInitDebug) dprint( "setting number of connections to reclaim during cleanup " + numberToReclaim ) ; } catch (java.lang.NumberFormatException e) {} } //GIOP Related Constants. param = props.getProperty( ORBConstants.GIOP_VERSION ) ; if (param != null) { try { giopVersion = GIOPVersion.parseVersion(param); if (ORBInitDebug) dprint( "setting default GIOP version to " + giopVersion); } catch (java.lang.NumberFormatException e) { if (ORBInitDebug) dprint( "Error: " + e); } } param = props.getProperty( ORBConstants.GIOP_FRAGMENT_SIZE ) ; if (param != null) { try { giopFragmentSize = Integer.parseInt(param); if(giopFragmentSize < ORBConstants.GIOP_FRAGMENT_MINIMUM_SIZE){ throw new INITIALIZE(ORBConstants.GIOP_FRAGMENT_SIZE + " Illegal value: " + giopFragmentSize + " (must be at least " + ORBConstants.GIOP_FRAGMENT_MINIMUM_SIZE + ")"); } if (giopFragmentSize % ORBConstants.GIOP_FRAGMENT_DIVISOR != 0) throw new INITIALIZE(ORBConstants.GIOP_FRAGMENT_SIZE + " Illegal value: " + giopFragmentSize + " (not divisible by " + ORBConstants.GIOP_FRAGMENT_DIVISOR + ")"); if (ORBInitDebug) dprint( "setting GIOP fragment size to " + giopFragmentSize ) ; } catch (java.lang.NumberFormatException e) {} } param = props.getProperty( ORBConstants.GIOP_BUFFER_SIZE ) ; if (param != null) { try { giopBufferSize = Integer.parseInt(param); if (ORBInitDebug) dprint( "setting GIOP buffer size to " + giopFragmentSize ) ; } catch (java.lang.NumberFormatException e) {} } param = props.getProperty( ORBConstants.GIOP_11_BUFFMGR ) ; if (param != null) { try { giop11BuffMgr = Integer.parseInt(param); if (ORBInitDebug) dprint( "setting default GIOP11 BuffMgr to " + giop11BuffMgr); } catch (java.lang.NumberFormatException e) { if (ORBInitDebug) dprint( "Error: " + e); } } param = props.getProperty( ORBConstants.GIOP_12_BUFFMGR ) ; if (param != null) { try { giop12BuffMgr = Integer.parseInt(param); if (ORBInitDebug) dprint( "setting default GIOP12 BuffMgr to " + giop12BuffMgr); } catch (java.lang.NumberFormatException e) { if (ORBInitDebug) dprint( "Error: " + e); } } param = props.getProperty(ORBConstants.GIOP_TARGET_ADDRESSING); if (param != null) { try { short targetAddressing = Short.parseShort(param); switch (targetAddressing) { case ORBConstants.ADDR_DISP_OBJKEY : giopAddressDisposition = KeyAddr.value; giopTargetAddressPreference = targetAddressing; break; case ORBConstants.ADDR_DISP_PROFILE : giopAddressDisposition = ProfileAddr.value; giopTargetAddressPreference = targetAddressing; break; case ORBConstants.ADDR_DISP_IOR : giopAddressDisposition = ReferenceAddr.value; giopTargetAddressPreference = targetAddressing; break; case ORBConstants.ADDR_DISP_HANDLE_ALL : giopAddressDisposition = KeyAddr.value; giopTargetAddressPreference = targetAddressing; break; default:
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?