View Javadoc
1   /*
2    * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
3    * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4    *
5    * This code is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU General Public License version 2 only, as
7    * published by the Free Software Foundation.  Oracle designates this
8    * particular file as subject to the "Classpath" exception as provided
9    * by Oracle in the LICENSE file that accompanied this code.
10   *
11   * This code is distributed in the hope that it will be useful, but WITHOUT
12   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13   * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14   * version 2 for more details (a copy is included in the LICENSE file that
15   * accompanied this code).
16   *
17   * You should have received a copy of the GNU General Public License version
18   * 2 along with this work; if not, write to the Free Software Foundation,
19   * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20   *
21   * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22   * or visit www.oracle.com if you need additional information or have any
23   * questions.
24   */
25  
26  package com.sun.jdi.connect;
27  
28  import java.util.Map;
29  import java.io.IOException;
30  import com.sun.jdi.VirtualMachine;
31  
32  /**
33   * A connector which listens for a connection initiated by a target VM.
34   *
35   * @author Gordon Hirsch
36   * @since  1.3
37   */
38  @jdk.Exported
39  public interface ListeningConnector extends Connector {
40      /**
41       * Indicates whether this listening connector supports multiple
42       * connections for a single argument map. If so, a call to
43       * {@link #startListening} may allow
44       * multiple target VM to become connected.
45       *
46       * @return <code>true</code> if multiple connections are supported;
47       * <code>false</code> otherwise.
48       */
49      boolean supportsMultipleConnections();
50  
51      /**
52       * Listens for one or more connections initiated by target VMs.
53       * The connector uses the given argument map
54       * in determining the address at which to listen or else it generates
55       * an appropriate listen address. In either case, an address string
56       * is returned from this method which can be used in starting target VMs
57       * to identify this connector. The format of the address string
58       * is connector, transport, and, possibly, platform dependent.
59       * <p>
60       * The argument map associates argument name strings to instances
61       * of {@link Connector.Argument}. The default argument map for a
62       * connector can be obtained through {@link Connector#defaultArguments}.
63       * Argument map values can be changed, but map entries should not be
64       * added or deleted.
65       * <p>
66       * This method does not return a {@link VirtualMachine}, and, normally,
67       * returns before any target VM initiates
68       * a connection. The connected target is obtained through
69       * {@link #accept} (using the same argument map as is passed to this
70       * method).
71       * <p>
72       * If <code>arguments</code> contains addressing information. and
73       * only one connection will be accepted, the {@link #accept accept} method
74       * can be called immediately without calling this method.
75       *
76       * @return the address at which the connector is listening
77       * for a connection.
78       * @throws java.io.IOException when unable to start listening.
79       * Specific exceptions are dependent on the Connector implementation
80       * in use.
81       * @throws IllegalConnectorArgumentsException when one of the
82       * connector arguments is invalid.
83       */
84      String startListening(Map<String,? extends Connector.Argument> arguments)
85          throws IOException, IllegalConnectorArgumentsException;
86  
87      /**
88       * Cancels listening for connections. The given argument map should match
89       * the argument map given for a previous {@link #startListening} invocation.
90       *
91       * @throws java.io.IOException when unable to stop listening.
92       * Specific exceptions are dependent on the Connector implementation
93       * in use.
94       * @throws IllegalConnectorArgumentsException when one of the
95       * connector arguments is invalid.
96       */
97      void stopListening(Map<String,? extends Connector.Argument> arguments)
98          throws IOException, IllegalConnectorArgumentsException;
99  
100 
101     /**
102      * Waits for a target VM to attach to this connector.
103      *
104      * @throws TransportTimeoutException when the Connector encapsulates
105      * a transport that supports a timeout when accepting, a
106      * {@link Connector.Argument} representing a timeout has been set
107      * in the argument map, and a timeout occurs whilst waiting for
108      * the target VM to connect.
109      * @throws java.io.IOException when unable to accept.
110      * Specific exceptions are dependent on the Connector implementation
111      * in use.
112      * @throws IllegalConnectorArgumentsException when one of the
113      * connector arguments is invalid.
114      */
115     VirtualMachine accept(Map<String,? extends Connector.Argument> arguments)
116         throws IOException, IllegalConnectorArgumentsException;
117 
118 }