## org.opencyc.cycagent
Class CycProxy

    java.lang.Object
      |
      +--org.opencyc.cycagent.GenericAgent
            |
            +--org.opencyc.cycagent.CycProxy

All Implemented Interfaces:
  MessageReceiver

public class CycProxy
extends GenericAgent

Provides a proxy for a cyc api service on the CoABS grid or FIPA-OS agent community, and also creates CycAgentProxy objects for each Cyc-hosted agent.

Author:
  Stephen L. Reed

  Copyright 2001 Cycorp, Inc., license is open source GNU LGPL.

  the license

  www.opencyc.org

  OpenCyc at SourceForge

  THIS SOFTWARE AND KNOWLEDGE BASE CONTENT ARE PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENCYC ORGANIZATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE AND KNOWLEDGE BASE CONTENT, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Field Summary
`CycConnection` `agentsCycConnection` One CycConnection object to send and receive asynchronous messsages with the Cyc server.
`protected static java.util.Hashtable` `cycAgentProxies` Association of Cyc-hosted agent names with their CycAgentProxy objects.
`protected static java.util.Hashtable` `cycApiConnectionCache` Cached CycConnection objects which preserve Cyc session state.

Fields inherited from class org.opencyc.cycagent.GenericAgent
`agentCommunityAdapter, coAbsCommunityAdapter, DEFAULT_VERBOSITY, fipaOsCommunityAdapter, messageConsumed, myAgentName, myAgentType, remoteAgentCommunity, remoteAgentName, verbosity`

Constructor Summary
`CycProxy(java.lang.String myAgentName, int verbosity)` Constructs a CycProxy object for the given agent on both agent communities.
`CycProxy(java.lang.String myAgentName, int remoteAgentCommunity, int verbosity)` Constructs a CycProxy object for the given agent on the given agent community.

Method Summary
`protected void` `handleMessageFromCyc(CycList fipaTransportMessage)` Handles one inbound asynchronous message from a Cyc-hosted agent.
`protected void` `handleMessagesFromCyc()` Handles inbound asynchronous messages from Cyc-hosted agents.
`void` `messageReceived(int remoteAgentCommunity, fipaos.ont.fipa.ACL acl)` Notifies my agent that an Agent Communication Language message has been received.
`void` `processApiRequest(int remoteAgentCommunity, fipaos.ont.fipa.ACL apiRequestAcl)` Processes a cyc api request from another agent.
`void` `setVerbosity(int verbosity)` Sets verbosity of the output.

Methods inherited from class org.opencyc.cycagent.GenericAgent
`aclToCycList, agentCommunity, agentCommunityName, getAgentType, getAID, getCoAbsCommunityAdapter, getFipaOsCommunityAdapter, getMyAgentName, initializeAgentCommunity, makeAID, processEchoRequest, toString`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### cycApiConnectionCache

    protected static java.util.Hashtable cycApiConnectionCache

  Cached CycConnection objects which preserve Cyc session state. myAgentName --> CycConnection instance

### agentsCycConnection

    public CycConnection agentsCycConnection

  One CycConnection object to send and receive asynchronous messsages with the Cyc server. All Cyc-hosted agents represented by this CycProxy object share this bidirectional connection.

### cycAgentProxies

    protected static java.util.Hashtable cycAgentProxies

  Association of Cyc-hosted agent names with their CycAgentProxy objects. CycAgentName --> CycAgentProxy instance

Constructor Detail

### CycProxy

    public CycProxy(java.lang.String myAgentName,
                    int verbosity)

  Constructs a CycProxy object for the given agent on both agent communities.
  Parameters:
    `myAgentName` - name of the local agent
    `verbosity` - the verbosity of this agent adapter's output. 0 --> quiet ... 9 -> maximum diagnostic input

### CycProxy

    public CycProxy(java.lang.String myAgentName,
                    int remoteAgentCommunity,
                    int verbosity)

  Constructs a CycProxy object for the given agent on the given agent community.
  Parameters:
    `myAgentName` - name of the local agent
    `remoteAgentCommunity` - indicates either CoAbs or FIPA-OS agent community
    `verbosity` - the verbosity of this agent adapter's output. 0 --> quiet ... 9 -> maximum diagnostic input

Method Detail

### handleMessagesFromCyc

    protected void handleMessagesFromCyc()

  Handles inbound asynchronous messages from Cyc-hosted agents. The process blocks while awaiting the next message.

### handleMessageFromCyc

    protected void handleMessageFromCyc(CycList fipaTransportMessage)

  Handles one inbound asynchronous message from a Cyc-hosted agent. Creates a CycAgentProxy object if the Cyc-hosted agent is new. Forwards the inbound message to the CycAgentProxy, which in turn forwards it to the agent community.
  Parameters:
    `fipaTransportMessage` - the message from a Cyc-hosted agent

### messageReceived

    public void messageReceived(int remoteAgentCommunity,
                                fipaos.ont.fipa.ACL acl)

  Notifies my agent that an Agent Communication Language message has been received.
  Overrides:
    `messageReceived` in class `GenericAgent`
  Parameters:
    `remoteAgentCommunity` - indicates either CoAbs or FIPA-OS agent community
    `acl` - the Agent Communication Language message which has been received for my agent

### processApiRequest

    public void processApiRequest(int remoteAgentCommunity,
                                  fipaos.ont.fipa.ACL apiRequestAcl)

  Processes a cyc api request from another agent.
  Parameters:
    `remoteAgentCommunity` - indicates either CoAbs or FIPA-OS agent community
    `apiRequestAcl` - the api request Agent Communication Language message

### setVerbosity

    public void setVerbosity(int verbosity)

  Sets verbosity of the output. 0 --> quiet ... 9 -> maximum diagnostic input.
  Overrides:
    `setVerbosity` in class `GenericAgent`
  Parameters:
    `verbosity` - 0 --> quiet ... 9 -> maximum diagnostic input