User Service Mechanism in Teamcenter Customization

You can use the UserService mechanism to call your ITK functions from Java in the rich client.

First register your ITK functions in the user_server_exits.c file.

Compile this file and your source code and link them into the libserver_exits library to make the functions available to the rich client.

  1. In the TC_ROOT\bin directory, back up your old library file (dll in Windows; libserver_exits.so or libserver_exits.sl in UNIX or Linux).
  2. Copy the c and user_server_exits.h files from the TC_ROOT/sample/userservice directory to your working folder.
  3. Register your ITK functions in the c file.

    Example:- 
    if you wanted to register an ITK function called PasteRevToNewstuff in the user_server_exits.c file,The File would look like figure 1-6.

#include <server_exits/user_server_exits.h>

#include <userservice.h>

extern DLLAPI int USERSERVICE_register_methods ()

{

int status = ITK_ok;

int iNumberOfArgs = 0;

int *piArgTypes = NULL;

 

/*

* This function registers the server side user defined functions for the

* CORBA server

*/

 

iNumberOfArgs = 2

piArgTypes = (int*) SM_alloc_persistent (iNumberOfArgs * sizeof (int));

piArgTypes[0] = USERARG_STRING_TYPE;

piArgTypes[1] = USERARG_STRING_TYPE;

 

USERSERVICE_register_method( “PasteRevToNewstuff”, PasteRevToNewstuff, iNumberOfArgs,piArgTypes,USERARG_TAG_TYPE);

return (status);

}


PLM: Introduction of Teamcenter Cloud


 user_server_exits.c file

Example:-

If you want to use an array, add the + USERARG_ARRAY_TYPE declaration to the argument declaration.

For Example:- To make  the piArgTypes[1] argument in figure 1-6 a string array instead of only a string, change the line to this:

piArgTypes[1] = USERARG_STRING_TYPE + USERARG_ARRAY_TYPE;

If you want to return the strings from the array, use the USERSERVICE_return_string_array function.

  1. If you are using Windows, compile your code and the c file using the compile.bat script in the TC_ROOT\sample directory with the following command:

%TC_ROOT%\sample\compile —DIPLIB=libserver_exits user_server_exits.c your-source-code.c

 


Introduction of Teamcenter Active Workspace Architecture


If you are using UNIX or Linux, see the Compiling section for the command.

  1. Link the server exits using the link_server_exits script in the TC_ROOT\sample directory with the following command:

     TC_ROOT\sample\link_server_exits

  1. Copy the new library file to the TC_ROOT\bin

You can then call your ITK functions from the rich client.

For example:-

if you wanted to call the PasteRevToNewstuff function from a JPanel component within an application,

import java.lang.Object;

import java.awt.*;

import javax.swing.*;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import com.teamcenter.rac.aif.*;

import com.teamcenter.rac.aif.kernel.*;

import com.teamcenter.rac.kernel.*;

import com.teamcenter.rac.util.*;

 

public class NewAppApplicationPanel extends JPanel

{

JTextPane JTextPane1 = new JTextPane();

private AbstractAIFUIApplication application = null;

private TCSession  session = null;

private TCUserService  service = null;

private TCComponent  component = null;

 

public class NewAppApplicationPanel( AbstractAIFUIApplication app )

{

super (new BorderLayout());

 

application = app;

session = (TCSession)application.getSession();

 

try

{

service = (TCUserService)session.getUserService();

}

catch( TCException e )

{

}

 

JtextPane1.setCaretColor(Color.red);

JtextPane1.setText(“Welcome”);

JtextPane1.setForeground(Color.magenta);

 

this.add (JTextPane1, null);

 

add( “North”, app.getApplicationHeader());

Object objs[] = new Object[2];

 

String itemID = new String( “000001”);

String revID = new String( “A”);

objs[0] = itemID;

objs[1] = revID;

try

{

component = (TCComponent) service.call( “ACME_PasteRevToNewstuff”, objs);

}

 

catch( TCException e )

{

MessageBox msgBox = new MessageBox( e );

msgBox.setModal( true );

msgBox.setVisible( true );

}

}

public NewAppApplicationPanel()

{

try

{

jbInit();

}  catch( Exception e )

{

e.printStackTrace();

}

}

private void jbInit() throws Exception

{

}

}

We will more post on PLM TUTORIAL–>Teamcenter Customization in upcoming days.

Kindly provide your valuable comment on below Comment section and also have you any question kindly ask to ASK QUESTION in FORUM. Our Team will try to provide the best workaround.

Kindly subscribe to your Email-Id in (https://globalplm.com/) and in case anyone wishes to contact for more information on this topic/query, please drop me a message/comments).

admin