• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Client/server application using CORBA

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the server side application that i have to write are as follows:
Server 1 - �Simple Server�
The first POA-based server you need to develop is the �simple server�. This server should perform the
following tasks:
1. Start a timer
2. Create 1,000 Count objects with names �My Count1� ... �My Count1000�, and activate each object at
the time of its creation
3. Stop the timer and print out the average time to create and activate each counter
4. Register each Count object with the Naming Service (you do not need to time how long this operation
takes)
5. Wait for client requests
Note that this server does not use a servant manager.

Can someone help on how to handle this program please?

// SimpleServer.java: The Simple Server main program

import org.omg.PortableServer.*;
import org.omg.CosNaming.*;

class SimpleServer
{ public static void main(String[] args)

{

try

{ // Initialize the ORB
org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args, null);

// get a reference to the root POA
POA rootPOA =
POAHelper.narrow(orb.resolve_initial_references("RootPOA"));

// Create policies for our persistent POA
org.omg.CORBA.Policy[] policies = {
rootPOA.create_lifespan_policy(LifespanPolicyValue.TRANSIENT)
};

// Create myPOA with the right policies
POA myPOA = rootPOA.create_POA( "count_poa", rootPOA.the_POAManager(),
policies );

//Start the timer
for(int i=0;i<1000;i++)
{

// Calculate Start time
long startTime = System.currentTimeMillis();

// Create the servant
CountPOAServant countServant = new CountPOAServant();

//Create the object id
MyCount[] c=new MyCount[i];


// Decide on the ID for the servant
byte[] countId = "Count".getBytes();

// Activate the servant with the ID on myPOA
myPOA.activate_object_with_id(countId, countServant);
// Activate the POA manager
rootPOA.the_POAManager().activate();

// Calculate stop time; print out statistics
long stopTime = System.currentTimeMillis();
System.out.println("Avg Ping = "
+ ((stopTime - startTime)/1000f) + " msecs");


}


// get a reference to the Naming Service root context
org.omg.CORBA.Object nameServiceObj =
orb.resolve_initial_references("NameService");
if (nameServiceObj == null)
{
System.out.println("nameServiceObj = null");
return;
}

NamingContextExt nameService =
NamingContextExtHelper.narrow(nameServiceObj);
if (nameService == null)
{
System.out.println("nameService = null");
return;
}

// bind the Count object in the Naming service
NameComponent[] countName = {new NameComponent("MyCount", "")};
nameService.rebind(countName,
myPOA.servant_to_reference(countServant));
System.out.println(myPOA.servant_to_reference(countServant)
+ " is ready.");
// Wait for incoming requests
System.out.println( orb.object_to_string( myPOA.servant_to_reference(countServant)));
orb.run();

} catch(Exception e)
{ System.err.println(e);
}
}
}
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So in 2013 you happen to have the exact same problem as someone did in 2008? Is this a school assignment or something like that? If so, it's seriously outdated if it still teaches CORBA.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic