<source><name>Hemi.transaction</name><project><name>Hemi JavaScript Framework</name><url-title>Hemi JavaScript Framework Project</url-title><url>/Hemi/</url></project><package><path>Hemi.transaction</path><library>Hemi</library><description>The Transaction Service provides an object-level communication bus. Unlike events, delegates, and message subscriptions and publications, the transaction service coordinates disimilar objects on a common band.  Non Framework Objects may be decorated with the Transaction Participant API, and allow cross-Framework coordination.</description><static-class><name>service</name><description>Static instance of the serviceImpl class.</description><version>3.1.9</version></static-class><static-class><name>TransactionParticipant</name><description>This static class describes the interface an object must expose to participate in the TransactionService.  A participant must be registered with the ObjectRegistry.  The addServiceAPI method may be used to instrument this API for quick access to the service.</description><method><name>doTransaction</name><param name="s" type="TransactionService">The TransactionService object handling this transaction.</param><param name="p" type="TransactionPacket">The packet being served.</param><return-value name="z" type="boolean">Always returns false.</return-value><description>Processes the served transaction packet.</description></method><method><name>startTransaction</name><param name="s" type="TransactionService">The TransactionService object handling this transaction.</param><param name="p" type="TransactionPacket">The packet for this transaction.</param><description>Starts the transaction for the specified packet.</description></method><method><name>endTransaction</name><param name="s" type="TransactionService">The TransactionService object handling this transaction.</param><param name="p" type="TransactionPacket">The packet for this transaction.</param><description>Ends the transaction for the specified packet.</description></method><version>3.1.9</version></static-class><class><name>TransactionPacket</name><version>3.1.9</version><description>This is an abstract class generated by the TransactionService. It has no public initializer or constructor.</description><property type="String" get="1"><name>service_id</name><description>The unique identifier of the service to which this packet belongs.</description></property><property type="String" get="1"><name>packet_id</name><description>The unique identifer of the packet.</description></property><property type="String" get="1"><name>packet_name</name><description>The name of the packet.</description></property><property type="hash" get="1"><name>participants</name><description>Hash of object identifiers that are participating in the transaction for this packet. The hash key is the object identifier, and the hash value is the participant state.  State values are: 0 = not participating / transaction ended, 1 = participating, 2 = participated and completed with a positive (true) response.</description></property><property type="int" get="1"><name>participant_count</name><description>Number of participants currently using this packet.</description></property><property type="int" get="1" set="1"><name>packet_state</name><description>Variable use property.</description></property><property type="int" get="1"><name>serve_type</name><description>The type of service this packet will receive.  1 indicates the packet will be served untill all participants return true from <i>doTransaction</i>.  2 indicates the packet is only served once.</description></property><method><name>setBlockStartTransaction</name><param name="b" type="boolean">Bit indicating whether the packet is blocked from being served during <i>startTransaction</i>.</param><description>Specifies whether the packet should be served during <i>startTransaction</i>.</description></method><method><name>setBlockServeTransaction</name><param name="b" type="boolean">Bit indicating whether the packet is blocked from being served during <i>serveTransaction</i>.</param><description>Specifies whether the packet should be served during <i>serveTransaction</i>.</description></method><method><name>setBlockEndTransaction</name><param name="b" type="boolean">Bit indicating whether the packet is blocked from being served during <i>endTransaction</i>.</param><description>Specifies whether the packet should be served during <i>endTransaction</i>.</description></method><method><name>setServeType</name><param name="i" type="int">The type of service this packet will receive.  1 indicates the packet will be served untill all participants return true from <i>doTransaction</i>.  2 indicates the packet is only served once.</param><description>Sets the packet serve type.</description></method><property type="boolean" get="1"><name>is_open</name><description>Bit indicating whether the packet is open.</description></property><property type="boolean" get="1"><name>is_finalized</name><description>Bit indicating whether the packet has been finalized.</description></property><property type="int" get="1" set="1"><name>errors</name><description>Variable use property.</description></property><property type="String" get="1"><name>owner_id</name><description>Identifier of the registered object that owns the packet.</description></property><property type="variant" get="1" set="1"><name>data</name><description>The packet data.</description></property></class><static-class><name>transaction</name><description>Static instance of the serviceImpl class.</description><version>3.1.9</version><method><name>addServiceAPI</name><param name="o" type="Object">Object onto which to inject helper methods for working with transactions.</param><return-value name="b" type="boolean">Bit indicating whether the service API was injected where otherwise not defined.</return-value><description>Injects the required API for working with transactions onto the target object.</description></method><method virtual="1"><name>_handle_transaction</name><param name="s" type="TransactionService">The TransactionService object handling this transaction.</param><param name="p" type="TransactionPacket">The packet being served.</param><description>Processes the served transaction packet.</description></method><method virtual="1"><name>_handle_begin_transaction</name><param name="s" type="TransactionService">The TransactionService object handling this transaction.</param><param name="p" type="TransactionPacket">The packet being served.</param><description>Invoked when the transaction for the specified packet begins.</description></method><method virtual="1"><name>_handle_end_transaction</name><param name="s" type="TransactionService">The TransactionService object handling this transaction.</param><param name="p" type="TransactionPacket">The packet being served.</param><description>Invoked when the transaction for the specified packet ends.</description></method><method virtual="1"><name>_handle_packettype</name><param name="s" type="TransactionService">The TransactionService object handling this transaction.</param><param name="p" type="TransactionPacket">The packet being served.</param><description>Processes the served transaction packet for the specified type. IE if a packet has the type 'custompacket', then you can define a method named <i>_handle_custompacket</i></description></method><method virtual="1"><name>getPacket</name><return-value name="p" type="TransactionPacket">TransactionPacket object.</return-value><description>Returns the transaction packet associated with this component.</description></method><method virtual="1"><name>startTransaction</name><param name="s" type="TransactionService">The TransactionService object handling this transaction.</param><param name="p" type="TransactionPacket">The packet for this transaction.</param><return-value name="z" type="boolean">Always returns true.</return-value><description>Starts the transaction for the specified packet. Automatically invokes <i>_handle_begin_transaction</i> if defined.</description></method><method virtual="1"><name>endTransaction</name><param name="s" type="TransactionService">The TransactionService object handling this transaction.</param><param name="p" type="TransactionPacket">The packet for this transaction.</param><return-value name="z" type="boolean">Always returns true.</return-value><description>Ends the transaction for the specified packet. Automatically invokes <i>_handle_end_transaction</i> if defined.</description></method><method virtual="1"><name>doTransaction</name><param name="s" type="TransactionService">The TransactionService object handling this transaction.</param><param name="p" type="TransactionPacket">The packet being served.</param><return-value name="z" type="boolean">Always returns false.</return-value><description>Processes the served transaction packet.  Automatically invokes <i>_handle_transaction</i>, if it was defined.  Also will invoke <i>_handle_packettype</i> if defined.  IE if a packet has the type 'custompacket', then you can define a method named <i>_handle_custompacket</i></description></method>
(x || y);
<method virtual="1"><name>serveTransaction</name><param name="t" type="variant">Variant value used to identify the type of the packet.</param><param name="s" type="variant">Variant value used to identify the source of the packet.</param><param name="b" type="boolean">Bit indicating whether the packet should be served to the owner.</param><param name="n" type="String">Packet name.</param><return-value name="z" type="boolean">Returns true if a packet exists and was served, false otherwise.</return-value><description>Serves the transaction packet to transaction participants.</description></method>
alert(n + ":" + p.participants.length);
<method virtual="1"><name>joinTranactionPacket</name><param name="s" type="String">The packet name.</param><return-value name="sPacketId" type="String">The transaction packet identifier.</return-value><description>Joins the object to the packet, and returns the packet identifier.</description></method>
alert("Warn packet overwrite: " + t.properties.PacketId + " with " + i);
<method virtual="1"><name>removeFromTransactionPacket</name><param name="s" type="String">The packet name.</param><return-value name="sPacketId" type="String">The transaction packet identifier.</return-value><description>Removes the object from the packet.</description></method></static-class><class><name>serviceImpl</name><description>A class for managing communication between objects implementing the TransactionParticipant API, and using TransactionPacket objects.</description><version>3.1.9</version><method><name>isPacket</name><param name="i" type="variant">Name or index of the TransactionPacket object..</param><return-value name="b" type="boolean">Bit indicating whether the specified object name exists.</return-value><description>Returns true if the specified name exists.</description></method><method><name>getPackets</name><return-value name="a" type="array">Array of TransactionPacket objects.</return-value><description>Returns an array of TransactionPacket objects.</description></method><method><name>getPacket</name><param name="i" type="int">Index of the TransactionPacket object..</param><return-value name="e" type="TransactionPacket">XHTMLForm object.</return-value><description>Returns the specified TransactionPacket object.</description></method><method><name>getPacketByName</name><param name="n" type="String">Name of the element.</param><return-value name="e" type="TransactionPacket">TransactionPacket object.</return-value><description>Returns the specified TransactionPacket object.</description></method><method><name>sigterm</name><description>Sends a termination signal to the service, and closes all open packets.</description></method><method><name>getRegisteredObjects</name><description>Returns an array of object identifiers that are registered with the TransactionService.</description><return-value type="array" name="a">Array of object identifiers</return-value></method><method><name>getRegisteredObjectsMap</name><description>Returns a hashmap of object identifiers and the index into the registered objects array.</description><return-value type="array" name="a">Hashmap of object identifiers</return-value></method><method><name>canRegister</name><param name="o" type="object">Object to test whether or not it can be registered.</param><description>Tests an object to determine if it can be registered.</description><return-value type="boolean" name="b">True if the object can be registered, otherwise false.</return-value></method><method><name>isRegistered</name><param name="o" type="object">Object to test whether or not it is registered.</param><description>Returns whether an object is registered..</description><return-value type="boolean" name="b">True if the object is registered, otherwise false.</return-value></method><method><name>register</name><param name="o" type="object">Object to register with the TransactionService.</param><param name="b" type="boolean" optional="1">Bit indicating the object should be instrumented with the transaction API.</param><description>Registers an object with the transaction service.</description><return-value type="boolean" name="b">True if the object was registered, otherwise false.</return-value></method><method><name>unregister</name><param name="o" type="object">Object to register with the TransactionService.</param><description>Unregisters an object with the transaction service.</description><return-value type="boolean" name="b">True if the object was unregistered, otherwise false.</return-value></method><method><name>removeTransactionParticipants</name><param name="o" type="TransactionParticipant">Object that is registered with the TransactionService.</param><description>Removes object from all transaction participations.</description></method><method><name>addTransactionParticipant</name><param name="o" type="TransactionParticipant">Object that is registered with the TransactionService.</param><param name="p" type="TransactionPacket">TransactionPacket with which the specified object should participate.</param><description>Adds an object to participate with the specified TransactionPacket.</description><return-value type="boolean" name="b">True if the object is participating with the packet, otherwise false.</return-value></method>
HemiEngine.log("Add P: " + t.isRegistered(o) + " / " + t.isPacket(p) + " / " + p.participants[o.object_id]);
<method><name>removeTransactionParticipant</name><param name="o" type="TransactionParticipant">Object that is registered with the TransactionService.</param><param name="p" type="TransactionPacket">TransactionPacket with which the specified object is participating.</param><description>Removes an object from participating with the specified TransactionPacket.</description><return-value type="boolean" name="b">True if the object was removed from participating with the packet, otherwise false.</return-value></method><method><name>serveTransaction</name><param name="p" type="TransactionPacket">TransactionPacket with which the specified object is participating.</param><param name="i" type="String" optional="1" default="owner id">Identifier of the object that should act as the controller of the packet.  Defaults to the packet owner.</param><param name="b" type="boolean" optional="1" default="false">Skip serving the packet to the controller.</param><description>Serves the specified TransactionPacket to its participants.</description><return-value type="boolean" name="b">True if the packet was served, otherwise false.</return-value></method><method><name>closeTransaction</name><param name="i" type="String">Name of the TransactionPacket.</param><description>Closes the transaction represented by the specified TransactionPacket.</description></method><method internal="1"><name>newTransactionPacket</name><param name="i" type="String">Packet identifier.</param><param name="n" type="String">Packet name.</param><param name="o" type="String">Owner id.</param><param name="v" type="object">Variant data.</param><param name="f" type="function">Packet finalization handler.</param><description>Creates a new TransactionPacket.</description><return-value type="TransactionPacket" name="p">A new TransactionPacket.</return-value></method><method><name>openTransaction</name><param name="n" type="String">Name of the transaction.</param><param name="p" type="TransactionParticipant" optional="1">Parent object.</param><param name="d" type="variant" optional="1">Data associated with the transaction.</param><param name="f" type="function" optional="1">Function to invoke when transaction completes and the TransactionPacket is finalized.</param><description>Opens a new transaction and returns the TransactionPacket identifier.</description><return-value type="String" name="i">Identifier of the new TransactionPacket.</return-value></method></class></package><index><description>The Transaction Service provides an object-level communication bus. Unlike events, delegates, and message subscriptions and publications, the transaction service coordinates disimilar objects on a common band.  Non Framework Objects may be decorated with the Transaction Participant API, and allow cross-Framework coordination.</description><url>Hemi_api.html</url><url-title>API Index</url-title></index></source>
