org.micropsi.comp.common
Class AbstractComponent

java.lang.Object
  extended byorg.micropsi.comp.common.AbstractComponent
Direct Known Subclasses:
AgentFrameworkComponent, ConsoleComponent, ExtensibleConsoleComponent, RobotWorldComponent, ServerComponent, TimerComponent, WorldComponent

public abstract class AbstractComponent
extends java.lang.Object

AbstractComponent is the abstract ancestor of all the application's components. The default AbstractComponent has no run method and hence is purely reactive. Components that need a run() method must implement ActiveComponentIF to be executed by the ComponentRunner.


Field Summary
protected  ComponentClientFacade clients
          The ClientFacade.
protected  ConfigurationReaderIF config
          Interface for reading configuration data.
protected  ConsoleServiceProvider consoleService
          The ConsoleServiceProvider.
protected  ExceptionProcessor exproc
          The exception processor.
protected  Logger logger
          The logger.
protected  java.lang.String prefixKey
          The component's configuration prefix.
protected  ComponentRunner runner
          The ComponenRunner that started the component
protected  ComponentServerFacade servers
          The ServerFacade.
 
Constructor Summary
AbstractComponent()
           
 
Method Summary
 ComponentDescriptor getComponentDescriptor()
           
 java.lang.String getComponentID()
          Return the component's id.
 ComponentRunner getComponentRunner()
           
 ConsoleServiceProvider getConsoleService()
           
 ExceptionProcessor getExproc()
           
protected abstract  int getInnerType()
           
 Logger getLogger()
           
protected  Logger getRealLogger()
           
 void initialize(ConfigurationReaderIF config, java.lang.String prefixKey, java.lang.String id, ComponentRunner runner)
          Initializes the component.
 void overrideComponentID(java.lang.String newID, boolean notifyComponentRunner)
           
protected abstract  void performInitialisation()
          Does the implementation-dependent initialisation.
abstract  void shutdown()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

config

protected ConfigurationReaderIF config
Interface for reading configuration data. You can simply use this, as it is initialized by the ComponentRunner


prefixKey

protected java.lang.String prefixKey
The component's configuration prefix. Use this when accessing the configuration. The prefix points at the "data" section of the component's configuration. (...data.foo.bar can be read by reading the key prefixKey + ".foo.bar"


exproc

protected ExceptionProcessor exproc
The exception processor. Simply put in here any exception you catch anywhere within the component.


servers

protected ComponentServerFacade servers
The ServerFacade. Register your RequestHandlers here.


clients

protected ComponentClientFacade clients
The ClientFacade. Place your requests here.


consoleService

protected ConsoleServiceProvider consoleService
The ConsoleServiceProvider. Register your QuestionTypes here


runner

protected ComponentRunner runner
The ComponenRunner that started the component


logger

protected Logger logger
The logger. Feel free to use this flexible logging channel. This is a proxy instance that will route your logs to the correct channels.

Constructor Detail

AbstractComponent

public AbstractComponent()
Method Detail

initialize

public void initialize(ConfigurationReaderIF config,
                       java.lang.String prefixKey,
                       java.lang.String id,
                       ComponentRunner runner)
                throws MicropsiException
Initializes the component. You don't want to call this, the ComponentRunner does.

Throws:
MicropsiException

performInitialisation

protected abstract void performInitialisation()
                                       throws MicropsiException
Does the implementation-dependent initialisation. When implementing a component, you'll want to instatiate the RequesHandlers here and register them with the ServerFacade.

Throws:
MicropsiException

getComponentID

public java.lang.String getComponentID()
Return the component's id.


overrideComponentID

public void overrideComponentID(java.lang.String newID,
                                boolean notifyComponentRunner)

getConsoleService

public ConsoleServiceProvider getConsoleService()

getExproc

public ExceptionProcessor getExproc()

getLogger

public Logger getLogger()

getRealLogger

protected Logger getRealLogger()

getComponentDescriptor

public ComponentDescriptor getComponentDescriptor()

getComponentRunner

public ComponentRunner getComponentRunner()

getInnerType

protected abstract int getInnerType()

shutdown

public abstract void shutdown()

(c) by Micropsi Project: http://www.cognitive-agents.org

.