xmlBlaster 2.2.0 client API

org.xmlBlaster.util.protocol.socket
Class SocketUrl

java.lang.Object
  extended by org.xmlBlaster.util.protocol.socket.SocketUrl

public class SocketUrl
extends java.lang.Object

This knows how to parse the URL notation of our SOCKET protocol. It holds the hostname and the port.

See Also:
The protocol.socket requirement, org.xmlBlaster.test.classtest.SocketUrlTest

Field Summary
static int DEFAULT_SERVER_PORT
          Default port of xmlBlaster socket server is 7607
static boolean SOCKET_TCP
          Flag to use TCP/IP
static boolean SOCKET_UDP
          Flag to use UDP
 
Constructor Summary
SocketUrl(Global glob, AddressBase address)
          Extract "hostname" and "port" from environment, if not found use the local host for hostname and the default port 7607.
SocketUrl(Global glob, AddressBase address, boolean isLocal, int defaultServerPort)
          Extract hostname and port from environment, if not found use the local host for hostname and the given default port (usually ExecutorBase.DEFAULT_SERVER_PORT=7607).
SocketUrl(Global glob, java.lang.String url)
          Parse the given url.
SocketUrl(Global glob, java.lang.String hostname, int port)
           
 
Method Summary
 java.net.ServerSocket createServerSocketSSL(int backlog, AddressBase address)
          Helper to create a server side SSL socket, uses reflection to compile with JDK 1.3 SSL support can't be used with a standard JDK 1.3

Setup:

 javax.net.ssl.SSLSocketFactory createSocketFactorySSL(AddressBase address)
           
 java.net.Socket createSocketSSL_OLD(SocketUrl localSocketUrl, AddressBase address)
          Helper to create a SSL socket, uses reflection to compile with JDK 1.3 SSL support can't be used with a standard JDK 1.3
 java.net.Socket createSocketSSL(SocketUrl localSocketUrl, AddressBase address)
          Helper to create a SSL socket, uses reflection to compile with JDK 1.3 SSL support can't be used with a standard JDK 1.3
 boolean equals(SocketUrl other)
           
 java.lang.String getHostname()
           
 java.net.InetAddress getInetAddress()
           
 int getPort()
           
 java.lang.String getUrl()
           
 boolean isEnforced()
           
static void main(java.lang.String[] args)
          java org.xmlBlaster.protocol.socket.SocketUrl socket://localhost:7609
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SOCKET_TCP

public static final boolean SOCKET_TCP
Flag to use TCP/IP

See Also:
Constant Field Values

SOCKET_UDP

public static final boolean SOCKET_UDP
Flag to use UDP

See Also:
Constant Field Values

DEFAULT_SERVER_PORT

public static final int DEFAULT_SERVER_PORT
Default port of xmlBlaster socket server is 7607

See Also:
Constant Field Values
Constructor Detail

SocketUrl

public SocketUrl(Global glob,
                 java.lang.String hostname,
                 int port)
          throws XmlBlasterException
Parameters:
hostname - if null or empty the local IP will be used
port - any port, not checked
Throws:
XmlBlasterException

SocketUrl

public SocketUrl(Global glob,
                 java.lang.String url)
          throws XmlBlasterException
Parse the given url.

Parameters:
url - e.g. "socket://127.168.1.1:7607" or only "127.168.1.1:7607" or "" (choose default settings)
Throws:
XmlBlasterException - if url is null or invalid

SocketUrl

public SocketUrl(Global glob,
                 AddressBase address)
          throws XmlBlasterException
Extract "hostname" and "port" from environment, if not found use the local host for hostname and the default port 7607.
Updates the raw address from AddressBase

Throws:
XmlBlasterException

SocketUrl

public SocketUrl(Global glob,
                 AddressBase address,
                 boolean isLocal,
                 int defaultServerPort)
          throws XmlBlasterException
Extract hostname and port from environment, if not found use the local host for hostname and the given default port (usually ExecutorBase.DEFAULT_SERVER_PORT=7607).
Updates the raw address from AddressBase if isLocal==false

Parameters:
isLocal - If local is set to true "localHostname" and "localPort" will be extracted
Throws:
XmlBlasterException
Method Detail

isEnforced

public boolean isEnforced()
Returns:
true if host or port was given by user configuration, false if default is chosen

getHostname

public java.lang.String getHostname()

getPort

public int getPort()

getUrl

public java.lang.String getUrl()
Returns:
for example "socket://myServer.com:7607"

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getInetAddress

public java.net.InetAddress getInetAddress()

equals

public boolean equals(SocketUrl other)

createServerSocketSSL

public java.net.ServerSocket createServerSocketSSL(int backlog,
                                                   AddressBase address)
                                            throws XmlBlasterException
Helper to create a server side SSL socket, uses reflection to compile with JDK 1.3 SSL support can't be used with a standard JDK 1.3

Setup:

keytool -genkey -keystore testStore -keyalg RSA   (using password 'testtest')

java org.xmlBlaster.Main -plugin/socket/SSL true -plugin/socket/keyStore testStore -plugin/socket/keyStorePassword testtest  

java javaclients.HelloWorldPublish -plugin/socket/SSL true -plugin/socket/keyStore testStore -plugin/socket/keyStorePassword testtest
 

Parameters:
backlog - Socket parameter
address - The configuration environment
Throws:
XmlBlasterException

createSocketSSL_OLD

public java.net.Socket createSocketSSL_OLD(SocketUrl localSocketUrl,
                                           AddressBase address)
                                    throws XmlBlasterException
Helper to create a SSL socket, uses reflection to compile with JDK 1.3 SSL support can't be used with a standard JDK 1.3

Parameters:
localSocketUrl - null or a configured local socket setting
address - The configuration environment
Throws:
XmlBlasterException

main

public static void main(java.lang.String[] args)
java org.xmlBlaster.protocol.socket.SocketUrl socket://localhost:7609


createSocketFactorySSL

public javax.net.ssl.SSLSocketFactory createSocketFactorySSL(AddressBase address)
                                                      throws XmlBlasterException
Throws:
XmlBlasterException

createSocketSSL

public java.net.Socket createSocketSSL(SocketUrl localSocketUrl,
                                       AddressBase address)
                                throws XmlBlasterException
Helper to create a SSL socket, uses reflection to compile with JDK 1.3 SSL support can't be used with a standard JDK 1.3

Parameters:
localSocketUrl - null or a configured local socket setting
address - The configuration environment
Throws:
XmlBlasterException

xmlBlaster 2.2.0 client API

Copyright © 1999-2014 The xmlBlaster.org contributers.