Neokernel API

AgentInterface Interface

A standard interface for Agents.

For a list of all members of this type, see AgentInterface Members .

public interface AgentInterface : HasStateMachineModel

Types that implement AgentInterface

Type Description
AutoReplyAgent This agent sets itself up to receive messages from a ReceiveEmailAgent and automatically respond to the sender using the SendEmailAgent. In most cases, this will be subclassed and the getReply method should be overridden.
EmailBugReportAgent This agent registers itself with the Service Manager as a BugReportInterface and periodically submits the bug reports collects as an email message to a list of recipients using the SendEmailInterface registered with the Service Manager as "send_email".
EmailReporter This is a Reporter Agent that extends FileLoggerAgent in order to log AK agent output to sequentially named text files. Upon loading, this agent replaces the default Reporter.
ReceiveEmailAgent This agent receives SMTP messages on a server socket (port 25 by default) and forwards them to RequestAgents registered to the Service Manager using the recipients email address (ie: name@domain) or email account name only (ie: name). On UNIX operating systems, root access is required to serve on port 25. You will also need to kill sendmail or any other SMTP servers that may already be using port 25. It may also be necessary to add a MX DNS entry for your server in order to allow SMTP messages to be routed properly to your server (read "DNS & BIND" from O'Reilly publishing for a good reference on DNS).
ReceivePOP3EmailAgent This agent periodically checks for new POP3 messages, passing routing the message to the registered RequestAgent matching the message recipient's email address.
RequestDumperAgent This is a simple agent which dumps the contents of the requests it receives. This can be used for debugging messages received by the ReceiveEmailAgent.
RequestFilterAgent This agent proxies requests to another request agent and in the process, it caches the props for each request. When this agent starts up, it grabs a reference to the RequestAgent that its requests are proxying to from the ServiceManager, then registers itself. Cached requests are filtered depending on the filter_interval property and the requests that made it through the filter are emailed to the list of email addresses provided by the recipients property. Note: It may be a bad idea for this agent to proxy AgentRequests that may contain references to resources that needs to be released. The props from AgentRequests are not released for garbage collection until the filtering has been done.
SendEmailAgent

This agent queues up email messages and sends them to the smtp_host at regular intervals. There are a variety of properties that can be configured which define how and when these messages are sent. This agent implements the SendEmailInterface and registers with the Service Manager for other agents to use.

The SendEmailAgent supports the following properties:

service_name
The name this agent uses to register with Service Manager. The default value is send_email
max_queue_size
Max size of the message queue. Default value is 100
smtp_sleep_ms
Number of milliseconds to wait before checking the queue for new messages to send. Default value is 5000
smtp_host
Hostname or IP address of the SMTP server. Default value is localhost
smtp_port
Port to use for SMTP communications. Default value is 25
smtp_timeout_ms
SMTP timeout in milliseconds. Default value is 30000
auth_username
Username to use for SMTP communications (optional). Default value is none
auth_password
Password to use for SMTP communications (optional). Default value is none

HTTPAuthenticationAgent This agent is used by the WebServer to handle authorization of password protected resources.

The authentication file defines the realms and the usernames and passwords which are used to authenticate clients to the paths associated with each realm. The authentication file is delimited by newlines and must end with a newline. Each realm is declared with a PATH and the REALM name separated by spaces, followed by usernames and passwords on new lines, separated by a space. PATHs must begin with a slash and end with a slash.

The HOSTNAME field at the beginning of the file indicates to the HTTPAuthentication agent what hostname the realms should be mapped to. In Virtual Host (multihoming) configurations, use multiple authentication files with different HOSTNAME values for each file. The default hostname is default.

Here is an example authentication file:
HOSTNAME
PATH0 REALM0
username0 password0
username1 password1
username2 password2
username3 password3
PATH1 REALM2
username0 password0
username1 password1

The following example shows an example of an authentication file with two realms, 'My realm' and 'Main Realm'. If any access is made to files or directories in /private/, this agent will ask for the username jonlin with the password mainpassword, except for accesses to /private/mine/, which is under the /private/ path but is its own realm and requires its own usernames and passwords. If default is used as the hostname then the authentication map will apply to all virtual hosts on this server.

default
/private/mine/ My realm
john johnpassword
santos halper
/private/ Main Realm
john mainpassword
This agent supports the following Props settings:
service_name
The name this agent uses to register with Service Manager. The WebServer's authentication_agent prop must be set to match this agent's service_name, or requests for urls requiring authentication will not be handed off to this agent. The default value is http_authentication.agent.
authentication_files
The file(s) used for authenticating requests. The default value is ./http.authentication. Separate multiple files with commas.
HTTPFileServerAgent

This agent is used by the WebServer and SecureWebServer to handle requests for files from the file system.

If the file is an ASP.NET file, it will be executed using the ASP.NET environment on the server and the output will be sent to the requestor. If the ASP.NET code references other assemblies or .dlls, include copies of these .dlls in the same folder as your ASP.NET file.

The HTTPFileServerAgent supports the following Props:

service_name
The name this agent uses to register with Service Manager. The default value is HTTPFileServerAgent
html_directory
The path to the directory where HTML files are served from. Defaults to ./
default_index
The default files (separated by commas) to serve when no filename is specified in the HTTP request. This prop is set to index.html by default, which means requests for /public_html/my_stuff/ will be served the file /public_html/my_stuff/index.html.
allow_directory_lists
If this is set to yes, this agent will display links to all files in a directory when a web request specifies a directory instead of a file. The default value is no
dont_index_list
This is the list of files that shouldn't appear in directory index listings, can use '*' to denote a wildcard. This property is not used if the allow_directory_lists property is set to false. By default, this property isn't set.
alpha_sort_index
If set to true, directory lists will be sorted in alphanumerical order. This property is set to true by default.
aspnet_config_file
The path to an XML file containing ASP.NET configuration and debugging information. Defaults to web.config.
preload_aspx_pages
A list describing the ASP.NET pages that should be pre-loaded when the agent starts. This is not required but it makes pages load faster the first time they are requested by the user. To pre-load ASP.NET pages the agent must know the file location and it's URL relative to the server root. The list of files is in the format:
[WebPath1],[FilePath1];[WebPath2],[FilePath2] (or [WebPath1],[FilePath1],[VirtualDirectory1] if the page is in a virtual directory),
and so on, where the first item in each pair is the path to the file relative to the root of the web server (e.g. /aspapp/myfile.aspx) and the second is the path to the file on the hard disk (e.g. d:\htmldir\aspapp\myfile.aspx). This property is not set by default.
aspx_assemblies
An optional comma separated list of assemblies referenced by ASP.Net pages. Assemblies appearing in this list will be copied to the \bin subdirectory of the folder where the ASP.Net page is located. The files will be re-copied and re-loaded if a newer version becomes available. Use the full path. Here is an example value for this property: c:\app\foo.dll,c:\anotherapp\bar.dll
file_buffer_size
The size of the buffer to read and write static files to the Socket connected to the client.
virtual_directories_config
The config file that defines virtual directories. This is a text file with alternating lines of physdir:[physical path] and virtpath:[virtual path], where the [physical path] can be a fully qualified pathname to an existing physical directory or a relative path and the [virtual path] is a URI path starting with the / character that is to be mapped to the physical directory. The virtpath: MUST follow a physdir:. An example of a virtual directory config file:

                      physdir:C:\Projects\Web App Projects\Calendar App
                      virtpath:/apps/calendar
                      physdir:..\..\Users\Docs
                      virtpath:/mydocs
                      physdir:\\mynetworkDrive\share\html
                      virtpath:/share
                    
restricted_directories
A set of directory names that will be denied access if they appear in the URI path. They are separated by commas and must not include any / path separators.
restricted_access_404
If this property is set to true, attempted accesses to restricted directories will return a 404 Not Found instead of the default 403 Forbidden. Set this to true if you want the added protection of less information disclosure of making access to a restricted directory appear as if the directory isn't there at all.

For virtual hosts (serving different websites with unique domain names a.k.a. multihoming), start multiple HTTPFileServerAgent instances and give each one unique service_name and html_directory prop values. Include the domain name (or the protocol, http:// or https://) with the URI in the agent's service_name. Here are some examples of valid service_names:


                http://www.server.org/
                http://www.server.org:8080/
                https://www.server.org/
                www.server.org/
                www.server.org:8080/
                /
              

HTTPProxyAgent

HTTPProxyAgent handles proxies to other web servers. It can provide complete http proxy services to browsers and other clients connecting on the addresses and ports specified in the listeners property, and it can proxy specific URLs from the http.proxy file while the WebServer handles other requests normally.

The http.proxy file lists full URLs or URIs to proxy and where they should be proxied to if the WebServer is running. It consists of name/value pairs separated by newlines. Lines beginning with the # character are ignored as comments. The value of each name/value pair must be a complete URL.

Here are some valid name/value pairs that might be used in the http.proxy file:

http://myserver/proxy_me=http://proxy:1099
http://myserver/proxy_me2=http://proxy1:9000
http://myserver/proxy_me2=http://proxy2:9000
http://myserver/proxy_me2=http://proxy3:9000
When a browser requests /proxy_me, the HTTPProxyAgent contacts the web server at proxy on port 1099 and proxies the request to that server. When a browser requests /proxy_me_too, the HTTPProxyAgent cycles through the 3 web servers indicated, so that the first time the URL is accessed, the connection is proxied to proxy1:9000. The second time, the request is proxied to proxy2:9000, the third request goes to proxy3:9000, the fourth request goes to proxy1:9000, and so on. Both the name and the value of each name/value pair are assumed to be literal, so they will only match the exact path/hostname of the http request.

The servers listed in the http.proxy file are periodically checked to ensure that they are up and responding. The HTTPProxyAgent will not proxy requests to hosts from the http.proxy file that aren't responding.

HTTPProxyAgent also supports listeners, which operate independently of the WebServer to proxy traffic for browsers configured to use a proxy server. Any number of listeners can be started to provide proxy services on specific ports or IPs. Listeners are specified using the listeners prop of the HTTPProxyAgent.

This agent supports the following Props entries:
service_name
The name this agent uses to register with Service Manager. The WebServer's proxy_agent prop must be set to match this agent's service_name, or requests for urls in the http.proxy file will not be handed off to this agent. The default value is http_proxy.agent.
proxy_file
The path to a file containing a list of the available proxies. See above for syntax. Defaults to ./http.proxy
log_requests
When this prop is set to true, the agent will log requests handled by proxy listeners. Requests routed through the WebServer are logged in the WebServer's http logs. Defaults to true.
proxy_log_dir
The path to a directory containing proxy log files. Defaults to .\proxy_logs.
check_interval
Specifies the time to wait (in millisecs) before checking a proxy's status. Defaults to 300000
initial_wait_time
Specifies the time to wait after startup (in millisecs) before checking a proxy's status. Defaults to 600000
listeners
A comma separated list of hostnames or IP addresses (with port number) on which to provide standard HTTP proxy services for browsers. Requests on these ports won't be routed through the WebServer. By default, this prop is not set.
snoop_traffic
A boolean value that determines if data sent through the http proxy will be output to the console or file logger. By default, this prop is false.
HTTPPutAgent This agent can be loaded to support traditional HTTP Put functionality, saving uploaded files to the directory specified in the html_directory prop. To run this agent, the WebServer must have a prop called http_put.agent that matches the HTTPPutAgent's service_name.
service_name
The name this agent uses to register with Service Manager. The default value is http_put.agent.
html_directory
The path to the directory where received files will be stored. Defaults to ./
make_directories
If this prop is set to true, the HTTPPutAgent will create new sub-directories under the server's html_directory when a client uploads a file to a non-existent directory. Defaults to false
HTTPRedirectAgent

This Request Agent is used by the WebServer to determine whether a web request should be redirected and to actually redirect the request by returning the proper redirect code to the client.

If an HTTPRedirectAgent is running and the WebServer's redirect_agent prop is the same as the HTTPRedirectAgent's service_name, the agent will redirect requests for URLs in the http.redirect file. This file lists where to redirect to; URIs with multiple redirects listed in the file will be cycled between the listed redirects, providing a round-robin load distribution scheme.

The file format is name/value pairs delimited by newlines; lines starting with '#' are ignored. Complete URLs must be used to specify redirected URLs and the redirect targets. Here is an example of a redirect file:

http://myserver/redir1/file.htm=http://yahoo.com/
http://myserver/redir2/=http://redirect1:9000/
http://myserver/redir2/==http://redirect2:9000/
http://myserver/redir2/==http://redirect3:9000/
When a browser requests /redir1/file.html, it is redirected to http://yahoo.com. When it requests /redir2, it is redirected to http://redirect1:9000/. The next request for /redir2 is redirected to http://redirect2:9000/. The third incoming request is redirected to http://redirect3:9000/. The fourth request is redirected to http://redirect1:9000/, and the cycle is started again. In this way, the HTTPRedirectAgent can be used for round-robin style load balancing.

There are 2 kinds of name/value pairs used in the redirect configuration file. The first is a direct mapping in the format NAME=VALUE. This mapping tells the redirect agent to redirect PATH NAME to PATH VALUE.

A directly mapped NAME that contains a hostname must have a host in its VALUE. A direct mapping will not recurse subdirectories in a path and each path is regarded as literal. Directly mapped names can by mapped to multiple values if the values are separated by commas. The agent will cycle through each of the different paths given as the value.

The second kind of mapping maps only hosts to hosts, and passes the requested URL along with the redirected request for the mapped host to handle. This is an example of host-to-host mapping syntax:

http://myhost.com>http://www.myhost.com
No path information is included in the syntax of this mapping, only the host names. Any path intended for myhost.com will be mapped to the host www.myhost.com.

Note: Cyclical references in the redirect mappings are not checked, if the redirect file has cyclical references, clients can be put into an infinite loop of redirects.

service_name
The name this agent uses to register with Service Manager. The WebServer's proxy_agent prop must be set to match this agent's service_name, or requests for urls in the http.redirect file will not be handed off to this agent. The default value is http_redirect.agent.
redirect_file
The path to the file where redirect mappings are specified. Defaults to ./http.redirect
check_interval
Specifies the time to wait (in millisecs) between checking to see if the redirect target servers are up. Defaults to 300000
initial_wait_time
Specifies the time to wait after startup (in millisecs) before checking to see if the redirect target servers are up. Defaults to 600000
check_hosts
If set to true, the HTTPRedirectAgent will check every check_interval milliseconds to ensure that servers handling redirects are up. If one goes down, requests are not redirected to that server until it comes back online. Defaults to true
default_port
Specifies the port to redirect requests on. Defaults to 80
SecureWebServer SecureWebServer extends WebServer with SSL security features. You must provide a certificate suitable for server authentication, and any passwords or key files needed to access the certificate. SSL3 and TLS3 are the only supported protocols. This agent supports the following Props entries:
socket_linger_time
The number of millisecs to wait after an http request is completed before closing the socket used for that request. Default value is 2000
bind_port
The port that the webserver will bind to. Default value is 80
max_connections
The maximum number of concurrent connections to allow. Default value is 20
index_agent
The agent that gets called when the default page is requested. Default value is HTTPFileServerAgent
bind_ip
The IP address to service HTTP requests on (on mulithoming machines. To service requests on any IP interfaces, use 0.0.0.0 as the value. Default value is 0.0.0.0
log_requests
If this is set to true, the server will create HTTP access logs. Default value is true
log_file_dir
Specifies the directory where the server will create the HTTP access logs. Default value is ./logs
mime_types_file
The path to a file specifying mime types to use with various file extensions. If this file is missing, the server uses common default mappings. Default value is ./mime_types
server_certificate
The path to the certificate this server will use for SSL connections. To retrieve a certificate from the local host's certificate store, use the syntax store:/MY/localhost. Note that the example above doesn’t include a certificate name. If no certificate name is provided the server will use the 1st certificate it finds in the specified certificate store that is suitable for SSL server authentication. Use the following values to access various certificate stores on windows platforms:
CA
Certification authority certificates.
MY
A certificate store holding "My" certificates.
ROOT
Root certificates.
SPC
Software publisher certificates.
Default value is ./test-cert.pfx
certificate_password
The password to use when accessing the certificate. (The password for the certificate stored in the file test-cert.pfx is abcd, so the default value is abcd
.
The following Props settings are optional:
server_key_file
The path to a server key file. By default this prop is not set.
key_file_password
The password used to access the server key file. By default this prop is not set.
WebServer

The Neokernel web server services http requests. If an incoming request is for a static file like an HTML file, the web server delivers it. If the request URI ends in .agent, the web server uses a custom C# or Visual Basic object to generate the response. Objects that generate responses in this way implement the RequestAgent interface. If the server can't find a file or a RequestAgent to match the client's request, a 404 (file not found) error is returned. Typically, an HTTPFileServerAgent is used to serve static files like images or HTML. The HTTPFileServerAgent also handles ASP.NET pages if the file ends with the .aspx extension.

Custom RequestAgents are commonly used in conjunction with the WebServer and SecureWebServer classes to handle HTTP requests dynamically. 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 );
      }
   }
 

WebServer supports the following Props entries:

socket_linger_time
The number of millisecs to wait after an http request is completed before closing the socket used for that request. Default value is 2000
bind_port
The port that the webserver will bind to. Default value is 80
max_connections
The maximum number of concurrent connections to allow. Default value is 20
index_agent
The agent that gets called when the default page is requested. Default value is HTTPFileServerAgent
bind_ip
The IP address to service HTTP requests on (on mulithoming machines.) To service requests on any IP interfaces, use 0.0.0.0 as the value. Default value is 0.0.0.0
log_requests
If this is set to true, the server will create HTTP access logs. Default value is true
log_file_dir
Specifies the directory where the server will create the HTTP access logs. Default value is ./logs
mime_types_file
The path to a file specifying mime types to use with various file extensions. If this file is missing, the server uses common default mappings. Default value is ./mime_types
max_uri_length
The maximum length (in bytes) of URIs that the server will accept before a request is ignored. The default value is 4096
max_multipart_length
The maximum size of a POST request that the server will accept (in bytes) before the request is ignored. Default value is 4194304 (4MB)
refuse_requests
This prop specifies a list of strings that will result in a request being refused if a client passes them in the request URI. By default this prop is not set.
multihome
If this prop is set to false, multihome functionality is disabled. By default this prop is set to
true
redirect_agent
If this prop is set to true, the server will use the HTTPRedirectAgent to redirect incoming requests. This prop is not set to a default value.
proxy_agent
If this prop is set to true, the server will use the HTTPProxyAgent to proxy incoming requests. This prop is not set to a default value.
authentication_agent
If this prop is set to true, the server will use the HTTPAuthenticationAgent to demand passwords for certain URLs specified in the http.authentication file. This prop is not set to a default value.

FileLoggerAgent This agent handles logging. Currently, the only method of logging available is to a file. A logging requests are sent to this agent via the log(String) method and the agent will synchronize and log it to the file. Because logging is synchronized, applications that need to be optimized for speed will want to minimize their logging output. FileLoggerAgent supports the following Props entries:
log_file_prefix
The prefix to use when naming log files. Default value is log_
logs_per_file
The maximum number of log entries per file. When logs_per_file has been reached, a new log file is created to hold additional data. Default value is 10000
service_name
The name that this agent will register with in the ServiceManager. Default value is /logger_agent
FileReporter This agent implements IReporterInterface so it can capture output generated by the kernel. If you start this agent, all Kernel output will be routed to log files instead of the standard output console. It extends FileLoggerAgent in order to log agent output to sequentially named text files. Upon loading, this agent replaces the default Reporter so kernel output is logged instead of showing up in the console. The supported Props are:
log_file_prefix
The prefix to use when naming log files. Default value is log_
logs_per_file
The maximum number of log entries per file. When logs_per_file has been reached, a new log file is created to hold additional data. Default value is 10000
service_name
The name that this agent will register with in the ServiceManager. Default value is /logger_agent.
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
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.
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.
AgentServer A server interface to the neokernel.
FileObjectManager

The FileObjectManager manages Props objects and stores them as files in the specified directory using FilePropsContainers. The FilePropsContainer keeps the file on the hard disk in sync with its corresponding Props in memory. To get a Props that is managed by the FileObjectManager, call createObject. The only ObjectType supported by this IObjectManager implementation is the PropsType; using other types will fail.

Props objects can be retrieved by calling getObject with the ObjectID for the desired Props. ObjectIDs can be created from Props like this:

new ObjectID(props.getString("type"),props.getString("id"));
You can list all or a subset of the Props by calling listObjects. The object passed as an argument will be used as a queryObject. If the queryObject is null (Nothing in Visual Basic), all ObjectIDs in this IObjectManager will be listed. If the queryObject is of type ObjectType, all ObjectIDs with the specified type will be returned. If queryObject is a Pair, an ObjectID will be returned for a Props that includes a prop name matching the string First and a prop value matching to the string Pair.second(). Props objects are removed by calling removeObject with the ObjectID of the object to be removed.

The Props objects stored in the FileObjectManager are cached in a Hashtable called allprops using their ObjectIDs as keys. The id prop of each Props is appended to its filename on disk, i.e. prop001 is the filename of the Prop with an id of 1.

ObjectManager This is a reference implementation of a non-persistent IObjectManager implemented as an agent. Normal operations are reported through debug for educational purposes. If you are using it in production, set the hide_debug prop to true for significantly faster performance.
SessionManager This agent is the reference implementation of the SessionManagerInterface.
SessionReaper

The SessionReaper is a ScheduledAgent that periodically checks for expired sessions created by the SessionManager. Although this agent has no direct interactions with the SessionManager, it knows that session information stored in an IObjectManager is tagged with a prop called timestamp. Any session Props that has a timestamp value greater than the SessionReaper's session_timeout_ms prop is removed from the ObjectManager. The SessionReaper checks for expired objects using the schedule, ObjectManager service, and session object type specified by it's Props.

This agent supports the following Props entries:
schedule
The schedule specifying when this agent will check for expired sessions. The default value is between 0:0:0-23:59:59 every 5m
session_type
The object type that should be used to identify for expired session objects. Defaults to session
om_service_name
Specifies the name of the Object Manager service that the persistent sessions are stored in. Defaults to object_manager
session_timeout_ms
Specifies the time in milliseconds that sessions will persist before they are reaped. Defaults to 300000 (5 minutes).
PropsListAgent This agent creates and registers a PropsList to the service manager. It can be extended to provide alternate storage layers, or used externally with associated Import and Export agents.
PropsListIteratorAgent This agent can be extended to iterate over a PropsList passing each Props value to the handleRequest method when the agent is started, or it's iterate method is called.
XMLPropsList

XMLPropsList is an agent that provides persistent storage of Props in XML format. It includes methods for loading Props from an XML file, writing Props to an XML file, and parsing streams of XML data to obtain additional props.

XMLPropsList supports the following Props entries:
service_name
The name that this agent will register with in the ServiceManager. The default value is database
schedule
This prop tells the LogViewerPage how often to save the XML file on the hard disk. This should be a string that conforms to the schedule syntax used by the Scheduler. Defaults to between 0:0:0-23:59:59 every 5m
load_file
This is the path to a file that the XMLPropsList should load props from on startup. Defaults to database.props
save_file
This is the path to the file that the XMLPropsList will write out to store it's Props. Defaults to database.props
XMLRequestAgent This is an abstract implementation of RequestAgent with convenience methods for producing streamed XML-based responses of indeterminate length.

Requirements

Namespace: com.neokernel.nk

Assembly: Neokernel (in Neokernel.exe)

See Also

AgentInterface Members | com.neokernel.nk Namespace