|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
% p* Z4 a+ C7 K$ ^3 _. G% x0 b% b" BTeamcenter SOA 开发基础代码解析
% E$ z- y" E9 O! R0 K7 h* An instance of the Connection object is created with implementations of the# w: @0 v$ I& I4 U
* ExceptionHandler, PartialErrorListener, ChangeListener, and DeleteListeners
. T. J5 s; X! a; e# q2 Z* intefaces. This client application performs the following functions:
! L4 ~: }; v& Y* 1. Establishes a session with the Teamcenter server+ }/ h, A/ f2 H: y+ `
* 2. Display the contents of the Home Folder: t* L$ y/ B* Q. @: l/ l: R
* 3. Performs a simple query of the database
, D: b/ [( p I5 x* 4. Create, revise, and delete an Item
) Q$ m4 r# n1 P* B# `2 h' C
2 _3 B/ q9 {' }( p- M. u( E+ c& ^3 w
public class Hello
6 L. W8 F, ? W- i3 N. F{4 c/ \9 f7 J8 f* y
/**0 a c* {% G6 `9 x6 }
* @param args -help or -h will print out a Usage statement: j! |, h/ R9 R4 h# ~/ t, b9 g
*/
. u; S* q6 k$ u. Apublic static void main(String[] args). O' ^. C* p4 _0 \: G
{' K: c e3 Q# t/ V* P
if (args.length > 0)
5 g4 [' p0 A; y8 L/ @* @{
; N; l. a. K4 G" y' jif (args[0].equals("-help") || args[0].equals("-h"))
+ |, m. v* j) }! v{5 }4 \1 v4 A: d) g8 ~$ p
System.out.println("usage: java [-Dhost=http://server:port/TC] com.teamcenter.hello.Hello");6 C6 E4 A3 Q$ L" o6 a, ], s# a3 R7 U) ]
System.exit(0);
5 q2 @3 x6 o4 C6 m- ^1 V' B, J$ q+ j}
! P, R; h# N* y+ q. Q9 c}
' P7 C6 c8 n% U% P. u// Get optional host information
3 l+ u+ F( T# N- {String serverHost = "http://localhost:7001/tc";
" O4 O% @- [/ d1 w0 V; mString host = System.getProperty("host");
7 m5 l/ E5 U9 ?9 I ^7 d9 Rif (host != null && host.length() > 0)% t Y, f! O" g p" p2 R
{
) y+ E L7 d5 R, I' YserverHost = host;
0 n* N! K, g4 i5 m; q}/ ?2 ~* x( P. [$ w$ B
Session session = new Session(serverHost);5 s3 p% |( h+ O5 L- R- i! g$ U2 J; S
HomeFolder home = new HomeFolder();" b8 r1 f# n0 P- Z4 t
Query query = new Query();
4 \. C( T" j8 R) k6 VDataManagement dm = new DataManagement();
# Y+ Z9 B. R5 J A. ?" Z6 B// Establish a session with the Teamcenter Server) P& l) Y6 r5 O$ U. H) H
User user = session.login();
& X3 x2 _% q2 o0 X( ^& w& [// Using the User object returned from the login service request5 _) B- g6 d' K4 O
// display the contents of the Home Folder2 \0 U( f; g/ D: s
home.listHomeFolder(user);2 j( A' P, Z! e* q" @
// Perform a simple query of the database
- G3 i7 s- z* l6 x9 u0 \! h% mquery.queryItems();! y' g, ] g! r9 w" V7 ^
// Perform some basic data management functions' n+ ~' s! G0 A' t; ~! v: W
dm.createReviseAndDelete();: C$ c$ Y7 v% W5 D9 ]! C
// Terminate the session with the Teamcenter server
2 }: r, k) T' I& x. B2 X; [session.logout();
7 d3 }; ]) O, g$ E! m}
( Y& t8 ~( R4 S- P3 M& O; Z}) d" k+ c! ` B! M/ p
/ M% e% H& m- _$ W |
|