After you have written an event listener by using the
preceding example as a guide, you then make the listener known to
the IOM object by using a connection point. A connection point is,
in effect, a child component of an IOM object that serves as a conduit
for passing events from the IOM object to its listeners. IOM objects
that support event interfaces implement an interface called
com.sas.iom.SASIOMDefs.ConnectionPointContainer
, which
includes a method called
FindConnectionPoint()
. To call the
FindConnectionPoint()
method,
you must narrow your object reference to
com.sas.iom.SASIOMDefs.ConnectionPointContainer
, as discussed in
Generic Object References and
IOM Objects That Support More than One Stub..
The
FindConnectionPoint()
method provides you with a reference to the correct connection point.
Because IOM objects can support more than one event interface, you
must identify which connection point you want when you call
FindConnectionPoint()
by using the unique interface
identifier of the event interface and the
com.sas.iom.SASIOMDefs.CP_ID
structure. The unique interface identifier for the event interface
can be found by calling the
id()
method on
the
Helper
class of the event interface.
The following example
shows you how to get a unique interface identifier and use it to initialize
the
com.sas.iom.SASIOMDefs.CP_ID
structure:
String cpidString = com.sas.iom.SASEvents.ILanguageEventsHelper.id();
int d1 = (int)java.lang.Long.parseLong(cpidString.substring(4,12),16);
short d2 = (short)java.lang.Integer.parseInt(cpidString.substring(13,17),16);
short d3 = (short)java.lang.Integer.parseInt(cpidString.substring(18,22),16);
byte[] d4 = new byte[8];
for (int i=0;i2;i++)
{
d4[i] = (byte)java.lang.Short.parseShort(
cpidString.substring(23+(i*2),25+(i*2)),16);
}
for (int i=0;i6;i++)
{
d4[i+2] = (byte)java.lang.Short.parseShort(
cpidString.substring(28+(i*2),30+(i*2)),16);
}
com.sas.iom.SASIOMDefs.CP_ID cpid=new com.sas.iom.SASIOMDefs.CP_ID(
d1,d2,d3,d4);
After you have constructed
the
com.sas.iom.SASIOMDefs.CP_ID
structure,
you are ready to call
FindConnectionPoint()
and obtain a reference to the connection point component. Note that
FindConnectionPoint()
uses an output parameter to return
a reference to the connection point, which means that you must use
the
Holder
class
com.sas.iom.SASIOMDefs.ConnectionPointHolder
. Do not confuse that class with the
com.sas.iom.SASIOMDefs.ConnectionPointContainer
class.
The following example
shows you how to find the connection point for the
com.sas.iom.SASEvents.ILanguageEvents
event interface:
com.sas.iom.SASIOMDefs.ConnectionPointContainer cpContainer =
com.sas.iom.SASIOMDefs.ConnectionPointContainerHelper.narrow(sasLanguage);
com.sas.iom.SASIOMDefs.ConnectionPointHolder cpHolder =
new com.sas.iom.SASIOMDefs.ConnectionPointHolder();
cpContainer.FindConnectionPoint(cpid,cpHolder);
com.sas.iom.SASIOMDefs.ConnectionPoint cp = cpHolder.value;