Hi,

I'm not a micro service specialist but I guess you don't link to 
CppMicroServices? However, this is strange as I assume you already link 
CppMicroServices (directly or indirectly through a core dependency) to your 
module A and you made your plugins in their CMakeLists.txt dependent on your 
module A?

Regarding my last mail: To get service references you should use the module 
context of the calling module, not the module context of the module which 
provides the service. See my code examples in the last mail, where I use the 
plugin's context: I do not have to call GetModule() at all. While this approach 
is "more correct" than Miklos' shortcut, I'm sure Sascha has an even better 
solution. Maybe based on service tracking magic. I put him on Cc explicitly. 
Let's see. ;)

Best,
Stefan
 
________________________________________
Von: Clarkson, Matt [[email protected]]
Gesendet: Montag, 31. März 2014 09:25
An: MITK
Betreff: [mitk-users] Accessing Micro Service from 2 plugins

Hi there,

following from Miklos and Stefan’s discussion, we now have a plugin that 
registers IPropertyExtensions on various properties. Im still not sure I 
understand this comment from Stefan:
http://sourceforge.net/p/mitk/mailman/message/32166243/

so, if anyone had time to expand on that, I would be grateful.

So, imagine I have some functionality I want to expose as a microservice. So, 
it would be a Service A, in Module B, and I want to use it from Plugins C and D.
I have created my service and activator with blank default methods just to see 
if it all compiles.

Then, in my first plugin (Plugin C in this example) I put:


      us::ModuleContext* niftkCoreGuiContext = 
us::ModuleRegistry::GetModule("niftkCoreGui")->GetModuleContext();

      us::ServiceReference<QmitkLookupTableProviderService> ref = 
niftkCoreGuiContext->GetServiceReference<QmitkLookupTableProviderService>();

      QmitkLookupTableProviderService* lutService = 
us::GetModuleContext()->GetService<QmitkLookupTableProviderService>(ref);


and I get:

Linking CXX shared library 
../../../../../bin/plugins/libuk_ac_ucl_cmic_gui_qt_commonapps.dylib
Undefined symbols for architecture x86_64:
  "us::GetModuleContext()", referenced from:
      
QmitkCommonAppsApplicationPlugin::RegisterImageRenderingModeProperties(std::string
 const&, mitk::DataNode*) in QmitkCommonAppsApplicationPlugin.cxx.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ma


which I find odd, as Miklo’s code


  us::ModuleContext* mitkCoreContext = 
us::ModuleRegistry::GetModule(1)->GetModuleContext();


is in the same class, and works!

What did I miss?

Thanks

Matt


------------------------------------------------------------------------------
_______________________________________________
mitk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mitk-users

Reply via email to