Back to Trading Service Examples Page
The Video on Demand example demonstrates of how to use the basic features of Trading Service. Features which are covered include:
The Video-On-Demand example consists of:
Video feed providers use the Trading Service to advertise their services to potential clients: clients use the Trading Service to locate the (previously advertised) video feeds that they want. A TV Company defines the types of service that the video feed providers can offer.
The following diagram shows the Video-on-Demand's architecture:
The source files for the Video on Demand example are:
Video.idl - the IDL interface for the video feed objects. A Programme interface defines an attribute "title" and a show operation. The Film and SportsEvent interfaces both extend the Programme interface. The Film interface adds the attribute certificate"; the SportsEvent interface adds the attribute "sport".
TradingUtil.java - provides methods that resolve the Trading Service and obtain references to some of the components of the Trading Service. The class' methods are:
getLookup is a static method that returns a reference
to the Lookup component of the Trading Service.
getRegister is a static method that returns a reference
to the Register component of the Trading Service.
getTypeRepos is a static method that returns a reference
to the ServiceTypeRepository component of the Trading Service.
getAdmin is a static method that returns a reference
to the Admin component of the Trading Service.
getProxy is a static method that returns a reference
to the Proxy component of the Trading Service.
FilmImpl.java - implements the Film interface in
Video.idl. The methods of this class are:
constructor creates a FilmImpl object giving details of
its title, certificate, and the VideoMachine that can show it.
certificate returns the certificate of the film.
title returns the title of the film.
show would broadcast the film but in this example
the method just prints a message.
description returns the combination of the title and the
certificate.
SportsEventImpl.java - implements the SportsEventImpl interface from
Video.idl. The methods of this class are:
constructor creates a SportsEventImpl object giving details
of its title, sport, and the VideoMachine that can show it.
sport returns the sport for the event.
title returns the title of the event.
show would broadcast the event but in this example
the method just prints a message.
description returns the combination of the title and the sport.
VideoMachine.java - a server that supplies video feeds. Its methods are:
main creates a new instance of a VideoMachine object.
constructor randomly chooses a number of television
programmes for which it can provide video feeds, and then calls the
export method to export offers of these video feeds.
Finally, the constructor calls ObjectAdapter.ready()
to establish the VideoMachine as a server.
export exports a number of offers of video feeds
to the Trading Service.
withdraw withdraws all the previously exported offers
of video feeds from the Trading Service.
TVCompany.java - adds the service types to the Trading Service. Is methods are:
main creates a new TVCompany instance.
constructor obtains a reference to the Service
Type Repository and then calls its add_type method to
add the service types to the trader. The service types that are
added to the trader are IDL:Video/Programme:1.0,
IDL:Video/Film:1.0, and IDL:Video/SportsEvent:1.0.
TVSet.java - represents a television set that can request a video feed. Its methods are:
main creates a new instance of the TVSet object.
constructor randomly chooses a programme. It then calls
the query method to obtain an offer of a video feed of that
programme.
The show method of the Programme is called when a offer of
service is
obtained.
query creates and performs a query to ask the trader
where to obtain a video feed of the specified programme.
ProgrammeFactory.java - a server that can provide video feeds which are identical to those provided by the VideoMachine class above, except that the video feeds are not created until they are required. This class is a Lookup object. Its methods are:
main creates a new instance of the ProgrammeFactory
object.
constructor exports itself to the Trading Service as a
proxy offer with the service type "programme".
query is called by the Trading Service when a client
requests a programme object. The constraint string is looked at to decide
which programme the client requires. A new video feed is then created
dynamically for the requested programme.
All other methods of this class are provided so that the class conforms
to the Lookup interface; they are not used in the manipulation
of the proxy offer.
If using an ORB which requires persistent POAs to be registered
before they can be activated, ensure that that the
OpenFusion.TradingTVCompany,
OpenFusion.TradingVideoMachine, and
OpenFusion.TradingTVSet POAs are registered.
From the command line use:
server -start TradingService
Using the Administration Manager:
Start the Administration Manager, right click on the TradingService node and select Start from the pop-up menu.
run com.prismt.cos.CosTrading.examples.Video.TVCompany
run com.prismt.cos.CosTrading.examples.Video.VideoMachine
run com.prismt.cos.CosTrading.examples.Video.TVSet