[Pkg-corba-commits] r200 - in /trunk/omnievents: debian/ etc/ etc/init.d/ examples/ tools/

tgg at users.alioth.debian.org tgg at users.alioth.debian.org
Fri Dec 25 19:19:31 UTC 2009


Author: tgg
Date: Fri Dec 25 19:19:31 2009
New Revision: 200

URL: http://svn.debian.org/wsvn/pkg-corba/?sc=1&rev=200
Log:
Commit pending work. It will require merging with NMU.

Added:
    trunk/omnievents/debian/omnievents.postinst
    trunk/omnievents/etc/
    trunk/omnievents/etc/init.d/
    trunk/omnievents/etc/init.d/omniorb-eventservice.in   (with props)
    trunk/omnievents/examples/
    trunk/omnievents/examples/pullcons.cc
    trunk/omnievents/examples/pullsupp.cc
    trunk/omnievents/examples/pushcons.cc
    trunk/omnievents/examples/pushsupp.cc
    trunk/omnievents/tools/
    trunk/omnievents/tools/eventc.cc
    trunk/omnievents/tools/eventf.cc
    trunk/omnievents/tools/rmeventc.cc
Modified:
    trunk/omnievents/debian/changelog
    trunk/omnievents/debian/control

Modified: trunk/omnievents/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-corba/trunk/omnievents/debian/changelog?rev=200&op=diff
==============================================================================
--- trunk/omnievents/debian/changelog (original)
+++ trunk/omnievents/debian/changelog Fri Dec 25 19:19:31 2009
@@ -5,8 +5,29 @@
 
   [ Thomas Girard ]
   * Add watch file.
+  * Fix typo in omnievents package description. Thanks to Pascal De Vuyst
+    for the report. Closes: #557829.
+  * Integrate NMU patch for #541249. Thanks to Petter Reinholdtsen for the
+    NMU. Closes: #547545, #541249.
+  * Fix FTBFS with g++ 4.4. Thanks to Martin Michlmayr for the report and
+    the patch. Closes: #504864.
+  * Bump Standards-Version: to 3.8.3.
+  * Switch debhelper level to 7.
+  * Add ${misc:Depends} where appropriate.
 
- -- Thomas Girard <thomas.g.girard at free.fr>  Sat, 24 May 2008 18:41:33 +0200
+ -- Thomas Girard <thomas.g.girard at free.fr>  Sun, 20 Dec 2009 17:32:39 +0100
+
+omnievents (1:2.6.2-1.1) unstable; urgency=low
+
+  * Non-maintainer upload to fix release goal.
+  * Correct init.d script header runlevel list and dependencies.  Add code
+    in postinst to recover systems affected by the bug (Closes: #541249).
+  * Correct section for libomnievents-dbg to 'debug', based on tip from
+    lintian.
+  * Add code to clean target of debian/rules to remove generated
+    config.log and config.status, based on tip from lintian.
+
+ -- Petter Reinholdtsen <pere at debian.org>  Sun, 20 Sep 2009 17:00:14 +0200
 
 omnievents (1:2.6.2-1) unstable; urgency=low
 

Modified: trunk/omnievents/debian/control
URL: http://svn.debian.org/wsvn/pkg-corba/trunk/omnievents/debian/control?rev=200&op=diff
==============================================================================
--- trunk/omnievents/debian/control (original)
+++ trunk/omnievents/debian/control Fri Dec 25 19:19:31 2009
@@ -3,8 +3,8 @@
 Priority: optional
 Maintainer: Debian CORBA Team <pkg-corba-devel at lists.alioth.debian.org>
 Uploaders: W. Borgert <debacle at debian.org>, Thomas Girard <thomas.g.girard at free.fr>
-Build-Depends: debhelper (>> 5), cdbs, libomniorb4-dev (>= 4.1.1), pkg-config, omniidl, libcos4-dev (>= 4.1.1), omniorb-idl, doxygen, graphviz, xsltproc, docbook-xsl, autotools-dev
-Standards-Version: 3.7.3
+Build-Depends: debhelper (>= 7), cdbs, libomniorb4-dev (>= 4.1.1), pkg-config, omniidl, libcos4-dev (>= 4.1.1), omniorb-idl, doxygen, graphviz, xsltproc, docbook-xsl, autotools-dev
+Standards-Version: 3.8.3
 Homepage: http://www.omnievents.org
 Vcs-Svn: svn://svn.debian.org/svn/pkg-corba/trunk/omnievents
 Vcs-Browser: http://svn.debian.org/wsvn/pkg-corba/trunk/omnievents
@@ -19,7 +19,7 @@
  is a small, efficient implementation of the Object Management Group's
  Event Service specification designed to work with omniORB.
  .
- This packages contains the CORBA Event Service daemon as a standalone
+ This package contains the CORBA Event Service daemon as a standalone
  executable, and the associated tools.
 
 Package: libomnievents2
@@ -36,7 +36,7 @@
 Package: libomnievents-dev
 Architecture: any
 Section: libdevel
-Depends: libomnievents2 (= ${binary:Version})
+Depends: libomnievents2 (= ${binary:Version}), ${misc:Depends}
 Recommends: pkg-config
 Suggests: omnievents-doc
 Description: omniORB event service development files
@@ -48,6 +48,7 @@
 Package: omnievents-doc
 Architecture: all
 Section: doc
+Depends: ${misc:Depends}
 Description: omniORB event service documentation
  This package contains omniEvents manual and doxygen generated documentation.
  .
@@ -55,9 +56,9 @@
 
 Package: libomnievents-dbg
 Architecture: any
-Section: libdevel
+Section: debug
 Priority: extra
-Depends: libomnievents2 (= ${binary:Version})
+Depends: libomnievents2 (= ${binary:Version}), ${misc:Depends}
 Description: omniORB event service debugging symbols
  This package contains omniEvents debugging symbols.
  .

Added: trunk/omnievents/debian/omnievents.postinst
URL: http://svn.debian.org/wsvn/pkg-corba/trunk/omnievents/debian/omnievents.postinst?rev=200&op=file
==============================================================================
--- trunk/omnievents/debian/omnievents.postinst (added)
+++ trunk/omnievents/debian/omnievents.postinst Fri Dec 25 19:19:31 2009
@@ -1,0 +1,14 @@
+#!/bin/sh
+
+set -e
+
+# Those using dependency based boot sequencing with sysv-rc and
+# installing omniorb-eventservice using version 1:2.6.2-1 and earlier
+# would have the wrong runlevel symlinks.  Recover from this.
+if [ "$1" = "configure" ] && dpkg --compare-versions "$2" le "1:2.6.2-1" \
+    && [ -f /etc/rc3.d/S[0-9][0-9]omniorb-eventservice ] && [ ! -f /etc/rc2.d/S[0-9][0-9]omniorb-eventservice ]
+then
+    update-rc.d -f omniorb-eventservice remove
+fi
+
+#DEBHELPER#

Added: trunk/omnievents/etc/init.d/omniorb-eventservice.in
URL: http://svn.debian.org/wsvn/pkg-corba/trunk/omnievents/etc/init.d/omniorb-eventservice.in?rev=200&op=file
==============================================================================
--- trunk/omnievents/etc/init.d/omniorb-eventservice.in (added)
+++ trunk/omnievents/etc/init.d/omniorb-eventservice.in Fri Dec 25 19:19:31 2009
@@ -1,0 +1,115 @@
+#! /bin/sh
+
+#                            Package   : omniEvents
+# omniorb-eventservice       Created   : 2004/07/11
+#                            Author    : Alex Tingle
+#   This file is part of the omniEvents application, most of which is licensed
+#   under the Lesser GPL. This file ONLY is hereby released into the public
+#   domain by Alex Tingle (2004/07/11).
+
+#
+# This SysV init script is LSB 1.3 compliant.
+# It should work fine on any SysV system.
+#
+
+### BEGIN INIT INFO
+# Provides: omniorb-eventservice
+# Required-Start: $network $remote_fs $syslog
+# Required-Stop:  $network $remote_fs $syslog
+# Default-Start:  2 3 4 5
+# Default-Stop:   0 1 6
+# Short-Description: CORBA event service
+# Description: CORBA event service. http://www.omnievents.org/
+### END INIT INFO
+
+# ---------------------- the real stuff starts here----------------------------
+
+# You might want to tweak the location of the configuration file:
+CONFIGFILE=@SYSCONFIG_DIR@/omniorb-eventservice
+
+PATH=/sbin:/bin:/usr/sbin:/usr/bin
+DAEMON=@prefix@/sbin/omniEvents
+NAME=omniEvents
+DESC="CORBA event service"
+
+test -f $DAEMON || exit 5
+
+#
+# Default parameters. Don't change these here. Change them by setting them in
+# file $CONFIGFILE
+test -z "$OMNIEVENTS_LOGDIR"  && OMNIEVENTS_LOGDIR=/var/lib/omniEvents
+test -z "$OMNIEVENTS_PORT"    && OMNIEVENTS_PORT=11169
+OMNIEVENTS_PIDFILE=/var/run/$NAME.pid
+
+# Load default preferences
+test -f $CONFIGFILE && . $CONFIGFILE
+
+# Calculate OPT_ALTERNATE & OPT_NS_NAME
+test -n "$OMNIEVENTS_ALTERNATE" && OPT_ALTERNATE="-a $OMNIEVENTS_ALTERNATE"
+test -n "$OMNIEVENTS_NS_NAME"   && OPT_NS_NAME="-N $OMNIEVENTS_NS_NAME"
+
+startOE() {
+  test -d $OMNIEVENTS_LOGDIR || mkdir -p $OMNIEVENTS_LOGDIR
+  printf "Starting $DESC on port $OMNIEVENTS_PORT: "
+  $DAEMON $OMNIEVENTS_OPTIONS -P $OMNIEVENTS_PIDFILE -l $OMNIEVENTS_LOGDIR \
+    -p $OMNIEVENTS_PORT $OPT_ALTERNATE $OPT_NS_NAME
+  echo "$NAME."
+}
+
+# If omniEvents is running, then send it SIGTERM and wait for
+# up to 6 seconds for it to delete its PID file.
+stopOE() {
+  if [ -f $OMNIEVENTS_PIDFILE ] ; then
+    printf "Stopping $DESC: "
+    kill `cat $OMNIEVENTS_PIDFILE` || rm -f $OMNIEVENTS_PIDFILE 2>/dev/null
+    t=0
+    while test -f $OMNIEVENTS_PIDFILE -a $t -lt 6 ; do
+      sleep 1
+      t=`expr $t + 1`
+    done
+    echo "$NAME."
+  fi
+}
+
+case "$1" in
+  start)
+        startOE
+        ;;
+  stop)
+        stopOE
+        ;;
+  restart)
+        stopOE
+        startOE
+        ;;
+  status)
+        if [ -f $OMNIEVENTS_PIDFILE ] ; then
+          PID=`cat $OMNIEVENTS_PIDFILE`
+          kill -0 $PID 2>/dev/null
+          if [ "$?" = "0" ] ; then
+            echo "$NAME running. PID=$PID"
+          else
+            echo "$NAME dead. PID=$PID"
+            exit 1
+          fi
+        else
+          echo "$NAME stopped."
+          exit 3
+        fi
+        ;;
+  force-reload)
+        stopOE
+        startOE
+        ;;
+  reload)
+        echo "Not implemented."
+        exit 3
+        ;;
+  *)
+        N=@INSTALL_ETC@/init.d/omniorb-eventservice
+        echo "Usage: $N {start|stop|restart|status}" >&2
+        exit 1
+        ;;
+esac
+
+exit 0

Propchange: trunk/omnievents/etc/init.d/omniorb-eventservice.in
------------------------------------------------------------------------------
    svn:executable = *

Added: trunk/omnievents/examples/pullcons.cc
URL: http://svn.debian.org/wsvn/pkg-corba/trunk/omnievents/examples/pullcons.cc?rev=200&op=file
==============================================================================
--- trunk/omnievents/examples/pullcons.cc (added)
+++ trunk/omnievents/examples/pullcons.cc Fri Dec 25 19:19:31 2009
@@ -1,0 +1,524 @@
+// -*- Mode: C++; -*-
+//                            Package   : omniEvents
+// pullcons.cc                Created on: 1/4/98
+//                            Author    : Paul Nader (pwn)
+//
+//    Copyright (C) 1998 Paul Nader, 2003-2004 Alex Tingle
+//
+//    This file is part of the omniEvents application.
+//
+//    omniEvents is free software; you can redistribute it and/or
+//    modify it under the terms of the GNU Lesser General Public
+//    License as published by the Free Software Foundation; either
+//    version 2.1 of the License, or (at your option) any later version.
+//
+//    omniEvents is distributed in the hope that it will be useful,
+//    but WITHOUT ANY WARRANTY; without even the implied warranty of
+//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//    Lesser General Public License for more details.
+//
+//    You should have received a copy of the GNU Lesser General Public
+//    License along with this library; if not, write to the Free Software
+//    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+//
+// Description:
+//    Pull Model consumer implementation.
+//	
+
+/*
+  $Log: pullcons.cc,v $
+  Revision 1.12  2004/10/08 09:06:08  alextingle
+  More robust exception minor code handling.
+
+  Revision 1.11  2004/08/18 17:49:45  alextingle
+  Added check for SIGPIPE before trying to use it.
+
+  Revision 1.10  2004/08/06 16:19:23  alextingle
+  -k & -K options removed.
+  Naming service names may now be as complex as you like.
+
+  Revision 1.9  2004/04/20 16:52:02  alextingle
+  All examples updated for latest version on omniEvents. Server may now be
+  specified as a 'corbaloc' string or IOR, instead of as naming service id/kind.
+
+  Revision 1.8  2004/03/08 18:00:13  alextingle
+  One too many newlines.
+
+  Revision 1.7  2004/03/08 17:48:25  alextingle
+  Added newlines to cirrectly format output when exceptions occur.
+
+  Revision 1.6  2004/02/21 19:07:45  alextingle
+  Corrected servants to use POA instead of BOA.
+
+  Revision 1.5  2004/02/04 22:29:55  alextingle
+  Reworked all C++ examples.
+  Removed catch(...) as it tends to make it harder to see what's going on.
+  Now uses POA instead of BOA.
+  Uses omniORB4's Exception name probing.
+  No longer uses 'naming.h/cc' utility code.
+
+  Revision 1.4  2004/01/11 16:59:28  alextingle
+  Added more helpful exception handling error messages to pullcons.cc.
+
+  Revision 1.3  2003/11/03 22:20:54  alextingle
+  Removed all platform specific switches. Now uses autoconf, config.h.
+  Removed stub header in order to allow makefile dependency checking to work
+  correctly.
+  Changed int to bool where appropriate.
+
+  Revision 1.1.1.1.2.1  2002/09/28 22:20:51  shamus13
+  Added ifdefs to enable omniEvents to compile
+  with both omniORB3 and omniORB4. If __OMNIORB4__
+  is defined during compilation, omniORB4 headers
+  and command line option syntax is used, otherwise
+  fall back to omniORB3 style.
+
+  Revision 1.1.1.1  2002/09/25 19:00:25  shamus13
+  Import of OmniEvents source tree from release 2.1.1
+
+  Revision 0.11  2000/10/11 01:16:21  naderp
+  *** empty log message ***
+
+  Revision 0.10  2000/08/30 04:39:48  naderp
+  Port to omniORB 3.0.1.
+
+  Revision 0.9  2000/03/16 05:37:27  naderp
+  Added stdlib.h for getopt.
+
+  Revision 0.8  2000/03/06 13:25:44  naderp
+  Using util getRootNamingContext function.
+  Using stub headers.
+  Fixed error messages.
+
+  Revision 0.7  2000/03/02 02:11:27  naderp
+  Added -r option to connect using nil reference.
+  Added retry resiliency for handling COMM_FAUILURE exceptions.
+
+  Revision 0.6  1999/11/02 13:38:57  naderp
+  Added <signal.h>
+
+  Revision 0.5  1999/11/01 15:55:11  naderp
+  omniEvents 2.0 Release.
+  Ignoring SIGPIPE for UNIX platforms.
+
+Revision 0.4  99/04/23  16:05:38  16:05:38  naderp (Paul Nader)
+gcc port.
+
+Revision 0.3  99/04/23  09:33:40  09:33:40  naderp (Paul Nader)
+Windows Port.
+
+Revision 0.2  99/04/21  18:06:25  18:06:25  naderp (Paul Nader)
+*** empty log message ***
+
+Revision 0.1.1.1  98/11/27  16:59:07  16:59:07  naderp (Paul Nader)
+Added -s option to sleep after disconnecting.
+
+Revision 0.1  98/11/25  14:08:04  14:08:04  naderp (Paul Nader)
+Initial Revision
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#ifdef HAVE_GETOPT
+#  include <unistd.h>
+extern char* optarg;
+extern int optind;
+#else
+#  include "getopt.h"
+#endif
+
+#ifdef HAVE_IOSTREAM
+#  include <iostream>
+#else
+#  include <iostream.h>
+#endif
+
+#ifdef HAVE_STD_IOSTREAM
+using namespace std;
+#endif
+
+#ifdef HAVE_STDLIB_H
+#  include <stdlib.h>
+#endif
+
+#ifdef HAVE_SIGNAL_H
+#  include <signal.h>
+#endif
+
+#include <cstdio>
+
+#include "CosEventComm.hh"
+#include "CosEventChannelAdmin.hh"
+#include "naming.h"
+
+static void usage(int argc, char **argv);
+
+class Consumer_i : virtual public POA_CosEventComm::PullConsumer {
+public:
+  Consumer_i () {};
+  void disconnect_pull_consumer ();
+};
+
+void Consumer_i::disconnect_pull_consumer () {
+  cout << "Pull Consumer: disconnected." << endl;
+}
+
+int
+main(int argc, char **argv)
+{
+  //
+  // Start orb.
+  CORBA::ORB_ptr orb = CORBA::ORB_init(argc,argv);
+
+  // Process Options
+  bool        trymode       =false;
+  int         discnum       =0;
+  bool        refnil        =false;
+  int         sleepInterval =0;
+  const char* channelName   ="EventChannel";
+
+  int c;
+  while ((c = getopt(argc,argv,"td:rs:n:h")) != EOF)
+  {
+     switch (c)
+     {
+        case 't': trymode = true;
+                  break;
+
+        case 'd': discnum = atoi(optarg);
+                  break;
+
+        case 'r': refnil = true;
+                  break;
+
+        case 's': sleepInterval = atoi(optarg);
+                  break;
+
+        case 'n': channelName = optarg;
+                  break;
+
+        case 'h':
+        default : usage(argc,argv);
+                  exit(-1);
+                  break;
+     }
+  }
+
+#if defined(HAVE_SIGNAL_H) && defined(SIGPIPE)
+  // Ignore broken pipes
+  signal(SIGPIPE, SIG_IGN);
+#endif
+
+  Consumer_i* consumer =NULL;
+  CosEventChannelAdmin::EventChannel_var channel;
+
+  const char* action=""; // Use this variable to help report errors.
+  try {
+    CORBA::Object_var obj;
+
+    // A Pull Consumer can be implemented as a pure client or as a mixed
+    // client-server process, depending on whether it requires and is
+    // prepared to service disconnect requests from the channel.
+    // If it is, then create the servant object and activate the POA.
+    if (! refnil)
+    {
+       consumer=new Consumer_i();
+
+       action="resolve initial reference 'RootPOA'";
+       obj=orb->resolve_initial_references("RootPOA");
+       PortableServer::POA_var rootPoa =PortableServer::POA::_narrow(obj);
+       if(CORBA::is_nil(rootPoa))
+           throw CORBA::OBJECT_NOT_EXIST();
+
+       action="activate the RootPOA's POAManager";
+       PortableServer::POAManager_var pman =rootPoa->the_POAManager();
+       pman->activate();
+    }
+   
+    //
+    // Obtain object reference to EventChannel
+    // (from command-line argument or from the Naming Service).
+    if(optind<argc)
+    {
+      action="convert URI from command line into object reference";
+      obj=orb->string_to_object(argv[optind]);
+    }
+    else
+    {
+      action="resolve initial reference 'NameService'";
+      obj=orb->resolve_initial_references("NameService");
+      CosNaming::NamingContext_var rootContext=
+        CosNaming::NamingContext::_narrow(obj);
+      if(CORBA::is_nil(rootContext))
+          throw CORBA::OBJECT_NOT_EXIST();
+
+      action="find EventChannel in NameService";
+      cout << action << endl;
+      obj=rootContext->resolve(str2name(channelName));
+    }
+
+    action="narrow object reference to event channel";
+    channel=CosEventChannelAdmin::EventChannel::_narrow(obj);
+    if(CORBA::is_nil(channel))
+    {
+       cerr << "Failed to narrow Event Channel reference." << endl;
+       exit(1);
+    }
+
+  }
+  catch(CORBA::ORB::InvalidName& ex) { // resolve_initial_references
+     cerr<<"Failed to "<<action<<". ORB::InvalidName"<<endl;
+     exit(1);
+  }
+  catch(CosNaming::NamingContext::InvalidName& ex) { // resolve
+     cerr<<"Failed to "<<action<<". NamingContext::InvalidName"<<endl;
+     exit(1);
+  }
+  catch(CosNaming::NamingContext::NotFound& ex) { // resolve
+     cerr<<"Failed to "<<action<<". NamingContext::NotFound"<<endl;
+     exit(1);
+  }
+  catch(CosNaming::NamingContext::CannotProceed& ex) { // resolve
+     cerr<<"Failed to "<<action<<". NamingContext::CannotProceed"<<endl;
+     exit(1);
+  }
+  catch(CORBA::TRANSIENT& ex) { // _narrow()
+     cerr<<"Failed to "<<action<<". TRANSIENT"<<endl;
+     exit(1);
+  }
+  catch(CORBA::OBJECT_NOT_EXIST& ex) { // _narrow()
+     cerr<<"Failed to "<<action<<". OBJECT_NOT_EXIST"<<endl;
+     exit(1);
+  }
+  catch(CORBA::SystemException& ex) {
+     cerr<<"Failed to "<<action<<".";
+#if defined(HAVE_OMNIORB4)
+     cerr<<" "<<ex._name();
+     if(ex.NP_minorString())
+         cerr<<" ("<<ex.NP_minorString()<<")";
+#endif
+     cerr<<endl;
+     exit(1);
+  }
+  catch(CORBA::Exception& ex) {
+     cerr<<"Failed to "<<action<<"."
+#if defined(HAVE_OMNIORB4)
+       " "<<ex._name()
+#endif
+       <<endl;
+     exit(1);
+  }
+
+  //
+  // Get Consumer admin interface - retrying on Comms Failure.
+  CosEventChannelAdmin::ConsumerAdmin_var consumer_admin;
+  while (1)
+  {
+     try {
+        consumer_admin = channel->for_consumers ();
+        if (CORBA::is_nil (consumer_admin))
+        {
+           cerr << "Event Channel returned nil Consumer Admin!" << endl;
+           exit (1);
+        }
+        break;
+     }
+     catch (CORBA::COMM_FAILURE& ex) {
+        cerr << "Caught COMM_FAILURE exception "
+             << "obtaining Consumer Admin! Retrying..."
+             << endl;
+        continue;
+     }
+  }
+  cout << "Obtained Consumer Admin." << endl;
+
+  while (1)
+  {
+     //
+     // Get proxy supplier - retrying on Comms Failure.
+     CosEventChannelAdmin::ProxyPullSupplier_var proxy_supplier;
+     while (1)
+     {
+        try {
+           proxy_supplier = consumer_admin->obtain_pull_supplier ();
+           if (CORBA::is_nil (proxy_supplier))
+           {
+              cerr << "Consumer Admin returned nil Proxy Supplier!" << endl;
+              exit (1);
+           }
+           break;
+        }
+        catch (CORBA::COMM_FAILURE& ex) {
+           cerr << "Caught COMM_FAILURE Exception "
+                << "obtaining Pull Supplier! Retrying..."
+                << endl;
+           continue;
+        }
+     }
+     cout << "Obtained ProxyPullSupplier." << endl;
+   
+     //
+     // Connect Pull Consumer - retrying on Comms Failure.
+     CosEventComm::PullConsumer_ptr cptr =CosEventComm::PullConsumer::_nil();
+     if (! refnil) {
+        cptr=consumer->_this();
+     }
+
+     while (1)
+     {
+        try {
+           proxy_supplier->connect_pull_consumer(cptr);
+           break;
+        }
+        catch (CORBA::BAD_PARAM& ex) {
+           cerr << "Caught BAD_PARAM exception connecting Pull Consumer!"<<endl;
+           exit (1);
+        }
+        catch (CosEventChannelAdmin::AlreadyConnected& ex) {
+           cerr << "Proxy Pull Supplier already connected!" 
+                << endl;
+           break;
+        }
+        catch (CORBA::COMM_FAILURE& ex) {
+           cerr << "Caught COMM_FAILURE Exception "
+                << "connecting Pull Consumer! Retrying..." 
+                << endl;
+           continue;
+        }
+     }
+     cout << "Connected Pull Consumer." << endl;
+
+     // Pull data.
+     CORBA::Any *data;
+     CORBA::ULong l = 0;
+     for (int i=0; (discnum == 0) || (i < discnum); i++)
+     {
+        if(trymode)
+        {
+           try {
+               CORBA::Boolean has_event;
+               data = proxy_supplier->try_pull(has_event);
+               cout << "Consumer: try_pull() called. Data : " << flush;
+               if (has_event)
+               {
+                  l = 0;
+                  *data >>= l;
+                  cout << l << endl;
+                  delete data;
+               }
+               else
+               {
+                  cout << "None" << endl;
+               }
+           }
+           catch (CosEventComm::Disconnected& ex) {
+              cout << endl;
+              cerr << "Failed. Caught Disconnected Exception !" << endl;
+           }
+           catch (CORBA::COMM_FAILURE& ex) {
+              cout << endl;
+              cerr << "Failed. Caught COMM_FAILURE Exception !" << endl;
+           }
+           catch (CORBA::Exception& ex) {
+              cout << endl;
+              cerr<<"CORBA exception, unable to try_pull()"
+#ifdef HAVE_OMNIORB4
+                  <<": "<<ex._name()
+#endif
+                  << endl;
+           }
+        }
+        else
+        {
+           try {
+               cout << "Pull Consumer: pull() called. ";
+               cout.flush();
+               data = proxy_supplier->pull();
+               l = 0;
+               *data >>= l;
+               cout << "Data : " << l << endl;
+               delete data;
+           }
+           catch(CORBA::TRANSIENT&) {
+              cout << "caught TRANSIENT." << endl;
+              omni_thread::sleep(1);
+           }
+           catch (CosEventComm::Disconnected& ex) {
+              cout << endl;
+              cerr << "Failed. Caught Disconnected exception!" << endl;
+              exit(1);
+           }
+           catch (CORBA::COMM_FAILURE& ex) {
+              cout << endl;
+              cerr << "Failed. Caught COMM_FAILURE exception!" << endl;
+              exit(1);
+           }
+           catch (CORBA::SystemException& ex) {
+              cout << endl;
+              cerr<<"System exception, unable to pull()";
+#ifdef HAVE_OMNIORB4
+              cerr<<": "<<ex._name();
+              if(ex.NP_minorString())
+                  cerr<<" ("<<ex.NP_minorString()<<")";
+#endif
+              cerr<< endl;
+              exit(1);
+           }
+           catch (CORBA::Exception& ex) {
+              cout << endl;
+              cerr<<"CORBA exception, unable to pull()"
+#ifdef HAVE_OMNIORB4
+                  <<": "<<ex._name()
+#endif
+                  << endl;
+              exit(1);
+           }
+        }
+     }
+
+     // Disconnect - retrying on Comms Failure.
+     while (1)
+     {
+        try {
+           proxy_supplier->disconnect_pull_supplier();
+           break;
+        }
+        catch (CORBA::COMM_FAILURE& ex) {
+           cerr << "Caught COMM_FAILURE exception "
+                << "disconnecting Pull Consumer! Retrying..." 
+                << endl;
+           continue;
+        }
+     }
+     cout << "Disconnected Pull Consumer." << endl;
+
+     // Yawn
+     cout << "Sleeping " << sleepInterval << " seconds." << endl;
+     omni_thread::sleep(sleepInterval);
+  }
+
+  // Not Reached
+  return 0;
+}
+
+static void
+usage(int argc, char **argv)
+{
+  cerr<<
+"\nCreate a PullConsumer to receive events from a channel.\n"
+"syntax: "<<(argc?argv[0]:"pullcons")<<" OPTIONS [CHANNEL_URI]\n"
+"\n"
+"CHANNEL_URI: The event channel may be specified as a URI.\n"
+" This may be an IOR, or a corbaloc::: or corbaname::: URI.\n"
+"\n"
+"OPTIONS:                                         DEFAULT:\n"
+" -t       enable try_pull mode\n"
+" -r       connect using a nil reference\n"
+" -d NUM   disconnect after receiving NUM events   [0 - never disconnect]\n"
+" -s SECS  sleep SECS seconds after disconnecting  [0]\n"
+" -n NAME  channel name (if URI is not specified)  [\"EventChannel\"]\n"
+" -h       display this help text\n" << endl;
+}

Added: trunk/omnievents/examples/pullsupp.cc
URL: http://svn.debian.org/wsvn/pkg-corba/trunk/omnievents/examples/pullsupp.cc?rev=200&op=file
==============================================================================
--- trunk/omnievents/examples/pullsupp.cc (added)
+++ trunk/omnievents/examples/pullsupp.cc Fri Dec 25 19:19:31 2009
@@ -1,0 +1,461 @@
+// -*- Mode: C++; -*-
+//                            Package   : omniEvents
+//   pullsupp.cc              Created   : 1/4/98
+//                            Author    : Paul Nader (pwn)
+//
+//    Copyright (C) 1998 Paul Nader, 2003-2004 Alex Tingle
+//
+//    This file is part of the omniEvents application.
+//
+//    omniEvents is free software; you can redistribute it and/or
+//    modify it under the terms of the GNU Lesser General Public
+//    License as published by the Free Software Foundation; either
+//    version 2.1 of the License, or (at your option) any later version.
+//
+//    omniEvents is distributed in the hope that it will be useful,
+//    but WITHOUT ANY WARRANTY; without even the implied warranty of
+//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//    Lesser General Public License for more details.
+//
+//    You should have received a copy of the GNU Lesser General Public
+//    License along with this library; if not, write to the Free Software
+//    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+//
+// Description:
+//    Pull Model supplier implementation.
+//	
+
+/*
+  $Log: pullsupp.cc,v $
+  Revision 1.9  2004/10/08 09:06:08  alextingle
+  More robust exception minor code handling.
+
+  Revision 1.8  2004/08/18 17:49:45  alextingle
+  Added check for SIGPIPE before trying to use it.
+
+  Revision 1.7  2004/08/06 16:19:23  alextingle
+  -k & -K options removed.
+  Naming service names may now be as complex as you like.
+
+  Revision 1.6  2004/04/20 16:52:05  alextingle
+  All examples updated for latest version on omniEvents. Server may now be
+  specified as a 'corbaloc' string or IOR, instead of as naming service id/kind.
+
+  Revision 1.5  2004/02/04 22:29:55  alextingle
+  Reworked all C++ examples.
+  Removed catch(...) as it tends to make it harder to see what's going on.
+  Now uses POA instead of BOA.
+  Uses omniORB4's Exception name probing.
+  No longer uses 'naming.h/cc' utility code.
+
+  Revision 1.4  2003/11/17 08:47:09  alextingle
+  Corrected typo.
+
+  Revision 1.2  2003/11/16 23:24:22  alex
+  Corrected typo.
+
+  Revision 1.1.1.1  2003/11/11 22:28:56  alex
+  Import of testing 2.3.0
+
+  Revision 1.3  2003/11/03 22:20:26  alextingle
+  Removed all platform specific switches. Now uses autoconf, config.h.
+  Removed stub header in order to allow makefile dependency checking to work
+  correctly.
+
+  Revision 1.1.1.1.2.1  2002/09/28 22:20:51  shamus13
+  Added ifdefs to enable omniEvents to compile
+  with both omniORB3 and omniORB4. If __OMNIORB4__
+  is defined during compilation, omniORB4 headers
+  and command line option syntax is used, otherwise
+  fall back to omniORB3 style.
+
+  Revision 1.1.1.1  2002/09/25 19:00:26  shamus13
+  Import of OmniEvents source tree from release 2.1.1
+
+  Revision 0.11  2000/08/30 04:39:48  naderp
+  Port to omniORB 3.0.1.
+
+  Revision 0.10  2000/03/16 05:37:27  naderp
+  Added stdlib.h for getopt.
+
+  Revision 0.9  2000/03/06 13:26:32  naderp
+  Using util getRootNamingContext function.
+  Using stub headers.
+  Fixed error messages.
+
+  Revision 0.8  2000/03/02 03:16:26  naderp
+  Added retry resiliency for handling COMM_FAUILURE exceptions.
+  Replaced condition variable by counting semaphore.
+
+  Revision 0.7  1999/11/02 13:39:13  naderp
+  Added <signal.h>
+
+  Revision 0.6  1999/11/02 07:57:22  naderp
+  Updated usage.
+
+Revision 0.5  99/11/01  16:10:12  16:10:12  naderp (Paul Nader)
+omniEvents 2.0 Release.
+Ignoring SIGPIPE for UNIX platforms.
+
+Revision 0.4  99/04/23  16:05:44  16:05:44  naderp (Paul Nader)
+gcc port.
+
+Revision 0.3  99/04/23  09:34:01  09:34:01  naderp (Paul Nader)
+Windows Port.
+
+Revision 0.2  99/04/21  18:06:25  18:06:25  naderp (Paul Nader)
+*** empty log message ***
+
+Revision 0.1.1.1  98/11/27  16:59:33  16:59:33  naderp (Paul Nader)
+Added -s option to sleep after disconnecting.
+
+Revision 0.1  98/11/25  14:08:07  14:08:07  naderp (Paul Nader)
+Initial Revision
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#ifdef HAVE_GETOPT
+#  include <unistd.h>
+extern char* optarg;
+extern int optind;
+#else
+#  include "getopt.h"
+#endif
+
+#ifdef HAVE_IOSTREAM
+#  include <iostream>
+#else
+#  include <iostream.h>
+#endif
+
+#ifdef HAVE_STD_IOSTREAM
+using namespace std;
+#endif
+
+#ifdef HAVE_STDLIB_H
+#  include <stdlib.h>
+#endif
+
+#ifdef HAVE_SIGNAL_H
+#  include <signal.h>
+#endif
+
+#include <cstdio>
+
+#include "CosEventComm.hh"
+#include "CosEventChannelAdmin.hh"
+#include "naming.h"
+
+static omni_semaphore connect_cond(0);
+static void usage(int argc, char **argv);
+
+class Supplier_i : virtual public POA_CosEventComm::PullSupplier {
+public:
+  Supplier_i (long disconnect = 0) : i(0), _disconnect(disconnect), l(0) {};
+  CORBA::Any *pull();
+  CORBA::Any *try_pull(CORBA::Boolean &has_event);
+  void disconnect_pull_supplier ();
+
+private:
+  long i;
+  long _disconnect;
+  CORBA::ULong l;
+};
+
+void
+Supplier_i::disconnect_pull_supplier () {
+  cout << "Pull Supplier: disconnected by channel." << endl;
+}
+
+CORBA::Any *
+Supplier_i::pull() {
+   cout << "Pull Supplier: pull() called. Data : ";
+   CORBA::Any *any = new CORBA::Any();
+   *any <<= l++;
+   cout << l-1 << endl;
+
+   // Exercise Disconnect
+   if ((_disconnect > 0) && (i == _disconnect)) {
+      i = 0;
+      // Signal main thread to disconnect and re-connect.
+      connect_cond.post();
+   }
+   i++;
+   return (any);
+}
+
+CORBA::Any *
+Supplier_i::try_pull(CORBA::Boolean &has_event)
+{
+   cout << "Pull Supplier: try_pull() called. Data : ";
+   CORBA::Any *any = new CORBA::Any();
+   *any <<= l++;
+   cout << l-1 << endl;
+   has_event = 1;
+
+   // Exercise Disconnect
+   if ((_disconnect > 0) && (i == _disconnect)) {
+      i = 0;
+      // Signal main thread to disconnect and re-connect.
+      connect_cond.post();
+   }
+   i++;
+   return (any);
+}
+
+
+int
+main (int argc, char** argv)
+{
+#if defined(HAVE_OMNIORB4)
+  CORBA::ORB_var orb =CORBA::ORB_init(argc,argv,"omniORB4");
+#else
+  CORBA::ORB_var orb =CORBA::ORB_init(argc,argv,"omniORB3");
+#endif
+
+  // Process Options
+  int         discnum       =0;
+  int         sleepInterval =0;
+  const char* channelName   ="EventChannel";
+
+  int c;
+  while ((c = getopt(argc,argv,"d:s:n:h")) != EOF)
+  {
+     switch (c)
+     {
+        case 'd': discnum = atoi(optarg);
+                  break;
+
+        case 's': sleepInterval = atoi(optarg);
+                  break;
+
+        case 'n': channelName = optarg;
+                  break;
+
+        case 'h':
+        default : usage(argc,argv);
+                  exit(-1);
+                  break;
+     }
+  }
+
+#if defined(HAVE_SIGNAL_H) && defined(SIGPIPE)
+  // Ignore broken pipes
+  signal(SIGPIPE, SIG_IGN);
+#endif
+
+  Supplier_i* supplier = new Supplier_i (discnum);
+  CosEventChannelAdmin::EventChannel_var channel;
+
+  const char* action=""; // Use this variable to help report errors.
+  try {
+    CORBA::Object_var obj;
+
+    action="resolve initial reference 'RootPOA'";
+    obj=orb->resolve_initial_references("RootPOA");
+    PortableServer::POA_var rootPoa =PortableServer::POA::_narrow(obj);
+    if(CORBA::is_nil(rootPoa))
+        throw CORBA::OBJECT_NOT_EXIST();
+
+    action="activate the RootPOA's POAManager";
+    PortableServer::POAManager_var pman =rootPoa->the_POAManager();
+    pman->activate();
+
+    //
+    // Obtain object reference to EventChannel
+    // (from command-line argument or from the Naming Service).
+    if(optind<argc)
+    {
+      action="convert URI from command line into object reference";
+      obj=orb->string_to_object(argv[optind]);
+    }
+    else
+    {
+      action="resolve initial reference 'NameService'";
+      obj=orb->resolve_initial_references("NameService");
+      CosNaming::NamingContext_var rootContext=
+        CosNaming::NamingContext::_narrow(obj);
+      if(CORBA::is_nil(rootContext))
+          throw CORBA::OBJECT_NOT_EXIST();
+
+      action="find EventChannel in NameService";
+      cout << action << endl;
+      obj=rootContext->resolve(str2name(channelName));
+    }
+
+    action="narrow object reference to event channel";
+    channel=CosEventChannelAdmin::EventChannel::_narrow(obj);
+    if(CORBA::is_nil(channel))
+    {
+       cerr << "Failed to narrow Event Channel reference." << endl;
+       exit(1);
+    }
+
+  }
+  catch(CORBA::ORB::InvalidName& ex) { // resolve_initial_references
+     cerr<<"Failed to "<<action<<". ORB::InvalidName"<<endl;
+     exit(1);
+  }
+  catch(CosNaming::NamingContext::InvalidName& ex) { // resolve
+     cerr<<"Failed to "<<action<<". NamingContext::InvalidName"<<endl;
+     exit(1);
+  }
+  catch(CosNaming::NamingContext::NotFound& ex) { // resolve
+     cerr<<"Failed to "<<action<<". NamingContext::NotFound"<<endl;
+     exit(1);
+  }
+  catch(CosNaming::NamingContext::CannotProceed& ex) { // resolve
+     cerr<<"Failed to "<<action<<". NamingContext::CannotProceed"<<endl;
+     exit(1);
+  }
+  catch(CORBA::TRANSIENT& ex) { // _narrow()
+     cerr<<"Failed to "<<action<<". TRANSIENT"<<endl;
+     exit(1);
+  }
+  catch(CORBA::OBJECT_NOT_EXIST& ex) { // _narrow()
+     cerr<<"Failed to "<<action<<". OBJECT_NOT_EXIST"<<endl;
+     exit(1);
+  }
+  catch(CORBA::SystemException& ex) {
+     cerr<<"Failed to "<<action<<".";
+#if defined(HAVE_OMNIORB4)
+     cerr<<" "<<ex._name();
+     if(ex.NP_minorString())
+         cerr<<" ("<<ex.NP_minorString()<<")";
+#endif
+     cerr<<endl;
+     exit(1);
+  }
+  catch(CORBA::Exception& ex) {
+     cerr<<"Failed to "<<action<<"."
+#if defined(HAVE_OMNIORB4)
+       " "<<ex._name()
+#endif
+       <<endl;
+     exit(1);
+  }
+
+  //
+  // Get Supplier Admin interface - retrying on Comms Failure.
+  CosEventChannelAdmin::SupplierAdmin_var supplier_admin;
+  while (1)
+  {
+     try {
+        supplier_admin = channel->for_suppliers ();
+        if (CORBA::is_nil(supplier_admin))
+        {
+           cerr << "Event Channel returned nil Supplier Admin!"
+                << endl;
+           exit(1);
+        }
+        break;
+     }
+     catch (CORBA::COMM_FAILURE& ex) {
+        cerr << "Caught COMM_FAILURE exception "
+             << "obtaining Supplier Admin! Retrying..."
+             << endl;
+        continue;
+     }
+  }
+  cout << "Obtained SupplierAdmin." << endl;
+
+  while (1)
+  {
+     //
+     // Get proxy consumer - retrying on Comms Failure.
+     CosEventChannelAdmin::ProxyPullConsumer_var proxy_consumer;
+     while (1)
+     {
+        try {
+           proxy_consumer = supplier_admin->obtain_pull_consumer ();
+           if (CORBA::is_nil(proxy_consumer))
+           {
+              cerr << "Supplier Admin returned nil proxy_consumer!"
+                   << endl;
+              exit(1);
+           }
+	   break;
+        }
+        catch (CORBA::COMM_FAILURE& ex) {
+           cerr << "Caught COMM_FAILURE exception "
+                << "obtaining Proxy Pull Consumer! Retrying..."
+                << endl;
+           continue;
+        }
+     }
+     cout << "Obtained ProxyPullConsumer." << endl;
+   
+     // Connect Pull Supplier - retrying on Comms Failure.
+     CosEventComm::PullSupplier_var supplierRef =supplier->_this();
+     while (1)
+     {
+        try {
+           proxy_consumer->connect_pull_supplier(supplierRef.in());
+           break;
+        }
+        catch (CORBA::BAD_PARAM& ex) {
+           cerr<<"Caught BAD_PARAM Exception connecting Pull Supplier!"<<endl;
+           exit(1);
+        }
+        catch (CosEventChannelAdmin::AlreadyConnected& ex) {
+           cerr << "Pull Supplier already connected!"
+                << endl;
+           break;
+        }
+        catch (CORBA::COMM_FAILURE& ex) {
+           cerr << "Caught COMM_FAILURE exception "
+                << "connecting Pull Supplier! Retrying..."
+                << endl;
+           continue;
+        }
+     }
+     cout << "Connected Pull Supplier." << endl;
+
+     // Wait for indication to disconnect before re-connecting.
+     connect_cond.wait();
+
+     // Disconnect - retrying on Comms Failure.
+     while (1)
+     {
+        try {
+           proxy_consumer->disconnect_pull_consumer();
+           break;
+        }
+        catch (CORBA::COMM_FAILURE& ex) {
+           cerr << "Caught COMM_FAILURE exception "
+                << "disconnecting Pull Supplier! Retrying..."
+                << endl;
+           continue;
+        }
+     }
+     cout << "Disconnected Pull Supplier." << endl;
+
+     // Yawn.
+     cout << "Sleeping " << sleepInterval << " seconds." << endl;
+     omni_thread::sleep(sleepInterval);
+  }
+
+  // Not Reached
+  return 0;
+}
+
+static void
+usage(int argc, char **argv)
+{
+  cerr<<
+"\nCreate a PullSupplier to send events to a channel.\n"
+"syntax: "<<(argc?argv[0]:"pullsupp")<<" OPTIONS [CHANNEL_URI]\n"
+"\n"
+"CHANNEL_URI: The event channel may be specified as a URI.\n"
+" This may be an IOR, or a corbaloc::: or corbaname::: URI.\n"
+"\n"
+"OPTIONS:                                         DEFAULT:\n"
+" -d NUM   disconnect after sending NUM events     [0 - never disconnect]\n"
+" -s SECS  sleep SECS seconds after disconnecting  [0]\n"
+" -n NAME  channel name (if URI is not specified)  [\"EventChannel\"]\n"
+" -h       display this help text\n" << endl;
+}

Added: trunk/omnievents/examples/pushcons.cc
URL: http://svn.debian.org/wsvn/pkg-corba/trunk/omnievents/examples/pushcons.cc?rev=200&op=file
==============================================================================
--- trunk/omnievents/examples/pushcons.cc (added)
+++ trunk/omnievents/examples/pushcons.cc Fri Dec 25 19:19:31 2009
@@ -1,0 +1,463 @@
+// -*- Mode: C++; -*-
+//                            Package   : omniEvents
+//   pushcons.cc              Created   : 1/4/98
+//                            Author    : Paul Nader (pwn)
+//
+//    Copyright (C) 1998 Paul Nader, 2003-2004 Alex Tingle
+//
+//    This file is part of the omniEvents application.
+//
+//    omniEvents is free software; you can redistribute it and/or
+//    modify it under the terms of the GNU Lesser General Public
+//    License as published by the Free Software Foundation; either
+//    version 2.1 of the License, or (at your option) any later version.
+//
+//    omniEvents is distributed in the hope that it will be useful,
+//    but WITHOUT ANY WARRANTY; without even the implied warranty of
+//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//    Lesser General Public License for more details.
+//
+//    You should have received a copy of the GNU Lesser General Public
+//    License along with this library; if not, write to the Free Software
+//    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+//
+// Description:
+//    Push Model consumer implementation
+//
+
+/*
+  $Log: pushcons.cc,v $
+  Revision 1.12.2.1  2005/06/16 09:39:49  alextingle
+  Fixed theoretical race caused by sloppy use of condition variable.
+
+  Revision 1.12  2004/10/08 09:06:08  alextingle
+  More robust exception minor code handling.
+
+  Revision 1.11  2004/08/18 17:49:45  alextingle
+  Added check for SIGPIPE before trying to use it.
+
+  Revision 1.10  2004/08/06 16:19:23  alextingle
+  -k & -K options removed.
+  Naming service names may now be as complex as you like.
+
+  Revision 1.9  2004/04/30 17:54:47  alextingle
+  Corrected handling of CORBA::Any.
+
+  Revision 1.8  2004/04/20 16:52:17  alextingle
+  All examples updated for latest version on omniEvents. Server may now be
+  specified as a 'corbaloc' string or IOR, instead of as naming service id/kind.
+
+  Revision 1.7  2004/04/01 22:28:36  alextingle
+  Corrected usage message.
+
+  Revision 1.6  2004/03/23 19:09:26  alextingle
+  Fixed typos.
+
+  Revision 1.5  2004/02/21 19:07:45  alextingle
+  Corrected servants to use POA instead of BOA.
+
+  Revision 1.4  2004/02/04 22:29:55  alextingle
+  Reworked all C++ examples.
+  Removed catch(...) as it tends to make it harder to see what's going on.
+  Now uses POA instead of BOA.
+  Uses omniORB4's Exception name probing.
+  No longer uses 'naming.h/cc' utility code.
+
+  Revision 1.3  2003/11/03 22:19:56  alextingle
+  Removed all platform specific switches. Now uses autoconf, config.h.
+  Removed stub header in order to allow makefile dependency checking to work
+  correctly.
+  Corrected usage of omni_condition/omni_mutex. Mutexes are now always unlocked by
+  the same thread that locked them.
+
+  Revision 1.1.1.1.2.1  2002/09/28 22:20:51  shamus13
+  Added ifdefs to enable omniEvents to compile
+  with both omniORB3 and omniORB4. If __OMNIORB4__
+  is defined during compilation, omniORB4 headers
+  and command line option syntax is used, otherwise
+  fall back to omniORB3 style.
+
+  Revision 1.1.1.1  2002/09/25 19:00:26  shamus13
+  Import of OmniEvents source tree from release 2.1.1
+
+  Revision 0.13  2000/08/30 04:39:48  naderp
+  Port to omniORB 3.0.1.
+
+  Revision 0.12  2000/03/16 05:37:27  naderp
+  Added stdlib.h for getopt.
+
+  Revision 0.11  2000/03/06 13:27:02  naderp
+  Using util getRootNamingContext function.
+  Using stub headers.
+  Fixed error messages.
+
+  Revision 0.10  2000/03/02 03:20:24  naderp
+  Added retry resiliency for handling COMM_FAUILURE exceptions.
+
+  Revision 0.9  1999/11/02 13:39:15  naderp
+  Added <signal.h>
+
+  Revision 0.8  1999/11/02 07:57:04  naderp
+  Updated usage.
+
+Revision 0.7  99/11/01  18:10:29  18:10:29  naderp (Paul Nader)
+Added ahndling of COMM_FAILURE exception for connect_push_consumer.
+
+Revision 0.6  99/11/01  16:11:03  16:11:03  naderp (Paul Nader)
+omniEvents 2.0 Release.
+
+Revision 0.5  99/10/27  19:46:01  19:46:01  naderp (Paul Nader)
+Ignoring Unix SIGPIPE signal.
+Catching COMM_FAILURE exception for obtain_push_supplier.
+Continuing if it fails to obtain Proxy Supplier.
+Try/Catch block for disconnect_push_supplier.
+
+Revision 0.4  99/04/23  16:05:46  16:05:46  naderp (Paul Nader)
+gcc port.
+
+Revision 0.3  99/04/23  09:34:03  09:34:03  naderp (Paul Nader)
+Windows Port.
+
+Revision 0.2  99/04/21  18:06:26  18:06:26  naderp (Paul Nader)
+*** empty log message ***
+
+Revision 0.1.1.1  98/11/27  16:59:37  16:59:37  naderp (Paul Nader)
+Added -s option to sleep after disconnecting.
+
+Revision 0.1  98/11/25  14:08:21  14:08:21  naderp (Paul Nader)
+Initial Revision
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#ifdef HAVE_GETOPT
+#  include <unistd.h>
+extern char* optarg;
+extern int optind;
+#else
+#  include "getopt.h"
+#endif
+
+#ifdef HAVE_IOSTREAM
+#  include <iostream>
+#else
+#  include <iostream.h>
+#endif
+
+#ifdef HAVE_STD_IOSTREAM
+using namespace std;
+#endif
+
+#ifdef HAVE_STDLIB_H
+#  include <stdlib.h>
+#endif
+
+#ifdef HAVE_SIGNAL_H
+#  include <signal.h>
+#endif
+
+#include <cstdio>
+
+#include "CosEventComm.hh"
+#include "CosEventChannelAdmin.hh"
+#include "naming.h"
+
+static omni_mutex mutex;
+static omni_condition connect_cond(&mutex);
+static void usage(int argc, char **argv);
+
+class Consumer_i : virtual public POA_CosEventComm::PushConsumer {
+public:
+  Consumer_i(long disconnect=0): _disconnect(disconnect) {}
+
+  void push(const CORBA::Any& data);
+  void disconnect_push_consumer ();
+
+private:
+  long _disconnect;
+};
+
+void Consumer_i::push(const CORBA::Any& data) {
+  CORBA::ULong l;
+  static int i = 0;
+
+  i++;
+  if( data>>=l )
+  {
+    cout<<"Push Consumer: push() called. Data : "<< l <<endl;
+
+    // Exercise Disconnect
+    if (i == _disconnect)
+    {
+       i = 0;
+       // NOTE : The proxy_supplier object is disposed at the server
+       //        during the disconnect_push_supplier call. Do NOT
+       //        use the proxy_supplier reference after disconnecting.
+
+       // Signal main thread to disconnect and re-connect.
+       omni_mutex_lock condition_lock(mutex); // ensure main thread in wait()
+       connect_cond.signal();
+    }
+  }
+  else
+  {
+    cerr<<"Push Consumer: push() called. UNEXPECTED TYPE"<<endl;
+  }
+}
+
+void Consumer_i::disconnect_push_consumer () {
+  cout << "Push Consumer: disconnected." << endl;
+}
+
+int
+main(int argc, char **argv)
+{
+  //
+  // Start orb.
+  CORBA::ORB_ptr orb = CORBA::ORB_init(argc,argv);
+
+  // Process Options
+  int         discnum       =0;
+  int         sleepInterval =0;
+  const char* channelName   ="EventChannel";
+
+  int c;
+  while ((c = getopt(argc,argv,"hd:s:n:")) != EOF)
+  {
+     switch (c)
+     {
+        case 'd': discnum = atoi(optarg);
+                  break;
+
+        case 's': sleepInterval = atoi(optarg);
+                  break;
+
+        case 'n': channelName = optarg;
+                  break;
+
+        case 'h': usage(argc,argv);
+                  exit(0);
+        default : usage(argc,argv);
+                  exit(-1);
+     }
+  }
+
+#if defined(HAVE_SIGNAL_H) && defined(SIGPIPE)
+  // Ignore broken pipes
+  signal(SIGPIPE, SIG_IGN);
+#endif
+
+  Consumer_i* consumer = new Consumer_i (discnum);
+  CosEventChannelAdmin::EventChannel_var channel;
+
+  const char* action=""; // Use this variable to help report errors.
+  try {
+    CORBA::Object_var obj;
+
+    action="resolve initial reference 'RootPOA'";
+    obj=orb->resolve_initial_references("RootPOA");
+    PortableServer::POA_var rootPoa =PortableServer::POA::_narrow(obj);
+    if(CORBA::is_nil(rootPoa))
+        throw CORBA::OBJECT_NOT_EXIST();
+
+    action="activate the RootPOA's POAManager";
+    PortableServer::POAManager_var pman =rootPoa->the_POAManager();
+    pman->activate();
+
+    //
+    // Obtain object reference to EventChannel
+    // (from command-line argument or from the Naming Service).
+    if(optind<argc)
+    {
+      action="convert URI from command line into object reference";
+      obj=orb->string_to_object(argv[optind]);
+    }
+    else
+    {
+      action="resolve initial reference 'NameService'";
+      obj=orb->resolve_initial_references("NameService");
+      CosNaming::NamingContext_var rootContext=
+        CosNaming::NamingContext::_narrow(obj);
+      if(CORBA::is_nil(rootContext))
+          throw CORBA::OBJECT_NOT_EXIST();
+
+      action="find EventChannel in NameService";
+      cout << action << endl;
+      obj=rootContext->resolve(str2name(channelName));
+    }
+
+    action="narrow object reference to event channel";
+    channel=CosEventChannelAdmin::EventChannel::_narrow(obj);
+    if(CORBA::is_nil(channel))
+    {
+       cerr << "Failed to narrow Event Channel reference." << endl;
+       exit(1);
+    }
+
+  }
+  catch(CORBA::ORB::InvalidName& ex) { // resolve_initial_references
+     cerr<<"Failed to "<<action<<". ORB::InvalidName"<<endl;
+     exit(1);
+  }
+  catch(CosNaming::NamingContext::InvalidName& ex) { // resolve
+     cerr<<"Failed to "<<action<<". NamingContext::InvalidName"<<endl;
+     exit(1);
+  }
+  catch(CosNaming::NamingContext::NotFound& ex) { // resolve
+     cerr<<"Failed to "<<action<<". NamingContext::NotFound"<<endl;
+     exit(1);
+  }
+  catch(CosNaming::NamingContext::CannotProceed& ex) { // resolve
+     cerr<<"Failed to "<<action<<". NamingContext::CannotProceed"<<endl;
+     exit(1);
+  }
+  catch(CORBA::TRANSIENT& ex) { // _narrow()
+     cerr<<"Failed to "<<action<<". TRANSIENT"<<endl;
+     exit(1);
+  }
+  catch(CORBA::OBJECT_NOT_EXIST& ex) { // _narrow()
+     cerr<<"Failed to "<<action<<". OBJECT_NOT_EXIST"<<endl;
+     exit(1);
+  }
+  catch(CORBA::SystemException& ex) {
+     cerr<<"Failed to "<<action<<".";
+#if defined(HAVE_OMNIORB4)
+     cerr<<" "<<ex._name();
+     if(ex.NP_minorString())
+         cerr<<" ("<<ex.NP_minorString()<<")";
+#endif
+     cerr<<endl;
+     exit(1);
+  }
+  catch(CORBA::Exception& ex) {
+     cerr<<"Failed to "<<action<<"."
+#if defined(HAVE_OMNIORB4)
+       " "<<ex._name()
+#endif
+       <<endl;
+     exit(1);
+  }
+
+  //
+  // Get Consumer admin interface - retrying on Comms Failure.
+  CosEventChannelAdmin::ConsumerAdmin_var consumer_admin;
+  while (1)
+  {
+     try {
+        consumer_admin = channel->for_consumers ();
+        if (CORBA::is_nil (consumer_admin))
+        {
+           cerr << "Event Channel returned nil Consumer Admin!" << endl;
+           exit(1);
+        }
+        break;
+     }
+     catch (CORBA::COMM_FAILURE& ex) {
+        cerr << "Caught COMM_FAILURE exception "
+             << "obtaining Consumer Admin! Retrying..."
+             << endl;
+        continue;
+     }
+  }
+  cout << "Obtained ConsumerAdmin." << endl;
+
+  omni_mutex_lock condition_lock(mutex);
+  while (1) {
+     //
+     // Get proxy supplier - retrying on Comms Failure.
+     CosEventChannelAdmin::ProxyPushSupplier_var proxy_supplier;
+     while (1)
+     {
+        try {
+           proxy_supplier = consumer_admin->obtain_push_supplier ();
+           if (CORBA::is_nil (proxy_supplier))
+           {
+              cerr << "Consumer Admin returned nil proxy_supplier!"
+                   << endl;
+              exit (1);
+           }
+           break;
+        }
+        catch (CORBA::COMM_FAILURE& ex) {
+           cerr << "Caught COMM_FAILURE Exception "
+                << "obtaining Push Supplier! Retrying..."
+                << endl;
+           continue;
+        }
+     }
+     cout << "Obtained ProxyPushSupplier." << endl;
+   
+     //
+     // Connect Push Consumer - retrying on Comms Failure.
+     while (1)
+     {
+        try {
+           proxy_supplier->connect_push_consumer(consumer->_this());
+           break;
+        }
+        catch (CORBA::BAD_PARAM& ex) {
+           cerr << "Caught BAD_PARAM Exception connecting Push Consumer!"
+                << endl;
+           exit (1);
+        }
+        catch (CosEventChannelAdmin::AlreadyConnected& ex) {
+           cerr << "Proxy Push Supplier already connected!"
+                << endl;
+           break;
+        }
+        catch (CORBA::COMM_FAILURE& ex) {
+           cerr << "Caught COMM_FAILURE exception "
+                << "connecting Push Consumer! Retrying..."
+                << endl;
+           continue;
+        }
+     }
+     cout << "Connected Push Consumer." << endl;
+
+     // Wait for indication to disconnect before re-connecting.
+     connect_cond.wait();
+
+     // Disconnect - retrying on Comms Failure.
+     while (1)
+     {
+        try {
+           proxy_supplier->disconnect_push_supplier();
+           break;
+        }
+        catch (CORBA::COMM_FAILURE& ex) {
+           cerr << "Caught COMM_FAILURE Exception "
+	        << "disconnecting Push Consumer! Retrying..."
+                << endl;
+           continue;
+        }
+     }
+     cout << "Disconnected Push Consumer." << endl;
+   
+     // Yawn
+     cout << "Sleeping " << sleepInterval << " seconds." << endl;
+     omni_thread::sleep(sleepInterval);
+  }
+
+  // NEVER GET HERE
+  return 0;
+}
+
+static void
+usage(int argc, char **argv)
+{
+  cerr<<
+"\nCreate a PushConsumer to receive events from a channel.\n"
+"syntax: "<<(argc?argv[0]:"pushcons")<<" OPTIONS [CHANNEL_URI]\n"
+"\n"
+"CHANNEL_URI: The event channel may be specified as a URI.\n"
+" This may be an IOR, or a corbaloc::: or corbaname::: URI.\n"
+"\n"
+"OPTIONS:                                         DEFAULT:\n"
+" -d NUM   disconnect after receiving NUM events   [0 - never disconnect]\n"
+" -s SECS  sleep SECS seconds after disconnecting  [0]\n"
+" -n NAME  channel name (if URI is not specified)  [\"EventChannel\"]\n"
+" -h       display this help text\n" << endl;
+}

Added: trunk/omnievents/examples/pushsupp.cc
URL: http://svn.debian.org/wsvn/pkg-corba/trunk/omnievents/examples/pushsupp.cc?rev=200&op=file
==============================================================================
--- trunk/omnievents/examples/pushsupp.cc (added)
+++ trunk/omnievents/examples/pushsupp.cc Fri Dec 25 19:19:31 2009
@@ -1,0 +1,454 @@
+// -*- Mode: C++; -*-
+//                            Package   : omniEvents
+//   pushsupp.cc              Created on: 1/4/98
+//                            Author    : Paul Nader (pwn)
+//
+//    Copyright (C) 1998 Paul Nader, 2003-2004 Alex Tingle
+//
+//    This file is part of the omnievents application.
+//
+//    omniEvents is free software; you can redistribute it and/or
+//    modify it under the terms of the GNU Lesser General Public
+//    License as published by the Free Software Foundation; either
+//    version 2.1 of the License, or (at your option) any later version.
+//
+//    omniEvents is distributed in the hope that it will be useful,
+//    but WITHOUT ANY WARRANTY; without even the implied warranty of
+//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//    Lesser General Public License for more details.
+//
+//    You should have received a copy of the GNU Lesser General Public
+//    License along with this library; if not, write to the Free Software
+//    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+//
+// Description:
+//    Push Model supplier implementation.
+//	
+
+/*
+  $Log: pushsupp.cc,v $
+  Revision 1.10  2004/10/08 09:06:08  alextingle
+  More robust exception minor code handling.
+
+  Revision 1.9  2004/08/18 17:49:45  alextingle
+  Added check for SIGPIPE before trying to use it.
+
+  Revision 1.8  2004/08/06 16:19:23  alextingle
+  -k & -K options removed.
+  Naming service names may now be as complex as you like.
+
+  Revision 1.7  2004/04/20 16:52:17  alextingle
+  All examples updated for latest version on omniEvents. Server may now be
+  specified as a 'corbaloc' string or IOR, instead of as naming service id/kind.
+
+  Revision 1.6  2004/03/23 19:09:26  alextingle
+  Fixed typos.
+
+  Revision 1.5  2004/02/21 19:07:45  alextingle
+  Corrected servants to use POA instead of BOA.
+
+  Revision 1.4  2004/02/04 22:29:55  alextingle
+  Reworked all C++ examples.
+  Removed catch(...) as it tends to make it harder to see what's going on.
+  Now uses POA instead of BOA.
+  Uses omniORB4's Exception name probing.
+  No longer uses 'naming.h/cc' utility code.
+
+  Revision 1.3  2003/11/03 22:19:25  alextingle
+  Removed all platform specific switches. Now uses autoconf, config.h.
+  Removed stub header in order to allow makefile dependency checking to work
+  correctly.
+  Changed int to bool where appropriate.
+
+  Revision 1.1.1.1.2.1  2002/09/28 22:20:51  shamus13
+  Added ifdefs to enable omniEvents to compile
+  with both omniORB3 and omniORB4. If __OMNIORB4__
+  is defined during compilation, omniORB4 headers
+  and command line option syntax is used, otherwise
+  fall back to omniORB3 style.
+
+  Revision 1.1.1.1  2002/09/25 19:00:26  shamus13
+  Import of OmniEvents source tree from release 2.1.1
+
+  Revision 0.14  2000/10/11 01:16:21  naderp
+  *** empty log message ***
+
+  Revision 0.13  2000/08/30 04:39:48  naderp
+  Port to omniORB 3.0.1.
+
+  Revision 0.12  2000/03/16 05:37:27  naderp
+  Added stdlib.h for getopt.
+
+  Revision 0.11  2000/03/06 13:27:10  naderp
+  Using util getRootNamingContext function.
+  Using stub headers.
+  Fixed error messages.
+
+  Revision 0.10  2000/03/02 03:21:20  naderp
+  Added -r option to connect using nil reference.
+  Added retry resiliency for handling COMM_FAUILURE exceptions.
+
+Revision 0.9  99/11/02  13:39:17  13:39:17  naderp (Paul Nader)
+Added <signal.h>
+
+  Revision 0.8  1999/11/02 07:57:18  naderp
+  Updated usage.
+
+Revision 0.7  99/11/01  19:22:43  19:22:43  naderp (Paul Nader)
+Added catch for COMM_FAILURE exception in obtain_push_consumer
+and disconnect_push_consumer calls.
+
+Revision 0.6  99/11/01  16:12:03  16:12:03  naderp (Paul Nader)
+omniEvents 2.0 Release.
+
+Revision 0.5  99/10/27  19:42:31  19:42:31  naderp (Paul Nader)
+Ignoring Unix SIGPIPE signal.
+Reporting sleep beforhand.
+
+Revision 0.4  99/04/23  16:05:47  16:05:47  naderp (Paul Nader)
+gcc port.
+
+Revision 0.3  99/04/23  09:34:04  09:34:04  naderp (Paul Nader)
+Windows Port.
+
+Revision 0.2  99/04/21  18:06:26  18:06:26  naderp (Paul Nader)
+*** empty log message ***
+
+Revision 0.1.1.1  98/11/27  16:59:40  16:59:40  naderp (Paul Nader)
+Added -s option to sleep after disconnecting.
+
+Revision 0.1  98/11/25  14:08:25  14:08:25  naderp (Paul Nader)
+Initial Revision
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#ifdef HAVE_GETOPT
+#  include <unistd.h>
+extern char* optarg;
+extern int optind;
+#else
+#  include "getopt.h"
+#endif
+
+#ifdef HAVE_IOSTREAM
+#  include <iostream>
+#else
+#  include <iostream.h>
+#endif
+
+#ifdef HAVE_STD_IOSTREAM
+using namespace std;
+#endif
+
+#ifdef HAVE_STDLIB_H
+#  include <stdlib.h>
+#endif
+
+#ifdef HAVE_SIGNAL_H
+#  include <signal.h>
+#endif
+
+#include <cstdio>
+
+#include "CosEventComm.hh"
+#include "CosEventChannelAdmin.hh"
+#include "naming.h"
+
+static void usage(int argc, char **argv);
+
+class Supplier_i : virtual public POA_CosEventComm::PushSupplier {
+public:
+  Supplier_i () {};
+  void disconnect_push_supplier ();
+};
+
+void
+Supplier_i::disconnect_push_supplier () {
+  cout << "Push Supplier: disconnected." << endl;
+}
+
+int main (int argc, char** argv)
+{
+  long l = 0;
+  CORBA::ORB_ptr orb = CORBA::ORB_init(argc,argv);
+
+  // Process Options
+  int         discnum       =0;
+  bool        refnil        =false;
+  int         sleepInterval =0;
+  const char* channelName   ="EventChannel";
+
+  int c;
+  while ((c = getopt(argc,argv,"d:rs:n:h")) != EOF)
+  {
+     switch (c)
+     {
+        case 'd': discnum = atoi(optarg);
+                  break;
+
+        case 'r': refnil = true;
+                  break;
+
+        case 's': sleepInterval = atoi(optarg);
+                  break;
+
+        case 'n': channelName = optarg;
+                  break;
+
+        case 'h':
+        default : usage(argc,argv);
+                  exit(-1);
+                  break;
+     }
+  }
+
+#if defined(HAVE_SIGNAL_H) && defined(SIGPIPE)
+  // Ignore broken pipes
+  signal(SIGPIPE, SIG_IGN);
+#endif
+
+  Supplier_i* supplier = NULL;
+  CosEventChannelAdmin::EventChannel_var channel;
+
+  const char* action=""; // Use this variable to help report errors.
+  try {
+    CORBA::Object_var obj;
+
+    // A Push Supplier can be implemented as a pure client or as a mixed
+    // client-server process, depending on whether it requires and is
+    // prepared to service disconnect requests from the channel.
+    // If it is then create the servant object and activate the POA.
+    if(!refnil)
+    {
+      supplier=new Supplier_i();
+
+      action="resolve initial reference 'RootPOA'";
+      obj=orb->resolve_initial_references("RootPOA");
+      PortableServer::POA_var rootPoa =PortableServer::POA::_narrow(obj);
+      if(CORBA::is_nil(rootPoa))
+          throw CORBA::OBJECT_NOT_EXIST();
+
+      action="activate the RootPOA's POAManager";
+      PortableServer::POAManager_var pman =rootPoa->the_POAManager();
+      pman->activate();
+    }
+
+    //
+    // Obtain object reference to EventChannel
+    // (from command-line argument or from the Naming Service).
+    if(optind<argc)
+    {
+      action="convert URI from command line into object reference";
+      obj=orb->string_to_object(argv[optind]);
+    }
+    else
+    {
+      action="resolve initial reference 'NameService'";
+      obj=orb->resolve_initial_references("NameService");
+      CosNaming::NamingContext_var rootContext=
+        CosNaming::NamingContext::_narrow(obj);
+      if(CORBA::is_nil(rootContext))
+          throw CORBA::OBJECT_NOT_EXIST();
+
+      action="find EventChannel in NameService";
+      cout << action << endl;
+      obj=rootContext->resolve(str2name(channelName));
+    }
+
+    action="narrow object reference to event channel";
+    channel=CosEventChannelAdmin::EventChannel::_narrow(obj);
+    if(CORBA::is_nil(channel))
+    {
+       cerr << "Failed to narrow Event Channel reference." << endl;
+       exit(1);
+    }
+
+  }
+  catch(CORBA::ORB::InvalidName& ex) { // resolve_initial_references
+     cerr<<"Failed to "<<action<<". ORB::InvalidName"<<endl;
+     exit(1);
+  }
+  catch(CosNaming::NamingContext::InvalidName& ex) { // resolve
+     cerr<<"Failed to "<<action<<". NamingContext::InvalidName"<<endl;
+     exit(1);
+  }
+  catch(CosNaming::NamingContext::NotFound& ex) { // resolve
+     cerr<<"Failed to "<<action<<". NamingContext::NotFound"<<endl;
+     exit(1);
+  }
+  catch(CosNaming::NamingContext::CannotProceed& ex) { // resolve
+     cerr<<"Failed to "<<action<<". NamingContext::CannotProceed"<<endl;
+     exit(1);
+  }
+  catch(CORBA::TRANSIENT& ex) { // _narrow()
+     cerr<<"Failed to "<<action<<". TRANSIENT"<<endl;
+     exit(1);
+  }
+  catch(CORBA::OBJECT_NOT_EXIST& ex) { // _narrow()
+     cerr<<"Failed to "<<action<<". OBJECT_NOT_EXIST"<<endl;
+     exit(1);
+  }
+  catch(CORBA::SystemException& ex) {
+     cerr<<"Failed to "<<action<<".";
+#if defined(HAVE_OMNIORB4)
+     cerr<<" "<<ex._name();
+     if(ex.NP_minorString())
+         cerr<<" ("<<ex.NP_minorString()<<")";
+#endif
+     cerr<<endl;
+     exit(1);
+  }
+  catch(CORBA::Exception& ex) {
+     cerr<<"Failed to "<<action<<"."
+#if defined(HAVE_OMNIORB4)
+       " "<<ex._name()
+#endif
+       <<endl;
+     exit(1);
+  }
+
+  //
+  // Get Supplier Admin interface - retrying on Comms Failure.
+  CosEventChannelAdmin::SupplierAdmin_var supplier_admin;
+  while (1)
+  {
+     try {
+        supplier_admin = channel->for_suppliers ();
+        if (CORBA::is_nil(supplier_admin))
+        {
+           cerr << "Event Channel returned nil Supplier Admin!"
+                << endl;
+           exit(1);
+        }
+        break;
+     }
+     catch (CORBA::COMM_FAILURE& ex) {
+        cerr << "Caught COMM_FAILURE Exception "
+             << "obtaining Supplier Admin! Retrying..."
+             << endl;
+        continue;
+     }
+  }
+  cout << "Obtained SupplierAdmin." << endl;
+
+  while (1)
+  {
+     //
+     // Get proxy consumer - retrying on Comms Failure.
+     CosEventChannelAdmin::ProxyPushConsumer_var proxy_consumer;
+     while (1)
+     {
+        try {
+           proxy_consumer = supplier_admin->obtain_push_consumer ();
+           if (CORBA::is_nil(proxy_consumer))
+           {
+              cerr << "Supplier Admin returned nil proxy_consumer!"<< endl;
+              exit(1);
+           }
+           break;
+        }
+        catch (CORBA::COMM_FAILURE& ex) {
+           cerr << "Caught COMM_FAILURE Exception "
+                << "obtaining Proxy Push Consumer! Retrying..."
+                << endl;
+           continue;
+        }
+     }
+     cout << "Obtained ProxyPushConsumer." << endl;
+   
+     //
+     // Connect Push Supplier - retrying on Comms Failure.
+     CosEventComm::PushSupplier_var sptr =CosEventComm::PushSupplier::_nil();
+     if (! refnil) {
+        sptr = supplier->_this();
+     }
+
+     while (1)
+     {
+        try {
+           proxy_consumer->connect_push_supplier(sptr.in());
+           break;
+        }
+        catch (CORBA::BAD_PARAM& ex) {
+           cerr << "Caught BAD_PARAM Exception connecting Push Supplier!"
+                << endl;
+           exit (1);
+        }
+        catch (CosEventChannelAdmin::AlreadyConnected& ex) {
+           cerr << "Proxy Push Consumer already connected!"
+                << endl;
+           break;
+        }
+        catch (CORBA::COMM_FAILURE& ex) {
+           cerr << "Caught COMM_FAILURE Exception "
+                << "connecting Push Supplier! Retrying..."
+                << endl;
+           continue;
+        }
+     }
+     cout << "Connected Push Supplier." << endl;
+   
+     // Push data.
+     for (int i=0; (discnum == 0) || (i < discnum); i++)
+     {
+        CORBA::Any any;
+        any <<= (CORBA::ULong) l++;
+        try {
+           cout << "Push Supplier: push() called. " << flush;
+           proxy_consumer->push(any);
+           cout << "Data : " << l-1 << endl;
+        }
+        catch(CosEventComm::Disconnected&) {
+           cout << "Failed. Caught Disconnected Exception!" << endl;
+        }
+        catch(CORBA::COMM_FAILURE&) {
+           cout << "Failed. Caught COMM_FAILURE Exception!" << endl;
+        }
+     }
+   
+     // Disconnect - retrying on Comms Failure.
+     while (1)
+     {
+        try {
+           proxy_consumer->disconnect_push_consumer();
+           break;
+        }
+        catch (CORBA::COMM_FAILURE& ex) {
+           cerr << "Caught COMM_FAILURE Exception "
+                << "disconnecting Push Supplier! Retrying..."
+                << endl;
+           continue;
+        }
+     }
+     cout << "ProxyPushConsumer disconnected." << endl;
+
+     // Yawn.
+     cout << "Sleeping " << sleepInterval << " seconds." << endl;
+     omni_thread::sleep(sleepInterval);
+  }
+
+  // Not Reached
+  return 0;
+}
+
+static void
+usage(int argc, char **argv)
+{
+  cerr<<
+"\nCreate a PushSupplier to send events to a channel.\n"
+"syntax: "<<(argc?argv[0]:"pushsupp")<<" OPTIONS [CHANNEL_URI]\n"
+"\n"
+"CHANNEL_URI: The event channel may be specified as a URI.\n"
+" This may be an IOR, or a corbaloc::: or corbaname::: URI.\n"
+"\n"
+"OPTIONS:                                         DEFAULT:\n"
+" -d NUM   disconnect after sending NUM events     [0 - never disconnect]\n"
+" -r       connect using a nil reference\n"
+" -s SECS  sleep SECS seconds after disconnecting  [0]\n"
+" -n NAME  channel name (if URI is not specified)  [\"EventChannel\"]\n"
+" -h       display this help text\n" << endl;
+}

Added: trunk/omnievents/tools/eventc.cc
URL: http://svn.debian.org/wsvn/pkg-corba/trunk/omnievents/tools/eventc.cc?rev=200&op=file
==============================================================================
--- trunk/omnievents/tools/eventc.cc (added)
+++ trunk/omnievents/tools/eventc.cc Fri Dec 25 19:19:31 2009
@@ -1,0 +1,475 @@
+// -*- Mode: C++; -*-
+//                            Package   : omniEvents
+// eventc.cc                  Created   : 1/4/98
+//                            Author    : Paul Nader (pwn)
+//
+//    Copyright (C) 1998 Paul Nader.
+//
+//    This file is part of the omniEvents application.
+//
+//    omniEvents is free software; you can redistribute it and/or
+//    modify it under the terms of the GNU Lesser General Public
+//    License as published by the Free Software Foundation; either
+//    version 2.1 of the License, or (at your option) any later version.
+//
+//    omniEvents is distributed in the hope that it will be useful,
+//    but WITHOUT ANY WARRANTY; without even the implied warranty of
+//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//    Lesser General Public License for more details.
+//
+//    You should have received a copy of the GNU Lesser General Public
+//    License along with this library; if not, write to the Free Software
+//    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+//
+// Description:
+//    Client to the event channel factory. Requests creation of an event
+//    channel and registers it with the Naming service.
+//	
+
+/*
+  $Log: eventc.cc,v $
+  Revision 1.4.2.2  2005/04/27 20:49:32  alextingle
+  Merge across changes from HEAD branch (see CHANGES_262. Change version number ready for release 2.6.2.
+
+  Revision 1.4.2.1  2004/11/01 12:27:12  alextingle
+  New EventChannel parameter `PullRetryPeriod_ms' supercedes `PullRetryPeriod'.
+  The new parameter is set by `eventc -R'. The old parameter and its `-r'
+  option still work as before, for backwards compatibility.
+
+  Revision 1.4  2004/10/08 09:06:19  alextingle
+  More robust exception minor code handling.
+
+  Revision 1.3  2004/08/06 16:16:40  alextingle
+  Simplified call to ORB_init().
+
+  Revision 1.2  2004/08/04 21:52:52  alextingle
+  'n' & 'N' options now take a full name path. No more 'k' or 'K' options.
+
+  Revision 1.1  2004/05/31 10:29:37  alextingle
+  New 'tools' directory. Contains useful command line tools that previously lived in the 'examples' directory.
+
+  Revision 1.14  2004/05/28 10:38:23  alextingle
+  Now uses new omniEvents.idl header. Properly this time!
+
+  Revision 1.13  2004/05/28 10:16:54  alextingle
+  Now uses new omniEvents.idl header.
+
+  Revision 1.12  2004/04/30 17:48:02  alextingle
+  New 'real time push' feature: -t option.
+
+  Revision 1.11  2004/04/21 10:23:46  alextingle
+  If there is no Naming Service, eventc only issues a warning unless it is needed to find the factory, or options -n or -k are set.
+
+  Revision 1.10  2004/04/20 16:51:59  alextingle
+  All examples updated for latest version on omniEvents. Server may now be
+  specified as a 'corbaloc' string or IOR, instead of as naming service id/kind.
+
+  Revision 1.9  2004/03/28 00:58:05  alextingle
+  New options. -c sets CyclePeriod_ns. -i sets the Channel's InsName.
+
+  Revision 1.8  2004/03/26 16:06:30  alextingle
+  Added verbose (-v) option that prints the new channel's IOR to standard out.
+
+  Revision 1.7  2004/02/20 17:41:40  alextingle
+  Moved 'endl;' to the actual end!!
+
+  Revision 1.6  2004/02/20 14:01:54  alextingle
+  New param: -p sets MaxNumProxies for omniEvents 2.5+.
+  No longer sends parameters that are not explicitly set on
+  the command line. This leaves the server to decide upon
+  default values.
+
+  Revision 1.5  2004/02/04 22:29:55  alextingle
+  Reworked all C++ examples.
+  Removed catch(...) as it tends to make it harder to see what's going on.
+  Now uses POA instead of BOA.
+  Uses omniORB4's Exception name probing.
+  No longer uses 'naming.h/cc' utility code.
+
+  Revision 1.4  2003/12/21 11:12:01  alextingle
+  Most exceptions are now caught by a unified catch block.
+
+  Revision 1.3  2003/11/03 22:21:21  alextingle
+  Removed all platform specific switches. Now uses autoconf, config.h.
+  Removed stub header in order to allow makefile dependency checking to work
+  correctly.
+
+  Revision 1.1.1.1.2.1  2002/09/28 22:20:51  shamus13
+  Added ifdefs to enable omniEvents to compile
+  with both omniORB3 and omniORB4. If __OMNIORB4__
+  is defined during compilation, omniORB4 headers
+  and command line option syntax is used, otherwise
+  fall back to omniORB3 style.
+
+  Revision 1.1.1.1  2002/09/25 19:00:25  shamus13
+  Import of OmniEvents source tree from release 2.1.1
+
+  Revision 1.6  2000/09/05 01:05:38  naderp
+  Added MaxQueueLength QOS.
+
+  Revision 1.5  2000/08/30 04:39:20  naderp
+  Port to omniORB 3.0.1.
+
+  Revision 1.4  2000/03/16 05:34:30  naderp
+  Added stdlib.h for solaris getopt()
+
+  Revision 1.3  2000/03/16 02:44:13  naderp
+  Added iostream and signal headers.
+
+  Revision 1.2  2000/03/06 13:23:50  naderp
+  Using util getRootNamingContext function.
+  Using stub headers.
+
+  Revision 1.1  1999/11/01 20:37:42  naderp
+  Updated usage statement.
+
+Revision 1.0  99/11/01  17:05:13  17:05:13  naderp (Paul Nader)
+omniEvents 2.0.
+Added -m switch to support MaxEventsPerConsumer criteria.
+
+Revision 0.6  99/08/27  11:48:22  11:48:22  naderp (Paul Nader)
+Partitioned EventChannelFactory_i from CosEvent_i.
+
+Revision 0.5  99/05/10  11:27:50  11:27:50  naderp (Paul Nader)
+Initialised rootContext.
+
+Revision 0.4  99/04/23  16:02:22  16:02:22  naderp (Paul Nader)
+gcc port.
+
+Revision 0.3  99/04/23  09:32:58  09:32:58  naderp (Paul Nader)
+Windows Port.
+
+Revision 0.2  99/04/21  18:06:23  18:06:23  naderp (Paul Nader)
+*** empty log message ***
+
+Revision 0.1.1.1  98/11/27  17:01:51  17:01:51  naderp (Paul Nader)
+Enclosed supports call in try block to avoid core dump.
+Added information messages for exceptions.
+
+Revision 0.1  98/11/25  14:07:22  14:07:22  naderp (Paul Nader)
+Initial Revision
+
+*/
+
+//
+//
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#ifdef HAVE_GETOPT
+#  include <unistd.h>
+extern char* optarg;
+extern int optind;
+#else
+#  include "getopt.h"
+#endif
+
+#ifdef HAVE_IOSTREAM
+#  include <iostream>
+#else
+#  include <iostream.h>
+#endif
+
+#ifdef HAVE_STD_IOSTREAM
+using namespace std;
+#endif
+
+#ifdef HAVE_STDLIB_H
+#  include <stdlib.h>
+#endif
+
+#ifdef HAVE_SIGNAL_H
+#  include <signal.h>
+#endif
+
+#include <cstdio>
+
+#include "omniEvents.hh"
+#include "naming.h"
+
+static void usage(int argc, char **argv);
+static void appendCriterion(   CosLifeCycle::Criteria&,const char*,const char*);
+static void appendCriterionStr(CosLifeCycle::Criteria&,const char*,const char*);
+
+int
+main(int argc, char **argv)
+{
+  int result =1;
+
+  //
+  // Start orb.
+  CORBA::ORB_var orb = CORBA::ORB_init(argc,argv);
+
+  // Process Options
+  bool verbose =false;
+  bool needNameService =false;
+  const char* channelName ="EventChannel";
+  const char* factoryName ="EventChannelFactory";
+  CosLifeCycle::Criteria criteria;
+
+  int c;
+  while ((c = getopt(argc,argv,"n:N:m:c:i:p:q:R:r:t:vh")) != EOF)
+  {
+     switch (c)
+     {
+     case 'n':
+       channelName=optarg;
+       needNameService=true;       
+       break;
+
+     case 'N':
+       factoryName=optarg;
+       break;
+
+     case 'm': // OLD OPTION
+       appendCriterion(criteria,"MaxEventsPerConsumer",optarg);
+       break;
+
+     case 'c':
+       appendCriterion(criteria,"CyclePeriod_ns",optarg);
+       break;
+
+     case 'i':
+       appendCriterionStr(criteria,"InsName",optarg);
+       break;
+
+     case 'p':
+       appendCriterion(criteria,"MaxNumProxies",optarg);
+       break;
+
+     case 'q':
+       appendCriterion(criteria,"MaxQueueLength",optarg);
+       break;
+
+     case 'R':
+       appendCriterion(criteria,"PullRetryPeriod_ms",optarg);
+       break;
+
+     case 'r': // This option is deprecated in favour of -R:
+       appendCriterion(criteria,"PullRetryPeriod",optarg);
+       break;
+
+     case 't':
+       appendCriterionStr(criteria,"FilterId",optarg);
+       break;
+
+     case 'v':
+       verbose=true;
+       break;
+
+     case 'h':
+       usage(argc,argv);
+       exit(0);
+
+     default :
+       usage(argc,argv);
+       exit(-1);
+     }
+  }
+  // Need the naming service to find the factory if there is no URI argument.
+  needNameService=(needNameService || optind>=argc);
+
+  //
+  // Use one big try...catch block.
+  // 'action' variable keeps track of what we're doing.
+  const char* action ="start";
+  try
+  {
+    CORBA::Object_var obj;
+
+    //
+    // Get Name Service root context.(we can carry on without it though)
+    CosNaming::NamingContext_var rootContext=CosNaming::NamingContext::_nil();
+    try {
+      action="resolve initial reference 'NameService'";
+      obj=orb->resolve_initial_references("NameService");
+      rootContext=CosNaming::NamingContext::_narrow(obj);
+      if(CORBA::is_nil(rootContext))
+          throw CORBA::OBJECT_NOT_EXIST();
+    }
+    catch (CORBA::Exception& ex) {
+       if(needNameService)
+           throw;
+       else
+           cerr<<"Warning - failed to "<<action<<"."<<endl;
+    }
+
+    //
+    // Obtain reference to the Event Channel Factory implementation.
+    // (from command-line argument or from the Naming Service).
+    if(optind<argc)
+    {
+      action="convert URI from command line into object reference";
+      obj=orb->string_to_object(argv[optind]);
+    }
+    else
+    {
+      action="find Event Channel Factory in naming service";
+      obj=rootContext->resolve(str2name(factoryName));
+    }
+
+    action="narrow object reference to event channel factory";
+    omniEvents::EventChannelFactory_var factory =
+      omniEvents::EventChannelFactory::_narrow(obj);
+    if(CORBA::is_nil(factory))
+    {
+       cerr << "Failed to narrow Event Channel Factory reference." << endl;
+       exit(1);
+    }
+
+    // Check that the factory is of the right type
+    action="check factory supports EventChannel object interface";
+    CosLifeCycle::Key key;
+    key.length (1);
+    key[0].id = CORBA::string_dup("EventChannel");
+    key[0].kind = CORBA::string_dup("object interface");
+
+    if(!factory->supports(key))
+    {
+      cerr << "Factory does not support Event Channel Interface! [\""
+           << factoryName << "\"]" << endl;
+      exit(1);
+    }
+
+    //
+    // Create Event Channel Object.
+    action="create EventChannel object";
+    CORBA::Object_var channelObj =factory->create_object(key, criteria);
+    if (CORBA::is_nil(channelObj))
+    {
+       cerr << "Channel Factory returned nil reference! [\""
+            << channelName << "\"]" << endl;
+       exit(1);
+    }
+
+    // Narrow object returned to an Event Channel
+    CosEventChannelAdmin::EventChannel_var channel =
+      CosEventChannelAdmin::EventChannel::_narrow(channelObj);
+    if (CORBA::is_nil(channel))
+    {
+       cerr << "Failed to narrow Event Channel! [\""
+            << channelName << "\"]" << endl;
+       exit(1);
+    }
+    
+    // Print the new EventChannel's IOR to standard output.
+    if(verbose)
+    {
+      CORBA::String_var sior =orb->object_to_string(channel);
+      cout<<sior.in()<<endl;
+    }
+
+    //
+    // Register event channel with naming service
+    if(!CORBA::is_nil(rootContext))
+    {
+      CosNaming::Name name =str2name(channelName);
+      try{
+        action="register (bind) EventChannel with the naming service";
+        rootContext->bind(name,channel.in());
+      }
+      catch(CosNaming::NamingContext::AlreadyBound& ex) {
+        action="register (rebind) EventChannel with the naming service";
+        rootContext->rebind(name,channel.in());
+      }
+    }
+    
+    //
+    // Clean up nicely.
+    action="destroy orb";
+    orb->destroy();
+    
+    //
+    // If we get here, then everything has worked OK.
+    result=0;
+
+  }
+  catch (CosLifeCycle::NoFactory& ex) /* create_object() */ {
+     cerr<<"Failed to create Event Channel: NoFactory"
+       " (interface not supported) "<<endl;
+  }
+  catch (CosLifeCycle::CannotMeetCriteria& ex) /* create_object() */ {
+     cerr<<"Failed to create Event Channel: CannotMeetCriteria "<<endl;
+  }
+  catch (CosLifeCycle::InvalidCriteria& ex) /* create_object() */ {
+     cerr<<"Failed to create Event Channel: InvalidCriteria "<<endl;
+  }
+  catch (CORBA::COMM_FAILURE& ex) {
+     cerr<<"System exception, unable to "<<action<<": COMM_FAILURE"<<endl;
+  }
+  catch (CORBA::SystemException& ex) {
+     cerr<<"System exception, unable to "<<action;
+#if defined(HAVE_OMNIORB4)
+     cerr<<" "<<ex._name();
+     if(ex.NP_minorString())
+         cerr<<" ("<<ex.NP_minorString()<<")";
+#endif
+     cerr<<endl;
+  }
+  catch (CORBA::Exception& ex) {
+     cerr<<"CORBA exception, unable to "<<action
+#ifdef HAVE_OMNIORB4
+         <<": "<<ex._name()
+#endif
+         << endl;
+  }
+  catch (omniORB::fatalException& ex) {
+     cerr<<"Fatal Exception, unable to "<<action<<endl;
+  }
+
+  return result;
+}
+
+static void
+usage(int argc, char **argv)
+{
+  cerr<<
+"\nCreate an EventChannel and register it in the naming service.\n"
+"syntax: "<<(argc?argv[0]:"eventc")<<" OPTIONS [FACTORY_URI]\n"
+"\n"
+"FACTORY_URI: The factory may be specified as a URI.\n"
+" This may be an IOR, or a corbaloc::: or corbaname::: URI.\n"
+" For example: corbaloc::localhost:11169/omniEvents\n"
+"\n"
+"OPTIONS:                                         DEFAULT:\n"
+" -n channel name                                  [\"EventChannel\"]\n"
+" -N factory name (if URI is not specified)        [\"EventChannelFactory\"]\n"
+" -c override default CyclePeriod_ns of new channel (nanoseconds)\n"
+" -i set the InsName of new channel, to enable access via corbaloc\n"
+" -p override default MaxNumProxies of new channel\n"
+" -q override default MaxQueueLength of new channel\n"
+" -R override default PullRetryPeriod_ms for new channel (milliseconds)\n"
+" -t set an event type filter, FilterId=<RepositoryId>\n"
+" -v print the IOR of the new EventChannel to standard output.\n"
+" -h display this help text\n"
+"OLD OPTIONS: (only used by omniEvents v2.4 and earlier)\n"
+" -m override default MaxEventsPerConsumer for new channel\n" << endl;
+}
+
+static void appendCriterion(
+  CosLifeCycle::Criteria& criteria,
+  const char* name,
+  const char* value
+)
+{
+  CORBA::ULong criteriaLen =criteria.length();
+  ++criteriaLen;
+  criteria.length(criteriaLen);
+  criteria[criteriaLen-1].name=CORBA::string_dup(name);
+  criteria[criteriaLen-1].value<<=CORBA::ULong(atol(value));
+}
+
+static void appendCriterionStr(
+  CosLifeCycle::Criteria& criteria,
+  const char* name,
+  const char* value
+)
+{
+  CORBA::ULong criteriaLen =criteria.length();
+  ++criteriaLen;
+  criteria.length(criteriaLen);
+  criteria[criteriaLen-1].name=CORBA::string_dup(name);
+  criteria[criteriaLen-1].value<<=value;
+}

Added: trunk/omnievents/tools/eventf.cc
URL: http://svn.debian.org/wsvn/pkg-corba/trunk/omnievents/tools/eventf.cc?rev=200&op=file
==============================================================================
--- trunk/omnievents/tools/eventf.cc (added)
+++ trunk/omnievents/tools/eventf.cc Fri Dec 25 19:19:31 2009
@@ -1,0 +1,195 @@
+//                            Package   : omniEvents
+// eventf.cc                  Created   : 2004-05-30
+//                            Author    : Alex Tingle
+//
+//    Copyright (C) 2004 Alex Tingle
+//
+//    This file is part of the omniEvents application.
+//
+//    omniEvents is free software; you can redistribute it and/or
+//    modify it under the terms of the GNU Lesser General Public
+//    License as published by the Free Software Foundation; either
+//    version 2.1 of the License, or (at your option) any later version.
+//
+//    omniEvents is distributed in the hope that it will be useful,
+//    but WITHOUT ANY WARRANTY; without even the implied warranty of
+//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//    Lesser General Public License for more details.
+//
+//    You should have received a copy of the GNU Lesser General Public
+//    License along with this library; if not, write to the Free Software
+//    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+//
+// Description:
+//    Destroys the named EventChannel.
+//	
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#ifdef HAVE_GETOPT
+#  include <unistd.h>
+extern char* optarg;
+extern int optind;
+#else
+#  include "getopt.h"
+#endif
+
+#ifdef HAVE_STDLIB_H
+#  include <stdlib.h> // exit()
+#endif
+
+#ifdef HAVE_IOSTREAM
+#  include <iostream>
+#else
+#  include <iostream.h>
+#endif
+
+#include <cstdio>
+
+#ifdef HAVE_STD_IOSTREAM
+using namespace std;
+#endif
+
+#include "CosEventChannelAdmin.hh"
+
+static void usage(int argc, char **argv);
+static CosEventChannelAdmin::EventChannel_ptr getChannel(const char* sior);
+
+CORBA::ORB_ptr orb;
+
+int
+main(int argc, char **argv)
+{
+  int result =1;
+
+  //
+  // Start orb.
+#if defined(HAVE_OMNIORB4)
+  orb=CORBA::ORB_init(argc,argv,"omniORB4");
+#else
+  orb=CORBA::ORB_init(argc,argv,"omniORB3");
+#endif
+
+  // Process Options
+  int c;
+
+  while((c = getopt(argc,argv,"h")) != EOF)
+  {
+    switch (c)
+    {
+      case 'h': usage(argc,argv);
+                exit(0);
+
+      default : usage(argc,argv);
+                exit(-1);
+    }
+  }
+
+  if(optind!=argc-2)
+  {
+    usage(argc,argv);
+    exit(-1);
+  }
+
+  //
+  // Use one big try...catch block.
+  // 'action' variable keeps track of what we're doing.
+  const char* action ="start";
+  try
+  {
+    using namespace CosEventChannelAdmin;
+
+    action="convert URI into reference to source channel";
+    EventChannel_var from_channel =getChannel(argv[optind]);
+
+    action="convert URI into reference to destination channel";
+    EventChannel_var to_channel   =getChannel(argv[optind+1]);
+
+    action="obtain ConsumerAdmin";
+    ConsumerAdmin_var cadmin =from_channel->for_consumers();
+
+    action="obtain ProxyPushSupplier";
+    ProxyPushSupplier_var supplier =cadmin->obtain_push_supplier();
+
+    action="obtain SupplierAdmin";
+    SupplierAdmin_var sadmin =to_channel->for_suppliers();
+
+    action="obtain ProxyPushConsumer";
+    ProxyPushConsumer_var consumer =sadmin->obtain_push_consumer();
+
+    action="connect PushConsumer";
+    consumer->connect_push_supplier(supplier.in());
+
+    action="connect PushSupplier";
+    supplier->connect_push_consumer(consumer.in());
+
+    //
+    // Clean up nicely.
+    action="destroy orb";
+    orb->destroy();
+
+    //
+    // If we get here, then everything has worked OK.
+    result=0;
+
+  }
+  catch(CORBA::TRANSIENT& ex) { // _narrow()
+     cerr<<"Failed to "<<action<<". TRANSIENT"<<endl;
+  }
+  catch(CORBA::OBJECT_NOT_EXIST& ex) { // _narrow()
+     cerr<<"Failed to "<<action<<". OBJECT_NOT_EXIST"<<endl;
+  }
+  catch(CORBA::SystemException& ex) {
+     cerr<<"Failed to "<<action<<".";
+#if defined(HAVE_OMNIORB4)
+     cerr<<" "<<ex._name();
+     if(ex.NP_minorString())
+         cerr<<" ("<<ex.NP_minorString()<<")";
+#endif
+     cerr<<endl;
+  }
+  catch(CORBA::Exception& ex) {
+     cerr<<"Failed to "<<action<<"."
+#if defined(HAVE_OMNIORB4)
+       " "<<ex._name()
+#endif
+       <<endl;
+  }
+
+  return result;
+}
+
+
+static void
+usage(int argc, char **argv)
+{
+  cerr<<
+"\nConnect (federate) two event channels.\n"
+"syntax: "<<(argc?argv[0]:"eventf")<<" OPTIONS [FROM_CHANNEL] [TO_CHANNEL]\n"
+"\n"
+"FROM/TO_CHANNEL: The event channels must be specified as a URI.\n"
+" This may be an IOR, or a corbaloc::: or corbaname::: URI.\n"
+"\n"
+"OPTIONS:\n"
+" -h  display this help text\n" << endl;
+}
+
+
+//
+// Obtain object reference to EventChannel
+static CosEventChannelAdmin::EventChannel_ptr
+getChannel(const char* sior)
+{
+  // convert URI from command line into object reference";
+  CORBA::Object_var obj =orb->string_to_object(sior);
+
+  // narrow object reference to event channel";
+  CosEventChannelAdmin::EventChannel_var channel =
+    CosEventChannelAdmin::EventChannel::_narrow(obj);
+  if(CORBA::is_nil(channel))
+      throw CORBA::OBJECT_NOT_EXIST();
+  
+  return channel._retn();
+}

Added: trunk/omnievents/tools/rmeventc.cc
URL: http://svn.debian.org/wsvn/pkg-corba/trunk/omnievents/tools/rmeventc.cc?rev=200&op=file
==============================================================================
--- trunk/omnievents/tools/rmeventc.cc (added)
+++ trunk/omnievents/tools/rmeventc.cc Fri Dec 25 19:19:31 2009
@@ -1,0 +1,204 @@
+//                            Package   : omniEvents
+// rmeventc.cc                Created   : 2003/12/21
+//                            Author    : Alex Tingle
+//
+//    Copyright (C) 2003 Alex Tingle
+//
+//    This file is part of the omniEvents application.
+//
+//    omniEvents is free software; you can redistribute it and/or
+//    modify it under the terms of the GNU Lesser General Public
+//    License as published by the Free Software Foundation; either
+//    version 2.1 of the License, or (at your option) any later version.
+//
+//    omniEvents is distributed in the hope that it will be useful,
+//    but WITHOUT ANY WARRANTY; without even the implied warranty of
+//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//    Lesser General Public License for more details.
+//
+//    You should have received a copy of the GNU Lesser General Public
+//    License along with this library; if not, write to the Free Software
+//    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+//
+// Description:
+//    Destroys the named EventChannel.
+//	
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#ifdef HAVE_GETOPT
+#  include <unistd.h>
+extern char* optarg;
+extern int optind;
+#else
+#  include "getopt.h"
+#endif
+
+#ifdef HAVE_STDLIB_H
+#  include <stdlib.h> // exit()
+#endif
+
+#ifdef HAVE_IOSTREAM
+#  include <iostream>
+#else
+#  include <iostream.h>
+#endif
+
+#include <cstdio>
+
+#ifdef HAVE_STD_IOSTREAM
+using namespace std;
+#endif
+
+#include "CosEventChannelAdmin.hh"
+#include "naming.h"
+
+static void usage(int argc, char **argv);
+
+int
+main(int argc, char **argv)
+{
+  int result =1;
+
+  //
+  // Start orb.
+#if defined(HAVE_OMNIORB4)
+  CORBA::ORB_ptr orb = CORBA::ORB_init(argc,argv,"omniORB4");
+#else
+  CORBA::ORB_ptr orb = CORBA::ORB_init(argc,argv,"omniORB3");
+#endif
+
+  // Process Options
+  int c;
+
+  CosNaming::Name ecName =str2name("EventChannel");
+
+  while ((c = getopt(argc,argv,"n:h")) != EOF)
+  {
+     switch (c)
+     {
+        case 'n': ecName=str2name(optarg);
+                  break;
+
+        case 'h': usage(argc,argv);
+                  exit(0);
+
+        default : usage(argc,argv);
+                  exit(-1);
+     }
+  }
+
+  //
+  // Use one big try...catch block.
+  // 'action' variable keeps track of what we're doing.
+  const char* action ="start";
+  try
+  {
+    CORBA::Object_var obj;
+    
+    //
+    // Obtain object reference to EventChannel
+    // (from command-line argument or from the Naming Service).
+    if(optind<argc)
+    {
+      action="convert URI from command line into object reference";
+      obj=orb->string_to_object(argv[optind]);
+    }
+    else
+    {
+      //
+      // Get Name Service root context.
+      action="resolve initial reference 'NameService'";
+      obj=orb->resolve_initial_references("NameService");
+      CosNaming::NamingContext_var rootContext=
+        CosNaming::NamingContext::_narrow(obj);
+      if(CORBA::is_nil(rootContext))
+          throw CORBA::OBJECT_NOT_EXIST();
+
+      //
+      // Obtain reference to the Event Channel.
+      action="find Event Channel in naming service";
+      obj=rootContext->resolve(ecName);
+
+      //
+      // Unbind the Channel's reference in the naming service.
+      action="unbind Event Channel from naming service";
+      rootContext->unbind(ecName);
+    }
+    
+    action="narrow object reference to event channel";
+    CosEventChannelAdmin::EventChannel_var channel =
+      CosEventChannelAdmin::EventChannel::_narrow(obj);
+    if(CORBA::is_nil(channel))
+        throw CORBA::OBJECT_NOT_EXIST();
+    
+    //
+    // Destroy the EventChannel.
+    action="destroy Event Channel";
+    channel->destroy();
+
+    //
+    // Clean up nicely.
+    action="destroy orb";
+    orb->destroy();
+
+    //
+    // If we get here, then everything has worked OK.
+    result=0;
+
+  }
+  catch(CORBA::ORB::InvalidName& ex) { // resolve_initial_references
+     cerr<<"Failed to "<<action<<". ORB::InvalidName"<<endl;
+  }
+  catch(CosNaming::NamingContext::InvalidName& ex) { // resolve
+     cerr<<"Failed to "<<action<<". NamingContext::InvalidName"<<endl;
+  }
+  catch(CosNaming::NamingContext::NotFound& ex) { // resolve
+     cerr<<"Failed to "<<action<<". NamingContext::NotFound"<<endl;
+  }
+  catch(CosNaming::NamingContext::CannotProceed& ex) { // resolve
+     cerr<<"Failed to "<<action<<". NamingContext::CannotProceed"<<endl;
+  }
+  catch(CORBA::TRANSIENT& ex) { // _narrow()
+     cerr<<"Failed to "<<action<<". TRANSIENT"<<endl;
+  }
+  catch(CORBA::OBJECT_NOT_EXIST& ex) { // _narrow()
+     cerr<<"Failed to "<<action<<". OBJECT_NOT_EXIST"<<endl;
+  }
+  catch(CORBA::SystemException& ex) {
+     cerr<<"Failed to "<<action<<".";
+#if defined(HAVE_OMNIORB4)
+     cerr<<" "<<ex._name();
+     if(ex.NP_minorString())
+         cerr<<" ("<<ex.NP_minorString()<<")";
+#endif
+     cerr<<endl;
+  }
+  catch(CORBA::Exception& ex) {
+     cerr<<"Failed to "<<action<<"."
+#if defined(HAVE_OMNIORB4)
+       " "<<ex._name()
+#endif
+       <<endl;
+  }
+
+  return result;
+}
+
+static void
+usage(int argc, char **argv)
+{
+  cerr<<
+"\nDestroy an EventChannel.\n"
+"syntax: "<<(argc?argv[0]:"rmeventc")<<" OPTIONS [CHANNEL_URI]\n"
+"\n"
+"CHANNEL_URI: The event channel may be specified as a URI.\n"
+" This may be an IOR, or a corbaloc::: or corbaname::: URI.\n"
+"\n"
+"OPTIONS:                                         DEFAULT:\n"
+" -n NAME  channel name (if URI is not specified)  [\"EventChannel\"]\n"
+" -h       display this help text\n" << endl;
+}
+




More information about the Pkg-corba-commits mailing list