Class ConnectionFactory


  • public abstract class ConnectionFactory
    extends java.lang.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:
    Connection
    • Constructor Detail

      • ConnectionFactory

        public ConnectionFactory()
    • 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 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:
        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 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:
        java.io.IOException - if the connection fails or times out
      • 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 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:
        java.io.IOException - if the connection fails or times out