Class ConnectionFactory

java.lang.Object
com.jprofiler.api.platform.connection.ConnectionFactory

public abstract class ConnectionFactory extends Object
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 Details

    • ConnectionFactory

      public ConnectionFactory()
  • Method Details

    • getLocalConnection

      public static Connection getLocalConnection() throws 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:
      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 file
      configFile - 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 computer
      port - 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
    • 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 computer
      port - the port on which the remote profiling agent is listening. The default value is 8849.
      timeout - the timeout in seconds
      sessionId - the id of the session used to profile
      configFile - 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