You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by mc...@apache.org on 2013/09/06 16:10:49 UTC
svn commit: r1520574 - in /qpid/proton/trunk:
examples/messenger/perl/recv.pl examples/messenger/perl/send.pl
proton-c/bindings/perl/ChangeLog
proton-c/bindings/perl/lib/qpid/proton/Message.pm
Author: mcpierce
Date: Fri Sep 6 14:10:49 2013
New Revision: 1520574
URL: http://svn.apache.org/r1520574
Log:
PROTON-383: Adds annotations to the Perl Message class.
Modified:
qpid/proton/trunk/examples/messenger/perl/recv.pl
qpid/proton/trunk/examples/messenger/perl/send.pl
qpid/proton/trunk/proton-c/bindings/perl/ChangeLog
qpid/proton/trunk/proton-c/bindings/perl/lib/qpid/proton/Message.pm
Modified: qpid/proton/trunk/examples/messenger/perl/recv.pl
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/examples/messenger/perl/recv.pl?rev=1520574&r1=1520573&r2=1520574&view=diff
==============================================================================
--- qpid/proton/trunk/examples/messenger/perl/recv.pl (original)
+++ qpid/proton/trunk/examples/messenger/perl/recv.pl Fri Sep 6 14:10:49 2013
@@ -57,6 +57,11 @@ for(;;)
foreach (keys $props) {
print "\t$_=$props->{$_}\n";
}
+ print "Annotations:\n";
+ my $annotations = $msg->get_annotations();
+ foreach (keys $annotations) {
+ print "\t$_=" . $annotations->{$_} . "\n";
+ }
}
}
Modified: qpid/proton/trunk/examples/messenger/perl/send.pl
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/examples/messenger/perl/send.pl?rev=1520574&r1=1520573&r2=1520574&view=diff
==============================================================================
--- qpid/proton/trunk/examples/messenger/perl/send.pl (original)
+++ qpid/proton/trunk/examples/messenger/perl/send.pl Fri Sep 6 14:10:49 2013
@@ -51,6 +51,9 @@ foreach (@messages)
# try a few different body types
my $body_type = int(rand(4));
$msg->set_property("sent", "" . localtime(time));
+ $msg->get_annotations->{"version"} = 1.0;
+ $msg->get_annotations->{"pill"} = "RED";
+
SWITCH: {
$body_type == 0 && do { $msg->set_body("It is now " . localtime(time));};
$body_type == 1 && do { $msg->set_body(rand(65536), qpid::proton::FLOAT); };
Modified: qpid/proton/trunk/proton-c/bindings/perl/ChangeLog
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/bindings/perl/ChangeLog?rev=1520574&r1=1520573&r2=1520574&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/bindings/perl/ChangeLog (original)
+++ qpid/proton/trunk/proton-c/bindings/perl/ChangeLog Fri Sep 6 14:10:49 2013
@@ -3,6 +3,7 @@ version 0.6:
* qpid::proton::Messenger returns outgoing tracker on put.
* qpid::proton::Message exposes the body property.
* qpid::proton::Message exposes the properties property.
+ * qpid::proton::Message exports the annotations property.
version 0.5:
* Added the qpid::proton::Data type.
Modified: qpid/proton/trunk/proton-c/bindings/perl/lib/qpid/proton/Message.pm
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/bindings/perl/lib/qpid/proton/Message.pm?rev=1520574&r1=1520573&r2=1520574&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/bindings/perl/lib/qpid/proton/Message.pm (original)
+++ qpid/proton/trunk/proton-c/bindings/perl/lib/qpid/proton/Message.pm Fri Sep 6 14:10:49 2013
@@ -31,6 +31,7 @@ sub new {
my $impl = cproton_perl::pn_message();
$self->{_impl} = $impl;
$self->{_properties} = {};
+ $self->{_annotations} = {};
$self->{_body} = undef;
$self->{_body_type} = undef;
@@ -369,6 +370,37 @@ sub set_property {
=pod
+=head2 ANNOTATIONS
+
+Allows for accessing and updatin ghte set of annotations associated with the
+message.
+
+=over
+
+=item my $annotations = $msg->get_annotations;
+
+=item $msg->get_annotations->{ [KEY] } = [VALUE];
+
+=item $msg->set_annotations( [VALUE ]);
+
+=back
+
+=cut
+
+sub get_annotations {
+ my ($self) = @_;
+ return $self->{_annotations};
+}
+
+sub set_annotations {
+ my ($self) = @_;
+ my $annotations = $_[1];
+
+ $self->{_annotations} = $annotations;
+}
+
+=pod
+
=head2 BODY
The body of the message. When setting the body value a type must be specified,
@@ -412,18 +444,22 @@ sub get_body_type {
sub preencode() {
my ($self) = @_;
my $impl = $self->{_impl};
+
my $my_body = $self->{_body};
my $body_type = $self->{_body_type};
-
my $body = new qpid::proton::Data(cproton_perl::pn_message_body($impl));
$body->clear();
$body_type->put($body, $my_body) if($my_body && $body_type);
my $my_props = $self->{_properties};
-
my $props = new qpid::proton::Data(cproton_perl::pn_message_properties($impl));
$props->clear();
qpid::proton::MAP->put($props, $my_props) if $my_props;
+
+ my $my_annots = $self->{_annotations};
+ my $annotations = new qpid::proton::Data(cproton_perl::pn_message_annotations($impl));
+ $annotations->clear();
+ qpid::proton::MAP->put($annotations, $my_annots);
}
sub postdecode() {
@@ -439,12 +475,20 @@ sub postdecode() {
}
my $props = new qpid::proton::Data(cproton_perl::pn_message_properties($impl));
-
$props->rewind;
if ($props->next) {
my $properties = $props->get_type->get($props);
$self->{_properties} = $props->get_type->get($props);
}
+
+ my $annotations = new qpid::proton::Data(cproton_perl::pn_message_annotations($impl));
+ $annotations->rewind;
+ if ($annotations->next) {
+ my $annots = $annotations->get_type->get($annotations);
+ $self->{_annotations} = $annots;
+ } else {
+ $self->{_annotations} = {};
+ }
}
1;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org