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.SocketChannelImplNested classes/interfaces inherited from interface org.jgrapes.core.Channel
Channel.Default -
Field Summary
Fields inherited from class org.jgrapes.net.SocketConnectionManager
channels -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new connector, using itself as component channel.SocketConnector(Channel channel) Create a new instance using the given channel. -
Method Summary
Modifier and TypeMethodDescriptionvoidShuts down the one of the connections.voidOpens a connection to the end point specified in the event.voidCalled 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, toStringMethods inherited from class org.jgrapes.core.Component
channel, component, defaultCriterion, isEligibleFor, setNameMethods 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, unregisterAsGeneratorMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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:SocketConnectionManagerSets the buffer size for the send an receive buffers.If no size is set, a default value of 32768 will be used.
- Overrides:
setBufferSizein 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
-