ParkNPark.common
Class NameService

java.lang.Object
  extended by ParkNPark.common.NameService

public class NameService
extends Object

Contains utility functions for working with the CORBA name service and the ParkNPark name context


Field Summary
protected  PrintStream err
          The original System.err instance
private  NamingContextExt nameServer
          Naming context
protected  ORB orb
          Object request broker
private  NamingContext parkNParkContext
          Our naming service's ParkNPark context, which contains server registrations
protected  boolean primaryServerRegistered
          Whether or not a primary server registration exists as of the last call to addServerListFromParkNParkContext()
private  ArrayList<Server> servers
          List of active servers
 
Constructor Summary
NameService(ORB orb, PrintStream err)
          Creates a new NameService instance using the given ORB
 
Method Summary
 boolean addServerListFromParkNParkContext(boolean createParkNParkContext, boolean verbose, LogEntry logEntry)
          Adds to the server List the ParkNParkContext's registered servers.
 NamingContextExt getNameServer()
          Returns the reference to the name service
 NamingContext getParkNParkContext()
          Returns the ParkNPark name context, which can be null if the ParkNPark context was not initialized with a call to refreshParkNParkContext()
 List<Server> getServers()
          Returns the set of ServerState objects
 boolean isPrimaryServerRegistered()
          Returns whether or not a primary server registration exists as of the last call to addServerListFromParkNParkContext()
 boolean refreshParkNParkContext(boolean create, boolean verbose, LogEntry logEntry)
          Refreshes the parkNParkContext name service object that we use to get server bindings on.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

orb

protected ORB orb
Object request broker


servers

private ArrayList<Server> servers
List of active servers


nameServer

private NamingContextExt nameServer
Naming context


parkNParkContext

private NamingContext parkNParkContext
Our naming service's ParkNPark context, which contains server registrations


primaryServerRegistered

protected boolean primaryServerRegistered
Whether or not a primary server registration exists as of the last call to addServerListFromParkNParkContext()


err

protected PrintStream err
The original System.err instance

Constructor Detail

NameService

public NameService(ORB orb,
                   PrintStream err)
Creates a new NameService instance using the given ORB

Parameters:
orb - The ORB to work with
err - The System.err instance to use
Method Detail

getServers

public List<Server> getServers()
Returns the set of ServerState objects

Returns:
The set of ServerState objects

getNameServer

public NamingContextExt getNameServer()
Returns the reference to the name service

Returns:
The reference to the name service

getParkNParkContext

public NamingContext getParkNParkContext()
Returns the ParkNPark name context, which can be null if the ParkNPark context was not initialized with a call to refreshParkNParkContext()

Returns:
The ParkNPark name context

isPrimaryServerRegistered

public boolean isPrimaryServerRegistered()
Returns whether or not a primary server registration exists as of the last call to addServerListFromParkNParkContext()

Returns:
True when a primary server registration exists as of the last call to addServerListFromParkNParkContext() or false otherwise

refreshParkNParkContext

public boolean refreshParkNParkContext(boolean create,
                                       boolean verbose,
                                       LogEntry logEntry)
Refreshes the parkNParkContext name service object that we use to get server bindings on. The name service is contacted from scratch in this method

Parameters:
create - When true and if the ParkNPark context does not exist in the name server, then this method will attempt to create it
verbose - If true, inform the user of possibly-active servers as each one is found
logEntry - A LogEntry object to log name service access times to when not null
Returns:
True if the parkNParkContext was refreshed or false if it was not

addServerListFromParkNParkContext

public boolean addServerListFromParkNParkContext(boolean createParkNParkContext,
                                                 boolean verbose,
                                                 LogEntry logEntry)
Adds to the server List the ParkNParkContext's registered servers. If the name service cannot be contacted, it is contacted as a result of this call

Parameters:
createParkNParkContext - When true and if the ParkNPark context does not exist in the name server, then this method will attempt to create it
verbose - If true, inform the user of possibly-active servers as each one is found
logEntry - A LogEntry object to log name service access times to when not null
Returns:
True when the server list was successfully obtained (even if it's empty) or false if the server list was unavailable