001: /*
002: *
003: *
004: * Copyright 1990-2007 Sun Microsystems, Inc. All Rights Reserved.
005: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License version
009: * 2 only, as published by the Free Software Foundation.
010: *
011: * This program is distributed in the hope that it will be useful, but
012: * WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * General Public License version 2 for more details (a copy is
015: * included at /legal/license.txt).
016: *
017: * You should have received a copy of the GNU General Public License
018: * version 2 along with this work; if not, write to the Free Software
019: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA
021: *
022: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023: * Clara, CA 95054 or visit www.sun.com if you need additional
024: * information or have any questions.
025: */
026:
027: package com.sun.cldchi.tools.memoryprofiler.jdwp;
028:
029: import java.net.*;
030: import java.io.*;
031: import java.util.*;
032:
033: /**
034: * The <code>VMConnection</code> declares interface between transport
035: * layer and data providing layer of the memory profiler. It allows sending
036: * commands to the VM and receiving replies as instances of <code>VMReply</code>.
037: * The default implementation of this interface is provided by <code>VMConnectionFactory</code>.
038: *
039: * @see com.sun.cldchi.tools.memoryprofiler.jdwp.VMConnection
040: * @see com.sun.cldchi.tools.memoryprofiler.jdwp.VMConnectionFactory
041: *
042: */
043:
044: public interface VMConnection {
045:
046: /**
047: * Sends a command to the VM, which produces some responce and
048: * returns instance of <code>VMReply</code> for working with the
049: * responce.
050: * Could throw <code>DebugeeException</code> unless sending command is successful
051: * This functions requires connection to a KDP and will throw <code>DebugeeException</code> otherwise.
052: * You can check it with <code>isConnected()</code> function.
053: * To connect to a KDP you must use <code>connect(String hostName, int port)</code> function.
054: *
055: * @param command - code of command to be sent
056: * @param params - additional command parameters
057: *
058: * @return instance of <code>VMReply</code> for working with the VM responce
059: *
060: * @see #sendCommand(int command)
061: * @see #isConnected()
062: */
063: public VMReply sendReplyCommand(int command, int[] params)
064: throws DebugeeException;
065:
066: /**
067: * Sends a command to the VM which don't needs any parameters, which produces some responce and
068: * returns instance of <code>VMReply</code> for working with the
069: * responce.
070: * Could throw <code>DebugeeException</code> unless sending command is successful
071: * This functions requires connection to a KDP and will throw <code>DebugeeException</code> otherwise.
072: * You can check it with <code>isConnected()</code> function.
073: * To connect to a KDP you must use <code>connect(String hostName, int port)</code> function.
074: *
075: * @param command - code of command to be sent
076: *
077: * @return instance of <code>VMReply</code> for working with the VM responce
078: *
079: * @see #sendCommand(int command)
080: * @see #isConnected()
081: */
082: public VMReply sendReplyCommand(int command)
083: throws DebugeeException;
084:
085: /**
086: * Sends a command to the VM, which doesn't produces and responce.
087: * Could throw <code>DebugeeException</code> unless sending command is successful
088: *
089: * This functions requires connection to a KDP and will throw <code>DebugeeException</code> otherwise.
090: * You can check it with <code>isConnected()</code> function.
091: * To connect to a kdp you must use <code>connect(String hostName, int port)</code> function.
092: *
093: * @param command - code of command to be sent
094: *
095: * @see #sendReplyCommand(int command)
096: * @see #isConnected()
097: */
098: public void sendCommand(int command) throws DebugeeException;
099:
100: /**
101: * Connects to the KDP running on hostName:port.
102: * Could throw <code>ConnectException</code> unless connection is successful
103: *
104: * @param hostName - name of host where KDP runs
105: * @param port - number of port where KDP listens
106: *
107: * @see #isConnected()
108: * @see #closeConnections()
109: */
110: public void connect(String hostName, int port)
111: throws ConnectException;
112:
113: /**
114: * Checks if the instance is connected to a KDP.
115: *
116: * @return true if is connected to a kdp, false otherwise.
117: *
118: * @see #connect(String hostName, int port)
119: * @see #closeConnections()
120: */
121: public boolean isConnected();
122:
123: /**
124: * Disconnects from a KDP.
125: *
126: * @see #isConnected()
127: * @see #connect(String hostName, int port)
128: */
129: public void closeConnections();
130: }
|