Note that there are some explanatory texts on larger screens.

plurals
  1. POIssue creating many server's from one class Corba
    primarykey
    data
    text
    <p>For a uni assignment, we have to create a way of managing flood sensors and alerting once if the water level becomes to high. So my idea was to create a LMS (Local Monitoring Station) which would hold an arrayList of sensor Servers and then manage them from there.</p> <p>So I created a test class to test the implementation of adding them;</p> <pre><code>public class testClass { static public void main(String[] args) { ArrayList&lt;FloodSensorServer&gt; sensors = new ArrayList&lt;FloodSensorServer&gt;(); sensors.add(new FloodSensorServer("Sensor 1")); sensors.add(new FloodSensorServer("Sensor 2")); sensors.add(new FloodSensorServer("Sensor 3")); sensors.add(new FloodSensorServer("Sensor 4")); } } </code></pre> <p>Logically, I thought this might have worked, Till I ran it and saw that it ran the first .add and then stopped. I then realized it was stopping because of this line of code;</p> <pre><code>orb.run(); public class FloorSensorServer { Sensor counter; String sensorName; public FloorSensorServer(String sensorName) { this.sensorName = sensorName; createServer(); } public void createServer() { try { // Initialize the ORB System.out.println("Creating sensor: " + sensorName); String[] newArgs = {"-ORBInitialPort", "1050"}; ORB orb = ORB.init(newArgs, null); // get reference to rootpoa &amp; activate the POAManager POA rootpoa = POAHelper.narrow(orb.resolve_initial_references("RootPOA")); rootpoa.the_POAManager().activate(); // Create the Count servant object FloorSensorImpl sensor = new FloorSensorImpl(sensorName); // get object reference from the servant org.omg.CORBA.Object ref = rootpoa.servant_to_reference(sensor); Sensor cref = SensorHelper.narrow(ref); // Get a reference to the Naming service org.omg.CORBA.Object nameServiceObj = orb.resolve_initial_references ("NameService"); if (nameServiceObj == null) { System.out.println("nameServiceObj = null"); return; } // Use NamingContextExt which is part of the Interoperable // Naming Service (INS) specification. NamingContextExt nameService = NamingContextExtHelper.narrow(nameServiceObj); if (nameService == null) { System.out.println("nameService = null"); return; } NameComponent[] countName = nameService.to_name(sensorName); nameService.rebind(countName, cref); // wait for invocations from clients orb.run(); } catch(Exception e) { System.err.println(e); } } } </code></pre> <p><strong>Question:</strong></p> <p>How would one deal with a situation like this? Or am I going about this the totally wrong way?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload