Methods Summary |
---|
public void | accept()
try {
SocketChannel socketChannel = null;
Socket socket = null;
if (serverSocketChannel == null) {
socket = serverSocket.accept();
} else {
socketChannel = serverSocketChannel.accept();
socket = socketChannel.socket();
}
orb.getORBData().getSocketFactory()
.setAcceptedSocketOptions(this, serverSocket, socket);
if (orb.transportDebugFlag) {
dprint(".accept: " +
(serverSocketChannel == null
? serverSocket.toString()
: serverSocketChannel.toString()));
}
CorbaConnection connection =
new SocketOrChannelConnectionImpl(orb, this, socket);
if (orb.transportDebugFlag) {
dprint(".accept: new: " + connection);
}
// NOTE: The connection MUST be put in the cache BEFORE being
// registered with the selector. Otherwise if the bytes
// are read on the connection it will attempt a time stamp
// but the cache will be null, resulting in NPE.
getConnectionCache().put(this, connection);
if (connection.shouldRegisterServerReadEvent()) {
Selector selector = orb.getTransportManager().getSelector(0);
selector.registerForEvent(connection.getEventHandler());
}
getConnectionCache().reclaim();
} catch (IOException e) {
if (orb.transportDebugFlag) {
dprint(".accept:", e);
}
orb.getTransportManager().getSelector(0).unregisterForEvent(this);
// REVISIT - need to close - recreate - then register new one.
orb.getTransportManager().getSelector(0).registerForEvent(this);
// NOTE: if register cycling we do not want to shut down ORB
// since local beans will still work. Instead one will see
// a growing log file to alert admin of problem.
}
|
public void | addToIORTemplate(com.sun.corba.se.spi.ior.IORTemplate iorTemplate, com.sun.corba.se.impl.oa.poa.Policies policies, java.lang.String codebase)
Iterator iterator = iorTemplate.iteratorById(
org.omg.IOP.TAG_INTERNET_IOP.value);
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 void | close()
try {
if (orb.transportDebugFlag) {
dprint(".close->:");
}
Selector selector = orb.getTransportManager().getSelector(0);
selector.unregisterForEvent(this);
if (serverSocketChannel != null) {
serverSocketChannel.close();
}
if (serverSocket != null) {
serverSocket.close();
}
} catch (IOException e) {
if (orb.transportDebugFlag) {
dprint(".close:", e);
}
} finally {
if (orb.transportDebugFlag) {
dprint(".close<-:");
}
}
|
public com.sun.corba.se.pept.encoding.InputObject | createInputObject(com.sun.corba.se.pept.broker.Broker broker, com.sun.corba.se.pept.protocol.MessageMediator messageMediator)
CorbaMessageMediator corbaMessageMediator = (CorbaMessageMediator)
messageMediator;
return new CDRInputObject((ORB)broker,
(CorbaConnection)messageMediator.getConnection(),
corbaMessageMediator.getDispatchBuffer(),
corbaMessageMediator.getDispatchHeader());
|
public com.sun.corba.se.pept.protocol.MessageMediator | createMessageMediator(com.sun.corba.se.pept.broker.Broker broker, com.sun.corba.se.pept.transport.Connection connection)
// REVISIT - no factoring so cheat to avoid code dup right now.
// REVISIT **** COUPLING !!!!
ContactInfo contactInfo = new SocketOrChannelContactInfoImpl();
return contactInfo.createMessageMediator(broker, connection);
|
public com.sun.corba.se.pept.encoding.OutputObject | createOutputObject(com.sun.corba.se.pept.broker.Broker broker, com.sun.corba.se.pept.protocol.MessageMediator messageMediator)
CorbaMessageMediator corbaMessageMediator = (CorbaMessageMediator)
messageMediator;
return new CDROutputObject((ORB) broker, corbaMessageMediator,
corbaMessageMediator.getReplyHeader(),
corbaMessageMediator.getStreamFormatVersion());
|
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);
}
}
|
protected void | dprint(java.lang.String msg)
ORBUtility.dprint(toStringName(), msg);
|
protected void | dprint(java.lang.String msg, java.lang.Throwable t)
dprint(msg);
t.printStackTrace(System.out);
|
public com.sun.corba.se.pept.protocol.MessageMediator | finishCreatingMessageMediator(com.sun.corba.se.pept.broker.Broker broker, com.sun.corba.se.pept.transport.Connection connection, com.sun.corba.se.pept.protocol.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 com.sun.corba.se.pept.transport.Acceptor | getAcceptor()
return this;
|
public java.nio.channels.SelectableChannel | getChannel()
return serverSocketChannel;
|
public com.sun.corba.se.pept.transport.Connection | getConnection()
throw new RuntimeException("Should not happen.");
|
public com.sun.corba.se.pept.transport.InboundConnectionCache | getConnectionCache()
return connectionCache;
|
public java.lang.String | getConnectionCacheType()
return this.getClass().toString();
|
public long | getEnqueueTime()
return enqueueTime;
|
public com.sun.corba.se.pept.transport.EventHandler | getEventHandler()
return this;
|
public java.lang.String | getHost()
return hostname;
|
public java.lang.String | getHostName()
return hostname;
|
public int | getInterestOps()
return SelectionKey.OP_ACCEPT;
|
public int | getLocatorPort()
return locatorPort;
|
public java.lang.String | getMonitoringName()
return "AcceptedConnections";
|
public java.lang.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;
|
public java.lang.String | getObjectAdapterId()
return null;
|
public java.lang.String | getObjectAdapterManagerId()
return null;
|
public int | getPort()
return port;
|
public java.net.ServerSocket | getServerSocket()
return serverSocket;
|
public java.lang.String | getType()
return type;
|
public boolean | initialize()
if (initialized) {
return false;
}
if (orb.transportDebugFlag) {
dprint(".initialize: " + this);
}
InetSocketAddress inetSocketAddress = null;
try {
if (orb.getORBData().getListenOnAllInterfaces().equals(ORBConstants.LISTEN_ON_ALL_INTERFACES)) {
inetSocketAddress = new InetSocketAddress(port);
} else {
String host = orb.getORBData().getORBServerHost();
inetSocketAddress = new InetSocketAddress(host, port);
}
serverSocket = orb.getORBData().getSocketFactory()
.createServerSocket(type, inetSocketAddress);
internalInitialize();
} catch (Throwable t) {
throw wrapper.createListenerFailed( t, Integer.toString(port) ) ;
}
initialized = true;
return true;
|
public boolean | initialized()
return initialized;
|
protected void | internalInitialize()
// Determine the listening port (for the IOR).
// This is important when using emphemeral ports (i.e.,
// when the port value to the constructor is 0).
port = serverSocket.getLocalPort();
// Register with transport (also sets up monitoring).
orb.getCorbaTransportManager().getInboundConnectionCache(this);
// Finish configuation.
serverSocketChannel = serverSocket.getChannel();
if (serverSocketChannel != null) {
setUseSelectThreadToWait(
orb.getORBData().acceptorSocketUseSelectThreadToWait());
serverSocketChannel.configureBlocking(
! orb.getORBData().acceptorSocketUseSelectThreadToWait());
} else {
// Configure to use listener and reader threads.
setUseSelectThreadToWait(false);
}
setUseWorkerThreadForEvent(
orb.getORBData().acceptorSocketUseWorkerThreadForEvent());
|
public void | setConnectionCache(com.sun.corba.se.pept.transport.InboundConnectionCache connectionCache)
this.connectionCache = connectionCache;
|
public void | setEnqueueTime(long timeInMillis)
enqueueTime = timeInMillis;
|
public void | setLocatorPort(int port)
locatorPort = port;
|
public boolean | shouldRegisterAcceptEvent()
return true;
|
public java.lang.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 java.lang.String | toStringName()
return "SocketOrChannelAcceptorImpl";
|