| Method from org.jboss.mq.il.uil2.UILServerILService Detail: |
public String getBindAddress() {
String addr = "0.0.0.0";
if (bindAddress != null)
addr = bindAddress.getHostName();
return addr;
}
Get the interface address the UIL2 server bind its listening port on |
public int getBufferSize() {
return bufferSize;
}
|
public int getChunkSize() {
return chunkSize;
}
|
public InetAddress getClientAddress() {
return clientAddress;
}
|
public Properties getClientConnectionProperties() {
return connectionProperties;
}
Used to construct the GenericConnectionFactory (bindJNDIReferences()
builds it) Sets up the connection properties need by a client to use this
IL |
public int getClientReadTimeout() {
return clientReadTimeout;
}
|
public String getClientSocketFactory() {
return clientSocketFactoryName;
}
Get the javax.net.SocketFactory implementation class to use on the
client. |
public String getConnectAddress() {
return connectAddress;
}
|
public int getConnectPort() {
return connectPort;
}
|
public boolean getEnableTcpNoDelay() {
return enableTcpNoDelay;
}
Gets the enableTcpNoDelay. |
public int getReadTimeout() {
return readTimeout;
}
|
public String getSecurityDomain() {
return this.securityDomain;
}
Get the security domain name to use with SSL aware socket factories |
public int getServerBindPort() {
return serverBindPort;
}
Get the UIL server listening port |
public ServerIL getServerIL() {
return serverIL;
}
Used to construct the GenericConnectionFactory (bindJNDIReferences()
builds it) |
public String getServerSocketFactory() {
String name = null;
if (serverSocketFactory != null)
name = serverSocketFactory.getClass().getName();
return name;
}
Get the javax.net.ServerSocketFactory implementation class to use to
create the service SocketFactory. |
protected void removeHandler(ServerSocketManagerHandler handler) {
handlers.remove(handler);
}
|
public void run() {
boolean trace = log.isTraceEnabled();
while (running.get())
{
Socket socket = null;
SocketManager socketMgr = null;
try
{
socket = serverSocket.accept();
if( trace )
log.trace("Accepted connection: "+socket);
socket.setSoTimeout(readTimeout);
socket.setTcpNoDelay(enableTcpNoDelay);
socketMgr = new SocketManager(socket);
ServerSocketManagerHandler handler = new ServerSocketManagerHandler(getJMSServer(), socketMgr, this);
handlers.add(handler);
socketMgr.setHandler(handler);
socketMgr.setBufferSize(bufferSize);
socketMgr.setChunkSize(chunkSize);
Invoker s = getJMSServer();
socketMgr.start(s.getThreadGroup());
}
catch (IOException e)
{
if (running.get())
log.warn("Failed to setup client connection", e);
}
catch(Throwable e)
{
if (running.get() || trace)
log.warn("Unexpected error in setup of client connection", e);
}
}
}
Client socket accept thread. |
public void setBindAddress(String host) throws UnknownHostException {
// If host is null or empty use any address
if (host == null || host.length() == 0)
bindAddress = null;
else
bindAddress = InetAddress.getByName(host);
}
Set the interface address the UIL2 server bind its listening port on |
public void setBufferSize(int size) {
this.bufferSize = size;
}
|
public void setChunkSize(int size) {
this.chunkSize = size;
}
|
public void setClientAddress(InetAddress addr) {
log.warn("ClientAddress has been deprecated, use ConnectAddress");
clientAddress = addr;
}
|
public void setClientReadTimeout(int timeout) {
this.clientReadTimeout = timeout;
}
|
public void setClientSocketFactory(String name) {
this.clientSocketFactoryName = name;
}
Set the javax.net.SocketFactory implementation class to use on the
client. |
public void setConnectAddress(String addr) {
connectAddress = addr;
}
|
public void setConnectPort(int port) {
connectPort = port;
}
|
public void setEnableTcpNoDelay(boolean enableTcpNoDelay) {
this.enableTcpNoDelay = enableTcpNoDelay;
}
Sets the enableTcpNoDelay. |
public void setReadTimeout(int timeout) {
this.readTimeout = timeout;
}
|
public void setSecurityDomain(String domainName) {
this.securityDomain = domainName;
}
Set the security domain name to use with SSL aware socket factories |
public void setServerBindPort(int serverBindPort) {
this.serverBindPort = serverBindPort;
}
Set the UIL server listening port |
public void setServerSocketFactory(String name) throws Exception {
ClassLoader loader = Thread.currentThread().getContextClassLoader();
Class ssfClass = loader.loadClass(name);
serverSocketFactory = (ServerSocketFactory) ssfClass.newInstance();
}
Set the javax.net.ServerSocketFactory implementation class to use to
create the service SocketFactory. |
public void startService() throws Exception {
super.startService();
// Use the default javax.net.ServerSocketFactory if none was set
if (serverSocketFactory == null)
serverSocketFactory = ServerSocketFactory.getDefault();
/* See if the server socket supports setSecurityDomain(SecurityDomain)
if an securityDomain was specified
*/
if (securityDomain != null)
{
try
{
InitialContext ctx = new InitialContext();
Class ssfClass = serverSocketFactory.getClass();
SecurityDomain domain = (SecurityDomain) ctx.lookup(securityDomain);
Class[] parameterTypes = {SecurityDomain.class};
Method m = ssfClass.getMethod("setSecurityDomain", parameterTypes);
Object[] args = {domain};
m.invoke(serverSocketFactory, args);
}
catch (NoSuchMethodException e)
{
log.error("Socket factory does not support setSecurityDomain(SecurityDomain)");
}
catch (Exception e)
{
log.error("Failed to setSecurityDomain=" + securityDomain + " on socket factory");
}
}
// Create the server socket using the socket factory
serverSocket = serverSocketFactory.createServerSocket(serverBindPort, 50, bindAddress);
InetAddress socketAddress = serverSocket.getInetAddress();
log.info("JBossMQ UIL service available at : " + socketAddress + ":" + serverSocket.getLocalPort());
acceptThread = new Thread(getJMSServer().getThreadGroup(), this, "UILServerILService Accept Thread");
running.set(true);
acceptThread.start();
/* We need to check the socketAddress against "0.0.0.0/0.0.0.0"
because this is not a valid address on Win32 while it is for
*NIX. See BugParade bug #4343286.
*/
socketAddress = ServerConfigUtil.fixRemoteAddress(socketAddress);
// If an explicit client bind address has been specified use it
if( clientAddress != null )
socketAddress = clientAddress;
serverIL = new UILServerIL(socketAddress, serverSocket.getLocalPort(),
clientSocketFactoryName, enableTcpNoDelay, bufferSize, chunkSize, clientReadTimeout, connectAddress, connectPort);
// Initialize the connection poperties using the base class.
connectionProperties = super.getClientConnectionProperties();
connectionProperties.setProperty(UILServerILFactory.CLIENT_IL_SERVICE_KEY, UILClientILService.class.getName());
connectionProperties.setProperty(UILServerILFactory.UIL_PORT_KEY, "" + serverSocket.getLocalPort());
connectionProperties.setProperty(UILServerILFactory.UIL_ADDRESS_KEY, "" + socketAddress.getHostAddress());
connectionProperties.setProperty(UILServerILFactory.UIL_TCPNODELAY_KEY, enableTcpNoDelay ? "yes" : "no");
connectionProperties.setProperty(UILServerILFactory.UIL_BUFFERSIZE_KEY, "" + bufferSize);
connectionProperties.setProperty(UILServerILFactory.UIL_CHUNKSIZE_KEY, "" + chunkSize);
connectionProperties.setProperty(UILServerILFactory.UIL_RECEIVE_REPLIES_KEY, "No");
connectionProperties.setProperty(UILServerILFactory.UIL_SOTIMEOUT_KEY, "" + clientReadTimeout);
connectionProperties.setProperty(UILServerILFactory.UIL_CONNECTADDRESS_KEY, "" + connectAddress);
connectionProperties.setProperty(UILServerILFactory.UIL_CONNECTPORT_KEY, "" + connectPort);
bindJNDIReferences();
BaseMsg.setUseJMSServerMsgIDs(true);
}
Starts this IL, and binds it to JNDI |
public void stopService() {
try
{
running.set(false);
unbindJNDIReferences();
// unbind Server Socket if needed
if (serverSocket != null)
{
serverSocket.close();
}
}
catch (Exception e)
{
log.error("Exception occured when trying to stop UIL Service: ", e);
}
// Try to close any open sockets that we know about
for (Iterator i = handlers.iterator(); i.hasNext();)
{
ServerSocketManagerHandler handler = (ServerSocketManagerHandler) i.next();
if (handler != null)
{
try
{
handler.close();
}
catch (Throwable ignored)
{
}
}
}
}
Stops this IL, and unbinds it from JNDI |