Class ConnectionFactory
- java.lang.Object
-
- com.jprofiler.api.platform.connection.ConnectionFactory
-
public abstract class ConnectionFactory extends java.lang.ObjectFactory 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:
Connection
-
-
Constructor Summary
Constructors Constructor Description ConnectionFactory()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ConnectioncreateRemoteConnection(java.lang.String hostname, int port, int timeout)Opens a connection to a remote JVM.static ConnectioncreateRemoteConnection(java.lang.String hostname, int port, int timeout, int sessionId, java.io.File configFile)Opens a connection to a remote JVM.static ConnectioncreateSnapshotConnection(java.io.File snapshot, java.io.File configFile)Opens a connection to a saved snapshot file.static ConnectiongetLocalConnection()Opens a connection to the JVM of the current process.
-
-
-
Method Detail
-
getLocalConnection
public static Connection getLocalConnection() throws java.io.IOException
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:
java.io.IOException- if the connection fails
-
createSnapshotConnection
public static Connection createSnapshotConnection(java.io.File snapshot, java.io.File configFile) throws java.io.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:
java.io.IOException- if the file does not exist or the connection fails for some other reason
-
createRemoteConnection
public static Connection createRemoteConnection(java.lang.String hostname, int port, int timeout) throws java.io.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:
java.io.IOException- if the connection fails or times out
-
the remote JVM is being profiled, i.e. if the
-
createRemoteConnection
public static Connection createRemoteConnection(java.lang.String hostname, int port, int timeout, int sessionId, java.io.File configFile) throws java.io.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:
java.io.IOException- if the connection fails or times out
-
-