Library | Package Java Toolkit

Interface AsyncConnection

package com.ptc.pfc.pfcAsyncConnection;

public interface AsyncConnection
  extends com.ptc.pfc.pfcBase.ActionSource



Description

This class represents an asynchronous connection to Creo Parametric.
Manual References:
Running J-Link Applications in Asynchronous Mode: Example Code



Method Summary
voidDisconnect ( /*optional*/ Integer TimeoutSec)
    Disconnects the application from the current Creo Parametric process. Creo Parametric will still be running after this call.
voidEnd ()
    Terminates and disconnects from the current Creo Parametric process.
voidEventProcess ()
    Enables your process to respond to listener calls from Creo Parametric. You must call this function within your control loop in order that your application will be able to respond to listener calls. Creo Parametric will be blocked until the application responds to a registered listener.
booleanExecuteAsyncJavaMethod (String Class, String Method, Arguments InputArguments, String ClassForUnlock)
    This is the "JOTK sandbox" to execute methods with full OTK Asynchronous Java access. Can be used only in Java language binding.
ConnectionIdGetConnectionId ()
    Extracts the identification handle of the current Creo Parametric process.
SessionGetSession ()
DEPRECATED: since Creo 4
SUCCESSOR(S): GetCurrentSession

    Get method for attribute "Session"
    The handle to the session of Creo Parametric for the current active connection.
voidInterruptEventProcessing ()
    Call this function from within a Creo Parametric callback function to halt a loop currently running in AsyncConnection.WaitForEvents().
booleanIsRunning ()
    Determines whether you are currently connected to an actively responding Creo Parametric session.
voidWaitForEvents ()
    Initiates an event loop which will call event processing periodically to handle events returned from Creo Parametric. Applicable only for full asynchronous applications which are not supposed to carry out any tasks while waiting for Creo Parametric events.

Methods Inherited from Interface com.ptc.pfc.pfcBase.ActionSource
AddActionListener, RemoveActionListener, AddActionListenerWithType

Method Detail

GetSession

SessionGetSession ()

DEPRECATED: since Creo 4
SUCCESSOR(S): GetCurrentSession


    The handle to the session of Creo Parametric for the current active connection.
Manual References:
Running J-Link Applications in Asynchronous Mode: Getting the Session Object



End

voidEnd ()


    Terminates and disconnects from the current Creo Parametric process.
Manual References:
Running J-Link Applications in Asynchronous Mode: Starting and Stopping Creo Parametric
Returns:


Disconnect

voidDisconnect ( /*optional*/ Integer TimeoutSec)


    Disconnects the application from the current Creo Parametric process. Creo Parametric will still be running after this call.

For J-Link only: In order to clear allocated Creo Parametric memory owned by the application, PTC recommends forcing garbage collection (using Java's System.gc()) before disconnecting from Creo Parametric.

Exceptions thrown (but not limited to):

XToolkitUnsupported - Connection is not Obtained

<reference 6 to unknown entity pfcExceptions::XProeWasNotConnected> - Handle not initialized


Manual References:
Running J-Link Applications in Asynchronous Mode: Example Code
Parameters:
TimeoutSec
The time, in seconds, to wait for Creo Parametric to respond to the disconnect request.
Returns:


WaitForEvents

voidWaitForEvents ()


    Initiates an event loop which will call event processing periodically to handle events returned from Creo Parametric. Applicable only for full asynchronous applications which are not supposed to carry out any tasks while waiting for Creo Parametric events.

This function will not return until interrupted by AsyncConnection.InterruptEventProcessing() or an error. No separate application processing is possible until that time, except within Creo Parametric event callbacks.
Manual References:
Running J-Link Applications in Asynchronous Mode: Full Asynchronous Mode, Running J-Link Applications in Asynchronous Mode: Full Asynchronous Mode
Returns:


InterruptEventProcessing

voidInterruptEventProcessing ()


    Call this function from within a Creo Parametric callback function to halt a loop currently running in AsyncConnection.WaitForEvents().
Manual References:
Running J-Link Applications in Asynchronous Mode: Full Asynchronous Mode, Running J-Link Applications in Asynchronous Mode: Full Asynchronous Mode
Returns:


GetConnectionId

ConnectionIdGetConnectionId ()


    Extracts the identification handle of the current Creo Parametric process.

Format of identification string is the following.
"host:H:address_version:A:address_type:T:rpcnum:R:rpcversion:V:netaddr:N"
where H - host name where Creo Parametric runs A - address version T - address type R - RPC number V - RPC version N - net address. The identification string can be used in subsequent attmepts to connect to this Creo Parametric session by this application or any other Creo Parametric TOOLKIT or PFC-based application.

Exceptions thrown (but not limited to):

XToolkitUnsupported - Connection is not Obtained


Manual References:
Running J-Link Applications in Asynchronous Mode: Connecting Via Connection ID, Running J-Link Applications in Asynchronous Mode: Connecting Via Connection ID
Returns:
The connection identifier handle.


IsRunning

booleanIsRunning ()


    Determines whether you are currently connected to an actively responding Creo Parametric session.
Manual References:
Running J-Link Applications in Asynchronous Mode: Connecting Via Connection ID
Returns:
true if communications with Creo Parametric are possible false otherwise.


ExecuteAsyncJavaMethod

booleanExecuteAsyncJavaMethod (String Class, String Method, Arguments InputArguments, String ClassForUnlock)


    This is the "JOTK sandbox" to execute methods with full OTK Asynchronous Java access. Can be used only in Java language binding.

The executed Java method must have one of the following signatures:
  public static void (Arguments inputs)

  public static void ()
     

Please note that Object Java Toolkit sets a separate application session within the sandbox. Hence, if the application requests a session outside the sandbox, its compatibility must be set, even it has already been done inside the sandbox.

Before executing the supplied Java method, the sandbox checks that the application is unlocked. It performs no execution and returns false if this check fails, which may happen because either the application is not unlocked (and overriding developer licenses are not present), or the application jar was not found (for instance, due to a wrong ClassForUnlock argument).
Parameters:
Class
Method's class. Full class name including the package, in Java syntax.
Method
Method's name.
InputArguments
Method's input arguments.
ClassForUnlock
The class used for unlocking this Java application. Full class name including the package, in Java syntax.
Returns:
False if the check for unlocking failed.


EventProcess

voidEventProcess ()


    Enables your process to respond to listener calls from Creo Parametric. You must call this function within your control loop in order that your application will be able to respond to listener calls. Creo Parametric will be blocked until the application responds to a registered listener.

Exceptions thrown (but not limited to):

XToolkitGeneralError - Creo Session has already terminated.


Manual References:
Running J-Link Applications in Asynchronous Mode: Full Asynchronous Mode, Running J-Link Applications in Asynchronous Mode: Full Asynchronous Mode
Returns: