Class TcpBuildConnection
- java.lang.Object
-
- org.codehaus.plexus.build.connect.TcpBuildConnection
-
- All Implemented Interfaces:
BuildConnection
@Named("default") @Singleton public class TcpBuildConnection extends java.lang.Object implements BuildConnectionDefault implementation using the system propertyplexus.build.ipc.portto communicate with an endpoint to exchange messages
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTcpBuildConnection.ServerConnectionRepresents a server connection that must be created to communicate with the maven process using theTcpBuildConnection
-
Constructor Summary
Constructors Constructor Description TcpBuildConnection()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static TcpBuildConnection.ServerConnectioncreateServer(java.util.function.Function<Message,java.util.Map<java.lang.String,java.lang.String>> consumer)Creates a new server that will receive messages from a remote endpoint and inform the consumerbooleanisEnabled()This method allows code to perform an eager check if a buildconnection is present to send messages.Messagesend(Message message, org.apache.maven.execution.MavenSession mavenSession)Send a message and returns the reply from the other endpoint, should only be called from a maven thread!
-
-
-
Method Detail
-
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
public Message send(Message message, org.apache.maven.execution.MavenSession mavenSession)
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(java.util.function.Function<Message,java.util.Map<java.lang.String,java.lang.String>> consumer) throws java.io.IOException
Creates 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:
java.io.IOException- if no local socket can be opened
-
-