View Javadoc
1   package org.apache.maven.surefire.spi;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *     http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.apache.maven.surefire.api.booter.MasterProcessChannelDecoder;
23  import org.apache.maven.surefire.api.booter.MasterProcessChannelEncoder;
24  import org.apache.maven.surefire.api.fork.ForkNodeArguments;
25  
26  import javax.annotation.Nonnull;
27  import java.io.Closeable;
28  import java.io.IOException;
29  
30  /**
31   * The SPI interface, a factory of an encoder and a decoder.
32   */
33  public interface MasterProcessChannelProcessorFactory extends Closeable
34  {
35      /**
36       * Evaluates the {@code channelConfig}.
37       *
38       * @param channelConfig a connection string used by the fork JVM
39       * @return {@code true} if {@code channelConfig} is applicable and thus this SPI is eligible in the fork
40       */
41      boolean canUse( String channelConfig );
42  
43      /**
44       * Open a new connection.
45       *
46       * @param channelConfig e.g. "pipe://3" or "tcp://localhost:65035"
47       * @throws IOException if cannot connect
48       */
49      void connect( String channelConfig ) throws IOException;
50  
51      /**
52       * Decoder factory method.
53       * @param forkingArguments forking arguments
54       * @return a new instance of decoder
55       */
56      MasterProcessChannelDecoder createDecoder( @Nonnull ForkNodeArguments forkingArguments ) throws IOException;
57  
58      /**
59       * Encoder factory method.
60       * @param forkingArguments forking arguments
61       * @return a new instance of encoder
62       */
63      MasterProcessChannelEncoder createEncoder( @Nonnull ForkNodeArguments forkingArguments ) throws IOException;
64  }