Platform SDK Java 8.5 API Reference

com.genesyslab.platform.commons.connection
Class AttributeSubscriptionList

java.lang.Object
  extended by com.genesyslab.platform.commons.connection.AttributeSubscriptionList

public class AttributeSubscriptionList
extends java.lang.Object

AttributeSubscriptionList is used for defining pairs messageId::attributeId for subscription to row data in incoming protocol "event" messages. Subscribed attributes can be defined or undefined in protocol. In any case subscribed attribute will not be parsed by Platform SDK. They can be accessed on the message level by indexers with their id (in the string form, e.g. "14") as a key.

Attribute subscription feature is useful in case when user needs to:

For example, when there is a need to get Configuration Server objects without parsing to heavy weight Documents or any structures, it is possible to make following subscription configuration:

 ConfServerProtocol protocol = new ConfServerProtocol(
         new Endpoint("conf-srv", HOST, PORT));
 protocol.setUserName(USERNAME);
 protocol.set...

 AttributeSubscriptionList subscriptionList = new AttributeSubscriptionList();
 subscriptionList.addAttribute(EventObjectsRead.ID, "9"); // 9 - "ConfObject"
 subscriptionList.applyToContext(protocol.connectionContext());

 protocol.open();
 
After such configuration of the connection, incoming EventObjectsRead will not contain Documents at eventObjectsRead.getConfObject(), but it will be possible to get raw string as it is packed for transportation with:
 String confData = (String) ((DataSupport) eventObjectsRead).attributes().get("9");
 

For Platform SDK version earlier than 8.5, "raw attribute value" means minimal values "wrapping" with classes like Integer, Long, String or byte[].
So, generally speaking, string type attribute values are unpacked to String's from network and, in special cases like their non-standard encoding, the data may be broken.
To help with this situation, Platform SDK 8.5 attributes subscription support has been extended with ability to subscribe for "more raw" data - actual network bytes.

To take network bytes of an attribute value, the subscription may look like following:

 subscriptionList.addAttribute(EventObjectsRead.ID, "9", AttributeSubscriptionType.Raw);
 
And then the data may be accessed by the way like:
 AttributeRawValue confData = (AttributeRawValue) ((DataSupport) eventObjectsRead).attributes().get("9");
 

See Also:
AttributeRawValue

Nested Class Summary
static class AttributeSubscriptionList.AttributeSubscriptionType
          Enumeration defining possible types of attribute subscription.
 
Field Summary
static java.lang.String SUBSCRIPTION_LIST_KEY
          The key this list is expected in context under.
 
Constructor Summary
AttributeSubscriptionList()
           
 
Method Summary
 void addAttribute(int messageId, java.lang.String attributeId)
          Adds given pair messageId::attributeId to list.
 void addAttribute(int messageId, java.lang.String attributeId, AttributeSubscriptionList.AttributeSubscriptionType type)
          Adds given pair messageId::attributeId to list.
 void applyToContext(ConnectionContext ctx)
          Apply this subscription list to given ConnectionContext.
static boolean attributeSubscribed(ConnectionContext context, int msgId, java.lang.String attrId)
          Deprecated.  
 boolean contains(int messageId, java.lang.String attrId)
          Deprecated.  
 java.util.Map<java.lang.String,AttributeSubscriptionList.AttributeSubscriptionType> getMessageSubscriptions(int messageId)
          Returns attributes mappings for particular message.
 boolean removeAttribute(int messageId, java.lang.String attrId)
          Removes subscription for given messageId::attrId pair.
 boolean removeWholeMessage(int messageId)
          Removes subscription to all attributes for given message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SUBSCRIPTION_LIST_KEY

public static final java.lang.String SUBSCRIPTION_LIST_KEY
The key this list is expected in context under.

See Also:
Constant Field Values
Constructor Detail

AttributeSubscriptionList

public AttributeSubscriptionList()
Method Detail

applyToContext

public void applyToContext(ConnectionContext ctx)
Apply this subscription list to given ConnectionContext. This method replaces subscription in the context (if exists) with the current one.

Parameters:
ctx - ConnectionContext to apply subscription to

contains

@Deprecated
public boolean contains(int messageId,
                                   java.lang.String attrId)
Deprecated. 

Checks if given pair messageId::attributeId is in list

Parameters:
messageId - message ID
attrId - attribute ID
Returns:
true, if this messageId::attributeId is in list
See Also:
getMessageSubscriptions(int)

getMessageSubscriptions

public java.util.Map<java.lang.String,AttributeSubscriptionList.AttributeSubscriptionType> getMessageSubscriptions(int messageId)
Returns attributes mappings for particular message.

For internal use.

Parameters:
messageId - protocol message id.
Returns:
map with subscribed attributes or null if no attributes subscribed on this message.

addAttribute

public void addAttribute(int messageId,
                         java.lang.String attributeId)
Adds given pair messageId::attributeId to list.

Parameters:
messageId - message ID.
attributeId - attribute ID.

addAttribute

public void addAttribute(int messageId,
                         java.lang.String attributeId,
                         AttributeSubscriptionList.AttributeSubscriptionType type)
Adds given pair messageId::attributeId to list.

Parameters:
messageId - message ID.
attributeId - attribute ID.
type - subscription type or null.

removeAttribute

public boolean removeAttribute(int messageId,
                               java.lang.String attrId)
Removes subscription for given messageId::attrId pair.

Parameters:
messageId - message ID
attrId - attribute ID
Returns:
true if the map contained mapping for the attribute on the message.

removeWholeMessage

public boolean removeWholeMessage(int messageId)
Removes subscription to all attributes for given message.

Parameters:
messageId - message ID.
Returns:
true if the map contained mapping for the message.

attributeSubscribed

@Deprecated
public static boolean attributeSubscribed(ConnectionContext context,
                                                     int msgId,
                                                     java.lang.String attrId)
Deprecated. 

Check if context contains subscription for row data of specified attribute

Parameters:
context - connection context to look in.
msgId - message ID.
attrId - attribute ID.
Returns:
true if the attribute is subscribed on the given message.
See Also:
getMessageSubscriptions(int)

Platform SDK Java 8.5 API Reference

Send comments on this topicTechpubs.webadmin@genesys.com.
Document version: 8.5.302.00
Copyright © 2006–2017 Genesys Telecommunications Laboratories, Inc. All rights reserved.