Permalink
Browse files

Added simple mock Java integration service for LCA and ant target to …

…start
  • Loading branch information...
1 parent aff8368 commit 84c475736d7985bad7e0bfbffd390ce468556606 Michael Meisinger committed Aug 4, 2010
View
@@ -2,7 +2,7 @@
LCAarch - OOI Release 1 LCA architecture prototype
==================================================
-April 2010 - May 2010
+April 2010 - August 2010
This project provides a service framwork and auxilliary functions for running
architecturally complete, but functionally limited versions of all the
@@ -19,7 +19,7 @@ http://www.oceanobservatories.org/spaces/display/CIDev/LCAARCH+Development+Proje
LCAarch is compatible with Python 2.5 and higher, but not Python 3.x
This project has as dependencies Magnet, Carrot, txAMQP, Twisted and pycassa,
-and msgpack
+and msgpack, pydap, simplejson
(see below)
Get LCAarch with
@@ -42,7 +42,7 @@ Start system by executing within the CC shell:
from ion.core import bootstrap
bootstrap.start()
-Alternatively from shell executing a script:
+Alternatively (better) from UNIX shell executing a script:
::
twistd -n magnet -h amoeba.ucsd.edu res/scripts/bootstrap.py
twistd -n magnet -h amoeba.ucsd.edu res/scripts/newcc.py
View
@@ -59,6 +59,22 @@
</exec>
</target>
+ <target name="javalca" depends=""
+ description="start Python CC with Java Integration LCA Demo" >
+ <!-- Run new empty capability container without shell -->
+ <echo message="Starting ION PyCC with sysname=${user.name}"/>
+ <exec executable="twistd">
+ <arg value="-n"/>
+ <arg value="magnet"/>
+ <arg value="-h"/>
+ <arg value="amoeba.ucsd.edu"/>
+ <arg value="-a"/>
+ <arg value="sysname=${user.name}"/>
+ <arg value="-n"/>
+ <arg value="res/scripts/javalca.py"/>
+ </exec>
+ </target>
+
<target name="test" depends="clean"
description="exdecutes all trial unit test cases" >
<exec executable="trial">
View
No changes.
View
No changes.
@@ -0,0 +1,89 @@
+#!/usr/bin/env python
+
+"""
+@file ion/demo/javaint_service.py
+@author Michael Meisinger
+@brief Java service integration service for R1 LCA.
+"""
+
+import logging
+logging = logging.getLogger(__name__)
+from twisted.internet import defer
+from magnet.spawnable import Receiver
+
+import ion.util.procutils as pu
+from ion.core.base_process import ProtocolFactory
+from ion.services.base_service import BaseService, BaseServiceClient
+
+class JavaIntegrationService(BaseService):
+ """
+ Example service interface
+ """
+ # Declaration of service
+ declare = BaseService.service_declare(name='javaint',
+ version='0.1.0',
+ dependencies=[])
+
+ def __init__(self, receiver, spawnArgs=None):
+ # Service class initializer. Basic config, but no yields allowed.
+ BaseService.__init__(self, receiver, spawnArgs)
+ logging.info('JavaIntegrationService.__init__()')
+
+ def slc_init(self):
+ # Service life cycle state. Initialize service here. Can use yields.
+ self.instruments = ["SBE49_1","SBE49_2"]
+ self.datasets = []
+ self.services = {'Service1':{'key1':'val1','key2':'val2'},'Service2':{'key1':'val3','key2':'val4'}}
+
+ @defer.inlineCallbacks
+ def op_hello(self, content, headers, msg):
+ logging.info('op_hello: '+str(content))
+
+ # The following line shows how to reply to a message
+ yield self.reply_ok(msg, {'value':'Hello there, '+str(content)}, {})
+
+ @defer.inlineCallbacks
+ def op_list_all_instruments(self, content, headers, msg):
+ logging.info('op_list_all_instruments: '+str(content))
+
+ # The following line shows how to reply to a message
+ yield self.reply_ok(msg, {'value':self.instruments})
+
+ @defer.inlineCallbacks
+ def op_register_instrument(self, content, headers, msg):
+ logging.info('op_register_instrument: '+str(content))
+
+ instname = str(content['InstName'])
+ if not instname in self.instruments:
+ self.instruments.append(instname)
+
+ # The following line shows how to reply to a message
+ yield self.reply_ok(msg)
+
+ @defer.inlineCallbacks
+ def op_list_all_datasets(self, content, headers, msg):
+ logging.info('op_list_all_datasets: '+str(content))
+
+ # The following line shows how to reply to a message
+ yield self.reply_ok(msg, {'value':self.datasets})
+
+ @defer.inlineCallbacks
+ def op_register_dataset(self, content, headers, msg):
+ logging.info('op_register_dataset: '+str(content))
+
+ dsname = str(content['DSName'])
+ if not dsname in self.datasets:
+ self.datasets.append(dsname)
+
+ # The following line shows how to reply to a message
+ yield self.reply_ok(msg)
+
+ @defer.inlineCallbacks
+ def op_list_all_services(self, content, headers, msg):
+ logging.info('op_list_all_services: '+str(content))
+
+ # The following line shows how to reply to a message
+ yield self.reply_ok(msg, {'value':self.services})
+
+# Spawn of the process using the module name
+factory = ProtocolFactory(JavaIntegrationService)
@@ -2,7 +2,6 @@
"""
@file ion/play/hello_service.py
-@package ion.play.hello_service Sample code to get you started.
@author Michael Meisinger
@brief An example service definition that can be used as template.
"""
View
@@ -0,0 +1,34 @@
+# Python Capability Container start script.
+# Starts container with Java Services.
+
+import logging
+from twisted.internet import defer
+
+from ion.core import ioninit
+from ion.core import bootstrap
+from ion.util.config import Config
+
+# Use the bootstrap configuration entries from the standard bootstrap
+CONF = ioninit.config('ion.core.bootstrap')
+
+# Config files with lists of processes to start
+agent_procs = ioninit.get_config('ccagent_cfg', CONF)
+demo_procs = [
+ {'name':'javaint','module':'ion.demo.lca.javaint_service','class':'JavaIntegrationService'},
+]
+
+@defer.inlineCallbacks
+def main():
+ """
+ Initializes container
+ """
+ logging.info("ION CONTAINER initializing... [LCA Java Integration Demo]")
+
+ processes = []
+ processes.extend(agent_procs)
+ processes.extend(demo_procs)
+
+ # Start the processes
+ sup = yield bootstrap.bootstrap(None, processes)
+
+main()

0 comments on commit 84c4757

Please sign in to comment.