3 use Bio
::CorbaServer
::BioEnv
;
4 use Bio
::CorbaClient
::SeqDB
;
5 use Bio
::DB
::CacheServer
::SeqDB
;
6 use Bio
::DB
::BioSQL
::DBAdaptor
;
9 use CORBA
::ORBit idl
=> [ 'biocorba.idl' ];
12 my $host = "localhost";
13 my $sqlname = "bioperlcache";
19 &GetOptions
( 'host:s' => \
$host,
20 'sqldb:s' => \
$sqlname,
21 'dbuser:s' => \
$dbuser,
22 'dbpass:s' => \
$dbpass,
23 'format:s' => \
$format,
24 'dbname:s' => \
$dbname,
25 'iorfile:s' => \
$iorfile
28 if( !defined $dbname) {
29 die "Must specify the dbname to cache\n";
35 my $orb = CORBA
::ORB_init
("orbit-local-orb");
36 my $root_poa = $orb->resolve_initial_references("RootPOA");
38 # get the corba object of our remote server
40 open(F
,"$iorfile") || die "Could not open $iorfile";
45 my $remote = $orb->string_to_object($ior);
46 my $corba_ref = $remote->get_SeqDB_by_name($dbname);
48 if( !defined $corba_ref ) {
49 die "No remote database for $dbname";
52 # bind the corba object as Bioperl Client
54 my $read = Bio
::CorbaClient
::SeqDB
->new( -corbaref
=> $corba_ref);
57 # connect to our local database. This will throw on inability to connect
59 $dbadaptor = Bio
::DB
::BioSQL
::DBAdaptor
->new( -host
=> $host,
66 # build a caching server
68 my $cache = Bio
::DB
::CacheServer
::SeqDB
->new( -read_db
=> $read,
69 -write_dbadaptor
=> $dbadaptor,
73 # bind cache to a servant object
75 my $servant = Bio
::CorbaServer
::BioEnv
->new('-poa' => $root_poa,
79 $servant->add_SeqDB($dbname,"unknown-version",$cache);
81 # Read to rock and roll
83 # this registers this object as a live object with the ORB
84 my $id = $root_poa->activate_object ($servant);
87 # we need to get the IOR of this object. The way to do this is to
88 # to get a client of the object (temp) and then get the IOR of the
90 $temp = $root_poa->id_to_reference ($id);
91 my $ior = $orb->object_to_string ($temp);
93 # write out the IOR. This is what we give to a different machine
94 $out_file = "cache.ior";
95 open (OUT
, ">$out_file") || die "Cannot open file for ior: $!";
99 # tell everyone we are ready for it
100 print STDERR
"Activating the ORB. IOR written to $out_file\n";
102 # and off we go. Woo Hoo!
103 $root_poa->_get_the_POAManager->activate;