Providing a service to other apps

9 views
Skip to first unread message

Thomas Pfau

unread,
Apr 26, 2016, 5:07:08 AM4/26/16
to cytoscap...@googlegroups.com
Hi,

I'm trying to provide generate an app that can load other plugins for
the app and was wondering, how I can register this app as a service to
the serviceregistry that is accessible by other apps.

Anyone got an idea how to do this?

Thanks in advance,

Thomas

--
Université du Luxembourg
Faculté des Sciences, de la Technologie et de la Communication
Campus Belval, Biotech II 423
6 avenue du Swing
L-4367 Belvaux
Tel: (+352) 46 66 44 5309
Email: thoma...@uni.lu

Scooter Morris

unread,
Apr 26, 2016, 10:39:38 AM4/26/16
to cytoscap...@googlegroups.com
Hi Thomas,
I'm not too sure what your app is doing, but you can certainly call
the registerService method in CyServiceRegistrar. That probably doesn't
help much because apps that one to use your app won't know that class to
look for, etc., so you will need to publish an API and apps will need to
compile against it.
My suggestion is to use the command api instead. Several of us use
that for calling methods in other apps -- they just export a set of
commands that they are willing to execute. In your app, all you would
need to do is to make sure you don't need a GUI for any of the tunables,
then just register the task factory like you usually would, except you
need to add the COMMAND_NAMESPACE and COMMAND properties
(COMMAND_DESCRIPTION is useful, too). The namespace is usually the name
of your app or function and all of your commands will use the same
namespace. Once you've done that, anyone who wants to use your app,
including command scripts and REST users, by the way, can just execute
the commands. The tunables in your task become the arguments to the
commands (so name them carefully). Apps can see if your app is loaded
by using org.cytoscape.command.AvailableCommands and execute commands by
using org.cytoscape.command.CommandExecutorTaskFactory.

Hope this helps!

-- scooter

Thomas Pfau

unread,
Apr 27, 2016, 1:40:44 AM4/27/16
to cytoscap...@googlegroups.com
Hi,

Thanks for the info. I'll give a few more details to clarify my intended
use.
What I would like to do is to allow others to add additional
implementations for a set of interfaces. Those implementations should
then be accessed by the app.
In detail, I'm mapping multiple datasets to automatically layouted image
nodes on the network nodes and the layout depends on the type and
representation of the data in question.
So I would like to allow other users to implement a data representation
that can then be used by my app.
Therefore, (I think) the command API is not applicable in my instance.

However, when I tried to register my app with its class, it worked to
retrieve it within the same app

App app = new App(cySwingApp);
registerService(context, app, App.class, new Properties());
App app = getService(context, App.class);


But If I want to load it in a second app (to be able to add classes from
that 'plugin' to my app) I get a
java.lang.RuntimeException: Couldn't find service: myApp.App

I add the jar generated for my original app to the dependencies of the
other app and set it to provided, which seems to work, as I don't get a
"NoClassDefFound" exception, when just trying to initialize an empty
object for the App.

Any Idea what might go wrong here?

Best,

Thomas

Thomas Pfau

unread,
Apr 27, 2016, 5:11:57 AM4/27/16
to cytoscap...@googlegroups.com
I got it to work.

I originally forgot to remove the package of the original app from the
exported directory in the plugin pom, so it was looking for an
"internal" Class instead of the external one.
However, If I disable/reenable my app and consecutively disable/reenable
the plugin, I get the service not found error again.
I assume, that this is due to the existing link between the apps which
is not freed properly (as it is still needed by the other app).

Thus the next question woudl be: How can I programmatically disable any
app that depends on my app, when my app is disabled?

Best,

Thomas
Reply all
Reply to author
Forward
0 new messages