Class OroServer
- java.lang.Object
-
- laas.openrobots.ontology.OroServer
-
- All Implemented Interfaces:
IServiceProvider
public class OroServer extends java.lang.Object implements IServiceProvider
OroServer
is the application entry point. It initializes and starts the various services, connectors and background tasks, as set up in theoro-server
configuration file.
OroServer does mainly two things:
- It registers and connects a set of services (presumably related to robotic cognition) to a socket interface,
- It runs in the background several tasks related to robotic cognition.
Features
Most services are related to access and management of a cognitive storage backend. The main storage backend is an ontology, as implemented in the
OpenRobotsOntology
class. This class exposes a set of RPC services (and hence implement theIServiceProvider
interface).
However, other services can be registred (likestats()
that returns statistics on the server itself).
Amongst the tasks that are run in background, we can list:
- The event manager (see
laas.openrobots.ontology.modules.events
) - The memory manager (see
MemoryManager
)
Getting access to the server
The communication with the server relies on standard TCP/IP sockets. The ASCII protocole we use is documented here:
SocketConnector
.Configuration
OroServer
has amain
function which expect a configuration file.
For the server, the following options are currently available:- port = [port number over 4000]: the port on which the server should starts and listen.
OpenRobotsOntology(Properties)
for others options, specific to the ontologies. Have a look at the config file itself for more details.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
OroServer.OnShuttingDown
-
Field Summary
Fields Modifier and Type Field Description static boolean
BLINGBLING
static java.lang.String
DEFAULT_CONF
The default configuration file (set to "etc/oro-server/oro.conf").static java.lang.String
DEFAULT_LANGUAGE
Defines the standard language used in particular for labels retrieval.
This field can be set up in the configuration file with thelanguage
option.
Expected values are ISO 2 characters language codes.static boolean
DEMO_MODE
static java.util.Set<java.lang.Class>
discardedTypeFromServiceArgs
This set holds the types that should not be exposed to oro-server clients but are required by some RPC methods (for instance to retrieve the context when the query was received).static boolean
HAS_A_TTY
static java.util.Date
SERVER_START_TIME
static java.util.Properties
ServerParameters
static VerboseLevel
VERBOSITY
static java.lang.String
VERSION
-
Constructor Summary
Constructors Constructor Description OroServer(java.lang.String confFile)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addNewServiceProviders(IServiceProvider provider)
static java.lang.String
formatParameters(java.lang.reflect.Method m)
Formats in a human-readable way the parameters of a method.static java.util.Properties
getConfiguration(java.lang.String configFileURI)
Read a configuration file and return to corresponding "Properties" object.java.lang.String
help()
java.util.Map<java.lang.String,java.lang.String>
listMethods()
java.util.Set<java.lang.String>
listSimpleMethods()
static void
main(java.lang.String[] args)
java.lang.String
makeHtmlDoc()
static int
nbExposedParameters(java.lang.reflect.Method m)
void
pushRequest(Request r)
void
reset()
void
runServer()
void
serverInitialization(java.util.Properties serverParameters)
long
size()
java.util.Map<java.lang.String,java.lang.String>
stats()
Returns several statistics on the server.
-
-
-
Field Detail
-
DEFAULT_CONF
public static final java.lang.String DEFAULT_CONF
The default configuration file (set to "etc/oro-server/oro.conf").- See Also:
- Constant Field Values
-
DEFAULT_LANGUAGE
public static java.lang.String DEFAULT_LANGUAGE
Defines the standard language used in particular for labels retrieval.
This field can be set up in the configuration file with thelanguage
option.
Expected values are ISO 2 characters language codes.
-
HAS_A_TTY
public static boolean HAS_A_TTY
-
VERBOSITY
public static VerboseLevel VERBOSITY
-
DEMO_MODE
public static boolean DEMO_MODE
-
ServerParameters
public static java.util.Properties ServerParameters
-
BLINGBLING
public static boolean BLINGBLING
-
VERSION
public static final java.lang.String VERSION
- See Also:
- Constant Field Values
-
SERVER_START_TIME
public static final java.util.Date SERVER_START_TIME
-
discardedTypeFromServiceArgs
public static final java.util.Set<java.lang.Class> discardedTypeFromServiceArgs
This set holds the types that should not be exposed to oro-server clients but are required by some RPC methods (for instance to retrieve the context when the query was received). TODO: This is more like a workaround...
-
-
Method Detail
-
addNewServiceProviders
public void addNewServiceProviders(IServiceProvider provider)
-
pushRequest
public void pushRequest(Request r)
-
runServer
public void runServer() throws java.lang.InterruptedException, OntologyServerException
- Throws:
java.lang.InterruptedException
OntologyServerException
-
serverInitialization
public void serverInitialization(java.util.Properties serverParameters) throws OntologyServerException
- Throws:
OntologyServerException
-
main
public static void main(java.lang.String[] args) throws OntologyConnectorException, java.lang.InterruptedException, OntologyServerException
- Throws:
OntologyConnectorException
java.lang.InterruptedException
OntologyServerException
-
reset
@RPCMethod(category="administration", desc="Reload the base ontologies, discarding all inserted of removed statements, in every models") public void reset() throws OntologyServerException
- Throws:
OntologyServerException
-
stats
@RPCMethod(category="administration", desc="returns some statistics on the server") public java.util.Map<java.lang.String,java.lang.String> stats()
Returns several statistics on the server. Returned values:- the server version
- the hostname where the server runs
- server uptime
- the current amount of classes in the ontology
- the current amount of instances in the ontology
- the current amount of client connected to the server
- Returns:
- a map containing the statistics (pairs name/value)
-
size
public long size()
-
help
@RPCMethod(desc="returns a human-friendly list of available methods with their signatures and short descriptions.") public java.lang.String help()
-
listMethods
@RPCMethod(category="administration", desc="returns the list of available methods with their signatures and short descriptions as a map.") public java.util.Map<java.lang.String,java.lang.String> listMethods()
-
listSimpleMethods
@RPCMethod(category="administration", desc="returns a raw list of available methods.") public java.util.Set<java.lang.String> listSimpleMethods()
-
makeHtmlDoc
@RPCMethod(category="administration", desc="returns a list of available methods in HTML format for inclusion in documentation.") public java.lang.String makeHtmlDoc()
-
formatParameters
public static java.lang.String formatParameters(java.lang.reflect.Method m)
Formats in a human-readable way the parameters of a method. This method skips all the parameters whose type belongs todiscardedTypeFromServiceArgs
- Parameters:
m
- The method- Returns:
- the in-parenthesis list of the method's parameters
-
nbExposedParameters
public static int nbExposedParameters(java.lang.reflect.Method m)
-
getConfiguration
public static java.util.Properties getConfiguration(java.lang.String configFileURI)
Read a configuration file and return to corresponding "Properties" object. The configuration file contains the path to the ontology to be loaded and several options regarding the server configuration.- Parameters:
configFileURI
- The path and filename of the configuration file.- Returns:
- A Java.util.Properties instance containing the application configuration.
-
-