Class TcpBuildConnection
java.lang.Object
org.codehaus.plexus.build.connect.TcpBuildConnection
- All Implemented Interfaces:
BuildConnection
@Named("default")
@Singleton
public class TcpBuildConnection
extends Object
implements BuildConnection
Default implementation using the system property
plexus.build.ipc.port to communicate with an endpoint to
exchange messages-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classRepresents a server connection that must be created to communicate with the maven process using theTcpBuildConnection -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCreates a new server that will receive messages from a remote endpoint and inform the consumerbooleanThis method allows code to perform an eager check if a buildconnection is present to send messages.Send a message and returns the reply from the other endpoint, should only be called from a maven thread!
-
Constructor Details
-
TcpBuildConnection
public TcpBuildConnection()
-
-
Method Details
-
isEnabled
public boolean isEnabled()Description copied from interface:BuildConnectionThis method allows code to perform an eager check if a buildconnection is present to send messages. This can be used to guard operations to prevent allocate resources or objects if the message will be dropped.- Specified by:
isEnabledin interfaceBuildConnection- Returns:
trueif the connection can be used to send messages or if they will be discarded
-
send
Description copied from interface:BuildConnectionSend a message and returns the reply from the other endpoint, should only be called from a maven thread!- Specified by:
sendin interfaceBuildConnection- Parameters:
message- the message to sendmavenSession- the maven session to reference- Returns:
- the reply message or
nullif this connection is not enabled and the message was discarded.
-
createServer
public static TcpBuildConnection.ServerConnection createServer(Function<Message, Map<String, String>> consumer) throws IOExceptionCreates a new server that will receive messages from a remote endpoint and inform the consumer- Parameters:
consumer- the consumer of messages, might be called by different threads, if the consumer throws an exception while handling a message it will maybe no longer receive some messages. The returned map is used as a payload for the reply to the server, ifnullis returned a simple acknowledgement without any payload will be send to the endpoint. If the consumer performs blocking operations the further execution of the maven process might be halted depending on the message type, if that is not desired work should be offloaded by the consumer to a different thread.- Returns:
- a
TcpBuildConnection.ServerConnectionthat can be used to shutdown the server and get properties that needs to be passed to the maven process - Throws:
IOException- if no local socket can be opened
-