1 /*
   2  * Copyright (c) 1998, 2004, 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 public interface ListeningConnector extends Connector {
  39     /**
  40      * Indicates whether this listening connector supports multiple
  41      * connections for a single argument map. If so, a call to
  42      * {@link #startListening} may allow
  43      * multiple target VM to become connected.
  44      *
  45      * @return <code>true</code> if multiple connections are supported;
  46      * <code>false</code> otherwise.
  47      */
  48     boolean supportsMultipleConnections();
  49 
  50     /**
  51      * Listens for one or more connections initiated by target VMs.
  52      * The connector uses the given argument map
  53      * in determining the address at which to listen or else it generates
  54      * an appropriate listen address. In either case, an address string
  55      * is returned from this method which can be used in starting target VMs
  56      * to identify this connector. The format of the address string
  57      * is connector, transport, and, possibly, platform dependent.
  58      * <p>
  59      * The argument map associates argument name strings to instances
  60      * of {@link Connector.Argument}. The default argument map for a
  61      * connector can be obtained through {@link Connector#defaultArguments}.
  62      * Argument map values can be changed, but map entries should not be
  63      * added or deleted.
  64      * <p>
  65      * This method does not return a {@link VirtualMachine}, and, normally,
  66      * returns before any target VM initiates
  67      * a connection. The connected target is obtained through
  68      * {@link #accept} (using the same argument map as is passed to this
  69      * method).
  70      * <p>
  71      * If <code>arguments</code> contains addressing information. and
  72      * only one conection will be accepted, the {@link #accept accept} method
  73      * can be called immediately without calling this method.
  74      *
  75      * @return the address at which the connector is listening
  76      * for a connection.
  77      * @throws java.io.IOException when unable to start listening.
  78      * Specific exceptions are dependent on the Connector implementation
  79      * in use.
  80      * @throws IllegalConnectorArgumentsException when one of the
  81      * connector arguments is invalid.
  82      */
  83     String startListening(Map<String,? extends Connector.Argument> arguments)
  84         throws IOException, IllegalConnectorArgumentsException;
  85 
  86     /**
  87      * Cancels listening for connections. The given argument map should match
  88      * the argument map given for a previous {@link #startListening} invocation.
  89      *
  90      * @throws java.io.IOException when unable to stop listening.
  91      * Specific exceptions are dependent on the Connector implementation
  92      * in use.
  93      * @throws IllegalConnectorArgumentsException when one of the
  94      * connector arguments is invalid.
  95      */
  96     void stopListening(Map<String,? extends Connector.Argument> arguments)
  97         throws IOException, IllegalConnectorArgumentsException;
  98 
  99 
 100     /**
 101      * Waits for a target VM to attach to this connector.
 102      *
 103      * @throws TransportTimeoutException when the Connector encapsulates
 104      * a transport that supports a timeout when accepting, a
 105      * {@link Connector.Argument} representing a timeout has been set
 106      * in the argument map, and a timeout occurs whilst waiting for
 107      * the target VM to connect.
 108      * @throws java.io.IOException when unable to accept.
 109      * Specific exceptions are dependent on the Connector implementation
 110      * in use.
 111      * @throws IllegalConnectorArgumentsException when one of the
 112      * connector arguments is invalid.
 113      */
 114     VirtualMachine accept(Map<String,? extends Connector.Argument> arguments)
 115         throws IOException, IllegalConnectorArgumentsException;
 116 
 117 }