You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@celix.apache.org by 陈坤家 <ju...@163.com> on 2024/08/02 10:22:00 UTC

[Help] C++Implementation Example of Service on Demand (SOD) Pattern

Dear Celix Community,


I am currently working on a project using Apache Celix, and I am encountering some difficulties related to implementing the Service-on-Demand (SOD) pattern in C++. I am looking for an example of how to implement a consumer bundle (PLC1/PLC2) that interacts with a service bundle (Pou) using C++. Specifically, I need: 

C++ implementation example with SOD similar to the whiteboard pattern example provided in link2

(Can you tell me how to make changes based on the example I provided)




The specific requirements for my project are as follows:

The Pou bundle should have two instances that independently serve the PLC1 and PLC2 bundles.
For example, if the Pou bundle has a variable count = 0, then calling an interface from PLC1 or PLC2 should increment count appropriately, as demonstrated below:
PLC1 call: count = count + 1 = 1
PLC1 call: count = count + 1 = 2
PLC2 call: count = count + 1 = 1

Both PLC bundles should be able to call the Pou bundle's service simultaneously.




My project repository is available at https://github.com/tonychen0924/CelixTest/tree/main/unitDemo15

Ref:
link1:https://github.com/apache/celix/blob/master/documents/patterns.md#service-on-demand-sod-pattern
link2:https://github.com/apache/celix/tree/master/examples/celix-examples/services_example_cxx
link3:https://github.com/apache/celix/tree/master/bundles/logging/log_admin
link4:https://github.com/apache/celix/tree/master/bundles/logging/log_helper

Thank you for your assistance.


Best regards,
[tony chen]





| |
陈坤家
|
|
junjiechen0924@163.com
|

Re: [Help] C++Implementation Example of Service on Demand (SOD) Pattern

Posted by Peng Zheng <pe...@apache.org>.
On 2024/8/2 18:22, 陈坤家 wrote:
> Dear Celix Community,
> 
> 
> I am currently working on a project using Apache Celix, and I am encountering some difficulties related to implementing the Service-on-Demand (SOD) pattern in C++. I am looking for an example of how to implement a consumer bundle (PLC1/PLC2) that interacts with a service bundle (Pou) using C++. Specifically, I need:
> 
> C++ implementation example with SOD similar to the whiteboard pattern example provided in link2
> 
> (Can you tell me how to make changes based on the example I provided)

If you can not figure out how to do it after reading source code of log 
admin, then this pattern is not suitable for you.

You may consider C per-bundle service factory instead, check 
TEST_F(CxxBundleContextTestSuite, CheckStandardServiceProperties).

If you insists that C service is not acceptable, then it is quite 
unfortunate that C++ service factory is unimplemented yet. I am not sure 
when it will be implemented, since I am mostly a user the C interface.

Note that it will always be welcome to send us a patch implementing this 
feature.

Regards,
-- 
Peng Zheng