Skip to content

Commit

Permalink
Implement just enough from framework.service for a JC sample to insta…
Browse files Browse the repository at this point in the history
…ll itself
  • Loading branch information
benallard committed Jun 8, 2011
1 parent 9db11ed commit 21dad63
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 0 deletions.
3 changes: 3 additions & 0 deletions python/rmi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@

class RemoteException(IOException):
pass

class Remote(object):
pass
25 changes: 25 additions & 0 deletions pythoncard/framework/service/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from pythoncard.framework import CardRuntimeException

class ServiceException(CardRuntimeException):
CANNOT_ACCESS_IN_COMMAND = 4
CANNOT_ACCESS_OUT_COMMAND = 5
COMMAND_DATA_TOO_LONG = 3
COMMAND_IS_FINISHED = 6
DISPATCH_TABLE_FULL = 2
ILLEGAL_PARAM = 1
REMOTE_OBJECT_NOT_EXPORTED = 7

class Service(object):
pass

from pythoncard.framework.service import cardremoteobject
CardRemoteObject = cardremoteobject.CardRemoteObject

from pythoncard.framework.service import dispatcher
Dispatcher = dispatcher.Dispatcher

from pythoncard.framework.service import basicservice
BasicService = basicservice.BasicService

from pythoncard.framework.service import rmiservice
RMIService = rmiservice.RMIService
4 changes: 4 additions & 0 deletions pythoncard/framework/service/basicservice.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from pythoncard.framework.service import Service

class BasicService(Service):
pass
4 changes: 4 additions & 0 deletions pythoncard/framework/service/cardremoteobject.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from python.rmi import Remote

class CardRemoteObject(Remote):
pass
24 changes: 24 additions & 0 deletions pythoncard/framework/service/dispatcher.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from pythoncard.framework.service import ServiceException

class Dispatcher(object):
PROCESS_COMMAND = 2
PROCESS_INPUT_DATA = 1
PROCESS_NONE = 0
PROCESS_OUTPUT_DATA = 3

def __init__(self, maxServices):
if maxServices < 0:
raise ServiceException(ServiceException.ILLEGAL_PARAM)
self.services = {Dispatcher.PROCESS_INPUT_DATA : [],
Dispatcher.PROCESS_COMMAND : [],
Dispatcher.PROCESS_OUTPUT_DATA : [],
Dispatcher.PROCESS_NONE: []}

def addService(self, service, phase):
if service is None:
raise ServiceException(ServiceException.ILLEGAL_PARAM)
try:
self.services[phase].append(service)
except KeyError:
raise ServiceException(ServiceException.ILLEGAL_PARAM)

5 changes: 5 additions & 0 deletions pythoncard/framework/service/rmiservice.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from pythoncard.framework.service import BasicService

class RMIService(BasicService):
def __init__(self, initialObject):
self.initialObject = initialObject

0 comments on commit 21dad63

Please sign in to comment.