Skip to content

Commit b50159c

Browse files
committed
Refactor imports and enhance type annotations in business operation and director modules
1 parent 0f4b8bd commit b50159c

File tree

7 files changed

+512
-502
lines changed

7 files changed

+512
-502
lines changed

src/iop/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
from iop._business_service import _BusinessService
2-
from iop._business_process import _BusinessProcess
3-
from iop._private_session_duplex import _PrivateSessionDuplex
4-
from iop._private_session_process import _PrivateSessionProcess
51
from iop._business_operation import _BusinessOperation
2+
from iop._business_process import _BusinessProcess
3+
from iop._business_service import _BusinessService
4+
from iop._director import _Director
65
from iop._inbound_adapter import _InboundAdapter
7-
from iop._outbound_adapter import _OutboundAdapter
86
from iop._message import _Message
7+
from iop._outbound_adapter import _OutboundAdapter
98
from iop._pickle_message import _PickleMessage
10-
from iop._director import _Director
9+
from iop._private_session_duplex import _PrivateSessionDuplex
10+
from iop._private_session_process import _PrivateSessionProcess
1111
from iop._utils import _Utils
1212

1313
class Utils(_Utils): pass

src/iop/_business_host.py

Lines changed: 253 additions & 220 deletions
Large diffs are not rendered by default.

src/iop/_business_operation.py

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,40 @@
11
import importlib
2+
from typing import Any, List, Optional, Union, Tuple
23
from iop._business_host import _BusinessHost
34

45
class _BusinessOperation(_BusinessHost):
5-
""" This class corresponds to the PEX framework EnsLib.PEX.BusinessOperation class.
6-
The EnsLib.PEX.BusinessOperation RemoteClassName property identifies the Python class with the business operation implementation.
7-
The business operation can optionally use an adapter to handle the outgoing message. Specify the adapter in the OutboundAdapter property.
8-
If the business operation has an adapter, it uses the adapter to send the message to the external system.
9-
The adapter can either be a PEX adapter or an ObjectScript adapter.
6+
"""Business operation component that handles outbound communication.
7+
8+
Responsible for sending messages to external systems. Can optionally use an
9+
adapter to handle the outbound messaging protocol.
1010
"""
1111

12-
DISPATCH = []
13-
Adapter = adapter = None
12+
DISPATCH: List[Tuple[str, str]] = []
13+
Adapter: Any = None
14+
adapter: Any = None
1415

15-
def on_message(self, request):
16-
""" Called when the business operation receives a message from another production component.
17-
Typically, the operation will either send the message to the external system or forward it to a business process or another business operation.
18-
If the operation has an adapter, it uses the Adapter.invoke() method to call the method on the adapter that sends the message to the external system.
19-
If the operation is forwarding the message to another production component, it uses the SendRequestAsync() or the SendRequestSync() method
20-
21-
Parameters:
22-
request: An instance of either a subclass of Message or of IRISObject containing the incoming message for the business operation.
16+
def on_message(self, request: Any) -> Any:
17+
"""Handle incoming messages.
18+
19+
Process messages received from other production components and either
20+
send to external system or forward to another component.
2321
22+
Args:
23+
request: The incoming message
24+
2425
Returns:
25-
The response object
26+
Response message
2627
"""
2728
return self.OnMessage(request)
2829

29-
def on_keepalive(self):
30+
def on_keepalive(self) -> None:
3031
"""
31-
> This function is called when the server sends a keepalive message
32+
Called when the server sends a keepalive message.
3233
"""
3334
return
3435

35-
def _set_iris_handles(self, handle_current, handle_partner):
36-
""" For internal use only. """
36+
def _set_iris_handles(self, handle_current: Any, handle_partner: Any) -> None:
37+
"""For internal use only."""
3738
self.iris_handle = handle_current
3839
if type(handle_partner).__module__.find('iris') == 0:
3940
if handle_partner._IsA("Grongier.PEX.OutboundAdapter") or handle_partner._IsA("IOP.OutboundAdapter"):
@@ -42,20 +43,20 @@ def _set_iris_handles(self, handle_current, handle_partner):
4243
self.Adapter = self.adapter = handle_partner
4344
return
4445

45-
def _dispatch_on_init(self, host_object):
46-
""" For internal use only. """
46+
def _dispatch_on_init(self, host_object: Any) -> None:
47+
"""For internal use only."""
4748
self._create_dispatch()
4849
self.on_init()
4950
return
5051

5152
@_BusinessHost.input_deserialzer
5253
@_BusinessHost.output_serialzer
53-
def _dispatch_on_message(self, request):
54-
""" For internal use only. """
54+
def _dispatch_on_message(self, request: Any) -> Any:
55+
"""For internal use only."""
5556
return self._dispach_message(request)
5657

57-
def OnMessage(self, request):
58-
""" DEPRECATED : use on_message
58+
def OnMessage(self, request: Any) -> Any:
59+
"""DEPRECATED : use on_message
5960
Called when the business operation receives a message from another production component.
6061
Typically, the operation will either send the message to the external system or forward it to a business process or another business operation.
6162
If the operation has an adapter, it uses the Adapter.invoke() method to call the method on the adapter that sends the message to the external system.
@@ -67,4 +68,4 @@ def OnMessage(self, request):
6768
Returns:
6869
The response object
6970
"""
70-
return
71+
return

0 commit comments

Comments
 (0)