NetKernel APIs


org.ten60.netkernel.layer1.nkf.impl
Class NKFHelperImpl

java.lang.Object
  extended byorg.ten60.netkernel.layer1.nkf.impl.NKFHelperImpl
All Implemented Interfaces:
INKFBasicHelper, INKFConvenienceHelper, INKFKernelHelper
Direct Known Subclasses:
NKFComponentHelperImpl, NKFTransportHelperImpl

public abstract class NKFHelperImpl
extends Object
implements INKFKernelHelper, INKFBasicHelper, INKFConvenienceHelper

The main helper implementation implements INKFCovenienceHelper


Constructor Summary
NKFHelperImpl(Container aContainer, IRequestorContext aContext, URRequest aRequest)
          Creates a new instance of NKFHelperImpl
 
Method Summary
 IURRepresentation createIntermediateRepresentationForAspect(IURAspect aAspect, String aMimeType)
          Create a representation around one aspect that has been internally created and give it the specified mimetype.
 INKFResponse createResponseFrom(IURAspect aAspect)
          Create a response which should then be configured before being set as the overall response for the accessor.
 INKFResponse createResponseFrom(IURRepresentation aRepresentation)
          Create a response which should then be configured before being set as the overall response for the accessor.
 INKFRequest createSubRequest()
          Create a subrequest which can then be configured with target URI, arguments, type etc before being issued to the kernel for scheduling.
 INKFRequest createSubRequest(String aURI)
          Create a subrequest with a given base URI.
 boolean delete(String aURI)
          Delete a resource for the given URI
 boolean exists(String aURI)
          Check for the existence of a resource for the given URI
 IURAspect fragment(IURAspect aSource, String aFragment, String aMimeType, Class aAspectClass)
          Apply a fragment identifier to an internally created resource.
 String getCWU()
          Gets the current working URI for created subrequests.
 Container getKernel()
          Advanced Return a reference to the Kernel Container.
 INKFKernelHelper getKernelHelper()
          Advanced Return the kernel helper API for a set of low-level APIs for advanced use.
 ModuleDefinition getOwningModule()
          Advanced Return the owning module of this accessor
 URRequest getThisKernelRequest()
          Advanced Return the request which initiated this invocation of the accessor
 INKFRequestReadOnly getThisRequest()
          Return a wrapper around the request which initiated the invocation of this accessor
 void handleAsyncException(Exception aException)
          log the exception as we cannot throw exception asyncronously
 void handleAsyncResponse(IURRepresentation aResponse)
          no response can be handled asynchronously
protected abstract  void innerIssueAsyncRequest(URRequest aRequest)
           
protected abstract  IURRepresentation innerIssueSyncRequest(URRequest aRequest)
           
 boolean isResponseSet()
          Test if the response has been set.
 INKFAsyncRequestHandle issueAsyncSubRequest(INKFRequest aRequest)
          Issue an asynchronous subrequest.
 IURRepresentation issueRequest(URRequest aRequest)
          Advanced Issue a resource request to the kernel using a URRequest.
 IURRepresentation issueSubRequest(INKFRequest aRequest)
          Issue a subrequest.
 IURAspect issueSubRequestForAspect(INKFRequest aRequest)
          Issue a subrequest.
 String requestNew(String aURIBase, IURAspect aOptionalSource)
          Request the creation of a new resource
 void setCWU(String aURI)
          Set the current working URI for created subrequests
 void setResponse(INKFResponse aResponse)
          Set the response to be returned as the result for the invocation of this accessor
 void setResponse(IURRepresentation aResponse)
          Advanced Sets the response that will be issued as the result of this invocation of the accessor.
 void sinkAspect(String aURI, IURAspect aAspect)
          Sink an aspect to the resource at a URI
 IURRepresentation source(String aURI)
          Source a resource from its URI
 IURRepresentation source(String aURI, Class aAspectClass)
          Source a resource from its URI
 IURAspect sourceAspect(String aURI, Class aAspectClass)
          Source a specific aspect of a resource from its URI
 IURAspect transrept(IURAspect aSource, Class aAspectClass)
          Transrept a internally created resource into alternative aspect.
 IURAspect transrept(IURRepresentation aSource, Class aAspectClass)
          Transrept a internally created resource into alternative aspect.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NKFHelperImpl

public NKFHelperImpl(Container aContainer,
                     IRequestorContext aContext,
                     URRequest aRequest)
Creates a new instance of NKFHelperImpl

Method Detail

getKernel

public Container getKernel()
Description copied from interface: INKFKernelHelper
Advanced Return a reference to the Kernel Container. From this the Scheduler and other kernel components may be accessed.

Specified by:
getKernel in interface INKFKernelHelper

getOwningModule

public ModuleDefinition getOwningModule()
Description copied from interface: INKFKernelHelper
Advanced Return the owning module of this accessor

Specified by:
getOwningModule in interface INKFKernelHelper

getThisKernelRequest

public URRequest getThisKernelRequest()
                               throws NKFException
Description copied from interface: INKFKernelHelper
Advanced Return the request which initiated this invocation of the accessor

Specified by:
getThisKernelRequest in interface INKFKernelHelper
Throws:
NKFException - thrown if no parent request initiated this invocation

issueRequest

public IURRepresentation issueRequest(URRequest aRequest)
                               throws NetKernelException
Description copied from interface: INKFKernelHelper
Advanced Issue a resource request to the kernel using a URRequest. All higher-level NKF methods will use this to issue kernel requests. Requests are Sychnoronous.

Specified by:
issueRequest in interface INKFKernelHelper
Parameters:
aRequest -
Returns:
a representation which is the response from the request
Throws:
NetKernelException

setResponse

public void setResponse(IURRepresentation aResponse)
Description copied from interface: INKFKernelHelper
Advanced Sets the response that will be issued as the result of this invocation of the accessor. All accessors should use this method to set a response before completion.

Specified by:
setResponse in interface INKFKernelHelper
Parameters:
aResponse - an IURRepresentation

getThisRequest

public INKFRequestReadOnly getThisRequest()
                                   throws NKFException
Description copied from interface: INKFBasicHelper
Return a wrapper around the request which initiated the invocation of this accessor

Specified by:
getThisRequest in interface INKFBasicHelper
Throws:
NKFException - thrown if no parent request initiated this invocation

createResponseFrom

public INKFResponse createResponseFrom(IURRepresentation aRepresentation)
Description copied from interface: INKFBasicHelper
Create a response which should then be configured before being set as the overall response for the accessor.

Specified by:
createResponseFrom in interface INKFBasicHelper
Parameters:
aRepresentation - a representation who aspects and metadata should be used as the basis for the response

createResponseFrom

public INKFResponse createResponseFrom(IURAspect aAspect)
Description copied from interface: INKFBasicHelper
Create a response which should then be configured before being set as the overall response for the accessor.

Specified by:
createResponseFrom in interface INKFBasicHelper
Parameters:
aAspect - an aspect which should be used as the basis for the response

setResponse

public void setResponse(INKFResponse aResponse)
Description copied from interface: INKFBasicHelper
Set the response to be returned as the result for the invocation of this accessor

Specified by:
setResponse in interface INKFBasicHelper
Parameters:
aResponse - a response object as created by createResponseFrom methods. If no response is set then a default Void aspect result is returned. It is an error to set the response to null for anything other than an accessor - in this case it has the effect of causing the accessor to not issue a response (this must be used with care in combination with INFKAsyncRequestListener.)

createSubRequest

public INKFRequest createSubRequest()
Description copied from interface: INKFBasicHelper
Create a subrequest which can then be configured with target URI, arguments, type etc before being issued to the kernel for scheduling. A subrequest will automatically acquire the calling request as its parent.

Specified by:
createSubRequest in interface INKFBasicHelper

createSubRequest

public INKFRequest createSubRequest(String aURI)
                             throws NKFException
Description copied from interface: INKFBasicHelper
Create a subrequest with a given base URI. Equivalent to calling createSubRequest().setURI(aURI)

Specified by:
createSubRequest in interface INKFBasicHelper
Parameters:
aURI -
Throws:
NKFException - thrown if aURI is relative and cwu not inherited from parent

issueSubRequest

public IURRepresentation issueSubRequest(INKFRequest aRequest)
                                  throws NKFException
Description copied from interface: INKFBasicHelper
Issue a subrequest. Make a secondary request to the kernel for scheduling. The request is synchronous.

Specified by:
issueSubRequest in interface INKFBasicHelper
Parameters:
aRequest -
Returns:
the resulting resource representation
Throws:
NKFException - if there is a failure executing the request

issueSubRequestForAspect

public IURAspect issueSubRequestForAspect(INKFRequest aRequest)
                                   throws NKFException
Description copied from interface: INKFBasicHelper
Issue a subrequest. Make a secondary request to the kernel for scheduling. The request is synchronous.

Specified by:
issueSubRequestForAspect in interface INKFBasicHelper
Parameters:
aRequest -
Returns:
the chosen aspect from the resulting resource representation
Throws:
NKFException - if there is a failure executing the request

issueAsyncSubRequest

public INKFAsyncRequestHandle issueAsyncSubRequest(INKFRequest aRequest)
                                            throws NKFException
Description copied from interface: INKFBasicHelper
Issue an asynchronous subrequest. Make a secondary request to the kernel for scheduling

Specified by:
issueAsyncSubRequest in interface INKFBasicHelper
Parameters:
aRequest -
Returns:
Throws:
NKFException

setCWU

public void setCWU(String aURI)
Description copied from interface: INKFBasicHelper
Set the current working URI for created subrequests

Specified by:
setCWU in interface INKFBasicHelper
Parameters:
aURI - the new current working URI, may be null so signify that relative URIs cannot be resolved.

getCWU

public String getCWU()
Description copied from interface: INKFBasicHelper
Gets the current working URI for created subrequests. By default this value is inherited from the request which initiated the accessor. This value may be null- in which case relative URI resolution will fail

Specified by:
getCWU in interface INKFBasicHelper
Returns:
the current working URI

sinkAspect

public void sinkAspect(String aURI,
                       IURAspect aAspect)
                throws NKFException
Description copied from interface: INKFConvenienceHelper
Sink an aspect to the resource at a URI

Specified by:
sinkAspect in interface INKFConvenienceHelper
Parameters:
aURI -
aAspect -
Throws:
NKFException

source

public IURRepresentation source(String aURI)
                         throws NKFException
Description copied from interface: INKFConvenienceHelper
Source a resource from its URI

Specified by:
source in interface INKFConvenienceHelper
Parameters:
aURI -
Throws:
NKFException

source

public IURRepresentation source(String aURI,
                                Class aAspectClass)
                         throws NKFException
Description copied from interface: INKFConvenienceHelper
Source a resource from its URI

Specified by:
source in interface INKFConvenienceHelper
Parameters:
aURI -
aAspectClass -
Throws:
NKFException

sourceAspect

public IURAspect sourceAspect(String aURI,
                              Class aAspectClass)
                       throws NKFException
Description copied from interface: INKFConvenienceHelper
Source a specific aspect of a resource from its URI

Specified by:
sourceAspect in interface INKFConvenienceHelper
Parameters:
aURI -
aAspectClass -
Throws:
NKFException

transrept

public IURAspect transrept(IURAspect aSource,
                           Class aAspectClass)
                    throws NKFException
Description copied from interface: INKFConvenienceHelper
Transrept a internally created resource into alternative aspect. There must be a registered Transreptor capable of performing the transrepresentation. - Do not use to transrept external resources source these using one of the methods which take an aspect class parameter.

Specified by:
transrept in interface INKFConvenienceHelper
Parameters:
aSource - An internally generated resource
aAspectClass - The class of the desired aspect for the resource
Returns:
An aspect of class aAspectClass for resource aSource
Throws:
NKFException - thrown if no transreptor available or transreptor fails

transrept

public IURAspect transrept(IURRepresentation aSource,
                           Class aAspectClass)
                    throws NKFException
Description copied from interface: INKFConvenienceHelper
Transrept a internally created resource into alternative aspect. There must be a registered Transreptor capable of performing the transrepresentation. - Do not use to transrept external resources source these using one of the methods which take an aspect class parameter.

Specified by:
transrept in interface INKFConvenienceHelper
Parameters:
aSource - An internally generated resource
aAspectClass - The class of the desired aspect for the resource
Returns:
An aspect of class aAspectClass for resource aSource
Throws:
NKFException - thrown if no transreptor available or transreptor fails

fragment

public IURAspect fragment(IURAspect aSource,
                          String aFragment,
                          String aMimeType,
                          Class aAspectClass)
                   throws NKFException
Description copied from interface: INKFConvenienceHelper
Apply a fragment identifier to an internally created resource. There must be a registered Fragmentor capable of performing the fragmentation. - Do not use to transrept external resources source these with a fragment identifier on the URI

Specified by:
fragment in interface INKFConvenienceHelper
Parameters:
aSource - An internally generated resource
aFragment - A valid fragment identifier string
aMimeType - The mimetype of the resource
aAspectClass - The class of the desired aspect for the resource
Returns:
An aspect of class aAspectClass for resource aSource
Throws:
NKFException - thrown if no transreptor available or transreptor fails

requestNew

public String requestNew(String aURIBase,
                         IURAspect aOptionalSource)
                  throws NKFException
Description copied from interface: INKFConvenienceHelper
Request the creation of a new resource

Specified by:
requestNew in interface INKFConvenienceHelper
Parameters:
aURIBase - A base URI that can identify which accessor to target the request at
aOptionalSource - Optional resource aspect that the accessor can use to seed the state of the new resource.
Returns:
The URI of the created resource
Throws:
NKFException - Thrown if no accessor could be located or it didn't support the NEW operation or the failed for some other accessor specific reason.

exists

public boolean exists(String aURI)
               throws NKFException
Description copied from interface: INKFConvenienceHelper
Check for the existence of a resource for the given URI

Specified by:
exists in interface INKFConvenienceHelper
Throws:
NKFException

delete

public boolean delete(String aURI)
               throws NKFException
Description copied from interface: INKFConvenienceHelper
Delete a resource for the given URI

Specified by:
delete in interface INKFConvenienceHelper
Returns:
true if it was deleted
Throws:
NKFException

innerIssueAsyncRequest

protected abstract void innerIssueAsyncRequest(URRequest aRequest)

innerIssueSyncRequest

protected abstract IURRepresentation innerIssueSyncRequest(URRequest aRequest)
                                                    throws NetKernelException
Throws:
NetKernelException

createIntermediateRepresentationForAspect

public IURRepresentation createIntermediateRepresentationForAspect(IURAspect aAspect,
                                                                   String aMimeType)
Description copied from interface: INKFConvenienceHelper
Create a representation around one aspect that has been internally created and give it the specified mimetype. The created representation is not expired but has no dependencies.

Specified by:
createIntermediateRepresentationForAspect in interface INKFConvenienceHelper
Parameters:
aAspect - the single aspect it should contain
aMimeType - the mimetype of the representation

getKernelHelper

public INKFKernelHelper getKernelHelper()
Description copied from interface: INKFBasicHelper
Advanced Return the kernel helper API for a set of low-level APIs for advanced use.

Specified by:
getKernelHelper in interface INKFBasicHelper

handleAsyncResponse

public void handleAsyncResponse(IURRepresentation aResponse)
no response can be handled asynchronously


handleAsyncException

public void handleAsyncException(Exception aException)
log the exception as we cannot throw exception asyncronously


isResponseSet

public boolean isResponseSet()
Description copied from interface: INKFBasicHelper
Test if the response has been set.

Specified by:
isResponseSet in interface INKFBasicHelper
Returns:
boolean

NetKernel APIs


Copyright © 2002-2004 1060 Research Ltd. All Rights Reserved.