1OpenFrame(3) User Contributed Perl Documentation OpenFrame(3)
2
3
4
6 OpenFrame - a framework for network enabled applications
7
9 use OpenFrame;
10
12 OpenFrame is a framework for network services serving to multiple media
13 channels - for instance, the web, WAP, and digital television. It is
14 built around the Pipeline API, and provides extra abstraction to make
15 delivery of a single application to multiple channels easier.
16
18 The most important thing that this module does is provide a wrapper
19 around OpenFrame specific debug information - for example, the informa‐
20 tion provided by OpenFrame segments.
21
22 This variable is a hash called %DEBUG in the OpenFrame package. If you
23 set the ALL key to a true value, then debugging information about all
24 segments will be printed. If you want to resolve your debugging output
25 to a single module, then set a key that matches the segments name to a
26 true value. For example, setting $OpenFrame::DEBUG{'OpenFrame::Seg‐
27 ment::HTTP::Request'} to 1 would mean that all the debug messages from
28 the HTTP::Request segment would get printed.
29
31 This will briefly explain how to set up a stand-alone OpenFrame server.
32 It uses the code listing below.
33
34 The first few lines (01-08) simply load all the modules that are needed
35 to setup the various constituent parts of an OpenFrame server. Lines 9
36 creates an HTTP daemon listening on port 8080 for requests, in the case
37 that the server cannot be created line 10 provides error reporting to
38 the screen.
39
40 The first real piece of OpenFrame code is found at line 14, where we
41 create a Pipeline object, followed quickly by lines 16, 17 and 18 which
42 create a couple of pipeline segments that will be added to the pipeline
43 at line 21. Lines 24 and 26 create a loop to listen for and accept con‐
44 nections, and fetch HTTP requests from those connections as and when it
45 is needed.
46
47 At line 28 we create a Pipeline::Store::Simple object, which will act
48 as our data container for the information flowing down the pipeline. We
49 add the request to the store and the store to the pipeline at line 31,
50 and then call the dispatch() method on the pipeline at line 34. This
51 sets the OpenFrame side of things going. At line 37 we ask the pipeline
52 for the store and the store for an HTTP::Response object, and then send
53 it back to the client at line 40.
54
55 The real work of OpenFrame is in the segments that are created, and the
56 order in which they are inserted into the Pipeline. With this in mind,
57 you know everything there is to know about OpenFrame.
58
60 01: use strict;
61 02: use warnings;
62 03:
63 04: use Pipeline;
64 05: use HTTP::Daemon;
65 06: use OpenFrame::Segment::HTTP::Request;
66 07: use OpenFrame::Segment::ContentLoader;
67 08:
68 09: my $d = HTTP::Daemon->new( LocalPort => '8080', Reuse => 1);
69 10: die $! unless $d;
70 11:
71 12: print "server running at http://localhost:8080/\n";
72 13:
73 14: my $pipeline = Pipeline->new();
74 15:
75 16: my $hr = OpenFrame::Segment::HTTP::Request->new();
76 17: my $cl = OpenFrame::Segment::ContentLoader->new()
77 18: ->directory("./webpages");
78 19:
79 20:
80 21: $pipeline->add_segment( $hr, $cl );
81 22:
82 23:
83 24: while(my $c = $d->accept()) {
84 25:
85 26: while(my $r = $c->get_request) {
86 27:
87 28: my $store = Pipeline::Store::Simple->new();
88 29:
89 30:
90 31: $pipeline->store( $store->set( $r ) );
91 32:
92 33:
93 34: $pipeline->dispatch();
94 35:
95 36:
96 37: my $response = $pipeline->store->get('HTTP::Response');
97 38:
98 39:
99 40: $c->send_response( $response );
100 41: }
101 42: }
102
104 perl(1) Pipeline(3) OpenFrame::Config(3)
105
107 James A. Duncan <jduncan@fotango.com>
108
109
110
111perl v5.8.8 2004-08-05 OpenFrame(3)