(This page is under construction)

Command Layer Definition

Command layer contains mechanism to make Cytoscape functions easily accessible from application layer. This layer should be separated from application layer and can be used in any mode: Desktop application, server version, and command line version.

Requirements

Command Usecases

From Plugins or Other Pre-Compiled Programs

From Interactive Shells

From Scripting Languages

Multiple Language Support

Functions Encapsulated as Command

In general, most of the classes in cytoscape.actions will be converted into Commands. In addition, some of the methods under the class cytoscape.Cytoscape will be encapsulated as command. Such as:

Design

   1 // Java
   2 CommandService.getCommand("command_name").execute();
   3 
   4 // Ruby
   5 CommandService.getCommand("command_name").execute
   6 

We can use similar design to Felix ShellService:

   1 package org.apache.felix.shell;
   2 
   3 public interface ShellService
   4 {
   5     public String[] getCommands();
   6     public String getCommandUsage(String name);
   7     public String getCommandDescription(String name);
   8     public ServiceReference getCommandReference(String name);
   9     public void executeCommand(
  10         String commandLine, PrintStream out, PrintStream err)
  11         throws Exception;
  12 }
  13 

Implementation

All commands should implement the following interface:

   1 public interface Command
   2 {
   3     public String getName();
   4     public void setParameter(String args[]);
   5     public void execute(String commandLine);
   6 }
   7 

Alternative API:

   1 public interface Command {
   2         
   3         public String getName();
   4         public String getDescription();
   5         
   6         public List<Object> execute(List<Object> args, List<Class<?>> argTypes);
   7 }
   8 

   1 public abstract class BasicCommand {
   2 
   3 
   4 }
   5 

Actual implementation of the Command looks like the following:

   1 public class ImportGraphFileCommand extends Command {
   2     // Wrapping CytoscapeActions with Command
   3 }
   4 

Exporting OSGi Service by Spring-DM

If we use one command = one OSGi service style design, we can use [http://www.springframework.org/osgi Spring Dynamic Module] for managing service import/export.

<bean name="importGraphFileCommandService"
                class="org.cytoscape.command.impl.ImportGraphFileCommandService" />

<osgi:service auto-export="interfaces" ref="importGraphFileCommandService" />

And Command Manager will be a class to holds a OSGi Service Tracker:

   1 public final class CommandManager implements BundleActivator {
   2 
   3         private ServiceTracker commandServiceTracker;
   4 
   5         public Command getCommand(final String commandName){
   6             //returns the command using Service Tracker
   7         }
   8 
   9         public void start(BundleContext bundleContext) throws Exception {
  10                 commandServiceTracker = new ServiceTracker(bundleContext, Command.class
  11                                 .getName(), null) {
  12                         @Override
  13                         public Object addingService(ServiceReference serviceReference) {
  14                                 Command command = (Command) super.addingService(serviceReference);
  15                                 return command;
  16                         }
  17                 };
  18 
  19                 commandServiceTracker.open();
  20                 
  21         }
  22 
  23         public void stop(BundleContext bundleContext) throws Exception {
  24                 commandServiceTracker.close();
  25         }
  26 }
  27 

OSGi Service

Dynamic Language Support on JVM

Funding for Cytoscape is provided by a federal grant from the U.S. National Institute of General Medical Sciences (NIGMS) of the Na tional Institutes of Health (NIH) under award number GM070743-01. Corporate funding is provided through a contract from Unilever PLC.

MoinMoin Appliance - Powered by TurnKey Linux