|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
. z* }- f' ]0 }) u4 tTeamcenter SOA 开发基础代码解析
9 N# i, Y7 ~) P) N. }: z* An instance of the Connection object is created with implementations of the# E( q/ Z+ }8 P/ k( {" l7 c, `
* ExceptionHandler, PartialErrorListener, ChangeListener, and DeleteListeners( _/ c2 _2 i3 x+ ~% l: ?- R$ B+ k6 {
* intefaces. This client application performs the following functions:
; I' C c5 k6 [& g. k* 1. Establishes a session with the Teamcenter server, P# B; J0 M8 [
* 2. Display the contents of the Home Folder. L8 x3 k! }( R3 l4 L- Y! s: [
* 3. Performs a simple query of the database0 l4 J' ~- G9 E- D) D; c" Q
* 4. Create, revise, and delete an Item
, c# I; H4 E; e% y$ U- V( x6 g! U7 i' |3 ^9 n: ^7 C
) a1 u% n: o2 ?6 k* @
public class Hello: `# w5 i* o( W5 Y3 i" L$ W# L7 z
{
' W6 z; j/ c$ g- @/**% g; Z4 M) j. c% _* b8 U
* @param args -help or -h will print out a Usage statement
0 M( x, F, h7 o& Z% l* ~*/
0 ~) ?. v; D `8 I4 j: `public static void main(String[] args)* f _' [; m2 l0 H) d" ~
{; a! S4 n( ]7 X& R7 Z
if (args.length > 0)
% L$ ?& V- o* p+ l" D; w! h{
8 \6 q0 D. y4 ]( h9 B+ wif (args[0].equals("-help") || args[0].equals("-h")); t! u0 J, Y: W4 j
{
8 ], Y2 u9 Y! w, h$ H4 QSystem.out.println("usage: java [-Dhost=http://server:port/TC] com.teamcenter.hello.Hello");
& ~# p0 \6 }: T% R+ R3 ySystem.exit(0);. d0 m$ K4 L: @! T
}( c- ~5 m+ _5 p" w" |
}7 D( N1 u9 n/ R
// Get optional host information
- _$ ]6 T# N0 ?( @0 y- AString serverHost = "http://localhost:7001/tc";. ~9 I- p3 `; I' z: i5 n9 b
String host = System.getProperty("host");7 i' E" M& X$ G4 Y
if (host != null && host.length() > 0)
$ U4 f% I9 @8 y* ~# Y. z. `{7 V1 }4 R! \9 N* }+ |6 ]( V
serverHost = host;4 U( w9 M1 T5 O0 p7 {/ j+ W: D
}4 U4 p, u' g. R
Session session = new Session(serverHost);* W6 d# z1 Q7 n3 m8 _/ A. P
HomeFolder home = new HomeFolder();. G+ W6 A k5 O; B, i4 a2 P
Query query = new Query();4 q- w% I- p, L7 \& S4 u) M. I0 y. r$ e
DataManagement dm = new DataManagement();, U* F4 K5 ~4 E/ d! ^
// Establish a session with the Teamcenter Server/ H% [- L4 [0 Z1 F
User user = session.login();+ z# `6 ~5 s* ?+ ^! r+ k
// Using the User object returned from the login service request6 i9 k& W- |* u2 m3 J% c1 l
// display the contents of the Home Folder
* m+ p1 D' i4 Y. q* A/ m& nhome.listHomeFolder(user);! e! C& W. `" p
// Perform a simple query of the database7 A! Q1 o g2 u2 f" t! b! L5 H/ t
query.queryItems();
" V1 z: h* V0 M n7 ~. _// Perform some basic data management functions
% t( ~" J/ j+ e# F$ L( L0 _dm.createReviseAndDelete();
% b7 e) G" {7 A( i/ O, R// Terminate the session with the Teamcenter server
4 K+ X% g1 y1 ?+ p' i: S9 Xsession.logout(); y! P% ?/ \7 ?; `# k
}' K" k9 u7 a" D/ r S# J
}
' l" ~1 y9 i6 O
/ F, _; K# l, S+ _% R6 p& B$ j( b8 { |
|