|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
D2 E. w8 ] j" p
Teamcenter SOA 开发基础代码解析
5 E8 C' ^/ q( E; @. m; k* e* An instance of the Connection object is created with implementations of the
' B! w1 m6 _2 P* O9 E2 {- s& H* ExceptionHandler, PartialErrorListener, ChangeListener, and DeleteListeners* J# e- ?6 \# _4 a1 ~( f* {& A
* intefaces. This client application performs the following functions:9 F' I- q5 n+ i [; N, I7 h1 s0 X
* 1. Establishes a session with the Teamcenter server( U5 f; w p; ]& p6 H: J9 v: ?6 R
* 2. Display the contents of the Home Folder6 j6 z4 O2 S. l! B- L* ]/ C
* 3. Performs a simple query of the database
9 I1 k) Z( N6 R! w; \* 4. Create, revise, and delete an Item
; ^6 o5 o$ l q4 Y
4 t% G; O* f1 m! O3 Y: J! a
+ z* I f! D. l5 \public class Hello9 Y w+ c) H* d( y
{% R8 Z& V, l Q9 E ^
/**6 J6 X5 N# \0 E, }( Q" C5 g0 L. G' K
* @param args -help or -h will print out a Usage statement
' W# T6 [$ `& f& l! p: E2 }*/
5 G# I+ D. J' S$ z- V# Mpublic static void main(String[] args)4 _% y( x' g, l4 D: `. m* ^, W
{
+ U5 X6 q% W* C# jif (args.length > 0)
q$ G: t1 M% _3 E7 \; U{
5 c) p9 a5 t0 C, C0 e: D1 m) w2 Aif (args[0].equals("-help") || args[0].equals("-h")), Y( Z. }* f0 q! ^
{ G3 w" B. T S" V" a, |+ `
System.out.println("usage: java [-Dhost=http://server:port/TC] com.teamcenter.hello.Hello");
6 H: i! V8 I" N6 [, z: B: {System.exit(0);
2 n+ w( {; ]& h2 u! h; ?}, e. n/ U5 K6 m# v4 i, b2 a, y
}& j, C& k9 l/ N+ D
// Get optional host information
3 {# Z% {( @1 j* @' s- N5 ^; nString serverHost = "http://localhost:7001/tc";' ]" t/ a' h+ s) Y5 [6 U
String host = System.getProperty("host");0 }' w4 ?! [" `6 V: W
if (host != null && host.length() > 0)0 E/ U& p( b- |' B& B, g
{
s" \, O9 Q1 {4 bserverHost = host;/ U5 Q- c8 e& X+ `7 c: R" v
}% i/ ~9 [0 v% b5 g* b* ?
Session session = new Session(serverHost);% o- _; P$ y) P! J9 n" B$ @
HomeFolder home = new HomeFolder();
" f+ d6 }9 O( K, m% v: z) o: `Query query = new Query();! z& s+ g1 T* s. K3 U
DataManagement dm = new DataManagement();
3 z! p# U. C! H; Q. w' T// Establish a session with the Teamcenter Server
, y6 y" I( Y6 uUser user = session.login(); G% Q4 f0 ~% V: ]4 S
// Using the User object returned from the login service request+ N$ D- q; A3 M
// display the contents of the Home Folder9 L' g: p6 O# y n
home.listHomeFolder(user);
" m+ l/ f4 v) c' Q$ j// Perform a simple query of the database! M' \- b. k9 W
query.queryItems();' a6 {1 t/ H' P3 `( L
// Perform some basic data management functions
* _3 f `1 R' kdm.createReviseAndDelete();
/ L7 }4 A8 n; O% f4 k// Terminate the session with the Teamcenter server
: ^( D4 b* \" O9 Isession.logout();
! i6 C; ~* g. q# y/ `# b( ?* b0 W}8 Z) K- j" J( s" k
}
8 C% L( d4 E; ~8 s3 P" ]
" V! m2 z5 p: X- D |
|