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
  • Constructor Details

    • TcpBuildConnection

      public TcpBuildConnection()
  • Method Details

    • isEnabled

      public boolean isEnabled()
      Description copied from interface: BuildConnection
      This 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:
      isEnabled in interface BuildConnection
      Returns:
      true if 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: BuildConnection
      Send a message and returns the reply from the other endpoint, should only be called from a maven thread!
      Specified by:
      send in interface BuildConnection
      Parameters:
      message - the message to send
      mavenSession - the maven session to reference
      Returns:
      the reply message or null if this connection is not enabled and the message was discarded.
    • createServer

      public static TcpBuildConnection.ServerConnection createServer(Function<Message, Map<String,String>> consumer) throws 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, if null is 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.ServerConnection that 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