@interface name="KitChannels" alias="$ENV">
Extension point for defining kit channels
(c) SAP AG 2003-2006. All rights reserved.
+
# The name of the channel implementation class
* # An argument to pass to the channel class constructor.
(1) The argument can be defined in the script section,
and used here (see example).
(2) If the argument is of type string, add type=string
to the arg tag (see example).
(3) The order of the args should match the
order of the arguments in the channel constructor
Example
core.env:myChannelClass
myChannel
[elem1, elem2, elem3]
array
function defineChannel(className, p1, p2, p3, p4, p5,p6,p7) {
// removed,
//if (p1 && UPPER(p1).indexOf('GKB:') == 0 && (UPPER(p1) in _kitChannels)) return ;
var obj = $ENV.createObject(className, p1, p2, p3, p4, p5, p6, p7);
if (!obj) return raiseKitError('Invalid channel "'+className+'" definition' );
var id = UPPER(obj.id);
if (!id) return raiseKitError('Id is missing from "'+className+'" channel definition');
if (!isValidId(obj.id)) return raiseKitError('Invalid namespace specification of Id:'+ obj.id + " in kit :" + _currentPackage);
if (id in _kitChannels) raiseKitError('Channel "'+id+'" is already defined');
_kitChannels[id] = obj
return obj;
}
<@method name="getChannel">
Returns a specified channel
The channel id
The requested channel object
function getChannel(id) {
return _kitChannels[UPPER(id)] || null;
}
<@method name="getChannelsTable">
Returns the complete channels table
Table of channel objects, indexed by channel id
Channel id's are stored in uppercase. Use @lib:Basic!UPPER macro to convert the channel name to uppercase
before using it as the index in this table.
function getChannelsTable() {
return _kitChannels;
}
<@method name="removeChannel">
Removes a specified channel
The id of the channel to remove
function removeChannel(id) {
id = UPPER(id);
if (id.indexOf('GKB:') >= 0) return;
delete _kitChannels[id];
}
<@method name="parseChannel" scope="private">
Parses the given channel node and returns a string which represents its details
channel node to parse
function parseChannel(channelNode) {
var map = getNodeProps(channelNode);
var classname = map['classname'];
if (!classname) return "";
var args = getNodeArgs(channelNode);
var res = "$ENV.defineChannel(" + STR(classname) + "," + JOIN(args,",") + ");";
return res;
}
// INTERNAL: notifies about a channel connection status change
function _notifyChannelConnection(id, status) {
var evt = createEventObject();
evt.channel = id;
evt.online = status;
evtChannelConnect.fire(evt);
}
<@event name="onChannelConnect">
Fires whenever a channel is connected/disconnected
The channel Id
The new channel status