20.08.2009

Domino - sticking Worlds together with Perl

>>Author:  Arnd Koch
>>Ort:     Schwentinental (Kiel)
        
URL: http://www.assono.de/blog/d6plinks/Domino-Java-Perl

Category: Lotus Domino, Java, Perl, Entwicklung


When talking about Perl and Domino most people (at least those who know both) probably think about OLE automation, but there are other ways to work with it.

By using the "Inline::Java" Perl module it is possible to access the Domino/Java bindings in a Perl script - a good combo which combines  the strengths of both Perl and Java.

Perl is very useful, especially when you need a small tool, fast  - of course it's still Java which does the whole work, but there is no need to write a single line of java code to use it.


The following Perl script lists all databases in the domino server's database directory, it also gives a few short information of the database (like replica id, title and filename)


 1 #! /usr/bin/perl
 2 

 3 
use strict;
 4 
use warnings;
 5 
use Inline (
 6    
         Java        => 'STUDY',
 7    
         CLASSPATH   => 'NCSO.jar', # NCSO.jar des domino servers 
                                            muß im classpath stehen   
 8    
         STUDY       => 'lotus.domino.NotesFactory',  
 9    
         AUTOSTUDY   => 1
10    
         );
11    

12    

13 
my $session;
14 
my $dbdirectory;
15 
my $database;
16 

17 
eval{
18  
   $session = lotus::domino::NotesFactory->createSession("servername", "user", "password");
19   
  $dbdirectory = $session->getDbDirectory("");
20 
    
21 
    ## 
22  
   # kleiner stolperstein in der funktion "getFirstDatabase" :
23    
 # "datenbanken suchen" muß im serverdokument für http-clients aktiviert werden:
24 
    #
25 
    # http://ianconnor.blogspot.com/2007/07/diiop-notesexception-server-access.html
26   
  #
27  
   $database = $dbdirectory->getFirstDatabase($dbdirectory->{DATABASE});
28 
};
29 
# prüfen ob eine exception geworfen wurde
30 
if($@){
31 
    die($@->toString()) if(ref($@));    # fehler in java
32 
    die($@);                            # oder in perl
33 
}
34 
    # informationen für alle datenbanken im dbdirectory ausgeben
35 
    while(ref($database)){
36   
      eval{
37   
          print "[".$database->getReplicaID()."] : "
                        .$database->getTitle()." -> "
                        .$database->getFilePath()."\n";
38   
          $database = $dbdirectory->getNextDatabase();
39    
     };
40    
     if($@){
41    
         warn($@->toString()) if(ref($@));
42    
         die($@);
43    
     }
44    
 }
45 
46 
# am schluß noch aufräumen
47 
$dbdirectory->recycle();
48 
$session->recycle();


Links:
http://strawberryperl.com/
http://search.cpan.org/~patl/Inline-Java-0.52/

Post A Comment

Comments

:-D:-o:-p:-x:-(:-):-\:angry::cool::cry::emb::grin::huh::laugh::lips::rolleyes:;-)

Tags

Deutsche RSS-Feeds (German)

Custom Button Custom Button

English RSS feeds

Custom Button Custom Button