Neokernel API

com.neokernel.nk Namespace

Namespace Hierarchy

Classes

Class Description
Agent This abstract implementation of the AgentInterface provides the base class for all components in the Neokernel. There is built-in support for routing agent output to Neokernel output and error streams, and masking output using hide_println, hide_debug, and hide_warningProps. This implementation of AgentInterface recognizes the following Props entries:
name
The agent's display name; this will be displayed in agent output. Defaults to be the same as the agent's classname.
id
The agent's id (a numeric value.) The kernel loads agents in numeric order according to their agent id. The default is for agents to use an id assigned by the kernel.
startup
A boolean value indicating whether this agent should be started. Default value is true
classname
The name of the object that contains this agent's code.
hide_println
If set to true, all println output for this agent is hidden. Default value is false
hide_debug
If set to true, all debug output for this agent is hidden. Default value is false
hide_warning
If set to true, all warning output for this agent is hidden. Default value is false
AgentController An implementation of AgentControllerInterface that is created by the neokernel to control the agents it creates.
AgentReplicator Used to create multiple instances of the same kind of Agent.
agent_classname
Specifies the classname of the Agent to start.
number_of_agents
Specifies the number of agent_classname to start.
AgentRequest This class is used to pass information to and from agents that implement the RequestAgentInterface. This information is stored in the AgentRequest's Props. An HTTPAgentRequest (which extends AgentRequest) is used when handling requests from the WebServer.
AgentStateException This exception is thrown by AgentController when the requested operation is illegal from its Agent's current state.
NK

This class is contains the public static void main() method for starting the Neokernel from a command line or other application bootstrapping mechanism. It supports the following command line parameters:

[-show_println] [-show_debug] [-show_warning] [-dont_start_agents] [-dont_start_webserver] [-startup_dir <dir>] [-only_load_from_xml] [-startup_file <.xml startup file>|<classname>]...

  • -show_println When present enables activity output
  • -show_debug When present enables debugging messages
  • -show_warning When present enables warning messages
  • -startup_dir Specifies the directory from which to load agents and look for the startup xml file.
  • -dont_start_agents Don't auto-start any agents when Neokernel starts
  • -dont_start_webserver Don't auto-start the WebServer when Neokernel starts
  • -only_load_from_xml Only start agents that are specified in the neokernel_props.xml or startup file.
  • -startup_file Specifies an xml props file from which to load agent props.

RequestAgent

A RequestAgent is a ServiceAgent that implements RequestAgentInterface. Create agents that extend this class to inherit the basic functionality for registering them with the ServiceManager at startup and making it available to other agents as a request based service.

RequestAgents are commonly used in conjunction with the WebServer and SecureWebServer classes to respond to HTTP requests. Here's an example of a simple RequestAgent written in Visual Basic:

 Imports com.neokernel.nk
    Imports com.neokernel.util

    Public Class SimpleVBPage
    Inherits RequestAgent

    Overrides Sub handleRequest(ByVal Request As AgentRequest)
    Dim title, body As String
    body = getString("body")
    Request.println(body)
    End Sub

    Overrides Sub initProps()
    setDefault("service_name", "/simple.agent")
    setDefault("body", "This is output from the SimplePage agent!")
    End Sub
    
    End Class

If a browser requests http://localhost/simple.agent from a server that has started the above SimpleAgent, the browser will display the text

This is output from the SimplePage agent!

Here is the exact same agent written using C#:

 using System;
    using com.neokernel.nk;

    public class SimplePage : RequestAgent
    {
        public override void initProps()
        {
            setDefault("service_name", "/simple.agent");

            setDefault("body", "This is output from the SimplePage agent!");
        }

        public override void handleRequest(HTTPAgentRequest request)
        {
            String body = getString("body");

            request.println( body );
        }
    }
    

ScheduledAgent

Abstract implementation of a scheduled agent, or an ISchedulable agent that wakes up periodically at the dates and times specified by it's schedule prop.

This agent implements ISchedulable; it creates and uses a Schedule using the value of it's schedule prop to initialize the Schedule. The schedule prop must be a valid Schedule string, for instance:

starting 10/31/2003 every 2h until 10/20/2004
starting 10/31/2003 between 10:00:00 and 11:00:00 every 20s until 12/01/2003
between 0:0:0 and 23:59:59 every 5m

SceduledAgents all have the following prop:
schedule
Specifies the schedule that specifies when this Agent will wake up.
 Schedule Syntax:

 date = mm/dd/yyyy
 time = hh:mm:ss
 [starting startDateTime]
 [[every n[y|m|w|d]] | [on [[SU][MO][TU][WE][TH][FR][SA] | [startDay-endDay]]]]
 [[between startTime-endTime every n[h|m|s]] | [at time1,time2,time3]]
 [until endDateTime]
 
Scheduler This is a ServiceAgent that implements the IScheduler interface. It maintains a pool of threads that periodically wake up any ISchedulables that have been scheduled. Look at ISchedule and Schedule to learn about supported scheduling features.
ServiceAgent Abstract agent that automatically registers with the ServiceManager using the service name specified in it's service_name prop.
service_name
Specifies the service name that the Agent will use to register with the ServiceManager.
ServiceManager The default implementation of ServiceManagerInterface. Agents use the ServiceManager to obtain references to other Agents and to register so that other Agents can access them. Agents register with the ServiceManager using a String to identify themselves; other Agents use that string to request a reference from the ServiceManager.

Interfaces

Interface Description
AgentControllerInterface An instance if this interface is created and managed by an implementation of NeokernelInterface as a proxy to the AgentInterface it represents.
AgentInterface A standard interface for Agents.
NeokernelInterface A standard neokernel interface.
RequestAgentInterface A standard interface for inter-agent communication. Agents that implement this interface are "triggered" when other agents pass them AgentRequest and HTTPAgentRequest objects.
ServiceManagerInterface A simple interface for registering, retrieving, and unregistering service implementations, typically ServiceAgents. The ServiceManager provides the reference implementation of this interface.