wt.com
Class WindchillComponent

java.lang.Object
  extended bywt.com.WindchillComponent

public class WindchillComponent
extends Object

WindchillComponent is meant to be used as a COM object to connect COM-compliant applications to the Windchill services. It is essentially a wrapper for RemoteMethodServer, and functions in much the same way. Developers wishing to use it would generally be best to write a more heavy-weight application on either the Win32 side or on the Java side of the fence.

If an application is written for Win32 and uses this component, it will be required to use the dispatch interface. For this reason it might be less attractive to use C or C++ as the application language.

If the application is written in Java, this component can be used to create an instance of that application object and invoke methods on it from some Win32 wrapper application that makes calls to invoke. The application will remain entirely encapsulated within the component, and will be unloaded when the component instance is destroyed.

This class is designed to be packaged with a COM DLL output format. The class has no standard entry points, other than the constructor. Public methods will be exposed as methods on the default COM interface.


Field Summary
private static String className
           
private  String codebase
           
private  String jarfile
           
private static WTProperties localProperties
           
private  Hashtable objectCache
           
private  String password
           
private  RemoteMethodServer rms
           
private static WTProperties serverProperties
           
private  String username
           
private static boolean VERBOSE
           
private  WindchillComponentIfc winComp
           
 
Constructor Summary
WindchillComponent()
           
 
Method Summary
private  void bootstrap()
           
 String getCodebase()
           
 String getJarfile()
           
 com.ms.com.Variant getProperty(String key, com.ms.com.Variant def)
          Get a property from the local windchill properties list.
 com.ms.com.Variant getServerProperty(String key, com.ms.com.Variant def)
          Get a property from the server's windchill properties list.
 String getUsername()
          Returns the username currently being used for method invocation.
 void initialize()
           
 com.ms.com.Variant invoke(String targetMethod, String targetClass, int targetObjectHandle, com.ms.com.Variant[] args)
          This method wraps RemoteMethodServer.invoke for Win32 applications to access transparently.
 void setCodebase(String cb)
          NOTE: To add auto-registration code, refer to the documentation on the following method public static void onCOMRegister(boolean unRegister) {}
 void setJarfile(String jar)
           
 void setPassword(String password)
          Set the password for authentication.
 void setUsername(String username)
          Sets the username for all transactions with Windchill.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

localProperties

private static WTProperties localProperties

serverProperties

private static WTProperties serverProperties

VERBOSE

private static boolean VERBOSE

username

private String username

password

private String password

rms

private RemoteMethodServer rms

objectCache

private Hashtable objectCache

codebase

private String codebase

jarfile

private String jarfile

className

private static final String className
See Also:
Constant Field Values

winComp

private WindchillComponentIfc winComp
Constructor Detail

WindchillComponent

public WindchillComponent()
Method Detail

invoke

public com.ms.com.Variant invoke(String targetMethod,
                                 String targetClass,
                                 int targetObjectHandle,
                                 com.ms.com.Variant[] args)
This method wraps RemoteMethodServer.invoke for Win32 applications to access transparently. Arguments to the invoked method may be any of the following primitive types or a String. Arguments are passed and results are returned through Variants. Supported types are: Any other types of input arguments or return values will cause an error (via ComFailException) with one exception: if the value returned from a method invocation is not one of the supported types, WindchillComponent will store the object and pass back a handle to it. This handle can be passed to future calls to invoke to use the saved object as the context for invocation. The saved object will be destroyed only when the component instance is destroyed.

The handle is passed back as an int (VT_I4) in a Variant. Passing 0 (zero) in for the handle will ignore the object store.

Parameters:
targetMethod - The method to invoke.
targetClass - The class that contains the method.
targetObjectHandle - A handle to an object instance to invoke the method from, or 0 (zero).
args - An array of Variant types containing the arguments to pass to the method.
Returns:
A Variant containing either the result of the method invocation or a handle to an object instance, stored for use in subsequent calls.

setUsername

public void setUsername(String username)
Sets the username for all transactions with Windchill. The username is set into the RemoteMethodServer along with the password for authentication. It it not recommended to try to use a single instance of this component with multiple users at the same time.

Parameters:
username - The username to authenticate as.

getUsername

public String getUsername()
Returns the username currently being used for method invocation.

Returns:
The username currently being used.

setPassword

public void setPassword(String password)
Set the password for authentication. The password is set into the RemoteMethodServer instance. It is not recommended to try to use a single instance of this component with multiple users at the same time.

Parameters:
password - The password for the current user.

getProperty

public com.ms.com.Variant getProperty(String key,
                                      com.ms.com.Variant def)
Get a property from the local windchill properties list. The type of the property returned depends on the type of the default value passed in. Supported types are:

Parameters:
key - The property key to look up.
def - The default value to return if the property is not found.
Returns:
The value stored in the property or the default value.

getServerProperty

public com.ms.com.Variant getServerProperty(String key,
                                            com.ms.com.Variant def)
Get a property from the server's windchill properties list. The type of the property returned depends on the type of the default value passed in. Supported types are:

Parameters:
key - The property key to look up.
def - The default value to return if the property is not found.
Returns:
The value stored in the property or the default value.

setCodebase

public void setCodebase(String cb)
NOTE: To add auto-registration code, refer to the documentation on the following method public static void onCOMRegister(boolean unRegister) {}


getCodebase

public String getCodebase()

setJarfile

public void setJarfile(String jar)

getJarfile

public String getJarfile()

initialize

public void initialize()

bootstrap

private void bootstrap()