Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Components in Perl and SOAP::Lite Team "Messengers" Larry McKnight, MD Davis Bu, MD Pete Stetson, MD Maryam Kamvar.

Similar presentations


Presentation on theme: "1 Components in Perl and SOAP::Lite Team "Messengers" Larry McKnight, MD Davis Bu, MD Pete Stetson, MD Maryam Kamvar."— Presentation transcript:

1 1 Components in Perl and SOAP::Lite Team "Messengers" Larry McKnight, MD Davis Bu, MD Pete Stetson, MD Maryam Kamvar

2 2 Table of Contents: Project Overview Project Demo Perl, SOAP::Lite and Components

3 3 Context: PalmCIS Project and Application. Project goal is to reduce medical errors. Improving communication (whiteboard) Timely access to patient information. PalmCIS (the app) a wireless handheld version of the CIS. Timely access to domain knowledge (Infobuttons).

4 4 Communication Example: Nurse wants orders renewed. Nurse identifies the Intern for her patient. Nurse finds the pager number for the Intern. Nurse pages intern, waits for response. Intern interrupts his current activities to answer page. Intern must remember task (sign orders) Intern return to previous task. Inefficient, error prone.

5 5 Project:A Virtual Whiteboard Problem: Team structure changes rapidly. Identifying and contacting providers is difficult. Problem: Interruptive work environments make errors more likely. Problem: Patients are very concerned about who looks at their data. Solution: new system. Patient centered, asynchronous, role based (like a whiteboard).

6 6 Legacy: WebCIS Web based Clinical Information System CGI based (written in C). AIX Server farm. Patient data on mainframe. Restricted access thru UNIX sockets (DAMs). Provider Authentication data through LDAP server. C and Perl socket drivers available. No EJB, CORBA, or.NET

7 7 WebCIS

8 8 New Problem We would like to take advantage of principles in this class – XP, Components, etc. We want to use Perl. Legacy Perl drivers. Convincing the system admin to install EJB, CORBA or.NET to run the project would kill it. Solution: Use Perl as a component model.

9 9 Is Perl a Component Model? Intro to Perl Perl Objects and Modules SOAP::Lite Component Model definitions and satisfaction with Perl Hold questions until end

10 10 Intro to Perl In the beginning: UNIX, C, sed, awk – Larry Wall Practical Extraction and Report Language Pathologically Eclectic Rubbish Lister "So lazy he created a new computer language“  V1, 12/87 Released to Usenet  V4, 3/91 The Camel book.  V5, 10/94 “Everything else” - Objects, Modules.  V5.6, 3/2000  V5.8, 7/2002 Today: widespread use, cgi scripts, CPAN.

11 11 Why Perl? Faster development time. ~1/3 – 2/3 as much code. CPAN Common things are easy, hard things are possible. Most things are (or can be represented as) text. Perl has excellent string handling. Perl is and (according to Larry Wall, will always be) free. Perl is fun.

12 12 Common Myths about Perl Myth:Easy to learn; Fact:Easy to use. Goal has always been power over learning. Lots of quirks, Easier ways. Myth:Slow; Fact: Mostly Fast. C bindings, Profiling. Use of appropriate data structures. Mod_perl. Don't use it to develop a CAD app or Micro-kernel.

13 13 Perl Myths continued… Myth:Insecure; Fact: Mostly Secure Taints, warnings, use safe Security by design, not obscurity Myth:Not scalable; Fact: Very scalable The defining problem. The best inter-platform, inter-language support I know of. It also scales down. Myth:Un-maintainable; Fact: It Depends “A very high-level language” Perl lets you get away with stuff.

14 14 Why ! Perl? Your boss/customer wants it done in some other language. Your problem has lots of numbers in it. You need a GUI. You don't know Perl. You despise the command prompt. You don't want others to see your code.

15 15 Perl: Data Types Scalars my $null_val=""; my $count++; my $name="Larry"; my $string=$name.$count; #string is “Larry1” Arrays, Lists Moe Curley); Hashes my %treatment=(diabetes=>"insulin"); my $medicine=$treatment{$disease};

16 16 Perl: Numbers Type automatically set to int or floats depending on context Integer Negative integer Floating point 6.02E23 Scientific notation 0xffff Hexadecimal 0377 Octal 4_294_967_296 Underline for legibility Override with int or hex functions

17 17 Perl: Type conversion Hashes can be arrays %fruit=('apples',3,'oranges',6); print $fruit{apples}; #prints 3 All arrays have scalar contexts $a=(2,4,6,8); #a is 8 $b=%c; #b is the number of items in c ($sec, $min, $hour, …)=localtime; $now=localtime; #$now is like "Fri Aug 18,…)

18 18 Perl: Subroutines Arguments Passed as a single flat list of scalars Return is evaluated in the context it is sub mysort { my $a=shift; my $b=shift; … }

19 19 Perl: "hanks", "cage", "cruise"); %treat=("headache"=>"aspirin", "cold"=>"chicken soup"); sub c2f { 9/5*$ARG[0]+32 }; $therapy=\%treat; $coldtherapy=\$treat{"cold"}; $convert=\&c2f; $pi=\3.1459; print $$coldtherapy; #prints chicken soup $stars->[3]; #cruise is blisted $family={dad=>"Homer", mom=>"Marge", son=>"Bart"}

20 20 Perl: Regular expressions /And(y|rew)/ #default $_ match Andy or Andrew $id =~ /^(\d+)$/; #id must not have characters $line !~ /^Intro:.*/; #all lines that don’t start with Intro s/([^c])ei/$1ie/g; #i before e, except after c

21 21 Perl Golf Defaults, backticks, <

22 22 Defining Perl Objects: package NBC::Horse; #namespace #inheritance sub new{ my ($class, my $self={name=>"$name", #anonymous reference sound=>"neigh"}; bless $self, $class; #blessed into an object } #return implied … sub sound { my $self=shift; return $self->{sound}; }

23 23 Instantiation of Perl Objects: use NBC::Horse; my $horse=NBC::Horse->new("Mr. Ed"); #is equivalent to my $horse=NBC::Horse::new("Horse", "Mr. Ed"); print $horse->name, " says ", $horse->sound, ".\n"; #prints Mr. Ed says neigh.

24 24 Perl Ties DBM use DB_File; tie %treat, "DB_File", "treatments"; my $rx=$treat{"Diabetes"}; $treat{"PUD"}="PrevPak"; Rolling your own: User CodeExecuted Code tie $s, "SomeClass"SomeClass->TIESCALAR() $p = $s$p = $obj->FETCH() $s = 10$obj->STORE(10)

25 25 Perl Modules The unit of software reuse in Perl is the module, a file that has a collection of related functions designed to be used by other programs and library modules. Every module has a public interface, a set of variables and functions that outsiders are encouraged to use. From inside the module, the interface is defined by initializing certain package variables that the standard Exporter module looks at. From outside the module, the interface is accessed by importing symbols as a side effect of the use statement. … When we talk about modules in this chapter, and traditional modules in general, we mean those that use the Exporter.

26 26 Perl Modules #!/usr/bin/perl –wT package Cards::Poker; use Exporter; use strict; use @deck=(); $VERSION=0.01; 1; sub new{ … sub shuffle{ …

27 27 Perl POD The Semantic Interface pod2man, pod2text, pod2html, pod2latex… … =head1 NAME MyModule … =head1 SYNOPSIS use MyModule; … =item foo($bar) Foo transforms $bars and returns a $baz =cut sub foo { my $bar=shift; …

28 28 Modules for Distribution CPAN h2xs Test Harness POD man perlmodlib

29 29 CPAN

30 30 Installing Modules Finding Modules find `perl –e ‘print ’`-name “*.pm” -print pmdesc Unix tar –xzvf; perl Makefile.PL; make; make test; make install perl –MCPAN -eshell Windows (ActiveState Perl) perl ppm.pl

31 31 Language Interfaces & Distributed Perl? XS Java.pm CORBA::Orbit COM SOAP::Lite

32 32 XS XS=eXternal Subroutine See man pages perlguts, perlxs, perlxstut,perlcall, perlapi, h2xs, Chap. 21 of the Camel.

33 33 Building XS h2xs -A -n Mytest MANIFEST, Makefile.PL,Mytest.pm, Mytest.xs, Changes edit Mytest.xs perl Makefile.PL make make test

34 34 Example: XS #include "EXTERN.h" #include "perl.h" #include "XSUB.h" MODULE = Mytest PACKAGE = Mytest void round(arg) double arg CODE: if (arg > 0.0) { arg = floor(arg + 0.5); } else if (arg < 0.0){ arg = ceil(arg - 0.5); } else { arg = 0.0; } OUTPUT: arg

35 35 Example:calling XS package Mytest; … require Dynaloader; … … bootstrap Mytest $VERSION;

36 36 Example: Java.pm use Java; $java = new Java; $frame = $java->create_object( "java.awt.Frame","Frame's Title"); $frame->setSize(400,400); $frame->show(); $java->do_event( $frame,"addWindowListener",\&event_handler); …

37 37 Example: CORBA::ORBit use CORBA::ORBit idl=>[‘echo.idl’]; my $orb=CORBA::ORB_init(“orbit-local-orb”); open IOR, “echo.ior”; my $ior= ; close IOR; my $echo=$orb->string_to_object($ior); … $echo->echoString($mystring);

38 38 Example: COM package WebMail; use Mail::Sender; 1; sub send { my($from, $replyto, $to, $cc, $bcc, $smtp, $subject, $message, $file) …

39 39 Example: Perl COM cont… PerlCtrl.pl –t =POD =BEGIN PerlCtrl %TypeLib = ( PackageName => 'WebMail', TypeLibGUID => '{B3C98206-C910-11D3-B F9BDE4A}', ControlGUID => '{B3C98207-C910-11D3-B F9BDE4A}', DispInterfaceIID=>'{B3C98208-C910-11D3-B F9BDE4A}', ControlName => 'WebMail', … Methods => { 'send' => { RetType => VT_BOOL, TotalParams => 9,

40 40 SOAP Simple Object Access Protocol XML standard … bar

41 41 SOAP::Lite Client Example #!/usr/bin/perl -w use SOAP::Lite; print SOAP::Lite ->uri('http://www.soaplite.com/Demo') ->proxy('http://services.soaplite.com/hibye.cgi') ->hi() ->result;

42 42 SOAP::Lite Client Example2 #!/usr/bin/perl -w use SOAP::Lite +autodispatch=> uri=>('http://www.soaplite.com/Temper'), proxy=>('http://services.soaplite.com/temper.cgi'); print f2c(98.6);

43 43 SOAP::Lite CGI Server #!/usr/bin/perl -w use SOAP::Transport::HTTP; SOAP::Transport::HTTP::CGI ->dispatch_to('Temperatures') ->handle; package Temperatures; sub f2c{ my ($class,$f)=$_; return 5/9*($f-32); }

44 44 SOAP HTTP Daemon Server #!/usr/bin/perl -w use SOAP::Transport; use Temperatures; my $daemon=SOAP::Transport::HTTP::Daemon ->new(LocalPort=>81) ->dispatch_to('/home/soaplite/modules'); print "started SOAP daemon at ",$daemon->url, "\n"; $daemon->handle;

45 45 SOAP::Lite Object methods, and exceptions. mod_perl, mod_soap servers Stated support for:.NET / COM MS SOAP/ Apache SOAP interoperability HTTPS / Jabber / MQSeries / SMTP / POP3 WSDL schema

46 46 SOAP::Lite suds Autodispatch doesn't always work. Talking to.Net servers requires explicitly naming and typing variables in SOAP::Lite.

47 47 Components What's a component? Legally Practically

48 48 A component defined "Legally" "A component model defines specific interaction and composition standards. A component model implementation is the dedicated set of executable software elements required to support the execution of components that conform to the model" "A software component is a software element that conforms to a component model, and can be independently deployed and composed without modification according to a composition standard" Page 7 CBSE

49 49 Interaction Standard "the mandatory requirements employed and enforced to enable software elements to directly interact with other software elements" Distributed Computing? Interfacing other languages?

50 50 Interaction Standard At a bare minimum: package, use For completeness, use Exporter. The unit of software reuse in Perl is the module, a file that has a collection of related functions designed to be used by other programs and library modules. Every module has a public interface, a set of variables and functions that outsiders are encouraged to use. From inside the module, the interface is defined by initializing certain package variables that the standard Exporter module looks at. From outside the module, the interface is accessed by importing symbols as a side effect of the use statement. … When we talk about modules in this chapter, and traditional modules in general, we mean those that use the Exporter.

51 51 A component explained "Technically" Channel StubSkel Component ClientServer Interface Symbol table Module Perl

52 52 Perl Interaction Standard A Symbol table How does the compiler know parameter types All parameters are passed as a list of scalars. How do I know how many parameters, ordering, expected return, etc. Smantics. Read the module documentation. Same problem in every other component interface.

53 53 Semantics String foo (String bar, int baz) raises fooException; float divide (float numerator, float denominator);

54 54 Composition Standard Combining of two or more software components yielding a new component behavior at a different level of abstraction. Clearly separate from OS and other components Typically involves: Installation Configuring Instantiating

55 55 Practical Components Software Reuse "you need components for complex, mission critical systems, because they are robust, scalable, flexible"

56 56 Practical Components Table 3.1 Interfaces Naming Meta data Interoperability Customization Composition Evolution Support Packaging and Deployment

57 57 Choosing a component model State management Scalability Robustness Security Fault tolerance Deployment Platform Support Ease of Development

58 58 Perl as a Component Model Conclusion From the definitions in the book, Perl fulfills the requirements of a component model. From a practical perspective, Perl modules are used as components. Perl (+/- SOAP::Lite) fares well in criteria used to evaluate other component models. Our project benefits from legacy support by using Perl.

59 59 Whiteboard Architecture Portal Formatting Data Objects DB Driver Database

60 60 Whiteboard Architecture

61 61 Whiteboard Architecture


Download ppt "1 Components in Perl and SOAP::Lite Team "Messengers" Larry McKnight, MD Davis Bu, MD Pete Stetson, MD Maryam Kamvar."

Similar presentations


Ads by Google