Shell
Introduction
The command lines and shell commands are mechanisms to execute code directly on the Windchill server. We can add new commands to the shell by adding a feature through the use of the @WexComponent
annotation:
@WexComponent(uid = "admin", description = "Wex example shell commands")
public class WexExampleShell {
@WexShellMethod(alias = "ec", description = "Example Command")
public void list() throws Exception {
System.out.println("Shell result");
}
}
Commands
Due to isolation the Windchill shell cannot access extension class. The mechanism to define a command line is as follow:
import com.wincomplm.wex.kernel.impl.annotations.WexComponent;
import com.wincomplm.wex.kernel.impl.wki.IWexCommandLine;
import java.io.Serializable;
import wt.method.RemoteAccess;
@WexComponent(uid = "wex-example-testcmd",
description = "A exammple command line")
public class ExampleCommand implements Serializable, RemoteAccess, IWexCommandLine {
public int execute(String[] args) {
try {
// Code here
} catch (Exception e) {
return 0;
}
return 1;
}
}
The command is executed using the following kernel command:
windchill com.wincomplm.wex.kernel.commands.WexCommandLineExecutor -pid <wexid> -cid <cmdid>
For example:
windchill com.wincomplm.wex.kernel.commands.WexCommandLineExecutor -pid com.wincomplm.wex-example-command -cid wex-example-testcmd