Class ConnectionFactory
java.lang.Object
com.jprofiler.api.platform.connection.ConnectionFactory
Factory for creating connections to profiled JVMs and saved snapshots.
You can create multiple concurrent connections. For example, you could aggregate information from multiple remote JVMs.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Connection
createRemoteConnection
(String hostname, int port, int timeout) Opens a connection to a remote JVM.static Connection
createRemoteConnection
(String hostname, int port, int timeout, int sessionId, File configFile) Opens a connection to a remote JVM.static Connection
createSnapshotConnection
(File snapshot, File configFile) Opens a connection to a saved snapshot file.static Connection
Opens a connection to the JVM of the current process.
-
Constructor Details
-
ConnectionFactory
public ConnectionFactory()
-
-
Method Details
-
getLocalConnection
Opens a connection to the JVM of the current process. This works only if the current JVM is being profiled in offline mode, i.e. if the-agentpath:[path to jprofilerti library]
VM parameter was passed to the JVM when the JVM was started and the "offline" and "id" options were specified.- Returns:
- the connection
- Throws:
IOException
- if the connection fails
-
createSnapshotConnection
public static Connection createSnapshotConnection(File snapshot, File configFile) throws IOException Opens a connection to a saved snapshot file.- Parameters:
snapshot
- the snapshot fileconfigFile
- the jprofiler_config.xml file of JProfiler. If this parameter is null, the default config file from the current user's home directory will be used (if it exists).- Returns:
- the connection
- Throws:
IOException
- if the file does not exist or the connection fails for some other reason
-
createRemoteConnection
public static Connection createRemoteConnection(String hostname, int port, int timeout) throws IOException Opens a connection to a remote JVM. This works only if-
the remote JVM is being profiled, i.e. if the
-agentpath:[path to jprofilerti library]
VM parameter was passed to the JVM when the JVM was started. -
the "nowait" and "id" option is included in
-agentpath:[path to jprofilerti library]
VM parameter. This is required since the connection factory does not pass profiling parameters to the remote side with this method.
- Parameters:
hostname
- the host name or the IP address of the remote computerport
- the port on which the remote profiling agent is listening. The default value is 8849.timeout
- the timeout in seconds- Returns:
- the connection
- Throws:
IOException
- if the connection fails or times out
-
the remote JVM is being profiled, i.e. if the
-
createRemoteConnection
public static Connection createRemoteConnection(String hostname, int port, int timeout, int sessionId, File configFile) throws IOException Opens a connection to a remote JVM. This works only if the remote JVM is being profiled, i.e. if the-agentpath:[path to jprofilerti library]
VM parameter was passed to the JVM when the JVM was started.- Parameters:
hostname
- the host name or the IP address of the remote computerport
- the port on which the remote profiling agent is listening. The default value is 8849.timeout
- the timeout in secondssessionId
- the id of the session used to profileconfigFile
- the jprofiler_config.xml file of JProfiler. If this parameter is null, the default config file from the current user's home directory will be used (if it exists).- Returns:
- the connection
- Throws:
IOException
- if the connection fails or times out
-