/*====================================================================
OpenCCM: The Open CORBA Component Model Platform
Copyright (C) 2000-2002 USTL - LIFL - GOAL
Contact: openccm-team@objectweb.org
This library 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 any later version.
This library 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
Initial developer(s): Philippe Merle, Mathieu Vadet.
Contributor(s): Romain Rouvoy_________________________.
====================================================================*/
package cisksu.basicsp;
/**
* The demo1 application deployment.
*
* @author <a href="mailto:Philippe.Merle@lifl.fr">Philippe Merle</A>
* <a href="mailto:Mathieu.Vadet@lifl.fr">Mathieu Vadet</A>
*/
public class BasicSP
{
/**
* The bootstrap of the demo1 application.
*/
public static void
main(String[] args)
throws Exception
{
// Init the ORB.
System.out.println("Initializing the ORB...");
// Init the OpenCCM Components Runtime.
org.omg.CORBA.ORB orb = org.objectweb.ccm.Components.Runtime.init(args);
// Obtain the Name Service.
System.out.println("Obtaining the Name Service...");
org.omg.CORBA.Object obj = orb.resolve_initial_references("NameService");
org.omg.CosNaming.NamingContext nc = org.omg.CosNaming.NamingContextHelper.narrow(obj);
// Obtain the component servers.
System.out.println("Obtaining Component Servers...");
org.omg.CosNaming.NameComponent[] ncomp = new org.omg.CosNaming.NameComponent[1];
ncomp[0] = new org.omg.CosNaming.NameComponent("ComponentServer1", "");
obj = nc.resolve(ncomp);
org.objectweb.ccm.Deployment.Server server1 = org.objectweb.ccm.Deployment.ServerHelper.narrow(obj);
ncomp[0].id = "ComponentServer2";
obj = nc.resolve(ncomp);
org.objectweb.ccm.Deployment.Server server2 = org.objectweb.ccm.Deployment.ServerHelper.narrow(obj);
// Obtain the container homes and archive installators.
org.omg.Components.Deployment.ComponentServer server1_cs = server1.provide_component_server();
org.omg.Components.Deployment.ComponentInstallation server1_inst = server1.provide_install();
org.omg.Components.Deployment.ComponentServer server2_cs = server2.provide_component_server();
org.omg.Components.Deployment.ComponentInstallation server2_inst = server2.provide_install();
// Install archives.
System.out.println("Installing archives...");
server1_inst.install("basicsp", "./archives/basicsp.jar");
server2_inst.install("basicsp", "./archives/basicsp.jar");
// install some plugins already provided by OpenCCM.
server1_inst.install("openccm_plugins", "./OpenCCM_Plugins.jar");
server2_inst.install("openccm_plugins", "./OpenCCM_Plugins.jar");
org.omg.Components.Deployment.Container server1_cont =
// server1_cs.create_container(config);
server1_cs.create_container(new org.omg.Components.ConfigValue[0]);
org.omg.Components.Deployment.Container server2_cont =
// server2_cs.create_container(config);
server2_cs.create_container(new org.omg.Components.ConfigValue[0]);
// Install homes.
System.out.println("Instantiating homes...");
org.omg.Components.CCMHome h = server1_cont.install_home("basicsp", "cisksu.basicsp.EventChannelHomeImpl.create_home", new org.omg.Components.ConfigValue[0]);
EventChannelHome sh = EventChannelHomeHelper.narrow(h);
h = server2_cont.install_home("basicsp", "cisksu.basicsp.BMClosedEDHomeImpl.create_home", new org.omg.Components.ConfigValue[0]);
BMClosedEDHome bmclosed = BMClosedEDHomeHelper.narrow(h);
h = server2_cont.install_home("basicsp", "cisksu.basicsp.BMDeviceHomeImpl.create_home", new org.omg.Components.ConfigValue[0]);
BMDeviceHome bmdevice = BMDeviceHomeHelper.narrow(h);
h = server2_cont.install_home("basicsp", "cisksu.basicsp.BMDisplayHomeImpl.create_home", new org.omg.Components.ConfigValue[0]);
BMDisplayHome bmdisplay = BMDisplayHomeHelper.narrow(h);
// Create components.
System.out.println("Instantiating components...");
EventChannel event = sh.create();
BMClosedED airframe = bmclosed.create();
BMDevice gps = bmdevice.create();
BMDisplay navDisplay = bmdisplay.create();
// Configure components.
System.out.println("Configuring components...");
// Connect clients and server.
System.out.println("Interconnecting components...");
event.subscribe_timeOut20(gps.get_consumer_timeOut20());
gps.subscribe_outDataAvailable(airframe.get_consumer_inDataAvailable());
airframe.subscribe_outDataAvailable(navDisplay.get_consumer_inDataAvailable());
ReadData dataOut = gps.provide_dataOut();
airframe.connect_dataIn(dataOut);
dataOut = airframe.provide_dataOut();
navDisplay.connect_dataIn(dataOut);
// Configuration completion.
System.out.println("Configuration completion...");
event.configuration_complete();
System.out.println("EventChannel: Configuration completion...");
airframe.configuration_complete();
gps.configuration_complete();
navDisplay.configuration_complete();
// Force to exit.
System.exit(0);
}
}
syntax highlighted by Code2HTML, v. 0.9