## plik Hello.idl # module HelloApp { interface Hello { string sayHello(); typedef sequence t_long_lista; t_long_lista razy2(in t_long_lista lista); t_long_lista razy3(in t_long_lista lista); attribute t_long_lista prop1; attribute t_long_lista prop2; }; }; ## klient uzywajacy obiektow Corby z PSSem # package re combat #% 0.7 corba::init \ -ORBInitRef InterfaceRepository=file://[pwd]/ird.ior \ -ORBInitRef NameService=file://[pwd]/nsd.ior if 0 { # mozna inaczej: corba::register_initial_reference InterfaceRepository [corba::string_to_object file://[pwd]/ird.ior] corba::register_initial_reference NameService [corba::string_to_object file://[pwd]/nsd.ior] } set ns [corba::resolve_initial_references NameService] join [$ns list 10 x y; set x] \n #% binding_name {{id qqq111 kind {}}} binding_type nobject binding_name {{id qqq222 kind {}}} binding_type nobject set h1 [$ns resolve_str "qqq111"] $h1 sayHello #% Jak sie masz ??? (1592) #% Jak sie masz ??? (1591) $h1 prop1 {5 5 5 5} $h1 prop1 #% 1 2 3 4 5 6 7 ## serwer ob. Corby z PSSem # # + musza byc uruchomione demony: ird i nsd (z brokera MICO) # + ird (serwer Interface Repository) musi miec zaladowane odp pliki IDL # idl --feed-ir -ORBInitRef InterfaceRepository=file://$(pwd)/ird.ior Hello.idl # idl --feed-ir -ORBInitRef InterfaceRepository=file://$(pwd)/ird.ior COS_ns.idl corba::init -ORBServerPort 10000 \ -ORBInitRef InterfaceRepository=file://[pwd]/ird.ior \ -ORBInitRef NameService=file://[pwd]/nsd.ior #delete class HelloWorld class HelloWorld { inherit PortableServer::ServantBase public method _Interface {} {return "IDL:HelloApp/Hello:1.0"} public method sayHello {} { pss_begin set licz [pss licz] incr licz pss licz $licz pss_end return "Jak sie masz ??? ($licz)" } public method razy2 lista { set _ {} foreach x $lista {lappend _ [expr {$x * 2}]} return $_ } public variable prop1 ? {pss_begin; pss prop1 $prop1; pss_end} public variable prop2 ? {pss_begin; pss prop2 $prop2; pss_end} # impl. atrybutow ob. Corby private variable oid private variable cursor # zmienne oid i cursor sa wymagane przez komende pss constructor {cursor_} { set oid [namespace tail $this] set cursor $cursor_ set prop1 [pss prop1] set prop2 [pss prop2] } } set poa [corba::resolve_initial_references "RootPOA"] set mgr [$poa the_POAManager] $mgr activate set poa2 [$poa create_POA "POA2" $mgr {USER_ID PERSISTENT}] set ns [corba::resolve_initial_references NameService] source pss_lib_2.tcl # rzeczywista implementacja trwalosci serwantow mk::file open db "ser3.mk" -nocommit mk::view layout db.HelloWorld {oid:I licz:I prop1:S prop2:S} # oprocz "oid" zdef wszystkie trwale atrybuty ob. klasy HelloWorld !!! HelloWorld 111 db.HelloWorld!0 # 111 to oid i rownoczesnie ref do ob. itcl (do serwanta) !!! # to ulatwia reprezentowanie zwiazkow miedzy obiektami... # "db.HelloWorld!0" to kursor w bazie metakit $poa2 activate_object_with_id 111 111 set ref [$poa2 id_to_reference 111] $ns rebind {{id "qqq111" kind ""}} $ref HelloWorld 222 db.HelloWorld!0 $poa2 activate_object_with_id 222 222 set ref [$poa2 id_to_reference 222] $ns rebind {{id "qqq222" kind ""}} $ref vwait qqq ## skrypt pss_lib_2.tcl (impl. proc pss) # package require Mk4tcl #% 2.4.9.5 proc pss args { upvar oid oid_ upvar cursor cursor_ set coid -1 catch {set coid [mk::get $cursor_ oid]} if {$coid!=$oid_} { # wybieramy wlasciwy wiersz tabeli set i1 [mk::select $cursor_ oid $oid_] if {$i1=={}} { # jesli nie ma wiersza to go tworzymy set c1 [mk::row append $cursor_ oid $oid_] set i1 [mk::cursor position c1] } mk::cursor position cursor_ $i1 } set argc [llength $args] if {$argc==1} { # get set name [lindex $args 0] return [mk::get $cursor_ $name] } elseif {$argc==2} { # set set name [lindex $args 0] set value [lindex $args 1] mk::set $cursor_ $name $value return {} } return {} } set pss_level 0 proc pss_begin {} { upvar oid oid upvar cursor cursor global pss_level incr pss_level pss; # uaktualnienie kursora } proc pss_end {} { upvar oid oid upvar cursor cursor global pss_level incr pss_level -1 if {$pss_level==0} { mk::file commit $cursor } }