Versions Compared

Key

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


 

Table of Contents
minLevel3
outlinetrue
stylenone

...

Facet Instance is a data structure associated with each incoming request to the TQLEngineA-Stack. Each facet instance is identified by its facet ID and represents a capability to perform certain actions on the TQLEngine. Incoming requests without valid facet IDs are rejected. Each facet instance is also associated with its Facet Type, which is a piece of executable code (a Java class) intended to actually process the request. Facet instances are deployed through packages. A package is a collection of related facet instances.defined by :

  • User Specified Facet ID
  • One of the A-Stack supported Facet Types
  • Protocol Handler Name on which the requests will be listening. 

Syntax

Code Block
languagexmltext
themeEclipse
titleFacetscript within TQL Query
linenumberstrue
For Statement Syntax
<NewFacetInstance fidFid="helloworld" name="HelloWorld" type="SffMsgFacet">
  <OnActivate/>
  <OnOpen ModifyPipeline="HttpServerExtensionArgs"/>
  <OnRequest>
    <DoResponse>
      <Process>
        <Message type="text">
          <Value>
            Hello World from FacetScript!
          </Value>
        </Message>
      </Process>
    </DoResponse>
  </OnRequest>
  <OnResponse/>
  <OnCloseUser-specified unique identifier" Name="Name of the Facet Instance" Type="FacetType Name">
  <!-- Blocks of Lifecycle stages -->
  <OnActivate/>
  <OnOpen ModifyPipeline="Server-side Name of the Protocol Handler"/>
  <OnRequest/>
  <OnResponse/>
  <OnClose/>
  <OnError/>
</NewFacetInstance>

Syntax Notes

  • NewFacetInstances are defined within NewPackage definition. A package definition consists of a collection of FacetInstances.
  • Examples of each of these variations will be provided in the next section. 
  • Incoming requests without valid facet IDs are rejected.


Facet Instance Lifecycle

Once a request legitimacy is established by successful resolution of its facet ID, a processing (Netty) pipeline is created for low level request processing. 

Once request data is presented in a universal fashion (as an instance of ListMap data structure), TQLEngine A-Stack invokes appropriate facet type method using current connection context and facet instance information as arguments.

The facet lifecycle is the beginning-to-end stages of the facet pipeline that are marked by different facet events. Each facet event can be associated with invoking a method. The actual call arguments will be selected by the TQLEngine A-Stack by executing the event-specific piece of facet script found in the facet instance. That is, it is possible to specify a correspondent piece of facet script for each facet event. Such facet script may contain simple logic to check some request value or do template-based data transformation before actual java method invocation.

Gliffy
bordertrue
nameFacet instance event lifecycle

For instance, upon facet instance activation (creation) the TQLEngine A-Stack will invoke the onActivate method; upon incoming request it will invoke onRequest method and so on.

EventDescription
onActivateHandler is called by the engine at the of activation of the facet
onDeactivateHandler is called by the engine at the time of deactivation
onOpenHandler is called, when facet pipeline is opened
onCloseHandler is called, when facet pipeline if closed
onRequestHandler is called when the request is received on the pipeline
onResponseHandler is called when the response is send on the pipeline
onErrorIf error in pipeline, this handler is called and pipeline gets closed

Facet Instance

...

Example

The “Hello, World” program is traditionally used to introduce a programming language. Here is an example of Hello, World in FacetScript:

Code Block
languagexml
themeEclipse
titleNewFacetInstance HelloWorld Example
linenumberstrue
<NewPackage>
<NewFacetInstance fid="helloworld" name="HelloWorld" type="SffMsgFacet">
  <OnActivate/>
  <OnOpen ModifyPipeline="HttpServerExtensionArgs"/>
  <OnRequest>
    <DoResponse>
      <Process>
        <Message type="text">
          <Value>
            Hello World from FacetScript!
          </Value>
        </Message>
      </Process>
    </DoResponse>
  </OnRequest>
  <OnResponse/>
  <OnClose/>
</NewFacetInstance>
</NewPackage>

Once the NewFacetInstance is deployed on A-Stack following EndPoint will be generated:

http://localhost:8080/fid-helloworld

which produces HTTP Response as

Hello World from FacetScript!

For FacetScript Language specs, see here.