|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
6 V- {: x: {4 R, a) _! |% B
Teamcenter SOA 开发基础代码解析
0 W5 j% K& |! ?% t4 b* An instance of the Connection object is created with implementations of the
" _& V7 Q7 C5 `0 k0 G$ f! V. q& }* ExceptionHandler, PartialErrorListener, ChangeListener, and DeleteListeners' N6 p! L( F$ @( `
* intefaces. This client application performs the following functions:+ i/ [+ m# x3 x4 i
* 1. Establishes a session with the Teamcenter server. G: [6 n0 W0 f4 Y9 H0 X
* 2. Display the contents of the Home Folder. R/ R, u# U3 }+ n4 D; x8 g' s
* 3. Performs a simple query of the database: ?1 V! U `4 Q
* 4. Create, revise, and delete an Item
* Z5 m5 o, f; B& c0 ^1 v# i0 o, q( i/ e; O/ g0 _- E
: r, p# a; f/ L5 t. N- opublic class Hello
- [0 Y2 U2 e- _- t% _. y$ p{5 K; ?& z0 v' V
/**( z6 W; X7 j( P( ^7 T& o# `( m8 J
* @param args -help or -h will print out a Usage statement) _! J6 U1 d( {3 S$ O
*/
! d e$ E/ O" Mpublic static void main(String[] args)
$ f7 ]2 a: U% j, W- {{: W3 u( _: s- E6 P) s
if (args.length > 0)$ I- J3 B' O8 W
{/ `7 k5 f# j' P) H
if (args[0].equals("-help") || args[0].equals("-h")) c5 k8 T( Q' f# t( w
{4 L1 _. h' F ]4 A `
System.out.println("usage: java [-Dhost=http://server:port/TC] com.teamcenter.hello.Hello");
" C1 ?3 ]3 r9 J0 @' t, c6 xSystem.exit(0);, L( P! }# u4 c. ^7 z0 U
}' ]. n& G# S* v" ~' u# ?' a
}
; o( w+ y* @0 _// Get optional host information
% r4 Q! E W- h# ` eString serverHost = "http://localhost:7001/tc";4 o' P9 k @6 {) U4 [9 {
String host = System.getProperty("host");
% a% w1 J( P$ i- f/ A. _7 Xif (host != null && host.length() > 0)
3 M1 [1 d* `; B{8 s( }/ W& o" {
serverHost = host;
6 `+ U& i8 D8 g7 Z$ Z& @5 H}
; E+ f. i2 ?( nSession session = new Session(serverHost);) G/ A( J W" G5 C0 k2 j: N
HomeFolder home = new HomeFolder();
% e' Q6 t8 b" _3 f: X, J* s- c, D( k7 OQuery query = new Query();
4 N0 n5 a9 j X3 L, M, s9 x" T- T; JDataManagement dm = new DataManagement();
7 o$ N$ ~, v3 S, f$ a) ~/ m// Establish a session with the Teamcenter Server
/ S% Y* T( e+ Q- Q# Q) tUser user = session.login();" o3 i6 M V+ _& t# D/ e
// Using the User object returned from the login service request
+ k5 u1 d9 f" v' K// display the contents of the Home Folder1 F" K/ `+ T& Y6 C, J& R6 A. u
home.listHomeFolder(user);% Z) m* T9 F; v0 D
// Perform a simple query of the database
, J9 N0 V6 h. c) }& U# W# w4 Vquery.queryItems();
. b5 f9 c3 E- P- u, h/ `// Perform some basic data management functions
' b; `8 `3 R. C$ c' @4 w. Ydm.createReviseAndDelete();
0 _; O3 M! y8 u. Y0 o8 h6 ?// Terminate the session with the Teamcenter server
$ x$ Z$ R4 L+ Dsession.logout();
2 h/ D6 Y7 C) j d}
1 F: J. t. z7 @6 u2 \# w& h: L}& U& v1 _% O; n# ^
; s* O6 E) ^/ R" s |
|