|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectJICSCore.OCSCORBAHelper
public class OCSCORBAHelper
This class will be used to provide a number of convenience CORBA related functions which can be used throughout the WHTICS system. It provides a wrapper around some of the common CORBA related tasks that need to be performed when creating a CORBA based client or server.
Example
This code is from the ParameterNoticeBoard. The ParameterNoticeBoard object implements two CORBA interfaces and as such both interfaces must be handled separately. Two entries, one for each of the interfaces are entered into the COS name service in different contexts.
public static void main(java.lang.String[] args) { // This will be used to perform a lot of the donkey work // associated with setting up a CORBA server. OCSCORBAHelper OCSCorba = null; // The CORBA request broker or ORB which will be used for handling // CORBA requests ORB orb = null; // The portable object adapter which will be used by this class POA parameterNoticeBoardPOA = null; // This is the root naming service context NamingContextExt RootNamingServiceContext = null; // Set up the default port for connection to the name service // on this machine. Note that the persistent port is 35576 for // the parameter noticeboard. try { OCSCorba = new OCSCORBAHelper(args,"35675","15242","ParameterNoticeBoardPOA"); } catch (UnableToFindNameServerException e) { System.out.println("Unable to find name server " + e.getMessage()); System.exit(-1); } catch (Exception e) { System.out.println("Error when initialising CORBA " + e.toString()); System.exit(-2); } // Now get a reference to the ORB singleton orb = OCSCorba.getORB(); // Now get a reference to the POA capable of creating persistent POAs // from the OCSCORBAHelper class parameterNoticeBoardPOA = OCSCorba.getPOA(); // Now get a reference to the COS name service RootNamingServiceContext = OCSCorba.getNameServiceReference(); // Now we need to create a instance of the // ParameterNoticeBoard CORBA object ParameterNoticeBoard parameterNoticeBoard = new ParameterNoticeBoard(syslogMessageHandler,orb); // Now attempt to add a reference to the ParameterNotice board // to the naming service. Note that we wrap the object up in a // TIE reference to get around the multiple inheritence // problem of java. ParameterNoticeBoardSupplierPOATie parameterNoticeBoardPseudoImpl = new ParameterNoticeBoardSupplierPOATie(parameterNoticeBoard); try { parameterNoticeBoardPOA.activate_object_with_id("ParameterNoticeBoard".getBytes(), parameterNoticeBoardPseudoImpl); } catch (Exception e) { System.out.println("Unable activate parameter noticeboard object > " + e.toString()); System.exit(-2); } // Now store the reference to the parameter noticeboard // interface in the name service using the OCSCorbaHelper library // Note by specifying null as the context signifies that the object // reference will be stored in the root context. try { OCSCorba.storeReferenceInNameService(parameterNoticeBoardPseudoImpl,null,"ParameterNoticeBoard"); } catch (Exception e) { System.out.println("Unable to store parameter noticeboard reference " + e.toString()); System.exit(-2); } // Now register the same object again only this time storing // it's InstrumentController interface so that we can provide // instrument control actions on the parameter noticeboard // (like close it down properly) InstrumentControllerPOATie controllerPseudoImpl = new InstrumentControllerPOATie(parameterNoticeBoard); try { parameterNoticeBoardPOA.activate_object_with_id("NoticeBoard".getBytes(), controllerPseudoImpl); } catch (Exception e) { System.out.println("Unable to activate object > " + e.toString()); System.exit(-2); } // Now we need to store a reference to the CORBA // InstrumentController interface which will be used to close // the program down and modify it's behaviour. // // Note that although it is the same object, we have to treat // both the interfaces that it implements individually with // respect to CORBA try { OCSCorba.storeReferenceInNameService(controllerPseudoImpl, "InstrumentController","ParameterNoticeBoard"); } catch (Exception e) { System.out.println("Unable to store instrument controller reference " + e.toString()); System.exit(-3); } // Now activate the POA so we can wait for incoming service // requests try { parameterNoticeBoardPOA.the_POAManager().activate(); } catch (Exception e) { System.out.println("Unable to activate parameter noticeboard POA " + e.getMessage() + " exiting application"); System.exit(-1); } // Start servicing requests on our CORBA objects orb.run(); }
Field Summary | |
---|---|
(package private) static boolean |
ClassInstantiated
Used to ensure that only ever one instance of this class exists in a process. |
private java.lang.String |
COSNameServiceHost
The machine which is hosting the name service |
private int |
NameServicePortNumber
This is the port number of the name service which by default is 35777 |
private org.omg.CORBA.ORB |
Orb
A reference to the the ORB singleton for this process |
private java.lang.String |
ORBName
This is the name of the ORB which will be used in the event of one not been supplied. |
private iParameterNoticeBoard.ParameterNoticeBoardSupplier |
ParameterNoticeBoard
This is a reference to the parameter noticeboard; |
private org.omg.PortableServer.POA |
Poa
This is a POA which is to be created. |
private java.lang.String |
POAName
This is the name of the POA which will be used in the event of one not been supplied. |
private org.omg.CosNaming.NamingContextExt |
rootNamingServiceContext
This is a reference to the top level context in the naming service |
private org.omg.PortableServer.POA |
rootPOA
This is the root POA of the CORBA system |
Constructor Summary | |
---|---|
OCSCORBAHelper(java.lang.String[] args,
java.util.Properties CORBAHelperProperties)
The constructor. |
|
OCSCORBAHelper(java.lang.String[] args,
java.lang.String POAName)
The constructor. |
|
OCSCORBAHelper(java.lang.String[] args,
java.lang.String POAName,
int COSNameServicePortNumber)
The constructor. |
|
OCSCORBAHelper(java.lang.String[] args,
java.lang.String POAName,
int COSNameServicePortNumber,
java.lang.String COSNameServiceHost)
The constructor. |
|
OCSCORBAHelper(java.lang.String[] args,
java.lang.String POAName,
java.lang.String COSNameServiceHost)
The constructor. |
|
OCSCORBAHelper(java.lang.String[] args,
java.lang.String ORBPersistentPort,
java.lang.String ORBServerID,
java.lang.String POAName)
The constructor. |
|
OCSCORBAHelper(java.lang.String[] args,
java.lang.String ORBPersistentPort,
java.lang.String ORBServerID,
java.lang.String POAName,
java.lang.String COSNameServiceHost)
The constructor. |
Method Summary | |
---|---|
void |
CORBAcloseDown()
Close down the CORBA communications. |
void |
createNamingServiceContext(java.lang.String Context)
Creates a new context in the naming service. |
org.omg.PortableServer.POA |
createNewPOA(java.lang.String POAIdentifier)
This will be used to create a new POA which supports persistent object references. |
private org.omg.CosNaming.NamingContextExt |
findNameService()
Looks up and returns a proxy Name Server CORBA object which can be used to access the name server. |
iInstrumentController.InstrumentController |
getInstrumentControllerReference(java.lang.String InstrumentControllerTaskName)
Returns a CORBA reference to the instrument controller interface associated with the instrument controller which was specified as part of the argument sequence. |
org.omg.CosNaming.NamingContextExt |
getNameServiceReference()
Returns a reference to the CORBA name service which was resolved when the class was instantiated. |
org.omg.CORBA.ORB |
getORB()
Returns a reference to the ORB singleton. |
iParameterNoticeBoard.ParameterNoticeBoardSupplier |
getParameterNoticeBoardReference()
Returns a CORBA reference to the parameter noticeboard. |
org.omg.PortableServer.POA |
getPOA()
Returns a reference to a POA which was setup to create objects with persistent IOR references |
private void |
InitialiseCORBAHelper(java.lang.String[] args,
java.lang.String POAName)
Will be used to initialise the CORBA helper but no persistent reference policy will be created for this ORB/POA. |
(package private) void |
InitialiseCORBAHelper(java.lang.String[] args,
java.lang.String ORBPersistentPort,
java.lang.String ORBServerID,
java.lang.String POAName)
Initialise the ICS CORBA helper class. |
static void |
main(java.lang.String[] args)
This is the main routine and can be used to test the class |
void |
storeReferenceInNameService(org.omg.PortableServer.Servant ActiveServant,
java.lang.String Context,
java.lang.String NamingServiceLocation)
Store a given CORBA servant reference to the name service. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private java.lang.String ORBName
private java.lang.String POAName
private java.lang.String COSNameServiceHost
private iParameterNoticeBoard.ParameterNoticeBoardSupplier ParameterNoticeBoard
private org.omg.PortableServer.POA rootPOA
private org.omg.PortableServer.POA Poa
private org.omg.CORBA.ORB Orb
private org.omg.CosNaming.NamingContextExt rootNamingServiceContext
private int NameServicePortNumber
static boolean ClassInstantiated
Constructor Detail |
---|
public OCSCORBAHelper(java.lang.String[] args, java.util.Properties CORBAHelperProperties) throws UnableToFindNameServerException, java.lang.Exception
Note that this method performs the configuration necessary to create persistent references in jacorb and the Sun ORB. Should another ORB be used, it will need to be configured further.
args
- This should contain the command line
arguments which were passed into the application. These may contain options
which could modify the behaviour of the ORB.
CORBAHelperProperties
- A set of properties which will be used by the
class to configure the ORB help. The details of the possible
properties which can be set are highlighted in the table below :
Property | Meaning | |
---|---|---|
PersistentPortNumber | The port for the task to bind to. If not specified then a random port will be used but the ORB will not create persistent references. | |
COSNameServiceHost | This is the machine which is hosting the COS name service. The default is localhost | |
ORBName | The name of the ORB server. Defaults to DEFAULTORB | |
POAName | The is the name of the default POA which is created. The default is DEFAULTPOA | |
COSNameServicePortNumber | The port to be used to talk to the COS name service. Defaults to 35777 if not specified. |
UnableToFindNameServerException
java.lang.Exception
getPOA()
public OCSCORBAHelper(java.lang.String[] args, java.lang.String ORBPersistentPort, java.lang.String ORBServerID, java.lang.String POAName) throws UnableToFindNameServerException, java.lang.Exception
Note that this method performs the configuration necessary to create persistent references in jacorb and the Sun ORB. Should another ORB be used, it will need to be configured further.
args
- This should contain the command line
arguments which were passed into the application. These may contain options
which could modify the behaviour of the ORB.
ORBPersistentPort
- A host unique port number which will
be used by this CORBA server to maintain persistent object references.
ORBServerID
- A string which will be used in
defining the persistent object reference for this process.
POAName
- This is the name to give to the POA which will be
created with a persistent policy.
UnableToFindNameServerException
java.lang.Exception
getPOA()
public OCSCORBAHelper(java.lang.String[] args, java.lang.String ORBPersistentPort, java.lang.String ORBServerID, java.lang.String POAName, java.lang.String COSNameServiceHost) throws UnableToFindNameServerException, java.lang.Exception
Note that this method performs the configuration necessary to create persistent references in jacorb and the Sun ORB. Should another ORB be used, it will need to be configured further.
args
- This should contain the command line
arguments which were passed into the application. These may contain options
which could modify the behaviour of the ORB.
ORBPersistentPort
- A host unique port number which will
be used by this CORBA server to maintain persistent object references.
ORBServerID
- A string which will be used in
defining the persistent object reference for this process.
POAName
- This is the name to give to the POA which will be
created with a persistent policy.
COSNameServiceHost
- This is the name of the machine which is to host the name service.
UnableToFindNameServerException
java.lang.Exception
getPOA()
public OCSCORBAHelper(java.lang.String[] args, java.lang.String POAName, int COSNameServicePortNumber, java.lang.String COSNameServiceHost) throws UnableToFindNameServerException, java.lang.Exception
args
- This should contain the command line
arguments which were passed into the application. These may contain options
which could modify the behaviour of the ORB.
POAName
- This is the name of the POA which is to be createdCOSNameServicePortNumber
- This is the port number upon which we expect to find the COS Name serviceCOSNameServiceHost
- This is the name of the machine which is hosting the COS name service
UnableToFindNameServerException
java.lang.Exception
getPOA()
public OCSCORBAHelper(java.lang.String[] args, java.lang.String POAName, int COSNameServicePortNumber) throws UnableToFindNameServerException, java.lang.Exception
args
- This should contain the command line
arguments which were passed into the application. These may contain options
which could modify the behaviour of the ORB.
POAName
- This is the name of the POA which is to be createdCOSNameServicePortNumber
- This is the port number upon which we expect to find the COS Name service
UnableToFindNameServerException
java.lang.Exception
getPOA()
public OCSCORBAHelper(java.lang.String[] args, java.lang.String POAName, java.lang.String COSNameServiceHost) throws UnableToFindNameServerException, java.lang.Exception
args
- This should contain the command line
arguments which were passed into the application. These may contain options
which could modify the behaviour of the ORB.
POAName
- This is the name of the POA which is to be createdCOSNameServiceHost
- This is the name of the machine which is hosting the COS name service
UnableToFindNameServerException
java.lang.Exception
getPOA()
public OCSCORBAHelper(java.lang.String[] args, java.lang.String POAName) throws UnableToFindNameServerException, java.lang.Exception
args
- This should contain the command line
arguments which were passed into the application. These may contain options
which could modify the behaviour of the ORB.
POAName
- This is the name of the POA which is to be created
UnableToFindNameServerException
java.lang.Exception
getPOA()
Method Detail |
---|
void InitialiseCORBAHelper(java.lang.String[] args, java.lang.String ORBPersistentPort, java.lang.String ORBServerID, java.lang.String POAName) throws UnableToFindNameServerException, java.lang.Exception
Note that this method performs the configuration necessary to create persistent references in jacorb and the Sun ORB. Should! another ORB be used, it will need to be configured further.
args
- This should contain the command line
arguments which were passed into the application. These may contain options
which could modify the behaviour of the ORB.
ORBPersistentPort
- A host unique port number which will
be used by this CORBA server to maintain persistent object references.
ORBServerID
- A string which will be used in
defining the persistent object reference for this process.
POAName
- This is the name to give to the POA which will be
created with a persistent policy.
UnableToFindNameServerException
java.lang.Exception
getPOA()
private void InitialiseCORBAHelper(java.lang.String[] args, java.lang.String POAName) throws UnableToFindNameServerException, java.lang.Exception
args
- Command line arguments which will be passed to the ORB.POAName
- This is the name of the name of the POA.
UnableToFindNameServerException
- If the name service cannot be contacted.
java.lang.Exception
getPOA()
public org.omg.PortableServer.POA createNewPOA(java.lang.String POAIdentifier) throws UnableToCreatePOA
POAIdentifier
- The identifier which is to be associated with the POA
The POA which was created by the method.
UnableToCreatePOA
- If we are unable to create the POA
for whatever reason
private org.omg.CosNaming.NamingContextExt findNameService() throws UnableToFindNameServerException
A reference to root naming context in the name server.
UnableToFindNameServerException
- When unable to locate the name server
public org.omg.PortableServer.POA getPOA()
The POA which was created when the class was instantiated.
createNewPOA(java.lang.String)
public org.omg.CORBA.ORB getORB()
public org.omg.CosNaming.NamingContextExt getNameServiceReference()
public iInstrumentController.InstrumentController getInstrumentControllerReference(java.lang.String InstrumentControllerTaskName) throws UnableToLocateInstrumentController
InstrumentControllerTaskName
- This is the name of the
instrument controller task which we are to locate
UnableToLocateInstrumentController
- Unable to find the
details of the instrument controller which was specified in the
name servicepublic iParameterNoticeBoard.ParameterNoticeBoardSupplier getParameterNoticeBoardReference() throws UnableToLocateParameterNoticeBoard
UnableToLocateParameterNoticeBoard
- When unable to
resolve the reference to the parameter noticeboard from the name service.
public void createNamingServiceContext(java.lang.String Context) throws java.lang.Exception
Context
- This is the name of the context to be created in
the naming service. This should take the form of ContextA/ContextB.
java.lang.Exception
- This is thrown if there are any problems
creating the new context.public void storeReferenceInNameService(org.omg.PortableServer.Servant ActiveServant, java.lang.String Context, java.lang.String NamingServiceLocation) throws java.lang.Exception
ActiveServant
- This is an active servant which is to
be stored in the naming service.
Context
- This is the full context in the name service in which
the object reference is to be stored. This should be left null if it is
to be stored in the top level context of the name service.
For example, the following are valid contexts
Do not specify the trailing / symbol.
Note that if the context does not already exist in the COS name service, it will be automatically created.
NamingServiceLocation
- This is the label with which the object
will be stored in the naming service.
org.omg.PortableServer.POAPackage.ServantNotActive
- The servant which was provided has not
been activated using the POA
java.lang.Exception
createNamingServiceContext(String)
public void CORBAcloseDown()
public static void main(java.lang.String[] args)
args
- Command line arguments provided when started
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |