Cisco Cisco Customer Voice Portal 8.0(1) Entwickleranleitung

Seite von 98
0
 
T
HE 
V
OICE 
F
OUNDATION 
C
LASSES
 
 
V
OICE
XML
 
P
ROGRAMMING 
G
UIDE 
 
 
 
FOR 
C
ISCO 
U
NIFIED 
C
USTOMER 
V
OICE 
P
ORTAL 
R
ELEASE 
4.0(1) 
 
 
 
 
76
 
and version 2.0, and the similarities are encapsulated in a common base class. Figure 15-1 shows 
this graphically with the 
VForm
 class. The main 
VForm
 class extends the 
VRoot
 class and is itself 
extended by 
VFormV1
 and 
VFormV2
, representing VoiceXML 1.0 and 2.0 compliance. Luckily, 
there are only a few differences between these versions, so the developer can still do most coding 
to the base 
VForm
 class. The Gateway Adapters introduce VFCs that extend 
VFormV1
 or 
VFormV2
 
depending on whether the voice browser it supports is compatible with VoiceXML 1.0 or 2.0. 
 
Figure 15-1 
The last concept is that VFC objects are not instantiated using the 
new
 keyword. A static factory 
method named 
getNew
 is used instead. The reason for this is related to the abstraction of the 
voice browser differences. As mentioned previously, a developer need only code using the base 
VFC classes. At runtime, the factory methods used to instantiate VFC classes actually returns the 
appropriate voice browser-specific VFC (for example, 
VFormFoo
But since the developer treats the return object as the base VFC, that object is downcasted. This 
is the heart of the VFC abstraction design. Since all VFC derivative classes extend their base 
VFCs, a developer need only code to the base VFCs and that automatically makes their code 
compatible with any voice browser represented by a Gateway Adapter. 
In order to identify which voice browser VFC to return, every factory method must include as its 
first argument an instance of 
VPreference
VPreference
, while a VFC class, does not match to 
a VoiceXML tag, it is used instead to hold preferences made by the user in Unified CVP 
VoiceXML Studio for the application, such as the voice browser and default audio path. By 
passing this object to all factory methods, the appropriate object can be returned. The 
VPreference
 instance is automatically created for the developer and made available through the 
Session API passed to voice elements, hotevents, or call end classes. 
The following Java code demonstrates the concepts described above: