ij-16.png   inspectorJ -- JavaTM Profiler
sf project site browse source checkout source
SourceForge.net Logo



inspectorj::client::ConnectionManager Class Reference

#include <connectionmanager.h>

Collaboration diagram for inspectorj::client::ConnectionManager:

Collaboration graph
[legend]
List of all members.

Detailed Description

ConnectionManager is a class that manages the underlying socket connection that InspectorJ uses to connect to the jvm.

It is responsible for connecting to and sometimes launching the jvm that is being profiled.

Definition at line 49 of file connectionmanager.h.

Public Slots

void closeConnection ()
 Close the connection to the profiler server.
void stopJavaApp ()

Signals

void connected (bool, QString &msg)

Public Member Functions

 ConnectionManager (QObject *parent, QMap< QString, SessionProfile > &, QProcess &)
 Constructor.
bool startAttachTimer (int, ijConnection)
 Start a timer to wait before attempting to attach to the server.
void getJDWPError (int errCode, QString &s)
 Looks up the error for errCode and stores a descriptive message in the QString reference s.
bool isAttached ()
 Returns true if inspectorJ is attached to an Agent, false otherwise.
void sendRequest (JDWPCommand *, JDWPAction *)
 Send a command to the profiler server.
void sendRequest (JDWPCommand *, QList< JDWPAction * > &)
 Send a command to the profiler server.
void setExiting (bool)

Private Slots

void attachToLaunchedServer ()
 Try to connect to the server.
void readPacket ()
 Read the data from the socket.
void sendHandshake ()
 Send handshake string to the server.
bool attachToServer ()
 Try to connect to the server.
void launchJavaApp ()
 Launch the java application that will be profiled.
void connectionClosedByServer ()
 Called when the connection is closed by the server.
void error (QAbstractSocket::SocketError)
 Called when the underlying connection emits an error signal.

Private Member Functions

void receiveHandshake ()
 Get the handshake response from the server.
bool okToConnect ()
 Return true if it is ok to connect to the inspectorj server.
bool okToLaunch ()
 Return true if it is ok to launch a new process.
QString buildCmdString (SessionProfile &profile, QString &)
 Construct the command string with information contained in the profile.

Private Attributes

bool exiting
ijConnection connection
QObject * parent
QMap< QString, SessionProfile > & profiles
 Map of SessionProfiles.
QProcess & javaAppProcess
 Process to start the jvm.
ClientPacketHandler handler
 The one ClientPacketHandler instance.
QTcpSocket tcpSocket
 Socket used to communicate with the profiler server.
bool attached
 This bool flag is true if we're attached to the profiler.


Constructor & Destructor Documentation

ConnectionManager::ConnectionManager ( QObject *  prnt,
QMap< QString, SessionProfile > &  profiles,
QProcess &  process 
)

Constructor.

Parameters:
prnt The QObject parent

Definition at line 36 of file connectionmanager.cpp.

References connectionClosedByServer(), error(), parent, readPacket(), sendHandshake(), and tcpSocket.


Member Function Documentation

bool ConnectionManager::startAttachTimer ( int  mills,
ijConnection  conn 
)

Start a timer to wait before attempting to attach to the server.

Parameters:
mills Milliseconds to wait for the timer times out
conn The server connection data
Returns:
true if the timer is successfully started, false otherwise

Definition at line 201 of file connectionmanager.cpp.

References attachToLaunchedServer(), connection, and okToConnect().

Referenced by inspectorj::client::InspectorJ::javaAppStarted().

void ConnectionManager::getJDWPError ( int  errCode,
QString &  s 
)

Looks up the error for errCode and stores a descriptive message in the QString reference s.

Parameters:
errCode The error code from the packet received from the jvm
s QString reference to hold the error message.

Definition at line 492 of file connectionmanager.cpp.

References inspectorj::jdwp::getJDWPError().

Referenced by inspectorj::toolset::ClassToolSet::getBytecodeString().

bool ConnectionManager::isAttached (  ) 

Returns true if inspectorJ is attached to an Agent, false otherwise.

Definition at line 51 of file connectionmanager.cpp.

References attached.

Referenced by inspectorj::client::InspectorJ::addClassFilter(), inspectorj::toolset::ClassToolSet::disassembleBytecodes(), inspectorj::client::InspectorJ::getJvmInfo(), inspectorj::client::InspectorJ::removeClassFilter(), inspectorj::client::InspectorJ::showSessionDlg(), and inspectorj::client::InspectorJ::updateBytecodeBtn().

void ConnectionManager::sendRequest ( JDWPCommand cmd,
JDWPAction action 
)

Send a command to the profiler server.

Parameters:
cmd The JDWPCommand object that wraps the jdwpCmdPacket
action An action to be triggered when a reply packet is received.

Definition at line 73 of file connectionmanager.cpp.

Referenced by closeConnection(), inspectorj::toolset::ClassToolSet::disassembleBytecodes(), inspectorj::toolset::ClassToolSet::getAllLoadedClasses(), inspectorj::toolset::ClassToolSet::getClassDetails(), inspectorj::client::InspectorJ::getJvmInfo(), and stopJavaApp().

void ConnectionManager::sendRequest ( JDWPCommand cmd,
QList< JDWPAction * > &  actions 
)

Send a command to the profiler server.

Parameters:
cmd The JDWPCommand object that wraps the jdwpCmdPacket
actions A list of actions to be triggered when a reply packet is received.

Definition at line 62 of file connectionmanager.cpp.

References handler, and inspectorj::client::ClientPacketHandler::sendJDWPCommand().

void ConnectionManager::closeConnection (  )  [slot]

Close the connection to the profiler server.

Definition at line 432 of file connectionmanager.cpp.

References attached, parent, sendRequest(), and tcpSocket.

Referenced by inspectorj::client::InspectorJ::closeEvent(), connectionClosedByServer(), error(), okToConnect(), and okToLaunch().

void ConnectionManager::attachToLaunchedServer (  )  [private, slot]

Try to connect to the server.

Definition at line 188 of file connectionmanager.cpp.

References connection, inspectorj::client::ijConnection::host, inspectorj::client::ijConnection::port, and tcpSocket.

Referenced by startAttachTimer().

void ConnectionManager::readPacket (  )  [private, slot]

Read the data from the socket.

This a callback function that is called when the socket has data to read.

Definition at line 84 of file connectionmanager.cpp.

References attached, handler, inspectorj::client::ClientPacketHandler::readJDWPPacket(), and receiveHandshake().

Referenced by ConnectionManager().

void ConnectionManager::sendHandshake (  )  [private, slot]

Send handshake string to the server.

Definition at line 393 of file connectionmanager.cpp.

References inspectorj::jdwp::JDWP_HANDSHAKE, and tcpSocket.

Referenced by ConnectionManager().

bool ConnectionManager::attachToServer (  )  [private, slot]

Try to connect to the server.

Definition at line 158 of file connectionmanager.cpp.

References okToConnect(), and tcpSocket.

void ConnectionManager::launchJavaApp (  )  [private, slot]

Launch the java application that will be profiled.

Definition at line 217 of file connectionmanager.cpp.

References buildCmdString(), javaAppProcess, okToLaunch(), and profiles.

void ConnectionManager::connectionClosedByServer (  )  [private, slot]

Called when the connection is closed by the server.

Definition at line 424 of file connectionmanager.cpp.

References closeConnection().

Referenced by ConnectionManager().

void ConnectionManager::error ( QAbstractSocket::SocketError  error  )  [private, slot]

Called when the underlying connection emits an error signal.

Parameters:
error The Socket error from the tcpSocket

Definition at line 501 of file connectionmanager.cpp.

References closeConnection(), exiting, inspectorj::client::ClientPacketHandler::getSocketError(), handler, and parent.

Referenced by ConnectionManager().

void ConnectionManager::receiveHandshake (  )  [private]

Get the handshake response from the server.

Definition at line 401 of file connectionmanager.cpp.

References attached, inspectorj::client::ClientPacketHandler::getHandshake(), handler, and parent.

Referenced by readPacket().

bool ConnectionManager::okToConnect (  )  [private]

Return true if it is ok to connect to the inspectorj server.

Definition at line 131 of file connectionmanager.cpp.

References closeConnection(), parent, and tcpSocket.

Referenced by attachToServer(), okToLaunch(), and startAttachTimer().

bool ConnectionManager::okToLaunch (  )  [private]

Return true if it is ok to launch a new process.

Definition at line 99 of file connectionmanager.cpp.

References closeConnection(), javaAppProcess, okToConnect(), parent, and tcpSocket.

Referenced by launchJavaApp().

QString ConnectionManager::buildCmdString ( SessionProfile profile,
QString &  profileDir 
) [private]

Construct the command string with information contained in the profile.

The command string will typically be "java [-options] class [args...]" but it could be another application that will start the jvm such as Tomcat's "catalina.sh start [-options]".

Parameters:
profile The profile with the java app information

Definition at line 254 of file connectionmanager.cpp.

References inspectorj::client::SessionProfile::getApplicationArgs(), inspectorj::client::SessionProfile::getApplicationEntry(), inspectorj::client::SessionProfile::getClassPath(), inspectorj::client::SessionProfile::getFileName(), inspectorj::client::SessionProfile::getJavaOptions(), inspectorj::client::SessionProfile::getJreHome(), inspectorj::client::SessionProfile::isJarFile(), inspectorj::client::SessionProfile::isTomcatApp(), isWindows(), and javaAppProcess.

Referenced by launchJavaApp().


Member Data Documentation

QMap<QString, SessionProfile>& inspectorj::client::ConnectionManager::profiles [private]

Map of SessionProfiles.

Definition at line 89 of file connectionmanager.h.

Referenced by launchJavaApp().

QProcess& inspectorj::client::ConnectionManager::javaAppProcess [private]

Process to start the jvm.

Definition at line 92 of file connectionmanager.h.

Referenced by buildCmdString(), launchJavaApp(), okToLaunch(), and stopJavaApp().

ClientPacketHandler inspectorj::client::ConnectionManager::handler [private]

The one ClientPacketHandler instance.

Definition at line 95 of file connectionmanager.h.

Referenced by error(), readPacket(), receiveHandshake(), and sendRequest().

QTcpSocket inspectorj::client::ConnectionManager::tcpSocket [private]

Socket used to communicate with the profiler server.

Definition at line 98 of file connectionmanager.h.

Referenced by attachToLaunchedServer(), attachToServer(), closeConnection(), ConnectionManager(), okToConnect(), okToLaunch(), sendHandshake(), and stopJavaApp().

bool inspectorj::client::ConnectionManager::attached [private]

This bool flag is true if we're attached to the profiler.

False otherwise. Note: attached and connected are different in this context. Connected means that we've established a TCP connection. Attached means we've successfully performed a handshake with the server.

Definition at line 106 of file connectionmanager.h.

Referenced by closeConnection(), isAttached(), readPacket(), receiveHandshake(), and stopJavaApp().


The documentation for this class was generated from the following files:
Generated on Sun Aug 19 17:08:15 2007 for inspectorJ by  doxygen 1.5.1