|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
- p: ^8 r9 G: z! Y& NTeamcenter SOA 开发基础代码解析
- W3 h8 `# }* K/ u5 [' y2 d" {* An instance of the Connection object is created with implementations of the
: P9 _. F+ c9 y3 s1 b0 B! P* ExceptionHandler, PartialErrorListener, ChangeListener, and DeleteListeners
6 h& T1 B: u& ~+ I2 i* intefaces. This client application performs the following functions:
& l/ ^( v6 u" n0 x! ?* 1. Establishes a session with the Teamcenter server
3 N, z' Y( e5 t$ U. e! T* ]* 2. Display the contents of the Home Folder
1 P- H2 D+ }7 k4 H! i) E7 o* 3. Performs a simple query of the database+ W8 l, J) W5 M6 Q& P4 F; m+ T
* 4. Create, revise, and delete an Item6 g& _) {$ r9 ^1 ^! I) R% A: T
( g6 [# s1 ~8 @ V( c+ B. W- W, \
9 c# H; e# U; O5 S' \public class Hello: Z2 q" T4 e* i( q
{
+ h& J+ }* }6 t/**5 z7 A/ d, l& {& ?- e8 f
* @param args -help or -h will print out a Usage statement
* b' u8 t% r$ T! \6 S# Z+ s*/3 }3 E0 W9 U' }) {5 C
public static void main(String[] args)
) P3 f- K* T) k) m2 S{
1 `2 X1 d6 V8 O3 Lif (args.length > 0)+ [3 j& [( g8 i0 [1 A" ?1 M
{
5 z$ V- i$ E+ \% c# R$ Iif (args[0].equals("-help") || args[0].equals("-h"))
) s# ^4 ]2 P7 y/ o$ Z{
1 W$ p1 U1 w, bSystem.out.println("usage: java [-Dhost=http://server:port/TC] com.teamcenter.hello.Hello");
: {! Y6 @8 ~- S5 MSystem.exit(0);
" m2 v; R" ~& F& t& _% |}
+ L S7 o/ c# _0 |: }4 g}$ e+ l! d5 O# n3 d8 V" _
// Get optional host information
' B- b* e) \+ IString serverHost = "http://localhost:7001/tc";
3 Y" S, ]; D u* z5 pString host = System.getProperty("host");
5 B$ P; F/ U4 T4 a9 M4 g' nif (host != null && host.length() > 0)
3 v$ b/ {$ n" ~4 e1 A0 ^8 w" a$ A( w/ Z. y{8 S) F( H6 G, H0 A! ]
serverHost = host;+ w+ {; A, \; q" k4 g) f+ f5 S
}4 L7 B# C% W0 F; X) T) |
Session session = new Session(serverHost);
+ D5 o' s; v$ {9 ~8 Q. y7 EHomeFolder home = new HomeFolder();8 W6 c3 S! `$ f% s+ Y) Z: s6 F
Query query = new Query();! e. x4 y* F2 v* @: P# l
DataManagement dm = new DataManagement();2 O t/ m! p% q/ c& W% v
// Establish a session with the Teamcenter Server; D4 a, y- M, p' M
User user = session.login();
( V9 c' C, D8 u+ D9 s- y) W" n7 p// Using the User object returned from the login service request4 W( h0 {# z5 Q7 R5 T G
// display the contents of the Home Folder
, B9 K& \7 t" m, W" ^& q E9 @home.listHomeFolder(user);& \& e q( P) E- b! o$ F
// Perform a simple query of the database% g9 ?1 M$ k/ k( ]( E" G
query.queryItems();! i" J, m: A) S& {; Q K3 p
// Perform some basic data management functions ^5 D* E% T$ J4 k
dm.createReviseAndDelete();7 b" b# `8 y9 }/ q* ~ Q
// Terminate the session with the Teamcenter server
2 u4 p8 \) d) d- e' qsession.logout();
# Z$ o* G Y f% z5 C; p}, n7 f/ S) O3 f0 y9 e& l
}& [ S- G2 S5 @6 e1 P
4 r# T+ J9 ~) W, L/ l7 `# t |
|