public final class TcpEventReceiver extends Object implements EventReceiver, TcpEventReceiverMBean
Modifier and Type | Field and Description |
---|---|
static int |
UNLIMITED_EVENTS
The value that defines unlimited events per connection.
|
RUNNING, START_PENDING, STARTING, STATUS_NAMES, STOP_PENDING, STOPPED
Constructor and Description |
---|
TcpEventReceiver()
Constructs a new TCP/IP event receiver on the default TCP/IP port.
|
TcpEventReceiver(int port,
String ipAddress)
Constructs a new TCP/IP event receiver on the passed port.
|
Modifier and Type | Method and Description |
---|---|
void |
addEventHandler(EventHandler handler)
Adds a new event handler to receiver.
|
void |
addEventHandler(String name)
Adds a new event handler by its managed name.
|
void |
destroy()
Called when the fiber is destroyed
|
List<EventHandler> |
getEventHandlers()
getEventHandlers
|
String |
getIpAddress()
getIpAddress
|
String |
getName()
Returns the name of this Fiber.
|
Integer |
getPort()
getPort
|
int |
getStatus()
Returns the status of this Fiber.
|
String |
getStatusText()
getStatusText
|
void |
init()
Called when the fiber is initialized
|
void |
removeEventHandler(EventHandler handler)
Removes an event handler from the list of handler called when an event is
received.
|
void |
removeEventHandler(String name)
Removes an event handler.
|
void |
setEventHandlers(List<EventHandler> eventHandlers)
setEventHandlers
|
void |
setEventsPerConnection(Integer number)
The number of event records a new connection is allowed to send before
the connection is terminated by the server.
|
void |
setIpAddress(String ipAddress)
setIpAddress
|
void |
setLogPrefix(String prefix)
The logging prefix to use
|
void |
setPort(Integer port)
Sets the port where new requests will be handled.
|
void |
start()
Allocates the server socket and starts up the server socket processor
thread.
|
String |
status()
status
|
void |
stop()
Stops the TCP/IP event receiver.
|
public static final int UNLIMITED_EVENTS
public TcpEventReceiver() throws UnknownHostException
UnknownHostException
- if any.public TcpEventReceiver(int port, String ipAddress) throws UnknownHostException
port
- The binding port for the TCP/IP server socket.ipAddress
- TODOUnknownHostException
- if any.public void start()
runtime exception
is thrown.start
in interface Fiber
start
in interface BaseOnmsMBean
UndeclaredThrowableException
- Thrown if an error occurs allocating the server socket.RuntimeException
- Thrown if the fiber is in an erronous state or the underlying
thread cannot be started.public void stop()
joined
.stop
in interface Fiber
stop
in interface BaseOnmsMBean
public String getName()
public int getStatus()
getStatus
in interface Fiber
getStatus
in interface BaseOnmsMBean
public String getStatusText()
getStatusText
getStatusText
in interface BaseOnmsMBean
String
object.public String status()
status
status
in interface BaseOnmsMBean
String
object.public void init()
init
in interface InitializableFiber
init
in interface BaseOnmsMBean
public void destroy()
destroy
in interface InitializableFiber
destroy
in interface TcpEventReceiverMBean
public void addEventHandler(EventHandler handler)
addEventHandler
in interface EventReceiver
handler
- A reference to an event handlerpublic void removeEventHandler(EventHandler handler)
equals()
inherieted from the Object
class.
Removes an event handler from the list of handler called when an event is
received. The handler is removed based upon the method
equals()
inherieted from the Object
class.removeEventHandler
in interface EventReceiver
handler
- A reference to the event handler.public List<EventHandler> getEventHandlers()
getEventHandlers
List
object.public void setEventHandlers(List<EventHandler> eventHandlers)
setEventHandlers
eventHandlers
- a List
object.public void setIpAddress(String ipAddress)
setIpAddress
ipAddress
- a String
object.public Integer getPort()
getPort
getPort
in interface TcpEventReceiverMBean
Integer
object.public void setPort(Integer port)
setPort
in interface TcpEventReceiverMBean
port
- The port to listen on.public void addEventHandler(String name) throws MalformedObjectNameException, InstanceNotFoundException
addEventHandler
in interface TcpEventReceiverMBean
name
- The name of the handler to add.MalformedObjectNameException
- Thrown if the passed name is not a valid ObjectName.InstanceNotFoundException
- Thrown if no managed bean can be found that matches the name.public void removeEventHandler(String name) throws MalformedObjectNameException, InstanceNotFoundException
removeEventHandler
in interface TcpEventReceiverMBean
name
- The name of the handler to remove.MalformedObjectNameException
- Thrown if the passed name is not a valid ObjectName.InstanceNotFoundException
- Thrown if no managed bean can be found that matches the name.public void setLogPrefix(String prefix)
setLogPrefix
in interface TcpEventReceiverMBean
prefix
- a String
object.public void setEventsPerConnection(Integer number)
setEventsPerConnection
in interface TcpEventReceiverMBean
number
- The number of event records.Copyright © 2017. All rights reserved.