The Talon Manual

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Array types are limited to primitive, built-in, and embedded entity types. They are intended to allow embedded values that are transported along with a message or entity, and consequently:
  • Queue, Set and Queue and Map types can only be used with non-embedded entities and may only use other non-embedded entities as their values.

...

Code Block
<!-- Defines fields which may be referenced by other model elements-->
<fields>
	<field name="myStringField" type="String" id="10000" length="16" doc="My String field" />
</fields>
 
<messages>
	<message name="Message" factoryid="1" id="1">
    	<fieldRef  ref="myStringField" name="myField"required="true" />
    	<field name="myOtherField" type="String" length="16" id=10001" doc="My Other String field" />
	</message>
</messages> 
Field Attributes

...

The type of the element. If the type is defined in this namespace or is a primitive or collection type, only the simple name of the type need be used. If the type belongs to another namespace from an imported file, then the fully qualified name should be used. The best practice when importing a type from another model is to use the fully qualified name of the imported type (e.g. com.example.importedmodel.MyEntity), as this insulates your model from future conflicts in the event that imported models are changed.

If the field is an array type, it should be suffixed with array indices such as MyEntity[] to denote it as an array.

...

Contains the name of the JSON property that will be used for the field when the message is serialized to JSON. Defaults to using the value defined in name.

 

...

The id of the field. The id must be unique with the scope of the containing type. For Xbuf/Protobuf encoding this tag is used as the tag value for the field on the wire. If not set, a unique id will be generated by the source code generator. For better control over compatibility, it is recommended that the application set this value manually.

Field ids must be between 0 and 32767 inclusive

...

If this field refers to a variable length type (such as a string), this indicates the maximum length of the field.

...

Note
titleQualifying conflicting type names

It is not possible to define two types with the same name in a given model. One exception to this rule is that it is possible (though strongly discouraged) to define a type with the same name as a built-in type. In this case, using an unqualified type reference will favor the built-in type. In this case, it is possible to reference the local type by using the this keyword, or the fully qualified name:

Code Block
xml
xml
<model xmlns="http://www.neeveresearch.com/schema/x-adml" 
       xmlns:xsi="http://www.w3.org/2001/XMLSchemainstance"
       name="Trading" 
       namespace="com.mycompany.trading" 
       defaultFactoryId="100">
       doc="Contains Messages used by the Trading Application">
 
  <import model="../orderprocessing.xml"/>
 
  <!--An unfortunately named entity:-->
  <entity name="Currency" id="1">
    <field name="currencyCode" type="String"/>
  </entity>
 
  <entity name="MyEntity" id="2">
    <!-- 
      Without qualifying the Currency type, the built 
      in Currency type is used, and the generated entity
      will return a java.util.Currency.
    -->
    <field name="javaCurrency" type="Currency" />
    <!-- 
      The 'this' keyword indicates that this is the Currency
      entity defined in this model:
    -->
    <field name="currencyEntity" type="this.Currency"/>
    <!-- 
      Namespace qualifying the typeindicates that this is the Currency
      entity defined in this model:
    -->
    <field name="currencyEntity2" type="com.mycompany.trading.Currency"/>
    <!-- 
      Namespace qualifying the type indicates that this is the Currency
      entity defined in some imported model:
    -->
    <field name="currencyEntity3" type="com.mycompany.orderprocessing.Currency"/>
  </entity>
</model>

...

To avoid garbage for embedded messages entities when using Xbuf encoding, while still providing a mechanism for applications to hold such fields in state beyond the lifespan of the message from whence they came, additional take/lend accessors are generated for embedded entity fields. Considerations for using embedded entity fields in the context of message pooling are discussed in detail in the section Embedded Entities.

Code Block
java
java
@Generated(value="com.neeve.adm.AdmGenerator", date="Fri Jan 23 02:03:22 PST 2015")
public interface IMyMessage extends extends IRogNode, IRogMessage {


    final public void setChildField(final Child2 val);
    final public Child2 getChildField();
 
    final public void lendChildField(final Child2 val);
    final public Child2 takeChildField();}

...

  • The field or type element that defines it has a poolable="true" attribute. The String type will be created based on the name of the field. 
  • A semantic type is defined with a base type of string and the poolable attribute set to true. The String type will be based on the name of the type. 
  • For applications that would rather separate the notion of pooling from the model itself, the Code Generator can be run with a directive indicating that all String fields should generate a poolable type (see Directives in the sections below).
  • In the future, different narrower directives may be introduced for finer-grained control over what String fields will create poolable types.

...

  1. Preallocate the pooled string type with preallocated application state, and copy the string from the inbound message into domain state. In this approach, the message keeps its reference to the pooled string field and reuses the same reference when the message is recycled through its pool. 
  2. Use take/lend semantics in the same fashion as with a Nested Entity as described in Xbuf and Embedded Entities. The domain state needn't preallocate the pooled string type but rather takes if from the message which then draws a new instance from a globally configured preallocated when the message itself is recycled to its pool.  

...

Code Block
languagexml
<collections>
  <collection name="MyQueue" is="Queue" contains="MyEntity" 
    factoryid="1" id="5" />
  <collection name="MySet" is="Set" contains="MyEntity" 
    factoryid="1" id="6" />
  <collection name="MyLongMap" contains="MyEntity" is="LongMap" 
    factoryid="1" id="76" />
</collections> 
<entity name="MyEntity" factoryid="1" id="1">
 <field name="longKey" type="Long" isKey="true" id="1"/>
 <field name="aQueue" type="MyQueue" id="2"/>
 <field name="aMap" type="MyStringMap id="3"/>
</entity> 

...