Package org.jgrapes.net
Class SocketConnector
java.lang.Object
org.jgrapes.core.internal.ComponentVertex
org.jgrapes.core.Component
org.jgrapes.net.SocketConnectionManager
org.jgrapes.net.SocketConnector
- All Implemented Interfaces:
Iterable<ComponentType>
,Channel
,ComponentType
,Eligible
,Manager
A component that reads from or write to a socket connection.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.jgrapes.net.SocketConnectionManager
SocketConnectionManager.SocketChannelImpl
Nested classes/interfaces inherited from interface org.jgrapes.core.Channel
Channel.Default
-
Field Summary
Fields inherited from class org.jgrapes.net.SocketConnectionManager
channels
-
Constructor Summary
ConstructorDescriptionCreates a new connector, using itself as component channel.SocketConnector
(Channel channel) Create a new instance using the given channel. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Shuts down the one of the connections.void
Opens a connection to the end point specified in the event.void
Called when the new socket channel has successfully been registered with the nio dispatcher.setBufferSize
(int size) Sets the buffer size for the send an receive buffers.Methods inherited from class org.jgrapes.net.SocketConnectionManager
bufferSize, executorService, onOutput, removeChannel, setExecutorService, toString
Methods inherited from class org.jgrapes.core.Component
channel, component, defaultCriterion, isEligibleFor, setName
Methods inherited from class org.jgrapes.core.internal.ComponentVertex
activeEventPipeline, addHandler, attach, channelReplacements, children, componentPath, componentVertex, detach, fire, initComponentsHandlers, iterator, name, newEventPipeline, newEventPipeline, parent, registerAsGenerator, root, unregisterAsGenerator
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
SocketConnector
Create a new instance using the given channel.- Parameters:
channel
- the component’s channel
-
SocketConnector
public SocketConnector()Creates a new connector, using itself as component channel.
-
-
Method Details
-
setBufferSize
Description copied from class:SocketConnectionManager
Sets the buffer size for the send an receive buffers.If no size is set, a default value of 32768 will be used.
- Overrides:
setBufferSize
in classSocketConnectionManager
- Parameters:
size
- the size to use for the send and receive buffers- Returns:
- the socket connection manager for easy chaining
-
onOpenConnection
Opens a connection to the end point specified in the event.- Parameters:
event
- the event
-
onRegistered
@Handler(channels=Self.class) public void onRegistered(NioRegistration.Completed event) throws InterruptedException, IOException Called when the new socket channel has successfully been registered with the nio dispatcher.- Parameters:
event
- the event- Throws:
InterruptedException
- the interrupted exceptionIOException
- Signals that an I/O exception has occurred.
-
onClose
Shuts down the one of the connections.- Parameters:
event
- the event- Throws:
IOException
- if an I/O exception occurredInterruptedException
- if the execution was interrupted
-