WARNING: This server provides a static reference view of the NetKernel documentation. Links to dynamic content do not work. For the best experience we recommend you install NetKernel and view the documentation in the live system .

An accessor is an endpoint that provides access to resources or services within a space. There is a one-to-one relationship between an accessor logical endpoint and its implementing physical endpoint. An endpoint is bound to its space with a grammar that defines the set of identifiers that resolve to it.

2009-06-21 11:48ZCanvas 1Layer 1SpaceAccessor

Service Accessor

A service accessor is a resource transformation function. It expects resource references as its argument values and it returns a representation of the transformed resource(s). A service accessor is bound to its space using a grammar that specifies the active: URI scheme. A service accessor is stateless; all state, or the identifiers of state, required to perform its work is supplied in the request in the form of named arguments.

Example

A random number generator service returns a resource representation containing a number that follows a pseudo-random distribution. Because it requires no state, this service can be declared with a simple grammar matching the identifier active:random.

<accessor>
  <grammar>
    <active>
      <identifier>active:random</identifier>
    </active>
  </grammar>
  <class>com.mycomp.security.RandomNumberAccessor</class>
</accessor>

Example

The MD5 secure hash function returns a resource representation that is the MD5 hash transformation of resource identified by the operand named argument. An identifier for the MD 5 hash transformation of the resource http://1060.org/upload/readme.txt is:

active:md5+operand@http://1060.org/upload/readme.txt

Example

The XSL Transform service, active:xslt, returns a resource representation that is the XSL transform of an XML resource as specified by an XSLT stylesheet. The two named arguments for this service are operand (for the XML to be transformed) and operator (for the XSLT stylesheet). An identifier for an example XSL transform is:

active:xslt+operand@res:/data.xml+operator@style.xsl

Example

A language runtime is a resource transformation. Any supported language can be used to transform a program into a resource. The following two identifiers illustrate how to use the active:java and active:groovy language runtime services:

active:java+operand@res:/resources/code/GenerateMenu+menu@res:/resources/menu/firstMenu.xml

active:groovy+operand@res:/resources/code/Min.gy+table@res:/resources/data/inputData.txt

Resource Accessor

A resource accessor provides access to resources within a space, acting as a gateway to the information managed by the system. At a minimum, an accessor supports the SOURCE verb and will return an immutable copy of the requested information. In addition to SOURCE an accessor may also support the verbs SINK, NEW, DELETE and EXISTS each of which implies certain semantics.

It is important to distinguish an accessor from the resource it accesses. An accessor is a stateless gateway to the state of the system. When an accessor processes a request it is provided all of the state needed to act on its system state (such as a representation to be used to update a resource when processing the SINK verb)

Example

The resource identified by res:/customers/ contains information about the set of all customers in an application. A request with the verb SOURCE will be resolved to the logical endpoint declared in a space with a grammar matching this one identifier. Note that the declaration specifies the physical endpoint that implements this accessor logical endpoint:

<accessor>
  <grammar>res:/customers/</grammar>
  <class>com.mycomp.customers.CustomerListAccessor</class>
</accessor>

Example

A set of resources contains members referenced by identifiers following the pattern res:/customer/{customer-id}. The accessor for this set is declared in a space using a grammar that parses the request identifiers and assigns the trailing portion of the identifier (the {customer-id} portion) to an argument named "id". The named argument ("id") and its value is available to the physical endpoint implementation.

<accessor>
  <grammar>res:/customer/
    <group name="id">
      <regex type="alphanum" />
    </group>
  </grammar>
  <class>com.mycomp.customers.CustomerAccessor</class>
</accessor>

Detailed information about physical endpoint development is provided in the Physical Reference Guide.