jigcell.compare.cellcycle
Class OAAConnector

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by jigcell.compare.ui.PanelTab
                      extended by jigcell.compare.cellcycle.OAAConnector
All Implemented Interfaces:
com.sri.oaa2.lib.OAAEventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.beans.PropertyChangeListener, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, ITab

public class OAAConnector
extends PanelTab
implements com.sri.oaa2.lib.OAAEventListener

A connector allowing the Comparator to be controlled through OAA requests.

This code is licensed under the DARPA BioCOMP Open Source License. See LICENSE for more details.

Author:
Nicholas Allen
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  java.lang.String agentName
          Agent name to expose
protected  bsh.Interpreter beanshell
          Interpreter for commands
static java.lang.String CONFIG_AGENTNAME
          Property key for agent name
protected static java.lang.String[][] DISPATCH_ARGUMENTS
          Argument lists for dispatch solvables
protected static java.lang.String FUNCTION_DISPATCH
          Start of function names for performing dispatches
protected static java.lang.String FUNCTION_EXECUTE
          Function name for executing a command
protected static java.lang.String FUNCTION_SENDFILE
          Function name for sending a file
protected static java.lang.String FUNCTION_SENDFILEPART
          Function name for sending part of a file
protected  com.sri.oaa2.lib.LibOaa myOaa
          OAA connection
protected static java.lang.String NAME_CALLBACK
          Name of the OAA callback method
protected static java.lang.String NAME_COMPARATOR
          Name of the dispatch target for the Comparator
protected static java.lang.String NAME_FACILITATOR
          Name of the facilitator connection ID
protected static java.lang.String NAME_FUNCTION
          Prefix name of a dispatch function
protected static java.lang.String NAME_VARIANT
          Prefix name of a dispatch function with multiple variants
protected  java.util.Map partWriters
          Currently open file parts
protected static java.util.regex.Pattern PATTERN_DISPATCH
          Pattern for matching a dispatch
protected static java.util.regex.Pattern PATTERN_VARIANT
          Pattern for matching a dispatch
protected static java.lang.String SOLVABLE_EXECUTE
          Solvable for executing a command
protected static java.lang.String SOLVABLE_SENDFILE
          Solvable for sending a file
protected static java.lang.String SOLVABLE_SENDFILEPART
          Solvable for sending part of a file
protected static java.lang.String TOKEN_ENDTERM
          Token marking the end of a term
protected static java.lang.String TOKEN_NEXTTERM
          Token marking the start of the next term
protected static java.lang.String TOKEN_STARTTERM
          Token marking the start of a term
protected static java.lang.String VARIABLE_COMPARE
          Variable to attach to compare
protected static java.lang.String VARIABLE_INSTANCE
          Variable to attach to a dispatch instance
protected static java.lang.String VARIABLE_METHOD
          Variable to attach to a dispatch method
 
Fields inherited from class jigcell.compare.ui.PanelTab
compare, configMarkers, PATH_ABOUT, PATH_DESCRIPTION_ABOUT, tabName
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface jigcell.compare.ITab
CONFIG_TABNAME, STATE_ENDINITIALIZE, STATE_ENDUI, STATE_INITIALIZE, STATE_RUNNING, STATES
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
OAAConnector(Compare compare, java.lang.String configMarker)
          Creates a new connector for receiving commands from OAA.
 
Method Summary
protected  java.lang.StringBuffer buildDispatch(int args, java.lang.String target, java.lang.String functor)
          Constructs a new dispatch solvable.
protected  java.lang.StringBuffer computeDispatches(java.util.Set dispatchNames, java.lang.String prefix, java.lang.Object o)
          Constructs a list of dispatch solvables that can be accessed from an object.
static com.sri.oaa2.lib.LibOaa connect(java.lang.String agentName)
          Creates an OAA connection suitable for sending commands through an OAAConnector.
static com.sri.oaa2.icl.IclList dispatch(com.sri.oaa2.lib.LibOaa myOaa, java.lang.String command, java.lang.String input, java.lang.String output)
          Dispatches a command through an OAAConnector.
protected  boolean doDispatch(java.lang.String functor, com.sri.oaa2.icl.IclTerm goal, com.sri.oaa2.icl.IclTerm answer)
          Performs a function dispatch in this Comparator.
protected  boolean doExecute(com.sri.oaa2.icl.IclTerm goal, com.sri.oaa2.icl.IclTerm answer)
          Executes a command in this Comparator.
 boolean doOAAEvent(com.sri.oaa2.icl.IclTerm goal, com.sri.oaa2.icl.IclList params, com.sri.oaa2.icl.IclList answers)
           
protected  boolean doSendFile(com.sri.oaa2.icl.IclTerm goal, com.sri.oaa2.icl.IclTerm answer, boolean part)
          Receives a file or part.
static com.sri.oaa2.icl.IclList execute(com.sri.oaa2.lib.LibOaa myOaa, java.lang.String command)
          Executes a command through an OAAConnector.
protected  java.lang.Object findInstanceForDispatch(java.lang.String tabName)
          Finds the object that should be dispatched against from the tab name or null if no object can be found.
protected  java.lang.reflect.Method findMethodForDispatch(java.lang.Object instance, java.lang.String methodName)
          Finds the method that should be dispatched against from the dispatch instance and method name or null if no method can be found.
protected  void initialize()
          Performs any initialization work for the view.
protected  java.lang.String mungeTabName(java.lang.String name)
          Converts a tab name into a solvable friendly form.
protected  void oaaConnect()
          Creates the OAA connection.
protected  void oaaDisconnect()
          Destroys the OAA connection.
protected  void oaaDisconnect(java.lang.String message, java.lang.Exception cause)
          Destroys the OAA connection.
static com.sri.oaa2.icl.IclList sendFile(com.sri.oaa2.lib.LibOaa myOaa, java.lang.String name, java.lang.String file)
          Sends a file through an OAAConnector.
protected static com.sri.oaa2.icl.IclList solve(com.sri.oaa2.lib.LibOaa myOaa, com.sri.oaa2.icl.IclTerm goal)
          Requests an OAA solvable.
 
Methods inherited from class jigcell.compare.ui.PanelTab
createAboutDialog, createAboutDialogForTab, createConfigEditor, createMenus, createTools, createUI, getCompare, getConfigForView, getConfigMarkers, getHostIdentifier, getName, propertyChange, readConfiguration
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CONFIG_AGENTNAME

public static final java.lang.String CONFIG_AGENTNAME
Property key for agent name

See Also:
Constant Field Values

PATTERN_DISPATCH

protected static final java.util.regex.Pattern PATTERN_DISPATCH
Pattern for matching a dispatch


PATTERN_VARIANT

protected static final java.util.regex.Pattern PATTERN_VARIANT
Pattern for matching a dispatch


DISPATCH_ARGUMENTS

protected static final java.lang.String[][] DISPATCH_ARGUMENTS
Argument lists for dispatch solvables


FUNCTION_DISPATCH

protected static final java.lang.String FUNCTION_DISPATCH
Start of function names for performing dispatches

See Also:
Constant Field Values

FUNCTION_EXECUTE

protected static final java.lang.String FUNCTION_EXECUTE
Function name for executing a command

See Also:
Constant Field Values

FUNCTION_SENDFILE

protected static final java.lang.String FUNCTION_SENDFILE
Function name for sending a file

See Also:
Constant Field Values

FUNCTION_SENDFILEPART

protected static final java.lang.String FUNCTION_SENDFILEPART
Function name for sending part of a file

See Also:
Constant Field Values

NAME_CALLBACK

protected static final java.lang.String NAME_CALLBACK
Name of the OAA callback method

See Also:
Constant Field Values

NAME_COMPARATOR

protected static final java.lang.String NAME_COMPARATOR
Name of the dispatch target for the Comparator

See Also:
Constant Field Values

NAME_FACILITATOR

protected static final java.lang.String NAME_FACILITATOR
Name of the facilitator connection ID

See Also:
Constant Field Values

NAME_FUNCTION

protected static final java.lang.String NAME_FUNCTION
Prefix name of a dispatch function

See Also:
Constant Field Values

NAME_VARIANT

protected static final java.lang.String NAME_VARIANT
Prefix name of a dispatch function with multiple variants

See Also:
Constant Field Values

SOLVABLE_EXECUTE

protected static final java.lang.String SOLVABLE_EXECUTE
Solvable for executing a command

See Also:
Constant Field Values

SOLVABLE_SENDFILE

protected static final java.lang.String SOLVABLE_SENDFILE
Solvable for sending a file

See Also:
Constant Field Values

SOLVABLE_SENDFILEPART

protected static final java.lang.String SOLVABLE_SENDFILEPART
Solvable for sending part of a file

See Also:
Constant Field Values

TOKEN_ENDTERM

protected static final java.lang.String TOKEN_ENDTERM
Token marking the end of a term

See Also:
Constant Field Values

TOKEN_NEXTTERM

protected static final java.lang.String TOKEN_NEXTTERM
Token marking the start of the next term

See Also:
Constant Field Values

TOKEN_STARTTERM

protected static final java.lang.String TOKEN_STARTTERM
Token marking the start of a term

See Also:
Constant Field Values

VARIABLE_COMPARE

protected static final java.lang.String VARIABLE_COMPARE
Variable to attach to compare

See Also:
Constant Field Values

VARIABLE_INSTANCE

protected static final java.lang.String VARIABLE_INSTANCE
Variable to attach to a dispatch instance

See Also:
Constant Field Values

VARIABLE_METHOD

protected static final java.lang.String VARIABLE_METHOD
Variable to attach to a dispatch method

See Also:
Constant Field Values

beanshell

protected bsh.Interpreter beanshell
Interpreter for commands


myOaa

protected com.sri.oaa2.lib.LibOaa myOaa
OAA connection


partWriters

protected java.util.Map partWriters
Currently open file parts


agentName

protected java.lang.String agentName
Agent name to expose

Constructor Detail

OAAConnector

public OAAConnector(Compare compare,
                    java.lang.String configMarker)
Creates a new connector for receiving commands from OAA.

Parameters:
compare - Comparator backend to interface with
configMarker - Marker for retrieving configuration information from Comparator backend
Method Detail

connect

public static com.sri.oaa2.lib.LibOaa connect(java.lang.String agentName)
Creates an OAA connection suitable for sending commands through an OAAConnector.

Parameters:
agentName - Name that other OAA clients will see you as

dispatch

public static com.sri.oaa2.icl.IclList dispatch(com.sri.oaa2.lib.LibOaa myOaa,
                                                java.lang.String command,
                                                java.lang.String input,
                                                java.lang.String output)
Dispatches a command through an OAAConnector.

Parameters:
myOaa - OAA library
command - Dispatch command
input - List of input variables or null if none
output - Name of output variable or null if none

execute

public static com.sri.oaa2.icl.IclList execute(com.sri.oaa2.lib.LibOaa myOaa,
                                               java.lang.String command)
Executes a command through an OAAConnector.

Parameters:
myOaa - OAA library
command - Command

sendFile

public static com.sri.oaa2.icl.IclList sendFile(com.sri.oaa2.lib.LibOaa myOaa,
                                                java.lang.String name,
                                                java.lang.String file)
Sends a file through an OAAConnector.

Parameters:
myOaa - OAA library
name - File name
file - File contents

solve

protected static com.sri.oaa2.icl.IclList solve(com.sri.oaa2.lib.LibOaa myOaa,
                                                com.sri.oaa2.icl.IclTerm goal)
Requests an OAA solvable.

Parameters:
myOaa - OAA library
goal - Goal

doOAAEvent

public boolean doOAAEvent(com.sri.oaa2.icl.IclTerm goal,
                          com.sri.oaa2.icl.IclList params,
                          com.sri.oaa2.icl.IclList answers)
Specified by:
doOAAEvent in interface com.sri.oaa2.lib.OAAEventListener

buildDispatch

protected java.lang.StringBuffer buildDispatch(int args,
                                               java.lang.String target,
                                               java.lang.String functor)
Constructs a new dispatch solvable.

Parameters:
args - Number of optional arguments
target - Dispatch target name
functor - Function name and argument list

computeDispatches

protected java.lang.StringBuffer computeDispatches(java.util.Set dispatchNames,
                                                   java.lang.String prefix,
                                                   java.lang.Object o)
Constructs a list of dispatch solvables that can be accessed from an object.

Parameters:
dispatchNames - Existing list of dispatch names
prefix - Prefix for object solvable names
o - Object

doDispatch

protected boolean doDispatch(java.lang.String functor,
                             com.sri.oaa2.icl.IclTerm goal,
                             com.sri.oaa2.icl.IclTerm answer)
Performs a function dispatch in this Comparator.

Parameters:
functor - Munged function name to dispatch
goal - OAA goal
answer - Response to command

doExecute

protected boolean doExecute(com.sri.oaa2.icl.IclTerm goal,
                            com.sri.oaa2.icl.IclTerm answer)
Executes a command in this Comparator.

Parameters:
goal - OAA goal
answer - Response to command

doSendFile

protected boolean doSendFile(com.sri.oaa2.icl.IclTerm goal,
                             com.sri.oaa2.icl.IclTerm answer,
                             boolean part)
Receives a file or part.

Parameters:
goal - OAA goal
answer - Response to command
part - Whether this is a part or complete file

findInstanceForDispatch

protected java.lang.Object findInstanceForDispatch(java.lang.String tabName)
Finds the object that should be dispatched against from the tab name or null if no object can be found.

Parameters:
tabName - Tab name

findMethodForDispatch

protected java.lang.reflect.Method findMethodForDispatch(java.lang.Object instance,
                                                         java.lang.String methodName)
Finds the method that should be dispatched against from the dispatch instance and method name or null if no method can be found.

Parameters:
instance - Dispatch instance
methodName - Method name

initialize

protected void initialize()
Performs any initialization work for the view.

Overrides:
initialize in class PanelTab

mungeTabName

protected java.lang.String mungeTabName(java.lang.String name)
Converts a tab name into a solvable friendly form.

Parameters:
name - Tab name

oaaConnect

protected void oaaConnect()
Creates the OAA connection.


oaaDisconnect

protected void oaaDisconnect()
Destroys the OAA connection.


oaaDisconnect

protected void oaaDisconnect(java.lang.String message,
                             java.lang.Exception cause)
Destroys the OAA connection.

Parameters:
message - Information message about error situation
cause - Why the connection is being destroyed