|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
# o- u! B! |$ f- F0 kTeamcenter SOA 开发基础代码解析5 w5 ^& S# N/ w8 L
* An instance of the Connection object is created with implementations of the
/ p0 R* s$ n4 ~& q4 `. Z/ Q' |' D* ExceptionHandler, PartialErrorListener, ChangeListener, and DeleteListeners
* X, h& F8 B [* intefaces. This client application performs the following functions:
7 M9 G& r5 I2 r. t4 n+ n* 1. Establishes a session with the Teamcenter server. l$ m) t* ~& i, O
* 2. Display the contents of the Home Folder
n' K: q/ F* X6 T) k A* 3. Performs a simple query of the database
8 |9 n/ e+ p+ N/ H; w* 4. Create, revise, and delete an Item
% r& H3 m( k# Z, z/ B) o, X( ]% {* h+ `7 r# H9 O* p4 M
8 N& K* i( [( @& B' ^9 p; N1 wpublic class Hello) X1 i' b( j0 j8 H" y% i
{4 d& ?) o. n; }
/**+ G3 n. r9 }( _) f
* @param args -help or -h will print out a Usage statement w1 T# {% D/ V5 R+ ]9 m" D
*/
9 X$ d# J* Y% H4 Zpublic static void main(String[] args)! m" v+ z5 q- v! K) j
{6 \* r: z; ?( D. A& T
if (args.length > 0)
: w5 h M' _% R% p6 y{; e! ]% ?- k6 m( ]2 p
if (args[0].equals("-help") || args[0].equals("-h"))
2 f: }9 l9 i; V6 s8 ~8 R2 |{
4 |& F6 O0 D, o/ VSystem.out.println("usage: java [-Dhost=http://server:port/TC] com.teamcenter.hello.Hello");
! A5 t; ?& G8 }3 n: h; `" f% zSystem.exit(0);8 I; `+ A& t- e9 N& W
}
% \2 L( i( o9 A- p2 _}
" m% _/ T" A* h7 \/ S' u/ n9 v// Get optional host information
' V0 L2 ?: a% g- i' b0 H/ YString serverHost = "http://localhost:7001/tc";, N% j1 s2 g- M$ p6 a! w% n& C$ k" k
String host = System.getProperty("host");
$ a; [& k- ?9 d' kif (host != null && host.length() > 0)9 s O) W' d3 I- [) h/ D
{: K- Z& ?1 \. t" U" O$ V
serverHost = host;
" D/ U1 s4 _7 h1 Z}
) W$ G, C7 S8 w* p; |0 |5 DSession session = new Session(serverHost);
$ H# _3 S3 W8 Y! H+ k' F' d6 z$ BHomeFolder home = new HomeFolder();
- u. o) t; {6 j+ ^ N$ W4 O, VQuery query = new Query();
A: f( L9 d0 M. f0 A, a5 rDataManagement dm = new DataManagement();7 o b4 Q/ O, \, W, {, T5 c
// Establish a session with the Teamcenter Server
' z' c( L4 Y2 L, W5 V/ gUser user = session.login();6 A: q# R5 k, u U
// Using the User object returned from the login service request
+ M! L: e4 Z% W// display the contents of the Home Folder
/ P& @( `# a+ A# ehome.listHomeFolder(user);
. t0 m. Q ~/ Y8 x5 g0 y// Perform a simple query of the database' g" Y% _' o, l: F: ?
query.queryItems();, l2 I! r+ T# \! v# A% H8 ?
// Perform some basic data management functions" ]+ u1 y! C- c0 W2 t7 R- x
dm.createReviseAndDelete();
3 u) r, I: {1 S, C" t" A. J// Terminate the session with the Teamcenter server+ L: w. N& R$ b# K1 \; P. X, _
session.logout();
( y7 N) H2 @. P# w* w* l0 m! _1 f}
9 g q: r% i0 I( O' v}1 f, N% X* J8 O! h3 s# \
4 l S% X! K$ P) x6 L) Q |
|