📄 socketorchannelacceptorimpl.java
字号:
String hostname = orb.getORBData().getORBServerHost(); if (iterator.hasNext()) { // REVISIT - how does this play with legacy ORBD port exchange? IIOPAddress iiopAddress = IIOPFactories.makeIIOPAddress(orb, hostname, port); AlternateIIOPAddressComponent iiopAddressComponent = IIOPFactories.makeAlternateIIOPAddressComponent(iiopAddress); while (iterator.hasNext()) { TaggedProfileTemplate taggedProfileTemplate = (TaggedProfileTemplate) iterator.next(); taggedProfileTemplate.add(iiopAddressComponent); } } else { GIOPVersion version = orb.getORBData().getGIOPVersion(); int templatePort; if (policies.forceZeroPort()) { templatePort = 0; } else if (policies.isTransient()) { templatePort = port; } else { templatePort = orb.getLegacyServerSocketManager() .legacyGetPersistentServerPort(SocketInfo.IIOP_CLEAR_TEXT); } IIOPAddress addr = IIOPFactories.makeIIOPAddress(orb, hostname, templatePort); IIOPProfileTemplate iiopProfile = IIOPFactories.makeIIOPProfileTemplate(orb, version, addr); if (version.supportsIORIIOPProfileComponents()) { iiopProfile.add(IIOPFactories.makeCodeSetsComponent(orb)); iiopProfile.add(IIOPFactories.makeMaxStreamFormatVersionComponent()); RequestPartitioningPolicy rpPolicy = (RequestPartitioningPolicy) policies.get_effective_policy( ORBConstants.REQUEST_PARTITIONING_POLICY); if (rpPolicy != null) { iiopProfile.add( IIOPFactories.makeRequestPartitioningComponent( rpPolicy.getValue())); } if (codebase != null && codebase != "") { iiopProfile.add(IIOPFactories. makeJavaCodebaseComponent(codebase)); } if (orb.getORBData().isJavaSerializationEnabled()) { iiopProfile.add( IIOPFactories.makeJavaSerializationComponent()); } } iorTemplate.add(iiopProfile); } } public String getMonitoringName() { return "AcceptedConnections"; } //////////////////////////////////////////////////// // // EventHandler methods // public SelectableChannel getChannel() { return serverSocketChannel; } public int getInterestOps() { return SelectionKey.OP_ACCEPT; } public Acceptor getAcceptor() { return this; } public Connection getConnection() { throw new RuntimeException("Should not happen."); } //////////////////////////////////////////////////// // // Work methods. // /* CONFLICT: with legacy below. public String getName() { return this.toString(); } */ public void doWork() { try { if (orb.transportDebugFlag) { dprint(".doWork->: " + this); } if (selectionKey.isAcceptable()) { AccessController.doPrivileged(new PrivilegedAction() { public java.lang.Object run() { accept(); return null; } }); } else { if (orb.transportDebugFlag) { dprint(".doWork: ! selectionKey.isAcceptable: " + this); } } } catch (SecurityException se) { if (orb.transportDebugFlag) { dprint(".doWork: ignoring SecurityException: " + se + " " + this); } String permissionStr = ORBUtility.getClassSecurityInfo(getClass()); wrapper.securityExceptionInAccept(se, permissionStr); } catch (Exception ex) { if (orb.transportDebugFlag) { dprint(".doWork: ignoring Exception: " + ex + " " + this); } wrapper.exceptionInAccept(ex); } catch (Throwable t) { if (orb.transportDebugFlag) { dprint(".doWork: ignoring Throwable: " + t + " " + this); } } finally { // IMPORTANT: To avoid bug (4953599), we force the // Thread that does the NIO select to also do the // enable/disable of Ops using SelectionKey.interestOps(). // Otherwise, the SelectionKey.interestOps() may block // indefinitely. // NOTE: If "acceptorSocketUseWorkerThreadForEvent" is // set to to false in ParserTable.java, then this method, // doWork(), will get executed by the same thread // (SelectorThread) that does the NIO select. // If "acceptorSocketUseWorkerThreadForEvent" is set // to true, a WorkerThread will execute this method, // doWork(). Hence, the registering of the enabling of // the SelectionKey's interestOps is done here instead // of calling SelectionKey.interestOps(<interest op>). Selector selector = orb.getTransportManager().getSelector(0); selector.registerInterestOps(this); if (orb.transportDebugFlag) { dprint(".doWork<-:" + this); } } } public void setEnqueueTime(long timeInMillis) { enqueueTime = timeInMillis; } public long getEnqueueTime() { return enqueueTime; } // // Factory methods. // // REVISIT: refactor into common base or delegate. public MessageMediator createMessageMediator(Broker broker, Connection connection) { // REVISIT - no factoring so cheat to avoid code dup right now. // REVISIT **** COUPLING !!!! ContactInfo contactInfo = new SocketOrChannelContactInfoImpl(); return contactInfo.createMessageMediator(broker, connection); } // REVISIT: refactor into common base or delegate. public MessageMediator finishCreatingMessageMediator(Broker broker, Connection connection, MessageMediator messageMediator) { // REVISIT - no factoring so cheat to avoid code dup right now. // REVISIT **** COUPLING !!!! ContactInfo contactInfo = new SocketOrChannelContactInfoImpl(); return contactInfo.finishCreatingMessageMediator(broker, connection, messageMediator); } public InputObject createInputObject(Broker broker, MessageMediator messageMediator) { CorbaMessageMediator corbaMessageMediator = (CorbaMessageMediator) messageMediator; return new CDRInputObject((ORB)broker, (CorbaConnection)messageMediator.getConnection(), corbaMessageMediator.getDispatchBuffer(), corbaMessageMediator.getDispatchHeader()); } public OutputObject createOutputObject(Broker broker, MessageMediator messageMediator) { CorbaMessageMediator corbaMessageMediator = (CorbaMessageMediator) messageMediator; return new CDROutputObject((ORB) broker, corbaMessageMediator, corbaMessageMediator.getReplyHeader(), corbaMessageMediator.getStreamFormatVersion()); } //////////////////////////////////////////////////// // // SocketOrChannelAcceptor // public ServerSocket getServerSocket() { return serverSocket; } //////////////////////////////////////////////////// // // Implementation. // public String toString() { String sock; if (serverSocketChannel == null) { if (serverSocket == null) { sock = "(not initialized)"; } else { sock = serverSocket.toString(); } } else { sock = serverSocketChannel.toString(); } return toStringName() + "[" + sock + " " + type + " " + shouldUseSelectThreadToWait() + " " + shouldUseWorkerThreadForEvent() + "]" ; } protected String toStringName() { return "SocketOrChannelAcceptorImpl"; } protected void dprint(String msg) { ORBUtility.dprint(toStringName(), msg); } protected void dprint(String msg, Throwable t) { dprint(msg); t.printStackTrace(System.out); } // BEGIN Legacy support //////////////////////////////////////////////////// // // LegacyServerSocketEndPointInfo and EndPointInfo // public String getType() { return type; } public String getHostName() { return hostname; } public String getHost() { return hostname; } public int getPort() { return port; } public int getLocatorPort() { return locatorPort; } public void setLocatorPort (int port) { locatorPort = port; } public String getName() { // Kluge alert: // Work and Legacy both define getName. // Try to make this behave best for most cases. String result = name.equals(LegacyServerSocketEndPointInfo.NO_NAME) ? this.toString() : name; return result; } // END Legacy support}// End of file.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -