Fragmentor Development
A guide to developing universal resource fragmentors
Index > Books > Advanced Developer Guide and Reference > Component Dev > Fragmentor Development

Rate this page:
Really useful
Satisfactory
Not helpful
Confusing
Incorrect
Unsure
Extra comments:


Fragmentor- What and Why?

When a request is issued which has a URI with a fragment identifier attached NetKernel attempts to process that fragment identifier after first resolving the resource. A fragmentor is a component which can be registered in a module to implement a mechanism for applying a fragment identifier to a resource.

Resolution and Invocation

Fragmentors are resolved within the context of the module which initiated the request. First all fragmentors within this module are tested to see if they are suitable, then all imported modules are tested recursively. If no fragmentor is found them the resolution process steps up the request call stack. If no fragmentor is found an Unrecognised Fragment Identifier exception is raised.

Fragmentors may be invoked in one of the following ways:

  • Explicit. Initiate a FRAGMENT request. This is an explicit request to to look for a fragmentor which can take a given representation which is passed by value and apply a fragment identifier to it.
  • Implicit Initiate a SOURCE request where the URI of the resource contains a fragment identifier.

Coding a fragmentor

Implement a default constructor and call super specifying a regular expression string for matching the request URI and the mimetype of the resource.

Subclass org.ten60.netkernel.layer1.nkf.impl.INKFFragmentorImpl and implement the method void fragment(INKFConvenienceHelper context) throws Exception.

For example a null fragmentor would be:


protected void fragment(INKFConvenienceHelper context) throws Exception
{   String fragment = context.getThisRequest().getFragment();
    String fromURI = context.getThisRequest().getURIWithoutFragment();

    IURRepresentation from = context.source(fromURI);
    
    // do some work here
    
    INKFResponse response = context.createResponseFrom(from);
    response.setCreationCost(8);
    context.setResponse(response);
}       
            

Issuing subrequests

Fragmentors need not usually issue sub-requests but there are a few situations where it might be useful to perform some validation or to have access to some configuration data. For these circumstances fragmentors can issue sub-requests.

The context object may be used to source resources and issue sub-requests in exactly the same way as with NKF Accessor development. Requests will be issued into the module address space of the module hosting the fragmentor.

Registering a fragmentor

A fragmentor is registered by placing configuration information in the host modules module.xml resource. An example from xml-ura is the XPointer fragmentor:

<fragmentors>  <fragmentor>org.ten60.netkernel.xml.fragmentation.XPointerFragmentor</fragmentor>
</fragmentors>
For each fragmentor a <fragmentor> element is placed with the <fragmentors> element (which is a direct child of the root element). <class> is the fully qualified java class accessible within the current module.

Out of the Box

Many fragmentors ship with NetKernel Standard Edition, they are listed here.

© 2003,2004, 1060 Research Limited. 1060 registered trademark, NetKernel trademark of 1060 Research Limited.