In this post I am trying to share the Windchill command line utility skeleton which uses RemoteMethodServer.
package com.blogspot.maheshmhetre.windchill.utilities; import java.lang.reflect.InvocationTargetException; import java.rmi.RemoteException; import wt.method.RemoteAccess; import wt.method.RemoteMethodServer; import wt.session.SessionHelper; import wt.util.WTException; public class WindchillCustomUtilitySkeleton { //START of inner class - Server public static class Server implements RemoteAccess { public static void methodOne(String param1, String param2) { try { //Get login credentials SessionHelper.manager.getPrincipal(); //Call core processing method WindchillCustomUtilitySkeleton utility = new WindchillCustomUtilitySkeleton(); utility.doOperation(param1, param2); } catch (Exception e) { e.printStackTrace(); } return; } } //END of inner class - Server private void doOperation(String param1, String param2) throws WTException{ //TODO execute your utility logic System.out.println("This sysout will be available in method server log."); } public static void main(String[] args) { //TODO get utility input parameters //TODO basic validation System.out.println("This sysout will be available on console from where the utility is running."); //prepare input params //data types will depends on your method parameters and can be any valid object type Class argTypes[] = {String.class, String.class};//add all remote method parameter data types Object argValues[] = {"param_1_value", "param_2_value"};//respective data value //call remote method - pass inner class name, method name, arg types and arg values try { RemoteMethodServer.getDefault().invoke("methodOne", "com.blogspot.maheshmhetre.windchill.utilities.WindchillCustomUtilitySkeleton$Server", null, argTypes, argValues); } catch (RemoteException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } Runtime.getRuntime().exit(0); } }
Please share your thoughts to improve this skeleton.