diff options
author | sbw1 <sbw1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-06-18 16:15:13 +0000 |
---|---|---|
committer | sbw1 <sbw1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-06-18 16:15:13 +0000 |
commit | 58a0a40c418e3645bf7036d12a6d7f36d2b50307 (patch) | |
tree | e01e3e84f132eaf2170376e47d5302e46eae9e24 /TAO/orbsvcs | |
parent | 7048ea53b8a3198476dd0402f024591423a98f4c (diff) | |
download | ATCD-58a0a40c418e3645bf7036d12a6d7f36d2b50307.tar.gz |
*** empty log message ***
Diffstat (limited to 'TAO/orbsvcs')
12 files changed, 923 insertions, 93 deletions
diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/Makefile b/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/Makefile index 23ba44d9610..fb3886d2c30 100644 --- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/Makefile +++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/Makefile @@ -76,7 +76,8 @@ clean: -/bin/rm -rf *.o Log $(BIN) obj.* core Templates.DB .make.state realclean: clean - -/bin/rm -rf $(addsuffix .h, $(IDL_FILES)) $(addsuffix .i, $(IDL_FILES)) $(addsuffix .cpp, $(IDL_FILES)) + -/bin/rm -rf $(addsuffix .h, $(IDL_FILES)) $(addsuffix .i, $(IDL_FILES)) $(addsuffix .cpp, $(IDL_FILES)) \ + $(addsuffix _T.h, $(IDL_FILES)) $(addsuffix _T.i, $(IDL_FILES)) $(addsuffix _T.cpp, $(IDL_FILES)) # DO NOT DELETE THIS LINE -- g++dep uses it. # DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. @@ -375,9 +376,7 @@ realclean: clean $(TAO_ROOT)/orbsvcs/orbsvcs/CosNamingS.i \ $(TAO_ROOT)/orbsvcs/orbsvcs/Naming/Entries.h \ $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/Audio_Server.h \ - vs.h \ - $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/include/Property_Info.h \ - Property_Exporter.h \ + vs.h Property_Exporter.h \ $(TAO_ROOT)/orbsvcs/orbsvcs/CosTradingC.h \ $(TAO_ROOT)/orbsvcs/orbsvcs/CosTradingC.i \ $(TAO_ROOT)/orbsvcs/orbsvcs/Trader/Dynamic_Property.h \ @@ -388,7 +387,8 @@ realclean: clean $(TAO_ROOT)/orbsvcs/orbsvcs/CosTradingS_T.i \ $(TAO_ROOT)/orbsvcs/orbsvcs/CosTradingS_T.cpp \ $(TAO_ROOT)/orbsvcs/orbsvcs/CosTradingS.i \ - Machine_Properties.h + Machine_Properties.h Video_Repository.h Video_RepositoryC.h \ + Video_RepositoryC.i .obj/server.o .obj/server.so .shobj/server.o .shobj/server.so: server.cpp server.h \ $(ACE_ROOT)/ace/Get_Opt.h \ $(ACE_ROOT)/ace/ACE.h \ @@ -683,20 +683,7 @@ realclean: clean $(TAO_ROOT)/orbsvcs/orbsvcs/CosNamingS.i \ $(TAO_ROOT)/orbsvcs/orbsvcs/Naming/Entries.h \ $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/Audio_Server.h \ - vs.h \ - $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/include/Property_Info.h \ - Property_Exporter.h \ - $(TAO_ROOT)/orbsvcs/orbsvcs/CosTradingC.h \ - $(TAO_ROOT)/orbsvcs/orbsvcs/CosTradingC.i \ - $(TAO_ROOT)/orbsvcs/orbsvcs/Trader/Dynamic_Property.h \ - $(TAO_ROOT)/orbsvcs/orbsvcs/Trader/Trader.h \ - $(TAO_ROOT)/orbsvcs/orbsvcs/Trader/Attributes.h \ - $(TAO_ROOT)/orbsvcs/orbsvcs/CosTradingS.h \ - $(TAO_ROOT)/orbsvcs/orbsvcs/CosTradingS_T.h \ - $(TAO_ROOT)/orbsvcs/orbsvcs/CosTradingS_T.i \ - $(TAO_ROOT)/orbsvcs/orbsvcs/CosTradingS_T.cpp \ - $(TAO_ROOT)/orbsvcs/orbsvcs/CosTradingS.i \ - Machine_Properties.h + vs.h .obj/vs.o .obj/vs.so .shobj/vs.o .shobj/vs.so: vs.cpp \ $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/Video_Server.h \ $(ACE_ROOT)/ace/Reactor.h \ @@ -1745,6 +1732,9 @@ realclean: clean $(TAO_ROOT)/orbsvcs/orbsvcs/CosTradingS_T.h \ $(TAO_ROOT)/orbsvcs/orbsvcs/CosTradingS_T.i \ $(TAO_ROOT)/orbsvcs/orbsvcs/CosTradingS_T.cpp \ - $(TAO_ROOT)/orbsvcs/orbsvcs/CosTradingS.i + $(TAO_ROOT)/orbsvcs/orbsvcs/CosTradingS.i \ + Property_Exporter.h \ + $(TAO_ROOT)/orbsvcs/orbsvcs/CosPropertyServiceC.h \ + $(TAO_ROOT)/orbsvcs/orbsvcs/CosPropertyServiceC.i # IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/Video_Repository.cpp b/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/Video_Repository.cpp index 7968e821c8d..9c35ddb5eff 100644 --- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/Video_Repository.cpp +++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/Video_Repository.cpp @@ -4,12 +4,10 @@ #include "ace/Read_Buffer.h" const char* TAO_Video_Repository::MOVIE_INFO = "Movie_Info"; -const char* TAO_Video_Repository::MOVIE_NAMES = "Movie_Names"; TAO_Video_Repository::TAO_Video_Repository (const char* file_name) : filename_ (file_name), movie_info_ (0), - movie_names_ (0), num_movies_ (0), lastchanged_ (0) { @@ -17,7 +15,6 @@ TAO_Video_Repository::TAO_Video_Repository (const char* file_name) TAO_Video_Repository::~TAO_Video_Repository (void) { - TAO_VR::Movie_Names::freebuf (this->movie_names_); TAO_VR::Movie_Info::freebuf (this->movie_info_); } @@ -55,33 +52,15 @@ TAO_Video_Repository::evalDP (const CORBA::Any& extra_info, } } - char* prop_name = 0; - extra_info >>= prop_name; - - String_var prop_name_var (prop_name); - if (ACE_OS::strcmp (prop_name, MOVIE_NAMES) == 0) - { - TAO_VR::Movie_Names* movie_names = 0; - ACE_NEW_RETURN (movie_names, - TAO_VR::Movie_Names (this->num_movies_, - this->num_movies_, - this->movie_names_, - CORBA::B_FALSE), - 0); - (*return_value) <<= movie_names; - } - else if (ACE_OS::strcmp (prop_name, MOVIE_INFO) == 0) - { - TAO_VR::Movie_Info* movie_info = 0; - ACE_NEW_RETURN (movie_info, - TAO_VR::Movie_Info (this->num_movies_, - this->num_movies_, - this->movie_info_, - CORBA::B_FALSE), - 0); - - (*return_value) <<= movie_info; - } + TAO_VR::Movie_Info* movie_info = 0; + ACE_NEW_RETURN (movie_info, + TAO_VR::Movie_Info (this->num_movies_, + this->num_movies_, + this->movie_info_, + CORBA::B_FALSE), + 0); + + (*return_value) <<= movie_info; } return return_value; @@ -97,20 +76,17 @@ TAO_Video_Repository::parse_file (const char* database, int num_lines) ACE_DEBUG ((LM_DEBUG, "Recomputing the movie stats.\n")); - TAO_VR::Movie_Names::freebuf (this->movie_names_); TAO_VR::Movie_Info::freebuf (this->movie_info_); - this->movie_names_ = TAO_VR::Movie_Names::allocbuf (num_lines); this->movie_info_ = TAO_VR::Movie_Info::allocbuf (num_lines); - if (this->movie_names_ != 0 && this->movie_info_ != 0) + if (this->movie_info_ != 0) { current = ACE_OS::strtok (current, "%"); while (current != 0) { TAO_VR::Movie& movie = this->movie_info_[i]; - this->movie_names_[i] = CORBA::string_dup (current); movie.name_ = (const char*) current; movie.filename_ = (const char*) ACE_OS::strtok (0, delim); movie.description_ = (const char*) ACE_OS::strtok (0, delim); @@ -148,14 +124,6 @@ export_dynamic_properties (TAO_Property_Exporter& prop_exporter, dp_dispatcher.register_handler (MOVIE_INFO, (TAO_DP_Evaluation_Handler*) this); prop_exporter.add_dynamic_property (MOVIE_INFO, dp_struct); - - extra_info <<= MOVIE_NAMES; - dp_struct = dp_dispatcher.construct_dynamic_prop (MOVIE_INFO, - TAO_VR::_tc_Movie_Names, - extra_info); - - dp_dispatcher.register_handler (MOVIE_NAMES, (TAO_DP_Evaluation_Handler*) this); - prop_exporter.add_dynamic_property (MOVIE_NAMES, dp_struct); } int @@ -165,16 +133,13 @@ define_properties (CosTradingRepos::ServiceTypeRepository::PropStructSeq& prop_s { CORBA::ULong num_props = prop_seq.length (); - if (num_props <= offset + 1) - prop_seq.length (offset + 2); + if (num_props <= offset) + prop_seq.length (offset + 1); prop_seq[offset].name = MOVIE_INFO; prop_seq[offset].value_type = CORBA::TypeCode::_duplicate (TAO_VR::_tc_Movie_Info); prop_seq[offset].mode = CosTradingRepos::ServiceTypeRepository::PROP_MANDATORY; - prop_seq[offset + 1].name = MOVIE_NAMES; - prop_seq[offset + 1].value_type = CORBA::TypeCode::_duplicate (TAO_VR::_tc_Movie_Names); - prop_seq[offset + 1].mode = CosTradingRepos::ServiceTypeRepository::PROP_MANDATORY; - return 2; + return 1; } diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/Video_Repository.h b/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/Video_Repository.h index 9bf902d98d8..435ed999a36 100644 --- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/Video_Repository.h +++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/Video_Repository.h @@ -1,7 +1,7 @@ /* -*- C++ -*- */ // ============================================================================ -// $Id$ +// $Id$ // // // = FILENAME @@ -42,7 +42,6 @@ class TAO_Video_Repository : { public: - static const char* MOVIE_NAMES; static const char* MOVIE_INFO; TAO_Video_Repository (const char* filename); @@ -78,7 +77,6 @@ private: // database. const char* filename_; - char** movie_names_; TAO_VR::Movie* movie_info_; int num_movies_; time_t lastchanged_; diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/Video_Repository.idl b/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/Video_Repository.idl index 5fe2896ee9a..ce42c089959 100644 --- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/Video_Repository.idl +++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/Video_Repository.idl @@ -1,5 +1,5 @@ // ============================================================================ -// $Id$ +// $Id$ // // = FILENAME // Video_Repository.idl @@ -28,5 +28,4 @@ module TAO_VR }; typedef sequence<Movie> Movie_Info; - typedef sequence<string> Movie_Names; }; diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/augmented_server.cpp b/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/augmented_server.cpp index 4dd3c04d4a6..dcb99819115 100644 --- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/augmented_server.cpp +++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/augmented_server.cpp @@ -467,12 +467,12 @@ AV_Server::init (int argc, */ // Invoke this once, passing in an object for each trading service // service type. - this->resolve_trader (env); - TAO_CHECK_ENV_RETURN (env, -1); - - // Invoke this for each offer. - this->export_properties (env); - TAO_CHECK_ENV_RETURN (env, -1); + if (this->resolve_trader (env) != -1) + { + // Invoke this for each offer. + this->export_properties (env); + TAO_CHECK_ENV_RETURN (env, -1); + } // Register the various signal handlers with the reactor. result = this->signal_handler_.register_handler (); @@ -527,7 +527,7 @@ AV_Server::export_properties (CORBA::Environment& _env) TAO_CHECK_ENV_RETURN_VOID (_env); } -void +int AV_Server::resolve_trader (CORBA::Environment& _env) { if (this->trader_.ptr () == 0) @@ -541,18 +541,18 @@ AV_Server::resolve_trader (CORBA::Environment& _env) { ACE_ERROR ((LM_ERROR, " (%P|%t) Unable to bootstrap to the Trading Service.\n")); - return; + return -1; } // Narrow the lookup interface. ACE_DEBUG ((LM_DEBUG, "Narrowing the lookup interface.\n")); this->trader_ = CosTrading::Lookup::_narrow (trading_obj.in (), _env); - TAO_CHECK_ENV_RETURN_VOID (_env); + TAO_CHECK_ENV_RETURN (_env, -1); CosTrading::TypeRepository_ptr obj = this->trader_->type_repos (_env); CosTradingRepos::ServiceTypeRepository_var str = CosTradingRepos::ServiceTypeRepository::_narrow (obj, _env); - TAO_CHECK_ENV_RETURN_VOID (_env); + TAO_CHECK_ENV_RETURN (_env, -1); TAO_TRY { @@ -560,6 +560,7 @@ AV_Server::resolve_trader (CORBA::Environment& _env) CosTradingRepos::ServiceTypeRepository::TypeStruct_var type_struct = str->describe_type (SERVICE_TYPE, TAO_TRY_ENV); TAO_CHECK_ENV; + return 0; } TAO_CATCH (CosTrading::UnknownServiceType, excp) { @@ -579,13 +580,13 @@ AV_Server::resolve_trader (CORBA::Environment& _env) prop_seq, type_name_seq, _env); - TAO_CHECK_ENV_RETURN_VOID (_env); - return; + TAO_CHECK_ENV_RETURN (_env, -1); + return 0; } TAO_CATCHANY { ACE_DEBUG ((LM_DEBUG, "Error in describe_type.\n")); - TAO_RETHROW; + TAO_RETHROW_RETURN (-1); } TAO_ENDTRY; } @@ -608,12 +609,15 @@ AV_Server::shutdown (void) const { TAO_TRY { - CosTrading::Register_var reg = this->trader_->register_if (TAO_TRY_ENV); - TAO_CHECK_ENV; - - ACE_DEBUG ((LM_DEBUG, "Withdrawing offer...\n")); - reg->withdraw (this->offer_id_.in (), TAO_TRY_ENV); - TAO_CHECK_ENV; + if (this->trader_.ptr () != 0) + { + CosTrading::Register_var reg = this->trader_->register_if (TAO_TRY_ENV); + TAO_CHECK_ENV; + + ACE_DEBUG ((LM_DEBUG, "Withdrawing offer...\n")); + reg->withdraw (this->offer_id_.in (), TAO_TRY_ENV); + TAO_CHECK_ENV; + } } TAO_CATCHANY { diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/augmented_server.h b/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/augmented_server.h index c34555b2498..492b7a6ad46 100644 --- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/augmented_server.h +++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/augmented_server.h @@ -183,7 +183,7 @@ private: void export_properties (CORBA::Environment& _env); - void resolve_trader (CORBA::Environment& _env); + int resolve_trader (CORBA::Environment& _env); TAO_ORB_Manager orb_manager_; // the TAO ORB manager. diff --git a/TAO/orbsvcs/tests/AVStreams/server_discovery/Discover_Server.java b/TAO/orbsvcs/tests/AVStreams/server_discovery/Discover_Server.java new file mode 100644 index 00000000000..0a7ea60181f --- /dev/null +++ b/TAO/orbsvcs/tests/AVStreams/server_discovery/Discover_Server.java @@ -0,0 +1,481 @@ +// $Id$ + +import java.io.*; +import java.net.*; +import java.awt.*; +import java.awt.event.*; +import java.util.*; +import org.omg.CORBA.*; +import CosTrading.*; +import CosTradingDynamic.*; +import CosTrading.LookupPackage.*; +import Property_Evaluator; +import TS_Resolve; + +public class Discover_Server + extends Frame + implements ItemListener, ActionListener +{ + private static final String CURRENT_DIR = System.getProperty ("user.dir"); + private static String FILE_SEPARATOR = System.getProperty ("file.separator"); + private static final String SERVICE_TYPE = "MMDevice"; + private static final String REFERENCE = "Reference"; + private static final String MOVIE_INFO = "Movie_Info"; + private static final String MOVIE_NAMES = "Movie_Names"; + private static final String SERVER_NAME = "Server_Name"; + private static final String HAS_CONNECTIONS = + " Number_Of_Connections < Max_Connections"; + private static final String HTML_FILE = + CURRENT_DIR + FILE_SEPARATOR + "movie-list.html"; + private static final String STATS_FILE = + CURRENT_DIR + FILE_SEPARATOR + "movie-stats.html"; + private static final String COMPILE = " Compile "; + private static final String SELECT = " Select "; + private static final String CLOSE = " Close "; + private static final byte JAVA_INIT = 35; + private static final Font FONT = new Font ("Dialog", Font.BOLD, 14); + + private ORB orb_; + private int port_; + private Lookup lookup_; + private boolean first_click_ = true; + private String currently_shown_ = null; + private List movies_selector_ = new List (14, false); + private Hashtable movies_ = new Hashtable (); + private Button compile_ = new Button (COMPILE); + private Button select_ = new Button (SELECT); + private Button close_ = new Button (CLOSE); + + public Discover_Server (ORB orb, Lookup lookup, int port) + { + super ("Server Discovery"); + + System.out.println ("yadda"); + this.orb_ = orb; + this.port_ = port; + this.lookup_ = lookup; + + Panel button_panel = new Panel (); + button_panel.setLayout (new FlowLayout (FlowLayout.CENTER, 25, 10)); + button_panel.add (this.compile_); + button_panel.add (this.select_); + button_panel.add (this.close_); + + Panel list_panel = new Panel (); + list_panel.setLayout (new CardLayout (10, 10)); + list_panel.add ("List", this.movies_selector_); + + this.compile_.setFont (FONT); + this.select_.setFont (FONT); + this.close_.setFont (FONT); + this.movies_selector_.setFont (FONT); + + this.compile_.requestFocus (); + this.compile_.addActionListener (this); + this.select_.addActionListener (this); + this.close_.addActionListener (this); + this.movies_selector_.addItemListener (this); + this.movies_selector_.addActionListener (this); + + this.setLayout (new BorderLayout (0, 0)); + this.add ("North", list_panel); + this.add ("South", button_panel); + } + + public void compile_movies () + { + String configuration = ""; + String[] properties = new String[3]; + SpecifiedProps desired_props = new SpecifiedProps (); + OfferSeqHolder offers = new OfferSeqHolder (); + OfferIteratorHolder offer_iter = new OfferIteratorHolder (); + + properties[0] = MOVIE_INFO; + properties[1] = MOVIE_NAMES; + properties[2] = SERVER_NAME; + desired_props.prop_names (properties); + + String constraint = configuration + HAS_CONNECTIONS; + this.query_trader (constraint, "", desired_props, offers, offer_iter); + + this.movies_selector_.removeAll (); + for (int i = 0; i < offers.value.length; i++) + this.extract_movies (offers.value[i]); + + if (offer_iter.value != null) + { + boolean more_in_iter = true; + OfferSeqHolder iter_offers = new OfferSeqHolder (); + while (more_in_iter) + { + more_in_iter = offer_iter.value.next_n (10, iter_offers); + + for (int i = 0; i < iter_offers.value.length; i++) + this.extract_movies (iter_offers.value[i]); + } + } + + // Add the movies to the list. + Enumeration movie_names = this.movies_.keys (); + + // Future: alphabetize this! + while (movie_names.hasMoreElements ()) + { + String movie_name = (String) movie_names.nextElement (); + System.out.println (movie_name); + this.movies_selector_.add (movie_name); + } + } + + public void view_info (String movie_name) + { + Runtime runtime = Runtime.getRuntime (); + + try + { + if (! movie_name.equals (this.currently_shown_)) + { + this.generate_html (movie_name); + + if (! this.first_click_) + runtime.exec ("netscape-remote " + HTML_FILE); + else + { + // runtime.exec ("netscape-remote-new " + HTML_FILE); + this.first_click_ = false; + } + + this.currently_shown_ = movie_name; + } + } + catch (Exception exception) + { + System.out.println (exception); + } + } + + public void select_movie (String movie_name) + { + // This will be replaced by the server performance visualization + // stage. + + if (movie_name != null) + { + // Perform lookup to retrieve the vector of offers associated + // with this movie name. + Vector vector = (Vector) this.movies_.get (movie_name); + Hashtable props = (Hashtable) vector.elementAt (0); + + org.omg.CORBA.Object object = + (org.omg.CORBA.Object) props.get (REFERENCE); + String ior = this.orb_.object_to_string (object); + + TAO_VR.Movie movie_info = (TAO_VR.Movie) props.get (movie_name); + + System.out.println (this.port_ + " " + ior + " " + movie_info.filename_); + this.load_movie (ior, movie_info.filename_); + + // this.shutdown (); + } + } + + public void itemStateChanged (ItemEvent e) + { + Integer index = (Integer) e.getItem (); + String movie_name = this.movies_selector_.getItem (index.intValue ()); + this.view_info (movie_name); + } + + public void actionPerformed (ActionEvent e) + { + String action_command = e.getActionCommand (); + + if (action_command.equals (COMPILE)) + this.compile_movies (); + else if (action_command.equals (SELECT)) + { + String selected_movie = this.movies_selector_.getSelectedItem (); + this.select_movie (selected_movie); + } + else if (action_command.equals (CLOSE)) + { + this.shutdown (); + } + else + this.select_movie (action_command); + } + + private void query_trader (String constraint, + String preference, + SpecifiedProps desired_props, + OfferSeqHolder offers, + OfferIteratorHolder offer_itr) + { + String ior = null; + Policy[] policies = new Policy[5]; + Any boolean_true = this.orb_.create_any (); + Any cardinality = this.orb_.create_any (); + Any follow_option_any = this.orb_.create_any (); + FollowOption follow_option_rule = FollowOption.always; + PolicyNameSeqHolder limits_applied = new PolicyNameSeqHolder (); + + desired_props.all_(true); + cardinality.insert_ulong (60); + boolean_true.insert_boolean (false); + FollowOptionHelper.insert (follow_option_any, follow_option_rule); + policies[0] = new Policy ("exact_type_match", boolean_true); + policies[1] = new Policy ("link_follow_rule", follow_option_any); + policies[2] = new Policy ("return_card", cardinality); + policies[3] = new Policy ("search_card", cardinality); + policies[4] = new Policy ("match_card", cardinality); + + try + { + // Compile list of names + this.lookup_.query (SERVICE_TYPE, + constraint, + preference, + policies, + desired_props, + 10, + offers, + offer_itr, + limits_applied); + + // this.dump_all_properties (offers.value, offer_itr.value); + } + catch (Exception excp) + { + System.err.println (excp); + } + } + + private void load_movie (String ior, String movie_name) + { + try + { + InetAddress inet_addr = InetAddress.getLocalHost (); + // Open a socket to the controller process of the video client. + // Socket controller_sock = new Socket (inet_addr, + //this.port_); + Socket controller_sock = new Socket ("merengue", this.port_); + OutputStream controller_stream = controller_sock.getOutputStream (); + // DataOutputStream dos = new DataOutputStream (controller_stream); + + // Write the demultiplexing key for this controller operation: + controller_stream.write (JAVA_INIT); + // dos.writeByte (JAVA_INIT); + + // Write the length and contents of the ior string. + controller_stream.write (ior.length ()); + System.out.println ("Writing: " + ior.length ()); + controller_stream.write (ior.getBytes ()); + System.out.println ("Writing: " + ior.getBytes ()); + //dos.writeChars (ior); + + // Write the length and contents of the ior string. + controller_stream.write (movie_name.length ()); + controller_stream.write (movie_name.getBytes ()); + //dos.writeChars (movie_name); + + // Close the socket. + //controller_sock.close (); + } + catch (Exception excp) + { + System.out.println ("Failed to load movie."); + System.out.println (excp); + } + } + + private void dump_all_properties (Offer[] offers, + OfferIterator offer_iterator) + { + try + { + this.dump_properties (offers); + + if (offer_iterator != null) + { + OfferSeqHolder iter_offers = new OfferSeqHolder (); + System.out.println ("*** Dumping Properties in Iterator."); + + boolean more_in_iter = true; + while (more_in_iter) + { + System.out.println ("*** Fetching another batch of offers."); + more_in_iter = offer_iterator.next_n (10, iter_offers); + + System.out.println ("*** Length: " + iter_offers.value.length); + this.dump_properties (iter_offers.value); + } + } + } + catch (DPEvalFailure exception) + { + System.out.println (exception); + } + } + + private void dump_properties (Offer[] offer_seq) + throws DPEvalFailure + { + for (int i = 0; i < offer_seq.length; i++) + { + Property_Evaluator prop_eval = new Property_Evaluator (offer_seq[i]); + + for (int j = 0; j < offer_seq[i].properties.length; j++) + { + System.out.println ("Property: " + + offer_seq[i].properties[j].name + + " Value: " + + prop_eval.property_value (j, this.orb_)); + //prop_eval.property_to_string (j, this.orb_)); + } + + System.out.println ("----------------------------"); + } + } + + private void extract_movies (Offer offer) + { + Hashtable prop_map = new Hashtable (); + + prop_map.put (REFERENCE, offer.reference); + for (int i = 0; i < offer.properties.length; i++) + { + Property property = offer.properties[i]; + String property_name = property.name; + + // Use a hashtable to map property names to their values. + prop_map.put (property_name, property); + System.out.println ("Found property " + property_name); + if (property_name.equals (MOVIE_INFO)) + { + try + { + Property_Evaluator prop_eval = new Property_Evaluator (offer); + Any tmp = prop_eval.property_value (i, this.orb_); + TAO_VR.Movie[] movie_info = TAO_VR.Movie_InfoHelper.extract (tmp); + + // In the top level hashtable, a movie name is mapped to + // a vector where each element is reserved for an offer + // that has that movie. In that element is the + // aforementioned interior hashtable. Pretty damn + // complicated. How did I think of this? + for (int j = 0; j < movie_info.length; j++) + { + Vector movie_vector = null; + movie_vector = (Vector) this.movies_.get (movie_info[j].name_); + + if (movie_vector == null) + { + System.out.println ("Adding movie to map " + movie_info[j]); + movie_vector = new Vector (); + this.movies_.put (movie_info[j].name_, movie_vector); + } + + movie_vector.addElement (prop_map); + prop_map.put (movie_info[j].name_, movie_info[j]); + } + } + catch (DPEvalFailure dpeval) + { + System.out.println (dpeval); + } + } + } + } + + private void generate_html (String movie_name) + throws IOException + { + String first_url = null; + Vector movie_offers = (Vector) this.movies_.get (movie_name); + FileOutputStream fos = new FileOutputStream (STATS_FILE); + PrintWriter pwr = new PrintWriter (fos); + + pwr.println ("<html>"); + pwr.println ("<BODY bgcolor=\"FFFFFF\" BACKGROUND=\"000000\""); + pwr.println ("TEXT= \"000055\" VLINK=\"0000BF\" LINK=\"BF0000\">"); + pwr.println ("<b> " + movie_name + " Availability: </b><p>"); + + for (int i = 0; i < movie_offers.size (); i++) + { + Hashtable offer_props = (Hashtable) movie_offers.elementAt (i); + Property name_prop = (Property) offer_props.get (SERVER_NAME); + TAO_VR.Movie movie_info = (TAO_VR.Movie) offer_props.get (movie_name); + String server_name = name_prop.value.extract_string (); + + pwr.println ("<b>Server: " + server_name + "</b><br>"); + if (i == 0) + first_url = movie_info.description_; + + pwr.println ("<font size =-1>"); + pwr.println ("<tt> <a href=\"" + + movie_info.description_ + + "\" Target=\"main\"\"> " + + movie_info.description_ + + "</a></tt><p>"); + pwr.println ("<li> Filename: <tt>" + + movie_info.filename_ + "</tt><br>"); + pwr.println ("<li> Format: <tt></tt> <br>"); + pwr.println ("<li> File size: <tt></tt> <br>"); + pwr.println ("<li> Duration: <tt></tt> <br>"); + pwr.println ("<li> Frame Rate: <tt></tt> <br>"); + pwr.println ("<li> Frame Size: <tt></tt> <br>"); + pwr.println ("</font>"); + pwr.println ("<p>"); + } + + pwr.println ("</html>"); + pwr.close (); + + fos = new FileOutputStream (HTML_FILE); + pwr = new PrintWriter (fos); + + pwr.println ("<html>"); + pwr.println ("<head>"); + pwr.println ("<title> " + movie_name + " </title>"); + pwr.println ("</head>"); + + pwr.println ("<FRAMESET COLS=\"250,*\" FRAMEBORDER=\"yes\" BORDER=\"1\" BORDERCOLOR=\"#000000\">"); + pwr.println ("<FRAME SRC=\"file:" + STATS_FILE + "\""); + pwr.println ("NAME=\"menu\" NORESIZE SCROLLING=\"auto\" MARGINWIDTH=0>"); + pwr.println ("<FRAME SRC=\"" + first_url + "\""); + pwr.println ("NAME=\"main\" NORESIZE SCROLLING=\"auto\" MARGINWIDTH=0>"); + pwr.println ("</FRAMESET>"); + pwr.println ("</html>"); + pwr.close (); + } + + private void shutdown () + { + Runtime runtime = Runtime.getRuntime (); + this.dispose (); + runtime.exit (0); + } + + public static void main (String[] args) + { + int port = 6676; + + if (args.length > 1) + port = Integer.parseInt (args[0]); + + // Initialize the ORB + java.util.Properties props = null; + ORB orb = ORB.init (args, props); + + // Resolve the Trading Service + Lookup lookup = TS_Resolve.resolve_trading_service (orb); + + if (lookup != null) + { + Discover_Server ds = new Discover_Server (orb, lookup, port); + + ds.setBounds (20, 20, 320, 350); + ds.show (); + } + } +} diff --git a/TAO/orbsvcs/tests/AVStreams/server_discovery/Makefile b/TAO/orbsvcs/tests/AVStreams/server_discovery/Makefile new file mode 100644 index 00000000000..78ffd8c486d --- /dev/null +++ b/TAO/orbsvcs/tests/AVStreams/server_discovery/Makefile @@ -0,0 +1,35 @@ +# $Id$ + +# Makefile + +.SUFFIXES: .idl .module .java .class + +.java.class: + $(VISIJAVA_ROOT)/bin/vbjc $< + +.idl.module: + $(VISIJAVA_ROOT)/bin/idl2java -DTAO_HAS_DYNAMIC_PROPERTY_BUG \ + -no_tie -no_skel -no_bind -no_comments -no_examples $< + touch $@ + +default: all + +clean: + rm -rf CosTrading CosTradingDynamic CosTradingRepos TAO_Sequences TAO_VR + rm -f *.class *.tmp *.module *~ + +IDLS = \ + $(TAO_ROOT)/orbsvcs/orbsvcs/CosTrading.idl \ + $(TAO_ROOT)/orbsvcs/orbsvcs/Sequences.idl \ + $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/server/Video_Repository.idl + +MODULES = $(IDLS:.idl=.module) + +SRCS = \ + TS_Resolve.java \ + Property_Evaluator.java \ + Discover_Server.java + +CLASSES = $(SRCS:.java=.class) + +all: $(MODULES) $(CLASSES) diff --git a/TAO/orbsvcs/tests/AVStreams/server_discovery/Property_Evaluator.java b/TAO/orbsvcs/tests/AVStreams/server_discovery/Property_Evaluator.java new file mode 100644 index 00000000000..4689c9443b4 --- /dev/null +++ b/TAO/orbsvcs/tests/AVStreams/server_discovery/Property_Evaluator.java @@ -0,0 +1,238 @@ +/* -*- C++ -*- */ + +// ======================================================================== +// $Id$ +// +// = FILENAME +// Property_Evaluator.java +// +// = AUTHOR +// Seth Widoff <sbw1@cs.wustl.edu> +// +// ======================================================================== + + +import org.omg.CORBA.*; +import CosTrading.*; +import CosTradingDynamic.*; +import TAO_Sequences.*; +import TAO_VR.*; + +/** + * This is a Java port of the TAO_Property_Evaluator class in the TAO + * trading service implementation. + */ + +public class Property_Evaluator +{ + private Property[] props_; + private boolean supports_dp_ = true; + + /** + * Construct an instance of TAO_Property_Evaluator that operates on + * a PropertySeq, <properties>. + */ + Property_Evaluator (Property[] properties) + { + this.props_ = properties; + } + + /** + * Construct an instance of TAO_Property_Evaluator that operates on + * an <offer>. + */ + public Property_Evaluator (Offer offer) + { + this.props_ = offer.properties; + } + + /** + * Disable or enable the evaluation of dynamic properties. + */ + public void allow_dynamic_properties (boolean toggle) + { + this.supports_dp_ = toggle; + } + + /** + * Returns true if the property at index <index> is dynamic. Returns a + * 0 when the index is out of bounds. + */ + public boolean is_dynamic_property (int index) + { + boolean return_value = false; + int num_properties = this.props_.length; + + if (index >= 0 && index < num_properties) + return_value = Property_Evaluator.is_dynamic_property (this.props_[index]); + + return return_value; + } + + public static boolean is_dynamic_property (Property prop) + { + boolean return_value = false; + + Any value = prop.value; + TypeCode type = value.type (); + + // Compare the type of the Any contents with the typecode + // for a dynamic property structure. + if (type.equal (DynamicPropHelper.type ())) + return_value = true; + + return return_value; + } + + /** + * Returns value of the property whose index is <index>. If the + * property at that index is dynamic and the trader supports dynamic + * properties, then the property_value method will obtain the value + * of the dynamic property using the evalDP method on the + * CosTradingDynamic::DynamicPropEval interface, passing on a + * CosTradingDynamic::DPEvalFailure exception on failure. If the + * property index is undefined, the method returns a null pointer. + */ + public Any property_value (int index, ORB orb) + throws DPEvalFailure + { + Any return_value = null; + int num_properties = this.props_.length; + + if (index >= 0 && index < num_properties) + { + return_value = + Property_Evaluator.property_value (this.props_[index], orb); + } + + return return_value; + } + + public static Any property_value (Property prop, ORB orb) + throws DPEvalFailure + { + Any prop_value = null; + + if (! Property_Evaluator.is_dynamic_property (prop)) + prop_value = prop.value; + else + { + DynamicProp dp_struct = + DynamicPropHelper.extract (prop.value); + String prop_name = prop.name; + + // This is because of the bug in TAO: + // Now we extract the object reference from the dynamic + // property structure. + org.omg.CORBA.Object obj = + orb.string_to_object (dp_struct.eval_if); + DynamicPropEval dp_eval = DynamicPropEvalHelper.narrow (obj); + + if (dp_eval != null) + { + prop_value = dp_eval.evalDP (prop_name, + dp_struct.returned_type, + dp_struct.extra_info); + } + else + { + throw new DPEvalFailure (prop_name, + dp_struct.returned_type, + dp_struct.extra_info); + } + } + + return prop_value; + } + + /** + * Returns the type of the property whose index is <index>. If the + * property is dynamic and the trader supports dynamic properties, + * then the method returns the <returned_type> field of the + * CosTradingDynamic::DynamicProp struct associated with the + * property name. If the index is out of bounds, the method returns + * a null pointer (that is, 0). + */ + + public TypeCode property_type (int index) + { + TypeCode prop_type = null; + + if (! this.is_dynamic_property (index)) + prop_type = this.props_[index].value.type (); + else + { + Any value = this.props_[index].value; + DynamicProp dp_struct = DynamicPropHelper.extract (value); + + prop_type = dp_struct.returned_type; + } + + return prop_type; + } + + public String property_to_string (int index, ORB orb) + throws DPEvalFailure + { + String return_value = null; + Any any_value = this.property_value (index, orb); + TypeCode type = any_value.type (); + int kind = type.kind ().value (); + + if (kind == TCKind._tk_null) + return_value = "Null"; + + else if (kind == TCKind._tk_void) + return_value = "Void"; + + else if (kind == TCKind._tk_short) + return_value = String.valueOf (any_value.extract_short ()); + + else if (kind == TCKind._tk_long) + return_value = String.valueOf (any_value.extract_long ()); + + else if (kind == TCKind._tk_ushort) + return_value = String.valueOf (any_value.extract_ushort ()); + + else if (kind == TCKind._tk_ulong) + return_value = String.valueOf (any_value.extract_ulong ()); + + else if (kind == TCKind._tk_float) + return_value = String.valueOf (any_value.extract_float ()); + + else if (kind == TCKind._tk_double) + return_value = String.valueOf (any_value.extract_double ()); + + else if (kind == TCKind._tk_boolean) + return_value = String.valueOf (any_value.extract_boolean ()); + + else if (kind == TCKind._tk_char) + return_value = String.valueOf (any_value.extract_char ()); + + else if (kind == TCKind._tk_string) + return_value = any_value.extract_string (); + + else if (type.equal (StringSeqHelper.type ())) + { + System.out.println ("Printing string sequence."); + String[] str_seq = StringSeqHelper.extract (any_value); + + for (int length = str_seq.length, i = 0; i < length; i++) + return_value = str_seq[i] + " "; + } + + else if (type.equal (ULongSeqHelper.type ())) + { + System.out.println ("Printing ulong sequence."); + int[] ulong_seq = ULongSeqHelper.extract (any_value); + + for (int length = ulong_seq.length, i = 0; i < length; i++) + return_value = ulong_seq[i] + " "; + } + + else + System.out.println ("TCKind" + kind); + + return return_value; + } +} diff --git a/TAO/orbsvcs/tests/AVStreams/server_discovery/TS_Resolve.java b/TAO/orbsvcs/tests/AVStreams/server_discovery/TS_Resolve.java new file mode 100644 index 00000000000..3cfcd69bc22 --- /dev/null +++ b/TAO/orbsvcs/tests/AVStreams/server_discovery/TS_Resolve.java @@ -0,0 +1,104 @@ +// $Id$ +// ============================================================================ +// +// +// = FILENAME +// NS_Resolve.java +// +// = AUTHOR +// Michael Kircher (mk1@cs.wustl.edu) +// +// = DESCRIPTION +// Resolves the initial reference to the Naming service, +// the orb has to be given as a parameter to the +// resolve_name_service call. +// +// +// ============================================================================ + +import CosTrading.*; +import org.omg.CORBA.*; +import java.net.*; +import java.io.*; + +public class TS_Resolve +{ + + private static final String ACE_DEFAULT_MULTICAST_ADDR = "224.9.9.2"; + private static final int TAO_DEFAULT_NAME_SERVER_REQUEST_PORT = 10016; + private static final int MULTICAST_SEND_PORT = 10060; + private static final int MULTICAST_RECEIVE_PORT = 10061; + private static final int TAO_SERVICEID_NAMESERVICE = 0; + private static final int TAO_SERVICEID_TRADINGSERVICE = 1; + + static public CosTrading.Lookup + resolve_trading_service (org.omg.CORBA.ORB orb) + { + try + { + // Create a message with the multicast receive port in it + ByteArrayOutputStream byte_stream_ = new ByteArrayOutputStream (); + byte_stream_.write ((int)((MULTICAST_RECEIVE_PORT&0xff00)>>>8)); + byte_stream_.write ((int)(MULTICAST_RECEIVE_PORT&0x00ff)); + byte_stream_.write ((int)((TAO_SERVICEID_TRADINGSERVICE&0xff00)>>>8)); + byte_stream_.write ((int)(TAO_SERVICEID_TRADINGSERVICE&0x00ff)); + byte[] msg = byte_stream_.toByteArray(); + + // Define the group for the multicast + + InetAddress group = InetAddress.getByName(ACE_DEFAULT_MULTICAST_ADDR); + // Create the multicast socket at any port you want + MulticastSocket multicastsocket = new MulticastSocket(MULTICAST_SEND_PORT); + // Create a socket for the answer of the Naming Service + DatagramSocket socket = new DatagramSocket (MULTICAST_RECEIVE_PORT); + // Give three seconds time for the Naming Service to respond + socket.setSoTimeout (3000); + // Build a packet with the port number in it + DatagramPacket hello = new DatagramPacket(msg, msg.length, + group, TAO_DEFAULT_NAME_SERVER_REQUEST_PORT); + + // Send the packet + multicastsocket.send (hello); + + // @@ The restriction right now is that the length of the IOR cannot be longer than 4096 + byte[] buf = new byte[4096]; + // Set up packet which can be received + DatagramPacket recv = new DatagramPacket (buf, buf.length); + // Receive a packet or time out + socket.receive (recv); + + // Determine the length of the IOR + int length; + for (length = 0; buf[length] != 0; length++); + + // Store the IOR in a String + String name_service_ior = new String (recv.getData (),0,length); + + // Convert the String into + org.omg.CORBA.Object obj = orb.string_to_object (name_service_ior); + return CosTrading.LookupHelper.narrow (obj); + } + catch (SocketException e) + { + System.err.println (e); + } + catch (java.io.InterruptedIOException e) + { + System.err.println ("TS_Resolve: The receive lasted too long"); + } + catch(org.omg.CORBA.SystemException e) + { + System.err.println(e); + } + catch (java.io.IOException e) + { + System.err.println (e); + } + return null; + } +}; + + + + + diff --git a/TAO/orbsvcs/tests/AVStreams/server_discovery/netscape-remote b/TAO/orbsvcs/tests/AVStreams/server_discovery/netscape-remote new file mode 100755 index 00000000000..dbaf3ca5b18 --- /dev/null +++ b/TAO/orbsvcs/tests/AVStreams/server_discovery/netscape-remote @@ -0,0 +1,8 @@ +#!/pkg/gnu/bin/bash +if [ -h $HOME/.netscape/lock ] +then echo hello > /dev/console +else exec netscape $1 2>&1 > /dev/console +fi + +exec netscape -remote openURL'('$1')' 2>&1 | cat > /dev/console + diff --git a/TAO/orbsvcs/tests/AVStreams/server_discovery/netscape-remote-new b/TAO/orbsvcs/tests/AVStreams/server_discovery/netscape-remote-new new file mode 100755 index 00000000000..c46a9fff1d6 --- /dev/null +++ b/TAO/orbsvcs/tests/AVStreams/server_discovery/netscape-remote-new @@ -0,0 +1,8 @@ +#!/pkg/gnu/bin/bash +if [ -h $HOME/.netscape/lock ] +then echo hello > /dev/console +else exec netscape $1 2>&1 > /dev/console +fi + +exec netscape -remote openURL'('$1',new-window)' 2>&1 | cat > /dev/console + |