r29155 - in /branches/upstream/libnet-stomp-perl: ./ current/ current/lib/ current/lib/Net/ current/lib/Net/Stomp/ current/t/

maddingue-guest at users.alioth.debian.org maddingue-guest at users.alioth.debian.org
Sun Jan 4 01:55:42 UTC 2009


Author: maddingue-guest
Date: Sun Jan  4 01:55:33 2009
New Revision: 29155

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=29155
Log:
[svn-inject] Installing original source of libnet-stomp-perl

Added:
    branches/upstream/libnet-stomp-perl/
    branches/upstream/libnet-stomp-perl/current/
    branches/upstream/libnet-stomp-perl/current/Build.PL
    branches/upstream/libnet-stomp-perl/current/CHANGES
    branches/upstream/libnet-stomp-perl/current/MANIFEST
    branches/upstream/libnet-stomp-perl/current/META.yml
    branches/upstream/libnet-stomp-perl/current/Makefile.PL
    branches/upstream/libnet-stomp-perl/current/README
    branches/upstream/libnet-stomp-perl/current/lib/
    branches/upstream/libnet-stomp-perl/current/lib/Net/
    branches/upstream/libnet-stomp-perl/current/lib/Net/Stomp/
    branches/upstream/libnet-stomp-perl/current/lib/Net/Stomp.pm
    branches/upstream/libnet-stomp-perl/current/lib/Net/Stomp/Frame.pm
    branches/upstream/libnet-stomp-perl/current/t/
    branches/upstream/libnet-stomp-perl/current/t/pod.t
    branches/upstream/libnet-stomp-perl/current/t/pod_coverage.t

Added: branches/upstream/libnet-stomp-perl/current/Build.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-stomp-perl/current/Build.PL?rev=29155&op=file
==============================================================================
--- branches/upstream/libnet-stomp-perl/current/Build.PL (added)
+++ branches/upstream/libnet-stomp-perl/current/Build.PL Sun Jan  4 01:55:33 2009
@@ -1,0 +1,16 @@
+#!perl
+use Module::Build;
+use strict;
+use warnings;
+
+my $build = Module::Build->new(
+    create_makefile_pl => 'traditional',
+    license            => 'perl',
+    module_name        => 'Net::Stomp',
+    requires           => {
+        'IO::Socket::INET'      => '0',
+        'IO::Select'            => '0',
+        'Class::Accessor::Fast' => '0',
+    },
+);
+$build->create_build_script;

Added: branches/upstream/libnet-stomp-perl/current/CHANGES
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-stomp-perl/current/CHANGES?rev=29155&op=file
==============================================================================
--- branches/upstream/libnet-stomp-perl/current/CHANGES (added)
+++ branches/upstream/libnet-stomp-perl/current/CHANGES Sun Jan  4 01:55:33 2009
@@ -1,0 +1,33 @@
+Revision history for Perl module Net::Stomp:
+
+0.34 Fri Jun 27 09:29:13 BST 2008
+  - revert to 0.32's code, as the last release broke things that
+    I don't have time to fix right now 
+
+0.33 Wed Jun 25 08:45:59 BST 2008
+  - fixes from Paul Driver: can_read doesn't behave correctly. The 
+    docs say it returns true iff there's a frame waiting to be 
+    read, but it's just a select() call to see if there's data 
+    on the socket, which can return both false positives and
+    false negatives. While investigating this, I noticed that 
+    Net::Stomp::Frame->parse was modified at some point to take
+    a socket as its argument. This is inconsistent with docs and
+    probably not what was wanted anyway. parse and as_string 
+    should be symmetrical. Attached is a patch that fixes both 
+    issues and adds tests for them.
+
+0.32 Sun Oct 29 09:06:31 GMT 2006
+  - rewrote the parser to add support for BytesMessage, which should
+    allow Java<->Perl messages (thanks to Hiram Chirino and Sileshi
+    Kassa)
+  - set binmode() on the socket so Windows should now work (thanks
+    to Sileshi Kassa)
+
+0.31 Wed Oct 11 17:28:31 BST 2006
+  - minor docpatch noticed by Leo Lapworth
+  - tweak frame parser
+  - add unsubscribe() method
+  - add can_read() method
+
+0.30 Sat Oct  7 09:47:57 BST 2006
+  - initial release

Added: branches/upstream/libnet-stomp-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-stomp-perl/current/MANIFEST?rev=29155&op=file
==============================================================================
--- branches/upstream/libnet-stomp-perl/current/MANIFEST (added)
+++ branches/upstream/libnet-stomp-perl/current/MANIFEST Sun Jan  4 01:55:33 2009
@@ -1,0 +1,10 @@
+Build.PL
+CHANGES
+lib/Net/Stomp.pm
+lib/Net/Stomp/Frame.pm
+Makefile.PL
+MANIFEST			This list of files
+README
+t/pod.t
+t/pod_coverage.t
+META.yml

Added: branches/upstream/libnet-stomp-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-stomp-perl/current/META.yml?rev=29155&op=file
==============================================================================
--- branches/upstream/libnet-stomp-perl/current/META.yml (added)
+++ branches/upstream/libnet-stomp-perl/current/META.yml Sun Jan  4 01:55:33 2009
@@ -1,0 +1,23 @@
+---
+name: Net-Stomp
+version: 0.34
+author:
+  - Leon Brocard <acme at astray.com>.
+abstract: A Streaming Text Orientated Messaging Protocol Client
+license: perl
+resources:
+  license: http://dev.perl.org/licenses/
+requires:
+  Class::Accessor::Fast: 0
+  IO::Select: 0
+  IO::Socket::INET: 0
+provides:
+  Net::Stomp:
+    file: lib/Net/Stomp.pm
+    version: 0.34
+  Net::Stomp::Frame:
+    file: lib/Net/Stomp/Frame.pm
+generated_by: Module::Build version 0.280801
+meta-spec:
+  url: http://module-build.sourceforge.net/META-spec-v1.2.html
+  version: 1.2

Added: branches/upstream/libnet-stomp-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-stomp-perl/current/Makefile.PL?rev=29155&op=file
==============================================================================
--- branches/upstream/libnet-stomp-perl/current/Makefile.PL (added)
+++ branches/upstream/libnet-stomp-perl/current/Makefile.PL Sun Jan  4 01:55:33 2009
@@ -1,0 +1,16 @@
+# Note: this file was auto-generated by Module::Build::Compat version 0.2808_01
+use ExtUtils::MakeMaker;
+WriteMakefile
+(
+          'PL_FILES' => {},
+          'INSTALLDIRS' => 'site',
+          'NAME' => 'Net::Stomp',
+          'EXE_FILES' => [],
+          'VERSION_FROM' => 'lib/Net/Stomp.pm',
+          'PREREQ_PM' => {
+                           'IO::Select' => '0',
+                           'IO::Socket::INET' => '0',
+                           'Class::Accessor::Fast' => '0'
+                         }
+        )
+;

Added: branches/upstream/libnet-stomp-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-stomp-perl/current/README?rev=29155&op=file
==============================================================================
--- branches/upstream/libnet-stomp-perl/current/README (added)
+++ branches/upstream/libnet-stomp-perl/current/README Sun Jan  4 01:55:33 2009
@@ -1,0 +1,192 @@
+NAME
+    Net::Stomp - A Streaming Text Orientated Messaging Protocol Client
+
+SYNOPSIS
+      # send a message to the queue 'foo'
+      use Net::Stomp;
+      my $stomp = Net::Stomp->new( { hostname => 'localhost', port => '61613' } );
+      $stomp->connect( { login => 'hello', passcode => 'there' } );
+      $stomp->send(
+          { destination => '/queue/foo', body => 'test message' } );
+      $stomp->disconnect;
+
+      # subscribe to messages from the queue 'foo'
+      use Net::Stomp;
+      my $stomp = Net::Stomp->new( { hostname => 'localhost', port => '61613' } );
+      $stomp->connect( { login => 'hello', passcode => 'there' } );
+      $stomp->subscribe(
+          {   destination             => '/queue/foo',
+              'ack'                   => 'client',
+              'activemq.prefetchSize' => 1
+          }
+      );
+      while (1) {
+        my $frame = $stomp->receive_frame;
+        warn $frame->body; # do something here
+        $stomp->ack( { frame => $frame } );
+      }
+      $stomp->disconnect;
+
+      # write your own frame
+       my $frame = Net::Stomp::Frame->new(
+           { command => $command, headers => $conf, body => $body } );
+      $self->send_frame($frame);
+
+DESCRIPTION
+    This module allows you to write a Stomp client. Stomp is the Streaming
+    Text Orientated Messaging Protocol (or the Protocol Briefly Known as
+    TTMP and Represented by the symbol :ttmp). It's a simple and easy to
+    implement protocol for working with Message Orientated Middleware from
+    any language. Net::Stomp is useful for talking to Apache ActiveMQ, an
+    open source (Apache 2.0 licensed) Java Message Service 1.1 (JMS) message
+    broker packed with many enterprise features.
+
+    A Stomp frame consists of a command, a series of headers and a body -
+    see Net::Stomp::Frame for more details.
+
+    For details on the protocol see <http://stomp.codehaus.org/Protocol>.
+
+    To enable the ActiveMQ Broker for Stomp add the following to the
+    activemq.xml configuration:
+
+      <connector>
+          <serverTransport uri="stomp://localhost:61613"/>
+      </connector>
+
+    For details on Stomp in ActiveMQ See
+    <http://www.activemq.org/site/stomp.html>.
+
+METHODS
+  new
+    The constructor creates a new object. You must pass in a hostname and a
+    port:
+
+      my $stomp = Net::Stomp->new( { hostname => 'localhost', port => '61613' } );
+
+  connect
+    This connects to the Stomp server. You must pass in a login and
+    passcode.
+
+    You may pass in 'client-id', which specifies the JMS Client ID which is
+    used in combination to the activemqq.subscriptionName to denote a
+    durable subscriber.
+
+      $stomp->connect( { login => 'hello', passcode => 'there' } );
+
+  send
+    This sends a message to a queue or topic. You must pass in a destination
+    and a body.
+
+      $stomp->send(
+          { destination => '/queue/foo', body => 'test message' } );
+
+    To send a BytesMessage, you should set the field 'bytes_message' to 1.
+
+  disconnect
+    This disconnects from the Stomp server:
+
+      $stomp->disconnect;
+
+  subscribe
+    This subscribes you to a queue or topic. You must pass in a destination.
+
+    The acknowledge mode defaults to 'auto', which means that frames will be
+    considered delivered after they have been sent to a client. The other
+    option is 'client', which means that messages will only be considered
+    delivered after the client specifically acknowledges them with an ACK
+    frame.
+
+    Other options:
+
+    'selector': which specifies a JMS Selector using SQL 92 syntax as
+    specified in the JMS 1.1 specificiation. This allows a filter to be
+    applied to each message as part of the subscription.
+
+    'activemq.dispatchAsync': should messages be dispatched synchronously or
+    asynchronously from the producer thread for non-durable topics in the
+    broker. For fast consumers set this to false. For slow consumers set it
+    to true so that dispatching will not block fast consumers.
+
+    'activemq.exclusive': Would I like to be an Exclusive Consumer on a
+    queue.
+
+    'activemq.maximumPendingMessageLimit': For Slow Consumer Handlingon
+    non-durable topics by dropping old messages - we can set a maximum
+    pending limit which once a slow consumer backs up to this high water
+    mark we begin to discard old messages.
+
+    'activemq.noLocal': Specifies whether or not locally sent messages
+    should be ignored for subscriptions. Set to true to filter out locally
+    sent messages.
+
+    'activemq.prefetchSize': Specifies the maximum number of pending
+    messages that will be dispatched to the client. Once this maximum is
+    reached no more messages are dispatched until the client acknowledges a
+    message. Set to 1 for very fair distribution of messages across
+    consumers where processing messages can be slow.
+
+    'activemq.priority': Sets the priority of the consumer so that
+    dispatching can be weighted in priority order.
+
+    'activemq.retroactive': For non-durable topics do you wish this
+    subscription to the retroactive.
+
+    'activemq.subscriptionName': For durable topic subscriptions you must
+    specify the same clientId on the connection and subscriberName on the
+    subscribe.
+
+      $stomp->subscribe(
+          {   destination             => '/queue/foo',
+              'ack'                   => 'client',
+              'activemq.prefetchSize' => 1
+          }
+      );
+
+  unsubscribe
+    This unsubscribes you to a queue or topic. You must pass in a
+    destination:
+
+      $stomp->unsubcribe({ destination => '/queue/foo' });
+
+  receive_frame
+    This blocks and returns you the next Stomp frame.
+
+      my $frame = $stomp->receive_frame;
+      warn $frame->body; # do something here
+
+    The header bytes_message is 1 if the message was a BytesMessage.
+
+  can_read
+    This returns whether a frame is waiting to be read. Optionally takes a
+    timeout in seconds:
+
+      my $can_read = $stomp->can_read;
+      my $can_read = $stomp->can_read({ timeout => '0.1' });
+
+  ack
+    This acknowledges that you have received and processed a frame (if you
+    are using client acknowledgements):
+
+      $stomp->ack( { frame => $frame } );
+
+  send_frame
+    If this module does not provide enough help for sending frames, you may
+    construct your own frame and send it:
+
+      # write your own frame
+      my $frame = Net::Stomp::Frame->new(
+           { command => $command, headers => $conf, body => $body } );
+      $self->send_frame($frame);
+
+SEE ALSO
+    Net::Stomp::Frame.
+
+AUTHOR
+    Leon Brocard <acme at astray.com>.
+
+COPYRIGHT
+    Copyright (C) 2006, Leon Brocard
+
+    This module is free software; you can redistribute it or modify it under
+    the same terms as Perl itself.
+

Added: branches/upstream/libnet-stomp-perl/current/lib/Net/Stomp.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-stomp-perl/current/lib/Net/Stomp.pm?rev=29155&op=file
==============================================================================
--- branches/upstream/libnet-stomp-perl/current/lib/Net/Stomp.pm (added)
+++ branches/upstream/libnet-stomp-perl/current/lib/Net/Stomp.pm Sun Jan  4 01:55:33 2009
@@ -1,0 +1,308 @@
+package Net::Stomp;
+use strict;
+use warnings;
+use IO::Socket::INET;
+use IO::Select;
+use Net::Stomp::Frame;
+use base 'Class::Accessor::Fast';
+__PACKAGE__->mk_accessors(qw(hostname port select socket));
+our $VERSION = '0.34';
+
+sub new {
+    my $class  = shift;
+    my $self   = $class->SUPER::new(@_);
+    my $socket = IO::Socket::INET->new(
+        PeerAddr => $self->hostname,
+        PeerPort => $self->port,
+        Proto    => 'tcp'
+    );
+    die "Error connecting to " . $self->hostname . ':' . $self->port . ": $!"
+        unless $socket;
+    binmode($socket);
+    $self->socket($socket);
+    my $select = IO::Select->new();
+    $select->add($socket);
+    $self->select($select);
+
+    return $self;
+}
+
+sub connect {
+    my ( $self, $conf ) = @_;
+    my $frame = Net::Stomp::Frame->new(
+        { command => 'CONNECT', headers => $conf } );
+    $self->send_frame($frame);
+    $frame = $self->receive_frame;
+    return $frame;
+}
+
+sub disconnect {
+    my $self = shift;
+    my $frame = Net::Stomp::Frame->new( { command => 'DISCONNECT', } );
+    $self->send_frame($frame);
+    $self->socket->close;
+}
+
+sub can_read {
+    my ( $self, $conf ) = @_;
+    my $timeout = $conf->{timeout} || 0;
+    return $self->select->can_read($timeout) || 0;
+}
+
+sub send {
+    my ( $self, $conf ) = @_;
+    my $body = $conf->{body};
+    delete $conf->{body};
+    my $frame = Net::Stomp::Frame->new(
+        { command => 'SEND', headers => $conf, body => $body } );
+    $self->send_frame($frame);
+}
+
+sub subscribe {
+    my ( $self, $conf ) = @_;
+    my $frame = Net::Stomp::Frame->new(
+        { command => 'SUBSCRIBE', headers => $conf } );
+    $self->send_frame($frame);
+}
+
+sub unsubscribe {
+    my ( $self, $conf ) = @_;
+    my $frame = Net::Stomp::Frame->new(
+        { command => 'UNSUBSCRIBE', headers => $conf } );
+    $self->send_frame($frame);
+}
+
+sub ack {
+    my ( $self, $conf ) = @_;
+    my $id    = $conf->{frame}->headers->{'message-id'};
+    my $frame = Net::Stomp::Frame->new(
+        { command => 'ACK', headers => { 'message-id' => $id } } );
+    $self->send_frame($frame);
+}
+
+sub send_frame {
+    my ( $self, $frame ) = @_;
+
+    #     warn "send [" . $frame->as_string . "]\n";
+    $self->socket->print( $frame->as_string );
+}
+
+sub receive_frame {
+    my $self = shift;
+
+    my $frame = Net::Stomp::Frame->parse( $self->socket );
+
+    #     warn "receive [" . $frame->as_string . "]\n";
+    return $frame;
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+Net::Stomp - A Streaming Text Orientated Messaging Protocol Client
+
+=head1 SYNOPSIS
+
+  # send a message to the queue 'foo'
+  use Net::Stomp;
+  my $stomp = Net::Stomp->new( { hostname => 'localhost', port => '61613' } );
+  $stomp->connect( { login => 'hello', passcode => 'there' } );
+  $stomp->send(
+      { destination => '/queue/foo', body => 'test message' } );
+  $stomp->disconnect;
+
+  # subscribe to messages from the queue 'foo'
+  use Net::Stomp;
+  my $stomp = Net::Stomp->new( { hostname => 'localhost', port => '61613' } );
+  $stomp->connect( { login => 'hello', passcode => 'there' } );
+  $stomp->subscribe(
+      {   destination             => '/queue/foo',
+          'ack'                   => 'client',
+          'activemq.prefetchSize' => 1
+      }
+  );
+  while (1) {
+    my $frame = $stomp->receive_frame;
+    warn $frame->body; # do something here
+    $stomp->ack( { frame => $frame } );
+  }
+  $stomp->disconnect;
+
+  # write your own frame
+   my $frame = Net::Stomp::Frame->new(
+       { command => $command, headers => $conf, body => $body } );
+  $self->send_frame($frame);
+
+=head1 DESCRIPTION
+
+This module allows you to write a Stomp client. Stomp is the Streaming
+Text Orientated Messaging Protocol (or the Protocol Briefly Known as
+TTMP and Represented by the symbol :ttmp). It's a simple and easy to
+implement protocol for working with Message Orientated Middleware from
+any language. L<Net::Stomp> is useful for talking to Apache ActiveMQ,
+an open source (Apache 2.0 licensed) Java Message Service 1.1 (JMS)
+message broker packed with many enterprise features.
+
+A Stomp frame consists of a command, a series of headers and a body -
+see L<Net::Stomp::Frame> for more details.
+
+For details on the protocol see L<http://stomp.codehaus.org/Protocol>.
+
+To enable the ActiveMQ Broker for Stomp add the following to the
+activemq.xml configuration:
+
+  <connector>
+      <serverTransport uri="stomp://localhost:61613"/>
+  </connector>
+
+For details on Stomp in ActiveMQ See L<http://www.activemq.org/site/stomp.html>.
+
+=head1 METHODS
+
+=head2 new
+
+The constructor creates a new object. You must pass in a hostname and
+a port:
+
+  my $stomp = Net::Stomp->new( { hostname => 'localhost', port => '61613' } );
+
+=head2 connect
+
+This connects to the Stomp server. You must pass in a login and
+passcode.
+
+You may pass in 'client-id', which specifies the JMS Client ID which
+is used in combination to the activemqq.subscriptionName to denote a
+durable subscriber.
+  
+  $stomp->connect( { login => 'hello', passcode => 'there' } );
+
+=head2 send
+
+This sends a message to a queue or topic. You must pass in a destination and a body.
+
+  $stomp->send(
+      { destination => '/queue/foo', body => 'test message' } );
+
+To send a BytesMessage, you should set the field 'bytes_message' to 1.
+
+=head2 disconnect
+
+This disconnects from the Stomp server:
+
+  $stomp->disconnect;
+
+=head2 subscribe
+
+This subscribes you to a queue or topic. You must pass in a destination.
+
+The acknowledge mode defaults to 'auto', which means that frames will
+be considered delivered after they have been sent to a client. The
+other option is 'client', which means that messages will only be
+considered delivered after the client specifically acknowledges them
+with an ACK frame.
+
+Other options:
+
+'selector': which specifies a JMS Selector using SQL
+92 syntax as specified in the JMS 1.1 specificiation. This allows a
+filter to be applied to each message as part of the subscription.
+
+'activemq.dispatchAsync': should messages be dispatched synchronously
+or asynchronously from the producer thread for non-durable topics in
+the broker. For fast consumers set this to false. For slow consumers
+set it to true so that dispatching will not block fast consumers.
+
+'activemq.exclusive': Would I like to be an Exclusive Consumer on a queue.
+
+'activemq.maximumPendingMessageLimit': For Slow Consumer Handlingon
+non-durable topics by dropping old messages - we can set a maximum
+pending limit which once a slow consumer backs up to this high water
+mark we begin to discard old messages.
+ 
+'activemq.noLocal': Specifies whether or not locally sent messages
+should be ignored for subscriptions. Set to true to filter out locally
+sent messages.
+ 
+'activemq.prefetchSize': Specifies the maximum number of pending
+messages that will be dispatched to the client. Once this maximum is
+reached no more messages are dispatched until the client acknowledges
+a message. Set to 1 for very fair distribution of messages across
+consumers where processing messages can be slow.
+ 
+'activemq.priority': Sets the priority of the consumer so that
+dispatching can be weighted in priority order.
+
+'activemq.retroactive': For non-durable topics do you wish this
+subscription to the retroactive.
+
+'activemq.subscriptionName': For durable topic subscriptions you must
+specify the same clientId on the connection and subscriberName on the
+subscribe.
+
+  $stomp->subscribe(
+      {   destination             => '/queue/foo',
+          'ack'                   => 'client',
+          'activemq.prefetchSize' => 1
+      }
+  );
+
+=head2 unsubscribe
+
+This unsubscribes you to a queue or topic. You must pass in a destination:
+
+  $stomp->unsubcribe({ destination => '/queue/foo' });
+
+=head2 receive_frame
+
+This blocks and returns you the next Stomp frame. 
+
+  my $frame = $stomp->receive_frame;
+  warn $frame->body; # do something here
+
+The header bytes_message is 1 if the message was a BytesMessage.
+
+=head2 can_read
+
+This returns whether a frame is waiting to be read. Optionally takes a
+timeout in seconds:
+
+  my $can_read = $stomp->can_read;
+  my $can_read = $stomp->can_read({ timeout => '0.1' });
+
+
+=head2 ack
+
+This acknowledges that you have received and processed a frame (if you
+are using client acknowledgements):
+
+  $stomp->ack( { frame => $frame } );
+
+=head2 send_frame
+
+If this module does not provide enough help for sending frames, you
+may construct your own frame and send it:
+
+  # write your own frame
+  my $frame = Net::Stomp::Frame->new(
+       { command => $command, headers => $conf, body => $body } );
+  $self->send_frame($frame);
+
+=head1 SEE ALSO
+
+L<Net::Stomp::Frame>.
+
+=head1 AUTHOR
+
+Leon Brocard <acme at astray.com>.
+
+=head1 COPYRIGHT
+
+Copyright (C) 2006, Leon Brocard
+
+This module is free software; you can redistribute it or modify it
+under the same terms as Perl itself.
+

Added: branches/upstream/libnet-stomp-perl/current/lib/Net/Stomp/Frame.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-stomp-perl/current/lib/Net/Stomp/Frame.pm?rev=29155&op=file
==============================================================================
--- branches/upstream/libnet-stomp-perl/current/lib/Net/Stomp/Frame.pm (added)
+++ branches/upstream/libnet-stomp-perl/current/lib/Net/Stomp/Frame.pm Sun Jan  4 01:55:33 2009
@@ -1,0 +1,144 @@
+package Net::Stomp::Frame;
+use strict;
+use warnings;
+use base 'Class::Accessor::Fast';
+__PACKAGE__->mk_accessors(qw(command headers body));
+
+sub as_string {
+    my $self    = shift;
+    my $command = $self->command;
+    my $headers = $self->headers;
+    my $body    = $self->body;
+    my $frame   = $command . "\n";
+
+    # insert a content-length header
+    my $bytes_message = 0;
+    if ( $headers->{bytes_message} ) {
+        $bytes_message = 1;
+        delete $headers->{bytes_message};
+        $headers->{"content-length"} = length( $self->body );
+    }
+
+    while ( my ( $key, $value ) = each %{ $headers || {} } ) {
+        $frame .= $key . ':' . $value . "\n";
+    }
+    $frame .= "\n";
+    $frame .= $body || '';
+    $frame .= "\000";
+}
+
+sub parse {
+    my ( $package, $socket ) = @_;
+    local $/ = "\n";
+
+    # read the command
+    my $command;
+    while (1) {
+        $command = $socket->getline || die "Error reading command: $!";
+        chop $command;
+        last if $command;
+    }
+
+    # read headers
+    my $headers;
+    while (1) {
+        my $line = $socket->getline || die "Error reading header: $!";
+        chop $line;
+        last if $line eq "";
+        my ( $key, $value ) = split /: ?/, $line, 2;
+        $headers->{$key} = $value;
+    }
+
+    # read the body
+    my $body;
+    if ( $headers->{"content-length"} ) {
+        $socket->read( $body, $headers->{"content-length"} )
+            || die "Error reading body: $!";
+        $socket->getc;    # eat the trailing null
+        $headers->{bytes_message} = 1;
+    } else {
+        while (1) {
+            my $byte = $socket->getc;
+            die "Error reading body: $!" unless defined $byte;
+            last if $byte eq "\000";
+            $body .= $byte;
+        }
+    }
+
+    my $frame = Net::Stomp::Frame->new(
+        { command => $command, headers => $headers, body => $body } );
+    return $frame;
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+Net::Stomp::Frame - A STOMP Frame
+
+=head1 SYNOPSIS
+
+  use Net::Stomp::Frame;
+  my $frame = Net::Stomp::Frame->new( {
+    command => $command,
+    headers => $headers,
+    body    => $body,
+  } );
+  my $frame  = Net::Stomp::Frame->parse($string);
+  my $string = $frame->as_string;
+  
+=head1 DESCRIPTION
+
+This module encapulates a Stomp frame. Stomp is the Streaming Text
+Orientated Messaging Protocol (or the Protocol Briefly Known as TTMP
+and Represented by the symbol :ttmp). It's a simple and easy to
+implement protocol for working with Message Orientated Middleware from
+any language. L<Net::Stomp> is useful for talking to Apache
+ActiveMQ, an open source (Apache 2.0 licensed) Java Message Service
+1.1 (JMS) message broker packed with many enterprise features.
+
+A Stomp frame consists of a command, a series of headers and a body.
+
+For details on the protocol see L<http://stomp.codehaus.org/Protocol>.
+
+=head1 METHODS
+
+=head2 new
+
+Create a new L<Net::Stomp::Frame> object:
+
+  my $frame = Net::Stomp::Frame->new( {
+    command => $command,
+    headers => $headers,
+    body    => $body,
+  } );
+
+=head2 parse
+
+Create a new L<Net::Somp::Frame> given a string containing the serialised frame:
+
+  my $frame  = Net::Stomp::Frame->parse($string);
+
+=head2 as_string
+
+Create a string containing the serialised frame representing the frame:
+
+  my $string = $frame->as_string;
+
+=head1 SEE ALSO
+
+L<Net::Stomp>.
+
+=head1 AUTHOR
+
+Leon Brocard <acme at astray.com>.
+
+=head1 COPYRIGHT
+
+Copyright (C) 2006, Leon Brocard
+
+This module is free software; you can redistribute it or modify it
+under the same terms as Perl itself.
+

Added: branches/upstream/libnet-stomp-perl/current/t/pod.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-stomp-perl/current/t/pod.t?rev=29155&op=file
==============================================================================
--- branches/upstream/libnet-stomp-perl/current/t/pod.t (added)
+++ branches/upstream/libnet-stomp-perl/current/t/pod.t Sun Jan  4 01:55:33 2009
@@ -1,0 +1,6 @@
+#!perl -T
+
+use Test::More;
+eval "use Test::Pod 1.14";
+plan skip_all => "Test::Pod 1.14 required for testing POD" if $@;
+all_pod_files_ok();

Added: branches/upstream/libnet-stomp-perl/current/t/pod_coverage.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-stomp-perl/current/t/pod_coverage.t?rev=29155&op=file
==============================================================================
--- branches/upstream/libnet-stomp-perl/current/t/pod_coverage.t (added)
+++ branches/upstream/libnet-stomp-perl/current/t/pod_coverage.t Sun Jan  4 01:55:33 2009
@@ -1,0 +1,6 @@
+#!perl -T
+
+use Test::More;
+eval "use Test::Pod::Coverage 1.04";
+plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" if $@;
+all_pod_coverage_ok();




More information about the Pkg-perl-cvs-commits mailing list