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 .

Endpoint
Name:DynamicSpaceAccessor
Description:Dynamically instantiate space constructed from space definition and expose its endpoints.
Id:mod.architecture.DynamicSpaceAccessor
Category:accessor prototype

DynamicSpaceAccessor is an accessor that must be instantiated from a prototype. You must instantiate the prototype in your module to create an accessor that can receive requests.

Parameters

The mod.architecture.DynamicSpaceAccessor prototype has the following initialisation parameters:

NameRulesTypingDefaultDescription
spaceMandatoryIdentifier or XML(none)
A nested space definition which the overlay will delegate all requests in to.
pollOptionalLong0
optional period to poll configuration for use when space hosts transport

Here is an auto-generated example of how to instantiate an instance of DynamicSpaceAccessor:

<accessor>
  <prototype>mod.architecture.DynamicSpaceAccessor</prototype>
  <space>
    < !--wrapped space...-->
  </space>
</accessor>
Import Requirements

To use DynamicSpaceAccessor accessor prototype you must import the module urn:com:ten60:netkernel:mod:architecture:

<import>
  <uri>urn:com:ten60:netkernel:mod:architecture</uri>
</import>

Operation

When a dynamic space accessor is instantiated in your application space it constructs an internal space dynamically from the configuration you specify in the space parameter. This space configuration is regular standard module rootspace syntax. This space is private and cannot be imported by other spaces. However the dynamic space accessor acts as a import to the space and all public endpoints from the space are exposed as logical endpoints on the interface.

If the space configuration references classes (endpoints, representations, prototypes) then these must be accessible from the classloader of the host space. Usually this means that classes must either exist in the host module or be statically imported by one of the spaces within the module. See physical reference for more details on classloaders.

The constructed space is fully viewable within the space explorer so you can see the current state of the space and how it is exposed into the host space:

Static structure diagrams reflect this state:

Configuration

The configuration resource is requested when the host space is first accessed and will be re-requested every time it is invalidated. It could change continually and the endpoint would behave in a consistent manner. The constructed space and it's endpoints will always go through the correctly lifecycle events.

It is important that you have the necessary transreptors available to convert your configuration resource into DOM. For example if your configuration is serialised then your will need to import xml:core:

<import>
  <uri>urn:org:netkernel:xml:core</uri>
  <private />
</import>

Poll parameter

When the dynamically instantiated space doesn't receive request directly but hosts its own transport that responds to external events a change in configuration will not cause the space to reconfigure itself. Therefore this optional poll parameter provides a mechanism to periodically poll the configuration to detect changes even when no requests are received.

Examples

dynamic switching

Switch between two different space definitions every 10 seconds:

<rootspace name="dynamic space test">
  <endpoint>
    <prototype>DynamicSpaceAccessor</prototype>
    <space>active:dynamicSpaceConfig</space>
  </endpoint>
  <endpoint>
    <grammar>active:dynamicSpaceConfig</grammar>
    <class>dst.DynamicSpaceConfig</class>
  </endpoint>
  <fileset>
    <regex>res:/dst/.*</regex>
  </fileset>
  <import>
    <uri>urn:com:ten60:netkernel:mod:architecture</uri>
    <private />
  </import>
  <import>
    <uri>urn:org:netkernel:xml:core</uri>
    <private />
  </import>
</rootspace>

and DynamicSpaceConfig accessor is implemented like this:

public class DynamicSpaceConfig extends StandardAccessorImpl
{   private int mState;
    
    public void onSource(INKFRequestContext aContext) throws Exception
    {   mState=(mState+1)%2;
        INKFResponseReadOnly respIn=aContext.sourceForResponse("res:/dst/space"+mState+".xml");
        INKFResponse resp=aContext.createResponseFrom(respIn);
        resp.setExpiry(INKFResponse.EXPIRY_CONSTANT,System.currentTimeMillis()+10000L);
    }
}

Nested dynamic spaces

A dynamic space endpoint inside a dynamic space endpoint just because you can:

<rootspace name="dynamic space test">
  <endpoint>
    <prototype>DynamicSpaceAccessor</prototype>
    <space name="Outer dynamic space">
      <accessor>
        <grammar>res:/dst/outer</grammar>
        <class>org.netkernel.tab.arch.playpen.dst.InDynamicSpaceAccessor</class>
      </accessor>
      <endpoint>
        <prototype>DynamicSpaceAccessor</prototype>
        <space private-filter="true">
          <accessor>
            <grammar>res:/dst/inner</grammar>
            <class>org.netkernel.tab.arch.playpen.dst.InDynamicSpaceAccessor</class>
          </accessor>
        </space>
      </endpoint>
      <import>
        <uri>urn:com:ten60:netkernel:mod:architecture</uri>
        <private />
      </import>
    </space>
  </endpoint>
  <import>
    <uri>urn:com:ten60:netkernel:mod:architecture</uri>
    <private />
  </import>
</rootspace>